diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index 85222a4f5..583be190c 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -96,7 +96,7 @@ BOOL STORMAPI SBltROP3Tiled(void *lpDstBuffer, RECT *lpDstRect, POINT *lpDstPt, BOOL STORMAPI SBmpDecodeImage(DWORD dwImgType, void *pSrcBuffer, DWORD dwSrcBuffersize, PALETTEENTRY *pPalette, void *pDstBuffer, DWORD dwDstBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; -BOOL STORMAPI SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *dwHeight, DWORD *pdwBpp) rBool; +BOOL STORMAPI SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) rBool; BOOL STORMAPI SBmpSaveImage(const char*, PALETTEENTRY*, void*, DWORD, DWORD, DWORD) rBool; HANDLE STORMAPI SBmpAllocLoadImage(const char *fileName, PALETTEENTRY *palette, void **buffer, int *width, int *height, int unused6, int unused7, void *(STORMAPI *allocFunction)(DWORD)) rPVoid; diff --git a/CMake/cotire.cmake b/CMake/cotire.cmake deleted file mode 100644 index 97275d649..000000000 --- a/CMake/cotire.cmake +++ /dev/null @@ -1,4190 +0,0 @@ -# - cotire (compile time reducer) -# -# See the cotire manual for usage hints. -# -#============================================================================= -# Copyright 2012-2018 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.8.0") - -# 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() - get_source_file_property(_sourceCompileOptions "${_sourceFile}" COMPILE_OPTIONS) - if (_sourceCompileOptions) - # add to excluded sources, if file has list of custom compile options - list (APPEND _excludedSourceFiles "${_sourceFile}") - else() - list (APPEND _sourceFiles "${_sourceFile}") - endif() - 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 do not 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() - if (WIN32) - file (TO_NATIVE_PATH "${_compilerExe}" _compilerExe) - 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 produces different output, 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]:[^:]+)$") - 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() - # add source files to be scanned - if (WIN32) - foreach (_sourceFile ${_existingSourceFiles}) - file (TO_NATIVE_PATH "${_sourceFile}" _sourceFileNative) - list (APPEND _cmd "${_sourceFileNative}") - endforeach() - else() - list (APPEND _cmd ${_existingSourceFiles}) - endif() - if (COTIRE_VERBOSE) - message (STATUS "execute_process: ${_cmd}") - endif() - if (MSVC_IDE OR _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) - if (WIN32) - file (TO_NATIVE_PATH "${_unparsedLinesFile}" _unparsedLinesLogPath) - else() - set (_unparsedLinesLogPath "${_unparsedLinesFile}") - endif() - message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesLogPath}") - endif() - string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") - endif() - file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}\n") -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") - if (UNIX) - # Clang options used - # -H print the name of each header file used - # -E invoke preprocessor - # -fno-color-diagnostics do not print diagnostics in color - # -Eonly just run preprocessor, no output - if (_flags) - # append to list - list (APPEND _flags -H -E -fno-color-diagnostics -Xclang -Eonly) - else() - # return as a flag string - set (_flags "-H -E -fno-color-diagnostics -Xclang -Eonly") - endif() - elseif (WIN32) - # Clang-cl.exe options used - # /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 - # -H print the name of each header file used - # -fno-color-diagnostics do not print diagnostics in color - # -Eonly just run preprocessor, no output - set (_sourceFileTypeC "/TC") - set (_sourceFileTypeCXX "/TP") - if (_flags) - # append to list - list (APPEND _flags "${_sourceFileType${_language}}" /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly) - else() - # return as a flag string - set (_flags "${_sourceFileType${_language}} /EP -fno-color-diagnostics -Xclang -H -Xclang -Eonly") - endif() - 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") - # GCC 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 "Clang") - if (UNIX) - # Clang options used - # -x specify the source language - # -c compile but do not link - # -o place output in file - # -fno-pch-timestamp disable inclusion of timestamp in precompiled headers (clang 4.0.0+) - 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}") - if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") - list (APPEND _flags -Xclang -fno-pch-timestamp) - endif() - else() - # return as a flag string - set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") - if (NOT "${_compilerVersion}" VERSION_LESS "4.0.0") - set (_flags "${_flags} -Xclang -fno-pch-timestamp") - endif() - endif() - elseif (WIN32) - # Clang-cl.exe options used - # /Yc creates a precompiled header file - # /Fp specifies precompiled header binary file name - # /FI forces inclusion of file - # /Zs syntax check only - # /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 - set (_sourceFileTypeC "/TC") - set (_sourceFileTypeCXX "/TP") - if (_flags) - # append to list - list (APPEND _flags "${_sourceFileType${_language}}" - "/Yc${_prefixFile}" "/Fp${_pchFile}" "/FI${_prefixFile}" /Zs "${_hostFile}") - else() - # return as a flag string - set (_flags "/Yc\"${_prefixFile}\" /Fp\"${_pchFile}\" /FI\"${_prefixFile}\"") - endif() - 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") - if (UNIX) - # Clang options used - # -include process include file as the first line of the primary source file - # note: ccache requires the -include flag to be used in order to process precompiled header correctly - if (_flags) - # append to list - list (APPEND _flags -include "${_prefixFile}") - else() - # return as a flag string - set (_flags "-include \"${_prefixFile}\"") - endif() - elseif (WIN32) - # Clang-cl.exe options used - # /Yu uses a precompiled header file during build - # /Fp specifies precompiled header binary file name - # /FI forces inclusion of file - if (_pchFile) - if (_flags) - # append to list - list (APPEND _flags "/Yu${_prefixFile}" "/Fp${_pchFile}" "/FI${_prefixFile}") - else() - # return as a flag string - set (_flags "/Yu\"${_prefixFile}\" /Fp\"${_pchFile}\" /FI\"${_prefixFile}\"") - endif() - else() - # no precompiled header, force inclusion of prefix header - if (_flags) - # append to list - list (APPEND _flags "/FI${_prefixFile}") - else() - # return as a flag string - set (_flags "/FI\"${_prefixFile}\"") - endif() - endif() - 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 (MSVC_IDE OR _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 "Clang" AND _option_COMPILER_VERSION VERSION_LESS "4.0.0") - if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR - _option_COMPILER_EXECUTABLE MATCHES "ccache") - # Newer versions of Clang 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") - # PCH 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") - if (UNIX) - # all Unix Clang versions have PCH support - set (${_msgVar} "" PARENT_SCOPE) - elseif (WIN32) - # only clang-cl is supported under Windows - get_filename_component(_compilerName "${CMAKE_${_language}_COMPILER}" NAME_WE) - if (NOT _compilerName MATCHES "cl$") - set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}. Use clang-cl instead." PARENT_SCOPE) - endif() - endif() - 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() - # check if ccache is used as a compiler launcher - get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) - get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" REALPATH) - if (_realCompilerExe MATCHES "ccache" OR _launcher MATCHES "ccache") - # verify that ccache configuration is compatible with precompiled headers - # always check environment variable CCACHE_SLOPPINESS, because earlier versions of ccache - # do not report the "sloppiness" setting correctly upon printing ccache configuration - 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 (_realCompilerExe MATCHES "ccache") - set (_ccacheExe "${_realCompilerExe}") - else() - set (_ccacheExe "${_launcher}") - 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) - set (${_msgVar} "ccache configuration cannot be determined." PARENT_SCOPE) - elseif (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" OR - (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) - # for MSVC, Intel and Clang-cl, 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" OR - (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) - # for MSVC, Intel and clang-cl, 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 MSVC, Intel and clang-cl, 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" AND NOT - (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) - 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 cl.exe 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() - if (_disableMsg) - set (_targetMsg "${_targetMsg} ${_disableMsg}") - 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() - if (_targetAddSCU) - # disable unity builds if automatic Qt processing is used - 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 (_disableMsg) - set (_disableMsg "${_disableMsg} Target uses automatic CMake Qt processing.") - else() - set (_disableMsg "Target uses automatic CMake Qt processing.") - endif() - set (_targetAddSCU 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]*)") - if (DEFINED CMAKE_MATCH_2) - set (_numberOfThreads "${CMAKE_MATCH_2}") - else() - set (_numberOfThreads "") - endif() - 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" AND NOT - (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "Clang")) - # MSVC, Intel and clang-cl 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() - # handle object libraries which are part of the target's sources - 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) - # 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() - # 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 BUILD_WITH_INSTALL_NAME_DIR - 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) - # copy CUDA platform specific stuff - cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} - CUDA_PTX_COMPILATION CUDA_SEPARABLE_COMPILATION CUDA_RESOLVE_DEVICE_SYMBOLS - CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED) - # 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() - # enable parallel compilation for MSVC - if (MSVC AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") - list (LENGTH _unityTargetSources _numberOfUnityTargetSources) - if (_numberOfUnityTargetSources GREATER 1) - set_property(TARGET ${_unityTargetName} APPEND PROPERTY COMPILE_OPTIONS "/MP") - 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() - get_target_property(_manualDependencies ${_target} MANUALLY_ADDED_DEPENDENCIES) - if (_manualDependencies) - cotire_map_libraries("${_linkLibrariesStrategy}" _unityManualDependencies ${_manualDependencies}) - if (_unityManualDependencies) - add_dependencies("${_unityTargetName}" ${_unityManualDependencies}) - 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 "2" 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 2." - ) - - 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/mingwcc.cmake b/CMake/mingwcc.cmake index 9e512f2fd..3e592e994 100644 --- a/CMake/mingwcc.cmake +++ b/CMake/mingwcc.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.13) - SET(CROSS_PREFIX "/usr" CACHE STRING "crosstool-NG prefix") SET(CMAKE_SYSTEM_NAME Windows) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74adde140..78734f420 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.12) include(CMake/out_of_tree.cmake) @@ -6,32 +6,39 @@ project(devilutionX VERSION 0.0.1 LANGUAGES C CXX) +list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake") + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Debug") endif() option(ASAN "Enable address sanitizer" ON) option(DEBUG "Enable debug mode in engine" ON) -option(COTIRE "Enable cotire" OFF) option(DIST "Dynamically link only glibc and SDL2" OFF) option(FASTER "Enable FASTER in engine" ON) option(BINARY_RELEASE "Enable options for binary release" OFF) +option(NIGHTLY_BUILD "Enable options for nightly build" OFF) if(BINARY_RELEASE) set(CMAKE_BUILD_TYPE "Release") set(ASAN OFF) set(DEBUG OFF) - set(COTIRE OFF) set(DIST ON) set(FASTER OFF) endif() +if(NIGHTLY_BUILD) + set(CMAKE_BUILD_TYPE "Debug") + set(ASAN OFF) + set(DEBUG ON) + set(DIST ON) + set(FASTER ON) +endif() + if(DIST) set(sodium_USE_STATIC_LIBS ON) endif() -list(APPEND CMAKE_MODULE_PATH "${devilutionX_SOURCE_DIR}/CMake") - set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) @@ -43,10 +50,6 @@ if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4) message(WARNING [[Not 32-bit, highly experimental!]]) endif() -if(COTIRE) - include(CMake/cotire.cmake) -endif() - find_package(Threads REQUIRED) find_package(SDL2 REQUIRED) find_package(SDL2_ttf REQUIRED) @@ -150,19 +153,20 @@ add_library(devilution OBJECT Source/track.cpp Source/trigs.cpp Source/wave.cpp) -target_include_directories(devilution PRIVATE SourceS) add_executable(devilutionx SourceX/dx.cpp SourceX/miniwin/misc.cpp SourceX/miniwin/misc_io.cpp SourceX/miniwin/misc_msg.cpp + SourceX/miniwin/misc_dx.cpp SourceX/miniwin/rand.cpp SourceX/miniwin/thread.cpp - SourceX/miniwin_dsound.cpp + SourceX/miniwin/dsound.cpp SourceX/sound.cpp - SourceX/storm.cpp - SourceX/storm_net.cpp + SourceX/storm/storm.cpp + SourceX/storm/storm_net.cpp + SourceX/storm/storm_dx.cpp SourceX/dvlnet/abstract_net.cpp SourceX/dvlnet/loopback.cpp SourceX/dvlnet/packet.cpp @@ -182,16 +186,20 @@ add_executable(devilutionx SourceX/DiabloUI/title.cpp SourceX/main.cpp) -target_include_directories(devilutionx PRIVATE SourceS SourceX 3rdParty/asio/include .) +target_include_directories(devilution PUBLIC Source SourceS) +target_include_directories(devilutionx PRIVATE + SourceX + 3rdParty/asio/include + 3rdParty/Radon/Radon/include + 3rdParty/libsmacker) -target_link_libraries(devilution PRIVATE Threads::Threads) +target_link_libraries(devilution PUBLIC Threads::Threads) target_link_libraries(devilutionx PRIVATE devilution PKWare StormLib smacker Radon - Threads::Threads SDL2::SDL2main SDL2::SDL2_ttf SDL2::SDL2_mixer @@ -203,10 +211,8 @@ target_compile_definitions(devilution PUBLIC "$<$:_DEBUG>" # Skip fades and other fluff "$<$:FASTER>") +target_compile_definitions(devilutionx PRIVATE ASIO_STANDALONE) -target_compile_definitions(devilutionx PUBLIC ASIO_STANDALONE) - -# Enable ASAN in Debug mode if(ASAN) target_compile_options(devilution PUBLIC -fsanitize=address -fsanitize-recover=address) target_link_libraries(devilution PUBLIC -fsanitize=address -fsanitize-recover=address) @@ -217,15 +223,14 @@ if(DIST) endif() if(WIN32) - cmake_minimum_required(VERSION 3.13) target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet) target_compile_options(devilution PUBLIC $<$:-gstabs>) endif() +target_compile_options(devilution PUBLIC -Wno-unknown-pragmas) # Note: In Debug mode, GCC generates spurious memory references that upset Valgrind, # these options fix that. target_compile_options(devilution PUBLIC $<$:-fno-omit-frame-pointer>) - # Ignore serious warnings due to "quality" of decompiled code # Currently, disable ignore all warnings (-w), to be removed later target_compile_options(devilution PRIVATE -fpermissive -Wno-write-strings -Wno-multichar -w) @@ -235,8 +240,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") target_compile_options(devilution PRIVATE -fno-aggressive-loop-optimizations) endif() # Warnings for devilutionX -target_compile_options(devilution PUBLIC -Wno-unknown-pragmas) -target_compile_options(devilutionx PRIVATE -Wall -Wextra -Wno-multichar -Wno-unused-parameter) +target_compile_options(devilutionx PRIVATE -Wall -Wextra -Wno-write-strings -Wno-multichar -Wno-unused-parameter) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Style issues @@ -248,11 +252,3 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set_target_properties(devilutionx PROPERTIES LINK_FLAGS "-liconv") endif() - -if(COTIRE) - set_target_properties(devilutionx PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - set_target_properties(devilutionx PROPERTIES - COTIRE_PREFIX_HEADER_INCLUDE_PATH "${devilutionX_SOURCE_DIR}" - COTIRE_PREFIX_HEADER_IGNORE_PATH "${devilutionX_SOURCE_DIR}/SourceX") - cotire(devilutionx) -endif() diff --git a/Diablo.dsp b/Diablo.dsp index 26021b92c..568d4f443 100644 --- a/Diablo.dsp +++ b/Diablo.dsp @@ -44,7 +44,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /TC /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /O1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /O1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /TC /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" @@ -97,7 +97,7 @@ LINK32=link.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # SUBTRACT BASE CPP /WX -# ADD CPP /nologo /MT /W3 /GX /Zi /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FAs /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /Zi /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FAs /YX /FD /TC /c # SUBTRACT CPP /WX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index 55cf681af..2780abe9f 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -70,7 +70,7 @@ char *__stdcall BNetGW_10002E0B(char *a1, unsigned int a2); void __cdecl Connect_FreeConnectData(); BOOL __cdecl Connect_LoadGFXAndStuff(); -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); +BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); void __cdecl j_Connect_cpp_init(); void __cdecl Connect_cpp_init(); BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5); diff --git a/DiabloUI/connect.cpp b/DiabloUI/connect.cpp index 0fbd485c9..bdd98d715 100644 --- a/DiabloUI/connect.cpp +++ b/DiabloUI/connect.cpp @@ -72,7 +72,7 @@ BOOL __cdecl Connect_LoadGFXAndStuff() // 100295C0: using guessed type int heroport_frames; // ref: 0x10003009 -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) +BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) { BOOL result; // eax char pszFileName[260]; // [esp+8h] [ebp-104h] diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index a222ef3cb..dd16d51f9 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -46,7 +46,7 @@ BOOL __stdcall UiSoundCallback(int a1, int type, int a3); void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType); BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6); -BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); +BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *a6); int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type); BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc); diff --git a/MakefileVC b/MakefileVC index d7759ad6b..eb1a64f93 100644 --- a/MakefileVC +++ b/MakefileVC @@ -36,7 +36,7 @@ else VC6_LINK = wine $(VC6_BIN_DIR)/link.exe endif -CFLAGS=/nologo /c /TC /GX /W3 /O1 /I $(VC6_INC_DIR) /FD /MT /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fp"Diablo.pch" /YX /Gm /Zi /FA +CFLAGS=/nologo /c /TC /GX /W3 /O1 /I $(VC6_INC_DIR) /FD /MT /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fp"Diablo.pch" /YX /Gm /Zi /FAs LINKFLAGS=/nologo /subsystem:windows /machine:I386 /incremental:no ifeq ($(MAKE_BUILD),pdb) diff --git a/Source/asm_trans_rect.inc b/Source/asm_trans_rect.inc index 643d62e73..12ef861a6 100644 --- a/Source/asm_trans_rect.inc +++ b/Source/asm_trans_rect.inc @@ -50,7 +50,7 @@ x2loop: #else // _MSC_VER && _M_IX86 { int row, col; - char *pix = &gpBuffer->row[TRANS_RECT_Y + TRANS_RECT_HEIGHT - 1].pixels[TRANS_RECT_X]; + BYTE *pix = &gpBuffer[SCREENXY(TRANS_RECT_X, TRANS_RECT_Y + TRANS_RECT_HEIGHT - 1)]; for (row = TRANS_RECT_HEIGHT >> 1; row != 0; row--) { for (col = TRANS_RECT_WIDTH >> 1; col != 0; col--) { *pix++ = 0; diff --git a/Source/automap.cpp b/Source/automap.cpp index 00a963a3c..a7d8e1272 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -177,7 +177,7 @@ void __cdecl DrawAutomap() return; } - gpBufEnd = (unsigned char *)&gpBuffer->row[352]; + gpBufEnd = (unsigned char *)&gpBuffer[(352 + 160) * 768]; MapX = (ViewX - 16) >> 1; while (MapX + AutoMapXOfs < 0) diff --git a/Source/capture.cpp b/Source/capture.cpp index ba1ce0f40..beb09f8e7 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -24,7 +24,7 @@ void __cdecl CaptureScreen() j_lock_buf_priv(2); success = CaptureHdr(hObject, 640, 480); if (success) { - success = CapturePix(hObject, 640, 480, 768, (BYTE *)gpBuffer->row[0].pixels); + success = CapturePix(hObject, 640, 480, 768, &gpBuffer[SCREENXY(0, 0)]); if (success) { success = CapturePal(hObject, palette); } diff --git a/Source/control.cpp b/Source/control.cpp index 7fa32bac8..c8b0dbf61 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -187,12 +187,11 @@ int SpellPages[6][7] = { void __fastcall DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w) { - BYTE *tmp, *dst, *tbl, *end; + BYTE *dst, *tbl, *end; /// ASSERT: assert(gpBuffer); - tmp = (BYTE *)gpBuffer; /* remove when fixed */ - dst = &tmp[screen_y_times_768[yp] + xp]; + dst = &gpBuffer[xp + screen_y_times_768[yp]]; tbl = SplTransTbl; #if (_MSC_VER >= 800) && (_MSC_VER <= 1200) @@ -846,7 +845,7 @@ void __fastcall DrawPanelBox(int x, int y, int w, int h, int sx, int sy) unsigned int v11; // ecx v6 = (char *)pBtmBuff + 640 * y + x; - v7 = &gpBuffer->row_unused_1[sy].col_unused_1[sx]; + v7 = (char *)&gpBuffer[768 * sy + sx]; v8 = h; do { v9 = w >> 1; @@ -872,7 +871,7 @@ void __fastcall SetFlaskHeight(char *buf, int min, int max, int c, int r) int v7; // edx v5 = &buf[88 * min]; - v6 = &gpBuffer->row_unused_1[r].col_unused_1[c]; + v6 = (char *)&gpBuffer[768 * r + c]; v7 = max - min; do { qmemcpy(v6, v5, 0x58u); @@ -1023,20 +1022,20 @@ void __cdecl InitControlPan() pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); SetSpellTrans(RSPLTYPE_SKILL); pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 143, 640, (char *)pStatusPanel, 1, 640); + CelDecodeRect((BYTE *)pBtmBuff, 0, 143, 640, (BYTE *)pStatusPanel, 1, 640); v1 = pStatusPanel; pStatusPanel = 0; mem_free_dbg(v1); pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); - CelDecodeRect(pLifeBuff, 0, 87, 88, (char *)pStatusPanel, 1, 88); - CelDecodeRect(pManaBuff, 0, 87, 88, (char *)pStatusPanel, 2, 88); + CelDecodeRect((BYTE *)pLifeBuff, 0, 87, 88, (BYTE *)pStatusPanel, 1, 88); + CelDecodeRect((BYTE *)pManaBuff, 0, 87, 88, (BYTE *)pStatusPanel, 2, 88); v2 = pStatusPanel; pStatusPanel = 0; mem_free_dbg(v2); talkflag = 0; if (gbMaxPlayers != 1) { pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); - CelDecodeRect((char *)pBtmBuff, 0, 287, 640, (char *)pTalkPanel, 1, 640); + CelDecodeRect((BYTE *)pBtmBuff, 0, 287, 640, (BYTE *)pTalkPanel, 1, 640); v3 = pTalkPanel; pTalkPanel = 0; mem_free_dbg(v3); @@ -2270,7 +2269,7 @@ void __cdecl RedBack() _LOWORD(v0) = v0 & 0xF400; v12 = v0 + 768 * 6; if (leveltype == DTYPE_HELL) { - v7 = gpBuffer->row[0].pixels; + v7 = (char *)&gpBuffer[SCREENXY(0, 0)]; _EBX = &pLightTbl[v12]; v9 = 352; do { @@ -2286,7 +2285,7 @@ void __cdecl RedBack() --v9; } while (v9); } else { - v1 = gpBuffer->row[0].pixels; + v1 = (char *)&gpBuffer[SCREENXY(0, 0)]; _EBX = &pLightTbl[v12]; v3 = 352; do { diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 43213e766..0afbb66e1 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -202,77 +202,87 @@ void __cdecl DRLG_L1Floor() void __cdecl DRLG_L1Pass3() { - int v0; // eax - int *v1; // edx - int *v2; // eax - signed int v3; // ecx - signed int v4; // ebx - int *v5; // ecx - unsigned char *v6; // edx - unsigned short *v7; // esi - unsigned short v8; // ax - int v9; // eax - int v10; // ST24_4 - int v11; // ST20_4 - int v12; // ST1C_4 - signed int v13; // [esp+Ch] [ebp-1Ch] - int *v14; // [esp+10h] [ebp-18h] - int v15; // [esp+14h] [ebp-14h] - int v16; // [esp+18h] [ebp-10h] - int v17; // [esp+1Ch] [ebp-Ch] - int v18; // [esp+20h] [ebp-8h] - - v0 = *((unsigned short *)pMegaTiles + 84) + 1; - v18 = *((unsigned short *)pMegaTiles + 84) + 1; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 85); - v17 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 86); - v16 = ++v0; - _LOWORD(v0) = *((_WORD *)pMegaTiles + 87); - v15 = v0 + 1; - v1 = dPiece[1]; - do { - v2 = v1; - v3 = 56; - do { - *(v2 - 112) = v18; - *v2 = v17; - *(v2 - 111) = v16; - v2[1] = v15; - v2 += 224; - --v3; - } while (v3); - v1 += 2; - } while ((INT_PTR)v1 < (INT_PTR)dPiece[2]); - v4 = 0; - v14 = &dPiece[17][16]; /* check */ - do { - v5 = v14; - v6 = (unsigned char *)dungeon + v4; - v13 = 40; - do { - v7 = (unsigned short *)((char *)pMegaTiles + 8 * (*v6 - 1)); - v8 = *v7; - ++v7; - v9 = v8 + 1; - v10 = v9; - _LOWORD(v9) = *v7; - ++v7; - v11 = ++v9; - _LOWORD(v9) = *v7; - v12 = ++v9; - _LOWORD(v9) = v7[1]; - v6 += 40; - *(v5 - 112) = v10; - *v5 = v11; - *(v5 - 111) = v12; - v5[1] = v9 + 1; - v5 += 224; - --v13; - } while (v13); - v14 += 2; - ++v4; - } while (v4 < 40); + int i, j, xx, yy; + long v1, v2, v3, v4, lv; + + lv = 22-1; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + + for(j = 0; j < MAXDUNY; j += 2) { + for(i = 0; i < MAXDUNX; i += 2) { + dPiece[i][j] = v1; + dPiece[i+1][j] = v2; + dPiece[i][j+1] = v3; + dPiece[i+1][j+1] = v4; + } + } + + yy = 16; + for(j = 0; j < DMAXY; j++) { + xx = 16; + for(i = 0; i < DMAXX; i++) { + lv = (unsigned char)dungeon[i][j]-1; + /// ASSERT: assert(lv >= 0); +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + mov eax, lv + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + } +#else + v1 = *((WORD *)&pMegaTiles[lv*8])+1; + v2 = *((WORD *)&pMegaTiles[lv*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[lv*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[lv*8]+3)+1; +#endif + dPiece[xx][yy] = v1; + dPiece[xx+1][yy] = v2; + dPiece[xx][yy+1] = v3; + dPiece[xx+1][yy+1] = v4; + xx += 2; + } + yy += 2; + } } void __cdecl DRLG_InitL1Vals() diff --git a/Source/dx.cpp b/Source/dx.cpp index 1122b9c78..fc0727356 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -4,11 +4,11 @@ DEVILUTION_BEGIN_NAMESPACE -Screen *sgpBackBuf; +BYTE *sgpBackBuf; LPDIRECTDRAW lpDDInterface; IDirectDrawPalette *lpDDPalette; // idb int sgdwLockCount; -Screen *gpBuffer; +BYTE *gpBuffer; IDirectDrawSurface *lpDDSBackBuf; IDirectDrawSurface *lpDDSPrimary; #ifdef _DEBUG @@ -130,7 +130,7 @@ void __cdecl dx_create_back_buffer() #else lpDDSPrimary->lpVtbl->Unlock(lpDDSPrimary, NULL); #endif - sgpBackBuf = (Screen *)DiabloAllocPtr(sizeof(Screen)); + sgpBackBuf = (BYTE *)DiabloAllocPtr(656 * 768); return; } if (error_code != DDERR_CANTLOCKSURFACE) @@ -240,7 +240,7 @@ void __cdecl lock_buf_priv() DDErrMsg(error_code, 235, "C:\\Src\\Diablo\\Source\\dx.cpp"); gpBufEnd += (int)ddsd.lpSurface; - gpBuffer = (Screen *)ddsd.lpSurface; + gpBuffer = (BYTE *)ddsd.lpSurface; sgdwLockCount++; } @@ -282,7 +282,7 @@ void __cdecl unlock_buf_priv() void __cdecl dx_cleanup() { - Screen *v0; // ecx + BYTE *v0; // ecx if (ghMainWnd) ShowWindow(ghMainWnd, SW_HIDE); diff --git a/Source/dx.h b/Source/dx.h index 8597def2d..e5ae74a8d 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -4,7 +4,7 @@ extern IDirectDraw *lpDDInterface; extern IDirectDrawPalette *lpDDPalette; // idb -extern Screen *gpBuffer; +extern BYTE *gpBuffer; extern IDirectDrawSurface *lpDDSBackBuf; extern IDirectDrawSurface *lpDDSPrimary; extern char gbBackBuf; // weak diff --git a/Source/effects.cpp b/Source/effects.cpp index 6cd68febf..b1ed23f2b 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1158,6 +1158,7 @@ void __cdecl sound_update() sfx_stop(); } } + // 415DBA: could not find valid save-restore pair for ebp void __cdecl effects_cleanup_sfx() diff --git a/Source/engine.cpp b/Source/engine.cpp index d588b8bb4..22c026b0c 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -121,7 +121,6 @@ void __fastcall CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { - BYTE *tmp; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -131,11 +130,10 @@ void __fastcall CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!pCelBuff) return; - tmp = (BYTE *)gpBuffer; pFrameTable = (DWORD *)pCelBuff; CelDrawDatOnly( - &tmp[sx + screen_y_times_768[sy]], + &gpBuffer[sx + screen_y_times_768[sy]], &pCelBuff[pFrameTable[nCel]], pFrameTable[nCel + 1] - pFrameTable[nCel], nWidth); @@ -164,7 +162,7 @@ void __fastcall CelDecDatOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) void __fastcall CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int v1, v2, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -192,9 +190,8 @@ void __fastcall CelDrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWi else nDataSize -= v1; - tmp = (BYTE *)gpBuffer; CelDrawDatOnly( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[v1], nDataSize, nWidth); @@ -577,7 +574,7 @@ L_ODD: void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; - BYTE *pDecodeTo, *pRLEBytes, *tmp; + BYTE *pDecodeTo, *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -587,12 +584,11 @@ void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int if(!pCelBuff) return; - tmp = (BYTE *)gpBuffer; pFrameTable = (DWORD *)pCelBuff; nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; pRLEBytes = &pCelBuff[pFrameTable[nCel]]; - pDecodeTo = &tmp[sx + screen_y_times_768[sy]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy]]; if(light_table_index) CelDecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); @@ -601,163 +597,193 @@ void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int } // 69BEF8: using guessed type int light_table_index; -void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction) +void __fastcall CelDecodeHdrLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { - int v7; // esi - char *v8; // ecx - int v9; // edi - char *v10; // edx - int v11; // ebx - int v12; // ebx - char *v13; // edx - char *v14; // ecx - int v15; // [esp+Ch] [ebp-4h] - char *cel_buf; // [esp+18h] [ebp+8h] - - v7 = screen_y; - v15 = screen_x; - if (gpBuffer) { - v8 = pCelBuff; - if (pCelBuff) { - v9 = *(_DWORD *)&pCelBuff[4 * frame]; - v10 = &pCelBuff[v9]; - v11 = *(unsigned short *)&pCelBuff[v9 + always_0]; - cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if (v11) { - if (direction != 8 && *(_WORD *)&v10[direction]) - v12 = *(unsigned short *)&v10[direction] - (_DWORD)cel_buf; - else - v12 = *(_DWORD *)&v8[4 * frame + 4] - v9 - (_DWORD)cel_buf; - v13 = &v10[(_DWORD)cel_buf]; - v14 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * always_0] + v15; - if (light_table_index) - CelDecDatLightOnly((BYTE *)v14, (BYTE *)v13, v12, frame_width); - else - CelDrawDatOnly((BYTE *)v14, (BYTE *)v13, v12, frame_width); - } - } - } + int hdr, nDataSize, v1, v2; + BYTE *pRLEBytes, *pDecodeTo, *v9; + DWORD *pFrameTable; + + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + v9 = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&v9[always_0]; + if(!hdr) + return; + + v1 = pFrameTable[1] - pFrameTable[0]; + if(dir == 8) + v2 = 0; + else + v2 = *(WORD *)&v9[dir]; + if(v2) + nDataSize = v2 - hdr; + else + nDataSize = v1 - hdr; + + pRLEBytes = &v9[hdr]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + if(light_table_index) + CelDecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); + else + CelDrawDatOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); } // 69BEF8: using guessed type int light_table_index; -void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction) +void __fastcall CelDecodeHdrLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { - char *v6; // eax - int v7; // esi - char *v8; // edx - int v9; // ebx - int v10; // eax - int v11; // eax - char *v12; // edx - - v6 = pCelBuff; - if (pCelBuff) { - if (pBuff) { - v7 = *(_DWORD *)&pCelBuff[4 * frame]; - v8 = &pCelBuff[v7]; - v9 = *(unsigned short *)&v6[v7 + always_0]; - if (*(_WORD *)&v6[v7 + always_0]) { - v10 = *(_DWORD *)&v6[4 * frame + 4] - v7; - if (direction != 8 && *(_WORD *)&v8[direction]) - v11 = *(unsigned short *)&v8[direction] - v9; - else - v11 = v10 - v9; - v12 = &v8[v9]; - if (cel_transparency_active) { - CelDecDatLightTrans((BYTE *)pBuff, (BYTE *)v12, v11, frame_width); - } else if (light_table_index) { - CelDecDatLightOnly((BYTE *)pBuff, (BYTE *)v12, v11, frame_width); - } else { - CelDrawDatOnly((BYTE *)pBuff, (BYTE *)v12, v11, frame_width); - } - } - } - } + int hdr, nDataSize, v1, v2; + BYTE *pRLEBytes, *v9; + DWORD *pFrameTable; + + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + /// ASSERT: assert(pBuff != NULL); + if(!pBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + v9 = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&v9[always_0]; + if(!hdr) + return; + + v1 = pFrameTable[1] - pFrameTable[0]; + if(dir == 8) + v2 = 0; + else + v2 = *(WORD *)&v9[dir]; + if(v2) + nDataSize = v2 - hdr; + else + nDataSize = v1 - hdr; + + pRLEBytes = &v9[hdr]; + + if(cel_transparency_active) + CelDecDatLightTrans(pBuff, pRLEBytes, nDataSize, nWidth); + else if(light_table_index) + CelDecDatLightOnly(pBuff, pRLEBytes, nDataSize, nWidth); + else + CelDrawDatOnly(pBuff, pRLEBytes, nDataSize, nWidth); } // 69BEF8: using guessed type int light_table_index; // 69CF94: using guessed type int cel_transparency_active; -void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1) +void __fastcall CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { - char *v8; // esi - int v9; // ebx - int v10; // eax - char *v11; // edi - int v12; // ecx - int v13; // esi - int v14; // eax - int v15; // eax - _BYTE *v16; // esi - char *v17; // edi - int v18; // edx - int v19; // eax - int v20; // ecx - int v21; // [esp+Ch] [ebp-4h] - char *v22; // [esp+Ch] [ebp-4h] - char *cel_buf; // [esp+18h] [ebp+8h] - char *cel_bufa; // [esp+18h] [ebp+8h] - int framea; // [esp+1Ch] [ebp+Ch] - int always_0a; // [esp+24h] [ebp+14h] - int directiona; // [esp+28h] [ebp+18h] - - v21 = screen_x; - if (gpBuffer) { - v8 = pCelBuff; - if (pCelBuff) { - v9 = *(_DWORD *)&pCelBuff[4 * frame]; - v10 = always_0; - v11 = &pCelBuff[v9]; - v12 = *(unsigned short *)&pCelBuff[v9 + always_0]; - cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if (v12) { - v13 = *(_DWORD *)&v8[4 * frame + 4] - v9; - if (direction != 8 && *(_WORD *)&v11[direction]) - always_0a = *(unsigned short *)&v11[direction] - (_DWORD)cel_buf; - else - always_0a = v13 - (_DWORD)cel_buf; - directiona = (int)&v11[(_DWORD)cel_buf]; - cel_bufa = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * v10] + v21; - v14 = -(light4flag != 0); - _LOWORD(v14) = v14 & 0xF400; - v15 = v14 + 4096; - framea = v15; - if (always_1 == 2) { - v15 += 256; - framea = v15; + int w, hdr, idx, nDataSize, v1; + BYTE *src, *dst, *tbl, *pRLEBytes; + DWORD *pFrameTable; + + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + pRLEBytes = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&pRLEBytes[always_0]; + if(!hdr) + return; + + if(dir == 8) + v1 = 0; + else + v1 = *(WORD *)&pRLEBytes[dir]; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; + + src = &pRLEBytes[hdr]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + idx = light4flag ? 1024 : 4096; + if(light == 2) + idx += 256; + if(light >= 4) + idx += (light - 1) << 8; + + tbl = (BYTE *)&pLightTbl[idx]; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, src + mov edi, dst + mov eax, 768 + add eax, nWidth + mov w, eax /* use C for w? w = 768 + nWidth */ + mov ebx, nDataSize + add ebx, esi + label1: + mov edx, nWidth + label2: + xor eax, eax + mov al, [esi] + inc esi + test al, al + js label4 + push ebx + mov ebx, tbl + sub edx, eax + mov ecx, eax + label3: + mov al, [esi] + inc esi + mov al, [ebx+eax] + mov [edi], al + dec ecx + lea edi, [edi+1] + jnz label3 + pop ebx + test edx, edx + jz label5 + jmp label2 + label4: + neg al + add edi, eax + sub edx, eax + jnz label2 + label5: + sub edi, w + cmp ebx, esi + jnz label1 + } +#else + BYTE width; + BYTE *end; + + end = &src[nDataSize]; + + for(; src != end; dst -= 768 + nWidth) { + for(w = nWidth; w;) { + width = *src++; + if(!(width & 0x80)) { + w -= width; + while(width) { + *dst = tbl[*src]; + src++; + dst++; + width--; } - if (always_1 >= 4) - framea = v15 + (always_1 << 8) - 256; - v22 = &pLightTbl[framea]; - v16 = (_BYTE *)directiona; - v17 = cel_bufa; - do { - v18 = frame_width; - do { - while (1) { - v19 = (unsigned char)*v16++; - if ((v19 & 0x80u) == 0) - break; - _LOBYTE(v19) = -(char)v19; - v17 += v19; - v18 -= v19; - if (!v18) - goto LABEL_20; - } - v18 -= v19; - v20 = v19; - do { - _LOBYTE(v19) = *v16++; - *v17 = v22[v19]; - --v20; - ++v17; - } while (v20); - } while (v18); - LABEL_20: - v17 += -frame_width - 768; - } while ((_BYTE *)(directiona + always_0a) != v16); + } else { + width = -(char)width; + dst += width; + w -= width; } } } +#endif } // 525728: using guessed type int light4flag; @@ -878,7 +904,7 @@ void __fastcall Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int v1, v2, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer); @@ -906,9 +932,8 @@ void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nW else nDataSize -= v1; - tmp = (BYTE *)gpBuffer; Cel2DecDatOnly( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[v1], nDataSize, nWidth); @@ -1076,56 +1101,704 @@ void __fastcall Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataS for(i = w; i;) { width = *src++; if(!(width & 0x80)) { - i -= width; - if(dst < gpBufEnd) { - if(width & 1) { - dst[0] = tbl[src[0]]; - src++; - dst++; - } - width >>= 1; - if(width & 1) { - dst[0] = tbl[src[0]]; - dst[1] = tbl[src[1]]; - src += 2; - dst += 2; - } - width >>= 1; - for(; width; width--) { - dst[0] = tbl[src[0]]; - dst[1] = tbl[src[1]]; - dst[2] = tbl[src[2]]; - dst[3] = tbl[src[3]]; - src += 4; - dst += 4; + i -= width; + if(dst < gpBufEnd) { + if(width & 1) { + dst[0] = tbl[src[0]]; + src++; + dst++; + } + width >>= 1; + if(width & 1) { + dst[0] = tbl[src[0]]; + dst[1] = tbl[src[1]]; + src += 2; + dst += 2; + } + width >>= 1; + for(; width; width--) { + dst[0] = tbl[src[0]]; + dst[1] = tbl[src[1]]; + dst[2] = tbl[src[2]]; + dst[3] = tbl[src[3]]; + src += 4; + dst += 4; + } + } else { + src += width; + dst += width; + } + } else { + width = -(char)width; + dst += width; + i -= width; + } + } + } +#endif +} +// 69BEF8: using guessed type int light_table_index; +// 69CF0C: using guessed type int gpBufEnd; + +void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) +{ + int w; + BOOL shift; + BYTE *tbl; + + /// ASSERT: assert(pDecodeTo != NULL); + if(!pDecodeTo) + return; + /// ASSERT: assert(pRLEBytes != NULL); + if(!pRLEBytes) + return; + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov eax, light_table_index + shl eax, 8 + add eax, pLightTbl + mov tbl, eax + mov esi, pRLEBytes + mov edi, pDecodeTo + mov eax, 768 + add eax, nWidth + mov w, eax + mov ebx, nDataSize + add ebx, esi + mov eax, edi + and eax, 1 + mov shift, eax + label1: + mov edx, nWidth + label2: + xor eax, eax + lodsb + or al, al + js label10 + push ebx + mov ebx, tbl + sub edx, eax + cmp edi, gpBufEnd + jb label3 + add esi, eax + add edi, eax + jmp label9 + label3: + mov ecx, eax + mov eax, edi + and eax, 1 + cmp eax, shift + jnz label6 + shr ecx, 1 + jnb label4 + inc esi + inc edi + jecxz label9 + jmp label7 + label4: + shr ecx, 1 + jnb label5 + inc esi + inc edi + lodsb + xlat + stosb + jecxz label9 + label5: + lodsd + inc edi + ror eax, 8 + xlat + stosb + ror eax, 10h + inc edi + xlat + stosb + loop label5 + jmp label9 + label6: + shr ecx, 1 + jnb label7 + lodsb + xlat + stosb + jecxz label9 + jmp label4 + label7: + shr ecx, 1 + jnb label8 + lodsb + xlat + stosb + inc esi + inc edi + jecxz label9 + label8: + lodsd + xlat + stosb + inc edi + ror eax, 10h + xlat + stosb + inc edi + loop label8 + label9: + pop ebx + or edx, edx + jz label11 + jmp label2 + label10: + neg al + add edi, eax + sub edx, eax + jnz label2 + label11: + sub edi, w + mov eax, shift + inc eax + and eax, 1 + mov shift, eax + cmp ebx, esi + jnz label1 + } +#else + int i; + BYTE width; + BYTE *src, *dst; + + src = pRLEBytes; + dst = pDecodeTo; + tbl = (BYTE *)&pLightTbl[light_table_index * 256]; + w = nWidth; + shift = (BYTE)dst & 1; + + for(; src != &pRLEBytes[nDataSize]; dst -= 768 + w, shift = (shift + 1) & 1) { + for(i = w; i;) { + width = *src++; + if(!(width & 0x80)) { + i -= width; + if(dst < gpBufEnd) { + if(((BYTE)dst & 1) == shift) { + if(!(width & 1)) { + goto L_ODD; + } else { + src++; + dst++; +L_EVEN: + width >>= 1; + if(width & 1) { + dst[0] = tbl[src[0]]; + src += 2; + dst += 2; + } + width >>= 1; + for(; width; width--) { + dst[0] = tbl[src[0]]; + dst[2] = tbl[src[2]]; + src += 4; + dst += 4; + } + } + } else { + if(!(width & 1)) { + goto L_EVEN; + } else { + dst[0] = tbl[src[0]]; + src++; + dst++; +L_ODD: + width >>= 1; + if(width & 1) { + dst[1] = tbl[src[1]]; + src += 2; + dst += 2; + } + width >>= 1; + for(; width; width--) { + dst[1] = tbl[src[1]]; + dst[3] = tbl[src[3]]; + src += 4; + dst += 4; + } + } + } + } else { + src += width; + dst += width; + } + } else { + width = -(char)width; + dst += width; + i -= width; + } + } + } +#endif +} +// 69BEF8: using guessed type int light_table_index; +// 69CF0C: using guessed type int gpBufEnd; + +void __fastcall Cel2DecodeHdrLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) +{ + int hdr, nDataSize, v1; + BYTE *pRLEBytes, *pDecodeTo, *v9; + DWORD *pFrameTable; + + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + v9 = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&v9[always_0]; + if(!hdr) + return; + + v1 = *(WORD *)&v9[dir]; + if(dir == 8) + v1 = 0; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; + + pRLEBytes = &v9[hdr]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + if(light_table_index) + Cel2DecDatLightOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); + else + Cel2DecDatOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); +} +// 69BEF8: using guessed type int light_table_index; + +void __fastcall Cel2DecodeLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) +{ + int hdr, nDataSize, v1, v2; + BYTE *pRLEBytes, *v9; + DWORD *pFrameTable; + + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + v9 = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&v9[always_0]; + if(!hdr) + return; + + v1 = pFrameTable[1] - pFrameTable[0]; + v2 = *(WORD *)&v9[dir]; + if(dir == 8) + v2 = 0; + if(v2) + nDataSize = v2 - hdr; + else + nDataSize = v1 - hdr; + + pRLEBytes = &v9[hdr]; + + if(cel_transparency_active) + Cel2DecDatLightTrans(pBuff, pRLEBytes, nDataSize, nWidth); + else if(light_table_index) + Cel2DecDatLightOnly(pBuff, pRLEBytes, nDataSize, nWidth); + else + Cel2DecDatOnly(pBuff, pRLEBytes, nDataSize, nWidth); +} +// 69BEF8: using guessed type int light_table_index; +// 69CF94: using guessed type int cel_transparency_active; + +void __fastcall Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) +{ + int w, hdr, idx, nDataSize, v1; + BYTE *src, *dst, *tbl, *pRLEBytes; + DWORD *pFrameTable; + + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + pRLEBytes = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&pRLEBytes[always_0]; + if(!hdr) + return; + + if(dir == 8) + v1 = 0; + else + v1 = *(WORD *)&pRLEBytes[dir]; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; + + src = &pRLEBytes[hdr]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + idx = light4flag ? 1024 : 4096; + if(light == 2) + idx += 256; + if(light >= 4) + idx += (light - 1) << 8; + + tbl = (BYTE *)&pLightTbl[idx]; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov eax, nWidth + add eax, 768 + mov w, eax /* use C for w? w = 768 + nWidth */ + mov esi, src + mov edi, dst + mov ecx, nDataSize + add ecx, esi + label1: + push ecx + mov edx, nWidth + xor ecx, ecx + label2: + xor eax, eax + mov al, [esi] + inc esi + test al, al + js label5 + mov ebx, tbl + sub edx, eax + cmp edi, gpBufEnd + jb label3 + add esi, eax + add edi, eax + jmp label4 + label3: + mov cl, [esi] + inc esi + mov cl, [ebx+ecx] + mov [edi], cl + dec eax + lea edi, [edi+1] + jnz label3 + label4: + test edx, edx + jz label6 + jmp label2 + label5: + neg al + add edi, eax + sub edx, eax + jnz label2 + label6: + pop ecx + sub edi, w + cmp ecx, esi + jnz label1 + } +#else + BYTE width; + BYTE *end; + + end = &src[nDataSize]; + + for(; src != end; dst -= 768 + nWidth) { + for(w = nWidth; w;) { + width = *src++; + if(!(width & 0x80)) { + w -= width; + if(dst < gpBufEnd) { + while(width) { + *dst = tbl[*src]; + src++; + dst++; + width--; + } + } else { + src += width; + dst += width; + } + } else { + width = -(char)width; + dst += width; + w -= width; + } + } + } +#endif +} +// 525728: using guessed type int light4flag; +// 69CF0C: using guessed type int gpBufEnd; + +void __fastcall CelDecodeRect(BYTE *pBuff, int always_0, int hgt, int wdt, BYTE *pCelBuff, int nCel, int nWidth) +{ + BYTE *src, *dst, *end; + + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + /// ASSERT: assert(pBuff != NULL); + if(!pBuff) + return; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov ebx, pCelBuff + mov eax, nCel + shl eax, 2 + add ebx, eax + mov eax, [ebx+4] + sub eax, [ebx] + mov end, eax + mov eax, pCelBuff + add eax, [ebx] + mov src, eax + } + + dst = &pBuff[hgt * wdt + always_0]; + + __asm { + mov esi, src + mov edi, dst + mov eax, wdt + add eax, nWidth + mov wdt, eax + mov ebx, end + add ebx, esi + label1: + mov edx, nWidth + label2: + xor eax, eax + lodsb + or al, al + js label6 + sub edx, eax + mov ecx, eax + shr ecx, 1 + jnb label3 + movsb + jecxz label5 + label3: + shr ecx, 1 + jnb label4 + movsw + jecxz label5 + label4: + rep movsd + label5: + or edx, edx + jz label7 + jmp label2 + label6: + neg al + add edi, eax + sub edx, eax + jnz label2 + label7: + sub edi, wdt + cmp ebx, esi + jnz label1 + } +#else + int i; + BYTE width; + DWORD *pFrameTable; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + src = &pCelBuff[pFrameTable[0]]; + end = &src[pFrameTable[1] - pFrameTable[0]]; + dst = &pBuff[hgt * wdt + always_0]; + + for(; src != end; dst -= wdt + nWidth) { + for(i = nWidth; i;) { + width = *src++; + if(!(width & 0x80)) { + i -= width; + if(width & 1) { + dst[0] = src[0]; + src++; + dst++; + } + width >>= 1; + if(width & 1) { + dst[0] = src[0]; + dst[1] = src[1]; + src += 2; + dst += 2; + } + width >>= 1; + while(width) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + src += 4; + dst += 4; + width--; + } + } else { + width = -(char)width; + dst += width; + i -= width; + } + } + } +#endif +} + +void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) +{ + int w, hdr, nDataSize, v1; + BYTE *src, *dst; + + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) + return; + /// ASSERT: assert(gpBuffer); + if(!gpBuffer) + return; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov ebx, pCelBuff + mov eax, nCel + shl eax, 2 + add ebx, eax + mov eax, [ebx+4] + sub eax, [ebx] + mov nDataSize, eax + mov edx, pCelBuff + add edx, [ebx] + mov src, edx + add edx, always_0 + xor eax, eax + mov ax, [edx] + mov hdr, eax + mov edx, src + add edx, dir + mov ax, [edx] + mov v1, eax + } + + if(!hdr) + return; + + if(dir == 8) + v1 = 0; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize -= hdr; + + src += hdr; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + __asm { + mov esi, src + mov edi, dst + mov eax, 768 + add eax, nWidth + mov w, eax + mov ebx, nDataSize + add ebx, esi + label1: + mov edx, nWidth + label2: + xor eax, eax + lodsb + or al, al + js label5 + sub edx, eax + mov ecx, eax + mov ah, col + label3: + lodsb + or al, al + jz label4 + mov [edi-768], ah + mov [edi-1], ah + mov [edi+1], ah + mov [edi+768], ah + label4: + inc edi + loop label3 + or edx, edx + jz label6 + jmp label2 + label5: + neg al + add edi, eax + sub edx, eax + jnz label2 + label6: + sub edi, w + cmp ebx, esi + jnz label1 + } +#else + BYTE width; + BYTE *end, *pRLEBytes; + DWORD *pFrameTable; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + pRLEBytes = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&pRLEBytes[always_0]; + if(!hdr) + return; + + v1 = *(WORD *)&pRLEBytes[dir]; + if(dir == 8) + v1 = 0; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; + + src = &pRLEBytes[hdr]; + end = &src[nDataSize]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + for(; src != end; dst -= 768 + nWidth) { + for(w = nWidth; w;) { + width = *src++; + if(!(width & 0x80)) { + w -= width; + while(width) { + if(*src++) { + dst[-768] = col; + dst[-1] = col; + dst[1] = col; + dst[768] = col; } - } else { - src += width; - dst += width; + dst++; + width--; } } else { width = -(char)width; dst += width; - i -= width; + w -= width; } } } #endif } -// 69BEF8: using guessed type int light_table_index; -// 69CF0C: using guessed type int gpBufEnd; -void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) +void __fastcall CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { - int w; - BOOL shift; - BYTE *tbl; + int w, hdr, nDataSize, v1; + BYTE *src, *dst; - /// ASSERT: assert(pDecodeTo != NULL); - if(!pDecodeTo) - return; - /// ASSERT: assert(pRLEBytes != NULL); - if(!pRLEBytes) + /// ASSERT: assert(pCelBuff != NULL); + if(!pCelBuff) return; /// ASSERT: assert(gpBuffer); if(!gpBuffer) @@ -1133,20 +1806,47 @@ void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nData #if (_MSC_VER >= 800) && (_MSC_VER <= 1200) __asm { - mov eax, light_table_index - shl eax, 8 - add eax, pLightTbl - mov tbl, eax - mov esi, pRLEBytes - mov edi, pDecodeTo + mov ebx, pCelBuff + mov eax, nCel + shl eax, 2 + add ebx, eax + mov eax, [ebx+4] + sub eax, [ebx] + mov nDataSize, eax + mov edx, pCelBuff + add edx, [ebx] + mov src, edx + add edx, always_0 + xor eax, eax + mov ax, [edx] + mov hdr, eax + mov edx, src + add edx, dir + mov ax, [edx] + mov v1, eax + } + + if(!hdr) + return; + + if(dir == 8) + v1 = 0; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize -= hdr; + + src += hdr; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + __asm { + mov esi, src + mov edi, dst mov eax, 768 add eax, nWidth mov w, eax mov ebx, nDataSize add ebx, esi - mov eax, edi - and eax, 1 - mov shift, eax label1: mov edx, nWidth label2: @@ -1154,76 +1854,45 @@ void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nData lodsb or al, al js label10 - push ebx - mov ebx, tbl sub edx, eax - cmp edi, gpBufEnd + mov ecx, gpBufEnd + cmp edi, ecx jb label3 add esi, eax add edi, eax jmp label9 label3: + sub ecx, 768 + cmp edi, ecx + jnb label6 mov ecx, eax - mov eax, edi - and eax, 1 - cmp eax, shift - jnz label6 - shr ecx, 1 - jnb label4 - inc esi - inc edi - jecxz label9 - jmp label7 + mov ah, col label4: - shr ecx, 1 - jnb label5 - inc esi - inc edi lodsb - xlat - stosb - jecxz label9 + or al, al + jz label5 + mov [edi-768], ah + mov [edi-1], ah + mov [edi+1], ah + mov [edi+768], ah label5: - lodsd - inc edi - ror eax, 8 - xlat - stosb - ror eax, 10h inc edi - xlat - stosb - loop label5 + loop label4 jmp label9 label6: - shr ecx, 1 - jnb label7 - lodsb - xlat - stosb - jecxz label9 - jmp label4 + mov ecx, eax + mov ah, col label7: - shr ecx, 1 - jnb label8 lodsb - xlat - stosb - inc esi - inc edi - jecxz label9 + or al, al + jz label8 + mov [edi-768], ah + mov [edi-1], ah + mov [edi+1], ah label8: - lodsd - xlat - stosb - inc edi - ror eax, 10h - xlat - stosb inc edi - loop label8 + loop label7 label9: - pop ebx or edx, edx jz label11 jmp label2 @@ -1234,72 +1903,58 @@ void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nData jnz label2 label11: sub edi, w - mov eax, shift - inc eax - and eax, 1 - mov shift, eax cmp ebx, esi jnz label1 } #else - int i; BYTE width; - BYTE *src, *dst; + BYTE *end, *pRLEBytes; + DWORD *pFrameTable; - src = pRLEBytes; - dst = pDecodeTo; - tbl = (BYTE *)&pLightTbl[light_table_index * 256]; - w = nWidth; - shift = (BYTE)dst & 1; + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + pRLEBytes = &pCelBuff[pFrameTable[0]]; + hdr = *(WORD *)&pRLEBytes[always_0]; + if(!hdr) + return; - for(; src != &pRLEBytes[nDataSize]; dst -= 768 + w, shift = (shift + 1) & 1) { - for(i = w; i;) { + v1 = *(WORD *)&pRLEBytes[dir]; + if(dir == 8) + v1 = 0; + if(v1) + nDataSize = v1 - hdr; + else + nDataSize = pFrameTable[1] - pFrameTable[0] - hdr; + + src = &pRLEBytes[hdr]; + end = &src[nDataSize]; + dst = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; + + for(; src != end; dst -= 768 + nWidth) { + for(w = nWidth; w;) { width = *src++; if(!(width & 0x80)) { - i -= width; + w -= width; if(dst < gpBufEnd) { - if(((BYTE)dst & 1) == shift) { - if(!(width & 1)) { - goto L_ODD; - } else { - src++; - dst++; -L_EVEN: - width >>= 1; - if(width & 1) { - dst[0] = tbl[src[0]]; - src += 2; - dst += 2; - } - width >>= 1; - for(; width; width--) { - dst[0] = tbl[src[0]]; - dst[2] = tbl[src[2]]; - src += 4; - dst += 4; + if(dst >= gpBufEnd - 768) { + while(width) { + if(*src++) { + dst[-768] = col; + dst[-1] = col; + dst[1] = col; } + dst++; + width--; } } else { - if(!(width & 1)) { - goto L_EVEN; - } else { - dst[0] = tbl[src[0]]; - src++; - dst++; -L_ODD: - width >>= 1; - if(width & 1) { - dst[1] = tbl[src[1]]; - src += 2; - dst += 2; - } - width >>= 1; - for(; width; width--) { - dst[1] = tbl[src[1]]; - dst[3] = tbl[src[3]]; - src += 4; - dst += 4; + while(width) { + if(*src++) { + dst[-768] = col; + dst[-1] = col; + dst[1] = col; + dst[768] = col; } + dst++; + width--; } } } else { @@ -1309,398 +1964,12 @@ L_ODD: } else { width = -(char)width; dst += width; - i -= width; + w -= width; } } } #endif } -// 69BEF8: using guessed type int light_table_index; -// 69CF0C: using guessed type int gpBufEnd; - -void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction) -{ - int v7; // esi - char *v8; // eax - int v9; // edi - char *v10; // edx - int v11; // ebx - int v12; // eax - int v13; // edi - int v14; // eax - char *v15; // edx - char *v16; // ecx - char *cel_buf; // [esp+18h] [ebp+8h] - - v7 = screen_y; - if (gpBuffer) { - v8 = pCelBuff; - if (pCelBuff) { - v9 = *(_DWORD *)&pCelBuff[4 * frame]; - v10 = &pCelBuff[v9]; - v11 = *(unsigned short *)&pCelBuff[v9 + a6]; - cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + a6]; - if (v11) { - v12 = *(_DWORD *)&v8[4 * frame + 4] - v9; - v13 = *(unsigned short *)&v10[direction]; - if (direction == 8) - v13 = 0; - if (v13) - v14 = v13 - (_DWORD)cel_buf; - else - v14 = v12 - (_DWORD)cel_buf; - v15 = &v10[(_DWORD)cel_buf]; - v16 = (char *)gpBuffer + screen_y_times_768[v7 - 16 * a6] + screen_x; - if (light_table_index) - Cel2DecDatLightOnly((BYTE *)v16, (BYTE *)v15, v14, frame_width); - else - Cel2DecDatOnly((BYTE *)v16, (BYTE *)v15, v14, frame_width); - } - } - } -} -// 69BEF8: using guessed type int light_table_index; - -void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction) -{ - char *v6; // eax - int v7; // esi - char *v8; // edx - int v9; // ebx - int v10; // eax - int v11; // esi - int v12; // eax - char *v13; // edx - - v6 = pCelBuff; - if (pCelBuff) { - v7 = *(_DWORD *)&pCelBuff[4 * frame]; - v8 = &pCelBuff[v7]; - v9 = *(unsigned short *)&v6[v7 + a5]; - if (*(_WORD *)&v6[v7 + a5]) { - v10 = *(_DWORD *)&v6[4 * frame + 4] - v7; - v11 = *(unsigned short *)&v8[direction]; - if (direction == 8) - v11 = 0; - if (v11) - v12 = v11 - v9; - else - v12 = v10 - v9; - v13 = &v8[v9]; - if (cel_transparency_active) { - Cel2DecDatLightTrans((BYTE *)dst_buf, (BYTE *)v13, v12, frame_width); - } else if (light_table_index) { - Cel2DecDatLightOnly((BYTE *)dst_buf, (BYTE *)v13, v12, frame_width); - } else { - Cel2DecDatOnly((BYTE *)dst_buf, (BYTE *)v13, v12, frame_width); - } - } - } -} -// 69BEF8: using guessed type int light_table_index; -// 69CF94: using guessed type int cel_transparency_active; - -void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1) -{ - char *v8; // esi - int v9; // ebx - char *v10; // edi - int v11; // ecx - int v12; // esi - int v13; // eax - int v14; // eax - _BYTE *v15; // esi - _BYTE *v16; // edi - int v17; // ecx - int v18; // edx - int v19; // ecx - int v20; // eax - _BYTE *v21; // [esp-4h] [ebp-14h] - int v22; // [esp+Ch] [ebp-4h] - char *cel_buf; // [esp+18h] [ebp+8h] - char *cel_bufa; // [esp+18h] [ebp+8h] - int framea; // [esp+1Ch] [ebp+Ch] - char *always_0a; // [esp+24h] [ebp+14h] - int directiona; // [esp+28h] [ebp+18h] - - v22 = screen_x; - if (gpBuffer) { - v8 = pCelBuff; - if (pCelBuff) { - v9 = *(_DWORD *)&pCelBuff[4 * frame]; - v10 = &pCelBuff[v9]; - v11 = *(unsigned short *)&pCelBuff[v9 + always_0]; - cel_buf = (char *)*(unsigned short *)&pCelBuff[v9 + always_0]; - if (v11) { - v12 = *(_DWORD *)&v8[4 * frame + 4] - v9; - if (direction != 8 && *(_WORD *)&v10[direction]) - framea = *(unsigned short *)&v10[direction] - (_DWORD)cel_buf; - else - framea = v12 - (_DWORD)cel_buf; - directiona = (int)&v10[(_DWORD)cel_buf]; - always_0a = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * always_0] + v22; - v13 = -(light4flag != 0); - _LOWORD(v13) = v13 & 0xF400; - v14 = v13 + 4096; - if (always_1 == 2) - v14 += 256; - if (always_1 >= 4) - v14 = v14 + (always_1 << 8) - 256; - cel_bufa = &pLightTbl[v14]; - v15 = (_BYTE *)directiona; - v16 = (unsigned char *)always_0a; - v17 = directiona + framea; - do { - v21 = (_BYTE *)v17; - v18 = frame_width; - v19 = 0; - do { - while (1) { - v20 = (unsigned char)*v15++; - if ((v20 & 0x80u) == 0) - break; - _LOBYTE(v20) = -(char)v20; - v16 += v20; - v18 -= v20; - if (!v18) - goto LABEL_21; - } - v18 -= v20; - if (v16 < gpBufEnd) { - do { - _LOBYTE(v19) = *v15++; - *v16 = cel_bufa[v19]; - --v20; - ++v16; - } while (v20); - } else { - v15 += v20; - v16 += v20; - } - } while (v18); - LABEL_21: - v17 = (int)v21; - v16 += -frame_width - 768; - } while (v21 != v15); - } - } - } -} -// 525728: using guessed type int light4flag; -// 69CF0C: using guessed type int gpBufEnd; - -void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst_width, char *pCelBuff, int frame, int frame_width) -{ - char *v7; // ebx - char *v8; // esi - char *v9; // edi - UINT_PTR v10; // ebx - int v11; // edx - unsigned int v12; // eax - unsigned int v13; // ecx - char v14; // cf - unsigned int v15; // ecx - int dst_widtha; // [esp+14h] [ebp+Ch] - - if (pCelBuff && pBuff) { - v7 = &pCelBuff[4 * frame]; - v8 = &pCelBuff[*(_DWORD *)v7]; - v9 = &pBuff[dst_width * dst_height + always_0]; - dst_widtha = frame_width + dst_width; - v10 = (UINT_PTR)&v8[*((_DWORD *)v7 + 1) - *(_DWORD *)v7]; - do { - v11 = frame_width; - do { - while (1) { - v12 = (unsigned char)*v8++; - if ((v12 & 0x80u) == 0) - break; - _LOBYTE(v12) = -(char)v12; - v9 += v12; - v11 -= v12; - if (!v11) - goto LABEL_14; - } - v11 -= v12; - v13 = v12 >> 1; - if (v12 & 1) { - *v9++ = *v8++; - if (!v13) - continue; - } - v14 = v13 & 1; - v15 = v12 >> 2; - if (v14) { - *(_WORD *)v9 = *(_WORD *)v8; - v8 += 2; - v9 += 2; - if (!v15) - continue; - } - qmemcpy(v9, v8, 4 * v15); - v8 += 4 * v15; - v9 += 4 * v15; - } while (v11); - LABEL_14: - v9 -= dst_widtha; - } while ((char *)v10 != v8); - } -} - -void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction) -{ - char *v8; // ebx - int v9; // eax - char *v10; // esi - char *v11; // edi - int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - int v16; // [esp+Ch] [ebp-10h] - char *v17; // [esp+10h] [ebp-Ch] - int v18; // [esp+14h] [ebp-8h] - char v19; // [esp+18h] [ebp-4h] - - v19 = colour; - if (pCelBuff) { - if (gpBuffer) { - v8 = &pCelBuff[4 * frame]; - v17 = &pCelBuff[*(_DWORD *)v8]; - v16 = *(unsigned short *)&v17[a7]; - if (*(_WORD *)&v17[a7]) { - if (direction == 8) - v9 = 0; - else - v9 = *(unsigned short *)&v17[direction]; - if (v9) - v18 = v9 - v16; - else - v18 = *((_DWORD *)v8 + 1) - *(_DWORD *)v8 - v16; - v10 = &v17[v16]; - v11 = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + screen_x; - do { - v12 = frame_width; - do { - while (1) { - v13 = (unsigned char)*v10++; - if ((v13 & 0x80u) == 0) - break; - _LOBYTE(v13) = -(char)v13; - v11 += v13; - v12 -= v13; - if (!v12) - goto LABEL_20; - } - v12 -= v13; - v14 = v13; - do { - v15 = *v10++; - if (v15) { - *(v11 - 768) = v19; - *(v11 - 1) = v19; - v11[1] = v19; - v11[768] = v19; - } - ++v11; - --v14; - } while (v14); - } while (v12); - LABEL_20: - v11 += -frame_width - 768; - } while (&v17[v16 + v18] != v10); - } - } - } -} - -void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction) -{ - char *v8; // ebx - int v9; // eax - char *v10; // esi - char *v11; // edi - int v12; // edx - int v13; // eax - int v14; // ecx - char v15; // al - int v16; // ecx - char v17; // al - int v18; // [esp+Ch] [ebp-10h] - char *v19; // [esp+10h] [ebp-Ch] - int v20; // [esp+14h] [ebp-8h] - char v21; // [esp+18h] [ebp-4h] - - v21 = colour; - if (pCelBuff) { - if (gpBuffer) { - v8 = &pCelBuff[4 * frame]; - v19 = &pCelBuff[*(_DWORD *)v8]; - v18 = *(unsigned short *)&v19[a7]; - if (*(_WORD *)&v19[a7]) { - if (direction == 8) - v9 = 0; - else - v9 = *(unsigned short *)&v19[direction]; - if (v9) - v20 = v9 - v18; - else - v20 = *((_DWORD *)v8 + 1) - *(_DWORD *)v8 - v18; - v10 = &v19[v18]; - v11 = (char *)gpBuffer + screen_y_times_768[screen_y - 16 * a7] + screen_x; - do { - v12 = frame_width; - do { - while (1) { - v13 = (unsigned char)*v10++; - if ((v13 & 0x80u) == 0) - break; - _LOBYTE(v13) = -(char)v13; - v11 += v13; - v12 -= v13; - if (!v12) - goto LABEL_28; - } - v12 -= v13; - if (v11 < (char *)gpBufEnd) { - if (v11 >= (char *)gpBufEnd - 768) { - v16 = v13; - do { - v17 = *v10++; - if (v17) { - *(v11 - 768) = v21; - *(v11 - 1) = v21; - v11[1] = v21; - } - ++v11; - --v16; - } while (v16); - } else { - v14 = v13; - do { - v15 = *v10++; - if (v15) { - *(v11 - 768) = v21; - *(v11 - 1) = v21; - v11[1] = v21; - v11[768] = v21; - } - ++v11; - --v14; - } while (v14); - } - } else { - v10 += v13; - v11 += v13; - } - } while (v12); - LABEL_28: - v11 += -frame_width - 768; - } while (&v19[v18 + v20] != v10); - } - } - } -} // 69CF0C: using guessed type int gpBufEnd; void __fastcall ENG_set_pixel(int screen_x, int screen_y, UCHAR pixel) @@ -2177,7 +2446,7 @@ void __fastcall Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) void __fastcall Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2205,9 +2474,8 @@ void __fastcall Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm1( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth); @@ -2357,7 +2625,7 @@ void __fastcall Cl2DecDatFrm1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2385,9 +2653,8 @@ void __fastcall Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm2( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -2559,7 +2826,7 @@ void __fastcall Cl2DecDatFrm2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int hdr, idx, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2593,9 +2860,8 @@ void __fastcall Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(light >= 4) idx += (light - 1) << 8; - tmp = (BYTE *)gpBuffer; Cl2DecDatLightTbl1( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -2757,7 +3023,7 @@ void __fastcall Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSi void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *pDecodeTo, *tmp; + BYTE *pRLEBytes, *pDecodeTo; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2785,8 +3051,7 @@ void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) Cl2DecDatLightTbl1(pDecodeTo, &pRLEBytes[hdr], nDataSize - hdr, nWidth, (BYTE *)&pLightTbl[light_table_index * 256]); @@ -2798,7 +3063,7 @@ void __fastcall Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int void __fastcall Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -2826,9 +3091,8 @@ void __fastcall Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; Cl2DecDatFrm4( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth); @@ -2992,7 +3256,7 @@ void __fastcall Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, i void __fastcall Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3020,10 +3284,9 @@ void __fastcall Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCe if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; gpBufEnd -= 768; Cl2DecDatClrHL( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -3209,7 +3472,7 @@ void __fastcall Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, void __fastcall Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light) { int hdr, idx, nDataSize; - BYTE *pRLEBytes, *tmp; + BYTE *pRLEBytes; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3243,9 +3506,8 @@ void __fastcall Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(light >= 4) idx += (light - 1) << 8; - tmp = (BYTE *)gpBuffer; Cl2DecDatLightTbl2( - &tmp[sx + screen_y_times_768[sy - 16 * always_0]], + &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]], &pRLEBytes[hdr], nDataSize - hdr, nWidth, @@ -3421,7 +3683,7 @@ void __fastcall Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSi void __fastcall Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir) { int hdr, nDataSize; - BYTE *pRLEBytes, *pDecodeTo, *tmp; + BYTE *pRLEBytes, *pDecodeTo; DWORD *pFrameTable; /// ASSERT: assert(gpBuffer != NULL); @@ -3449,8 +3711,7 @@ void __fastcall Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWid if(!nDataSize) nDataSize = pFrameTable[nCel + 1] - pFrameTable[nCel]; - tmp = (BYTE *)gpBuffer; - pDecodeTo = &tmp[sx + screen_y_times_768[sy - 16 * always_0]]; + pDecodeTo = &gpBuffer[sx + screen_y_times_768[sy - 16 * always_0]]; if(light_table_index) Cl2DecDatLightTbl2(pDecodeTo, &pRLEBytes[hdr], nDataSize - hdr, nWidth, (BYTE *)&pLightTbl[light_table_index * 256]); diff --git a/Source/engine.h b/Source/engine.h index f45abbbb9..037ce85cf 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -19,20 +19,20 @@ void __fastcall CelDecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWid void __fastcall CelDecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void __fastcall CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void __fastcall CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth); -void __fastcall CelDecodeHdrLightOnly(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction); -void __fastcall CelDecodeHdrLightTrans(char *pBuff, char *pCelBuff, int frame, int frame_width, int always_0, int direction); -void __fastcall CelDrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1); +void __fastcall CelDecodeHdrLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); +void __fastcall CelDecodeHdrLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); +void __fastcall CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light); void __fastcall Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void __fastcall Cel2DrawHdrOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); void __fastcall Cel2DecodeHdrOnly(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); void __fastcall Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void __fastcall Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); -void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a6, int direction); -void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction); -void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1); -void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst_width, char *pCelBuff, int frame, int frame_width); -void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction); -void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction); +void __fastcall Cel2DecodeHdrLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); +void __fastcall Cel2DecodeLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); +void __fastcall Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir, char light); +void __fastcall CelDecodeRect(BYTE *pBuff, int always_0, int hgt, int wdt, BYTE *pCelBuff, int nCel, int nWidth); +void __fastcall CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); +void __fastcall CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int always_0, int dir); void __fastcall ENG_set_pixel(int screen_x, int screen_y, UCHAR pixel); void __fastcall engine_draw_pixel(int x, int y); void __fastcall DrawLine(int x0, int y0, int x1, int y1, UCHAR col); diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 057adf755..f48cb25b7 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -24,7 +24,7 @@ int dPiece[MAXDUNX][MAXDUNY]; char dTransVal[MAXDUNX][MAXDUNY]; int setloadflag_2; // weak int tile_defs[2048]; -void *pMegaTiles; +BYTE *pMegaTiles; void *pLevelPieces; int gnDifficulty; // idb char block_lvid[2049]; diff --git a/Source/gendung.h b/Source/gendung.h index 9381e8fb7..83067f16b 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -22,7 +22,7 @@ extern int dPiece[MAXDUNX][MAXDUNY]; extern char dTransVal[MAXDUNX][MAXDUNY]; extern int setloadflag_2; // weak extern int tile_defs[2048]; -extern void *pMegaTiles; +extern BYTE *pMegaTiles; extern void *pLevelPieces; extern int gnDifficulty; // idb extern char block_lvid[2049]; diff --git a/Source/inv.cpp b/Source/inv.cpp index bd011b4e7..32f19f590 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -168,13 +168,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, 517, 219, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, 517, 219, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag) { CelDrawHdrOnly(517, 219, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(517, 219, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(517, 219, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -192,13 +192,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, 432, 365, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, 432, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag) { CelDrawHdrOnly(432, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(432, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(432, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -216,13 +216,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, 633, 365, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, 633, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag) { CelDrawHdrOnly(633, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(633, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(633, 365, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -240,13 +240,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, 589, 220, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, 589, 220, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag) { CelDrawHdrOnly(589, 220, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(589, 220, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(589, 220, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -267,13 +267,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag) { CelDrawHdrOnly(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) { @@ -283,9 +283,9 @@ void __cdecl DrawInv() CelDecodeHdrLightTrans( frame_width == INV_SLOT_SIZE_PX - ? &gpBuffer->row[160].pixels[581] - : &gpBuffer->row[160].pixels[567], - (char *)pCursCels, frame, frame_width, 0, 8); + ? &gpBuffer[SCREENXY(581, 160)] + : &gpBuffer[SCREENXY(567, 160)], + (BYTE *)pCursCels, frame, frame_width, 0, 8); cel_transparency_active = 0; } @@ -307,13 +307,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) { CelDrawHdrOnly(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(screen_x, screen_y, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -331,13 +331,13 @@ void __cdecl DrawInv() if (!plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { colour = ICOL_RED; } - CelDecodeClr(colour, 517, 320, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, 517, 320, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag) { CelDrawHdrOnly(517, 320, (BYTE *)pCursCels, frame, frame_width, 0, 8); } else { - CelDrawHdrLightRed(517, 320, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(517, 320, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } @@ -372,7 +372,7 @@ void __cdecl DrawInv() colour, InvRect[j + SLOTXY_INV_FIRST].X + 64, InvRect[j + SLOTXY_INV_FIRST].Y + 159, - (char *)pCursCels, frame, frame_width, 0, 8); + (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].InvList[ii]._iStatFlag) { @@ -384,7 +384,7 @@ void __cdecl DrawInv() CelDrawHdrLightRed( InvRect[j + SLOTXY_INV_FIRST].X + 64, InvRect[j + SLOTXY_INV_FIRST].Y + 159, - (char *)pCursCels, frame, frame_width, 0, 8, 1); + (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); } } } @@ -420,13 +420,13 @@ void __cdecl DrawInvBelt() colour = ICOL_BLUE; if (!plr[myplr].SpdList[i]._iStatFlag) colour = ICOL_RED; - CelDecodeClr(colour, InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (char *)pCursCels, frame, frame_width, 0, 8); + CelDecodeClr(colour, InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (BYTE *)pCursCels, frame, frame_width, 0, 8); } if (plr[myplr].SpdList[i]._iStatFlag) CelDrawHdrOnly(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (BYTE *)pCursCels, frame, frame_width, 0, 8); else - CelDrawHdrLightRed(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (char *)pCursCels, frame, frame_width, 0, 8, 1); + CelDrawHdrLightRed(InvRect[i + 65].X + 64, InvRect[i + 65].Y + 159, (BYTE *)pCursCels, frame, frame_width, 0, 8, 1); if (AllItemsList[plr[myplr].SpdList[i].IDidx].iUsable && plr[myplr].SpdList[i]._iStatFlag diff --git a/Source/items.cpp b/Source/items.cpp index 86f27e852..39c37415b 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3767,8 +3767,8 @@ void __fastcall DrawULine(int y) char *v2; // edi signed int v3; // edx - v1 = &gpBuffer->row[25].pixels[26]; - v2 = &gpBuffer->row_unused_1[0].pixels[screen_y_times_768[SStringY[y] + 198] + 26]; + v1 = (char *)&gpBuffer[SCREENXY(26, 25)]; + v2 = (char *)&gpBuffer[screen_y_times_768[SStringY[y] + 198] + 26 + 64]; v3 = 3; do { qmemcpy(v2, v1, 0x10A); /* find real fix */ @@ -4129,15 +4129,18 @@ void __fastcall UseItem(int p, int Mid, int spl) } } -BOOLEAN __fastcall StoreStatOk(ItemStruct *h) +BOOL __fastcall StoreStatOk(ItemStruct *h) { - BOOLEAN sf; // al + BOOL sf; + + sf = TRUE; + if (plr[myplr]._pStrength < h->_iMinStr) + sf = FALSE; + if (plr[myplr]._pMagic < h->_iMinMag) + sf = FALSE; + if (plr[myplr]._pDexterity < h->_iMinDex) + sf = FALSE; - sf = 1; - if (plr[myplr]._pStrength < h->_iMinStr - || plr[myplr]._pMagic < h->_iMinMag - || plr[myplr]._pDexterity < h->_iMinDex) - sf = 0; return sf; } diff --git a/Source/items.h b/Source/items.h index cd058139e..e8c86fbab 100644 --- a/Source/items.h +++ b/Source/items.h @@ -88,7 +88,7 @@ void __fastcall PrintItemMisc(ItemStruct *x); void __fastcall PrintItemDetails(ItemStruct *x); void __fastcall PrintItemDur(ItemStruct *x); void __fastcall UseItem(int p, int Mid, int spl); -BOOLEAN __fastcall StoreStatOk(ItemStruct *h); +BOOL __fastcall StoreStatOk(ItemStruct *h); BOOL __fastcall SmithItemOk(int i); int __fastcall RndSmithItem(int lvl); void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b); diff --git a/Source/minitext.cpp b/Source/minitext.cpp index ec58a99fb..78b497586 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -96,59 +96,121 @@ void __cdecl DrawQTextBack() #include "asm_trans_rect.inc" } -void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame) +void __fastcall PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel) { - char *v4; // ebx - char *v5; // esi - char *v6; // edi - int v7; // ebx - signed int v8; // edx - unsigned int v9; // eax - unsigned int v10; // ecx - char v11; // cf - unsigned int v12; // ecx - char *v13; // [esp+14h] [ebp-8h] - char *v14; // [esp+18h] [ebp-4h] + BYTE *dst, *pStart, *pEnd, *end; - v13 = (char *)gpBuffer + screen_y_times_768[209]; - v14 = (char *)gpBuffer + screen_y_times_768[469]; - v4 = &cel_buf[4 * frame]; - v5 = &cel_buf[*(_DWORD *)v4]; - v6 = (char *)gpBuffer + screen_y_times_768[screen_y] + screen_x; - v7 = (int)&v5[*((_DWORD *)v4 + 1) - *(_DWORD *)v4]; - do { - v8 = 22; - do { - while (1) { - v9 = (unsigned char)*v5++; - if ((v9 & 0x80u) == 0) - break; - _LOBYTE(v9) = -(char)v9; - v6 += v9; - v8 -= v9; - if (!v8) - goto LABEL_15; - } - v8 -= v9; - if (v6 < v13 || v6 > v14) { - v5 += v9; - v6 += v9; - } else { - v10 = v9 >> 1; - if (!(v9 & 1) || (*v6 = *v5, ++v5, ++v6, v10)) { - v11 = v10 & 1; - v12 = v9 >> 2; - if (!v11 || (*(_WORD *)v6 = *(_WORD *)v5, v5 += 2, v6 += 2, v12)) { - qmemcpy(v6, v5, 4 * v12); - v5 += 4 * v12; - v6 += 4 * v12; + /// ASSERT: assert(gpBuffer); + + dst = &gpBuffer[sx + screen_y_times_768[sy]]; + pStart = &gpBuffer[screen_y_times_768[209]]; + pEnd = &gpBuffer[screen_y_times_768[469]]; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov ebx, pCelBuff + mov eax, nCel + shl eax, 2 + add ebx, eax + mov eax, [ebx+4] + sub eax, [ebx] + mov end, eax + mov esi, pCelBuff + add esi, [ebx] + mov edi, dst + mov ebx, end + add ebx, esi + label1: + mov edx, 22 + label2: + xor eax, eax + lodsb + or al, al + js label7 + sub edx, eax + cmp edi, pStart + jb label5 + cmp edi, pEnd + ja label5 + mov ecx, eax + shr ecx, 1 + jnb label3 + movsb + jecxz label6 + label3: + shr ecx, 1 + jnb label4 + movsw + jecxz label6 + label4: + rep movsd + jmp label6 + label5: + add esi, eax + add edi, eax + label6: + or edx, edx + jz label8 + jmp label2 + label7: + neg al + add edi, eax + sub edx, eax + jnz label2 + label8: + sub edi, 768 + 22 + cmp ebx, esi + jnz label1 + } +#else + int i; + BYTE width; + BYTE *src; + DWORD *pFrameTable; + + pFrameTable = (DWORD *)&pCelBuff[4 * nCel]; + src = &pCelBuff[pFrameTable[0]]; + end = &src[pFrameTable[1] - pFrameTable[0]]; + + for(; src != end; dst -= 768 + 22) { + for(i = 22; i;) { + width = *src++; + if(!(width & 0x80)) { + i -= width; + if(dst >= pStart && dst <= pEnd) { + if(width & 1) { + dst[0] = src[0]; + src++; + dst++; + } + width >>= 1; + if(width & 1) { + dst[0] = src[0]; + dst[1] = src[1]; + src += 2; + dst += 2; + } + width >>= 1; + for(; width; width--) { + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; + src += 4; + dst += 4; } + } else { + src += width; + dst += width; } + } else { + width = -(char)width; + dst += width; + i -= width; } - } while (v8); - LABEL_15: - v6 -= 790; - } while ((char *)v7 != v5); + } + } +#endif } void __cdecl DrawQText() @@ -213,7 +275,7 @@ void __cdecl DrawQText() if (*v0 == 10) ++v0; if (v10) - PrintQTextChr(screen_x, screen_y, (char *)pMedTextCels, v10); + PrintQTextChr(screen_x, screen_y, (BYTE *)pMedTextCels, v10); ++v9; screen_x += mfontkern[v10] + 2; v8 = *v9; diff --git a/Source/minitext.h b/Source/minitext.h index 8c7797047..fa27ae73c 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -14,7 +14,7 @@ void __cdecl FreeQuestText(); void __cdecl InitQuestText(); void __fastcall InitQTextMsg(int m); void __cdecl DrawQTextBack(); -void __fastcall PrintQTextChr(int screen_x, int screen_y, char *cel_buf, int frame); +void __fastcall PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel); void __cdecl DrawQText(); /* rdata */ diff --git a/Source/missiles.cpp b/Source/missiles.cpp index af7fe1f5c..ea201953e 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2439,7 +2439,7 @@ void __fastcall miss_null_11(int mi, int sx, int sy, int dx, int dy, int midir, SetMissDir(mi, dx); v10 = v9; missile[v10]._midam = 0; - missile[v10]._miLightFlag = 1; + missile[v10]._miLightFlag = TRUE; missile[v10]._mirange = 250; } @@ -2456,7 +2456,7 @@ void __fastcall miss_null_12(int mi, int sx, int sy, int dx, int dy, int midir, SetMissDir(mi, v9); v11 = v10; missile[v11]._midam = 0; - missile[v11]._miLightFlag = 1; + missile[v11]._miLightFlag = TRUE; missile[v11]._mirange = 250; } @@ -2475,56 +2475,43 @@ void __fastcall miss_null_13(int mi, int sx, int sy, int dx, int dy, int midir, v11 = v10; v12 = missile[v10]._miAnimLen; missile[v11]._midam = 0; - missile[v11]._miLightFlag = 1; + missile[v11]._miLightFlag = TRUE; missile[v11]._mirange = v12; } void __fastcall AddRhino(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam) { - int v9; // esi - CMonster *v10; // eax - char v11; // cl - AnimStruct *v12; // edi - int v13; // eax - CMonster *v14; // ecx - char v15; // cl - BOOLEAN v16; // zf - int i; // [esp+8h] [ebp-4h] + AnimStruct *anim; - v9 = id; - i = mi; - v10 = monster[id].MType; - v11 = v10->mtype; - if (v10->mtype < MT_HORNED || v11 > MT_OBLORD) { - if (v11 < MT_NSNAKE || (v12 = &v10->Anims[MA_ATTACK], v11 > MT_GSNAKE)) - v12 = &v10->Anims[MA_WALK]; + if (monster[id].MType->mtype < MT_HORNED || monster[id].MType->mtype > MT_OBLORD) { + if (monster[id].MType->mtype < MT_NSNAKE || monster[id].MType->mtype > MT_GSNAKE) { + anim = &monster[id].MType->Anims[MA_WALK]; + } else { + anim = &monster[id].MType->Anims[MA_ATTACK]; + } } else { - v12 = &v10->Anims[MA_SPECIAL]; - } - GetMissileVel(i, sx, sy, dx, dy, 18); - v13 = i; - missile[v13]._miAnimFlags = 0; - missile[v13]._mimfnum = midir; - missile[v13]._miAnimData = v12->Data[midir]; - missile[v13]._miAnimDelay = v12->Rate; - missile[v13]._miAnimLen = v12->Frames; - v14 = monster[v9].MType; - missile[v13]._miAnimWidth = v14->width; - missile[v13]._miAnimWidth2 = v14->width2; - missile[v13]._miAnimAdd = 1; - v15 = v14->mtype; - if (v15 >= MT_NSNAKE && v15 <= MT_GSNAKE) - missile[v13]._miAnimFrame = 7; - missile[v13]._miVar1 = 0; - missile[v13]._miVar2 = 0; - v16 = monster[v9]._uniqtype == 0; - missile[v13]._miLightFlag = 1; - if (!v16) { - missile[v13]._miUniqTrans = (unsigned char)monster[v9]._uniqtrans + 1; - missile[v13]._mlid = (unsigned char)monster[v9].mlid; - } - missile[v13]._mirange = 256; - PutMissile(i); + anim = &monster[id].MType->Anims[MA_SPECIAL]; + } + GetMissileVel(mi, sx, sy, dx, dy, 18); + missile[mi]._miAnimFlags = 0; + missile[mi]._mimfnum = midir; + missile[mi]._miAnimData = anim->Data[midir]; + missile[mi]._miAnimDelay = anim->Rate; + missile[mi]._miAnimLen = anim->Frames; + missile[mi]._miAnimWidth = monster[id].MType->width; + missile[mi]._miAnimWidth2 = monster[id].MType->width2; + missile[mi]._miAnimAdd = 1; + if (monster[id].MType->mtype >= MT_NSNAKE && monster[id].MType->mtype <= MT_GSNAKE) + missile[mi]._miAnimFrame = 7; + missile[mi]._miVar1 = 0; + missile[mi]._miVar2 = 0; + missile[mi]._miLightFlag = TRUE; + if (monster[id]._uniqtype != 0) { + missile[mi]._miUniqTrans = monster[id]._uniqtrans + 1; + missile[mi]._mlid = monster[id].mlid; + } + missile[mi]._mirange = 256; + PutMissile(mi); } void __fastcall miss_null_32(int mi, int sx, int sy, int dx, int dy, int midir, int mienemy, int id, int dam) @@ -2543,7 +2530,7 @@ void __fastcall miss_null_32(int mi, int sx, int sy, int dx, int dy, int midir, missile[mi]._miAnimAdd = 1; missile[mi]._miVar1 = 0; missile[mi]._miVar2 = 0; - missile[mi]._miLightFlag = 1; + missile[mi]._miLightFlag = TRUE; if (monster[id]._uniqtype != 0) missile[mi]._miUniqTrans = monster[id]._uniqtrans + 1; dMonster[monster[id]._mx][monster[id]._my] = 0; @@ -2621,7 +2608,7 @@ void __fastcall AddAcidpud(int mi, int sx, int sy, int dx, int dy, int midir, in missile[v9]._miyvel = 0; missile[v9]._mixoff = 0; missile[v9]._miyoff = 0; - missile[v9]._miLightFlag = 1; + missile[v9]._miLightFlag = TRUE; v11 = random(50, 15); missile[v9]._miPreFlag = TRUE; missile[v9]._mirange = v11 + 40 * ((unsigned char)monster[v10]._mint + 1); @@ -2767,7 +2754,7 @@ void __fastcall miss_null_23(int mi, int sx, int sy, int dx, int dy, int midir, SetMissDir(mi, 0); else SetMissDir(mi, 1); - missile[mi]._miLightFlag = 1; + missile[mi]._miLightFlag = TRUE; missile[mi]._mirange = missile[mi]._miAnimLen; } @@ -3290,7 +3277,7 @@ int __fastcall AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, missile[mi]._mityoff = 0; missile[mi]._miDelFlag = FALSE; missile[mi]._miAnimAdd = 1; - missile[mi]._miLightFlag = 0; + missile[mi]._miLightFlag = FALSE; missile[mi]._miPreFlag = FALSE; missile[mi]._miUniqTrans = 0; missile[mi]._midam = midam; @@ -4280,75 +4267,44 @@ void __fastcall MI_Etherealize(int i) void __fastcall MI_Firemove(int i) { - int v1; // esi - int *v2; // eax - int v4; // ecx - int v5; // ebx - int v6; // ecx - int v7; // edx - int v8; // ecx - int v9; // ST10_4 - int v10; // ecx - int ExpLight[14]; // [esp+Ch] [ebp-3Ch] - int ia; // [esp+44h] [ebp-4h] + int j; + int ExpLight[14] = { 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 12 }; - v1 = i; - ExpLight[3] = 5; - ExpLight[4] = 5; - missile[v1]._miyoff += 32; - ExpLight[11] = 12; - ExpLight[12] = 12; - --missile[v1]._mix; - --missile[v1]._miy; - ExpLight[0] = 2; - ExpLight[1] = 3; - ExpLight[2] = 4; - ExpLight[5] = 6; - ExpLight[6] = 7; - ExpLight[7] = 8; - ExpLight[8] = 9; - ExpLight[9] = 10; - ExpLight[10] = 11; - ia = i; - ExpLight[13] = 0; - v2 = &missile[i]._miVar1; - if (++*v2 == missile[i]._miAnimLen) { + missile[i]._mix--; + missile[i]._miy--; + missile[i]._miyoff += 32; + missile[i]._miVar1++; + if (missile[i]._miVar1 == missile[i]._miAnimLen) { SetMissDir(i, 1); - missile[v1]._miAnimFrame = random(82, 11) + 1; + missile[i]._miAnimFrame = random(82, 11) + 1; } - v4 = ia; - missile[v1]._mitxoff += missile[v1]._mixvel; - missile[v1]._mityoff += missile[v1]._miyvel; - GetMissilePos(v4); - v5 = missile[v1]._mirange; - CheckMissileCol(ia, missile[v1]._midam, missile[v1]._midam, 0, missile[v1]._mix, missile[v1]._miy, 0); - if (missile[v1]._miHitFlag) - missile[v1]._mirange = v5; - if (!missile[v1]._mirange) { - v6 = missile[v1]._mlid; - missile[v1]._miDelFlag = TRUE; - AddUnLight(v6); + missile[i]._mitxoff += missile[i]._mixvel; + missile[i]._mityoff += missile[i]._miyvel; + GetMissilePos(i); + j = missile[i]._mirange; + CheckMissileCol(i, missile[i]._midam, missile[i]._midam, 0, missile[i]._mix, missile[i]._miy, 0); + if (missile[i]._miHitFlag == TRUE) + missile[i]._mirange = j; + if (!missile[i]._mirange) { + missile[i]._miDelFlag = TRUE; + AddUnLight(missile[i]._mlid); } - if (missile[v1]._mimfnum || !missile[v1]._mirange) { - v7 = missile[v1]._mix; - if (v7 != missile[v1]._miVar3 || missile[v1]._miy != missile[v1]._miVar4) { - v8 = missile[v1]._mlid; - missile[v1]._miVar3 = v7; - v9 = missile[v1]._miy; - missile[v1]._miVar4 = v9; - ChangeLight(v8, v7, v9, 8); + if (missile[i]._mimfnum || !missile[i]._mirange) { + if (missile[i]._mix != missile[i]._miVar3 || missile[i]._miy != missile[i]._miVar4) { + missile[i]._miVar3 = missile[i]._mix; + missile[i]._miVar4 = missile[i]._miy; + ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, 8); } } else { - if (!missile[v1]._miVar2) - missile[v1]._mlid = AddLight(missile[v1]._mix, missile[v1]._miy, ExpLight[0]); - ChangeLight(missile[v1]._mlid, missile[v1]._mix, missile[v1]._miy, ExpLight[missile[v1]._miVar2]); - ++missile[v1]._miVar2; + if (!missile[i]._miVar2) + missile[i]._mlid = AddLight(missile[i]._mix, missile[i]._miy, ExpLight[0]); + ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, ExpLight[missile[i]._miVar2]); + missile[i]._miVar2++; } - ++missile[v1]._mix; - v10 = ia; - ++missile[v1]._miy; - missile[v1]._miyoff -= 32; - PutMissile(v10); + missile[i]._mix++; + missile[i]._miy++; + missile[i]._miyoff -= 32; + PutMissile(i); } void __fastcall MI_Guardian(int i) @@ -4746,78 +4702,44 @@ void __fastcall MI_Rhino(int i) void __fastcall mi_null_32(int i) { - int v1; // edi - int v2; // esi - int v3; // ebx - int v4; // edi - int v5; // eax - int v6; // eax - int v7; // ecx - int v8; // eax - int v9; // eax - int v10; // ebx - int v11; // eax - //int v12; // eax - int v13; // ecx - int v14; // ecx - unsigned char *v15; // eax - int v16; // [esp+Ch] [ebp-14h] - int arglist; // [esp+10h] [ebp-10h] - int x; // [esp+14h] [ebp-Ch] - int y; // [esp+18h] [ebp-8h] - int a3; // [esp+1Ch] [ebp-4h] + int src, enemy, ax, ay, bx, by, cx, cy, j; - v1 = i; - arglist = i; GetMissilePos(i); - v2 = v1; - v3 = missile[v1]._mix; - a3 = missile[v1]._miy; - missile[v2]._mitxoff += missile[v1]._mixvel; - missile[v2]._mityoff += missile[v1]._miyvel; - GetMissilePos(v1); - v4 = missile[v1]._misource; - y = missile[v2]._miy; - v5 = monster[v4]._menemy; - x = missile[v2]._mix; - if (monster[v4]._mFlags & MFLAG_TARGETS_MONSTER) { - v9 = v5; - v7 = monster[v9]._mx; - v8 = monster[v9]._my; + ax = missile[i]._mix; + ay = missile[i]._miy; + missile[i]._mitxoff += missile[i]._mixvel; + missile[i]._mityoff += missile[i]._miyvel; + GetMissilePos(i); + src = missile[i]._misource; + bx = missile[i]._mix; + by = missile[i]._miy; + enemy = monster[src]._menemy; + if (!(monster[src]._mFlags & MFLAG_TARGETS_MONSTER)) { + cx = plr[enemy].WorldX; + cy = plr[enemy].WorldY; } else { - v6 = v5; - v7 = plr[v6].WorldX; - v8 = plr[v6].WorldY; - } - v16 = v8; - if ((missile[v2]._mix != v3 || y != a3) - && (missile[v2]._miVar1 & 1 && (abs(v3 - v7) >= 4 || abs(a3 - v16) >= 4) || missile[v2]._miVar2 > 1) - && PosOkMonst(missile[v2]._misource, v3, a3)) { - MissToMonst(arglist, v3, a3); - v10 = v16; - missile[v2]._miDelFlag = TRUE; + cx = monster[enemy]._mx; + cy = monster[enemy]._my; + } + if ((bx != ax || by != ay) && (missile[i]._miVar1 & 1 && (abs(ax - cx) >= 4 || abs(ay - cy) >= 4) || missile[i]._miVar2 > 1) && PosOkMonst(missile[i]._misource, ax, ay)) { + MissToMonst(i, ax, ay); + missile[i]._miDelFlag = TRUE; + } else if (!(monster[src]._mFlags & MFLAG_TARGETS_MONSTER)) { + j = dPlayer[bx][by]; } else { - v11 = x; - if (monster[v4]._mFlags & MFLAG_TARGETS_MONSTER) - v10 = dMonster[v11][y]; - else - v10 = dPlayer[v11][y]; - } - //_LOBYTE(v12) = PosOkMissile(x, y); - if (!PosOkMissile(x, y) || v10 > 0 && !(missile[v2]._miVar1 & 1)) { - missile[v2]._mixvel = -missile[v2]._mixvel; - v13 = missile[v2]._mimfnum; - missile[v2]._miyvel = -missile[v2]._miyvel; - v14 = opposite[v13]; - missile[v2]._mimfnum = v14; - v15 = monster[v4].MType->Anims[MA_WALK].Data[v14]; - ++missile[v2]._miVar2; - missile[v2]._miAnimData = v15; - if (v10 > 0) - missile[v2]._miVar1 |= 1u; + j = dMonster[bx][by]; } - MoveMissilePos(arglist); - PutMissile(arglist); + if (!PosOkMissile(bx, by) || j > 0 && !(missile[i]._miVar1 & 1)) { + missile[i]._mixvel *= -1; + missile[i]._miyvel *= -1; + missile[i]._mimfnum = opposite[missile[i]._mimfnum]; + missile[i]._miAnimData = monster[src].MType->Anims[MA_WALK].Data[missile[i]._mimfnum]; + missile[i]._miVar2++; + if (j > 0) + missile[i]._miVar1 |= 1; + } + MoveMissilePos(i); + PutMissile(i); } void __fastcall MI_FirewallC(int i) @@ -5497,66 +5419,32 @@ void __fastcall MI_Bonespirit(int i) void __fastcall MI_ResurrectBeam(int i) { - int v1; // eax - BOOLEAN v2; // zf - - v1 = i; - v2 = missile[i]._mirange == 1; - --missile[v1]._mirange; - if (v2) - missile[v1]._miDelFlag = TRUE; + missile[i]._mirange--; + if (missile[i]._mirange == 0) + missile[i]._miDelFlag = TRUE; PutMissile(i); } void __fastcall MI_Rportal(int i) { - int v1; // esi - int v2; // eax - int v3; // ecx - int ExpLight[17]; // [esp+8h] [ebp-48h] - int ia; // [esp+4Ch] [ebp-4h] + int ExpLight[17] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15 }; - v1 = i; - ExpLight[14] = 15; - ExpLight[15] = 15; - ExpLight[16] = 15; - v2 = missile[i]._mirange; - ia = i; - ExpLight[0] = 1; - ExpLight[1] = 2; - ExpLight[2] = 3; - ExpLight[3] = 4; - ExpLight[4] = 5; - ExpLight[5] = 6; - ExpLight[6] = 7; - ExpLight[7] = 8; - ExpLight[8] = 9; - ExpLight[9] = 10; - ExpLight[10] = 11; - ExpLight[11] = 12; - ExpLight[12] = 13; - ExpLight[13] = 14; - if (v2 > 1) - missile[v1]._mirange = v2 - 1; - if (missile[v1]._mirange == missile[v1]._miVar1) + if (missile[i]._mirange > 1) + missile[i]._mirange--; + if (missile[i]._mirange == missile[i]._miVar1) SetMissDir(i, 1); - if (currlevel && missile[v1]._mimfnum != 1) { - if (!missile[v1]._mirange) { - LABEL_12: - v3 = missile[v1]._mlid; - missile[v1]._miDelFlag = TRUE; - AddUnLight(v3); - goto LABEL_13; - } - if (!missile[v1]._miVar2) - missile[v1]._mlid = AddLight(missile[v1]._mix, missile[v1]._miy, 1); - ChangeLight(missile[v1]._mlid, missile[v1]._mix, missile[v1]._miy, ExpLight[missile[v1]._miVar2]); - ++missile[v1]._miVar2; + + if (currlevel && missile[i]._mimfnum != 1 && missile[i]._mirange != 0) { + if (!missile[i]._miVar2) + missile[i]._mlid = AddLight(missile[i]._mix, missile[i]._miy, 1); + ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, ExpLight[missile[i]._miVar2]); + missile[i]._miVar2++; } - if (!missile[v1]._mirange) - goto LABEL_12; -LABEL_13: - PutMissile(ia); + if (!missile[i]._mirange) { + missile[i]._miDelFlag = TRUE; + AddUnLight(missile[i]._mlid); + } + PutMissile(i); } void __cdecl ProcessMissiles() @@ -5619,33 +5507,26 @@ void __cdecl ProcessMissiles() void __cdecl missiles_process_charge() { - int v0; // ebx - int i; // edi - int v2; // ecx - int v3; // esi - BOOLEAN v4; // zf - CMonster *v5; // eax - char v6; // dl - AnimStruct *v7; // eax - - v0 = nummissiles; - for (i = 0; i < v0; ++i) { - v2 = missileactive[i]; - v3 = missile[v2]._mimfnum; - v4 = missile[v2]._mitype == MIS_RHINO; - missile[v2]._miAnimData = misfiledata[0].mAnimData[v3 + 59 * _LOBYTE(missile[v2]._miAnimType)]; - if (v4) { - v5 = monster[missile[v2]._misource].MType; - v6 = v5->mtype; - if (v5->mtype < MT_HORNED || v6 > MT_OBLORD) { - if (v6 < MT_NSNAKE || v6 > MT_GSNAKE) - v7 = &v5->Anims[MA_WALK]; - else - v7 = &v5->Anims[MA_ATTACK]; + CMonster *mon; + AnimStruct *anim; + MissileStruct *mis; + int i, mi; + + for (i = 0; i < nummissiles; i++) { + mi = missileactive[i]; + mis = &missile[mi]; + mis->_miAnimData = misfiledata[mis->_miAnimType].mAnimData[mis->_mimfnum]; + if (mis->_mitype == MIS_RHINO) { + mon = monster[mis->_misource].MType; + if (mon->mtype >= MT_HORNED && mon->mtype <= MT_OBLORD) { + anim = &mon->Anims[MA_SPECIAL]; } else { - v7 = &v5->Anims[MA_SPECIAL]; + if (mon->mtype >= MT_NSNAKE && mon->mtype <= MT_GSNAKE) + anim = &mon->Anims[MA_ATTACK]; + else + anim = &mon->Anims[MA_WALK]; } - missile[v2]._miAnimData = v7->Data[v3]; + missile[mi]._miAnimData = anim->Data[mis->_mimfnum]; } } } diff --git a/Source/objects.cpp b/Source/objects.cpp index 4b3742f1e..f0add46fb 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2631,34 +2631,44 @@ void __fastcall objects_set_door_piece(int x, int y) void __fastcall ObjSetMini(int x, int y, int v) { - unsigned short *v3; // esi - unsigned short v4; // ax - int v5; // eax - int pn; // ST1C_4 - int v7; // ST18_4 - int v8; // ST14_4 - int v9; // ST10_4 - int v10; // esi - int v11; // edi - - v3 = (unsigned short *)((char *)pMegaTiles + 8 * ((unsigned short)v - 1)); - v4 = *v3; - ++v3; - v5 = v4 + 1; - pn = v5; - _LOWORD(v5) = *v3; - ++v3; - v7 = ++v5; - _LOWORD(v5) = *v3; - v8 = ++v5; - _LOWORD(v5) = v3[1]; - v9 = v5 + 1; - v10 = 2 * x + 16; - v11 = 2 * y + 16; - ObjSetMicro(v10, v11, pn); - ObjSetMicro(v10 + 1, v11++, v7); - ObjSetMicro(v10, v11, v8); - ObjSetMicro(v10 + 1, v11, v9); + int xx, yy; + long v1, v2, v3, v4; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pMegaTiles + xor eax, eax + mov ax, word ptr v + dec eax + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + } +#else + v1 = *((WORD *)&pMegaTiles[((WORD)v-1)*8])+1; + v2 = *((WORD *)&pMegaTiles[((WORD)v-1)*8]+1)+1; + v3 = *((WORD *)&pMegaTiles[((WORD)v-1)*8]+2)+1; + v4 = *((WORD *)&pMegaTiles[((WORD)v-1)*8]+3)+1; +#endif + + xx = 2 * x + 16; + yy = 2 * y + 16; + ObjSetMicro(xx, yy, v1); + ObjSetMicro(xx + 1, yy, v2); + ObjSetMicro(xx, yy + 1, v3); + ObjSetMicro(xx + 1, yy + 1, v4); } void __fastcall ObjL1Special(int x1, int y1, int x2, int y2) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 357fd3563..435c8dfcb 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -873,8 +873,8 @@ void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, if (v18 >= 1 && *(_DWORD *)v17 <= 0x32u && v18 <= *(_DWORD *)v17) { v19 = a4 - v16->_iAnimWidth2; if (v49 - 1 == pcursitem) - CelDrawHdrClrHL(ICOL_BLUE, v19, a5, v17, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); - Cel2DecodeHdrLight(v19, a5, (char *)v16->_iAnimData, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); + CelDrawHdrClrHL(ICOL_BLUE, v19, a5, (BYTE *)v17, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); + Cel2DecodeHdrLight(v19, a5, v16->_iAnimData, v16->_iAnimFrame, v16->_iAnimWidth, 0, 8); } } } @@ -987,11 +987,11 @@ void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, if (v38 >= 1 && *(_DWORD *)v37 <= 0x32u && v38 <= *(_DWORD *)v37) { v39 = a4 - v36->_iAnimWidth2; if (v49 - 1 == pcursitem) - CelDrawHdrClrHL(ICOL_BLUE, v39, a5, v37, v36->_iAnimFrame, v36->_iAnimWidth, 0, 8); + CelDrawHdrClrHL(ICOL_BLUE, v39, a5, (BYTE *)v37, v36->_iAnimFrame, v36->_iAnimWidth, 0, 8); Cel2DecodeHdrLight( v39, a5, - (char *)v36->_iAnimData, + v36->_iAnimData, v36->_iAnimFrame, v36->_iAnimWidth, 0, @@ -1003,7 +1003,7 @@ void __fastcall scrollrt_draw_clipped_dungeon(char *a1, int sx, int sy, int a4, } if (v46) { cel_transparency_active = (unsigned char)TransList[v44]; - Cel2DecodeLightTrans(dst_buf, (char *)level_special_cel, v46, 64, 0, 8); + Cel2DecodeLightTrans((BYTE *)dst_buf, (BYTE *)level_special_cel, v46, 64, 0, 8); } } // 4B8CC0: using guessed type char pcursitem; @@ -1111,9 +1111,9 @@ void __fastcall DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int a6 } if(bv == pcursobj) - CelDrawHdrClrHL(194, sx, sy, (char *)object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); + CelDrawHdrClrHL(194, sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); if(object[bv]._oLight) - Cel2DecodeHdrLight(sx, sy, (char *)object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); + Cel2DecodeHdrLight(sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); else Cel2DrawHdrOnly(sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); } @@ -1473,8 +1473,8 @@ void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int if (v21 >= 1 && *(_DWORD *)v20 <= 0x32u && v21 <= *(_DWORD *)v20) { v22 = v13 - v19->_iAnimWidth2; if (v52 - 1 == pcursitem) - CelDrawHdrClrHL(ICOL_BLUE, v22, sy, v20, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); - Cel2DecodeHdrLight(v22, sy, (char *)v19->_iAnimData, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); + CelDrawHdrClrHL(ICOL_BLUE, v22, sy, (BYTE *)v20, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); + Cel2DecodeHdrLight(v22, sy, v19->_iAnimData, v19->_iAnimFrame, v19->_iAnimWidth, a5, 8); } } } @@ -1589,11 +1589,11 @@ void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int if (v41 >= 1 && *(_DWORD *)v40 <= 0x32u && v41 <= *(_DWORD *)v40) { v42 = v13 - v39->_iAnimWidth2; if (v52 - 1 == pcursitem) - CelDrawHdrClrHL(ICOL_BLUE, v42, sy, v40, v41, v39->_iAnimWidth, a5, 8); + CelDrawHdrClrHL(ICOL_BLUE, v42, sy, (BYTE *)v40, v41, v39->_iAnimWidth, a5, 8); Cel2DecodeHdrLight( v42, sy, - (char *)v39->_iAnimData, + v39->_iAnimData, v39->_iAnimFrame, v39->_iAnimWidth, a5, @@ -1605,7 +1605,7 @@ void __fastcall scrollrt_draw_clipped_dungeon_2(char *buffer, int x, int y, int } if (v49) { cel_transparency_active = (unsigned char)TransList[v47]; - Cel2DecodeLightTrans(dst_buf, (char *)level_special_cel, v49, 64, a5, 8); + Cel2DecodeLightTrans((BYTE *)dst_buf, (BYTE *)level_special_cel, v49, 64, a5, 8); } } // 4B8CC0: using guessed type char pcursitem; @@ -2013,8 +2013,8 @@ void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5 if (v20 >= 1 && *(_DWORD *)v19 <= 0x32u && v20 <= *(_DWORD *)v19) { v21 = sx - v18->_iAnimWidth2; if (v51 - 1 == pcursitem) - CelDecodeClr(ICOL_BLUE, v21, sy, v19, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); - CelDecodeHdrLightOnly(v21, sy, (char *)v18->_iAnimData, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); + CelDecodeClr(ICOL_BLUE, v21, sy, (BYTE *)v19, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); + CelDecodeHdrLightOnly(v21, sy, v18->_iAnimData, v18->_iAnimFrame, v18->_iAnimWidth, 0, a5); } } } @@ -2127,11 +2127,11 @@ void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5 if (v40 >= 1 && *(_DWORD *)v39 <= 0x32u && v40 <= *(_DWORD *)v39) { v41 = sx - v38->_iAnimWidth2; if (v51 - 1 == pcursitem) - CelDecodeClr(ICOL_BLUE, v41, sy, v39, v38->_iAnimFrame, v38->_iAnimWidth, 0, a5); + CelDecodeClr(ICOL_BLUE, v41, sy, (BYTE *)v39, v38->_iAnimFrame, v38->_iAnimWidth, 0, a5); CelDecodeHdrLightOnly( v41, sy, - (char *)v38->_iAnimData, + v38->_iAnimData, v38->_iAnimFrame, v38->_iAnimWidth, 0, @@ -2143,7 +2143,7 @@ void __fastcall scrollrt_draw_dungeon(char *buffer, int x, int y, int a4, int a5 } if (v48) { cel_transparency_active = (unsigned char)TransList[v46]; - CelDecodeHdrLightTrans(dst_buf, (char *)level_special_cel, v48, 64, 0, a5); + CelDecodeHdrLightTrans((BYTE *)dst_buf, (BYTE *)level_special_cel, v48, 64, 0, a5); } } // 4B8CC0: using guessed type char pcursitem; @@ -2251,9 +2251,9 @@ void __fastcall DrawObject(int x, int y, int ox, int oy, BOOL pre, int a6, int d } if(bv == pcursobj) - CelDecodeClr(194, sx, sy, (char *)object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); + CelDecodeClr(194, sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); if(object[bv]._oLight) { - CelDecodeHdrLightOnly(sx, sy, (char *)object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); + CelDecodeHdrLightOnly(sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, a6, dir); } else { /// ASSERT: assert(object[bv]._oAnimData); if(object[bv]._oAnimData) // BUGFIX: _oAnimData was already checked, this is redundant @@ -2465,7 +2465,7 @@ void __fastcall DrawZoom(int x, int y) LABEL_24: v11 = (_WORD *)((char *)gpBuffer + a6b); v12 = (char *)gpBuffer + a5a; - v13 = &gpBuffer->row_unused_1[1].col_unused_1[a6b]; + v13 = (char *)&gpBuffer[a6b + 768]; v14 = 176; do { v15 = v19; @@ -2501,7 +2501,7 @@ void __cdecl ClearScreenBuffer() j_lock_buf_priv(3); for (i = 0; i < 480; i++) - memset(gpBuffer->row[i].pixels, 0, 640); + memset(&gpBuffer[SCREENXY(0, i)], 0, 640); j_unlock_buf_priv(3); } @@ -2629,7 +2629,7 @@ void __cdecl scrollrt_draw_cursor_back_buffer() if (sgdwCursWdt) { v1 = sgdwCursY; v2 = sgSaveBack; - v3 = &gpBuffer->row[sgdwCursY].pixels[sgdwCursX]; + v3 = (char *)&gpBuffer[SCREENXY(sgdwCursX, sgdwCursY)]; v4 = sgdwCursHgt; if (sgdwCursHgt) { v5 = sgdwCursHgt; @@ -2701,7 +2701,7 @@ void __cdecl scrollrt_draw_cursor_item() v14 = sgSaveBack; v6 = 1 - v3 + v5; sgdwCursHgt = v6; - v7 = &gpBuffer->row[v3].pixels[v2 & 0xFFFFFFFC]; + v7 = (char *)&gpBuffer[SCREENXY(v2 & 0xFFFFFFFC, v3)]; if (v6) { v8 = v6; do { @@ -2725,10 +2725,10 @@ void __cdecl scrollrt_draw_cursor_item() if (!plr[myplr].HoldItem._iStatFlag) colour = ICOL_RED; v12 = v9 + 64; - CelDrawHdrClrHL(colour, v12, v1 + v10 + 159, (char *)pCursCels, pcurs, v0, 0, 8); + CelDrawHdrClrHL(colour, v12, v1 + v10 + 159, (BYTE *)pCursCels, pcurs, v0, 0, 8); v13 = cursH + v10 + 159; if (colour == ICOL_RED) - Cel2DrawHdrLightRed(v12, v13, (char *)pCursCels, pcurs, cursW, 0, 8, 1); + Cel2DrawHdrLightRed(v12, v13, (BYTE *)pCursCels, pcurs, cursW, 0, 8, 1); else Cel2DrawHdrOnly(v12, v13, (BYTE *)pCursCels, pcurs, cursW, 0, 8); } diff --git a/Source/sound.cpp b/Source/sound.cpp index 8cdb5c326..02f706f31 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -6,7 +6,7 @@ DEVILUTION_BEGIN_NAMESPACE LPDIRECTSOUNDBUFFER DSBs[8]; LPDIRECTSOUND sglpDS; -char gbSndInited; +BOOLEAN gbSndInited; int sglMusicVolume; int sglSoundVolume; HMODULE hDsound_dll; diff --git a/Source/sound.h b/Source/sound.h index 9ef9a2f2d..ffc0439f2 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -3,7 +3,7 @@ #define __SOUND_H__ extern IDirectSoundBuffer *DSBs[8]; -extern char gbSndInited; +extern BOOLEAN gbSndInited; extern HMODULE hDsound_dll; void __fastcall snd_update(BOOL bStopAll); diff --git a/Source/stores.cpp b/Source/stores.cpp index 9cdaebb1c..8f628dff8 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -579,35 +579,36 @@ void __cdecl S_StartSmith() void __fastcall S_ScrollSBuy(int idx) { - int v1; // esi - int v2; // edi - char *v3; // esi - char *v4; // eax - int iclr; // [esp+Ch] [ebp-4h] + int y; + char clr; - v1 = idx; - v2 = 5; ClearSText(5, 21); - v3 = &smithitem[v1]._iMagical; stextup = 5; - do { - if (*((_DWORD *)v3 - 13) != -1) { - _LOBYTE(iclr) = COL_WHITE; - if (*v3) - _LOBYTE(iclr) = COL_BLUE; - if (!*((_DWORD *)v3 + 74)) - _LOBYTE(iclr) = COL_RED; - v4 = v3 + 65; - if (!*v3) - v4 = v3 + 1; - AddSText(20, v2, 0, v4, iclr, 1); - AddSTextVal(v2, *((_DWORD *)v3 + 35)); - PrintStoreItem((ItemStruct *)(v3 - 60), v2 + 1, iclr); - stextdown = v2; - v3 += 368; + + for (y = 5; y < 20; y += 4) { + if (smithitem[idx]._itype != -1) { + clr = COL_WHITE; + if (smithitem[idx]._iMagical) { + clr = COL_BLUE; + } + + if (!smithitem[idx]._iStatFlag) { + clr = COL_RED; + } + + if (smithitem[idx]._iMagical) { + AddSText(20, y, 0, smithitem[idx]._iIName, clr, 1); + } else { + AddSText(20, y, 0, smithitem[idx]._iName, clr, 1); + } + + AddSTextVal(y, smithitem[idx]._iIvalue); + PrintStoreItem(&smithitem[idx], y + 1, clr); + stextdown = y; + idx++; } - v2 += 4; - } while (v2 < 20); + } + if (!stext[stextsel]._ssel && stextsel != 22) stextsel = stextdown; } diff --git a/Source/town.cpp b/Source/town.cpp index 15e818c7f..6304a3959 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -4,83 +4,143 @@ DEVILUTION_BEGIN_NAMESPACE -void __fastcall town_clear_upper_buf(unsigned char *a1) +void __fastcall town_clear_upper_buf(BYTE *pBuff) { - unsigned char *v1; // edi - signed int v2; // edx - signed int v3; // ebx - unsigned char *v4; // edi - signed int v5; // edx - signed int v6; // ebx - unsigned char *v7; // edi + /// ASSERT: assert(gpBuffer); - v1 = a1; - v2 = 30; - v3 = 1; - while (v1 >= gpBufEnd) { - v4 = &v1[v2]; - memset(v4, 0, 4 * v3); - v1 = &v4[4 * v3 - 832 + v2]; - if (!v2) { - v5 = 2; - v6 = 15; - do { - if (v1 < gpBufEnd) - break; - v7 = &v1[v5]; - memset(v7, 0, 4 * v6); - v1 = &v7[4 * v6-- - 832 + v5]; - v5 += 2; - } while (v5 != 32); - return; - } - v2 -= 2; - ++v3; +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov edi, pBuff + mov edx, 30 + mov ebx, 1 + xor eax, eax + label1: + cmp edi, gpBufEnd + jb label4 + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + sub edi, 768 + 64 + or edx, edx + jz label2 + sub edx, 2 + inc ebx + jmp label1 + label2: + mov edx, 2 + mov ebx, 15 + label3: + cmp edi, gpBufEnd + jb label4 + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + sub edi, 768 + 64 + dec ebx + add edx, 2 + cmp edx, 32 + jnz label3 + label4: + nop + } +#else + int i, j, k; + BYTE *dst; + + dst = pBuff; + + for(i = 30, j = 1; i >= 0 && dst >= gpBufEnd; i -= 2, j++, dst -= 768 + 64) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } + for(i = 2, j = 15; i != 32 && dst >= gpBufEnd; i += 2, j--, dst -= 768 + 64) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; + } +#endif } // 69CF0C: using guessed type int gpBufEnd; -void __fastcall town_clear_low_buf(unsigned char *y_related) +void __fastcall town_clear_low_buf(BYTE *pBuff) { - unsigned char *v1; // edi - signed int v2; // edx - signed int i; // ebx - unsigned char *v4; // edi - unsigned char *v5; // edi - signed int v6; // edx - signed int v7; // ebx - unsigned char *v8; // edi - unsigned char *v9; // edi + /// ASSERT: assert(gpBuffer); + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov edi, pBuff + mov edx, 30 + mov ebx, 1 + xor eax, eax + label1: + cmp edi, gpBufEnd + jb label2 + add edi, 64 + jmp label3 + label2: + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + label3: + sub edi, 768 + 64 + or edx, edx + jz label4 + sub edx, 2 + inc ebx + jmp label1 + label4: + mov edx, 2 + mov ebx, 15 + label5: + cmp edi, gpBufEnd + jb label6 + add edi, 64 + jmp label7 + label6: + add edi, edx + mov ecx, ebx + rep stosd + add edi, edx + label7: + sub edi, 768 + 64 + dec ebx + add edx, 2 + cmp edx, 32 + jnz label5 + } +#else + int i, j, k; + BYTE *dst; - v1 = y_related; - v2 = 30; - for (i = 1;; ++i) { - if (v1 < gpBufEnd) { - v5 = &v1[v2]; - memset(v5, 0, 4 * i); - v4 = &v5[4 * i + v2]; + dst = pBuff; + + for(i = 30, j = 1; i >= 0; i -= 2, j++, dst -= 768 + 64) { + if(dst < gpBufEnd) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } else { - v4 = v1 + 64; + dst += 64; } - v1 = v4 - 832; - if (!v2) - break; - v2 -= 2; } - v6 = 2; - v7 = 15; - do { - if (v1 < gpBufEnd) { - v9 = &v1[v6]; - memset(v9, 0, 4 * v7); - v8 = &v9[4 * v7 + v6]; + for(i = 2, j = 15; i != 32; i += 2, j--, dst -= 768 + 64) { + if(dst < gpBufEnd) { + dst += i; + for(k = 0; k < 4 * j; k++) + *dst++ = 0; + dst += i; } else { - v8 = v1 + 64; + dst += 64; } - v1 = v8 - 832; - --v7; - v6 += 2; - } while (v6 != 32); + } +#endif } // 69CF0C: using guessed type int gpBufEnd; @@ -148,7 +208,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s ICOL_BLUE, v11, sy, - (char *)item[v10]._iAnimData, + item[v10]._iAnimData, item[v10]._iAnimFrame, item[v10]._iAnimWidth, 0, @@ -163,7 +223,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s 166, v13, sy, - (char *)towner[v12]._tAnimData, + towner[v12]._tAnimData, towner[v12]._tAnimFrame, towner[v12]._tAnimWidth, 0, @@ -180,7 +240,7 @@ void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int s 166, v17, sy, - (char *)towner[v16]._tAnimData, + towner[v16]._tAnimData, towner[v16]._tAnimFrame, towner[v16]._tAnimWidth, 0, @@ -253,7 +313,7 @@ void __fastcall town_draw_lower(int x, int y, int sx, int sy, int a5, int some_f if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX && (level_cel_block = dPiece[x][y]) != 0) { v6 = sy; v7 = &screen_y_times_768[sy]; - a1 = (unsigned char *)&gpBuffer->row_unused_1[0].col_unused_1[*v7 + 32 + sx]; + a1 = (unsigned char *)&gpBuffer[*v7 + 32 + sx]; v25 = 1; v8 = (char *)dpiece_defs_map_1 + 32 * gendung_get_dpiece_num_from_coord(x, y); do { @@ -408,7 +468,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i ICOL_BLUE, v13, sy, - (char *)item[v12]._iAnimData, + item[v12]._iAnimData, item[v12]._iAnimFrame, item[v12]._iAnimWidth, a5, @@ -423,7 +483,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i 166, v15, sy, - (char *)towner[v14]._tAnimData, + towner[v14]._tAnimData, towner[v14]._tAnimFrame, towner[v14]._tAnimWidth, a5, @@ -440,7 +500,7 @@ void __fastcall town_draw_clipped_town_2(int x, int y, int a3, int a4, int a5, i 166, v19, sy, - (char *)towner[v18]._tAnimData, + towner[v18]._tAnimData, towner[v18]._tAnimFrame, towner[v18]._tAnimWidth, a5, @@ -655,21 +715,21 @@ void __fastcall town_draw_town_all(BYTE *buffer, int x, int y, int a4, int dir, ii = dItem[x][y] - 1; xx = sx - item[ii]._iAnimWidth2; if (ii == pcursitem) - CelDecodeClr(ICOL_BLUE, xx, sy, (char *)item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir); + CelDecodeClr(ICOL_BLUE, xx, sy, item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir); CelDrawHdrOnly(xx, sy, item[ii]._iAnimData, item[ii]._iAnimFrame, item[ii]._iAnimWidth, 0, dir); } if (dFlags[x][y] & DFLAG_MONSTER) { mi = -1 - dMonster[x][y - 1]; xx = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) - CelDecodeClr(PAL16_BEIGE + 6, xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDecodeClr(PAL16_BEIGE + 6, xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); CelDrawHdrOnly(xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); } if (dMonster[x][y] > 0) { mi = dMonster[x][y] - 1; xx = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) - CelDecodeClr(PAL16_BEIGE + 6, xx, sy, (char *)towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDecodeClr(PAL16_BEIGE + 6, xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); CelDrawHdrOnly(xx, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); } if (dFlags[x][y] & DFLAG_PLAYER) { @@ -712,7 +772,7 @@ void __fastcall town_draw_upper(int x, int y, int sx, int sy, INT_PTR a5, int a6 int v14; // esi int v15; // edi int v16; // eax - Screen *v17; // eax + BYTE *v17; // eax unsigned char *v18; // ebx char *v19; // edi int v20; // eax @@ -749,7 +809,7 @@ void __fastcall town_draw_upper(int x, int y, int sx, int sy, INT_PTR a5, int a6 v10 = v9 == 0; v11 = sy; if (!v10) { - a1 = (int *)&gpBuffer->row_unused_1[0].col_unused_1[sx + 32 + screen_y_times_768[sy]]; + a1 = (int *)&gpBuffer[sx + 32 + screen_y_times_768[sy]]; sxa = 0; v12 = &dpiece_defs_map_1[0][16 * gendung_get_dpiece_num_from_coord(x, y) + 1]; do { @@ -1106,7 +1166,7 @@ void __fastcall T_DrawZoom(int x, int y) LABEL_24: v11 = (_WORD *)((char *)gpBuffer + a5a); v12 = (char *)gpBuffer + a6b; - v13 = &gpBuffer->row_unused_1[1].col_unused_1[a5a]; + v13 = (char *)&gpBuffer[a5a + 768]; v14 = 176; do { v15 = v19; @@ -1245,94 +1305,121 @@ void __cdecl town_init_dpiece_defs_map() // 5C3000: using guessed type int scr_pix_width; // 5C3004: using guessed type int scr_pix_height; -void __fastcall T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) /* check 7 params: int AddSec */ +void __fastcall T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) { - int v7; // ebx - int v8; // edx - int v9; // edi - int *v10; // ecx - int v11; // eax - unsigned char *v12; // esi - unsigned short v13; // ax - int v14; // eax - int v15; // [esp+4h] [ebp-14h] - int v16; // [esp+8h] [ebp-10h] - unsigned char *v17; // [esp+Ch] [ebp-Ch] - unsigned char *v18; // [esp+10h] [ebp-8h] - signed int v19; // [esp+14h] [ebp-4h] - int a4; // [esp+24h] [ebp+Ch] - int a6; // [esp+2Ch] [ebp+14h] + int i, j, xx, yy; + long v1, v2, v3, v4, ii; - v7 = h; - v17 = pSector; - v8 = yi; - v18 = P3Tiles; - v19 = 4; - if (h > 0) { - do { - v9 = w; - if (w > 0) { - v10 = &dPiece[1][v8 + 112 * xi]; - do { - v11 = *(unsigned short *)&v17[v19]; - if ((_WORD)v11) { - v12 = &v18[8 * (v11 - 1)]; - v13 = *(_WORD *)v12; - v12 += 2; - v14 = v13 + 1; - a4 = v14; - _LOWORD(v14) = *(_WORD *)v12; - v12 += 2; - a6 = ++v14; - _LOWORD(v14) = *(_WORD *)v12; - v16 = ++v14; - _LOWORD(v14) = *((_WORD *)v12 + 1); - v15 = v14 + 1; - } else { - a4 = 0; - a6 = 0; - v16 = 0; - v15 = 0; - } - v19 += 2; - *(v10 - 112) = a4; - *v10 = a6; - *(v10 - 111) = v16; - v10[1] = v15; - v10 += 224; - --v9; - } while (v9); + ii = 4; + yy = yi; + for(j = 0; j < h; j++) { + xx = xi; + for(i = 0; i < w; i++) { +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov esi, pSector + mov eax, ii + add esi, eax + xor eax, eax + lodsw + or eax, eax + jz label1 + dec eax + mov esi, P3Tiles + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + jmp label2 + label1: + mov v1, eax + mov v2, eax + mov v3, eax + mov v4, eax + label2: + nop } - v8 += 2; - --v7; - } while (v7); +#else + WORD *Map; + + Map = (WORD *)&pSector[ii]; + if(*Map) { + v1 = *((WORD *)&P3Tiles[(*Map-1)*8])+1; + v2 = *((WORD *)&P3Tiles[(*Map-1)*8]+1)+1; + v3 = *((WORD *)&P3Tiles[(*Map-1)*8]+2)+1; + v4 = *((WORD *)&P3Tiles[(*Map-1)*8]+3)+1; + } else { + v1 = 0; + v2 = 0; + v3 = 0; + v4 = 0; + } +#endif + dPiece[xx][yy] = v1; + dPiece[xx + 1][yy] = v2; + dPiece[xx][yy + 1] = v3; + dPiece[xx + 1][yy + 1] = v4; + xx += 2; + ii += 2; + } + yy += 2; } } void __fastcall T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) { - unsigned char *v4; // esi - unsigned short v5; // ax - int v6; // eax - int v7; // ST10_4 - int v8; // ST0C_4 - int v9; // ST08_4 + long v1, v2, v3, v4; + +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) + __asm { + mov eax, t + dec eax + mov esi, P3Tiles + shl eax, 3 + add esi, eax + xor eax, eax + lodsw + inc eax + mov v1, eax + lodsw + inc eax + mov v2, eax + lodsw + inc eax + mov v3, eax + lodsw + inc eax + mov v4, eax + jmp label1 + mov v1, eax + mov v2, eax + mov v3, eax + mov v4, eax + label1: + nop + } +#else + v1 = *((WORD *)&P3Tiles[(t-1)*8])+1; + v2 = *((WORD *)&P3Tiles[(t-1)*8]+1)+1; + v3 = *((WORD *)&P3Tiles[(t-1)*8]+2)+1; + v4 = *((WORD *)&P3Tiles[(t-1)*8]+3)+1; +#endif - v4 = &P3Tiles[8 * (t - 1)]; - v5 = *(_WORD *)v4; - v4 += 2; - v6 = v5 + 1; - v7 = v6; - _LOWORD(v6) = *(_WORD *)v4; - v4 += 2; - v8 = ++v6; - _LOWORD(v6) = *(_WORD *)v4; - v9 = ++v6; - _LOWORD(v6) = *((_WORD *)v4 + 1); - dPiece[xx][yy] = v7; - dPiece[xx + 1][yy] = v8; - dPiece[xx][yy + 1] = v9; - dPiece[xx + 1][yy + 1] = v6 + 1; + dPiece[xx][yy] = v1; + dPiece[xx + 1][yy] = v2; + dPiece[xx][yy + 1] = v3; + dPiece[xx + 1][yy + 1] = v4; } void __cdecl T_Pass3() diff --git a/Source/town.h b/Source/town.h index 9580bc64f..de73f2b38 100644 --- a/Source/town.h +++ b/Source/town.h @@ -2,8 +2,8 @@ #ifndef __TOWN_H__ #define __TOWN_H__ -void __fastcall town_clear_upper_buf(unsigned char *a1); -void __fastcall town_clear_low_buf(unsigned char *y_related); +void __fastcall town_clear_upper_buf(BYTE *pBuff); +void __fastcall town_clear_low_buf(BYTE *pBuff); void __fastcall town_draw_clipped_e_flag(BYTE *buffer, int x, int y, int sx, int sy); void __fastcall town_draw_clipped_town(BYTE *buffer, int x, int y, int sx, int sy, int some_flag); void __fastcall town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag); diff --git a/SourceS/devilution.h b/SourceS/devilution.h new file mode 100644 index 000000000..fa95d570b --- /dev/null +++ b/SourceS/devilution.h @@ -0,0 +1 @@ +#include "../types.h" diff --git a/SourceS/miniwin.h b/SourceS/miniwin.h index d4c488ec7..05e5dc254 100644 --- a/SourceS/miniwin.h +++ b/SourceS/miniwin.h @@ -30,6 +30,7 @@ #include "miniwin/ui.h" #include "miniwin/thread.h" #include "miniwin/rand.h" +#include "storm_full.h" #ifdef DEVILUTION_ENGINE #include "miniwin/misc_macro.h" diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 25582df92..958fe17e6 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -45,10 +45,6 @@ typedef int INT; typedef unsigned int UINT; typedef unsigned int *PUINT; -// GCC qword alignment is 4, MSVC is 8, work around by introducing a more aligned type -typedef long long INT64; -typedef unsigned long long UINT64; - typedef intptr_t INT_PTR, *PINT_PTR; typedef uintptr_t UINT_PTR, *PUINT_PTR; @@ -203,7 +199,7 @@ struct DVL_finddata_t { time_t time_access; /* -1 for FAT file systems */ time_t time_write; _fsize_t size; - char name[260]; + char name[DVL_MAX_PATH]; }; typedef WORD ATOM; diff --git a/SourceS/storm_full.h b/SourceS/storm_full.h new file mode 100644 index 000000000..457376414 --- /dev/null +++ b/SourceS/storm_full.h @@ -0,0 +1,11 @@ +#pragma once + +namespace dvl { +extern "C" { + +extern DWORD nLastError; + +void TranslateFileName(char *dst, int dstLen, const char *src); + +} +} // namespace dvl diff --git a/SourceX/DiabloUI/credits.cpp b/SourceX/DiabloUI/credits.cpp index 889d54212..af74594ce 100644 --- a/SourceX/DiabloUI/credits.cpp +++ b/SourceX/DiabloUI/credits.cpp @@ -1,4 +1,6 @@ -#include "pch.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" +#include "dx.h" #define CREDIT_LINES 13 @@ -517,7 +519,8 @@ void credts_Render() x += 40; } - if (text_surface = TTF_RenderUTF8_Solid(font, the_long_credits[creditLine + i] + offset, color)) { + text_surface = TTF_RenderUTF8_Solid(font, the_long_credits[creditLine + i] + offset, color); + if (text_surface) { SDL_Rect src_rect = { 0, -y, SCREEN_WIDTH, 251 }; SDL_Rect dsc_rect = { 64 + x, 160 + 114, SCREEN_WIDTH, SCREEN_HEIGHT }; SDL_BlitSurface(text_surface, &src_rect, pal_surface, &dsc_rect); diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index 0ce4fa74a..e101eccd6 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -1,6 +1,10 @@ -#include "pch.h" #include + +#include "devilution.h" +#include "DiabloUI/diabloui.h" +#include "dx.h" #include "utf8.h" +#include "stubs.h" namespace dvl { @@ -483,7 +487,7 @@ BOOL UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6) UNIMPLEMENTED(); } -BOOL UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, void *pBuffer, +BOOL UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp) { UNIMPLEMENTED(); @@ -515,7 +519,7 @@ BOOL UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) void DrawArt(int screenX, int screenY, Art *art, int nFrame, int drawW) { BYTE *src = (BYTE *)art->data + (art->width * art->height * nFrame); - BYTE *dst = (BYTE *)&gpBuffer->row[screenY].pixels[screenX]; + BYTE *dst = &gpBuffer[screenX + 64 + (screenY + 160) * 768]; drawW = drawW ?: art->width; for (int i = 0; i < art->height && i + screenY < SCREEN_HEIGHT; i++, src += art->width, dst += ROW_PITCH) { @@ -539,7 +543,7 @@ int GetStrWidth(char *str, int size) { int strWidth = 0; - for (int i = 0; i < strlen((char *)str); i++) { + for (size_t i = 0; i < strlen((char *)str); i++) { BYTE w = FontTables[size][*(BYTE *)&str[i] + 2]; if (w) strWidth += w; @@ -629,7 +633,7 @@ void DrawArtStr(UI_Item *item) if (item->flags & UIS_VCENTER) sy += (item->rect.h - ArtFonts[size][color].height) / 2; - for (int i = 0; i < strlen((char *)item->caption); i++) { + for (size_t i = 0; i < strlen((char *)item->caption); i++) { if (item->caption[i] == '\n') { sx = x; sy += ArtFonts[size][color].height; diff --git a/SourceX/DiabloUI/diabloui.h b/SourceX/DiabloUI/diabloui.h index 5ddbddfd4..91451f2a3 100644 --- a/SourceX/DiabloUI/diabloui.h +++ b/SourceX/DiabloUI/diabloui.h @@ -68,7 +68,7 @@ typedef struct UI_Item { int flags; int value; char *caption; - void *context; + const void *context; } UI_Item; extern TTF_Font *font; diff --git a/SourceX/DiabloUI/dialogs.cpp b/SourceX/DiabloUI/dialogs.cpp index 00688c9a0..6c9ac120d 100644 --- a/SourceX/DiabloUI/dialogs.cpp +++ b/SourceX/DiabloUI/dialogs.cpp @@ -1,4 +1,5 @@ -#include "pch.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" namespace dvl { diff --git a/SourceX/DiabloUI/mainmenu.cpp b/SourceX/DiabloUI/mainmenu.cpp index 3e5e78f5d..dc9b8d2aa 100644 --- a/SourceX/DiabloUI/mainmenu.cpp +++ b/SourceX/DiabloUI/mainmenu.cpp @@ -1,4 +1,5 @@ -#include "pch.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" namespace dvl { diff --git a/SourceX/DiabloUI/progress.cpp b/SourceX/DiabloUI/progress.cpp index a9dc261df..90ed59dcb 100644 --- a/SourceX/DiabloUI/progress.cpp +++ b/SourceX/DiabloUI/progress.cpp @@ -1,4 +1,6 @@ -#include "pch.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" +#include "dx.h" namespace dvl { diff --git a/SourceX/DiabloUI/selconn.cpp b/SourceX/DiabloUI/selconn.cpp index d1fbae511..d4f93c2bc 100644 --- a/SourceX/DiabloUI/selconn.cpp +++ b/SourceX/DiabloUI/selconn.cpp @@ -1,6 +1,8 @@ -#include "pch.h" #include "selconn.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" + namespace dvl { char selconn_MaxPlayers[21]; diff --git a/SourceX/DiabloUI/selgame.cpp b/SourceX/DiabloUI/selgame.cpp index 9f46e8d02..bdaabf785 100644 --- a/SourceX/DiabloUI/selgame.cpp +++ b/SourceX/DiabloUI/selgame.cpp @@ -1,6 +1,8 @@ -#include "pch.h" #include "selgame.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" + namespace dvl { char selgame_Lable[32]; diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index 5219893e3..c09d53dbb 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -1,6 +1,8 @@ -#include "pch.h" #include "selhero.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" + namespace dvl { int selhero_SaveCount = 0; diff --git a/SourceX/DiabloUI/title.cpp b/SourceX/DiabloUI/title.cpp index 1308e66ee..27d5c7568 100644 --- a/SourceX/DiabloUI/title.cpp +++ b/SourceX/DiabloUI/title.cpp @@ -1,4 +1,5 @@ -#include "pch.h" +#include "devilution.h" +#include "DiabloUI/diabloui.h" namespace dvl { @@ -26,7 +27,7 @@ BOOL UiTitleDialog(int a1) title_Load(); bool endMenu = false; - int timeOut = SDL_GetTicks() + 7000; + Uint32 timeOut = SDL_GetTicks() + 7000; SDL_Event event; while (!endMenu && SDL_GetTicks() < timeOut) { diff --git a/SourceX/devilution.h b/SourceX/devilution.h deleted file mode 100644 index 41e446c13..000000000 --- a/SourceX/devilution.h +++ /dev/null @@ -1,3 +0,0 @@ -#include -#include "stubs.h" -#include "miniwin_sdl.h" diff --git a/SourceX/dvlnet/abstract_net.cpp b/SourceX/dvlnet/abstract_net.cpp index 6789b6b9b..afb601b20 100644 --- a/SourceX/dvlnet/abstract_net.cpp +++ b/SourceX/dvlnet/abstract_net.cpp @@ -5,7 +5,8 @@ #include "dvlnet/udp_p2p.h" #include "dvlnet/loopback.h" -namespace dvl { namespace net { +namespace dvl { +namespace net { abstract_net::~abstract_net() { @@ -24,4 +25,5 @@ std::unique_ptr abstract_net::make_net(provider_t provider) } } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/abstract_net.h b/SourceX/dvlnet/abstract_net.h index 36c7f96dc..a69725a5b 100644 --- a/SourceX/dvlnet/abstract_net.h +++ b/SourceX/dvlnet/abstract_net.h @@ -7,36 +7,39 @@ #include "devilution.h" -namespace dvl { namespace net { - typedef std::vector buffer_t; - typedef void(*snet_event_func)(struct _SNETEVENT*); - typedef unsigned long provider_t; - class dvlnet_exception : public std::exception {}; +namespace dvl { +namespace net { - class abstract_net { - public: - virtual int create(std::string addrstr, std::string passwd) = 0; - virtual int join(std::string addrstr, std::string passwd) = 0; - virtual bool SNetReceiveMessage(int* sender, char** data, - int* size) = 0; - virtual bool SNetSendMessage(int dest, void* data, - unsigned int size) = 0; - virtual bool SNetReceiveTurns(char** data, unsigned int* size, - DWORD* status) = 0; - virtual bool SNetSendTurn(char* data, unsigned int size) = 0; - virtual int SNetGetProviderCaps(struct _SNETCAPS* caps) = 0; - virtual void* SNetRegisterEventHandler(event_type evtype, - snet_event_func func) = 0; - virtual void* SNetUnregisterEventHandler(event_type evtype, - snet_event_func func) = 0; - virtual bool SNetLeaveGame(int type) = 0; - virtual bool SNetDropPlayer(int playerid, DWORD flags) = 0; - virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns) = 0; - virtual bool SNetGetTurnsInTransit(int *turns) = 0; - virtual void setup_gameinfo(buffer_t info) = 0; - virtual ~abstract_net(); +typedef std::vector buffer_t; +typedef void(*snet_event_func)(struct _SNETEVENT*); +typedef unsigned long provider_t; +class dvlnet_exception : public std::exception {}; - static std::unique_ptr make_net(provider_t provider); +class abstract_net { +public: + virtual int create(std::string addrstr, std::string passwd) = 0; + virtual int join(std::string addrstr, std::string passwd) = 0; + virtual bool SNetReceiveMessage(int* sender, char** data, + int* size) = 0; + virtual bool SNetSendMessage(int dest, void* data, + unsigned int size) = 0; + virtual bool SNetReceiveTurns(char** data, unsigned int* size, + DWORD* status) = 0; + virtual bool SNetSendTurn(char* data, unsigned int size) = 0; + virtual int SNetGetProviderCaps(struct _SNETCAPS* caps) = 0; + virtual void* SNetRegisterEventHandler(event_type evtype, + snet_event_func func) = 0; + virtual void* SNetUnregisterEventHandler(event_type evtype, + snet_event_func func) = 0; + virtual bool SNetLeaveGame(int type) = 0; + virtual bool SNetDropPlayer(int playerid, DWORD flags) = 0; + virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns) = 0; + virtual bool SNetGetTurnsInTransit(int *turns) = 0; + virtual void setup_gameinfo(buffer_t info) = 0; + virtual ~abstract_net(); + + static std::unique_ptr make_net(provider_t provider); }; -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/base.cpp b/SourceX/dvlnet/base.cpp index f78507588..0860a4628 100644 --- a/SourceX/dvlnet/base.cpp +++ b/SourceX/dvlnet/base.cpp @@ -1,8 +1,10 @@ #include "dvlnet/base.h" #include +#include -namespace dvl { namespace net { +namespace dvl { +namespace net { void base::setup_gameinfo(buffer_t info) { @@ -170,7 +172,8 @@ bool base::SNetSendTurn(char* data, unsigned int size) { if (size != sizeof(turn_t)) ABORT(); - turn_t turn = *reinterpret_cast(data); + turn_t turn; + std::memcpy(&turn, data, sizeof(turn)); auto pkt = pktfty->make_packet(plr_self, PLR_BROADCAST, turn); send(*pkt); turn_queue[plr_self].push_back(pkt->turn()); @@ -253,4 +256,5 @@ bool base::SNetGetTurnsInTransit(int *turns) return true; } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/base.h b/SourceX/dvlnet/base.h index bc4decb34..56be6c3db 100644 --- a/SourceX/dvlnet/base.h +++ b/SourceX/dvlnet/base.h @@ -18,60 +18,64 @@ #define LEAVE_ENDING 0x40000004 #define LEAVE_DROP 0x40000006 -namespace dvl { namespace net { - class base : public abstract_net { - public: - virtual int create(std::string addrstr, std::string passwd) = 0; - virtual int join(std::string addrstr, std::string passwd) = 0; - - virtual bool SNetReceiveMessage(int* sender, char** data, int* size); - virtual bool SNetSendMessage(int dest, void* data, unsigned int size); - virtual bool SNetReceiveTurns(char** data, unsigned int* size, - DWORD* status); - virtual bool SNetSendTurn(char* data, unsigned int size); - virtual int SNetGetProviderCaps(struct _SNETCAPS* caps); - virtual void* SNetRegisterEventHandler(event_type evtype, - snet_event_func func); - virtual void* SNetUnregisterEventHandler(event_type evtype, - snet_event_func func); - virtual bool SNetLeaveGame(int type); - virtual bool SNetDropPlayer(int playerid, DWORD flags); - virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns); - virtual bool SNetGetTurnsInTransit(int *turns); - - virtual void poll() = 0; - virtual void send(packet& pkt) = 0; - - void setup_gameinfo(buffer_t info); - protected: - std::map registered_handlers; - buffer_t game_init_info; - - struct message_t { - int sender; // change int to something else in devilution code later - buffer_t payload; - message_t() : sender(-1), payload({}) {} - message_t(int s, buffer_t p) : sender(s), payload(p) {} - }; - - message_t message_last; - std::deque message_queue; - std::array turn_last = {}; - std::array, MAX_PLRS> turn_queue; - std::array connected_table = {}; - - plr_t plr_self = PLR_BROADCAST; - cookie_t cookie_self = 0; - - std::unique_ptr pktfty; - - void setup_password(std::string pw); - void handle_accept(packet& pkt); - void recv_local(packet& pkt); - void run_event_handler(_SNETEVENT& ev); - - private: - plr_t get_owner(); - void clear_msg(plr_t plr); +namespace dvl { +namespace net { + +class base : public abstract_net { +public: + virtual int create(std::string addrstr, std::string passwd) = 0; + virtual int join(std::string addrstr, std::string passwd) = 0; + + virtual bool SNetReceiveMessage(int* sender, char** data, int* size); + virtual bool SNetSendMessage(int dest, void* data, unsigned int size); + virtual bool SNetReceiveTurns(char** data, unsigned int* size, + DWORD* status); + virtual bool SNetSendTurn(char* data, unsigned int size); + virtual int SNetGetProviderCaps(struct _SNETCAPS* caps); + virtual void* SNetRegisterEventHandler(event_type evtype, + snet_event_func func); + virtual void* SNetUnregisterEventHandler(event_type evtype, + snet_event_func func); + virtual bool SNetLeaveGame(int type); + virtual bool SNetDropPlayer(int playerid, DWORD flags); + virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns); + virtual bool SNetGetTurnsInTransit(int *turns); + + virtual void poll() = 0; + virtual void send(packet& pkt) = 0; + + void setup_gameinfo(buffer_t info); +protected: + std::map registered_handlers; + buffer_t game_init_info; + + struct message_t { + int sender; // change int to something else in devilution code later + buffer_t payload; + message_t() : sender(-1), payload({}) {} + message_t(int s, buffer_t p) : sender(s), payload(p) {} }; -}} + + message_t message_last; + std::deque message_queue; + std::array turn_last = {}; + std::array, MAX_PLRS> turn_queue; + std::array connected_table = {}; + + plr_t plr_self = PLR_BROADCAST; + cookie_t cookie_self = 0; + + std::unique_ptr pktfty; + + void setup_password(std::string pw); + void handle_accept(packet& pkt); + void recv_local(packet& pkt); + void run_event_handler(_SNETEVENT& ev); + +private: + plr_t get_owner(); + void clear_msg(plr_t plr); +}; + +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/frame_queue.cpp b/SourceX/dvlnet/frame_queue.cpp index 5374995cf..a6211e4fd 100644 --- a/SourceX/dvlnet/frame_queue.cpp +++ b/SourceX/dvlnet/frame_queue.cpp @@ -1,8 +1,11 @@ #include "dvlnet/frame_queue.h" +#include + #include "dvlnet/packet.h" -namespace dvl { namespace net { +namespace dvl { +namespace net { size_t frame_queue::size() { @@ -45,7 +48,7 @@ bool frame_queue::packet_ready() if(size() < sizeof(framesize_t)) return false; auto szbuf = read(sizeof(framesize_t)); - nextsize = *(reinterpret_cast(&szbuf[0])); + std::memcpy(&nextsize, &szbuf[0], sizeof(nextsize)); if(!nextsize) throw frame_queue_exception(); } @@ -75,4 +78,5 @@ buffer_t frame_queue::make_frame(buffer_t packetbuf) return std::move(ret); } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/frame_queue.h b/SourceX/dvlnet/frame_queue.h index 9aed69b94..666f2d21a 100644 --- a/SourceX/dvlnet/frame_queue.h +++ b/SourceX/dvlnet/frame_queue.h @@ -4,25 +4,29 @@ #include "dvlnet/abstract_net.h" -namespace dvl { namespace net { - class frame_queue_exception : public dvlnet_exception {}; - - class frame_queue { - public: - typedef uint32_t framesize_t; - constexpr static framesize_t max_frame_size = 0xFFFF; - private: - size_t current_size = 0; - std::deque buffer_deque; - size_t nextsize = 0; - - size_t size(); - buffer_t read(size_t s); - public: - bool packet_ready(); - buffer_t read_packet(); - void write(buffer_t buf); - - static buffer_t make_frame(buffer_t packetbuf); - }; -}} +namespace dvl { +namespace net { + +class frame_queue_exception : public dvlnet_exception {}; + +class frame_queue { +public: + typedef uint32_t framesize_t; + constexpr static framesize_t max_frame_size = 0xFFFF; +private: + size_t current_size = 0; + std::deque buffer_deque; + size_t nextsize = 0; + + size_t size(); + buffer_t read(size_t s); +public: + bool packet_ready(); + buffer_t read_packet(); + void write(buffer_t buf); + + static buffer_t make_frame(buffer_t packetbuf); +}; + +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/loopback.cpp b/SourceX/dvlnet/loopback.cpp index 7de7c88e5..0cf0c380a 100644 --- a/SourceX/dvlnet/loopback.cpp +++ b/SourceX/dvlnet/loopback.cpp @@ -1,6 +1,8 @@ #include "dvlnet/loopback.h" +#include "stubs.h" -namespace dvl { namespace net { +namespace dvl { +namespace net { int loopback::create(std::string addrstr, std::string passwd) { @@ -103,4 +105,5 @@ bool loopback::SNetGetTurnsInTransit(int *turns) return true; } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/loopback.h b/SourceX/dvlnet/loopback.h index 4e45376e8..f3a5034c1 100644 --- a/SourceX/dvlnet/loopback.h +++ b/SourceX/dvlnet/loopback.h @@ -6,30 +6,34 @@ #include "devilution.h" #include "dvlnet/abstract_net.h" -namespace dvl { namespace net { - class loopback : public abstract_net { - private: - std::queue message_queue; - buffer_t message_last; - const int plr_single = 0; +namespace dvl { +namespace net { - public: - virtual int create(std::string addrstr, std::string passwd); - virtual int join(std::string addrstr, std::string passwd); - virtual bool SNetReceiveMessage(int* sender, char** data, int* size); - virtual bool SNetSendMessage(int dest, void* data, unsigned int size); - virtual bool SNetReceiveTurns(char** data, unsigned int* size, - DWORD* status); - virtual bool SNetSendTurn(char* data, unsigned int size); - virtual int SNetGetProviderCaps(struct _SNETCAPS* caps); - virtual void *SNetRegisterEventHandler(event_type evtype, - snet_event_func func); - virtual void *SNetUnregisterEventHandler(event_type evtype, - snet_event_func func); - virtual bool SNetLeaveGame(int type); - virtual bool SNetDropPlayer(int playerid, DWORD flags); - virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns); - virtual bool SNetGetTurnsInTransit(int *turns); - virtual void setup_gameinfo(buffer_t info); - }; -}} +class loopback : public abstract_net { +private: + std::queue message_queue; + buffer_t message_last; + const int plr_single = 0; + +public: + virtual int create(std::string addrstr, std::string passwd); + virtual int join(std::string addrstr, std::string passwd); + virtual bool SNetReceiveMessage(int* sender, char** data, int* size); + virtual bool SNetSendMessage(int dest, void* data, unsigned int size); + virtual bool SNetReceiveTurns(char** data, unsigned int* size, + DWORD* status); + virtual bool SNetSendTurn(char* data, unsigned int size); + virtual int SNetGetProviderCaps(struct _SNETCAPS* caps); + virtual void *SNetRegisterEventHandler(event_type evtype, + snet_event_func func); + virtual void *SNetUnregisterEventHandler(event_type evtype, + snet_event_func func); + virtual bool SNetLeaveGame(int type); + virtual bool SNetDropPlayer(int playerid, DWORD flags); + virtual bool SNetGetOwnerTurnsWaiting(DWORD *turns); + virtual bool SNetGetTurnsInTransit(int *turns); + virtual void setup_gameinfo(buffer_t info); +}; + +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/packet.cpp b/SourceX/dvlnet/packet.cpp index e6dfd5b26..fca7f2f80 100644 --- a/SourceX/dvlnet/packet.cpp +++ b/SourceX/dvlnet/packet.cpp @@ -1,6 +1,7 @@ #include "dvlnet/packet.h" -namespace dvl { namespace net { +namespace dvl { +namespace net { static constexpr bool disable_encryption = false; @@ -174,4 +175,5 @@ packet_factory::packet_factory(std::string pw) ABORT(); } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/packet.h b/SourceX/dvlnet/packet.h index 6a1ecd67f..dcca79ca0 100644 --- a/SourceX/dvlnet/packet.h +++ b/SourceX/dvlnet/packet.h @@ -3,266 +3,272 @@ #include #include #include +#include #include #include "dvlnet/abstract_net.h" +#include "stubs.h" -namespace dvl { namespace net { - enum packet_type : uint8_t { +namespace dvl { +namespace net { + +enum packet_type : uint8_t { PT_MESSAGE = 0x01, PT_TURN = 0x02, PT_JOIN_REQUEST = 0x11, PT_JOIN_ACCEPT = 0x12, PT_CONNECT = 0x13, PT_DISCONNECT = 0x14, - }; - - typedef uint8_t plr_t; - typedef uint32_t cookie_t; - typedef int turn_t; // change int to something else in devilution code later - typedef int leaveinfo_t; // also change later - typedef std::array key_t; - - static constexpr plr_t PLR_MASTER = 0xFE; - static constexpr plr_t PLR_BROADCAST = 0xFF; - - class packet_exception : public dvlnet_exception {}; - - class packet { - protected: - packet_type m_type; - plr_t m_src; - plr_t m_dest; - buffer_t m_message; - turn_t m_turn; - cookie_t m_cookie; - plr_t m_newplr; - buffer_t m_info; - leaveinfo_t m_leaveinfo; - - const key_t& key; - bool have_encrypted = false; - bool have_decrypted = false; - buffer_t encrypted_buffer; - buffer_t decrypted_buffer; - - public: - packet(const key_t& k) : key(k) {}; - - const buffer_t& data(); - - packet_type type(); - plr_t src(); - plr_t dest(); - const buffer_t& message(); - turn_t turn(); - cookie_t cookie(); - plr_t newplr(); - const buffer_t& info(); - leaveinfo_t leaveinfo(); - }; - - template class packet_proc : public packet { - public: - using packet::packet; - void process_data(); - }; - - class packet_in : public packet_proc { - public: - using packet_proc::packet_proc; - void create(buffer_t buf); - void process_element(buffer_t& x); - template void process_element(T& x); - void decrypt(); - }; - - class packet_out : public packet_proc { - public: - using packet_proc::packet_proc; - - template - void create(Args... args); - - void process_element(buffer_t& x); - template void process_element(T& x); - template static const unsigned char* begin(const T& x); - template static const unsigned char* end(const T& x); - void encrypt(); - }; - - template void packet_proc

::process_data() - { - P& self = static_cast(*this); - self.process_element(m_type); - self.process_element(m_src); - self.process_element(m_dest); - switch (m_type) { - case PT_MESSAGE: - self.process_element(m_message); - break; - case PT_TURN: - self.process_element(m_turn); - break; - case PT_JOIN_REQUEST: - self.process_element(m_cookie); - self.process_element(m_info); - break; - case PT_JOIN_ACCEPT: - self.process_element(m_cookie); - self.process_element(m_newplr); - self.process_element(m_info); - break; - case PT_CONNECT: - self.process_element(m_newplr); - break; - case PT_DISCONNECT: - self.process_element(m_newplr); - self.process_element(m_leaveinfo); - break; - } - } - - inline void packet_in::process_element(buffer_t& x) - { - x.insert(x.begin(), decrypted_buffer.begin(), decrypted_buffer.end()); - decrypted_buffer.resize(0); - } - - template void packet_in::process_element(T& x) - { - if (decrypted_buffer.size() < sizeof(T)) - throw packet_exception(); - x = *reinterpret_cast(decrypted_buffer.data()); - decrypted_buffer.erase(decrypted_buffer.begin(), - decrypted_buffer.begin() + sizeof(T)); - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, buffer_t m) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_MESSAGE; - m_src = s; - m_dest = d; - m_message = std::move(m); - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, turn_t u) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_TURN; - m_src = s; - m_dest = d; - m_turn = u; - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, - cookie_t c, buffer_t i) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_JOIN_REQUEST; - m_src = s; - m_dest = d; - m_cookie = c; - m_info = i; - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, cookie_t c, - plr_t n, buffer_t i) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_JOIN_ACCEPT; - m_src = s; - m_dest = d; - m_cookie = c; - m_newplr = n; - m_info = i; - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, plr_t n) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_CONNECT; - m_src = s; - m_dest = d; - m_newplr = n; - } - - template<> - inline void packet_out::create(plr_t s, plr_t d, plr_t n, - leaveinfo_t l) - { - if (have_encrypted || have_decrypted) - ABORT(); - have_decrypted = true; - m_type = PT_DISCONNECT; - m_src = s; - m_dest = d; - m_newplr = n; - m_leaveinfo = l; - } - - inline void packet_out::process_element(buffer_t& x) - { - encrypted_buffer.insert(encrypted_buffer.end(), x.begin(), x.end()); - } - - template void packet_out::process_element(T& x) - { - encrypted_buffer.insert(encrypted_buffer.end(), begin(x), end(x)); - } - - template const unsigned char* packet_out::begin(const T& x) - { - return reinterpret_cast(&x); - } - - template const unsigned char* packet_out::end(const T& x) - { - return reinterpret_cast(&x) + sizeof(T); - } - - class packet_factory { - key_t key = {}; - - public: - static constexpr unsigned short max_packet_size = 0xFFFF; - - packet_factory(std::string pw = ""); - std::unique_ptr make_packet(buffer_t buf); - template - std::unique_ptr make_packet(Args... args); - }; - - inline std::unique_ptr packet_factory::make_packet(buffer_t buf) - { - auto ret = std::make_unique(key); - ret->create(std::move(buf)); - ret->decrypt(); - return ret; - } +}; + +typedef uint8_t plr_t; +typedef uint32_t cookie_t; +typedef int turn_t; // change int to something else in devilution code later +typedef int leaveinfo_t; // also change later +typedef std::array key_t; + +static constexpr plr_t PLR_MASTER = 0xFE; +static constexpr plr_t PLR_BROADCAST = 0xFF; + +class packet_exception : public dvlnet_exception {}; + +class packet { +protected: + packet_type m_type; + plr_t m_src; + plr_t m_dest; + buffer_t m_message; + turn_t m_turn; + cookie_t m_cookie; + plr_t m_newplr; + buffer_t m_info; + leaveinfo_t m_leaveinfo; + + const key_t& key; + bool have_encrypted = false; + bool have_decrypted = false; + buffer_t encrypted_buffer; + buffer_t decrypted_buffer; + +public: + packet(const key_t& k) : key(k) {}; + + const buffer_t& data(); + + packet_type type(); + plr_t src(); + plr_t dest(); + const buffer_t& message(); + turn_t turn(); + cookie_t cookie(); + plr_t newplr(); + const buffer_t& info(); + leaveinfo_t leaveinfo(); +}; + +template class packet_proc : public packet { +public: + using packet::packet; + void process_data(); +}; + +class packet_in : public packet_proc { +public: + using packet_proc::packet_proc; + void create(buffer_t buf); + void process_element(buffer_t& x); + template void process_element(T& x); + void decrypt(); +}; + +class packet_out : public packet_proc { +public: + using packet_proc::packet_proc; template - std::unique_ptr packet_factory::make_packet(Args... args) - { - auto ret = std::make_unique(key); - ret->create(args...); - ret->encrypt(); - return ret; + void create(Args... args); + + void process_element(buffer_t& x); + template void process_element(T& x); + template static const unsigned char* begin(const T& x); + template static const unsigned char* end(const T& x); + void encrypt(); +}; + +template void packet_proc

::process_data() +{ + P& self = static_cast(*this); + self.process_element(m_type); + self.process_element(m_src); + self.process_element(m_dest); + switch (m_type) { + case PT_MESSAGE: + self.process_element(m_message); + break; + case PT_TURN: + self.process_element(m_turn); + break; + case PT_JOIN_REQUEST: + self.process_element(m_cookie); + self.process_element(m_info); + break; + case PT_JOIN_ACCEPT: + self.process_element(m_cookie); + self.process_element(m_newplr); + self.process_element(m_info); + break; + case PT_CONNECT: + self.process_element(m_newplr); + break; + case PT_DISCONNECT: + self.process_element(m_newplr); + self.process_element(m_leaveinfo); + break; } -}} +} + +inline void packet_in::process_element(buffer_t& x) +{ + x.insert(x.begin(), decrypted_buffer.begin(), decrypted_buffer.end()); + decrypted_buffer.resize(0); +} + +template void packet_in::process_element(T& x) +{ + if (decrypted_buffer.size() < sizeof(T)) + throw packet_exception(); + std::memcpy(&x, decrypted_buffer.data(), sizeof(T)); + decrypted_buffer.erase(decrypted_buffer.begin(), + decrypted_buffer.begin() + sizeof(T)); +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, buffer_t m) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_MESSAGE; + m_src = s; + m_dest = d; + m_message = std::move(m); +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, turn_t u) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_TURN; + m_src = s; + m_dest = d; + m_turn = u; +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, + cookie_t c, buffer_t i) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_JOIN_REQUEST; + m_src = s; + m_dest = d; + m_cookie = c; + m_info = i; +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, cookie_t c, + plr_t n, buffer_t i) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_JOIN_ACCEPT; + m_src = s; + m_dest = d; + m_cookie = c; + m_newplr = n; + m_info = i; +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, plr_t n) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_CONNECT; + m_src = s; + m_dest = d; + m_newplr = n; +} + +template<> +inline void packet_out::create(plr_t s, plr_t d, plr_t n, + leaveinfo_t l) +{ + if (have_encrypted || have_decrypted) + ABORT(); + have_decrypted = true; + m_type = PT_DISCONNECT; + m_src = s; + m_dest = d; + m_newplr = n; + m_leaveinfo = l; +} + +inline void packet_out::process_element(buffer_t& x) +{ + encrypted_buffer.insert(encrypted_buffer.end(), x.begin(), x.end()); +} + +template void packet_out::process_element(T& x) +{ + encrypted_buffer.insert(encrypted_buffer.end(), begin(x), end(x)); +} + +template const unsigned char* packet_out::begin(const T& x) +{ + return reinterpret_cast(&x); +} + +template const unsigned char* packet_out::end(const T& x) +{ + return reinterpret_cast(&x) + sizeof(T); +} + +class packet_factory { + key_t key = {}; + +public: + static constexpr unsigned short max_packet_size = 0xFFFF; + + packet_factory(std::string pw = ""); + std::unique_ptr make_packet(buffer_t buf); + template + std::unique_ptr make_packet(Args... args); +}; + +inline std::unique_ptr packet_factory::make_packet(buffer_t buf) +{ + auto ret = std::make_unique(key); + ret->create(std::move(buf)); + ret->decrypt(); + return ret; +} + +template +std::unique_ptr packet_factory::make_packet(Args... args) +{ + auto ret = std::make_unique(key); + ret->create(args...); + ret->encrypt(); + return ret; +} + +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/tcp_client.cpp b/SourceX/dvlnet/tcp_client.cpp index ed683d12d..51e2e4ab0 100644 --- a/SourceX/dvlnet/tcp_client.cpp +++ b/SourceX/dvlnet/tcp_client.cpp @@ -7,7 +7,8 @@ #include #include -namespace dvl { namespace net { +namespace dvl { +namespace net { int tcp_client::create(std::string addrstr, std::string passwd) { @@ -102,4 +103,5 @@ void tcp_client::send(packet& pkt) std::placeholders::_1, std::placeholders::_2)); } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/tcp_client.h b/SourceX/dvlnet/tcp_client.h index bdb8cbf40..fd3db20e4 100644 --- a/SourceX/dvlnet/tcp_client.h +++ b/SourceX/dvlnet/tcp_client.h @@ -12,26 +12,30 @@ #include "dvlnet/base.h" #include "dvlnet/tcp_server.h" -namespace dvl { namespace net { - class tcp_client : public base { - public: - int create(std::string addrstr, std::string passwd); - int join(std::string addrstr, std::string passwd); - - constexpr static unsigned short default_port = 6112; - - virtual void poll(); - virtual void send(packet& pkt); - private: - frame_queue recv_queue; - buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size); - - asio::io_context ioc; - asio::ip::tcp::socket sock = asio::ip::tcp::socket(ioc); - std::unique_ptr local_server; // must be declared *after* ioc - - void handle_recv(const asio::error_code& error, size_t bytes_read); - void start_recv(); - void handle_send(const asio::error_code& error, size_t bytes_sent); - }; -}} +namespace dvl { +namespace net { + +class tcp_client : public base { +public: + int create(std::string addrstr, std::string passwd); + int join(std::string addrstr, std::string passwd); + + constexpr static unsigned short default_port = 6112; + + virtual void poll(); + virtual void send(packet& pkt); +private: + frame_queue recv_queue; + buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size); + + asio::io_context ioc; + asio::ip::tcp::socket sock = asio::ip::tcp::socket(ioc); + std::unique_ptr local_server; // must be declared *after* ioc + + void handle_recv(const asio::error_code& error, size_t bytes_read); + void start_recv(); + void handle_send(const asio::error_code& error, size_t bytes_sent); +}; + +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/tcp_server.cpp b/SourceX/dvlnet/tcp_server.cpp index 8ecbde56c..2fe1a4f2c 100644 --- a/SourceX/dvlnet/tcp_server.cpp +++ b/SourceX/dvlnet/tcp_server.cpp @@ -5,7 +5,8 @@ #include "dvlnet/base.h" -namespace dvl { namespace net { +namespace dvl { +namespace net { tcp_server::tcp_server(asio::io_context& ioc, std::string bindaddr, unsigned short port, std::string pw) : @@ -208,4 +209,5 @@ void tcp_server::drop_connection(scc con) con->socket.close(); } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/tcp_server.h b/SourceX/dvlnet/tcp_server.h index bd4918f6d..1c5271b13 100644 --- a/SourceX/dvlnet/tcp_server.h +++ b/SourceX/dvlnet/tcp_server.h @@ -12,53 +12,57 @@ #include "dvlnet/abstract_net.h" #include "dvlnet/frame_queue.h" -namespace dvl { namespace net { - class server_exception : public dvlnet_exception {}; +namespace dvl { +namespace net { - class tcp_server { - public: - tcp_server(asio::io_context& ioc, std::string bindaddr, - unsigned short port, std::string pw); - std::string localhost_self(); +class server_exception : public dvlnet_exception {}; - private: - static constexpr int timeout_connect = 30; - static constexpr int timeout_active = 60; +class tcp_server { +public: + tcp_server(asio::io_context& ioc, std::string bindaddr, + unsigned short port, std::string pw); + std::string localhost_self(); - struct client_connection { - frame_queue recv_queue; - buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size); - plr_t plr = PLR_BROADCAST; - asio::ip::tcp::socket socket; - asio::steady_timer timer; - int timeout; - client_connection(asio::io_context& ioc) : - socket(ioc), timer(ioc) {} - }; +private: + static constexpr int timeout_connect = 30; + static constexpr int timeout_active = 60; - typedef std::shared_ptr scc; + struct client_connection { + frame_queue recv_queue; + buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size); + plr_t plr = PLR_BROADCAST; + asio::ip::tcp::socket socket; + asio::steady_timer timer; + int timeout; + client_connection(asio::io_context& ioc) : + socket(ioc), timer(ioc) {} + }; - asio::io_context& ioc; - packet_factory pktfty; - std::unique_ptr acceptor; - std::array connections; - buffer_t game_init_info; + typedef std::shared_ptr scc; - scc make_connection(); - plr_t next_free(); - bool empty(); - void start_accept(); - void handle_accept(scc con, const asio::error_code& ec); - void start_recv(scc con); - void handle_recv(scc con, const asio::error_code& ec, size_t bytes_read); - void handle_recv_newplr(scc con, packet& pkt); - void handle_recv_packet(packet& pkt); - void send_connect(scc con); - void send_packet(packet& pkt); - void start_send(scc con, packet& pkt); - void handle_send(scc con, const asio::error_code& ec, size_t bytes_sent); - void start_timeout(scc con); - void handle_timeout(scc con, const asio::error_code& ec); - void drop_connection(scc con); - }; -}} + asio::io_context& ioc; + packet_factory pktfty; + std::unique_ptr acceptor; + std::array connections; + buffer_t game_init_info; + + scc make_connection(); + plr_t next_free(); + bool empty(); + void start_accept(); + void handle_accept(scc con, const asio::error_code& ec); + void start_recv(scc con); + void handle_recv(scc con, const asio::error_code& ec, size_t bytes_read); + void handle_recv_newplr(scc con, packet& pkt); + void handle_recv_packet(packet& pkt); + void send_connect(scc con); + void send_packet(packet& pkt); + void start_send(scc con, packet& pkt); + void handle_send(scc con, const asio::error_code& ec, size_t bytes_sent); + void start_timeout(scc con); + void handle_timeout(scc con, const asio::error_code& ec); + void drop_connection(scc con); +}; + +} //namespace net +} //namespace dvl diff --git a/SourceX/dvlnet/udp_p2p.cpp b/SourceX/dvlnet/udp_p2p.cpp index 74271042a..1a143cdeb 100644 --- a/SourceX/dvlnet/udp_p2p.cpp +++ b/SourceX/dvlnet/udp_p2p.cpp @@ -1,6 +1,9 @@ #include "dvlnet/udp_p2p.h" -namespace dvl { namespace net { +#include + +namespace dvl { +namespace net { const udp_p2p::endpoint udp_p2p::none; @@ -49,7 +52,7 @@ int udp_p2p::join(std::string addrstr, std::string passwd) sock.connect(themaster); master = themaster; { // hack: try to join for 5 seconds - randombytes_buf(reinterpret_cast(&cookie_self), + randombytes_buf(reinterpret_cast(&cookie_self), sizeof(cookie_t)); auto pkt = pktfty->make_packet(PLR_BROADCAST, PLR_MASTER, cookie_self, @@ -167,4 +170,5 @@ void udp_p2p::recv_decrypted(packet& pkt, endpoint sender) recv_local(pkt); } -}} +} // namespace net +} // namespace dvl diff --git a/SourceX/dvlnet/udp_p2p.h b/SourceX/dvlnet/udp_p2p.h index 585ff485a..9f3a976b3 100644 --- a/SourceX/dvlnet/udp_p2p.h +++ b/SourceX/dvlnet/udp_p2p.h @@ -10,36 +10,40 @@ #include "dvlnet/packet.h" #include "dvlnet/base.h" -namespace dvl { namespace net { - class udp_p2p : public base { - public: - virtual int create(std::string addrstr, std::string passwd); - virtual int join(std::string addrstr, std::string passwd); - virtual void poll(); - virtual void send(packet& pkt); - - private: - typedef asio::ip::udp::endpoint endpoint; - static const endpoint none; - - unsigned short udpport_self = 0; - - static constexpr unsigned short default_port = 6112; - static constexpr unsigned short try_ports = 512; - static constexpr int ACTIVE = 60; - - asio::io_context io_context; - endpoint master; - - std::set connection_requests_pending; - std::array nexthop_table; - - asio::ip::udp::socket sock = asio::ip::udp::socket(io_context); - - void recv(); - void handle_join_request(packet& pkt, endpoint sender); - void send_internal(packet& pkt, endpoint sender = none); - std::set dests_for_addr(plr_t dest, endpoint sender); - void recv_decrypted(packet& pkt, endpoint sender); - }; -}} +namespace dvl { +namespace net { + +class udp_p2p : public base { +public: + virtual int create(std::string addrstr, std::string passwd); + virtual int join(std::string addrstr, std::string passwd); + virtual void poll(); + virtual void send(packet& pkt); + +private: + typedef asio::ip::udp::endpoint endpoint; + static const endpoint none; + + unsigned short udpport_self = 0; + + static constexpr unsigned short default_port = 6112; + static constexpr unsigned short try_ports = 512; + static constexpr int ACTIVE = 60; + + asio::io_context io_context; + endpoint master; + + std::set connection_requests_pending; + std::array nexthop_table; + + asio::ip::udp::socket sock = asio::ip::udp::socket(io_context); + + void recv(); + void handle_join_request(packet& pkt, endpoint sender); + void send_internal(packet& pkt, endpoint sender = none); + std::set dests_for_addr(plr_t dest, endpoint sender); + void recv_decrypted(packet& pkt, endpoint sender); +}; + +} // namespace net +} // namespace dvl diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 046aa1127..274566096 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -1,8 +1,12 @@ -#include "pch.h" +#include "dx.h" + +#include "devilution.h" +#include "stubs.h" +#include "DiabloUI/diabloui.h" namespace dvl { -Screen *gpBuffer; +BYTE *gpBuffer; IDirectDraw *lpDDInterface; IDirectDrawSurface *lpDDSPrimary; @@ -366,7 +370,7 @@ void dx_init(HWND hWnd) } const int pitch = 64 + SCREEN_WIDTH + 64; - gpBuffer = (Screen *)malloc(sizeof(Screen)); + gpBuffer = (BYTE *)malloc(656 * 768); gpBufEnd += (uintptr_t)gpBuffer; pal_surface = SDL_CreateRGBSurfaceFrom(gpBuffer, pitch, 160 + SCREEN_HEIGHT + 16, 8, pitch, 0, 0, 0, 0); @@ -380,7 +384,7 @@ void dx_init(HWND hWnd) return; } - MainWndProc(NULL, DVL_WM_ACTIVATEAPP, true, NULL); + MainWndProc(NULL, DVL_WM_ACTIVATEAPP, true, 0); lpDDInterface = &stub_draw; lpDDSPrimary = &stub_surface; @@ -444,77 +448,4 @@ void dx_reinit() UNIMPLEMENTED(); } -// -// Storm functions -// - -BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) -{ - assert(firstentry == 0); - assert(numentries == 256); - - SDL_Color colors[256]; - for (unsigned int i = firstentry; i < numentries; i++) { - SDL_Color *c = &colors[i]; - PALETTEENTRY *p = &pPalEntries[i]; - c->r = p->peRed; - c->g = p->peGreen; - c->b = p->peBlue; - c->a = SDL_ALPHA_OPAQUE; - } - - assert(palette); - if (SDL_SetPaletteColors(palette, colors, firstentry, numentries) != 0) { - SDL_Log("SDL_SetPaletteColors: %s\n", SDL_GetError()); - return false; - } - - if (pal_surface) { - sdl_update_entire_surface(); - sdl_present_surface(); - } - - return true; -} - -// -// Windows API functions -// - -WINBOOL SetCursorPos(int X, int Y) -{ - assert(renderer); - assert(window); - - SDL_Rect view; - SDL_RenderGetViewport(renderer, &view); - X += view.x; - Y += view.y; - - float scaleX; - SDL_RenderGetScale(renderer, &scaleX, NULL); - X *= scaleX; - Y *= scaleX; - - SDL_WarpMouseInWindow(window, X, Y); - return true; -} - -int ShowCursor(WINBOOL bShow) -{ - SDL_ShowCursor(bShow ? SDL_ENABLE : SDL_DISABLE); - - return bShow; -} - -WINBOOL TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c) -{ - DUMMY_ONCE(); - - assert(window); - SDL_SetWindowTitle(window, lpString); - - return true; -} - -} +} // namespace dvl diff --git a/SourceX/miniwin_sdl.h b/SourceX/dx.h similarity index 93% rename from SourceX/miniwin_sdl.h rename to SourceX/dx.h index 2aee33057..da5db9570 100644 --- a/SourceX/miniwin_sdl.h +++ b/SourceX/dx.h @@ -15,4 +15,4 @@ void sdl_present_surface(); void sdl_update_entire_surface(); -} +} // namespace dvl diff --git a/SourceX/main.cpp b/SourceX/main.cpp index 7d9b3ed1c..ec1d15db8 100644 --- a/SourceX/main.cpp +++ b/SourceX/main.cpp @@ -1,4 +1,7 @@ -#include "pch.h" +#include +#include + +#include "devilution.h" extern "C" const char *__asan_default_options() { diff --git a/SourceX/miniwin_dsound.cpp b/SourceX/miniwin/dsound.cpp similarity index 96% rename from SourceX/miniwin_dsound.cpp rename to SourceX/miniwin/dsound.cpp index de18b0a24..7d6b043f4 100644 --- a/SourceX/miniwin_dsound.cpp +++ b/SourceX/miniwin/dsound.cpp @@ -1,4 +1,9 @@ -#include "pch.h" +#include "miniwin/dsound.h" + +#include + +#include "devilution.h" +#include "stubs.h" namespace dvl { diff --git a/SourceX/miniwin/dsound.h b/SourceX/miniwin/dsound.h new file mode 100644 index 000000000..a29dce871 --- /dev/null +++ b/SourceX/miniwin/dsound.h @@ -0,0 +1,26 @@ +#include "devilution.h" + +#include + +namespace dvl { + +struct DirectSoundBuffer : public IDirectSoundBuffer { +public: + virtual ULONG Release(); + BOOL GetStatus(LPDWORD pdwStatus); + HRESULT Lock(DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags); + HRESULT Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags); + HRESULT SetFormat(LPCWAVEFORMATEX pcfxFormat); + HRESULT SetVolume(LONG lVolume); + HRESULT SetPan(LONG lPan); + HRESULT Stop(); + HRESULT Unlock(LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2); + HRESULT Restore(); + private: + int volume = 0; + int pan = 0; + Mix_Chunk *chunk; +}; + +} // namespace dvl diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 80c9a444f..59f4473d8 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -1,10 +1,10 @@ -#include "pch.h" -#ifndef _WIN32 -#include -#endif - #include +#include "devilution.h" +#include "stubs.h" +#include "dx.h" +#include "DiabloUI/diabloui.h" + namespace dvl { DWORD last_error; @@ -104,25 +104,11 @@ UINT GetWindowsDirectoryA(LPSTR lpBuffer, UINT uSize) WINBOOL GetDiskFreeSpaceA(LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters) { -#ifndef _WIN32 - struct statvfs fiData; - int success = statvfs("/", &fiData); - *lpBytesPerSector = fiData.f_frsize; - *lpSectorsPerCluster = 1; - *lpNumberOfFreeClusters = fiData.f_bavail; - *lpTotalNumberOfClusters = fiData.f_blocks; - - return success >= 0; -#else - // Todo give windows the real GetDiskFreeSpace - DUMMY(); *lpBytesPerSector = 1; *lpSectorsPerCluster = 1; *lpNumberOfFreeClusters = 10 << 20; *lpTotalNumberOfClusters = 10 << 20; - return true; -#endif } /** @@ -188,6 +174,7 @@ DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) if (!base_path) { base_path = SDL_strdup("./"); } + eprintf("BasePath: %s\n", base_path); strncpy(lpBuffer, base_path, nBufferLength); SDL_free(base_path); @@ -201,10 +188,7 @@ DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer) { - DUMMY(); - sprintf(lpBuffer, "/"); - - return 3; + return 0; } UINT GetDriveTypeA(LPCSTR lpRootPathName) @@ -274,7 +258,7 @@ HWND FindWindowA(LPCSTR lpClassName, LPCSTR lpWindowName) void FakeWMDestroy() { - MainWndProc(NULL, DVL_WM_DESTROY, 0, NULL); + MainWndProc(NULL, DVL_WM_DESTROY, 0, 0); } HWND CreateWindowExA( @@ -639,6 +623,7 @@ DWORD GetPrivateProfileStringA(LPCSTR lpAppName, LPCSTR lpKeyName, LPCSTR lpDefa strncpy(lpReturnedString, lpDefault, nSize); SRegSaveString(lpAppName, lpKeyName, 0, lpReturnedString); } + return 0; // dummy return value } int MessageBoxA(HWND hWnd, const char *Text, const char *Title, UINT Flags) @@ -704,7 +689,7 @@ LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) if (Msg == DVL_WM_QUERYENDSESSION) exit(0); - return NULL; + return 0; } LONG GetWindowLongA(HWND hWnd, int nIndex) diff --git a/SourceX/miniwin/misc_dx.cpp b/SourceX/miniwin/misc_dx.cpp new file mode 100644 index 000000000..12959aa2b --- /dev/null +++ b/SourceX/miniwin/misc_dx.cpp @@ -0,0 +1,45 @@ +#include + +#include "devilution.h" +#include "dx.h" +#include "stubs.h" + +namespace dvl { + +WINBOOL SetCursorPos(int X, int Y) +{ + assert(renderer); + assert(window); + + SDL_Rect view; + SDL_RenderGetViewport(renderer, &view); + X += view.x; + Y += view.y; + + float scaleX; + SDL_RenderGetScale(renderer, &scaleX, NULL); + X *= scaleX; + Y *= scaleX; + + SDL_WarpMouseInWindow(window, X, Y); + return true; +} + +int ShowCursor(WINBOOL bShow) +{ + SDL_ShowCursor(bShow ? SDL_ENABLE : SDL_DISABLE); + + return bShow; +} + +WINBOOL TextOutA(HDC hdc, int x, int y, LPCSTR lpString, int c) +{ + DUMMY_ONCE(); + + assert(window); + SDL_SetWindowTitle(window, lpString); + + return true; +} + +} // namespace dvl diff --git a/SourceX/miniwin/misc_io.cpp b/SourceX/miniwin/misc_io.cpp index 9f953d27d..79070352e 100644 --- a/SourceX/miniwin/misc_io.cpp +++ b/SourceX/miniwin/misc_io.cpp @@ -1,153 +1,147 @@ -#include "pch.h" - -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "devilution.h" +#include "stubs.h" namespace dvl { -extern "C" void TranslateFileName(char *dst, int dstLen, const char *src) -{ - for (int i = 0; i < dstLen; i++) { - char c = *src++; - dst[i] = c == '\\' ? '/' : c; - if (!c) { - break; - } - } -} +struct memfile { + std::string path; + std::vector buf; + std::size_t pos = 0; +}; -static std::set files; +static std::set files; HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) + LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, + DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { - char name[260]; + char name[DVL_MAX_PATH]; TranslateFileName(name, sizeof(name), lpFileName); - DUMMY_PRINT("file: %s (%s)", lpFileName, name); - - assert(dwDesiredAccess == DVL_GENERIC_READ | DVL_GENERIC_WRITE); - - int flags = O_RDWR; - mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + UNIMPLEMENTED_UNLESS(dwDesiredAccess == (DVL_GENERIC_READ | DVL_GENERIC_WRITE)); + memfile* file = new memfile; + file->path = name; if (dwCreationDisposition == DVL_OPEN_EXISTING) { - // Nothing + // read contents of existing file into buffer + std::ifstream filestream(file->path, std::ios::binary); + if(!filestream.fail()) { + file->buf.insert(file->buf.begin(), + std::istreambuf_iterator(filestream), + std::istreambuf_iterator()); + } } else if (dwCreationDisposition == DVL_CREATE_ALWAYS) { - flags |= O_CREAT | O_TRUNC; + // start with empty file } else { UNIMPLEMENTED(); } -#ifdef _WIN32 - //replace this later by something portable - HANDLE fd = (HANDLE)open(name, flags | _O_BINARY, mode); -#else - HANDLE fd = (HANDLE)open(name, flags, mode); -#endif - - files.insert(fd); - return fd; + files.insert(file); + return file; } WINBOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, - LPOVERLAPPED lpOverlapped) + LPOVERLAPPED lpOverlapped) { - DUMMY_ONCE(); - - assert(!lpOverlapped); - int len = read((intptr_t)hFile, lpBuffer, nNumberOfBytesToRead); - assert(len != -1); + memfile* file = static_cast(hFile); + UNIMPLEMENTED_UNLESS(!lpOverlapped); + size_t len = std::min(file->buf.size() - file->pos, nNumberOfBytesToRead); + std::copy(file->buf.begin() + file->pos, file->buf.begin() + file->pos + len, static_cast(lpBuffer)); + file->pos += len; *lpNumberOfBytesRead = len; return true; } DWORD GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) { - DUMMY_ONCE(); - - assert(!lpFileSizeHigh); - struct stat s; - int ret = fstat((intptr_t)hFile, &s); - assert(ret == 0); - return s.st_size; + memfile* file = static_cast(hFile); + return file->buf.size(); } -WINBOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, - LPOVERLAPPED lpOverlapped) +WINBOOL WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, + LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) { - DUMMY_ONCE(); - - assert(!lpOverlapped); - ssize_t len = write((intptr_t)hFile, lpBuffer, nNumberOfBytesToWrite); - if (len == -1) { - *lpNumberOfBytesWritten = 0; - return false; - } - *lpNumberOfBytesWritten = (DWORD)len; + memfile* file = static_cast(hFile); + UNIMPLEMENTED_UNLESS(!lpOverlapped); + if(!nNumberOfBytesToWrite) + return true; + if(file->buf.size() < file->pos + nNumberOfBytesToWrite) + file->buf.resize(file->pos + nNumberOfBytesToWrite); + std::copy(static_cast(lpBuffer), + static_cast(lpBuffer) + nNumberOfBytesToWrite, + file->buf.begin() + file->pos); + file->pos += nNumberOfBytesToWrite; + *lpNumberOfBytesWritten = nNumberOfBytesToWrite; return true; } DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod) { - DUMMY_ONCE(); - - assert(!lpDistanceToMoveHigh); - int whence; + memfile* file = static_cast(hFile); + UNIMPLEMENTED_UNLESS(!lpDistanceToMoveHigh); if (dwMoveMethod == DVL_FILE_BEGIN) { - whence = SEEK_SET; + file->pos = lDistanceToMove; } else if (dwMoveMethod == DVL_FILE_CURRENT) { - whence = SEEK_CUR; + file->pos += lDistanceToMove; } else { UNIMPLEMENTED(); } - off_t ret = lseek((intptr_t)hFile, lDistanceToMove, whence); - return (DWORD)ret; + if(file->buf.size() < file->pos + 1) + file->buf.resize(file->pos + 1); + return file->pos; } WINBOOL SetEndOfFile(HANDLE hFile) { - DUMMY_ONCE(); - - off_t cur = lseek((intptr_t)hFile, 0, SEEK_CUR); - assert(cur != -1); - int res = ftruncate((intptr_t)hFile, cur); - assert(res == 0); + memfile* file = static_cast(hFile); + file->buf.erase(file->buf.begin() + file->pos, file->buf.end()); return true; } DWORD GetFileAttributesA(LPCSTR lpFileName) { - char name[260]; + char name[DVL_MAX_PATH]; TranslateFileName(name, sizeof(name), lpFileName); - - DUMMY_PRINT("file: %s (%s)", lpFileName, name); - - struct stat s; - int res = stat(name, &s); - - if (res == -1) { + std::ifstream filestream(name, std::ios::binary); + if (filestream.fail()) { SetLastError(DVL_ERROR_FILE_NOT_FOUND); return (DWORD)-1; } - return 0x80; } WINBOOL SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes) { - DUMMY_PRINT("file: %s", lpFileName); return true; } WINBOOL CloseHandle(HANDLE hObject) { - if (files.find(hObject) != files.end()) { - int ret = close((intptr_t)hObject); - assert(ret == 0); - files.erase(hObject); + memfile* file = static_cast(hObject); + if (files.find(file) == files.end()) + return true; + std::unique_ptr ufile(file); // ensure that delete file is + // called on returning + bool ret = true; + std::ofstream filestream(file->path + ".tmp", std::ios::binary); + if (filestream.fail()) + ret = false; + filestream.write(file->buf.data(), file->buf.size()); + if (filestream.fail()) + ret = false; + if (std::rename((file->path + ".tmp").c_str(), file->path.c_str())) + ret = false; + if(!ret) { + DialogBoxParam(ghInst, DVL_MAKEINTRESOURCE(IDD_DIALOG7), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)file->path.c_str()); } - return true; + return ret; } -} +} // namespace dvl diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index 819f04e73..c03983a81 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -1,4 +1,9 @@ -#include "pch.h" +#include +#include + +#include "devilution.h" +#include "stubs.h" + /** @file * * * Windows message handling and keyboard event conversion for SDL. diff --git a/SourceX/miniwin/rand.cpp b/SourceX/miniwin/rand.cpp index b14b044f4..327e8d1cc 100644 --- a/SourceX/miniwin/rand.cpp +++ b/SourceX/miniwin/rand.cpp @@ -1,4 +1,4 @@ -#include +#include #include "devilution.h" diff --git a/SourceX/miniwin/thread.cpp b/SourceX/miniwin/thread.cpp index 1091c6c9f..ffa6ad50a 100644 --- a/SourceX/miniwin/thread.cpp +++ b/SourceX/miniwin/thread.cpp @@ -1,4 +1,8 @@ -#include "pch.h" +#include +#include + +#include "devilution.h" +#include "stubs.h" namespace dvl { diff --git a/SourceX/pch.h b/SourceX/pch.h deleted file mode 100644 index 15158591c..000000000 --- a/SourceX/pch.h +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "devilution.h" -#include "DiabloUI/diabloui.h" - -namespace dvl { - -struct DirectSoundBuffer : public IDirectSoundBuffer { -public: - virtual ULONG Release(); - BOOL GetStatus(LPDWORD pdwStatus); - HRESULT Lock(DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags); - HRESULT Play(DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags); - HRESULT SetFormat(LPCWAVEFORMATEX pcfxFormat); - HRESULT SetVolume(LONG lVolume); - HRESULT SetPan(LONG lPan); - HRESULT Stop(); - HRESULT Unlock(LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2); - HRESULT Restore(); - private: - int volume = 0; - int pan = 0; - Mix_Chunk *chunk; -}; - -} // namespace dvl diff --git a/SourceX/sound.cpp b/SourceX/sound.cpp index b32ec2f17..fece87865 100644 --- a/SourceX/sound.cpp +++ b/SourceX/sound.cpp @@ -1,13 +1,14 @@ -//HEADER_GOES_HERE +#include "devilution.h" -#include "../types.h" -#include "pch.h" +#include + +#include "stubs.h" namespace dvl { LPDIRECTSOUNDBUFFER DSBs[8]; LPDIRECTSOUND sglpDS; -char gbSndInited; +BOOLEAN gbSndInited; int sglMusicVolume; int sglSoundVolume; HMODULE hDsound_dll; diff --git a/SourceX/storm.cpp b/SourceX/storm/storm.cpp similarity index 90% rename from SourceX/storm.cpp rename to SourceX/storm/storm.cpp index 652e55f1c..1e5ea82b3 100644 --- a/SourceX/storm.cpp +++ b/SourceX/storm/storm.cpp @@ -1,24 +1,40 @@ -#include "../3rdParty/Radon/Radon/include/Radon.hpp" -#include "../3rdParty/libsmacker/smacker.h" -#include "pch.h" +#include +#include +#include +#include -#include +#include "devilution.h" +#include "stubs.h" +#include "DiabloUI/diabloui.h" +#include "dx.h" namespace dvl { -extern "C" DWORD nLastError = 0; +DWORD nLastError = 0; -std::string getIniPath() +static std::string getIniPath() { - char path[280]; - int len = GetModuleFileNameA(ghInst, path, 260); + char path[DVL_MAX_PATH]; + int len = GetModuleFileNameA(ghInst, path, DVL_MAX_PATH); path[len - 1] = '/'; strcat(path, "diablo.ini"); return path; } -radon::File ini(getIniPath()); +static radon::File ini(getIniPath()); +static Mix_Chunk *SFileChunk; + +void TranslateFileName(char *dst, int dstLen, const char *src) +{ + for (int i = 0; i < dstLen; i++) { + char c = *src++; + dst[i] = c == '\\' ? '/' : c; + if (!c) { + break; + } + } +} // BOOL SFileCloseArchive(HANDLE hArchive) // { @@ -30,7 +46,6 @@ radon::File ini(getIniPath()); // UNIMPLEMENTED(); // } -Mix_Chunk *SFileChunk; BOOL SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7) { @@ -42,6 +57,9 @@ BOOL SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDi SFileChunk = Mix_LoadWAV_RW(rw, 1); free(SFXbuffer); + Mix_Volume(0, MIX_MAX_VOLUME - MIX_MAX_VOLUME * volume / VOLUME_MIN); + int panned = 255 - 255 * abs(pan) / 10000; + Mix_SetPanning(0, pan <= 0 ? 255 : panned, pan >= 0 ? 255 : panned); Mix_PlayChannel(0, SFileChunk, 0); return true; @@ -206,7 +224,7 @@ BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffe byte = *dataPtr; if (byte < 0xC0) { *pBuffer = byte; - *pBuffer++; + pBuffer++; x++; continue; } @@ -214,7 +232,7 @@ BOOL SBmpLoadImage(const char *pszFileName, PALETTEENTRY *pPalette, BYTE *pBuffe for (int i = 0; i < (byte & 0x3F); i++) { *pBuffer = *dataPtr; - *pBuffer++; + pBuffer++; x++; } } @@ -526,7 +544,7 @@ BOOL SVidPlayContinue(void) double now = SDL_GetTicks() * 1000; if (now < SVidFrameEnd) { - usleep(SVidFrameEnd - now); // wait with next frame if the system is to fast + SDL_Delay((SVidFrameEnd - now)/1000); // wait with next frame if the system is to fast } return SVidLoadNextFrame(); diff --git a/SourceX/storm/storm_dx.cpp b/SourceX/storm/storm_dx.cpp new file mode 100644 index 000000000..e341a611b --- /dev/null +++ b/SourceX/storm/storm_dx.cpp @@ -0,0 +1,38 @@ +#include + +#include "devilution.h" +#include "dx.h" +#include "stubs.h" + +namespace dvl { + +BOOL SDrawUpdatePalette(unsigned int firstentry, unsigned int numentries, PALETTEENTRY *pPalEntries, int a4) +{ + assert(firstentry == 0); + assert(numentries == 256); + + SDL_Color colors[256]; + for (unsigned int i = firstentry; i < numentries; i++) { + SDL_Color *c = &colors[i]; + PALETTEENTRY *p = &pPalEntries[i]; + c->r = p->peRed; + c->g = p->peGreen; + c->b = p->peBlue; + c->a = SDL_ALPHA_OPAQUE; + } + + assert(palette); + if (SDL_SetPaletteColors(palette, colors, firstentry, numentries) != 0) { + SDL_Log("SDL_SetPaletteColors: %s\n", SDL_GetError()); + return false; + } + + if (pal_surface) { + sdl_update_entire_surface(); + sdl_present_surface(); + } + + return true; +} + +} // namespace dvl diff --git a/SourceX/storm_net.cpp b/SourceX/storm/storm_net.cpp similarity index 98% rename from SourceX/storm_net.cpp rename to SourceX/storm/storm_net.cpp index 7e66ecf57..fabd846e3 100644 --- a/SourceX/storm_net.cpp +++ b/SourceX/storm/storm_net.cpp @@ -1,5 +1,8 @@ +#include + +#include "devilution.h" +#include "stubs.h" #include "dvlnet/abstract_net.h" -#include "pch.h" namespace dvl { diff --git a/SourceX/stubs.h b/SourceX/stubs.h index 8ea96bbd6..9919c9024 100644 --- a/SourceX/stubs.h +++ b/SourceX/stubs.h @@ -12,6 +12,12 @@ abort(); \ } while (0) +#define UNIMPLEMENTED_UNLESS(x) \ + do { \ + if(!(x)) \ + UNIMPLEMENTED(); \ + } while (0) + #define ABORT() \ do { \ eprintf("ABORT: %s @ %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ diff --git a/SourceX/utf8.h b/SourceX/utf8.h index 26d9a7a79..7f2c396fb 100644 --- a/SourceX/utf8.h +++ b/SourceX/utf8.h @@ -1,13 +1,13 @@ +#pragma once + +#include +#include +#include + /* Branchless UTF-8 decoder * * This is free and unencumbered software released into the public domain. */ -#ifndef UTF8_H -#define UTF8_H - -#include -#include -#include /* Decode the next character, C, from BUF, reporting errors in E. * @@ -84,5 +84,3 @@ inline std::string utf8_to_latin1(const char* in) } return std::move(ret); } - -#endif diff --git a/Xcode/devilutionX.xcodeproj/project.pbxproj b/Xcode/devilutionX.xcodeproj/project.pbxproj index 7e2f630a4..730e24e6f 100644 --- a/Xcode/devilutionX.xcodeproj/project.pbxproj +++ b/Xcode/devilutionX.xcodeproj/project.pbxproj @@ -7,19 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 00DABA918E5348F382AF3E16 /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A4D49F7AAB1448BB3796750 /* debug.cpp */; }; - 0E40D3E2ABA5486884AD1271 /* textdat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC0017809BF45FD9BCC06CA /* textdat.cpp */; }; - 10A37F34E807485A8081A8A6 /* missiles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DDD7341C6712447191FD2C4B /* missiles.cpp */; }; - 17C52FFA55984C5A93007652 /* objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C713AED00778486B94CD282B /* objects.cpp */; }; - 1EDB503A982F46D4920BFF3D /* gmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3CC4A34B55AA4827B345A6A0 /* gmenu.cpp */; }; - 2363B2BA33664F008CF2266E /* engine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E47C81C5BD940C2A5A1704D /* engine.cpp */; }; - 283E47DA990148F18302218F /* towners.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 47D57E7305264ED7951AF3B1 /* towners.cpp */; }; - 2962434943834AF8839658B8 /* pack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31E66A5457E64947AA68C7F7 /* pack.cpp */; }; - 2A743A2DEE444E6295400155 /* player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1B3EB5883E0C42D3A0F3D4D5 /* player.cpp */; }; - 2B0FDA186B5D4A348E82BE69 /* drlg_l3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1B1230CFD4B8587F7EC80 /* drlg_l3.cpp */; }; - 2E51C3FD096247BDB522FA63 /* error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413186B26DE644E197D49314 /* error.cpp */; }; - 3AA9769F36DA404CB3DB029B /* portal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2017B5200DF14FD7B6959133 /* portal.cpp */; }; - 3D80977966AE4264938D37A3 /* town.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DAAD0527F1EA496A8B669415 /* town.cpp */; }; 433449A42240500B003AB4F2 /* libpng16.16.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 433449A222404FFA003AB4F2 /* libpng16.16.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 43398749223E5D3A001F8420 /* SDL2_mixer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43398741223E5CB0001F8420 /* SDL2_mixer.framework */; }; 4339874A223E5D3A001F8420 /* SDL2_mixer.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 43398741223E5CB0001F8420 /* SDL2_mixer.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -27,34 +14,6 @@ 4339874C223E5D3A001F8420 /* SDL2_ttf.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 4339873F223E5CAB001F8420 /* SDL2_ttf.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 4339874E223E5D3A001F8420 /* SDL2.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 4339873D223E5C1A001F8420 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 43398752223E5E0E001F8420 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4339873D223E5C1A001F8420 /* SDL2.framework */; }; - 43398770223E60F8001F8420 /* miniwin_dsound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398754223E60F3001F8420 /* miniwin_dsound.cpp */; }; - 43398771223E60F8001F8420 /* udp_p2p.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398755223E60F3001F8420 /* udp_p2p.cpp */; }; - 43398772223E60F8001F8420 /* base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398756223E60F4001F8420 /* base.cpp */; }; - 43398773223E60F8001F8420 /* storm_net.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398757223E60F4001F8420 /* storm_net.cpp */; }; - 43398774223E60F8001F8420 /* diabloui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398758223E60F4001F8420 /* diabloui.cpp */; }; - 43398775223E60F8001F8420 /* mainmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398759223E60F4001F8420 /* mainmenu.cpp */; }; - 43398776223E60F8001F8420 /* progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875A223E60F4001F8420 /* progress.cpp */; }; - 43398777223E60F9001F8420 /* selconn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875B223E60F4001F8420 /* selconn.cpp */; }; - 43398778223E60F9001F8420 /* packet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875C223E60F4001F8420 /* packet.cpp */; }; - 43398779223E60F9001F8420 /* sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875D223E60F5001F8420 /* sound.cpp */; }; - 4339877A223E60F9001F8420 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875E223E60F5001F8420 /* main.cpp */; }; - 4339877B223E60F9001F8420 /* storm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339875F223E60F5001F8420 /* storm.cpp */; }; - 4339877C223E60F9001F8420 /* abstract_net.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398760223E60F5001F8420 /* abstract_net.cpp */; }; - 4339877D223E60F9001F8420 /* frame_queue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398761223E60F5001F8420 /* frame_queue.cpp */; }; - 4339877E223E60F9001F8420 /* misc_msg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398762223E60F6001F8420 /* misc_msg.cpp */; }; - 4339877F223E60F9001F8420 /* misc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398763223E60F6001F8420 /* misc.cpp */; }; - 43398780223E60F9001F8420 /* thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398764223E60F6001F8420 /* thread.cpp */; }; - 43398781223E60F9001F8420 /* title.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398765223E60F6001F8420 /* title.cpp */; }; - 43398782223E60F9001F8420 /* dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398766223E60F6001F8420 /* dx.cpp */; }; - 43398783223E60F9001F8420 /* tcp_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398767223E60F7001F8420 /* tcp_client.cpp */; }; - 43398784223E60F9001F8420 /* rand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398768223E60F7001F8420 /* rand.cpp */; }; - 43398785223E60F9001F8420 /* misc_io.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43398769223E60F7001F8420 /* misc_io.cpp */; }; - 43398786223E60F9001F8420 /* selgame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876A223E60F7001F8420 /* selgame.cpp */; }; - 43398787223E60F9001F8420 /* tcp_server.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876B223E60F7001F8420 /* tcp_server.cpp */; }; - 43398788223E60F9001F8420 /* loopback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876C223E60F8001F8420 /* loopback.cpp */; }; - 43398789223E60F9001F8420 /* selhero.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876D223E60F8001F8420 /* selhero.cpp */; }; - 4339878A223E60F9001F8420 /* credits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876E223E60F8001F8420 /* credits.cpp */; }; - 4339878B223E60F9001F8420 /* dialogs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4339876F223E60F8001F8420 /* dialogs.cpp */; }; 436280812236241F00C911AD /* libdevilution.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ECD637555514971BCD3E90E /* libdevilution.a */; }; 436280822236241F00C911AD /* libPKWare.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 646292CBB776434AA4CA1C94 /* libPKWare.a */; }; 436280832236241F00C911AD /* libRadon.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 92E1DAF5C7BA48E5A1E39C04 /* libRadon.a */; }; @@ -75,70 +34,113 @@ 4362B526223E2B8600633F20 /* SBaseCommon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362B51B223E2B8600633F20 /* SBaseCommon.cpp */; }; 4362B527223E2B8600633F20 /* SFileExtractFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362B51C223E2B8600633F20 /* SFileExtractFile.cpp */; }; 4362B528223E2B8600633F20 /* FileStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362B51D223E2B8600633F20 /* FileStream.cpp */; }; + 43B6C7CA224068AB007313EA /* abstract_net.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7992240688A007313EA /* abstract_net.cpp */; }; + 43B6C7CB224068AB007313EA /* base.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79022406888007313EA /* base.cpp */; }; + 43B6C7CC224068AB007313EA /* credits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A92240688C007313EA /* credits.cpp */; }; + 43B6C7CD224068AB007313EA /* diabloui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79122406889007313EA /* diabloui.cpp */; }; + 43B6C7CE224068AB007313EA /* dialogs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7AA2240688D007313EA /* dialogs.cpp */; }; + 43B6C7CF224068AB007313EA /* dsound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7982240688A007313EA /* dsound.cpp */; }; + 43B6C7D0224068AB007313EA /* dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A02240688B007313EA /* dx.cpp */; }; + 43B6C7D1224068AB007313EA /* frame_queue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79A2240688A007313EA /* frame_queue.cpp */; }; + 43B6C7D2224068AB007313EA /* loopback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A62240688C007313EA /* loopback.cpp */; }; + 43B6C7D3224068AB007313EA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79722406889007313EA /* main.cpp */; }; + 43B6C7D4224068AB007313EA /* mainmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79222406889007313EA /* mainmenu.cpp */; }; + 43B6C7D5224068AB007313EA /* misc_dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C78F22406888007313EA /* misc_dx.cpp */; }; + 43B6C7D6224068AB007313EA /* misc_io.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A32240688B007313EA /* misc_io.cpp */; }; + 43B6C7D7224068AB007313EA /* misc_msg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79B2240688A007313EA /* misc_msg.cpp */; }; + 43B6C7D8224068AB007313EA /* misc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79C2240688A007313EA /* misc.cpp */; }; + 43B6C7D9224068AB007313EA /* packet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79522406889007313EA /* packet.cpp */; }; + 43B6C7DA224068AB007313EA /* progress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79322406889007313EA /* progress.cpp */; }; + 43B6C7DB224068AB007313EA /* rand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A22240688B007313EA /* rand.cpp */; }; + 43B6C7DC224068AB007313EA /* selconn.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79422406889007313EA /* selconn.cpp */; }; + 43B6C7DD224068AB007313EA /* selgame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A42240688B007313EA /* selgame.cpp */; }; + 43B6C7DE224068AB007313EA /* selhero.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A72240688C007313EA /* selhero.cpp */; }; + 43B6C7DF224068AB007313EA /* sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79D2240688A007313EA /* sound.cpp */; }; + 43B6C7E0224068AB007313EA /* storm_dx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A82240688C007313EA /* storm_dx.cpp */; }; + 43B6C7E1224068AB007313EA /* storm_net.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79622406889007313EA /* storm_net.cpp */; }; + 43B6C7E2224068AB007313EA /* storm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7AB2240688D007313EA /* storm.cpp */; }; + 43B6C7E3224068AB007313EA /* tcp_client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A12240688B007313EA /* tcp_client.cpp */; }; + 43B6C7E4224068AB007313EA /* tcp_server.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7A52240688C007313EA /* tcp_server.cpp */; }; + 43B6C7E5224068AB007313EA /* thread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79E2240688A007313EA /* thread.cpp */; }; + 43B6C7E6224068AB007313EA /* title.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C79F2240688B007313EA /* title.cpp */; }; + 43B6C7E7224068AB007313EA /* udp_p2p.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C78E22406888007313EA /* udp_p2p.cpp */; }; + 43B6C82A224068CF007313EA /* appfat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72B2240686D007313EA /* appfat.cpp */; }; + 43B6C82B224068CF007313EA /* automap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7212240686A007313EA /* automap.cpp */; }; + 43B6C82C224068CF007313EA /* capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7312240686F007313EA /* capture.cpp */; }; + 43B6C82D224068CF007313EA /* codec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74622406874007313EA /* codec.cpp */; }; + 43B6C82E224068CF007313EA /* control.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71F2240686A007313EA /* control.cpp */; }; + 43B6C82F224068CF007313EA /* cursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70E22406867007313EA /* cursor.cpp */; }; + 43B6C830224068CF007313EA /* dead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71522406868007313EA /* dead.cpp */; }; + 43B6C831224068CF007313EA /* debug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71D22406869007313EA /* debug.cpp */; }; + 43B6C832224068CF007313EA /* diablo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73F22406873007313EA /* diablo.cpp */; }; + 43B6C833224068CF007313EA /* doom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7252240686B007313EA /* doom.cpp */; }; + 43B6C834224068CF007313EA /* drlg_l1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71222406867007313EA /* drlg_l1.cpp */; }; + 43B6C835224068CF007313EA /* drlg_l2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73722406871007313EA /* drlg_l2.cpp */; }; + 43B6C836224068CF007313EA /* drlg_l3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71322406868007313EA /* drlg_l3.cpp */; }; + 43B6C837224068CF007313EA /* drlg_l4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73822406871007313EA /* drlg_l4.cpp */; }; + 43B6C838224068CF007313EA /* dthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73E22406872007313EA /* dthread.cpp */; }; + 43B6C839224068CF007313EA /* effects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73B22406872007313EA /* effects.cpp */; }; + 43B6C83A224068CF007313EA /* encrypt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74022406873007313EA /* encrypt.cpp */; }; + 43B6C83B224068CF007313EA /* engine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73522406870007313EA /* engine.cpp */; }; + 43B6C83C224068CF007313EA /* error.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70A22406866007313EA /* error.cpp */; }; + 43B6C83D224068CF007313EA /* fault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7202240686A007313EA /* fault.cpp */; }; + 43B6C83E224068CF007313EA /* gamemenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72E2240686E007313EA /* gamemenu.cpp */; }; + 43B6C83F224068CF007313EA /* gendung.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71C22406869007313EA /* gendung.cpp */; }; + 43B6C840224068CF007313EA /* gmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70B22406866007313EA /* gmenu.cpp */; }; + 43B6C841224068CF007313EA /* help.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70D22406867007313EA /* help.cpp */; }; + 43B6C842224068CF007313EA /* init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70C22406866007313EA /* init.cpp */; }; + 43B6C843224068CF007313EA /* interfac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71422406868007313EA /* interfac.cpp */; }; + 43B6C844224068CF007313EA /* inv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73C22406872007313EA /* inv.cpp */; }; + 43B6C845224068CF007313EA /* items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71022406867007313EA /* items.cpp */; }; + 43B6C846224068CF007313EA /* lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74722406875007313EA /* lighting.cpp */; }; + 43B6C847224068CF007313EA /* loadsave.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72F2240686F007313EA /* loadsave.cpp */; }; + 43B6C848224068CF007313EA /* logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7222240686A007313EA /* logging.cpp */; }; + 43B6C849224068CF007313EA /* mainmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7302240686F007313EA /* mainmenu.cpp */; }; + 43B6C84A224068CF007313EA /* minitext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7242240686B007313EA /* minitext.cpp */; }; + 43B6C84B224068CF007313EA /* missiles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71622406868007313EA /* missiles.cpp */; }; + 43B6C84C224068CF007313EA /* monster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74822406875007313EA /* monster.cpp */; }; + 43B6C84D224068CF007313EA /* movie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72A2240686D007313EA /* movie.cpp */; }; + 43B6C84E224068CF007313EA /* mpqapi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72D2240686E007313EA /* mpqapi.cpp */; }; + 43B6C84F224068CF007313EA /* msg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71722406868007313EA /* msg.cpp */; }; + 43B6C850224068CF007313EA /* msgcmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74922406875007313EA /* msgcmd.cpp */; }; + 43B6C851224068CF007313EA /* multi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71E22406869007313EA /* multi.cpp */; }; + 43B6C852224068CF007313EA /* nthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73422406870007313EA /* nthread.cpp */; }; + 43B6C853224068CF007313EA /* objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C72C2240686E007313EA /* objects.cpp */; }; + 43B6C854224068CF007313EA /* pack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74122406873007313EA /* pack.cpp */; }; + 43B6C855224068CF007313EA /* palette.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73322406870007313EA /* palette.cpp */; }; + 43B6C856224068CF007313EA /* path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7322240686F007313EA /* path.cpp */; }; + 43B6C857224068CF007313EA /* pfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73922406871007313EA /* pfile.cpp */; }; + 43B6C858224068CF007313EA /* player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C70F22406867007313EA /* player.cpp */; }; + 43B6C859224068CF007313EA /* plrmsg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7232240686A007313EA /* plrmsg.cpp */; }; + 43B6C85A224068CF007313EA /* portal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71922406869007313EA /* portal.cpp */; }; + 43B6C85B224068CF007313EA /* quests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74222406873007313EA /* quests.cpp */; }; + 43B6C85C224068CF007313EA /* render.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73622406870007313EA /* render.cpp */; }; + 43B6C85D224068CF007313EA /* restrict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73D22406872007313EA /* restrict.cpp */; }; + 43B6C85E224068CF007313EA /* scrollrt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74B22406875007313EA /* scrollrt.cpp */; }; + 43B6C85F224068CF007313EA /* setmaps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74322406874007313EA /* setmaps.cpp */; }; + 43B6C860224068CF007313EA /* sha.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7272240686C007313EA /* sha.cpp */; }; + 43B6C861224068CF007313EA /* spells.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71822406868007313EA /* spells.cpp */; }; + 43B6C862224068CF007313EA /* stores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71122406867007313EA /* stores.cpp */; }; + 43B6C863224068CF007313EA /* sync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7282240686C007313EA /* sync.cpp */; }; + 43B6C864224068CF007313EA /* textdat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7262240686C007313EA /* textdat.cpp */; }; + 43B6C865224068CF007313EA /* themes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C7292240686D007313EA /* themes.cpp */; }; + 43B6C866224068CF007313EA /* tmsg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71B22406869007313EA /* tmsg.cpp */; }; + 43B6C867224068CF007313EA /* town.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74422406874007313EA /* town.cpp */; }; + 43B6C868224068CF007313EA /* towners.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74A22406875007313EA /* towners.cpp */; }; + 43B6C869224068CF007313EA /* track.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C71A22406869007313EA /* track.cpp */; }; + 43B6C86A224068CF007313EA /* trigs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C74522406874007313EA /* trigs.cpp */; }; + 43B6C86B224068CF007313EA /* wave.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B6C73A22406872007313EA /* wave.cpp */; }; 43BA39B122375D8A009041FF /* AppIcon.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 43BA39AF22375925009041FF /* AppIcon.xcassets */; }; - 4F27D72CD6A448B196008C10 /* encrypt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1F6D083DFE8F4912AD21323E /* encrypt.cpp */; }; - 503716BF6B434A48ACA1BD86 /* drlg_l1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6687A60F94C648A2B5E20FB7 /* drlg_l1.cpp */; }; - 50630CDFA3D444DCA5946A1C /* lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D58130817DEA419984D28AB3 /* lighting.cpp */; }; - 545DD73999244831A23D777A /* scrollrt.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7385F58EEFA44AF88C4D8798 /* scrollrt.cpp */; }; - 547166BC671248509081109E /* restrict.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5876CCE0133A4D6EADDF0AAE /* restrict.cpp */; }; - 5CE3C7E27B6E4BD9AAA5619D /* gamemenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FBCC5BCDC3842F58CF572AB /* gamemenu.cpp */; }; - 5E67153371F94500B95B41A7 /* track.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2C87FF47C667465E868B191E /* track.cpp */; }; - 5FA14820FB17477383DA0700 /* path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A711EC4A01C74302BF18E4C3 /* path.cpp */; }; - 6186FBD4D4644CA78FEAAA53 /* appfat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EDDB82E7195E4EF69A42C0D5 /* appfat.cpp */; }; - 623ACC26BBBB42978A6386EF /* automap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D86188B68E494666A2972128 /* automap.cpp */; }; - 6240F97CE4014B1DB267D471 /* dthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D961B8EC59154E98955AE2E7 /* dthread.cpp */; }; - 6261395CEAB2412186C5666C /* interfac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8445BFAA306D42FE886F0ACC /* interfac.cpp */; }; - 64CE5D2CE32946A08990EE92 /* setmaps.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C78DC63816DF4F1C867578C7 /* setmaps.cpp */; }; 652BBCD55FBE46CC941FD64C /* smk_bitstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 670494A24D7F4CFFACCD3BFB /* smk_bitstream.c */; }; - 6651D75C83744F8BB9A4EE09 /* drlg_l2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 219EFD2B33014357A3B26650 /* drlg_l2.cpp */; }; - 6669BEC0507C4957BAD30989 /* effects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A28321B6858D4AB5A53D7408 /* effects.cpp */; }; 73E86BC9E2714148AD560C46 /* smacker.c in Sources */ = {isa = PBXBuildFile; fileRef = 622A8C6A02D94FFC996C2CAE /* smacker.c */; }; - 75294609B2944CC9BC4A487B /* drlg_l4.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 183703645CB04A19AD9E5025 /* drlg_l4.cpp */; }; - 75CE86C992F940A4B4D78E5C /* diablo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0EF63E8BD67C4954A26480D5 /* diablo.cpp */; }; - 7652232427CA44C1BBBAAFE3 /* capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3B7366F811604AE1B00C8C9A /* capture.cpp */; }; - 76C236244D2B4D5FB67381DB /* spells.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84BAB44B72164700A0A8B4D6 /* spells.cpp */; }; - 773B22BC5C3E41799F769001 /* msg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4040598A1C254715A8C8673C /* msg.cpp */; }; - 7AF599B5937C48CFA2FFDAA4 /* render.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5A898CD619824F19ABC9E484 /* render.cpp */; }; - 7DACE4548EF94D77874E0F31 /* palette.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32E0A65ED0904E12BE84988B /* palette.cpp */; }; - 7E67ADF45FD840B69098C6D0 /* sync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D09D9AFCBB94D86BD283257 /* sync.cpp */; }; - 81595166A06F4A09A80AEFB5 /* help.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBB67C79EEBA48D1B5D8D70B /* help.cpp */; }; - 81797D16B64A49F79D53FE9B /* loadsave.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F0FEC1BE8E6049D593406F4D /* loadsave.cpp */; }; - 82418547480144C0A65FC9CE /* themes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98AB581710214A55AD84E8D0 /* themes.cpp */; }; 8305C713732C4CECA36F37E9 /* explode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D7FE30F050049FB933D2788 /* explode.cpp */; }; - 8774C8F414CF47248652D15A /* nthread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 203ED4AA4231415BA1B02BAE /* nthread.cpp */; }; - 89C8F76E788A4369AE9CA283 /* logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 68977FC478CB4E6CA54A3E38 /* logging.cpp */; }; - 8AC07A27B0D3408884802D80 /* tmsg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3216A3E0351743AE8FFCF891 /* tmsg.cpp */; }; 8FA4E9B3FA7D4B6AAB10EF73 /* implode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1B2D29A5A284CD29205745F /* implode.cpp */; }; - 96A5B8E287BF480CB1733558 /* mainmenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 737FBDFA9A4A4B628BB2235B /* mainmenu.cpp */; }; - A4D2FA94492E46D38B094934 /* sha.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4741C7B8659C4E1C826A129C /* sha.cpp */; }; - A708041A39EB43BB8F68E7D2 /* movie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7B0ACCABE284B3888DF09D5 /* movie.cpp */; }; - AA419C3D7384435299F5FA80 /* trigs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 60A06F7D04B1447FAE6F13C9 /* trigs.cpp */; }; - AED121172E094DAAB8B1322D /* msgcmd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EAC7C674E0104BA4A4B0FEA3 /* msgcmd.cpp */; }; - B000FB7744A2405CB4A39483 /* multi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5F3FB00DF08741CDA799AB93 /* multi.cpp */; }; - B1D9EA0B0DA04F15BFA456A9 /* gendung.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E421A97655174F4099852AD2 /* gendung.cpp */; }; - B4BBB196D148453BA2BA830E /* init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6BDC3D1BA3B64866B84CEB3C /* init.cpp */; }; - B728E60F029A4234B90A9371 /* dead.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 16C6AB08C75D4A1E993FE50B /* dead.cpp */; }; - B748B788987B4A9A91DF84B3 /* items.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF78F60283044A13A4CE1D1B /* items.cpp */; }; - BAC5D4D57F364349B3C2F552 /* control.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D7327A50AC445CE94B2B4C9 /* control.cpp */; }; - BB88EC00498744F7914A1484 /* stores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3D28A84812B34E10AE50E192 /* stores.cpp */; }; - BFF16F60B46F4B8984D3007C /* quests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0348AAD50CEF4915900FD581 /* quests.cpp */; }; C43B4AA5223F0DD900CE0DD9 /* libclang_rt.asan_osx_dynamic.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = C43B4AA3223F0DCA00CE0DD9 /* libclang_rt.asan_osx_dynamic.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; - C648EEFB6E17468AB8C3943E /* fault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C2AEA532E6F4FF8B66083C9 /* fault.cpp */; }; C794AF87232B4745B3C48397 /* Key.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0B8A000CA684B9FAF88F313 /* Key.cpp */; }; - CCB1A17083824600A7FC6DBF /* doom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7119751C6B7A4F40BB3B87B0 /* doom.cpp */; }; - CE3E3D2BD44C407A9BE60A72 /* codec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CA4B6FC7C063411F9460CD20 /* codec.cpp */; }; - D1124CA76EC04271B012DDA6 /* pfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A86F8316B224BF3BA817854 /* pfile.cpp */; }; - D9B4737B66AE401189E47E04 /* wave.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 373F9A9104DF4176A291FC8B /* wave.cpp */; }; - DA61C597DBC848E39FBE602E /* plrmsg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BA2A3A52015F4859A4C5A6A2 /* plrmsg.cpp */; }; - E3A3620899BB426EA66636CF /* monster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E54D4F37A0B24C6B83CE5D22 /* monster.cpp */; }; E3C499D08A284F95BDB46B42 /* smk_hufftree.c in Sources */ = {isa = PBXBuildFile; fileRef = 500C9F6E13FE44BFAEFCB81B /* smk_hufftree.c */; }; - E777E9F7F0C54ECBA2DE2A2C /* cursor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E812A68DE4194125A3A7A351 /* cursor.cpp */; }; EF709BC9D0B245338D17E9D7 /* Section.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6F074DDFE42C4B46A93CC4A9 /* Section.cpp */; }; F425942E977042C9AAD29647 /* File.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 722EB8D86DBF49368AAFEE3C /* File.cpp */; }; - F47E4687B48048D9943833C3 /* inv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CF6C9F651C014C538ECFCC09 /* inv.cpp */; }; - FA750FAB5C734384B3E1D709 /* minitext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DB292068EC0C4CDD8E7A57CF /* minitext.cpp */; }; FB80B52A619D452FA9BDE316 /* Named.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B229DB87369B4D76B0A60580 /* Named.cpp */; }; - FD006417F6AA479E9A2764C5 /* mpqapi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 966BF9CEF1B6419CA25FC162 /* mpqapi.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -205,63 +207,11 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0348AAD50CEF4915900FD581 /* quests.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = quests.cpp; path = Source/quests.cpp; sourceTree = SOURCE_ROOT; }; - 0EF63E8BD67C4954A26480D5 /* diablo.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = diablo.cpp; path = Source/diablo.cpp; sourceTree = SOURCE_ROOT; }; - 16C6AB08C75D4A1E993FE50B /* dead.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = dead.cpp; path = Source/dead.cpp; sourceTree = SOURCE_ROOT; }; - 183703645CB04A19AD9E5025 /* drlg_l4.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = drlg_l4.cpp; path = Source/drlg_l4.cpp; sourceTree = SOURCE_ROOT; }; - 1A4D49F7AAB1448BB3796750 /* debug.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = debug.cpp; path = Source/debug.cpp; sourceTree = SOURCE_ROOT; }; - 1B3EB5883E0C42D3A0F3D4D5 /* player.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = player.cpp; path = Source/player.cpp; sourceTree = SOURCE_ROOT; }; - 1F6D083DFE8F4912AD21323E /* encrypt.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = encrypt.cpp; path = Source/encrypt.cpp; sourceTree = SOURCE_ROOT; }; - 1FBCC5BCDC3842F58CF572AB /* gamemenu.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = gamemenu.cpp; path = Source/gamemenu.cpp; sourceTree = SOURCE_ROOT; }; - 2017B5200DF14FD7B6959133 /* portal.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = portal.cpp; path = Source/portal.cpp; sourceTree = SOURCE_ROOT; }; - 203ED4AA4231415BA1B02BAE /* nthread.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = nthread.cpp; path = Source/nthread.cpp; sourceTree = SOURCE_ROOT; }; - 219EFD2B33014357A3B26650 /* drlg_l2.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = drlg_l2.cpp; path = Source/drlg_l2.cpp; sourceTree = SOURCE_ROOT; }; - 2C87FF47C667465E868B191E /* track.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = track.cpp; path = Source/track.cpp; sourceTree = SOURCE_ROOT; }; - 2D7327A50AC445CE94B2B4C9 /* control.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = control.cpp; path = Source/control.cpp; sourceTree = SOURCE_ROOT; }; - 31E66A5457E64947AA68C7F7 /* pack.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = pack.cpp; path = Source/pack.cpp; sourceTree = SOURCE_ROOT; }; - 3216A3E0351743AE8FFCF891 /* tmsg.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = tmsg.cpp; path = Source/tmsg.cpp; sourceTree = SOURCE_ROOT; }; - 32E0A65ED0904E12BE84988B /* palette.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = palette.cpp; path = Source/palette.cpp; sourceTree = SOURCE_ROOT; }; - 373F9A9104DF4176A291FC8B /* wave.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = wave.cpp; path = Source/wave.cpp; sourceTree = SOURCE_ROOT; }; - 3B7366F811604AE1B00C8C9A /* capture.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = capture.cpp; path = Source/capture.cpp; sourceTree = SOURCE_ROOT; }; - 3CC0017809BF45FD9BCC06CA /* textdat.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = textdat.cpp; path = Source/textdat.cpp; sourceTree = SOURCE_ROOT; }; - 3CC4A34B55AA4827B345A6A0 /* gmenu.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = gmenu.cpp; path = Source/gmenu.cpp; sourceTree = SOURCE_ROOT; }; - 3D09D9AFCBB94D86BD283257 /* sync.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = sync.cpp; path = Source/sync.cpp; sourceTree = SOURCE_ROOT; }; - 3D28A84812B34E10AE50E192 /* stores.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = stores.cpp; path = Source/stores.cpp; sourceTree = SOURCE_ROOT; }; 3ECD637555514971BCD3E90E /* libdevilution.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libdevilution.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 4040598A1C254715A8C8673C /* msg.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = msg.cpp; path = Source/msg.cpp; sourceTree = SOURCE_ROOT; }; - 413186B26DE644E197D49314 /* error.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = error.cpp; path = Source/error.cpp; sourceTree = SOURCE_ROOT; }; 433449A222404FFA003AB4F2 /* libpng16.16.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libpng16.16.dylib; path = libs/frameworks/libpng16.16.dylib; sourceTree = ""; }; 4339873D223E5C1A001F8420 /* SDL2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = SDL2.framework; path = libs/frameworks/SDL2.framework; sourceTree = SOURCE_ROOT; }; 4339873F223E5CAB001F8420 /* SDL2_ttf.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = SDL2_ttf.framework; path = libs/frameworks/SDL2_ttf.framework; sourceTree = ""; }; 43398741223E5CB0001F8420 /* SDL2_mixer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = SDL2_mixer.framework; path = libs/frameworks/SDL2_mixer.framework; sourceTree = ""; }; - 43398754223E60F3001F8420 /* miniwin_dsound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = miniwin_dsound.cpp; path = SourceX/miniwin_dsound.cpp; sourceTree = ""; }; - 43398755223E60F3001F8420 /* udp_p2p.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = udp_p2p.cpp; path = SourceX/dvlnet/udp_p2p.cpp; sourceTree = ""; }; - 43398756223E60F4001F8420 /* base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = base.cpp; path = SourceX/dvlnet/base.cpp; sourceTree = ""; }; - 43398757223E60F4001F8420 /* storm_net.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = storm_net.cpp; path = SourceX/storm_net.cpp; sourceTree = ""; }; - 43398758223E60F4001F8420 /* diabloui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = diabloui.cpp; path = SourceX/DiabloUI/diabloui.cpp; sourceTree = ""; }; - 43398759223E60F4001F8420 /* mainmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mainmenu.cpp; path = SourceX/DiabloUI/mainmenu.cpp; sourceTree = ""; }; - 4339875A223E60F4001F8420 /* progress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = progress.cpp; path = SourceX/DiabloUI/progress.cpp; sourceTree = ""; }; - 4339875B223E60F4001F8420 /* selconn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selconn.cpp; path = SourceX/DiabloUI/selconn.cpp; sourceTree = ""; }; - 4339875C223E60F4001F8420 /* packet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = packet.cpp; path = SourceX/dvlnet/packet.cpp; sourceTree = ""; }; - 4339875D223E60F5001F8420 /* sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sound.cpp; path = SourceX/sound.cpp; sourceTree = ""; }; - 4339875E223E60F5001F8420 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = SourceX/main.cpp; sourceTree = ""; }; - 4339875F223E60F5001F8420 /* storm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = storm.cpp; path = SourceX/storm.cpp; sourceTree = ""; }; - 43398760223E60F5001F8420 /* abstract_net.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = abstract_net.cpp; path = SourceX/dvlnet/abstract_net.cpp; sourceTree = ""; }; - 43398761223E60F5001F8420 /* frame_queue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = frame_queue.cpp; path = SourceX/dvlnet/frame_queue.cpp; sourceTree = ""; }; - 43398762223E60F6001F8420 /* misc_msg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc_msg.cpp; path = SourceX/miniwin/misc_msg.cpp; sourceTree = ""; }; - 43398763223E60F6001F8420 /* misc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc.cpp; path = SourceX/miniwin/misc.cpp; sourceTree = ""; }; - 43398764223E60F6001F8420 /* thread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = thread.cpp; path = SourceX/miniwin/thread.cpp; sourceTree = ""; }; - 43398765223E60F6001F8420 /* title.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = title.cpp; path = SourceX/DiabloUI/title.cpp; sourceTree = ""; }; - 43398766223E60F6001F8420 /* dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dx.cpp; path = SourceX/dx.cpp; sourceTree = ""; }; - 43398767223E60F7001F8420 /* tcp_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tcp_client.cpp; path = SourceX/dvlnet/tcp_client.cpp; sourceTree = ""; }; - 43398768223E60F7001F8420 /* rand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rand.cpp; path = SourceX/miniwin/rand.cpp; sourceTree = ""; }; - 43398769223E60F7001F8420 /* misc_io.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc_io.cpp; path = SourceX/miniwin/misc_io.cpp; sourceTree = ""; }; - 4339876A223E60F7001F8420 /* selgame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selgame.cpp; path = SourceX/DiabloUI/selgame.cpp; sourceTree = ""; }; - 4339876B223E60F7001F8420 /* tcp_server.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tcp_server.cpp; path = SourceX/dvlnet/tcp_server.cpp; sourceTree = ""; }; - 4339876C223E60F8001F8420 /* loopback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loopback.cpp; path = SourceX/dvlnet/loopback.cpp; sourceTree = ""; }; - 4339876D223E60F8001F8420 /* selhero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selhero.cpp; path = SourceX/DiabloUI/selhero.cpp; sourceTree = ""; }; - 4339876E223E60F8001F8420 /* credits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = credits.cpp; path = SourceX/DiabloUI/credits.cpp; sourceTree = ""; }; - 4339876F223E60F8001F8420 /* dialogs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dialogs.cpp; path = SourceX/DiabloUI/dialogs.cpp; sourceTree = ""; }; 436280B22236351000C911AD /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; 436280B42236352000C911AD /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = System/Library/Frameworks/AudioUnit.framework; sourceTree = SDKROOT; }; 436280B62236354100C911AD /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; @@ -278,63 +228,117 @@ 4362B51B223E2B8600633F20 /* SBaseCommon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBaseCommon.cpp; path = 3rdParty/StormLib/src/SBaseCommon.cpp; sourceTree = ""; }; 4362B51C223E2B8600633F20 /* SFileExtractFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SFileExtractFile.cpp; path = 3rdParty/StormLib/src/SFileExtractFile.cpp; sourceTree = ""; }; 4362B51D223E2B8600633F20 /* FileStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileStream.cpp; path = 3rdParty/StormLib/src/FileStream.cpp; sourceTree = ""; }; + 43B6C70A22406866007313EA /* error.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = error.cpp; path = Source/error.cpp; sourceTree = ""; }; + 43B6C70B22406866007313EA /* gmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gmenu.cpp; path = Source/gmenu.cpp; sourceTree = ""; }; + 43B6C70C22406866007313EA /* init.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = init.cpp; path = Source/init.cpp; sourceTree = ""; }; + 43B6C70D22406867007313EA /* help.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = help.cpp; path = Source/help.cpp; sourceTree = ""; }; + 43B6C70E22406867007313EA /* cursor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cursor.cpp; path = Source/cursor.cpp; sourceTree = ""; }; + 43B6C70F22406867007313EA /* player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = player.cpp; path = Source/player.cpp; sourceTree = ""; }; + 43B6C71022406867007313EA /* items.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = items.cpp; path = Source/items.cpp; sourceTree = ""; }; + 43B6C71122406867007313EA /* stores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stores.cpp; path = Source/stores.cpp; sourceTree = ""; }; + 43B6C71222406867007313EA /* drlg_l1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = drlg_l1.cpp; path = Source/drlg_l1.cpp; sourceTree = ""; }; + 43B6C71322406868007313EA /* drlg_l3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = drlg_l3.cpp; path = Source/drlg_l3.cpp; sourceTree = ""; }; + 43B6C71422406868007313EA /* interfac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = interfac.cpp; path = Source/interfac.cpp; sourceTree = ""; }; + 43B6C71522406868007313EA /* dead.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dead.cpp; path = Source/dead.cpp; sourceTree = ""; }; + 43B6C71622406868007313EA /* missiles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = missiles.cpp; path = Source/missiles.cpp; sourceTree = ""; }; + 43B6C71722406868007313EA /* msg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = msg.cpp; path = Source/msg.cpp; sourceTree = ""; }; + 43B6C71822406868007313EA /* spells.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = spells.cpp; path = Source/spells.cpp; sourceTree = ""; }; + 43B6C71922406869007313EA /* portal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = portal.cpp; path = Source/portal.cpp; sourceTree = ""; }; + 43B6C71A22406869007313EA /* track.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = track.cpp; path = Source/track.cpp; sourceTree = ""; }; + 43B6C71B22406869007313EA /* tmsg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tmsg.cpp; path = Source/tmsg.cpp; sourceTree = ""; }; + 43B6C71C22406869007313EA /* gendung.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gendung.cpp; path = Source/gendung.cpp; sourceTree = ""; }; + 43B6C71D22406869007313EA /* debug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = debug.cpp; path = Source/debug.cpp; sourceTree = ""; }; + 43B6C71E22406869007313EA /* multi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = multi.cpp; path = Source/multi.cpp; sourceTree = ""; }; + 43B6C71F2240686A007313EA /* control.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = control.cpp; path = Source/control.cpp; sourceTree = ""; }; + 43B6C7202240686A007313EA /* fault.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fault.cpp; path = Source/fault.cpp; sourceTree = ""; }; + 43B6C7212240686A007313EA /* automap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = automap.cpp; path = Source/automap.cpp; sourceTree = ""; }; + 43B6C7222240686A007313EA /* logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = logging.cpp; path = Source/logging.cpp; sourceTree = ""; }; + 43B6C7232240686A007313EA /* plrmsg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = plrmsg.cpp; path = Source/plrmsg.cpp; sourceTree = ""; }; + 43B6C7242240686B007313EA /* minitext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = minitext.cpp; path = Source/minitext.cpp; sourceTree = ""; }; + 43B6C7252240686B007313EA /* doom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = doom.cpp; path = Source/doom.cpp; sourceTree = ""; }; + 43B6C7262240686C007313EA /* textdat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textdat.cpp; path = Source/textdat.cpp; sourceTree = ""; }; + 43B6C7272240686C007313EA /* sha.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sha.cpp; path = Source/sha.cpp; sourceTree = ""; }; + 43B6C7282240686C007313EA /* sync.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sync.cpp; path = Source/sync.cpp; sourceTree = ""; }; + 43B6C7292240686D007313EA /* themes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = themes.cpp; path = Source/themes.cpp; sourceTree = ""; }; + 43B6C72A2240686D007313EA /* movie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = movie.cpp; path = Source/movie.cpp; sourceTree = ""; }; + 43B6C72B2240686D007313EA /* appfat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = appfat.cpp; path = Source/appfat.cpp; sourceTree = ""; }; + 43B6C72C2240686E007313EA /* objects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = objects.cpp; path = Source/objects.cpp; sourceTree = ""; }; + 43B6C72D2240686E007313EA /* mpqapi.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mpqapi.cpp; path = Source/mpqapi.cpp; sourceTree = ""; }; + 43B6C72E2240686E007313EA /* gamemenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = gamemenu.cpp; path = Source/gamemenu.cpp; sourceTree = ""; }; + 43B6C72F2240686F007313EA /* loadsave.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loadsave.cpp; path = Source/loadsave.cpp; sourceTree = ""; }; + 43B6C7302240686F007313EA /* mainmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mainmenu.cpp; path = Source/mainmenu.cpp; sourceTree = ""; }; + 43B6C7312240686F007313EA /* capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = capture.cpp; path = Source/capture.cpp; sourceTree = ""; }; + 43B6C7322240686F007313EA /* path.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = path.cpp; path = Source/path.cpp; sourceTree = ""; }; + 43B6C73322406870007313EA /* palette.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = palette.cpp; path = Source/palette.cpp; sourceTree = ""; }; + 43B6C73422406870007313EA /* nthread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nthread.cpp; path = Source/nthread.cpp; sourceTree = ""; }; + 43B6C73522406870007313EA /* engine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = engine.cpp; path = Source/engine.cpp; sourceTree = ""; }; + 43B6C73622406870007313EA /* render.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = render.cpp; path = Source/render.cpp; sourceTree = ""; }; + 43B6C73722406871007313EA /* drlg_l2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = drlg_l2.cpp; path = Source/drlg_l2.cpp; sourceTree = ""; }; + 43B6C73822406871007313EA /* drlg_l4.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = drlg_l4.cpp; path = Source/drlg_l4.cpp; sourceTree = ""; }; + 43B6C73922406871007313EA /* pfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pfile.cpp; path = Source/pfile.cpp; sourceTree = ""; }; + 43B6C73A22406872007313EA /* wave.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = wave.cpp; path = Source/wave.cpp; sourceTree = ""; }; + 43B6C73B22406872007313EA /* effects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = effects.cpp; path = Source/effects.cpp; sourceTree = ""; }; + 43B6C73C22406872007313EA /* inv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = inv.cpp; path = Source/inv.cpp; sourceTree = ""; }; + 43B6C73D22406872007313EA /* restrict.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = restrict.cpp; path = Source/restrict.cpp; sourceTree = ""; }; + 43B6C73E22406872007313EA /* dthread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dthread.cpp; path = Source/dthread.cpp; sourceTree = ""; }; + 43B6C73F22406873007313EA /* diablo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = diablo.cpp; path = Source/diablo.cpp; sourceTree = ""; }; + 43B6C74022406873007313EA /* encrypt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = encrypt.cpp; path = Source/encrypt.cpp; sourceTree = ""; }; + 43B6C74122406873007313EA /* pack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pack.cpp; path = Source/pack.cpp; sourceTree = ""; }; + 43B6C74222406873007313EA /* quests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = quests.cpp; path = Source/quests.cpp; sourceTree = ""; }; + 43B6C74322406874007313EA /* setmaps.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = setmaps.cpp; path = Source/setmaps.cpp; sourceTree = ""; }; + 43B6C74422406874007313EA /* town.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = town.cpp; path = Source/town.cpp; sourceTree = ""; }; + 43B6C74522406874007313EA /* trigs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = trigs.cpp; path = Source/trigs.cpp; sourceTree = ""; }; + 43B6C74622406874007313EA /* codec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = codec.cpp; path = Source/codec.cpp; sourceTree = ""; }; + 43B6C74722406875007313EA /* lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = lighting.cpp; path = Source/lighting.cpp; sourceTree = ""; }; + 43B6C74822406875007313EA /* monster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = monster.cpp; path = Source/monster.cpp; sourceTree = ""; }; + 43B6C74922406875007313EA /* msgcmd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = msgcmd.cpp; path = Source/msgcmd.cpp; sourceTree = ""; }; + 43B6C74A22406875007313EA /* towners.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = towners.cpp; path = Source/towners.cpp; sourceTree = ""; }; + 43B6C74B22406875007313EA /* scrollrt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = scrollrt.cpp; path = Source/scrollrt.cpp; sourceTree = ""; }; + 43B6C78E22406888007313EA /* udp_p2p.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = udp_p2p.cpp; path = SourceX/dvlnet/udp_p2p.cpp; sourceTree = ""; }; + 43B6C78F22406888007313EA /* misc_dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc_dx.cpp; path = SourceX/miniwin/misc_dx.cpp; sourceTree = ""; }; + 43B6C79022406888007313EA /* base.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = base.cpp; path = SourceX/dvlnet/base.cpp; sourceTree = ""; }; + 43B6C79122406889007313EA /* diabloui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = diabloui.cpp; path = SourceX/DiabloUI/diabloui.cpp; sourceTree = ""; }; + 43B6C79222406889007313EA /* mainmenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mainmenu.cpp; path = SourceX/DiabloUI/mainmenu.cpp; sourceTree = ""; }; + 43B6C79322406889007313EA /* progress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = progress.cpp; path = SourceX/DiabloUI/progress.cpp; sourceTree = ""; }; + 43B6C79422406889007313EA /* selconn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selconn.cpp; path = SourceX/DiabloUI/selconn.cpp; sourceTree = ""; }; + 43B6C79522406889007313EA /* packet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = packet.cpp; path = SourceX/dvlnet/packet.cpp; sourceTree = ""; }; + 43B6C79622406889007313EA /* storm_net.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = storm_net.cpp; path = SourceX/storm/storm_net.cpp; sourceTree = ""; }; + 43B6C79722406889007313EA /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = SourceX/main.cpp; sourceTree = ""; }; + 43B6C7982240688A007313EA /* dsound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dsound.cpp; path = SourceX/miniwin/dsound.cpp; sourceTree = ""; }; + 43B6C7992240688A007313EA /* abstract_net.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = abstract_net.cpp; path = SourceX/dvlnet/abstract_net.cpp; sourceTree = ""; }; + 43B6C79A2240688A007313EA /* frame_queue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = frame_queue.cpp; path = SourceX/dvlnet/frame_queue.cpp; sourceTree = ""; }; + 43B6C79B2240688A007313EA /* misc_msg.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc_msg.cpp; path = SourceX/miniwin/misc_msg.cpp; sourceTree = ""; }; + 43B6C79C2240688A007313EA /* misc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc.cpp; path = SourceX/miniwin/misc.cpp; sourceTree = ""; }; + 43B6C79D2240688A007313EA /* sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sound.cpp; path = SourceX/sound.cpp; sourceTree = ""; }; + 43B6C79E2240688A007313EA /* thread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = thread.cpp; path = SourceX/miniwin/thread.cpp; sourceTree = ""; }; + 43B6C79F2240688B007313EA /* title.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = title.cpp; path = SourceX/DiabloUI/title.cpp; sourceTree = ""; }; + 43B6C7A02240688B007313EA /* dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dx.cpp; path = SourceX/dx.cpp; sourceTree = ""; }; + 43B6C7A12240688B007313EA /* tcp_client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tcp_client.cpp; path = SourceX/dvlnet/tcp_client.cpp; sourceTree = ""; }; + 43B6C7A22240688B007313EA /* rand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = rand.cpp; path = SourceX/miniwin/rand.cpp; sourceTree = ""; }; + 43B6C7A32240688B007313EA /* misc_io.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = misc_io.cpp; path = SourceX/miniwin/misc_io.cpp; sourceTree = ""; }; + 43B6C7A42240688B007313EA /* selgame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selgame.cpp; path = SourceX/DiabloUI/selgame.cpp; sourceTree = ""; }; + 43B6C7A52240688C007313EA /* tcp_server.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tcp_server.cpp; path = SourceX/dvlnet/tcp_server.cpp; sourceTree = ""; }; + 43B6C7A62240688C007313EA /* loopback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = loopback.cpp; path = SourceX/dvlnet/loopback.cpp; sourceTree = ""; }; + 43B6C7A72240688C007313EA /* selhero.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = selhero.cpp; path = SourceX/DiabloUI/selhero.cpp; sourceTree = ""; }; + 43B6C7A82240688C007313EA /* storm_dx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = storm_dx.cpp; path = SourceX/storm/storm_dx.cpp; sourceTree = ""; }; + 43B6C7A92240688C007313EA /* credits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = credits.cpp; path = SourceX/DiabloUI/credits.cpp; sourceTree = ""; }; + 43B6C7AA2240688D007313EA /* dialogs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = dialogs.cpp; path = SourceX/DiabloUI/dialogs.cpp; sourceTree = ""; }; + 43B6C7AB2240688D007313EA /* storm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = storm.cpp; path = SourceX/storm/storm.cpp; sourceTree = ""; }; 43BA39AF22375925009041FF /* AppIcon.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = AppIcon.xcassets; path = Xcode/AppIcon.xcassets; sourceTree = SOURCE_ROOT; }; 43BF58B52235DEB8001F9748 /* devilutionX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = devilutionX.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 4741C7B8659C4E1C826A129C /* sha.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = sha.cpp; path = Source/sha.cpp; sourceTree = SOURCE_ROOT; }; - 47D57E7305264ED7951AF3B1 /* towners.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = towners.cpp; path = Source/towners.cpp; sourceTree = SOURCE_ROOT; }; - 4A86F8316B224BF3BA817854 /* pfile.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = pfile.cpp; path = Source/pfile.cpp; sourceTree = SOURCE_ROOT; }; 500C9F6E13FE44BFAEFCB81B /* smk_hufftree.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; name = smk_hufftree.c; path = 3rdParty/libsmacker/smk_hufftree.c; sourceTree = SOURCE_ROOT; }; - 5876CCE0133A4D6EADDF0AAE /* restrict.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = restrict.cpp; path = Source/restrict.cpp; sourceTree = SOURCE_ROOT; }; - 5A898CD619824F19ABC9E484 /* render.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = render.cpp; path = Source/render.cpp; sourceTree = SOURCE_ROOT; }; - 5F3FB00DF08741CDA799AB93 /* multi.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = multi.cpp; path = Source/multi.cpp; sourceTree = SOURCE_ROOT; }; - 60A06F7D04B1447FAE6F13C9 /* trigs.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = trigs.cpp; path = Source/trigs.cpp; sourceTree = SOURCE_ROOT; }; 622A8C6A02D94FFC996C2CAE /* smacker.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; name = smacker.c; path = 3rdParty/libsmacker/smacker.c; sourceTree = SOURCE_ROOT; }; 646292CBB776434AA4CA1C94 /* libPKWare.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libPKWare.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 6687A60F94C648A2B5E20FB7 /* drlg_l1.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = drlg_l1.cpp; path = Source/drlg_l1.cpp; sourceTree = SOURCE_ROOT; }; 670494A24D7F4CFFACCD3BFB /* smk_bitstream.c */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.c; fileEncoding = 4; name = smk_bitstream.c; path = 3rdParty/libsmacker/smk_bitstream.c; sourceTree = SOURCE_ROOT; }; - 68977FC478CB4E6CA54A3E38 /* logging.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = logging.cpp; path = Source/logging.cpp; sourceTree = SOURCE_ROOT; }; - 6BDC3D1BA3B64866B84CEB3C /* init.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = init.cpp; path = Source/init.cpp; sourceTree = SOURCE_ROOT; }; 6D7FE30F050049FB933D2788 /* explode.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = explode.cpp; path = 3rdParty/PKWare/explode.cpp; sourceTree = SOURCE_ROOT; }; 6F074DDFE42C4B46A93CC4A9 /* Section.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = Section.cpp; path = 3rdParty/Radon/Radon/source/Section.cpp; sourceTree = SOURCE_ROOT; }; - 7119751C6B7A4F40BB3B87B0 /* doom.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = doom.cpp; path = Source/doom.cpp; sourceTree = SOURCE_ROOT; }; 722EB8D86DBF49368AAFEE3C /* File.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = File.cpp; path = 3rdParty/Radon/Radon/source/File.cpp; sourceTree = SOURCE_ROOT; }; - 737FBDFA9A4A4B628BB2235B /* mainmenu.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = mainmenu.cpp; path = Source/mainmenu.cpp; sourceTree = SOURCE_ROOT; }; - 7385F58EEFA44AF88C4D8798 /* scrollrt.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = scrollrt.cpp; path = Source/scrollrt.cpp; sourceTree = SOURCE_ROOT; }; - 8445BFAA306D42FE886F0ACC /* interfac.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = interfac.cpp; path = Source/interfac.cpp; sourceTree = SOURCE_ROOT; }; - 84BAB44B72164700A0A8B4D6 /* spells.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = spells.cpp; path = Source/spells.cpp; sourceTree = SOURCE_ROOT; }; - 8E47C81C5BD940C2A5A1704D /* engine.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = engine.cpp; path = Source/engine.cpp; sourceTree = SOURCE_ROOT; }; 92E1DAF5C7BA48E5A1E39C04 /* libRadon.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libRadon.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 966BF9CEF1B6419CA25FC162 /* mpqapi.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = mpqapi.cpp; path = Source/mpqapi.cpp; sourceTree = SOURCE_ROOT; }; - 98AB581710214A55AD84E8D0 /* themes.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = themes.cpp; path = Source/themes.cpp; sourceTree = SOURCE_ROOT; }; - 9C2AEA532E6F4FF8B66083C9 /* fault.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = fault.cpp; path = Source/fault.cpp; sourceTree = SOURCE_ROOT; }; - A1E1B1230CFD4B8587F7EC80 /* drlg_l3.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = drlg_l3.cpp; path = Source/drlg_l3.cpp; sourceTree = SOURCE_ROOT; }; - A28321B6858D4AB5A53D7408 /* effects.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = effects.cpp; path = Source/effects.cpp; sourceTree = SOURCE_ROOT; }; - A711EC4A01C74302BF18E4C3 /* path.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = path.cpp; path = Source/path.cpp; sourceTree = SOURCE_ROOT; }; B1B2D29A5A284CD29205745F /* implode.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = implode.cpp; path = 3rdParty/PKWare/implode.cpp; sourceTree = SOURCE_ROOT; }; B229DB87369B4D76B0A60580 /* Named.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = Named.cpp; path = 3rdParty/Radon/Radon/source/Named.cpp; sourceTree = SOURCE_ROOT; }; - BA2A3A52015F4859A4C5A6A2 /* plrmsg.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = plrmsg.cpp; path = Source/plrmsg.cpp; sourceTree = SOURCE_ROOT; }; - BF78F60283044A13A4CE1D1B /* items.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = items.cpp; path = Source/items.cpp; sourceTree = SOURCE_ROOT; }; C0B8A000CA684B9FAF88F313 /* Key.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = Key.cpp; path = 3rdParty/Radon/Radon/source/Key.cpp; sourceTree = SOURCE_ROOT; }; C43B4AA3223F0DCA00CE0DD9 /* libclang_rt.asan_osx_dynamic.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libclang_rt.asan_osx_dynamic.dylib; path = 3rdParty/darwin/libclang_rt.asan_osx_dynamic.dylib; sourceTree = ""; }; - C713AED00778486B94CD282B /* objects.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = objects.cpp; path = Source/objects.cpp; sourceTree = SOURCE_ROOT; }; - C78DC63816DF4F1C867578C7 /* setmaps.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = setmaps.cpp; path = Source/setmaps.cpp; sourceTree = SOURCE_ROOT; }; - CA4B6FC7C063411F9460CD20 /* codec.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = codec.cpp; path = Source/codec.cpp; sourceTree = SOURCE_ROOT; }; - CF6C9F651C014C538ECFCC09 /* inv.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = inv.cpp; path = Source/inv.cpp; sourceTree = SOURCE_ROOT; }; - D58130817DEA419984D28AB3 /* lighting.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = lighting.cpp; path = Source/lighting.cpp; sourceTree = SOURCE_ROOT; }; - D86188B68E494666A2972128 /* automap.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = automap.cpp; path = Source/automap.cpp; sourceTree = SOURCE_ROOT; }; - D961B8EC59154E98955AE2E7 /* dthread.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = dthread.cpp; path = Source/dthread.cpp; sourceTree = SOURCE_ROOT; }; - DAAD0527F1EA496A8B669415 /* town.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = town.cpp; path = Source/town.cpp; sourceTree = SOURCE_ROOT; }; - DB292068EC0C4CDD8E7A57CF /* minitext.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = minitext.cpp; path = Source/minitext.cpp; sourceTree = SOURCE_ROOT; }; DCC453E263C842279A5E02E7 /* libsmacker.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libsmacker.a; sourceTree = BUILT_PRODUCTS_DIR; }; - DDD7341C6712447191FD2C4B /* missiles.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = missiles.cpp; path = Source/missiles.cpp; sourceTree = SOURCE_ROOT; }; - E421A97655174F4099852AD2 /* gendung.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = gendung.cpp; path = Source/gendung.cpp; sourceTree = SOURCE_ROOT; }; - E54D4F37A0B24C6B83CE5D22 /* monster.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = monster.cpp; path = Source/monster.cpp; sourceTree = SOURCE_ROOT; }; - E7B0ACCABE284B3888DF09D5 /* movie.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = movie.cpp; path = Source/movie.cpp; sourceTree = SOURCE_ROOT; }; - E812A68DE4194125A3A7A351 /* cursor.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = cursor.cpp; path = Source/cursor.cpp; sourceTree = SOURCE_ROOT; }; - EAC7C674E0104BA4A4B0FEA3 /* msgcmd.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = msgcmd.cpp; path = Source/msgcmd.cpp; sourceTree = SOURCE_ROOT; }; - EBB67C79EEBA48D1B5D8D70B /* help.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = help.cpp; path = Source/help.cpp; sourceTree = SOURCE_ROOT; }; - EDDB82E7195E4EF69A42C0D5 /* appfat.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = appfat.cpp; path = Source/appfat.cpp; sourceTree = SOURCE_ROOT; }; - F0FEC1BE8E6049D593406F4D /* loadsave.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = loadsave.cpp; path = Source/loadsave.cpp; sourceTree = SOURCE_ROOT; }; F249E02C422E4EC2B812E004 /* libStormLib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libStormLib.a; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -444,72 +448,72 @@ 7F95B2EF6FB44A038C321DA7 /* Source Files */ = { isa = PBXGroup; children = ( - EDDB82E7195E4EF69A42C0D5 /* appfat.cpp */, - D86188B68E494666A2972128 /* automap.cpp */, - 3B7366F811604AE1B00C8C9A /* capture.cpp */, - CA4B6FC7C063411F9460CD20 /* codec.cpp */, - 2D7327A50AC445CE94B2B4C9 /* control.cpp */, - E812A68DE4194125A3A7A351 /* cursor.cpp */, - 16C6AB08C75D4A1E993FE50B /* dead.cpp */, - 1A4D49F7AAB1448BB3796750 /* debug.cpp */, - 0EF63E8BD67C4954A26480D5 /* diablo.cpp */, - 7119751C6B7A4F40BB3B87B0 /* doom.cpp */, - 6687A60F94C648A2B5E20FB7 /* drlg_l1.cpp */, - 219EFD2B33014357A3B26650 /* drlg_l2.cpp */, - A1E1B1230CFD4B8587F7EC80 /* drlg_l3.cpp */, - 183703645CB04A19AD9E5025 /* drlg_l4.cpp */, - D961B8EC59154E98955AE2E7 /* dthread.cpp */, - A28321B6858D4AB5A53D7408 /* effects.cpp */, - 1F6D083DFE8F4912AD21323E /* encrypt.cpp */, - 8E47C81C5BD940C2A5A1704D /* engine.cpp */, - 413186B26DE644E197D49314 /* error.cpp */, - 9C2AEA532E6F4FF8B66083C9 /* fault.cpp */, - 1FBCC5BCDC3842F58CF572AB /* gamemenu.cpp */, - E421A97655174F4099852AD2 /* gendung.cpp */, - 3CC4A34B55AA4827B345A6A0 /* gmenu.cpp */, - EBB67C79EEBA48D1B5D8D70B /* help.cpp */, - 6BDC3D1BA3B64866B84CEB3C /* init.cpp */, - 8445BFAA306D42FE886F0ACC /* interfac.cpp */, - CF6C9F651C014C538ECFCC09 /* inv.cpp */, - BF78F60283044A13A4CE1D1B /* items.cpp */, - D58130817DEA419984D28AB3 /* lighting.cpp */, - F0FEC1BE8E6049D593406F4D /* loadsave.cpp */, - 68977FC478CB4E6CA54A3E38 /* logging.cpp */, - 737FBDFA9A4A4B628BB2235B /* mainmenu.cpp */, - DB292068EC0C4CDD8E7A57CF /* minitext.cpp */, - DDD7341C6712447191FD2C4B /* missiles.cpp */, - E54D4F37A0B24C6B83CE5D22 /* monster.cpp */, - E7B0ACCABE284B3888DF09D5 /* movie.cpp */, - 966BF9CEF1B6419CA25FC162 /* mpqapi.cpp */, - 4040598A1C254715A8C8673C /* msg.cpp */, - EAC7C674E0104BA4A4B0FEA3 /* msgcmd.cpp */, - 5F3FB00DF08741CDA799AB93 /* multi.cpp */, - 203ED4AA4231415BA1B02BAE /* nthread.cpp */, - C713AED00778486B94CD282B /* objects.cpp */, - 31E66A5457E64947AA68C7F7 /* pack.cpp */, - 32E0A65ED0904E12BE84988B /* palette.cpp */, - A711EC4A01C74302BF18E4C3 /* path.cpp */, - 4A86F8316B224BF3BA817854 /* pfile.cpp */, - 1B3EB5883E0C42D3A0F3D4D5 /* player.cpp */, - BA2A3A52015F4859A4C5A6A2 /* plrmsg.cpp */, - 2017B5200DF14FD7B6959133 /* portal.cpp */, - 0348AAD50CEF4915900FD581 /* quests.cpp */, - 5A898CD619824F19ABC9E484 /* render.cpp */, - 5876CCE0133A4D6EADDF0AAE /* restrict.cpp */, - 7385F58EEFA44AF88C4D8798 /* scrollrt.cpp */, - C78DC63816DF4F1C867578C7 /* setmaps.cpp */, - 4741C7B8659C4E1C826A129C /* sha.cpp */, - 84BAB44B72164700A0A8B4D6 /* spells.cpp */, - 3D28A84812B34E10AE50E192 /* stores.cpp */, - 3D09D9AFCBB94D86BD283257 /* sync.cpp */, - 3CC0017809BF45FD9BCC06CA /* textdat.cpp */, - 98AB581710214A55AD84E8D0 /* themes.cpp */, - 3216A3E0351743AE8FFCF891 /* tmsg.cpp */, - DAAD0527F1EA496A8B669415 /* town.cpp */, - 47D57E7305264ED7951AF3B1 /* towners.cpp */, - 2C87FF47C667465E868B191E /* track.cpp */, - 60A06F7D04B1447FAE6F13C9 /* trigs.cpp */, - 373F9A9104DF4176A291FC8B /* wave.cpp */, + 43B6C72B2240686D007313EA /* appfat.cpp */, + 43B6C7212240686A007313EA /* automap.cpp */, + 43B6C7312240686F007313EA /* capture.cpp */, + 43B6C74622406874007313EA /* codec.cpp */, + 43B6C71F2240686A007313EA /* control.cpp */, + 43B6C70E22406867007313EA /* cursor.cpp */, + 43B6C71522406868007313EA /* dead.cpp */, + 43B6C71D22406869007313EA /* debug.cpp */, + 43B6C73F22406873007313EA /* diablo.cpp */, + 43B6C7252240686B007313EA /* doom.cpp */, + 43B6C71222406867007313EA /* drlg_l1.cpp */, + 43B6C73722406871007313EA /* drlg_l2.cpp */, + 43B6C71322406868007313EA /* drlg_l3.cpp */, + 43B6C73822406871007313EA /* drlg_l4.cpp */, + 43B6C73E22406872007313EA /* dthread.cpp */, + 43B6C73B22406872007313EA /* effects.cpp */, + 43B6C74022406873007313EA /* encrypt.cpp */, + 43B6C73522406870007313EA /* engine.cpp */, + 43B6C70A22406866007313EA /* error.cpp */, + 43B6C7202240686A007313EA /* fault.cpp */, + 43B6C72E2240686E007313EA /* gamemenu.cpp */, + 43B6C71C22406869007313EA /* gendung.cpp */, + 43B6C70B22406866007313EA /* gmenu.cpp */, + 43B6C70D22406867007313EA /* help.cpp */, + 43B6C70C22406866007313EA /* init.cpp */, + 43B6C71422406868007313EA /* interfac.cpp */, + 43B6C73C22406872007313EA /* inv.cpp */, + 43B6C71022406867007313EA /* items.cpp */, + 43B6C74722406875007313EA /* lighting.cpp */, + 43B6C72F2240686F007313EA /* loadsave.cpp */, + 43B6C7222240686A007313EA /* logging.cpp */, + 43B6C7302240686F007313EA /* mainmenu.cpp */, + 43B6C7242240686B007313EA /* minitext.cpp */, + 43B6C71622406868007313EA /* missiles.cpp */, + 43B6C74822406875007313EA /* monster.cpp */, + 43B6C72A2240686D007313EA /* movie.cpp */, + 43B6C72D2240686E007313EA /* mpqapi.cpp */, + 43B6C71722406868007313EA /* msg.cpp */, + 43B6C74922406875007313EA /* msgcmd.cpp */, + 43B6C71E22406869007313EA /* multi.cpp */, + 43B6C73422406870007313EA /* nthread.cpp */, + 43B6C72C2240686E007313EA /* objects.cpp */, + 43B6C74122406873007313EA /* pack.cpp */, + 43B6C73322406870007313EA /* palette.cpp */, + 43B6C7322240686F007313EA /* path.cpp */, + 43B6C73922406871007313EA /* pfile.cpp */, + 43B6C70F22406867007313EA /* player.cpp */, + 43B6C7232240686A007313EA /* plrmsg.cpp */, + 43B6C71922406869007313EA /* portal.cpp */, + 43B6C74222406873007313EA /* quests.cpp */, + 43B6C73622406870007313EA /* render.cpp */, + 43B6C73D22406872007313EA /* restrict.cpp */, + 43B6C74B22406875007313EA /* scrollrt.cpp */, + 43B6C74322406874007313EA /* setmaps.cpp */, + 43B6C7272240686C007313EA /* sha.cpp */, + 43B6C71822406868007313EA /* spells.cpp */, + 43B6C71122406867007313EA /* stores.cpp */, + 43B6C7282240686C007313EA /* sync.cpp */, + 43B6C7262240686C007313EA /* textdat.cpp */, + 43B6C7292240686D007313EA /* themes.cpp */, + 43B6C71B22406869007313EA /* tmsg.cpp */, + 43B6C74422406874007313EA /* town.cpp */, + 43B6C74A22406875007313EA /* towners.cpp */, + 43B6C71A22406869007313EA /* track.cpp */, + 43B6C74522406874007313EA /* trigs.cpp */, + 43B6C73A22406872007313EA /* wave.cpp */, ); name = "Source Files"; sourceTree = ""; @@ -558,34 +562,36 @@ E1EABD1AC2D8479DB77DBAE9 /* Source Files */ = { isa = PBXGroup; children = ( - 43398760223E60F5001F8420 /* abstract_net.cpp */, - 43398756223E60F4001F8420 /* base.cpp */, - 4339876E223E60F8001F8420 /* credits.cpp */, - 43398758223E60F4001F8420 /* diabloui.cpp */, - 4339876F223E60F8001F8420 /* dialogs.cpp */, - 43398766223E60F6001F8420 /* dx.cpp */, - 43398761223E60F5001F8420 /* frame_queue.cpp */, - 4339876C223E60F8001F8420 /* loopback.cpp */, - 4339875E223E60F5001F8420 /* main.cpp */, - 43398759223E60F4001F8420 /* mainmenu.cpp */, - 43398754223E60F3001F8420 /* miniwin_dsound.cpp */, - 43398769223E60F7001F8420 /* misc_io.cpp */, - 43398762223E60F6001F8420 /* misc_msg.cpp */, - 43398763223E60F6001F8420 /* misc.cpp */, - 4339875C223E60F4001F8420 /* packet.cpp */, - 4339875A223E60F4001F8420 /* progress.cpp */, - 43398768223E60F7001F8420 /* rand.cpp */, - 4339875B223E60F4001F8420 /* selconn.cpp */, - 4339876A223E60F7001F8420 /* selgame.cpp */, - 4339876D223E60F8001F8420 /* selhero.cpp */, - 4339875D223E60F5001F8420 /* sound.cpp */, - 43398757223E60F4001F8420 /* storm_net.cpp */, - 4339875F223E60F5001F8420 /* storm.cpp */, - 43398767223E60F7001F8420 /* tcp_client.cpp */, - 4339876B223E60F7001F8420 /* tcp_server.cpp */, - 43398764223E60F6001F8420 /* thread.cpp */, - 43398765223E60F6001F8420 /* title.cpp */, - 43398755223E60F3001F8420 /* udp_p2p.cpp */, + 43B6C7992240688A007313EA /* abstract_net.cpp */, + 43B6C79022406888007313EA /* base.cpp */, + 43B6C7A92240688C007313EA /* credits.cpp */, + 43B6C79122406889007313EA /* diabloui.cpp */, + 43B6C7AA2240688D007313EA /* dialogs.cpp */, + 43B6C7982240688A007313EA /* dsound.cpp */, + 43B6C7A02240688B007313EA /* dx.cpp */, + 43B6C79A2240688A007313EA /* frame_queue.cpp */, + 43B6C7A62240688C007313EA /* loopback.cpp */, + 43B6C79722406889007313EA /* main.cpp */, + 43B6C79222406889007313EA /* mainmenu.cpp */, + 43B6C78F22406888007313EA /* misc_dx.cpp */, + 43B6C7A32240688B007313EA /* misc_io.cpp */, + 43B6C79B2240688A007313EA /* misc_msg.cpp */, + 43B6C79C2240688A007313EA /* misc.cpp */, + 43B6C79522406889007313EA /* packet.cpp */, + 43B6C79322406889007313EA /* progress.cpp */, + 43B6C7A22240688B007313EA /* rand.cpp */, + 43B6C79422406889007313EA /* selconn.cpp */, + 43B6C7A42240688B007313EA /* selgame.cpp */, + 43B6C7A72240688C007313EA /* selhero.cpp */, + 43B6C79D2240688A007313EA /* sound.cpp */, + 43B6C7A82240688C007313EA /* storm_dx.cpp */, + 43B6C79622406889007313EA /* storm_net.cpp */, + 43B6C7AB2240688D007313EA /* storm.cpp */, + 43B6C7A12240688B007313EA /* tcp_client.cpp */, + 43B6C7A52240688C007313EA /* tcp_server.cpp */, + 43B6C79E2240688A007313EA /* thread.cpp */, + 43B6C79F2240688B007313EA /* title.cpp */, + 43B6C78E22406888007313EA /* udp_p2p.cpp */, ); name = "Source Files"; sourceTree = ""; @@ -765,72 +771,72 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 6186FBD4D4644CA78FEAAA53 /* appfat.cpp in Sources */, - 623ACC26BBBB42978A6386EF /* automap.cpp in Sources */, - 7652232427CA44C1BBBAAFE3 /* capture.cpp in Sources */, - CE3E3D2BD44C407A9BE60A72 /* codec.cpp in Sources */, - BAC5D4D57F364349B3C2F552 /* control.cpp in Sources */, - E777E9F7F0C54ECBA2DE2A2C /* cursor.cpp in Sources */, - B728E60F029A4234B90A9371 /* dead.cpp in Sources */, - 00DABA918E5348F382AF3E16 /* debug.cpp in Sources */, - 75CE86C992F940A4B4D78E5C /* diablo.cpp in Sources */, - CCB1A17083824600A7FC6DBF /* doom.cpp in Sources */, - 503716BF6B434A48ACA1BD86 /* drlg_l1.cpp in Sources */, - 6651D75C83744F8BB9A4EE09 /* drlg_l2.cpp in Sources */, - 2B0FDA186B5D4A348E82BE69 /* drlg_l3.cpp in Sources */, - 75294609B2944CC9BC4A487B /* drlg_l4.cpp in Sources */, - 6240F97CE4014B1DB267D471 /* dthread.cpp in Sources */, - 6669BEC0507C4957BAD30989 /* effects.cpp in Sources */, - 4F27D72CD6A448B196008C10 /* encrypt.cpp in Sources */, - 2363B2BA33664F008CF2266E /* engine.cpp in Sources */, - 2E51C3FD096247BDB522FA63 /* error.cpp in Sources */, - C648EEFB6E17468AB8C3943E /* fault.cpp in Sources */, - 5CE3C7E27B6E4BD9AAA5619D /* gamemenu.cpp in Sources */, - B1D9EA0B0DA04F15BFA456A9 /* gendung.cpp in Sources */, - 1EDB503A982F46D4920BFF3D /* gmenu.cpp in Sources */, - 81595166A06F4A09A80AEFB5 /* help.cpp in Sources */, - B4BBB196D148453BA2BA830E /* init.cpp in Sources */, - 6261395CEAB2412186C5666C /* interfac.cpp in Sources */, - F47E4687B48048D9943833C3 /* inv.cpp in Sources */, - B748B788987B4A9A91DF84B3 /* items.cpp in Sources */, - 50630CDFA3D444DCA5946A1C /* lighting.cpp in Sources */, - 81797D16B64A49F79D53FE9B /* loadsave.cpp in Sources */, - 89C8F76E788A4369AE9CA283 /* logging.cpp in Sources */, - 96A5B8E287BF480CB1733558 /* mainmenu.cpp in Sources */, - FA750FAB5C734384B3E1D709 /* minitext.cpp in Sources */, - 10A37F34E807485A8081A8A6 /* missiles.cpp in Sources */, - E3A3620899BB426EA66636CF /* monster.cpp in Sources */, - A708041A39EB43BB8F68E7D2 /* movie.cpp in Sources */, - FD006417F6AA479E9A2764C5 /* mpqapi.cpp in Sources */, - 773B22BC5C3E41799F769001 /* msg.cpp in Sources */, - AED121172E094DAAB8B1322D /* msgcmd.cpp in Sources */, - B000FB7744A2405CB4A39483 /* multi.cpp in Sources */, - 8774C8F414CF47248652D15A /* nthread.cpp in Sources */, - 17C52FFA55984C5A93007652 /* objects.cpp in Sources */, - 2962434943834AF8839658B8 /* pack.cpp in Sources */, - 7DACE4548EF94D77874E0F31 /* palette.cpp in Sources */, - 5FA14820FB17477383DA0700 /* path.cpp in Sources */, - D1124CA76EC04271B012DDA6 /* pfile.cpp in Sources */, - 2A743A2DEE444E6295400155 /* player.cpp in Sources */, - DA61C597DBC848E39FBE602E /* plrmsg.cpp in Sources */, - 3AA9769F36DA404CB3DB029B /* portal.cpp in Sources */, - BFF16F60B46F4B8984D3007C /* quests.cpp in Sources */, - 7AF599B5937C48CFA2FFDAA4 /* render.cpp in Sources */, - 547166BC671248509081109E /* restrict.cpp in Sources */, - 545DD73999244831A23D777A /* scrollrt.cpp in Sources */, - 64CE5D2CE32946A08990EE92 /* setmaps.cpp in Sources */, - A4D2FA94492E46D38B094934 /* sha.cpp in Sources */, - 76C236244D2B4D5FB67381DB /* spells.cpp in Sources */, - BB88EC00498744F7914A1484 /* stores.cpp in Sources */, - 7E67ADF45FD840B69098C6D0 /* sync.cpp in Sources */, - 0E40D3E2ABA5486884AD1271 /* textdat.cpp in Sources */, - 82418547480144C0A65FC9CE /* themes.cpp in Sources */, - 8AC07A27B0D3408884802D80 /* tmsg.cpp in Sources */, - 3D80977966AE4264938D37A3 /* town.cpp in Sources */, - 283E47DA990148F18302218F /* towners.cpp in Sources */, - 5E67153371F94500B95B41A7 /* track.cpp in Sources */, - AA419C3D7384435299F5FA80 /* trigs.cpp in Sources */, - D9B4737B66AE401189E47E04 /* wave.cpp in Sources */, + 43B6C82A224068CF007313EA /* appfat.cpp in Sources */, + 43B6C82B224068CF007313EA /* automap.cpp in Sources */, + 43B6C82C224068CF007313EA /* capture.cpp in Sources */, + 43B6C82D224068CF007313EA /* codec.cpp in Sources */, + 43B6C82E224068CF007313EA /* control.cpp in Sources */, + 43B6C82F224068CF007313EA /* cursor.cpp in Sources */, + 43B6C830224068CF007313EA /* dead.cpp in Sources */, + 43B6C831224068CF007313EA /* debug.cpp in Sources */, + 43B6C832224068CF007313EA /* diablo.cpp in Sources */, + 43B6C833224068CF007313EA /* doom.cpp in Sources */, + 43B6C834224068CF007313EA /* drlg_l1.cpp in Sources */, + 43B6C835224068CF007313EA /* drlg_l2.cpp in Sources */, + 43B6C836224068CF007313EA /* drlg_l3.cpp in Sources */, + 43B6C837224068CF007313EA /* drlg_l4.cpp in Sources */, + 43B6C838224068CF007313EA /* dthread.cpp in Sources */, + 43B6C839224068CF007313EA /* effects.cpp in Sources */, + 43B6C83A224068CF007313EA /* encrypt.cpp in Sources */, + 43B6C83B224068CF007313EA /* engine.cpp in Sources */, + 43B6C83C224068CF007313EA /* error.cpp in Sources */, + 43B6C83D224068CF007313EA /* fault.cpp in Sources */, + 43B6C83E224068CF007313EA /* gamemenu.cpp in Sources */, + 43B6C83F224068CF007313EA /* gendung.cpp in Sources */, + 43B6C840224068CF007313EA /* gmenu.cpp in Sources */, + 43B6C841224068CF007313EA /* help.cpp in Sources */, + 43B6C842224068CF007313EA /* init.cpp in Sources */, + 43B6C843224068CF007313EA /* interfac.cpp in Sources */, + 43B6C844224068CF007313EA /* inv.cpp in Sources */, + 43B6C845224068CF007313EA /* items.cpp in Sources */, + 43B6C846224068CF007313EA /* lighting.cpp in Sources */, + 43B6C847224068CF007313EA /* loadsave.cpp in Sources */, + 43B6C848224068CF007313EA /* logging.cpp in Sources */, + 43B6C849224068CF007313EA /* mainmenu.cpp in Sources */, + 43B6C84A224068CF007313EA /* minitext.cpp in Sources */, + 43B6C84B224068CF007313EA /* missiles.cpp in Sources */, + 43B6C84C224068CF007313EA /* monster.cpp in Sources */, + 43B6C84D224068CF007313EA /* movie.cpp in Sources */, + 43B6C84E224068CF007313EA /* mpqapi.cpp in Sources */, + 43B6C84F224068CF007313EA /* msg.cpp in Sources */, + 43B6C850224068CF007313EA /* msgcmd.cpp in Sources */, + 43B6C851224068CF007313EA /* multi.cpp in Sources */, + 43B6C852224068CF007313EA /* nthread.cpp in Sources */, + 43B6C853224068CF007313EA /* objects.cpp in Sources */, + 43B6C854224068CF007313EA /* pack.cpp in Sources */, + 43B6C855224068CF007313EA /* palette.cpp in Sources */, + 43B6C856224068CF007313EA /* path.cpp in Sources */, + 43B6C857224068CF007313EA /* pfile.cpp in Sources */, + 43B6C858224068CF007313EA /* player.cpp in Sources */, + 43B6C859224068CF007313EA /* plrmsg.cpp in Sources */, + 43B6C85A224068CF007313EA /* portal.cpp in Sources */, + 43B6C85B224068CF007313EA /* quests.cpp in Sources */, + 43B6C85C224068CF007313EA /* render.cpp in Sources */, + 43B6C85D224068CF007313EA /* restrict.cpp in Sources */, + 43B6C85E224068CF007313EA /* scrollrt.cpp in Sources */, + 43B6C85F224068CF007313EA /* setmaps.cpp in Sources */, + 43B6C860224068CF007313EA /* sha.cpp in Sources */, + 43B6C861224068CF007313EA /* spells.cpp in Sources */, + 43B6C862224068CF007313EA /* stores.cpp in Sources */, + 43B6C863224068CF007313EA /* sync.cpp in Sources */, + 43B6C864224068CF007313EA /* textdat.cpp in Sources */, + 43B6C865224068CF007313EA /* themes.cpp in Sources */, + 43B6C866224068CF007313EA /* tmsg.cpp in Sources */, + 43B6C867224068CF007313EA /* town.cpp in Sources */, + 43B6C868224068CF007313EA /* towners.cpp in Sources */, + 43B6C869224068CF007313EA /* track.cpp in Sources */, + 43B6C86A224068CF007313EA /* trigs.cpp in Sources */, + 43B6C86B224068CF007313EA /* wave.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -838,34 +844,36 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 43398771223E60F8001F8420 /* udp_p2p.cpp in Sources */, - 43398782223E60F9001F8420 /* dx.cpp in Sources */, - 43398789223E60F9001F8420 /* selhero.cpp in Sources */, - 43398784223E60F9001F8420 /* rand.cpp in Sources */, - 4339878A223E60F9001F8420 /* credits.cpp in Sources */, - 43398773223E60F8001F8420 /* storm_net.cpp in Sources */, - 43398787223E60F9001F8420 /* tcp_server.cpp in Sources */, - 4339878B223E60F9001F8420 /* dialogs.cpp in Sources */, - 43398776223E60F8001F8420 /* progress.cpp in Sources */, - 43398783223E60F9001F8420 /* tcp_client.cpp in Sources */, - 4339877D223E60F9001F8420 /* frame_queue.cpp in Sources */, - 43398788223E60F9001F8420 /* loopback.cpp in Sources */, - 43398780223E60F9001F8420 /* thread.cpp in Sources */, - 43398778223E60F9001F8420 /* packet.cpp in Sources */, - 4339877F223E60F9001F8420 /* misc.cpp in Sources */, - 4339877A223E60F9001F8420 /* main.cpp in Sources */, - 43398781223E60F9001F8420 /* title.cpp in Sources */, - 43398770223E60F8001F8420 /* miniwin_dsound.cpp in Sources */, - 43398785223E60F9001F8420 /* misc_io.cpp in Sources */, - 43398786223E60F9001F8420 /* selgame.cpp in Sources */, - 4339877E223E60F9001F8420 /* misc_msg.cpp in Sources */, - 43398775223E60F8001F8420 /* mainmenu.cpp in Sources */, - 4339877B223E60F9001F8420 /* storm.cpp in Sources */, - 43398774223E60F8001F8420 /* diabloui.cpp in Sources */, - 43398779223E60F9001F8420 /* sound.cpp in Sources */, - 43398777223E60F9001F8420 /* selconn.cpp in Sources */, - 4339877C223E60F9001F8420 /* abstract_net.cpp in Sources */, - 43398772223E60F8001F8420 /* base.cpp in Sources */, + 43B6C7CA224068AB007313EA /* abstract_net.cpp in Sources */, + 43B6C7CB224068AB007313EA /* base.cpp in Sources */, + 43B6C7CC224068AB007313EA /* credits.cpp in Sources */, + 43B6C7CD224068AB007313EA /* diabloui.cpp in Sources */, + 43B6C7CE224068AB007313EA /* dialogs.cpp in Sources */, + 43B6C7CF224068AB007313EA /* dsound.cpp in Sources */, + 43B6C7D0224068AB007313EA /* dx.cpp in Sources */, + 43B6C7D1224068AB007313EA /* frame_queue.cpp in Sources */, + 43B6C7D2224068AB007313EA /* loopback.cpp in Sources */, + 43B6C7D3224068AB007313EA /* main.cpp in Sources */, + 43B6C7D4224068AB007313EA /* mainmenu.cpp in Sources */, + 43B6C7D5224068AB007313EA /* misc_dx.cpp in Sources */, + 43B6C7D6224068AB007313EA /* misc_io.cpp in Sources */, + 43B6C7D7224068AB007313EA /* misc_msg.cpp in Sources */, + 43B6C7D8224068AB007313EA /* misc.cpp in Sources */, + 43B6C7D9224068AB007313EA /* packet.cpp in Sources */, + 43B6C7DA224068AB007313EA /* progress.cpp in Sources */, + 43B6C7DB224068AB007313EA /* rand.cpp in Sources */, + 43B6C7DC224068AB007313EA /* selconn.cpp in Sources */, + 43B6C7DD224068AB007313EA /* selgame.cpp in Sources */, + 43B6C7DE224068AB007313EA /* selhero.cpp in Sources */, + 43B6C7DF224068AB007313EA /* sound.cpp in Sources */, + 43B6C7E0224068AB007313EA /* storm_dx.cpp in Sources */, + 43B6C7E1224068AB007313EA /* storm_net.cpp in Sources */, + 43B6C7E2224068AB007313EA /* storm.cpp in Sources */, + 43B6C7E3224068AB007313EA /* tcp_client.cpp in Sources */, + 43B6C7E4224068AB007313EA /* tcp_server.cpp in Sources */, + 43B6C7E5224068AB007313EA /* thread.cpp in Sources */, + 43B6C7E6224068AB007313EA /* title.cpp in Sources */, + 43B6C7E7224068AB007313EA /* udp_p2p.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1095,10 +1103,14 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(PROJECT_DIR)/SourceS", "$(PROJECT_DIR)/SourceX", "$(PROJECT_DIR)/3rdParty/asio/include", + "$(PROJECT_DIR)/3rdParty/Radon/Radon/include", + "$(PROJECT_DIR)/3rdParty/libsmacker", + "$(PROJECT_DIR)/3rdParty/StromLib/src", "$(PROJECT_DIR)/.", + "$(PROJECT_DIR)/Source", + "$(PROJECT_DIR)/SourceS", ); INFOPLIST_EXPAND_BUILD_SETTINGS = YES; INFOPLIST_FILE = "$(SRCROOT)/Xcode/Info.plist"; @@ -1217,10 +1229,14 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ( - "$(PROJECT_DIR)/SourceS", "$(PROJECT_DIR)/SourceX", "$(PROJECT_DIR)/3rdParty/asio/include", + "$(PROJECT_DIR)/3rdParty/Radon/Radon/include", + "$(PROJECT_DIR)/3rdParty/libsmacker", + "$(PROJECT_DIR)/3rdParty/StromLib/src", "$(PROJECT_DIR)/.", + "$(PROJECT_DIR)/Source", + "$(PROJECT_DIR)/SourceS", ); INFOPLIST_EXPAND_BUILD_SETTINGS = YES; INFOPLIST_FILE = "$(SRCROOT)/Xcode/Info.plist"; @@ -1344,7 +1360,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; @@ -1394,7 +1410,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; @@ -1489,7 +1505,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; @@ -1525,7 +1541,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; @@ -1564,7 +1580,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; @@ -1600,7 +1616,7 @@ GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "'CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"'"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_SYMBOLS_PRIVATE_EXTERN = NO; INSTALL_PATH = ""; LIBRARY_STYLE = STATIC; diff --git a/defs.h b/defs.h index 73729fd34..182830eee 100644 --- a/defs.h +++ b/defs.h @@ -83,6 +83,8 @@ #define PAL16_RED 224 #define PAL16_GRAY 240 +#define SCREENXY(x, y) ((x) + 64 + (((y) + 160) * 768)) + #ifndef INVALID_FILE_ATTRIBUTES #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif diff --git a/structs.h b/structs.h index cb00b19e4..5b63c3c09 100644 --- a/structs.h +++ b/structs.h @@ -413,7 +413,7 @@ typedef struct MissileStruct { int _miAnimAdd; int _miAnimFrame; BOOL _miDrawFlag; - int _miLightFlag; + BOOL _miLightFlag; BOOL _miPreFlag; int _miUniqTrans; int _mirange; @@ -1187,22 +1187,6 @@ typedef struct DeadStruct { char _deadtrans; } DeadStruct; -////////////////////////////////////////////////// -// dx -////////////////////////////////////////////////// - -typedef struct ScreenRow { - char col_unused_1[64]; - char pixels[640]; - char col_unused_2[64]; -} ScreenRow; - -typedef struct Screen { /* create union for work data vs visible data */ - ScreenRow row_unused_1[160]; - ScreenRow row[480]; - ScreenRow row_unused_2[16]; -} Screen; - ////////////////////////////////////////////////// // diabloui //////////////////////////////////////////////////