# HG changeset patch # User Xeli # Date 1351427303 -3600 # Node ID ddcdedd3330b4bf32eaf613500f88eae0aa3c198 # Parent 41b0a9955c475591c47c84a35cc9e0c9655addd8# Parent 0b447175594fe5e1247226f92c94111f733cc37f merge hedgeroid branch with tip diff -r 41b0a9955c47 -r ddcdedd3330b .hgeol --- a/.hgeol Thu Nov 24 13:44:30 2011 +0100 +++ b/.hgeol Sun Oct 28 13:28:23 2012 +0100 @@ -6,3 +6,4 @@ **.txt = native **.pas = native **.inc = native +**.hs = native diff -r 41b0a9955c47 -r ddcdedd3330b .hgignore --- a/.hgignore Thu Nov 24 13:44:30 2011 +0100 +++ b/.hgignore Sun Oct 28 13:28:23 2012 +0100 @@ -3,11 +3,14 @@ glob:moc_*.cxx glob:qrc_*.cxx glob:*.o +glob:*.qm glob:Makefile glob:bin glob:*.hi +glob:*.ppu glob:*.*~ glob:*.core +glob:hedgewars.pro.user glob:config.inc glob:cmake_install.cmake glob:QTfrontend/hwconsts.cpp @@ -26,7 +29,7 @@ glob:misc/libtremor/Xcode/build/ glob:misc/liblua/Xcode/build/ glob:misc/libfreetype/Xcode/build/ -glob:misc/libfreetype/Xcode-iPhoneOS/build/ +glob:misc/libfreetype/Xcode-iOS/build/ glob:moc_*.cxx_parameters relre:^release\/ glob:*.log @@ -42,9 +45,14 @@ glob:project_files/Android-build/SDL-android-project/bin glob:project_files/Android-build/SDL-android-project/gen glob:project_files/Android-build/SDL-android-project/local.properties +glob:project_files/Android-build/SDL-android-project/project.properties glob:project_files/Android-build/SDL-android-project/default.properties +glob:project_files/Android-build/SDL-android-project/proguard.cfg glob:project_files/Android-build/SDL-android-project/.* -glob:project_files/Android-build/complete_build.sh -glob:project_files/Android-build/pushToDevice.sh +glob:project_files/Android-build/out glob:project_files/Android-build/Makefile.android -glob:project_files/Android-build/out +glob:hedgewars-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug +glob:hedgewars-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release +glob:*.depends +glob:tools/build_windows_koda.bat + diff -r 41b0a9955c47 -r ddcdedd3330b .hgtags --- a/.hgtags Thu Nov 24 13:44:30 2011 +0100 +++ b/.hgtags Sun Oct 28 13:28:23 2012 +0100 @@ -46,3 +46,7 @@ cba92708277b6d0aeabfff2b878845b7d848bdcd Hedgewars-iOS-1.3.1 74bc72746bec68806344f4ba7be0d1bc6e05d380 0.9.16-release 652a199d4f38f5becbec0839f5a1f63294dd89bf Hedgewars-iOS-1.3.2 +4670f003f91b3246665ca0de95fa056d2d2f3f54 0-9.17-release +0000000000000000000000000000000000000000 0-9.17-release +4670f003f91b3246665ca0de95fa056d2d2f3f54 0.9.17-release +ce2b24995ab2efc088accecd7f7b116bb946fff7 hedgeroid-alpha diff -r 41b0a9955c47 -r ddcdedd3330b CMakeLists.txt --- a/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -4,9 +4,9 @@ #initialise cmake environment cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) FOREACH(policy CMP0003 CMP0012) - IF(POLICY ${policy}) - CMAKE_POLICY(SET ${policy} NEW) - ENDIF() + IF(POLICY ${policy}) + CMAKE_POLICY(SET ${policy} NEW) + ENDIF() ENDFOREACH() set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules) @@ -15,194 +15,243 @@ set(version_suffix "-dev") #UNSET THIS VARIABLE AT RELEASE TIME set(HGCHANGED "") IF(version_suffix MATCHES "-dev") - set(HW_DEV true) - IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.hg) - FIND_PROGRAM(HGCOMMAND hg) - IF(HGCOMMAND) - exec_program(${HGCOMMAND} - ARGS identify -in ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE version_suffix - ) - STRING(REGEX REPLACE "[^+]" "" HGCHANGED ${version_suffix}) - STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) ([0-9]+)(.*)" "\\3-\\1" version_suffix ${version_suffix}) - IF (HGCHANGED) - MESSAGE(STATUS "Building revision ${version_suffix} (SOURCE CODE MODIFIED)") - ELSE() - MESSAGE(STATUS "Building revision ${version_suffix}") - ENDIF() - set(version_suffix "-${version_suffix}") - ENDIF() - ENDIF() + set(HW_DEV true) + set(default_build_type "DEBUG") + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.hg) + FIND_PROGRAM(HGCOMMAND hg) + IF(HGCOMMAND) + exec_program(${HGCOMMAND} + ARGS identify -in ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE version_suffix + ) + STRING(REGEX REPLACE "[^+]" "" HGCHANGED ${version_suffix}) + STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) ([0-9]+)(.*)" "\\3-\\1" version_suffix ${version_suffix}) + IF (HGCHANGED) + MESSAGE(STATUS "Building revision ${version_suffix} (SOURCE CODE MODIFIED)") + ELSE() + MESSAGE(STATUS "Building revision ${version_suffix}") + ENDIF() + set(version_suffix "-${version_suffix}") + ENDIF() + ENDIF() ELSE() - set(HW_DEV false) + set(HW_DEV false) + set(default_build_type "RELEASE") ENDIF() #versioning set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 9) -set(CPACK_PACKAGE_VERSION_PATCH 17${version_suffix}) -set(HEDGEWARS_PROTO_VER 40) +set(CPACK_PACKAGE_VERSION_PATCH 18${version_suffix}) +set(HEDGEWARS_PROTO_VER 42) set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -#set some safe values -IF(NOT WITH_SERVER) - SET(WITH_SERVER 0) -ENDIF(NOT WITH_SERVER) -IF(NOT BUILD_ENGINE_LIBRARY) - SET(BUILD_ENGINE_LIBRARY 0) -ENDIF(NOT BUILD_ENGINE_LIBRARY) -set(target_dir "bin") +#set some default values +option(NOSERVER "Disable gameServer build [default: auto]" OFF) +option(NOPNG "Disable screenshoot compression [default: auto]" OFF) +option(NOVIDEOREC "Disable video recording [default: auto]" OFF) + +option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF) +option(ANDROID "Enable Android build [default: off]" OFF) +option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF) #bundle .app setup -if(APPLE) - set(CMAKE_FIND_FRAMEWORK "FIRST") +if(APPLE OR CROSSAPPLE) + #paths for creating the bundle + set(bundle_name Hedgewars.app) + set(frameworks_dir ${bundle_name}/Contents/Frameworks/) + set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/) + set(DATA_INSTALL_DIR "../Resources/") + set(target_dir ".") + set(minimum_macosx_version "10.6") +else() + set(target_dir "bin") +endif() - #paths for creating the bundle - set(bundle_name Hedgewars.app) - set(frameworks_dir ${bundle_name}/Contents/Frameworks/) - set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/) - set(DATA_INSTALL_DIR "../Resources/") - set(target_dir ".") +if(APPLE) + set(CMAKE_FIND_FRAMEWORK "FIRST") - #what system are we building for - set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) + #what system are we building for + set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) - #detect on which system are we - EXEC_PROGRAM("/usr/bin/sw_vers" ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version) - STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) + #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version + find_program(sw_vers sw_vers) + if(sw_vers) + exec_program(${sw_vers} ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version) + string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) + else() + if(NOT minimum_macosx_version) + message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set") + else() + set(current_macosx_version ${minimum_macosx_version}) + endif() + endif() - #if nothing is set, we deploy only for the current system - if(NOT minimum_macosx_version) - set(minimum_macosx_version ${current_macosx_version}) - endif() + #if nothing is set, we deploy only for the current system + if(NOT minimum_macosx_version) + set(minimum_macosx_version ${current_macosx_version}) + endif() - #who uses them anyway? - if (minimum_macosx_version LESS "10.4") - message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") - endif() + #lower systems don't have enough processing power anyways + if (minimum_macosx_version LESS "10.4") + message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") + endif() - #this variable needs to be set for frapascal universal binary - if(NOT CMAKE_OSX_ARCHITECTURES) - if(current_macosx_version LESS "10.6") - if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") - set(CMAKE_OSX_ARCHITECTURES "ppc7400") - else() - set(CMAKE_OSX_ARCHITECTURES "i386") - endif() - else() - set(CMAKE_OSX_ARCHITECTURES "x86_64") - endif() - endif() - - #be sure to select ppc-compatible toolchains just in case - if(minimum_macosx_version LESS "10.6") - set(CMAKE_C_COMPILER "gcc-4.0") - set(CMAKE_CXX_COMPILER "g++-4.0") - endif() + #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) + if(current_macosx_version MATCHES "10.4") + find_package(SDL_mixer REQUIRED) + set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg") + set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") + set(pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}" ${pascal_flags}) + set(CMAKE_C_FLAGS "${DYLIB_SMPEG}" "${DYLIB_MIKMOD}" ${CMAKE_C_FLAGS}) + endif() - if(minimum_macosx_version MATCHES "10.4") - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") - #workaround for http://playcontrol.net/ewing/jibberjabber/big_behind-the-scenes_chang.html#SDL_mixer (Update 2) - if(current_macosx_version MATCHES "10.4") - find_package(SDL_mixer REQUIRED) - set(pascal_compiler_flags_cmn "-k-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg" "-k-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod" ${pascal_compiler_flags_cmn}) - set(CMAKE_C_FLAGS "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg -dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod") - endif() - else() - STRING(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") - endif() + #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking + if(NOT CMAKE_OSX_ARCHITECTURES) + if(current_macosx_version LESS "10.6") + if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") + set(CMAKE_OSX_ARCHITECTURES "ppc7400") + else() + set(CMAKE_OSX_ARCHITECTURES "i386") + endif() + else() + set(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() + endif() - #add user framework directory - set(pascal_compiler_flags_cmn "-Ff~/Library/Frameworks" ${pascal_compiler_flags_cmn}) - #set deployment target - set(pascal_compiler_flags_cmn "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_compiler_flags_cmn}) - #link with liblua.a (which requires readline) - set(pascal_compiler_flags_cmn "-k${CMAKE_BINARY_DIR}/bin/liblua.a" "-k-lreadline" ${pascal_compiler_flags_cmn}) - #link with libsdlmain.a (when building an executable) - if(NOT BUILD_ENGINE_LIBRARY) - set(pascal_compiler_flags_cmn "-k${CMAKE_BINARY_DIR}/bin/libSDLmain.a" ${pascal_compiler_flags_cmn}) - endif() + #CMAKE_OSX_SYSROOT is set at the system version we are supposed to build on + #we need to provide the correct one when host and target differ + if(NOT ${minimum_macosx_version} MATCHES ${current_macosx_version}) + if(minimum_macosx_version MATCHES "10.4") + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/") + set(CMAKE_C_COMPILER "gcc-4.0") + set(CMAKE_CXX_COMPILER "g++-4.0") + else() + string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") + endif() + endif() - message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}") - message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s):${CMAKE_OSX_ARCHITECTURES}") + #add user framework directory, other paths can be passed via FPFLAGS + set(pascal_flags "-Ff~/Library/Frameworks" ${pascal_flags}) + #set deployment target + set(pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}" ${pascal_flags}) + + message(STATUS "Build system: Mac OS X ${current_macosx_version} with GCC:${CMAKE_C_COMPILER}") + message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s):${CMAKE_OSX_ARCHITECTURES}") endif(APPLE) -#build Debug only when explicitally set -if (NOT CMAKE_BUILD_TYPE) - set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: Debug Release." FORCE) -endif (NOT CMAKE_BUILD_TYPE) - -if(CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "debug") - message(STATUS "Building Debug") - set(Optz false) -else() - message(STATUS "Building Release") - set(Optz true) -endif() +#when build type is not specified, assume Debug/Release according to build version information +if (CMAKE_BUILD_TYPE) + string (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) + if ( NOT( (CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "DEBUG") ) ) + set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Only 'Debug' or 'Release' options are allowed." FORCE) + message (STATUS "Unknown build type, using default (${default_build_type})") + endif () +else (CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE) +endif (CMAKE_BUILD_TYPE) -#set default flags values for all the project +#set default flags values for all projects set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}") -set(CMAKE_C_FLAGS_RELEASE "-w -O2 -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS}) set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) -set(pascal_compiler_flags_cmn "-B" "-FE../bin" "-Cs2000000" "-vewn" ${pascal_compiler_flags_cmn}) +#parse additional parameters +if(FPFLAGS OR GHFLAGS) + math(EXPR cmake_version "${CMAKE_MAJOR_VERSION}*10000 + ${CMAKE_MINOR_VERSION}*100 + ${CMAKE_PATCH_VERSION}") + if(cmake_version LESS "020800") + message(STATUS "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8") + else() + separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) + separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) + endif() +endif() -if(Optz) -# set(pascal_compiler_flags_cmn "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_compiler_flags_cmn}) - set(pascal_compiler_flags_cmn "-O2" "-Xs" "-Si" ${pascal_compiler_flags_cmn}) - set(haskell_compiler_flags_cmn "-O2" "-w" "-fno-warn-unused-do-bind") -else(Optz) -# set(pascal_compiler_flags_cmn "-O-" "-g" "-gh" "-gl" "-dDEBUGFILE" ${pascal_compiler_flags_cmn}) - set(pascal_compiler_flags_cmn "-O-" "-g" "-gl" "-dDEBUGFILE" ${pascal_compiler_flags_cmn}) - set(haskell_compiler_flags_cmn "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind") -endif(Optz) +set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags}) +set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags}) + +#get BUILD_TYPE and enable/disable optimisation +if(CMAKE_BUILD_TYPE MATCHES "DEBUG") + message(STATUS "Building Debug flavour") + set(pascal_flags "-O-" "-g" "-gl" "-gv" ${pascal_flags}) + set(haskell_flags "-Wall" "-debug" "-dcore-lint" "-fno-warn-unused-do-bind" ${haskell_flags}) +else() + message(STATUS "Building Release flavour") +# set(pascal_flags "-O3" "-OpPENTIUM4" "-CfSSE3" "-Xs" "-Si" ${pascal_flags}) + set(pascal_flags "-Os" "-Ooregvar" "-Xs" "-Si" ${pascal_flags}) + set(haskell_flags "-w" "-fno-warn-unused-do-bind" ${haskell_flags}) +endif() +#finish setting paths if(DEFINED DATA_INSTALL_DIR) - set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/) + set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/) else() - set(SHAREPATH share/hedgewars/) + set(SHAREPATH share/hedgewars/) endif() set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) -if(WITH_SERVER) - find_program(ghc_executable ghc) +#server discovery +if(NOT NOSERVER) + if(GHC) + set(ghc_executable ${GHC}) + else() + find_program(ghc_executable ghc) + endif() - if(ghc_executable) - set(HAVE_NETSERVER true) - add_subdirectory(gameServer) - else() - message(STATUS "No GHC executable found, server will *not* be built") - set(HAVE_NETSERVER false) - endif() -else(WITH_SERVER) - set(HAVE_NETSERVER false) -endif(WITH_SERVER) + if(ghc_executable) + set(HAVE_NETSERVER true) + add_subdirectory(gameServer) + message(STATUS "Found GHC: ${ghc_executable}") + else() + message(STATUS "Could NOT find GHC, server will not be built") + set(HAVE_NETSERVER false) + endif() +else() + message(STATUS "Server will not be built per user request") + set(HAVE_NETSERVER false) +endif() + -add_subdirectory(misc/liblua) +#lua discovery +find_package(Lua) +if(LUA_FOUND) + message(STATUS "Found LUA: ${LUA_DEFAULT}") +else() + message(STATUS "LUA will be provided by the bundled sources") + add_subdirectory(misc/liblua) + #linking with liblua.a requires system readline -- this works everywhere, right? + set(pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline" ${pascal_flags}) +endif() + + +#main engine add_subdirectory(hedgewars) -#run cmake -DBUILD_ANDROID_PORT=1 to enable this -if(BUILD_ANDROID_PORT) - add_subdirectory(project_files/Android-build) +#Android related build scripts +if(ANDROID) + #run cmake -DANDROID=1 to enable this + add_subdirectory(project_files/Android-build) endif() -if(NOT BUILD_ENGINE_LIBRARY) - add_subdirectory(bin) - add_subdirectory(misc/quazip) - add_subdirectory(QTfrontend) - add_subdirectory(share) - add_subdirectory(tools) +#TODO: when ANDROID, BUILD_ENGINE_LIBRARY should be set +if(NOT (BUILD_ENGINE_LIBRARY OR ANDROID)) + add_subdirectory(bin) + add_subdirectory(misc/quazip) + add_subdirectory(QTfrontend) + add_subdirectory(share) + add_subdirectory(tools) endif() @@ -217,74 +266,74 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Hedgewars ${HEDGEWARS_VERSION}") if(WIN32 AND NOT UNIX) - set(CPACK_NSIS_DISPLAY_NAME "Hedgewars") - set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/") - set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/") - set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com") - set(CPACK_NSIS_MODIFY_PATH OFF) - set(CPACK_GENERATOR "ZIP;NSIS") - set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hedgewars") + set(CPACK_NSIS_DISPLAY_NAME "Hedgewars") + set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/") + set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/") + set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com") + set(CPACK_NSIS_MODIFY_PATH OFF) + set(CPACK_GENERATOR "ZIP;NSIS") + set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hedgewars") else(WIN32 AND NOT UNIX) - set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine") + set(CPACK_STRIP_FILES "bin/hedgewars;bin/hwengine") endif(WIN32 AND NOT UNIX) set(CPACK_SOURCE_IGNORE_FILES - "~" - "\\\\.hg" - "\\\\.svn" - "\\\\.exe$" - "\\\\.a$" - "\\\\.dll$" - "\\\\.xcf$" - "\\\\.cxx$" - "\\\\.db$" - "\\\\.dof$" - "\\\\.layout$" - "\\\\.zip$" - "\\\\.gz$" - "\\\\.bz2$" - "\\\\.tmp$" - "\\\\.core$" - "\\\\.sh$" - "\\\\.sifz$" - "\\\\.svg$" - "\\\\.svgz$" - "\\\\.ppu$" - "\\\\.psd$" - "\\\\.o$" - "Makefile" - "Doxyfile" - "CMakeFiles" - "debug" - "release$" - "Debug$" - "Release$" - "proto\\\\.inc$" - "hwconsts\\\\.cpp$" - "playlist\\\\.inc$" - "CPack" - "cmake_install\\\\.cmake$" - "config\\\\.inc$" - "hwengine\\\\.desktop$" - "CMakeCache\\\\.txt$" -# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libopenalbridge" -# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libfreetype" - "^${CMAKE_CURRENT_SOURCE_DIR}/misc/liblua" -# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libtremor" - "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/HedgewarsMobile/" - "^${CMAKE_CURRENT_SOURCE_DIR}/bin/[a-z]" - "^${CMAKE_CURRENT_SOURCE_DIR}/tools/templates" - "^${CMAKE_CURRENT_SOURCE_DIR}/doc" - "^${CMAKE_CURRENT_SOURCE_DIR}/templates" - "^${CMAKE_CURRENT_SOURCE_DIR}/Graphics" - "^${CMAKE_CURRENT_SOURCE_DIR}/realtest" - "^${CMAKE_CURRENT_SOURCE_DIR}/tmp" - "^${CMAKE_CURRENT_SOURCE_DIR}/utils" - "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Maps/test" - "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Themes/ethereal" - "^${CMAKE_CURRENT_SOURCE_DIR}/install_manifest.txt" - "^${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" - "^${CMAKE_CURRENT_SOURCE_DIR}/hedgewars\\\\." + "~" + "\\\\.hg" + "\\\\.svn" + "\\\\.exe$" + "\\\\.a$" + "\\\\.dll$" + "\\\\.xcf$" + "\\\\.cxx$" + "\\\\.db$" + "\\\\.dof$" + "\\\\.layout$" + "\\\\.zip$" + "\\\\.gz$" + "\\\\.bz2$" + "\\\\.tmp$" + "\\\\.core$" + "\\\\.sh$" + "\\\\.sifz$" + "\\\\.svg$" + "\\\\.svgz$" + "\\\\.ppu$" + "\\\\.psd$" + "\\\\.o$" + "Makefile" + "Doxyfile" + "CMakeFiles" + "debug" + "release$" + "Debug$" + "Release$" + "proto\\\\.inc$" + "hwconsts\\\\.cpp$" + "playlist\\\\.inc$" + "CPack" + "cmake_install\\\\.cmake$" + "config\\\\.inc$" + "hwengine\\\\.desktop$" + "CMakeCache\\\\.txt$" +# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libopenalbridge" +# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libfreetype" + "^${CMAKE_CURRENT_SOURCE_DIR}/misc/liblua" +# "^${CMAKE_CURRENT_SOURCE_DIR}/misc/libtremor" + "^${CMAKE_CURRENT_SOURCE_DIR}/project_files/HedgewarsMobile/" + "^${CMAKE_CURRENT_SOURCE_DIR}/bin/[a-z]" + "^${CMAKE_CURRENT_SOURCE_DIR}/tools/templates" + "^${CMAKE_CURRENT_SOURCE_DIR}/doc" + "^${CMAKE_CURRENT_SOURCE_DIR}/templates" + "^${CMAKE_CURRENT_SOURCE_DIR}/Graphics" + "^${CMAKE_CURRENT_SOURCE_DIR}/realtest" + "^${CMAKE_CURRENT_SOURCE_DIR}/tmp" + "^${CMAKE_CURRENT_SOURCE_DIR}/utils" + "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Maps/test" + "^${CMAKE_CURRENT_SOURCE_DIR}/share/hedgewars/Data/Themes/ethereal" + "^${CMAKE_CURRENT_SOURCE_DIR}/install_manifest.txt" + "^${CMAKE_CURRENT_SOURCE_DIR}/CMakeCache.txt" + "^${CMAKE_CURRENT_SOURCE_DIR}/hedgewars\\\\." ) include(CPack) diff -r 41b0a9955c47 -r ddcdedd3330b CREDITS --- a/CREDITS Thu Nov 24 13:44:30 2011 +0100 +++ b/CREDITS Sun Oct 28 13:28:23 2012 +0100 @@ -18,6 +18,12 @@ - hillis -> AkuAku (2010) - Lortinak -> OldMan (2010), ShortHair (2010) - chujoii -> BrainSlug (2010), Dragon (2010), Ladle (2010), Laminaria (2010), Pantsu (2010), Pig (2010), Plunger (2010), SauceBoat (2010), ShaggyYeti (2010), SleepWalker (2010), SunWukong (2010), Teapot (2010), Teacup (2010), Zombi (2010) +- Randy Broda -> Cyclops (2011), Soldier (2011) + +========== += GRAVESTONES +========== +- Randy Broda -> Dragonball (2012) ========== = MAPS diff -r 41b0a9955c47 -r ddcdedd3330b ChangeLog.txt --- a/ChangeLog.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/ChangeLog.txt Sun Oct 28 13:28:23 2012 +0100 @@ -1,11 +1,40 @@ + features * bugfixes +0.9.17 -> 0.9.18: + + + 'A Classic Fairytale' Campaign + + Video recorder (requires ffmpeg) + + Cleaver weapon + + AI is now aware of drowning and fall damage + + AI learned how to use Sniper Rifle and Cake + + Variable pen width and eraser for drawn maps + + Several trainings and missions + + Allow setting custom local palette of teams colors + + Hide eliminated teams from teams healths widget + + Server doesn't delete room till last player quits it + + PNG screenshots + + Show bot level on CPU flag + + Objects now have density value assigned which impacts their behavior on explosions, throwing from rope and drowning + + Improve AI skills at Desert Eagel, Whip, Firepunch, Baseball Bat, Hammer, Cluster Bomb, Watermelon and walking + + Individual hedgehogs healths in team health bar + + Drill rocket wouldn't explode in your face if you stand close to wall + + Ability to rope into a portal, allow RC plane to go through portals + + Many small frontend improvements: get rid of "save" buttons, descriptions, allow to use network proxy, etc + + Reduce amount of memory needed for engine to store land data + + Countless other small fixes and improvements + + Detect desyncs early + * Fix cake getting stuck in barrels, crates and hedgehogs + * Fix all knowns bugs which caused network game hang when players close engine or quit + * Fix drill strike bug when drill's timer gets ridiculously high value instead of explosion + * Fix some crashes, freezes and memory leaks in frontend and engine + 0.9.16 -> 0.9.17: + New theme, Cave + New voicepack, Hillbilly + More attractive mission screen with previews + Chat timestamping, links, input history, tab completion + + AI smarter, now uses switch. Also tweaks to mine/crate/barrel rules + Customisable chat by dragging a .css file, see file generated by the /saveStyleSheet command + Errors/warnings in chat instead of popup boxes + Mousewheel to change hog/weapon counts in game creation @@ -19,6 +48,7 @@ + Grenades/bazooka/melon pieces/ballgun now kicked by explosions + Minor theme optimisation, Optional SkyR + Camera follows melon, clusterbomb, gas cloud + * More fixes to fullscreen/window resize on non-Linux systems * Vertical movement should be restricted for small displays, camera will try less hard to keep hog in centre * Keep mouse from jumping around when ammo menu is active * Hogs can now move after trapping another hog in a portal loop @@ -30,7 +60,7 @@ * Girders no longer make windows in tunnels * Prevent some more escaping through border, firepunch, pickhammer * Many frontend bugfixes, code cleanup. Crash in game abort, flake clipping, invalid state on room close - * Many other engine bugfixes. SDL event crasher, timebox crasher, birdy hang, desync on quits, crash in birdy eggshell, clouds on Deep Space theme, etc + * Many other engine bugfixes. SDL event crasher, timebox crasher, birdy hang, desync on quits, crash in birdy eggshell, hammer + vamp + invuln, clouds on Deep Space theme, etc 0.9.15 -> 0.9.16: + In-game chat now supports backspace-repeat and Escape to close the text input area diff -r 41b0a9955c47 -r ddcdedd3330b INSTALL --- a/INSTALL Thu Nov 24 13:44:30 2011 +0100 +++ b/INSTALL Sun Oct 28 13:28:23 2012 +0100 @@ -18,9 +18,9 @@ $ cmake . or $ cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="install_prefix" \ --DDATA_INSTALL_DIR="data_dir" . +-DDATA_INSTALL_DIR="data_dir" -DNOSERVER=1 . -add -DWITH_SERVER=1 to compile net server; if you have Qt installed but it is +add -DNOSERVER=0 to compile net server; if you have Qt installed but it is not found you can set it up with -DQT_QMAKE_EXECUTABLE="path_to_qmake" 2. Compile: diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -11,7 +11,9 @@ set(QT_USE_QTMAIN TRUE) find_package(Qt4 REQUIRED) -include(${QT_USE_FILE}) +if (NOT CROSSAPPLE) + include(${QT_USE_FILE}) +endif() # Check if we need zlib check_library_exists("${QT_QTCORE_LIBRARY}" inflateInit2_ ${QT_LIBRARY_DIR} QT_PROVIDES_ZLIB_FUNCTIONS) @@ -26,6 +28,9 @@ # Configure for SDL find_package(SDL REQUIRED) find_package(SDL_mixer REQUIRED) +if(NOT NOVIDEOREC) + find_package(FFMPEG) +endif() include_directories(.) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model) @@ -37,6 +42,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util) include_directories(${SDL_INCLUDE_DIR}) include_directories(${SDLMIXER_INCLUDE_DIR}) +include_directories(${FFMPEG_INCLUDE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/misc/quazip) if(UNIX) # HACK: in freebsd cannot find iconv.h included via SDL.h @@ -47,7 +53,7 @@ if(WIN32 AND NOT UNIX) set(HEDGEWARS_BINDIR ".") set(HEDGEWARS_DATADIR "../share/") - add_definitions(-DUSE_XFIRE) + add_definitions(-DUSE_XFIRE) else() set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}) if(DEFINED DATA_INSTALL_DIR) @@ -69,6 +75,10 @@ file(GLOB_RECURSE UIcpp ui/*.cpp) file(GLOB UtilCpp util/*.cpp) +if(${FFMPEG_FOUND}) + add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) +endif() + set(hwfr_src ${ModelCpp} ${NetCpp} @@ -83,6 +93,7 @@ hwform.cpp main.cpp team.cpp + campaign.cpp ui_hwform.cpp ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp ) @@ -119,6 +130,8 @@ HWApplication.h hwform.h team.h + util/DataManager.h + util/libav_iteraction.h ) set(hwfr_hdrs @@ -130,6 +143,7 @@ KB.h hwconsts.h sdlkeys.h + campaign.h ) set(hwfr_rez hedgewars.qrc) @@ -139,7 +153,7 @@ qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs}) -if(APPLE) +if(APPLE OR CROSSAPPLE) set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m) set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS}) @@ -167,6 +181,7 @@ ${QT_LIBRARIES} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} + ${FFMPEG_LIBRARIES} ${HW_LINK_LIBS} ) @@ -185,7 +200,11 @@ endif() -target_link_libraries(hedgewars ${HW_LINK_LIBS}) +if (CROSSAPPLE) + add_dependencies(hedgewars quazip) +else() + target_link_libraries(hedgewars ${HW_LINK_LIBS}) +endif() install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/CocoaInitializer.h --- a/QTfrontend/CocoaInitializer.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/CocoaInitializer.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/CocoaInitializer.mm --- a/QTfrontend/CocoaInitializer.mm Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/CocoaInitializer.mm Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/HWApplication.cpp --- a/QTfrontend/HWApplication.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/HWApplication.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,15 +22,17 @@ #include "hwform.h" HWApplication::HWApplication(int &argc, char **argv): - QApplication(argc, argv) + QApplication(argc, argv) { } -bool HWApplication::event(QEvent *event) { +bool HWApplication::event(QEvent *event) +{ QFileOpenEvent *openEvent; - switch (event->type()) { + switch (event->type()) + { case QEvent::FileOpen: openEvent = (QFileOpenEvent *)event; if (form) form->PlayDemoQuick(openEvent->file()); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/HWApplication.h --- a/QTfrontend/HWApplication.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/HWApplication.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,14 +35,14 @@ */ class HWApplication : public QApplication { - Q_OBJECT -public: - HWApplication(int &argc, char **argv); - ~HWApplication() {}; + Q_OBJECT + public: + HWApplication(int &argc, char **argv); + ~HWApplication() {}; - HWForm *form; -protected: - bool event(QEvent *); + HWForm *form; + protected: + bool event(QEvent *); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/InstallController.cpp --- a/QTfrontend/InstallController.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/InstallController.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/InstallController.h --- a/QTfrontend/InstallController.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/InstallController.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/KB.h --- a/QTfrontend/KB.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/KB.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,9 +26,9 @@ const QString KBMessages[KBmsgsCount] = { QT_TRANSLATE_NOOP("KB", "SDL_ttf returned error while rendering text, " - "most propably it is related to the bug " - "in freetype2. It's recommended to update your " - "freetype lib.") + "most propably it is related to the bug " + "in freetype2. It's recommended to update your " + "freetype lib.") }; #endif // KB_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/M3InstallController.h --- a/QTfrontend/M3InstallController.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/M3InstallController.h Sun Oct 28 13:28:23 2012 +0100 @@ -42,7 +42,9 @@ //#endif -@interface M3InstallController : NSObject { +@interface M3InstallController : +NSObject +{ NSAlert *alert; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/M3InstallController.m --- a/QTfrontend/M3InstallController.m Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/M3InstallController.m Sun Oct 28 13:28:23 2012 +0100 @@ -36,7 +36,7 @@ @implementation M3InstallController - (id) init { - if (self = [super init]) { + if ((self = [super init])) { NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; NSString *title = [NSString stringWithFormat:NSLocalizedString(@"%@ is currently running from a disk image", @"AppName is currently running from a disk image"), appName]; NSString *body = [NSString stringWithFormat:NSLocalizedString(@"Would you like to install %@ in your applications folder before quitting?", @"Would you like to install App Name in your applications folder before quitting?"), appName]; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/M3Panel.h --- a/QTfrontend/M3Panel.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/M3Panel.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/M3Panel.mm --- a/QTfrontend/M3Panel.mm Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/M3Panel.mm Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/NSWorkspace_RBAdditions.h --- a/QTfrontend/NSWorkspace_RBAdditions.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/NSWorkspace_RBAdditions.h Sun Oct 28 13:28:23 2012 +0100 @@ -32,6 +32,7 @@ //- NSWorkspace_RBimagefilepath: should be present for disk images only. Shows the path of the disk image file. //- NSWorkspace_RBserverURL: should be present for remote volumes only. Shows the server URL. -- (NSDictionary*)propertiesForPath:(NSString*)path; +- (NSDictionary*)propertiesForPath: +(NSString*)path; @end diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/NSWorkspace_RBAdditions.m --- a/QTfrontend/NSWorkspace_RBAdditions.m Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/NSWorkspace_RBAdditions.m Sun Oct 28 13:28:23 2012 +0100 @@ -9,6 +9,7 @@ #import "NSWorkspace_RBAdditions.h" #include #include +#include NSString* NSWorkspace_RBfstypename = @"NSWorkspace_RBfstypename"; NSString* NSWorkspace_RBmntonname = @"NSWorkspace_RBmntonname"; @@ -66,14 +67,14 @@ partition = [props objectForKey:@"Content"]; } else if (IOObjectConformsTo(nextParent,"IODiskImageBlockStorageDeviceOutKernel")) { NSData* data = nil; - if (data = [[props objectForKey:@"Protocol Characteristics"] objectForKey:@"Virtual Interface Location Path"]) { + if ((data = [[props objectForKey:@"Protocol Characteristics"] objectForKey:@"Virtual Interface Location Path"])) { image = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding] autorelease]; } } else if (IOObjectConformsTo(nextParent,"IOHDIXHDDriveInKernel")) { image = [props objectForKey:@"KDIURLPath"]; } NSDictionary* subdict; - if (subdict = [props objectForKey:@"Protocol Characteristics"]) { + if ((subdict = [props objectForKey:@"Protocol Characteristics"])) { connection = [subdict objectForKey:@"Physical Interconnect"]; } else { connection = [props objectForKey:@"Physical Interconnect"]; @@ -88,21 +89,21 @@ [dict setObject:image forKey:NSWorkspace_RBimagefilepath]; } NSString* value; - if (subdict = [props objectForKey:@"Device Characteristics"]) { - if (value = [subdict objectForKey:@"Product Name"]) { + if ((subdict = [props objectForKey:@"Device Characteristics"])) { + if ((value = [subdict objectForKey:@"Product Name"])) { result = AddPart(result,value); } - if (value = [subdict objectForKey:@"Product Revision Level"]) { + if ((value = [subdict objectForKey:@"Product Revision Level"])) { result = AddPart(result,value); } - if (value = [subdict objectForKey:@"Vendor Name"]) { + if ((value = [subdict objectForKey:@"Vendor Name"])) { result = AddPart(result,value); } } - if (value = [props objectForKey:@"USB Serial Number"]) { + if ((value = [props objectForKey:@"USB Serial Number"])) { result = AddPart(result,value); } - if (value = [props objectForKey:@"USB Vendor Name"]) { + if ((value = [props objectForKey:@"USB Vendor Name"])) { result = AddPart(result,value); } NSString* cls = [(NSString*)IOObjectCopyClass(nextParent) autorelease]; @@ -124,6 +125,7 @@ // This formats the (partially undocumented) AFPXMountInfo info into a string. +/* static NSString* FormatAFPURL(AFPXVolMountInfoPtr mountInfo,NSString** devdesc) { UInt8* work = ((UInt8*)mountInfo)+mountInfo->serverNameOffset; if (devdesc) { @@ -162,6 +164,7 @@ } return [NSString stringWithFormat:@"afp://%@/%@",dns?:(ip?:@""),volname]; } +*/ @implementation NSWorkspace (NSWorkspace_RBAdditions) diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/SparkleAutoUpdater.mm --- a/QTfrontend/SparkleAutoUpdater.mm Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/SparkleAutoUpdater.mm Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/achievements.cpp --- a/QTfrontend/achievements.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/achievements.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,8 @@ #include "achievements.h" // TODO: use some structs instead? -const char achievements[][6][256] = { +const char achievements[][6][256] = +{ // 6 array members each: id, caption, description, image, required number, attributes /* {"rounds1", QT_TRANSLATE_NOOP("achievements", "No complete Newbie!"), QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "nonewb", "1", ""}, diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/achievements.h --- a/QTfrontend/achievements.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/achievements.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/binds.cpp --- a/QTfrontend/binds.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/binds.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,8 +52,8 @@ {"+cur_r", "[6]", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL}, {"+cur_d", "[2]", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL}, // {"+cur_m", "", QT_TRANSLATE_NOOP("binds", "movement key modifier"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")}, - {"zoomin", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")}, - {"zoomout", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL}, + {"zoomin", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")}, + {"zoomout", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL}, {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), NULL, NULL}, {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), QT_TRANSLATE_NOOP("binds (categories)", "Other"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your team or all participants:")}, {"history", "`", QT_TRANSLATE_NOOP("binds", "chat history"), NULL, NULL}, @@ -62,7 +62,9 @@ {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL}, {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")}, {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL}, + {"mute", "8", QT_TRANSLATE_NOOP("binds", "mute audio"), NULL, NULL}, {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")}, {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")}, - {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")} + {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")}, + {"record", "r", QT_TRANSLATE_NOOP("binds", "record"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Record video:")} }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/binds.h --- a/QTfrontend/binds.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/binds.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include -#define BINDS_NUMBER 44 +#define BINDS_NUMBER 46 struct BindAction { diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/campaign.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/campaign.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,90 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "campaign.h" +#include "gameuiconfig.h" +#include "hwconsts.h" +#include "gamecfgwidget.h" +#include "bgwidget.h" +#include "mouseoverfilter.h" +#include "tcpBase.h" + +#include "DataManager.h" + +extern QString campaign, campaignTeam; + +QStringList getCampMissionList(QString & campaign) +{ + QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0); + campfile.setIniCodec("UTF-8"); + unsigned int mNum = campfile.value("MissionNum", 0).toInt(); + + QStringList missionList; + for (unsigned int i = 0; i < mNum; i++) + { + missionList += campfile.value(QString("Mission %1/Name").arg(i + 1)).toString(); + } + return missionList; +} + +unsigned int getCampProgress(QString & teamName, QString & campName) +{ + QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + teamName + ".hwt", QSettings::IniFormat, 0); + teamfile.setIniCodec("UTF-8"); + return teamfile.value("Campaign " + campName + "/Progress", 0).toInt(); +} + +QString getCampaignScript(QString campaign, unsigned int mNum) +{ + QSettings campfile(DataManager::instance().findFileForRead("Missions/Campaign/" + campaign + "/campaign.ini"), QSettings::IniFormat, 0); + campfile.setIniCodec("UTF-8"); + return campfile.value(QString("Mission %1/Script").arg(mNum)).toString(); +} + + + + + + + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/campaign.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/campaign.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,42 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef CAMPAIGN_H +#define CAMPAIGN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "netserver.h" +#include "game.h" +#include "ui_hwform.h" +#include "SDLInteraction.h" +#include "bgwidget.h" + +QStringList getCampMissionList(QString & campaign); +unsigned int getCampProgress(QString & teamName, QString & campName); +QString getCampaignScript(QString campaign, unsigned int mNum); + +#endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/drawmapscene.cpp --- a/QTfrontend/drawmapscene.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/drawmapscene.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,19 +31,28 @@ DrawMapScene::DrawMapScene(QObject *parent) : QGraphicsScene(parent), m_pen(Qt::yellow), - m_brush(Qt::yellow) + m_brush(Qt::yellow), + m_cursor(new QGraphicsEllipseItem(-0.5, -0.5, 1, 1)) { setSceneRect(0, 0, 4096, 2048); QLinearGradient gradient(0, 0, 0, 2048); gradient.setColorAt(0, QColor(60, 60, 155)); gradient.setColorAt(1, QColor(155, 155, 60)); - setBackgroundBrush(QBrush(gradient)); - m_pen.setWidth(67); + m_eraser = QBrush(gradient); + setBackgroundBrush(m_eraser); + m_isErasing = false; + + m_pen.setWidth(76); m_pen.setJoinStyle(Qt::RoundJoin); m_pen.setCapStyle(Qt::RoundCap); m_currPath = 0; + + m_isCursorShown = false; + m_cursor->setPen(QPen(Qt::green)); + m_cursor->setZValue(1); + m_cursor->setScale(m_pen.width()); } void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent) @@ -58,15 +67,20 @@ QPointF pos = mouseEvent->scenePos(); path.setElementPositionAt(c - 1, pos.x(), pos.y()); - } else + } + else { path.lineTo(mouseEvent->scenePos()); - paths.first().append(mouseEvent->scenePos().toPoint()); + paths.first().points.append(mouseEvent->scenePos().toPoint()); } m_currPath->setPath(path); emit pathChanged(); } + + if(!m_isCursorShown) + showCursor(); + m_cursor->setPos(mouseEvent->scenePos()); } void DrawMapScene::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent) @@ -78,7 +92,12 @@ p += QPointF(0.01, 0.01); path.moveTo(p); path.lineTo(mouseEvent->scenePos()); - paths.prepend(QList() << mouseEvent->scenePos().toPoint()); + + PathParams params; + params.width = serializePenWidth(m_pen.width()); + params.erasing = m_isErasing; + params.points = QList() << mouseEvent->scenePos().toPoint(); + paths.prepend(params); m_currPath->setPath(path); emit pathChanged(); @@ -90,7 +109,7 @@ { QPainterPath path = m_currPath->path(); path.lineTo(mouseEvent->scenePos()); - paths.first().append(mouseEvent->scenePos().toPoint()); + paths.first().points.append(mouseEvent->scenePos().toPoint()); m_currPath->setPath(path); simplifyLast(); @@ -99,8 +118,44 @@ } } +void DrawMapScene::wheelEvent(QGraphicsSceneWheelEvent * wheelEvent) +{ + if(wheelEvent->delta() > 0 && m_pen.width() < 516) + m_pen.setWidth(m_pen.width() + 10); + else if(wheelEvent->delta() < 0 && m_pen.width() >= 16) + m_pen.setWidth(m_pen.width() - 10); + + m_cursor->setScale(m_pen.width()); + + if(m_currPath) + { + m_currPath->setPen(m_pen); + paths.first().width = serializePenWidth(m_pen.width()); + } +} + +void DrawMapScene::showCursor() +{ + if(!m_isCursorShown) + addItem(m_cursor); + + m_isCursorShown = true; +} + +void DrawMapScene::hideCursor() +{ + if(m_isCursorShown) + removeItem(m_cursor); + + m_isCursorShown = false; +} + void DrawMapScene::undo() { + // cursor is a part of items() + if(m_isCursorShown) + return; + if(items().size()) { removeItem(items().first()); @@ -120,6 +175,10 @@ void DrawMapScene::clearMap() { + // cursor is a part of items() + if(m_isCursorShown) + return; + // don't clear if already cleared if(!items().size()) return; @@ -127,7 +186,8 @@ oldItems.clear(); // do this since clear() would _destroy_ all items - while(items().size()) { + while(items().size()) + { oldItems.push_front(items().first()); removeItem(items().first()); } @@ -139,6 +199,16 @@ emit pathChanged(); } + +void DrawMapScene::setErasing(bool erasing) +{ + m_isErasing = erasing; + if(erasing) + m_pen.setBrush(m_eraser); + else + m_pen.setBrush(m_brush); +} + QByteArray DrawMapScene::encode() { QByteArray b; @@ -146,13 +216,17 @@ for(int i = paths.size() - 1; i >= 0; --i) { int cnt = 0; - QList points = paths.at(i); - foreach(QPoint point, points) + PathParams params = paths.at(i); + foreach(QPoint point, params.points) { qint16 px = qToBigEndian((qint16)point.x()); qint16 py = qToBigEndian((qint16)point.y()); - quint8 flags = 2; - if(!cnt) flags |= 0x80; + quint8 flags = 0; + if(!cnt) + { + flags = 0x80 + params.width; + if(params.erasing) flags |= 0x40; + } b.append((const char *)&px, 2); b.append((const char *)&py, 2); b.append((const char *)&flags, 1); @@ -167,12 +241,14 @@ void DrawMapScene::decode(QByteArray data) { + bool erasing = m_isErasing; + oldItems.clear(); oldPaths.clear(); clear(); paths.clear(); - QList points; + PathParams params; while(data.size() >= 5) { @@ -183,38 +259,53 @@ quint8 flags = *(quint8 *)data.data(); data.remove(0, 1); - if((flags & 0x80) && points.size()) + if(flags & 0x80) { - addPath(pointsToPath(points), m_pen); - paths.prepend(points); + if(params.points.size()) + { + addPath(pointsToPath(params.points), m_pen); + + paths.prepend(params); + + params.points.clear(); + } - points.clear(); + quint8 penWidth = flags & 0x3f; + m_pen.setWidth(deserializePenWidth(penWidth)); + params.erasing = flags & 0x40; + if(params.erasing) + m_pen.setBrush(m_eraser); + else + m_pen.setBrush(m_brush); + params.width = penWidth; } - points.append(QPoint(px, py)); + params.points.append(QPoint(px, py)); } - if(points.size()) + if(params.points.size()) { - addPath(pointsToPath(points), m_pen); - paths.prepend(points); + addPath(pointsToPath(params.points), m_pen); + paths.prepend(params); } emit pathChanged(); + + setErasing(erasing); } void DrawMapScene::simplifyLast() { if(!paths.size()) return; - QList points = paths.at(0); + QList points = paths.at(0).points; QPoint prevPoint = points.first(); int i = 1; while(i < points.size()) { if( (i != points.size() - 1) - && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000) + && (sqr(prevPoint.x() - points[i].x()) + sqr(prevPoint.y() - points[i].y()) < 1000) ) points.removeAt(i); else @@ -224,18 +315,27 @@ } } - paths[0] = points; + paths[0].points = points; // redraw path { - QGraphicsPathItem * pathItem = static_cast(items()[0]); - pathItem->setPath(pointsToPath(paths[0])); + QGraphicsPathItem * pathItem = static_cast(items()[m_isCursorShown ? 1 : 0]); + pathItem->setPath(pointsToPath(paths[0].points)); } emit pathChanged(); } +int DrawMapScene::pointsCount() +{ + int cnt = 0; + foreach(PathParams p, paths) + cnt += p.points.size(); + + return cnt; +} + QPainterPath DrawMapScene::pointsToPath(const QList points) { QPainterPath path; @@ -246,8 +346,18 @@ path.moveTo(p); foreach(QPoint p, points) - path.lineTo(p); + path.lineTo(p); } return path; } + +quint8 DrawMapScene::serializePenWidth(int width) +{ + return (width - 6) / 10; +} + +int DrawMapScene::deserializePenWidth(quint8 width) +{ + return width * 10 + 6; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/drawmapscene.h --- a/QTfrontend/drawmapscene.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/drawmapscene.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,41 +21,61 @@ #include #include +#include class QGraphicsPathItem; -typedef QList > Paths; +struct PathParams +{ + quint8 width; + bool erasing; + QList points; +}; + +typedef QList Paths; class DrawMapScene : public QGraphicsScene { -Q_OBJECT -public: - explicit DrawMapScene(QObject *parent = 0); + Q_OBJECT + public: + explicit DrawMapScene(QObject *parent = 0); + + QByteArray encode(); + void decode(QByteArray data); + int pointsCount(); - QByteArray encode(); - void decode(QByteArray data); + signals: + void pathChanged(); -signals: - void pathChanged(); + public slots: + void undo(); + void clearMap(); + void simplifyLast(); + void setErasing(bool erasing); + void showCursor(); + void hideCursor(); -public slots: - void undo(); - void clearMap(); - void simplifyLast(); + private: + QPen m_pen; + QBrush m_eraser; + QBrush m_brush; + QGraphicsPathItem * m_currPath; + Paths paths; + Paths oldPaths; + bool m_isErasing; + QList oldItems; + QGraphicsEllipseItem * m_cursor; + bool m_isCursorShown; -private: - QPen m_pen; - QBrush m_brush; - QGraphicsPathItem * m_currPath; - Paths paths; - Paths oldPaths; - QList oldItems; + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); + virtual void wheelEvent(QGraphicsSceneWheelEvent *); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); - virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); + QPainterPath pointsToPath(const QList points); - QPainterPath pointsToPath(const QList points); + quint8 serializePenWidth(int width); + int deserializePenWidth(quint8 width); }; #endif // DRAWMAPSCENE_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/game.cpp --- a/QTfrontend/game.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/game.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ #include #include #include +#include #include "game.h" #include "hwconsts.h" @@ -29,15 +30,17 @@ #include "teamselect.h" #include "KB.h" #include "proto.h" +#include "campaign.h" #include +#include "ThemeModel.h" -QString training, campaign; // TODO: Cleaner solution? +QString training, campaign, campaignScript, campaignTeam; // TODO: Cleaner solution? HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) : - TCPBase(true), - ammostr(ammo), - m_pTeamSelWidget(pTeamSelWidget) + TCPBase(true), + ammostr(ammo), + m_pTeamSelWidget(pTeamSelWidget) { this->config = config; this->gamecfg = gamecfg; @@ -51,21 +54,22 @@ void HWGame::onClientDisconnect() { - switch (gameType) { - case gtSave: - if (gameState == gsInterrupted || gameState == gsHalted) - emit HaveRecord(false, demo); - else if (gameState == gsFinished) - emit HaveRecord(true, demo); - break; + switch (gameType) + { case gtDemo: + // for video recording we need demo anyway + emit HaveRecord(rtNeither, demo); break; case gtNet: - emit HaveRecord(true, demo); + emit HaveRecord(rtDemo, demo); break; default: - if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo); - else if (gameState == gsFinished) emit HaveRecord(true, demo); + if (gameState == gsInterrupted || gameState == gsHalted) + emit HaveRecord(rtSave, demo); + else if (gameState == gsFinished) + emit HaveRecord(rtDemo, demo); + else + emit HaveRecord(rtNeither, demo); } SetGameState(gsStopped); } @@ -74,7 +78,8 @@ { QByteArray buf; QString gt; - switch (gameType) { + switch (gameType) + { case gtDemo: gt = "TD"; break; @@ -96,9 +101,9 @@ HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber))); HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber))); HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber))); - if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); + if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore")); HWProto::addStringListToBuffer(buf, - team.teamGameConfig(gamecfg->getInitHealth())); + team.teamGameConfig(gamecfg->getInitHealth())); ; } } @@ -113,29 +118,32 @@ void HWGame::SendQuickConfig() { QByteArray teamscfg; + ThemeModel * themeModel = DataManager::instance().themeModel(); HWProto::addStringToBuffer(teamscfg, "TL"); HWProto::addStringToBuffer(teamscfg, QString("etheme %1") - .arg((themesModel->rowCount() > 0) ? themesModel->index(rand() % themesModel->rowCount()).data().toString() : "steel")); + .arg((themeModel->rowCount() > 0) ? themeModel->index(rand() % themeModel->rowCount()).data().toString() : "steel")); HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); + HWProto::addStringToBuffer(teamscfg, "e$template_filter 2"); + HWTeam team1; team1.setDifficulty(0); - team1.setColor(QColor(colors[0])); + team1.setColor(0); team1.setNumHedgehogs(4); HWNamegen::teamRandomNames(team1,true); HWProto::addStringListToBuffer(teamscfg, - team1.teamGameConfig(100)); + team1.teamGameConfig(100)); HWTeam team2; team2.setDifficulty(4); - team2.setColor(QColor(colors[1])); + team2.setColor(1); team2.setNumHedgehogs(4); do HWNamegen::teamRandomNames(team2,true); while(!team2.name().compare(team1.name()) || !team2.hedgehog(0).Hat.compare(team1.hedgehog(0).Hat)); HWProto::addStringListToBuffer(teamscfg, - team2.teamGameConfig(100)); + team2.teamGameConfig(100)); HWProto::addStringToBuffer(teamscfg, QString("eammloadt %1").arg(cDefaultAmmoStore->mid(0, cAmmoNumber))); HWProto::addStringToBuffer(teamscfg, QString("eammprob %1").arg(cDefaultAmmoStore->mid(cAmmoNumber, cAmmoNumber))); @@ -150,7 +158,7 @@ { QByteArray traincfg; HWProto::addStringToBuffer(traincfg, "TL"); - + HWProto::addStringToBuffer(traincfg, "eseed " + QUuid::createUuid().toString()); HWProto::addStringToBuffer(traincfg, "escript " + training); RawSendIPC(traincfg); @@ -160,8 +168,9 @@ { QByteArray campaigncfg; HWProto::addStringToBuffer(campaigncfg, "TL"); + HWProto::addStringToBuffer(campaigncfg, "eseed " + QUuid::createUuid().toString()); - HWProto::addStringToBuffer(campaigncfg, "escript " + campaign); + HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript); RawSendIPC(campaigncfg); } @@ -173,48 +182,61 @@ void HWGame::ParseMessage(const QByteArray & msg) { - switch(msg.at(1)) { - case '?': { + switch(msg.at(1)) + { + case '?': + { SendIPC("!"); break; } - case 'C': { - switch (gameType) { - case gtLocal: { + case 'C': + { + switch (gameType) + { + case gtLocal: + { SendConfig(); break; } - case gtQLocal: { + case gtQLocal: + { SendQuickConfig(); break; } case gtSave: - case gtDemo: break; - case gtNet: { + case gtDemo: + break; + case gtNet: + { SendNetConfig(); break; } - case gtTraining: { + case gtTraining: + { SendTrainingConfig(); break; } - case gtCampaign: { + case gtCampaign: + { SendCampaignConfig(); break; } } break; } - case 'E': { + case 'E': + { int size = msg.size(); emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); return; } - case 'K': { + case 'K': + { ulong kb = msg.mid(2).toULong(); - if (kb==1) { - qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); - return; + if (kb==1) + { + qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); + return; } if (kb && kb <= KBmsgsCount) { @@ -222,23 +244,28 @@ } return; } - case 'i': { + case 'i': + { emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); break; } - case 'Q': { + case 'Q': + { SetGameState(gsInterrupted); break; } - case 'q': { + case 'q': + { SetGameState(gsFinished); break; } - case 'H': { + case 'H': + { SetGameState(gsHalted); break; } - case 's': { + case 's': + { int size = msg.size(); QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); emit SendChat(msgbody); @@ -248,13 +275,23 @@ demo.append(buf); break; } - case 'b': { + case 'b': + { int size = msg.size(); QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); emit SendTeamMessage(msgbody); break; } - default: { + case 'V': + { + if (msg.at(2) == '?') + sendCampaignVar(msg.right(msg.size() - 3)); + else if (msg.at(2) == '!') + writeCampaignVar(msg.right(msg.size() - 3)); + break; + } + default: + { if (gameType == gtNet && !netSuspend) { emit SendNet(msg); @@ -367,10 +404,12 @@ SetGameState(gsStarted); } -void HWGame::StartCampaign(const QString & file) +void HWGame::StartCampaign(const QString & camp, const QString & campScript, const QString & campTeam) { gameType = gtCampaign; - campaign = "Missions/Campaign/" + file + ".lua"; + campaign = camp; + campaignScript = "Missions/Campaign/" + camp + "/" + campScript; + campaignTeam = campTeam; demo.clear(); Start(); SetGameState(gsStarted); @@ -380,6 +419,10 @@ { gameState = state; emit GameStateChanged(state); + if (gameType == gtCampaign) + { + emit CampStateChanged(1); + } } void HWGame::abort() @@ -388,3 +431,29 @@ HWProto::addStringToBuffer(buf, QString("efinish")); RawSendIPC(buf); } + +void HWGame::sendCampaignVar(const QByteArray &varToSend) +{ + QString varToFind(varToSend); + QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0); + teamfile.setIniCodec("UTF-8"); + QString varValue = teamfile.value("Campaign " + campaign + "/" + varToFind, "").toString(); + QByteArray command; + HWProto::addStringToBuffer(command, "V." + varValue); + RawSendIPC(command); +} + +void HWGame::writeCampaignVar(const QByteArray & varVal) +{ + int i = varVal.indexOf(" "); + if(i < 0) + return; + + QString varToWrite = QString::fromUtf8(varVal.left(i)); + QString varValue = QString::fromUtf8(varVal.mid(i + 1)); + + QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0); + teamfile.setIniCodec("UTF-8"); + teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue); +} + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/game.h --- a/QTfrontend/game.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/game.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,8 @@ class GameCFGWidget; class TeamSelWidget; -enum GameState { +enum GameState +{ gsNotStarted = 0, gsStarted = 1, gsInterrupted = 2, @@ -39,68 +40,79 @@ gsHalted = 6 }; +enum RecordType +{ + rtDemo, + rtSave, + rtNeither, +}; + bool checkForDir(const QString & dir); class HWGame : public TCPBase { - Q_OBJECT -public: - HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); - virtual ~HWGame(); - void AddTeam(const QString & team); - void PlayDemo(const QString & demofilename, bool isSave); - void StartLocal(); - void StartQuick(); - void StartNet(); - void StartTraining(const QString & file); - void StartCampaign(const QString & file); - void abort(); - GameState gameState; - bool netSuspend; + Q_OBJECT + public: + HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); + virtual ~HWGame(); + void AddTeam(const QString & team); + void PlayDemo(const QString & demofilename, bool isSave); + void StartLocal(); + void StartQuick(); + void StartNet(); + void StartTraining(const QString & file); + void StartCampaign(const QString & camp, const QString & campScript, const QString & campTeam); + void abort(); + GameState gameState; + bool netSuspend; - protected: - virtual QStringList getArguments(); - virtual void onClientRead(); - virtual void onClientDisconnect(); + protected: + virtual QStringList getArguments(); + virtual void onClientRead(); + virtual void onClientDisconnect(); -signals: - void SendNet(const QByteArray & msg); - void SendChat(const QString & msg); - void SendTeamMessage(const QString & msg); - void GameStateChanged(GameState gameState); - void GameStats(char type, const QString & info); - void HaveRecord(bool isDemo, const QByteArray & record); - void ErrorMessage(const QString &); + signals: + void SendNet(const QByteArray & msg); + void SendChat(const QString & msg); + void SendTeamMessage(const QString & msg); + void GameStateChanged(GameState gameState); + void GameStats(char type, const QString & info); + void HaveRecord(RecordType type, const QByteArray & record); + void ErrorMessage(const QString &); + void CampStateChanged(int); -public slots: - void FromNet(const QByteArray & msg); - void FromNetChat(const QString & msg); + public slots: + void FromNet(const QByteArray & msg); + void FromNetChat(const QString & msg); -private: - enum GameType { - gtLocal = 1, - gtQLocal = 2, - gtDemo = 3, - gtNet = 4, - gtTraining = 5, - gtCampaign = 6, - gtSave = 7, - }; - char msgbuf[MAXMSGCHARS]; - QString ammostr; - GameUIConfig * config; - GameCFGWidget * gamecfg; - TeamSelWidget* m_pTeamSelWidget; - GameType gameType; + private: + enum GameType + { + gtLocal = 1, + gtQLocal = 2, + gtDemo = 3, + gtNet = 4, + gtTraining = 5, + gtCampaign = 6, + gtSave = 7, + }; + char msgbuf[MAXMSGCHARS]; + QString ammostr; + GameUIConfig * config; + GameCFGWidget * gamecfg; + TeamSelWidget* m_pTeamSelWidget; + GameType gameType; - void commonConfig(); - void SendConfig(); - void SendQuickConfig(); - void SendNetConfig(); - void SendTrainingConfig(); - void SendCampaignConfig(); - void ParseMessage(const QByteArray & msg); - void SetGameState(GameState state); + void commonConfig(); + void SendConfig(); + void SendQuickConfig(); + void SendNetConfig(); + void SendTrainingConfig(); + void SendCampaignConfig(); + void ParseMessage(const QByteArray & msg); + void SetGameState(GameState state); + void sendCampaignVar(const QByteArray & varToSend); + void writeCampaignVar(const QByteArray &varVal); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/gameuiconfig.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,20 +16,32 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include #include #include #include #include #include +#include +#include +#include #include "gameuiconfig.h" #include "hwform.h" #include "pageoptions.h" +#include "pagevideos.h" #include "pagenetserver.h" #include "hwconsts.h" #include "fpsedit.h" #include "HWApplication.h" +#include "DataManager.h" + + +const QNetworkProxy::ProxyType proxyTypesMap[] = { + QNetworkProxy::NoProxy + , QNetworkProxy::NoProxy // dummy value + , QNetworkProxy::Socks5Proxy + , QNetworkProxy::HttpProxy}; + GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName) : QSettings(fileName, QSettings::IniFormat) @@ -41,13 +53,20 @@ //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt()); resizeToConfigValues(); + reloadValues(); + reloadVideosValues(); +} + +void GameUIConfig::reloadValues(void) +{ Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool()); int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString()); - if (t < 0) { + if (t < 0) + { if (Form->ui.pageOptions->CBResolution->count() > 1) Form->ui.pageOptions->CBResolution->setCurrentIndex(1); - else + else Form->ui.pageOptions->CBResolution->setCurrentIndex(0); } else Form->ui.pageOptions->CBResolution->setCurrentIndex(t); @@ -58,7 +77,7 @@ Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt()); Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt()); - Form->ui.pageOptions->CBFrontendEffects->setChecked(frontendEffects); + Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("frontend/effects", true).toBool()); Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool()); Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("frontend/sound", true).toBool()); Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool()); @@ -67,11 +86,18 @@ QString netNick = value("net/nick", "").toString(); Form->ui.pageOptions->editNetNick->setText(netNick); - + bool savePwd = value("net/savepassword",true).toBool(); + Form->ui.pageOptions->CBSavePassword->setChecked(savePwd); + Form->ui.pageOptions->editNetPassword->installEventFilter(this); - + int passLength = value("net/passwordlength", 0).toInt(); setNetPasswordLength(passLength); + if (savePwd == false) { + Form->ui.pageOptions->editNetPassword->setEnabled(savePwd); + Form->ui.pageOptions->editNetPassword->setText(""); + setNetPasswordLength(0); + } delete netHost; netHost = new QString(value("net/ip", "").toString()); @@ -87,14 +113,50 @@ Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool()); #ifdef SPARKLE_ENABLED - Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool()); + Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool()); #endif Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString())); + Form->ui.pageOptions->cbProxyType->setCurrentIndex(value("proxy/type", 0).toInt()); + Form->ui.pageOptions->leProxy->setText(value("proxy/host", "").toString()); + Form->ui.pageOptions->sbProxyPort->setValue(value("proxy/port", "8080").toInt()); + Form->ui.pageOptions->leProxyLogin->setText(value("proxy/login", "").toString()); + Form->ui.pageOptions->leProxyPassword->setText(value("proxy/password", "").toString()); + depth = HWApplication::desktop()->depth(); if (depth < 16) depth = 16; else if (depth > 16) depth = 32; + + { // load colors + QStandardItemModel * model = DataManager::instance().colorsModel(); + for(int i = model->rowCount() - 1; i >= 0; --i) + model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data().value()).value())); + } +} + +void GameUIConfig::reloadVideosValues(void) +{ + Form->ui.pageVideos->framerateBox->setValue(value("videorec/fps",25).toUInt()); + Form->ui.pageVideos->bitrateBox->setValue(value("videorec/bitrate",400).toUInt()); + bool useGameRes = value("videorec/usegameres",true).toBool(); + if (useGameRes) + { + QRect res = vid_Resolution(); + Form->ui.pageVideos->widthEdit->setText(QString::number(res.width())); + Form->ui.pageVideos->heightEdit->setText(QString::number(res.height())); + } + else + { + Form->ui.pageVideos->widthEdit->setText(value("videorec/width","800").toString()); + Form->ui.pageVideos->heightEdit->setText(value("videorec/height","600").toString()); + } + Form->ui.pageVideos->checkUseGameRes->setChecked(useGameRes); + Form->ui.pageVideos->checkRecordAudio->setChecked(value("videorec/audio",true).toBool()); + if (!Form->ui.pageVideos->tryCodecs(value("videorec/format","no").toString(), + value("videorec/videocodec","no").toString(), + value("videorec/audiocodec","no").toString())) + Form->ui.pageVideos->setDefaultCodecs(); } QStringList GameUIConfig::GetTeamsList() @@ -103,16 +165,17 @@ teamdir.cd(cfgdir->absolutePath() + "/Teams"); QStringList teamslist = teamdir.entryList(QStringList("*.hwt"),QDir::Files|QDir::Hidden); QStringList cleanedList; - for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { - QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1"); - cleanedList.push_back(tmpTeamStr); + for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) + { + QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.hwt$"), "\\1"); + cleanedList.push_back(tmpTeamStr); } return cleanedList; } void GameUIConfig::resizeToConfigValues() { - Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt()); + Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt()); } void GameUIConfig::SaveOptions() @@ -130,11 +193,14 @@ bool ffscr = isFrontendFullscreen(); setValue("frontend/fullscreen", ffscr); emit frontendFullscreen(ffscr); - if (!ffscr) { - setValue("frontend/width", Form->width()); - setValue("frontend/height", Form->height()); - } else { - //resizeToConfigValues(); // TODO: why this has been made? + if (!ffscr) + { + setValue("frontend/width", Form->width()); + setValue("frontend/height", Form->height()); + } + else + { + //resizeToConfigValues(); // TODO: why this has been made? } setValue("audio/sound", isSoundEnabled()); @@ -144,11 +210,12 @@ setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); setValue("net/nick", netNick()); - if (netPasswordIsValid()) + if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) { setValue("net/passwordhash", netPasswordHash()); setValue("net/passwordlength", netPasswordLength()); } + setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked()); setValue("net/ip", *netHost); setValue("net/port", netPort); setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text()); @@ -156,14 +223,67 @@ setValue("fps/show", isShowFPSEnabled()); setValue("fps/limit", Form->ui.pageOptions->fpsedit->value()); - + setValue("misc/altdamage", isAltDamageEnabled()); setValue("misc/appendTimeToRecords", appendDateTimeToRecordName()); setValue("misc/locale", language()); #ifdef SPARKLE_ENABLED - setValue("misc/autoUpdate", isAutoUpdateEnabled()); + setValue("misc/autoUpdate", isAutoUpdateEnabled()); #endif + + { // setup proxy + int proxyType = Form->ui.pageOptions->cbProxyType->currentIndex(); + setValue("proxy/type", proxyType); + + if(proxyType == PageOptions::Socks5Proxy || proxyType == PageOptions::HTTPProxy) + { + setValue("proxy/host", Form->ui.pageOptions->leProxy->text()); + setValue("proxy/port", Form->ui.pageOptions->sbProxyPort->value()); + setValue("proxy/login", Form->ui.pageOptions->leProxyLogin->text()); + setValue("proxy/password", Form->ui.pageOptions->leProxyPassword->text()); + } + + QNetworkProxy proxy; + + if(proxyType == PageOptions::SystemProxy) + { + // use system proxy settings + proxy = QNetworkProxyFactory::systemProxyForQuery().at(0); + } else + { + proxy.setType(proxyTypesMap[proxyType]); + proxy.setHostName(Form->ui.pageOptions->leProxy->text()); + proxy.setPort(Form->ui.pageOptions->sbProxyPort->value()); + proxy.setUser(Form->ui.pageOptions->leProxyLogin->text()); + proxy.setPassword(Form->ui.pageOptions->leProxyPassword->text()); + } + + QNetworkProxy::setApplicationProxy(proxy); + } + + { // save colors + QStandardItemModel * model = DataManager::instance().colorsModel(); + for(int i = model->rowCount() - 1; i >= 0; --i) + setValue(QString("colors/color%1").arg(i), model->item(i)->data()); + } + + Form->gameSettings->sync(); +} + +void GameUIConfig::SaveVideosOptions() +{ + QRect res = rec_Resolution(); + setValue("videorec/format", AVFormat()); + setValue("videorec/videocodec", videoCodec()); + setValue("videorec/audiocodec", audioCodec()); + setValue("videorec/fps", rec_Framerate()); + setValue("videorec/bitrate", rec_Bitrate()); + setValue("videorec/width", res.width()); + setValue("videorec/height", res.height()); + setValue("videorec/usegameres", Form->ui.pageVideos->checkUseGameRes->isChecked()); + setValue("videorec/audio", recordAudio()); + Form->gameSettings->sync(); } @@ -204,47 +324,48 @@ quint32 rqClampLess = 0x00000200; // don't clamp textures quint32 rqTooltipsOff = 0x00000400; // tooltips are not drawn quint32 rqDesyncVBlank = 0x00000800; // don't sync on vblank - + quint32 result = (Form->ui.pageOptions->WeaponTooltip->isChecked()) ? rqNone : rqTooltipsOff; - - switch (Form->ui.pageOptions->SLQuality->value()) { - case 5: - break; - case 4: - result |= rqBlurryLand; - break; - case 3: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash; - break; - case 2: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu; - break; - case 1: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank; - break; - case 0: - result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | - rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank | - rqNoBackground | rqClampLess; - break; - default: - fprintf(stderr,"unset value from slider"); - break; + + switch (Form->ui.pageOptions->SLQuality->value()) + { + case 5: + break; + case 4: + result |= rqBlurryLand; + break; + case 3: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash; + break; + case 2: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu; + break; + case 1: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank; + break; + case 0: + result |= rqBlurryLand | rqKillFlakes | rqPlainSplash | rq2DWater | + rqAntiBoom | rqSlowMenu | rqSimpleRope | rqDesyncVBlank | + rqNoBackground | rqClampLess; + break; + default: + fprintf(stderr,"unset value from slider"); + break; } - + return result; } bool GameUIConfig::isFrontendEffects() const { - return Form->ui.pageOptions->CBFrontendEffects->isChecked(); + return Form->ui.pageOptions->CBFrontendEffects->isChecked(); } bool GameUIConfig::isFrontendFullscreen() const { - return Form->ui.pageOptions->CBFrontendFullscreen->isChecked(); + return Form->ui.pageOptions->CBFrontendFullscreen->isChecked(); } bool GameUIConfig::isSoundEnabled() @@ -314,7 +435,7 @@ QByteArray GameUIConfig::netPasswordHash() { - return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toLatin1(), QCryptographicHash::Md5).toHex(); + return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex(); } int GameUIConfig::netPasswordLength() @@ -340,7 +461,7 @@ } } } - + // Don't filter anything return false; } @@ -361,3 +482,43 @@ { return Form->ui.pageOptions->volumeBox->value() * 128 / 100; } + +QString GameUIConfig::AVFormat() +{ + return Form->ui.pageVideos->format(); +} + +QString GameUIConfig::videoCodec() +{ + return Form->ui.pageVideos->videoCodec(); +} + +QString GameUIConfig::audioCodec() +{ + return Form->ui.pageVideos->audioCodec(); +} + +QRect GameUIConfig::rec_Resolution() +{ + if (Form->ui.pageVideos->checkUseGameRes->isChecked()) + return vid_Resolution(); + QRect res(0,0,0,0); + res.setWidth(Form->ui.pageVideos->widthEdit->text().toUInt()); + res.setHeight(Form->ui.pageVideos->heightEdit->text().toUInt()); + return res; +} + +int GameUIConfig::rec_Framerate() +{ + return Form->ui.pageVideos->framerateBox->value(); +} + +int GameUIConfig::rec_Bitrate() +{ + return Form->ui.pageVideos->bitrateBox->value(); +} + +bool GameUIConfig::recordAudio() +{ + return Form->ui.pageVideos->checkRecordAudio->isChecked(); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/gameuiconfig.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,52 +29,63 @@ class GameUIConfig : public QSettings { - Q_OBJECT + Q_OBJECT -public: - HWForm * Form; - GameUIConfig(HWForm * FormWidgets, const QString & fileName); - QStringList GetTeamsList(); - QRect vid_Resolution(); - bool vid_Fullscreen(); - quint32 translateQuality(); - bool isSoundEnabled(); - bool isFrontendSoundEnabled(); - QString language(); - bool isMusicEnabled(); - bool isFrontendMusicEnabled(); - bool isShowFPSEnabled(); - bool isAltDamageEnabled(); - bool appendDateTimeToRecordName(); - quint8 volume(); - quint8 timerInterval(); - quint8 bitDepth(); - QString netNick(); - QByteArray netPasswordHash(); - int netPasswordLength(); - void setNetPasswordLength(int passwordLength); - bool isReducedQuality() const; - bool isFrontendEffects() const; - bool isFrontendFullscreen() const; - void resizeToConfigValues(); - quint32 stereoMode() const; + public: + HWForm * Form; + GameUIConfig(HWForm * FormWidgets, const QString & fileName); + QStringList GetTeamsList(); + QRect vid_Resolution(); + bool vid_Fullscreen(); + quint32 translateQuality(); + bool isSoundEnabled(); + bool isFrontendSoundEnabled(); + QString language(); + bool isMusicEnabled(); + bool isFrontendMusicEnabled(); + bool isShowFPSEnabled(); + bool isAltDamageEnabled(); + bool appendDateTimeToRecordName(); + quint8 volume(); + quint8 timerInterval(); + quint8 bitDepth(); + QString netNick(); + QByteArray netPasswordHash(); + int netPasswordLength(); + void setNetPasswordLength(int passwordLength); + bool isReducedQuality() const; + bool isFrontendEffects() const; + bool isFrontendFullscreen() const; + void resizeToConfigValues(); + quint32 stereoMode() const; + + QString AVFormat(); + QString videoCodec(); + QString audioCodec(); + QRect rec_Resolution(); + int rec_Framerate(); + int rec_Bitrate(); + bool recordAudio(); #ifdef __APPLE__ #ifdef SPARKLE_ENABLED - bool isAutoUpdateEnabled(); + bool isAutoUpdateEnabled(); #endif #endif + void reloadValues(); + void reloadVideosValues(); - signals: - void frontendFullscreen(bool value); + signals: + void frontendFullscreen(bool value); -public slots: - void SaveOptions(); - void updNetNick(); -private: - bool netPasswordIsValid(); - bool eventFilter(QObject *object, QEvent *event); - quint8 depth; + public slots: + void SaveOptions(); + void SaveVideosOptions(); + void updNetNick(); + private: + bool netPasswordIsValid(); + bool eventFilter(QObject *object, QEvent *event); + quint8 depth; }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/hedgewars.qrc Sun Oct 28 13:28:23 2012 +0100 @@ -1,8 +1,11 @@ ../share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png - res/css/qt.css - res/css/chat.css + res/css/qt.css + res/css/chat.css + res/css/christmas.css + res/css/easter.css + res/css/birthday.css res/hh25x25.png res/hh25x25grey.png res/ammopic.png @@ -34,6 +37,9 @@ res/Multiplayer.png res/Trainings.png res/Background.png + res/BackgroundChristmas.png + res/BackgroundEaster.png + res/BackgroundBirthday.png res/Exit.png res/HedgewarsTitle.png res/LocalPlay.png @@ -50,6 +56,7 @@ res/Load.png res/Save.png res/Record.png + res/Videos.png res/weaponsicon.png res/teamicon.png res/panelbg.png @@ -95,17 +102,11 @@ res/iconRope.png res/dice.png res/Star.png + res/Flake.png + res/Egg.png + res/Confetti.png res/file_save.png res/file_demo.png - res/chat_default.png - res/chat_ignore.png - res/chat_friend.png - res/chat_default_on.png - res/chat_ignore_on.png - res/chat_friend_on.png - res/chat_default_off.png - res/chat_ignore_off.png - res/chat_friend_off.png res/addfriend.png res/remfriend.png res/ignore.png @@ -133,5 +134,16 @@ res/mapMissing.png res/mapCustom.png res/mapMission.png + res/chat/friend.png + res/chat/ignore.png + res/chat/lamp.png + res/chat/hedgehog.png + res/chat/hedgehog_gray.png + res/chat/roomadmin.png + res/chat/roomadmin_gray.png + res/chat/serveradmin.png + res/chat/serveradmin_gray.png + res/chat/lamp_off.png + res/chat/ingame.png diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/hwconsts.cpp.in Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include + #include "hwconsts.h" QString * cProtoVer = new QString("${HEDGEWARS_PROTO_VER}"); @@ -27,15 +29,11 @@ QDir * cfgdir = new QDir(); QDir * datadir = new QDir(); -ThemesModel * themesModel; -QStringList * mapList; -QStringList * scriptList; - bool custom_config = false; bool custom_data = false; int cMaxTeams = 8; -int cMinServerVersion = 0; +int cMinServerVersion = 1; QString * cDefaultAmmoStore = new QString( AMMOLINE_DEFAULT_QT AMMOLINE_DEFAULT_PROB AMMOLINE_DEFAULT_DELAY AMMOLINE_DEFAULT_CRATE ); @@ -71,3 +69,6 @@ bool haveServer = ${HAVE_NETSERVER}; bool isDevBuild = ${HW_DEV}; + +int season = SEASON_NONE; +int years_since_foundation = 0; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/hwconsts.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,6 @@ #include #include -#include "themesmodel.h" extern QString * cProtoVer; extern QString * cVersionString; @@ -39,11 +38,7 @@ extern int cMaxTeams; extern int cMinServerVersion; -class QStringListModel; - -extern ThemesModel * themesModel; -extern QStringList * mapList; -extern QStringList * scriptList; +class QStandardItemModel; extern QString * cDefaultAmmoStore; extern int cAmmoNumber; @@ -56,45 +51,58 @@ extern bool haveServer; extern bool isDevBuild; + +//Current season, SEASON_NONE by default +extern int season; +//On the day of hedgewars birthday (Oct 31st) this variable is assigned +//with number of years past 2004 (foundation of hedgewars) +//Could be used to implement a text/graphic like "This is the xxth birthday of hedgewars" or similar +extern int years_since_foundation; + #endif #define HEDGEHOGS_PER_TEAM 8 -#define AMMOLINE_DEFAULT_QT "939192942219912103223511100120100000021111010101111101" -#define AMMOLINE_DEFAULT_PROB "040504054160065554655446477657666666615551010111541101" -#define AMMOLINE_DEFAULT_DELAY "000000000000020550000004000700400000000022000000060000" -#define AMMOLINE_DEFAULT_CRATE "131111031211111112311411111111111111121111110111111101" +#define AMMOLINE_DEFAULT_QT "93919294221991210322351110012010000002111101010111110101" +#define AMMOLINE_DEFAULT_PROB "04050405416006555465544647765766666661555101011154110101" +#define AMMOLINE_DEFAULT_DELAY "00000000000002055000000400070040000000002200000006000000" +#define AMMOLINE_DEFAULT_CRATE "13111103121111111231141111111111111112111111011111110101" + +#define AMMOLINE_CRAZY_QT "99999999999999999929999999999999992999999999099999920909" +#define AMMOLINE_CRAZY_PROB "11111101111111111111111111111111111111111111011111110101" +#define AMMOLINE_CRAZY_DELAY "00000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_CRAZY_CRATE "13111103121111111231141111111111111112111101011111110101" -#define AMMOLINE_CRAZY_QT "999999999999999999299999999999999929999999990999999209" -#define AMMOLINE_CRAZY_PROB "111111011111111111111111111111111111111111110111111101" -#define AMMOLINE_CRAZY_DELAY "000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_CRAZY_CRATE "131111031211111112311411111111111111121111010111111101" +#define AMMOLINE_PROMODE_QT "90900090000000000000090000000000000000000000000000000001" +#define AMMOLINE_PROMODE_PROB "00000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_PROMODE_DELAY "00000000000002055000000400070040000000002000000000000009" +#define AMMOLINE_PROMODE_CRATE "11111111111111111111111111111111111111111001011111110101" -#define AMMOLINE_PROMODE_QT "909000900000000000000900000000000000000000000000000000" -#define AMMOLINE_PROMODE_PROB "000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_PROMODE_DELAY "000000000000020550000004000700400000000020000000000000" -#define AMMOLINE_PROMODE_CRATE "111111111111111111111111111111111111111110010111111101" +#define AMMOLINE_SHOPPA_QT "00000099000000000000000000000000000000000000000000000000" +#define AMMOLINE_SHOPPA_PROB "44444100442444022101121212224220000000020004000100110000" +#define AMMOLINE_SHOPPA_DELAY "00000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_SHOPPA_CRATE "11111111111111111111111111111111111111111011011111110001" -#define AMMOLINE_SHOPPA_QT "000000990000000000000000000000000000000000000000000000" -#define AMMOLINE_SHOPPA_PROB "444441004424440221011212122242200000000200040001001100" -#define AMMOLINE_SHOPPA_DELAY "000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_SHOPPA_CRATE "111111111111111111111111111111111111111110110111111100" +#define AMMOLINE_CLEAN_QT "10100090000100000110000000000000000000000000000010000000" +#define AMMOLINE_CLEAN_PROB "04050405416006555465544647765766666661555101011154110101" +#define AMMOLINE_CLEAN_DELAY "00000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_CLEAN_CRATE "13111103121111111231141111111111111112111111011111110101" -#define AMMOLINE_CLEAN_QT "101000900001000001100000000000000000000000000000100000" -#define AMMOLINE_CLEAN_PROB "040504054160065554655446477657666666615551010111541101" -#define AMMOLINE_CLEAN_DELAY "000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_CLEAN_CRATE "131111031211111112311411111111111111121111110111111101" +#define AMMOLINE_MINES_QT "00000099000900000003000000000000000000000000000000000000" +#define AMMOLINE_MINES_PROB "00000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_MINES_DELAY "00000000000002055000000400070040000000002000000006000000" +#define AMMOLINE_MINES_CRATE "11111111111111111111111111111111111111111111011111110101" -#define AMMOLINE_MINES_QT "000000990009000000030000000000000000000000000000000000" -#define AMMOLINE_MINES_PROB "000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_MINES_DELAY "000000000000020550000004000700400000000020000000060000" -#define AMMOLINE_MINES_CRATE "111111111111111111111111111111111111111111110111111101" +#define AMMOLINE_PORTALS_QT "90000090020000000021000000000000001100000900000000000000" +#define AMMOLINE_PORTALS_PROB "04050405416006555465544647765766666661555101011154110100" +#define AMMOLINE_PORTALS_DELAY "00000000000002055000000400070040000000002000000006000000" +#define AMMOLINE_PORTALS_CRATE "13111103121111111231141111111111111112111111011111110101" -#define AMMOLINE_PORTALS_QT "900000900200000000210000000000000011000009000000000000" -#define AMMOLINE_PORTALS_PROB "040504054160065554655446477657666666615551010111541101" -#define AMMOLINE_PORTALS_DELAY "000000000000020550000004000700400000000020000000060000" -#define AMMOLINE_PORTALS_CRATE "131111031211111112311411111111111111121111110111111101" - +//Different seasons; assigned to season (int) +#define SEASON_NONE 0 +#define SEASON_CHRISTMAS 2 +#define SEASON_HWBDAY 4 +#define SEASON_EASTER 8 #define NETGAME_DEFAULT_PORT 46631 @@ -108,7 +116,7 @@ 0xffcfcfc4, /. pastel gray ./ \ 0xffbff000, /. lime ./ \ 0xffffef00, /. yellow ./ \ - // add new colors here + // add new colors here 0 }*/ /* #define HW_TEAMCOLOR_ARRAY { 0xffd12b42, /. red ./ \ diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/hwform.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,10 +40,18 @@ #include #include #include +#include +#include + +#if (QT_VERSION >= 0x040600) +#include +#include +#endif #include "hwform.h" #include "game.h" #include "team.h" +#include "campaign.h" #include "teamselect.h" #include "selectWeapon.h" #include "gameuiconfig.h" @@ -62,12 +70,14 @@ #include "pagemultiplayer.h" #include "pagenet.h" #include "pagemain.h" +#include "pagefeedback.h" #include "pagenetserver.h" #include "pagedrawmap.h" #include "pagenettype.h" #include "pagegamestats.h" #include "pageplayrecord.h" #include "pagedata.h" +#include "pagevideos.h" #include "hwconsts.h" #include "newnetclient.h" #include "gamecfgwidget.h" @@ -75,12 +85,17 @@ #include "netudpserver.h" #include "chatwidget.h" #include "input_ip.h" +#include "input_password.h" #include "ammoSchemeModel.h" #include "bgwidget.h" #include "xfire.h" #include "drawmapwidget.h" +#include "mouseoverfilter.h" +#include "roomslistmodel.h" +#include "recorder.h" +#include "playerslistmodel.h" -#include "HWDataManager.h" +#include "DataManager.h" #ifdef __APPLE__ #include "M3Panel.h" @@ -90,22 +105,26 @@ #endif #endif + // I started handing this down to each place it touches, but it was getting ridiculous // and this one flag does not warrant a static class bool frontendEffects = true; QString playerHash; +GameUIConfig* HWForm::config = NULL; +QSettings* HWForm::gameSettings = NULL; + HWForm::HWForm(QWidget *parent, QString styleSheet) - : QMainWindow(parent) - , game(0) - , pnetserver(0) - , pRegisterServer(0) - , editedTeam(0) - , hwnet(0) + : QMainWindow(parent) + , game(0) + , pnetserver(0) + , pRegisterServer(0) + , editedTeam(0) + , hwnet(0) { // set music track SDLInteraction::instance().setMusicTrack( - HWDataManager::instance().findFileForRead("Music/main_theme.ogg") + DataManager::instance().findFileForRead("Music/main_theme.ogg") ); #ifdef USE_XFIRE @@ -113,7 +132,7 @@ #endif gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); frontendEffects = gameSettings->value("frontend/effects", true).toBool(); - playerHash = QString(QCryptographicHash::hash(gameSettings->value("net/nick","").toString().toLatin1(), QCryptographicHash::Md5).toHex()); + playerHash = QString(QCryptographicHash::hash(gameSettings->value("net/nick","").toString().toUtf8(), QCryptographicHash::Md5).toHex()); this->setStyleSheet(styleSheet); ui.setupUi(this); @@ -125,6 +144,7 @@ config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); + ui.pageVideos->init(config); #ifdef __APPLE__ panel = new M3Panel; @@ -141,11 +161,14 @@ connect (hideFrontend, SIGNAL(activated()), this, SLOT(showMinimized())); #else // ctrl+q closes frontend for consistency - QShortcut *closeFrontend = new QShortcut(QKeySequence("Ctrl+Q"), this); + QShortcut * closeFrontend = new QShortcut(QKeySequence("Ctrl+Q"), this); connect (closeFrontend, SIGNAL(activated()), this, SLOT(close())); + //QShortcut * updateData = new QShortcut(QKeySequence("F5"), this); + //connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload())); #endif UpdateTeamsLists(); + InitCampaignPage(); UpdateCampaignPage(0); UpdateWeapons(); @@ -166,7 +189,12 @@ connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); - + +#if 0 + connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); + pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK); +#endif + connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); @@ -176,14 +204,22 @@ connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); + +#ifdef VIDEOREC + connect(ui.pageMain->BtnVideos, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); + pageSwitchMapper->setMapping(ui.pageMain->BtnVideos, ID_PAGE_VIDEOS); +#endif + //connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); //connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); - connect(ui.pageEditTeam, SIGNAL(teamEdited()), this, SLOT(AfterTeamEdit())); + connect(ui.pageFeedback->BtnSend, SIGNAL(clicked()), this, SLOT(SendFeedback())); + + connect(ui.pageEditTeam, SIGNAL(goBack()), this, SLOT(AfterTeamEdit())); connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), - ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); + ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); connect(ui.pageMultiplayer, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); @@ -197,8 +233,7 @@ connect(ui.pageOptions, SIGNAL(newTeamRequested()), this, SLOT(NewTeam())); connect(ui.pageOptions, SIGNAL(editTeamRequested(const QString&)), this, SLOT(EditTeam(const QString&))); connect(ui.pageOptions, SIGNAL(deleteTeamRequested(const QString&)), this, SLOT(DeleteTeam(const QString&))); - connect(ui.pageOptions->btnSave, SIGNAL(clicked()), config, SLOT(SaveOptions())); - connect(ui.pageOptions->btnSave, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageOptions, SIGNAL(goBack()), config, SLOT(SaveOptions())); connect(ui.pageOptions->BtnAssociateFiles, SIGNAL(clicked()), this, SLOT(AssociateFiles())); connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); @@ -207,6 +242,7 @@ connect(ui.pageOptions->SchemeEdit, SIGNAL(clicked()), this, SLOT(GoToEditScheme())); connect(ui.pageOptions->SchemeNew, SIGNAL(clicked()), this, SLOT(GoToNewScheme())); connect(ui.pageOptions->SchemeDelete, SIGNAL(clicked()), this, SLOT(DeleteScheme())); + connect(ui.pageOptions->CBFrontendEffects, SIGNAL(toggled(bool)), this, SLOT(onFrontendEffects(bool)) ); connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); @@ -218,7 +254,7 @@ connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), - ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); + ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); connect(ui.pageNetGame, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes(int)), this, SLOT(GoToScheme(int))); connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(int)), this, SLOT(GoToSelectWeaponSet(int))); @@ -249,12 +285,13 @@ connect(ui.pageCampaign->BtnStartCampaign, SIGNAL(clicked()), this, SLOT(StartCampaign())); connect(ui.pageCampaign->CBTeam, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); + connect(ui.pageCampaign->CBCampaign, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCampaignPage(int))); connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), - ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first + ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), - this, SLOT(UpdateWeapons())); // executed second + this, SLOT(UpdateWeapons())); // executed second //connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), // this, SLOT(GoBack())); // executed third @@ -264,19 +301,35 @@ connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack())); + connect(ui.pageVideos, SIGNAL(goBack()), config, SLOT(SaveVideosOptions())); ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); ui.pageScheme->setModel(ammoSchemeModel); ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel); ui.pageOptions->SchemesName->setModel(ammoSchemeModel); - wBackground = NULL; - if (config->isFrontendEffects()) { - wBackground = new BGWidget(this); - wBackground->setFixedSize(this->width(), this->height()); - wBackground->lower(); - wBackground->init(); - wBackground->startAnimation(); + wBackground = new BGWidget(this); + wBackground->setFixedSize(this->width(), this->height()); + wBackground->lower(); + wBackground->init(); + wBackground->enabled = config->isFrontendEffects(); + wBackground->startAnimation(); + + //Install all eventFilters : + + MouseOverFilter *filter = new MouseOverFilter(); + filter->setUi(&ui); + + QList widgets; + + for (int i=0; i < ui.Pages->count(); i++) + { + widgets = ui.Pages->widget(i)->findChildren(); + + for (int i=0; i < widgets.size(); i++) + { + widgets.at(i)->installEventFilter(filter); + } } PagesStack.push(ID_PAGE_MAIN); @@ -293,26 +346,26 @@ { case HWNewNet::Connecting: // Connecting case HWNewNet::Connected: - xfire_setvalue(XFIRE_STATUS, "Connecting"); - xfire_setvalue(XFIRE_NICKNAME, "-"); - xfire_setvalue(XFIRE_ROOM, "-"); + xfire_setvalue(XFIRE_STATUS, "Connecting"); + xfire_setvalue(XFIRE_NICKNAME, "-"); + xfire_setvalue(XFIRE_ROOM, "-"); case HWNewNet::InLobby: // In lobby - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, "In game lobby"); - break; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, "In game lobby"); + break; case HWNewNet::InRoom: // In room - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); - break; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); + break; case HWNewNet::InGame: // In game - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); - break; + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); + break; default: - break; + break; } } else @@ -328,17 +381,27 @@ void HWForm::onFrontendFullscreen(bool value) { - if (value) - setWindowState(windowState() | Qt::WindowFullScreen); - else { - setWindowState(windowState() & static_cast(!Qt::WindowFullScreen)); - } + if (value) + setWindowState(windowState() | Qt::WindowFullScreen); + else + { + setWindowState(windowState() & static_cast(!Qt::WindowFullScreen)); + } +} + +void HWForm::onFrontendEffects(bool value) +{ + wBackground->enabled = value; + if (value) + wBackground->startAnimation(); + else + wBackground->stopAnimation(); } /* void HWForm::keyReleaseEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Escape) + if (event->key() == Qt::Key_Escape) this->GoBack(); } */ @@ -366,14 +429,16 @@ QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames(); - for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) { + for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) + { (*it)->clear(); for(int i = 0; i < names.size(); ++i) (*it)->addItem(names[i], ui.pageSelectWeapon->pWeapons->getWeaponsString(names[i])); int pos = (*it)->findText("Default"); - if (pos != -1) { + if (pos != -1) + { (*it)->setCurrentIndex(pos); } } @@ -382,13 +447,17 @@ void HWForm::UpdateTeamsLists(const QStringList* editable_teams) { QStringList teamslist; - if(editable_teams) { - teamslist =* editable_teams; - } else { - teamslist = config->GetTeamsList(); + if(editable_teams) + { + teamslist =* editable_teams; + } + else + { + teamslist = config->GetTeamsList(); } - if(teamslist.empty()) { + if(teamslist.empty()) + { HWTeam defaultTeam(tr("DefaultTeam")); defaultTeam.saveToFile(); teamslist.push_back(tr("DefaultTeam")); @@ -457,6 +526,11 @@ GoToPage(ID_PAGE_SCHEME); } +void HWForm::GoToVideos() +{ + GoToPage(ID_PAGE_VIDEOS); +} + void HWForm::OnPageShown(quint8 id, quint8 lastid) { #ifdef USE_XFIRE @@ -466,7 +540,8 @@ { ui.pageDataDownload->fetchList(); } - if (id == ID_PAGE_DRAWMAP) { + if (id == ID_PAGE_DRAWMAP) + { DrawMapScene * scene; if(lastid == ID_PAGE_MULTIPLAYER) scene = ui.pageMultiplayer->gameCFG->pMapContainer->getDrawMapScene(); @@ -476,100 +551,205 @@ ui.pageDrawMap->drawMapWidget->setScene(scene); } - if (lastid == ID_PAGE_DRAWMAP) { + if (lastid == ID_PAGE_DRAWMAP) + { if (id == ID_PAGE_MULTIPLAYER) ui.pageMultiplayer->gameCFG->pMapContainer->mapDrawingFinished(); else ui.pageNetGame->pGameCFG->pMapContainer->mapDrawingFinished(); } - if (id == ID_PAGE_ROOMSLIST) { - if (hwnet && game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills. + if (id == ID_PAGE_ROOMSLIST) + { + if (hwnet && game && game->gameState == gsStarted) // abnormal exit - kick or room destruction - send kills. + { game->netSuspend = true; ui.pageRoomsList->displayWarning(tr("Game aborted")); game->abort(); } } - if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { + if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) + { QStringList tmNames = config->GetTeamsList(); TeamSelWidget* curTeamSelWidget; ui.pageOptions->setTeamOptionsEnabled(false); - if (id == ID_PAGE_MULTIPLAYER) { + if (id == ID_PAGE_MULTIPLAYER) + { curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { + } + else + { curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; } QList teamsList; - for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { + for (QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) + { HWTeam team(*it); team.loadFromFile(); teamsList.push_back(team); } - if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) { // _TEAM - if (editedTeam) { + if (lastid == ID_PAGE_SETUP || lastid == ID_PAGE_DRAWMAP) // _TEAM + { + if (editedTeam) + { curTeamSelWidget->addTeam(*editedTeam); } - } else if (lastid != ID_PAGE_GAMESTATS - && lastid != ID_PAGE_INGAME - && lastid != ID_PAGE_SCHEME - && lastid != ID_PAGE_SELECTWEAPON) { + } + else if (lastid != ID_PAGE_GAMESTATS + && lastid != ID_PAGE_INGAME + && lastid != ID_PAGE_SCHEME + && lastid != ID_PAGE_SELECTWEAPON) + { curTeamSelWidget->resetPlayingTeams(teamsList); } - } else - if (id == ID_PAGE_GAMESTATS) { - ui.pageGameStats->renderStats(); - } + } + else if (id == ID_PAGE_GAMESTATS) + { + ui.pageGameStats->renderStats(); + } - if (id == ID_PAGE_MAIN) { + if (id == ID_PAGE_MAIN) + { ui.pageOptions->setTeamOptionsEnabled(true); } - // load and save ignore/friends lists - if (lastid == ID_PAGE_NETGAME) // leaving a room - ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); - else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby - ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); + if (id == ID_PAGE_SETUP) + { + config->reloadValues(); + } - if (id == ID_PAGE_NETGAME) // joining a room - ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); -// joining the lobby - else if (id == ID_PAGE_ROOMSLIST) - ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); - + if (id == ID_PAGE_VIDEOS ) + { + config->reloadVideosValues(); + } } void HWForm::GoToPage(int id) { + bool stopAnim = false; + int lastid = ui.Pages->currentIndex(); PagesStack.push(ui.Pages->currentIndex()); + OnPageShown(id, lastid); ui.Pages->setCurrentIndex(id); + + + /* if (id == ID_PAGE_DRAWMAP || id == ID_PAGE_GAMESTATS) + stopAnim = true; + This were disabled due to broken flake animations. I believe the more general problems w/ opacity that forced its disable makes blocking these + unnecessary. + */ + +#if (QT_VERSION >= 0x040600) + if (!stopAnim) + { + /**Start animation :**/ + int coeff = 1; +#ifdef false + coeff = 2; + QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id)); + ui.Pages->widget(id)->setGraphicsEffect(effectNew); + + QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(lastid)); + ui.Pages->widget(lastid)->setGraphicsEffect(effectLast); +#endif + // no effects, means 0 effect duration :D + int duration = config->isFrontendEffects() ? 500 : 0; + + //New page animation + animationNewSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos"); + animationNewSlide->setDuration(duration); + animationNewSlide->setStartValue(QPoint(width()/coeff, 0)); + animationNewSlide->setEndValue(QPoint(0, 0)); + animationNewSlide->setEasingCurve(QEasingCurve::OutExpo); + +#ifdef false + animationNewOpacity = new QPropertyAnimation(effectNew, "opacity"); + animationNewOpacity->setDuration(duration); + animationNewOpacity->setStartValue(0.01); + animationNewOpacity->setEndValue(1); + animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo); +#endif + + //Last page animation + ui.Pages->widget(lastid)->setHidden(false); + + animationOldSlide = new QPropertyAnimation(ui.Pages->widget(lastid), "pos"); + animationOldSlide->setDuration(duration); + animationOldSlide->setStartValue(QPoint(0, 0)); + animationOldSlide->setEndValue(QPoint(-width()/coeff, 0)); + animationOldSlide->setEasingCurve(QEasingCurve::OutExpo); + +#ifdef false + animationOldOpacity = new QPropertyAnimation(effectLast, "opacity"); + animationOldOpacity->setDuration(duration); + animationOldOpacity->setStartValue(1); + animationOldOpacity->setEndValue(0.01); + animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo); +#endif + + QParallelAnimationGroup *group = new QParallelAnimationGroup; + group->addAnimation(animationOldSlide); + group->addAnimation(animationNewSlide); +#ifdef false + group->addAnimation(animationOldOpacity); + group->addAnimation(animationNewOpacity); +#endif + + connect(animationOldSlide, SIGNAL(finished()), ui.Pages->widget(lastid), SLOT(hide())); + group->start(); + + /* this is for the situation when the animation below is interrupted by a new animation. For some reason, finished is not being fired */ + for(int i=0;iwidget(i)->hide(); + } +#endif } void HWForm::GoBack() { + bool stopAnim = false; int curid = ui.Pages->currentIndex(); if (curid == ID_PAGE_MAIN) + { + if (!ui.pageVideos->tryQuit(this)) + return; + stopAnim = true; exit(); + } int id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); ui.Pages->setCurrentIndex(id); OnPageShown(id, curid); if (id == ID_PAGE_CONNECTING) + { + stopAnim = true; GoBack(); + } if (id == ID_PAGE_NETSERVER) + { + stopAnim = true; GoBack(); + } if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) + { + stopAnim = true; GoBack(); + } + /*if (curid == ID_PAGE_DRAWMAP) + stopAnim = true; */ if ((!hwnet) || (!hwnet->isInRoom())) if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) + { + stopAnim = true; GoBack(); + } if (curid == ID_PAGE_ROOMSLIST || curid == ID_PAGE_CONNECTING) NetDisconnect(); if (curid == ID_PAGE_NETGAME && hwnet && hwnet->isInRoom()) hwnet->partRoom(); @@ -578,6 +758,74 @@ if (curid == ID_PAGE_SCHEME) ammoSchemeModel->Save(); + +#if (QT_VERSION >= 0x040600) + /**Start animation :**/ + if (curid != 0 && !stopAnim) + { + int coeff = 1; +#ifdef false + coeff = 2; + QGraphicsOpacityEffect *effectNew = new QGraphicsOpacityEffect(ui.Pages->widget(id)); + effectNew->setOpacity(1); + ui.Pages->widget(id)->setGraphicsEffect(effectNew); + + QGraphicsOpacityEffect *effectLast = new QGraphicsOpacityEffect(ui.Pages->widget(curid)); + ui.Pages->widget(curid)->setGraphicsEffect(effectLast); +#endif + // no effects, means 0 effect duration :D + int duration = config->isFrontendEffects() ? 500 : 0; + + //Last page animation + animationOldSlide = new QPropertyAnimation(ui.Pages->widget(id), "pos"); + animationOldSlide->setDuration(duration); + animationOldSlide->setStartValue(QPoint(-width()/coeff, 0)); + animationOldSlide->setEndValue(QPoint(0, 0)); + animationOldSlide->setEasingCurve(QEasingCurve::OutExpo); + +#ifdef false + animationOldOpacity = new QPropertyAnimation(effectLast, "opacity"); + animationOldOpacity->setDuration(duration); + animationOldOpacity->setStartValue(1); + animationOldOpacity->setEndValue(0.01); + animationOldOpacity->setEasingCurve(QEasingCurve::OutExpo); +#endif + //New page animation + ui.Pages->widget(curid)->setHidden(false); + + animationNewSlide = new QPropertyAnimation(ui.Pages->widget(curid), "pos"); + animationNewSlide->setDuration(duration); + animationNewSlide->setStartValue(QPoint(0, 0)); + animationNewSlide->setEndValue(QPoint(width()/coeff, 0)); + animationNewSlide->setEasingCurve(QEasingCurve::OutExpo); + +#ifdef false + animationNewOpacity = new QPropertyAnimation(effectNew, "opacity"); + animationNewOpacity->setDuration(duration); + animationNewOpacity->setStartValue(0.01); + animationNewOpacity->setEndValue(1); + animationNewOpacity->setEasingCurve(QEasingCurve::OutExpo); +#endif + + QParallelAnimationGroup *group = new QParallelAnimationGroup; + group->addAnimation(animationOldSlide); + group->addAnimation(animationNewSlide); +#ifdef false + group->addAnimation(animationOldOpacity); + group->addAnimation(animationNewOpacity); +#endif + + connect(animationNewSlide, SIGNAL(finished()), ui.Pages->widget(curid), SLOT(hide())); + group->start(); + } +#endif + + if (stopAnim) + ui.Pages->widget(curid)->hide(); + +// TODO the whole pages shown and effects stuff should be moved +// out of hwform.cpp and into a subclass of QStackedLayout + } void HWForm::OpenSnapshotFolder() @@ -595,19 +843,19 @@ { // if (eggTimer.elapsed() < 3000){ #ifdef __APPLE__ - panel->showInstallController(); + panel->showInstallController(); #endif - close(); + close(); // TODO reactivate egg -/* } - else - { - QPushButton * btn = findChild("imageButt"); - if (btn) + /* } + else { - btn->setIcon(QIcon(":/res/bonus.png")); - } - } */ + QPushButton * btn = findChild("imageButt"); + if (btn) + { + btn->setIcon(QIcon(":/res/bonus.png")); + } + } */ } void HWForm::IntermediateSetup() @@ -615,16 +863,19 @@ quint8 id=ui.Pages->currentIndex(); TeamSelWidget* curTeamSelWidget; - if(id == ID_PAGE_MULTIPLAYER) { + if(id == ID_PAGE_MULTIPLAYER) + { curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { + } + else + { curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; } QStringList tmnames; foreach(HWTeam team, curTeamSelWidget->getNotPlayingTeams()) - tmnames += team.name(); + tmnames += team.name(); //UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring UpdateTeamsLists(); @@ -648,24 +899,35 @@ void HWForm::AfterTeamEdit() { UpdateTeamsLists(); - GoBack(); + //GoBack(); } void HWForm::DeleteTeam(const QString & teamName) { - ui.pageEditTeam->deleteTeam(teamName); - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel); + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(teamName)); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - UpdateTeamsLists(); + if (reallyDeleteMsg.exec() == QMessageBox::Ok) + { + ui.pageEditTeam->deleteTeam(teamName); + UpdateTeamsLists(); + } } void HWForm::DeleteScheme() { ui.pageScheme->selectScheme->setCurrentIndex(ui.pageOptions->SchemesName->currentIndex()); - if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) { - QMessageBox::warning(0, QMessageBox::tr("Schemes"), QMessageBox::tr("Can not delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); - } else { + if (ui.pageOptions->SchemesName->currentIndex() < ammoSchemeModel->numberOfDefaultSchemes) + { + ShowErrorMessage(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(ui.pageOptions->SchemesName->currentText())); + } + else + { ui.pageScheme->deleteRow(); ammoSchemeModel->Save(); } @@ -688,10 +950,7 @@ QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); if (!curritem) { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list above"), - tr("OK")); + ShowErrorMessage(QMessageBox::tr("Please select a record from the list")); return; } CreateGame(0, 0, 0); @@ -719,24 +978,34 @@ void HWForm::NetPassword(const QString & nick) { - bool ok = false; int passLength = config->value("net/passwordlength", 0).toInt(); QString hash = config->value("net/passwordhash", "").toString(); // If the password is blank, ask the user to enter one in if (passLength == 0) { - QString password = QInputDialog::getText(this, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok); - - if (!ok) { + HWPasswordDialog * hpd = new HWPasswordDialog(this, tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password below\nor pick another nickname in game config:").arg(nick)); + hpd->cbSave->setChecked(config->value("net/savepassword", true).toBool()); + if (hpd->exec() != QDialog::Accepted) + { ForcedDisconnect(tr("No password supplied.")); + delete hpd; return; } - hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); - config->setValue("net/passwordhash", hash); - config->setValue("net/passwordlength", password.size()); - config->setNetPasswordLength(password.size()); + QString password = hpd->lePassword->text(); + hash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex(); + + bool save = hpd->cbSave->isChecked(); + config->setValue("net/savepassword", save); + if (save) // user wants to save password + { + config->setValue("net/passwordhash", hash); + config->setValue("net/passwordlength", password.size()); + config->setNetPasswordLength(password.size()); + } + + delete hpd; } hwnet->SendPasswordHash(hash); @@ -745,10 +1014,11 @@ void HWForm::NetNickTaken(const QString & nick) { bool ok = false; - QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Some one already uses\n your nickname %1\non the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok); + QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Someone already uses your nickname %1 on the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok); - if (!ok || newNick.isEmpty()) { - ForcedDisconnect(tr("No nickname supplied.")); + if (!ok || newNick.isEmpty()) + { + ForcedDisconnect(tr("No nickname supplied.")); return; } @@ -783,7 +1053,7 @@ ui.pageNetGame->displayError(errmsg); break; default: - ui.pageRoomsList->displayError(errmsg); + ui.pageRoomsList->displayError(errmsg); } } @@ -797,7 +1067,8 @@ void HWForm::_NetConnect(const QString & hostName, quint16 port, QString nick) { - if(hwnet) { + if(hwnet) + { hwnet->Disconnect(); delete hwnet; hwnet=0; @@ -807,111 +1078,112 @@ GoToPage(ID_PAGE_CONNECTING); - connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); - connect(hwnet, SIGNAL(connected()), this, SLOT(NetConnected())); - connect(hwnet, SIGNAL(Error(const QString&)), this, SLOT(NetError(const QString&))); - connect(hwnet, SIGNAL(Warning(const QString&)), this, SLOT(NetWarning(const QString&))); - connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); - connect(hwnet, SIGNAL(LeftRoom(const QString&)), this, SLOT(NetLeftRoom(const QString&))); - connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); - connect(hwnet, SIGNAL(RemoveNetTeam(const HWTeam&)), this, SLOT(RemoveNetTeam(const HWTeam&))); - connect(hwnet, SIGNAL(TeamAccepted(const QString&)), this, SLOT(NetTeamAccepted(const QString&))); - connect(hwnet, SIGNAL(AskForPassword(const QString&)), this, SLOT(NetPassword(const QString&))); - connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&))); - connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed())); + connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame()), Qt::QueuedConnection); + connect(hwnet, SIGNAL(connected()), this, SLOT(NetConnected()), Qt::QueuedConnection); + connect(hwnet, SIGNAL(Error(const QString&)), this, SLOT(NetError(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(Warning(const QString&)), this, SLOT(NetWarning(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter()), Qt::QueuedConnection); + connect(hwnet, SIGNAL(LeftRoom(const QString&)), this, SLOT(NetLeftRoom(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(RemoveNetTeam(const HWTeam&)), this, SLOT(RemoveNetTeam(const HWTeam&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(TeamAccepted(const QString&)), this, SLOT(NetTeamAccepted(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(AskForPassword(const QString&)), this, SLOT(NetPassword(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection); //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); + ui.pageRoomsList->chatWidget->setUsersModel(hwnet->lobbyPlayersModel()); + ui.pageNetGame->pChatWidget->setUsersModel(hwnet->roomPlayersModel()); + // rooms list page stuff - connect(hwnet, SIGNAL(roomsList(const QStringList&)), - ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); + ui.pageRoomsList->setModel(hwnet->roomsListModel()); connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList, SLOT(setAdmin(bool))); + ui.pageRoomsList, SLOT(setAdmin(bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); + ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(serverMessage(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&)), Qt::QueuedConnection); connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), - hwnet, SLOT(CreateRoom(const QString&))); + hwnet, SLOT(CreateRoom(const QString&))); connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), - hwnet, SLOT(JoinRoom(const QString&))); + hwnet, SLOT(JoinRoom(const QString&))); // connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), // this, SLOT(NetGameMaster())); // connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), // this, SLOT(NetGameSlave())); connect(ui.pageRoomsList, SIGNAL(askForRoomList()), - hwnet, SLOT(askRoomsList())); + hwnet, SLOT(askRoomsList())); // room status stuff connect(hwnet, SIGNAL(roomMaster(bool)), - this, SLOT(NetGameChangeStatus(bool))); + this, SLOT(NetGameChangeStatus(bool)), Qt::QueuedConnection); // net page stuff connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); - connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), - ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(roomMaster(bool)), - ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); + ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool)), Qt::QueuedConnection); connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToNet(const QString&))); + hwnet, SLOT(chatLineToNet(const QString&))); connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); connect(hwnet, SIGNAL(setMyReadyStatus(bool)), - ui.pageNetGame, SLOT(setReadyStatus(bool))); + ui.pageNetGame, SLOT(setReadyStatus(bool)), Qt::QueuedConnection); // chat widget actions connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); + hwnet, SLOT(kickPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); + hwnet, SLOT(banPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); + hwnet, SLOT(infoPlayer(const QString&))); connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); + hwnet, SLOT(followPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); + hwnet, SLOT(kickPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); + hwnet, SLOT(banPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); + hwnet, SLOT(infoPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); + hwnet, SLOT(followPlayer(const QString&))); // chatting connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToLobby(const QString&))); + hwnet, SLOT(chatLineToLobby(const QString&))); connect(hwnet, SIGNAL(chatStringLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(chatStringLobby(const QString&, const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&, const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&, const QString&))); connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); // nick list stuff connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), - ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); + ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickRemoved(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); + ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), - ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); + ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); + ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&)), Qt::QueuedConnection); // teams selecting stuff connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), - hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); + hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), - hwnet, SLOT(onTeamColorChanged(const HWTeam&))); + hwnet, SLOT(onTeamColorChanged(const HWTeam&))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); + ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); + ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&)), Qt::QueuedConnection); // admin stuff connect(hwnet, SIGNAL(serverMessageNew(const QString&)), ui.pageAdmin, SLOT(serverMessageNew(const QString &))); @@ -931,12 +1203,13 @@ connect(ui.pageNetGame->pGameCFG, SIGNAL(paramChanged(const QString &, const QStringList &)), hwnet, SLOT(onParamChanged(const QString &, const QStringList &))); connect(hwnet, SIGNAL(configAsked()), ui.pageNetGame->pGameCFG, SLOT(fullNetConfig())); - while (nick.isEmpty()) { + while (nick.isEmpty()) + { nick = QInputDialog::getText(this, - QObject::tr("Nickname"), - QObject::tr("Please enter your nickname"), - QLineEdit::Normal, - QDir::home().dirName()); + QObject::tr("Nickname"), + QObject::tr("Please enter your nickname"), + QLineEdit::Normal, + QDir::home().dirName()); config->setValue("net/nick",nick); config->updNetNick(); } @@ -961,6 +1234,7 @@ netPort = hpd->sbPort->value(); NetConnectServer(*netHost, netPort); } + delete hpd; } void HWForm::NetStartServer() @@ -968,10 +1242,10 @@ config->SaveOptions(); pnetserver = new HWNetServer; - if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) + if (!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server")); + ShowErrorMessage(QMessageBox::tr("Unable to start server")); + delete pnetserver; pnetserver = 0; return; @@ -980,8 +1254,8 @@ QTimer::singleShot(250, this, SLOT(AsyncNetServerStart())); pRegisterServer = new HWNetUdpServer(0, - ui.pageNetServer->leServerDescr->text(), - ui.pageNetServer->sbPort->value()); + ui.pageNetServer->leServerDescr->text(), + ui.pageNetServer->sbPort->value()); } void HWForm::AsyncNetServerStart() @@ -991,7 +1265,8 @@ void HWForm::NetDisconnect() { - if(pnetserver) { + if(pnetserver) + { if (pRegisterServer) { pRegisterServer->unregister(); @@ -1009,13 +1284,20 @@ void HWForm::ForcedDisconnect(const QString & reason) { - if(pnetserver) return; // we have server - let it care of all things - if (hwnet) { - QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'))); + if (pnetserver) + return; // we have server - let it care of all things + if (hwnet) + { + QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"')); + ShowErrorMessage(errorStr); + } + while (ui.Pages->currentIndex() != ID_PAGE_NET + && ui.Pages->currentIndex() != ID_PAGE_NETTYPE + && ui.Pages->currentIndex() != ID_PAGE_MAIN) + { + GoBack(); } - if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); } void HWForm::NetConnected() @@ -1043,8 +1325,8 @@ { QString ammo; ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( - ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() - ).toString(); + ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() + ).toString(); CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); @@ -1054,8 +1336,10 @@ void HWForm::GameStateChanged(GameState gameState) { quint8 id = ui.Pages->currentIndex(); - switch(gameState) { - case gsStarted: { + switch(gameState) + { + case gsStarted: + { Music(false); if (wBackground) wBackground->stopAnimation(); if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME); @@ -1069,7 +1353,8 @@ setFocusPolicy(Qt::NoFocus); break; } - case gsFinished: { + case gsFinished: + { //setVisible(true); setFocusPolicy(Qt::StrongFocus); if (id == ID_PAGE_INGAME) GoBack(); @@ -1080,14 +1365,16 @@ if (game) game->netSuspend = false; break; } - default: { + default: + { //setVisible(true); setFocusPolicy(Qt::StrongFocus); quint8 id = ui.Pages->currentIndex(); if (id == ID_PAGE_INGAME || // was room chief and the game was aborted - (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && - (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed || gameState == gsHalted))) { + (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && + (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed || gameState == gsHalted))) + { if (id == ID_PAGE_INGAME) GoBack(); Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); if (wBackground) wBackground->startAnimation(); @@ -1101,56 +1388,65 @@ void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) { game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); + connect(game, SIGNAL(CampStateChanged(int)), this, SLOT(UpdateCampaignPageProgress(int))); connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); - connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); + connect(game, SIGNAL(HaveRecord(RecordType, const QByteArray &)), this, SLOT(GetRecord(RecordType, const QByteArray &))); m_lastDemo = QByteArray(); } void HWForm::ShowErrorMessage(const QString & msg) { - QMessageBox::warning(this, - "Hedgewars", - msg); + QMessageBox msgMsg(this); + msgMsg.setIcon(QMessageBox::Warning); + msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error")); + msgMsg.setText(msg); + msgMsg.setWindowModality(Qt::WindowModal); + msgMsg.exec(); } -void HWForm::GetRecord(bool isDemo, const QByteArray & record) +void HWForm::GetRecord(RecordType type, const QByteArray & record) { - QString filename; - QByteArray demo = record; - QString recordFileName = + if (type != rtNeither) + { + QString filename; + QByteArray demo = record; + QString recordFileName = config->appendDateTimeToRecordName() ? - QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : - "LastRound"; + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : + "LastRound"; - QStringList versionParts = cVersionString->split('-'); - if ( (versionParts.size() == 2) && (!versionParts[1].isEmpty()) && (versionParts[1].contains(':')) ) - recordFileName = recordFileName + "_" + versionParts[1].replace(':','-'); + QStringList versionParts = cVersionString->split('-'); + if ( (versionParts.size() == 2) && (!versionParts[1].isEmpty()) && (versionParts[1].contains(':')) ) + recordFileName = recordFileName + "_" + versionParts[1].replace(':','-'); - if (isDemo) - { - demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); - demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); - demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); - filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; - m_lastDemo = demo; - } else - { - demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); - demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); - filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; + if (type == rtDemo) + { + demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); + demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); + demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); + filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; + m_lastDemo = demo; + } + else + { + demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); + demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); + filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; + } + + QFile demofile(filename); + if (!demofile.open(QIODevice::WriteOnly)) + ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); + else + { + demofile.write(demo); + demofile.close(); + } } - - QFile demofile(filename); - if (!demofile.open(QIODevice::WriteOnly)) - { - ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); - return ; - } - demofile.write(demo); - demofile.close(); + ui.pageVideos->startEncoding(record); } void HWForm::startTraining(const QString & scriptName) @@ -1164,15 +1460,21 @@ { CreateGame(0, 0, 0); - game->StartCampaign(ui.pageCampaign->CBSelect->itemData(ui.pageCampaign->CBSelect->currentIndex()).toString()); + QComboBox *combo = ui.pageCampaign->CBMission; + QString camp = ui.pageCampaign->CBCampaign->currentText(); + unsigned int mNum = combo->count() - combo->currentIndex(); + QString miss = getCampaignScript(camp, mNum); + QString campTeam = ui.pageCampaign->CBTeam->currentText(); + + game->StartCampaign(camp, miss, campTeam); } void HWForm::CreateNetGame() { QString ammo; ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( - ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() - ).toString(); + ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() + ).toString(); CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); @@ -1191,6 +1493,7 @@ xfire_free(); #endif config->SaveOptions(); + config->SaveVideosOptions(); event->accept(); } @@ -1227,19 +1530,21 @@ // disconnect connections first to ensure their inexistance and not to connect twice ui.pageNetGame->BtnStart->disconnect(hwnet); ui.pageNetGame->BtnUpdate->disconnect(hwnet); - ui.pageNetGame->setRoomName(hwnet->getRoom()); ui.pageNetGame->restrictJoins->disconnect(hwnet); ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); + ui.pageNetGame->disconnect(hwnet, SLOT(updateRoomName(const QString&))); + + ui.pageNetGame->setRoomName(hwnet->getRoom()); + connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); - connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), - hwnet, SLOT(updateRoomName(const QString &))); + connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), hwnet, SLOT(updateRoomName(const QString &))); connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), ui.pageNetGame->pGameCFG, SLOT(resendSchemeData()) - ); + ); } } @@ -1283,47 +1588,76 @@ { int w = event->size().width(); int h = event->size().height(); - if (wBackground) { + if (wBackground) + { wBackground->setFixedSize(w, h); wBackground->move(0, 0); } } +void HWForm::InitCampaignPage() +{ + ui.pageCampaign->CBCampaign->clear(); + HWTeam team(ui.pageCampaign->CBTeam->currentText()); + + QStringList entries = DataManager::instance().entryList( + "Missions/Campaign", + QDir::Dirs, + QStringList("[^\\.]*") + ); + + unsigned int n = entries.count(); + for(unsigned int i = 0; i < n; i++) + { + ui.pageCampaign->CBCampaign->addItem(QString(entries[i]), QString(entries[i])); + } +} + + void HWForm::UpdateCampaignPage(int index) { Q_UNUSED(index); HWTeam team(ui.pageCampaign->CBTeam->currentText()); - ui.pageCampaign->CBSelect->clear(); + ui.pageCampaign->CBMission->clear(); + + QString campaignName = ui.pageCampaign->CBCampaign->currentText(); + QStringList missionEntries = getCampMissionList(campaignName); + QString tName = team.name(); + unsigned int n = missionEntries.count(); + unsigned int m = getCampProgress(tName, campaignName); - QStringList entries = HWDataManager::instance().entryList( - "Missions/Campaign", - QDir::Files, - QStringList("*#*.lua") - ); - - unsigned int n = entries.count(); - for(unsigned int i = 0; (i < n) && (i <= team.campaignProgress()); i++) { - ui.pageCampaign->CBSelect->addItem(QString(entries[i]).replace(QRegExp("^(\\d+)#(.+)\\.lua"), QComboBox::tr("Mission") + " \\1: \\2").replace("_", " "), QString(entries[i]).replace(QRegExp("^(.*)\\.lua"), "\\1")); + for (unsigned int i = qMin(m + 1, n); i > 0; i--) + { + ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1])); } } +void HWForm::UpdateCampaignPageProgress(int index) +{ + Q_UNUSED(index); + + int missionIndex = ui.pageCampaign->CBMission->currentIndex(); + UpdateCampaignPage(0); + ui.pageCampaign->CBMission->setCurrentIndex(missionIndex); +} + // used for --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality] QString HWForm::getDemoArguments() { QRect resolution = config->vid_Resolution(); return QString(QString::number(resolution.width()) + " " - + QString::number(resolution.height()) + " " - + QString::number(config->bitDepth()) + " " // bpp - + QString::number(config->volume()) + " " // sound volume - + (config->isMusicEnabled() ? "1" : "0") + " " - + (config->isSoundEnabled() ? "1" : "0") + " " - + config->language() + ".txt " - + (config->vid_Fullscreen() ? "1" : "0") + " " - + (config->isShowFPSEnabled() ? "1" : "0") + " " - + (config->isAltDamageEnabled() ? "1" : "0") + " " - + QString::number(config->timerInterval()) + " " - + QString::number(config->translateQuality())); + + QString::number(resolution.height()) + " " + + QString::number(config->bitDepth()) + " " // bpp + + QString::number(config->volume()) + " " // sound volume + + (config->isMusicEnabled() ? "1" : "0") + " " + + (config->isSoundEnabled() ? "1" : "0") + " " + + config->language() + ".txt " + + (config->vid_Fullscreen() ? "1" : "0") + " " + + (config->isShowFPSEnabled() ? "1" : "0") + " " + + (config->isAltDamageEnabled() ? "1" : "0") + " " + + QString::number(config->timerInterval()) + " " + + QString::number(config->translateQuality())); } void HWForm::AssociateFiles() @@ -1362,8 +1696,17 @@ // hack to add user's settings to hwengine. might be better at this point to read in the file, append it, and write it out to its new home. This assumes no spaces in the data dir path if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 "+cfgdir->absolutePath().replace(" ","\\\\ ").replace("/","\\/")+" \\2 --set-everything "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0; #endif - if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); - else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); + if (success) + { + QMessageBox infoMsg(this); + infoMsg.setIcon(QMessageBox::Information); + infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); + infoMsg.setText(QMessageBox::tr("All file associations have been set")); + infoMsg.setWindowModality(Qt::WindowModal); + infoMsg.exec(); + } + else + ShowErrorMessage(QMessageBox::tr("File association failed.")); } void HWForm::saveDemoWithCustomName() @@ -1375,7 +1718,7 @@ do { fileName = QInputDialog::getText(this, tr("Demo name"), tr("Demo name:")); - + if(!fileName.isEmpty()) { QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; @@ -1389,7 +1732,112 @@ demofile.close(); } } - } while(!fileName.isEmpty() && !ok); + } + while(!fileName.isEmpty() && !ok); } } +void HWForm::SendFeedback() +{ + //Create Xml representation of google code issue first + if (!CreateIssueXml()) + { + ShowErrorMessage(QMessageBox::tr("Please fill out all fields")); + return; + } + + //Google login using fake account (feedback.hedgewars@gmail.com) + nam = new QNetworkAccessManager(this); + connect(nam, SIGNAL(finished(QNetworkReply*)), + this, SLOT(finishedSlot(QNetworkReply*))); + + QUrl url(QString("https://www.google.com/accounts/ClientLogin?" + "accountType=GOOGLE&Email=feedback.hedgewars@gmail.com&Passwd=hwfeedback&service=code&source=HedgewarsFoundation-Hedgewars-") + + (cVersionString?(*cVersionString):QString(""))); + nam->get(QNetworkRequest(url)); + +} + +bool HWForm::CreateIssueXml() +{ + QString summary = ui.pageFeedback->summary->text(); + QString description = ui.pageFeedback->description->toPlainText(); + + //Check if all necessary information is entered + if (summary.isEmpty() || description.isEmpty()) + return false; + + issueXml = + "" + "" + ""; + issueXml.append(summary); + issueXml.append(""); + issueXml.append(description); + issueXml.append("feedback.hedgewars"); + + return true; +} + +void HWForm::finishedSlot(QNetworkReply* reply) +{ + if (reply && reply->error() == QNetworkReply::NoError) + { + QByteArray array = reply->readAll(); + QString str(array); + + if (authToken.length() != 0) + { + + QMessageBox infoMsg(this); + infoMsg.setIcon(QMessageBox::Information); + infoMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Success")); + infoMsg.setText(QMessageBox::tr("Successfully posted the issue on hedgewars.googlecode.com")); + infoMsg.setWindowModality(Qt::WindowModal); + infoMsg.exec(); + + ui.pageFeedback->summary->clear(); + ui.pageFeedback->description->clear(); + authToken = ""; + return; + } + + if (!getAuthToken(str)) + { + ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com")); + return; + } + + QByteArray body(issueXml.toUtf8()); + QNetworkRequest header(QUrl("https://code.google.com/feeds/issues/p/hedgewars/issues/full")); + header.setRawHeader("Content-Length", QString::number(issueXml.length()).toAscii()); + header.setRawHeader("Content-Type", "application/atom+xml"); + header.setRawHeader("Authorization", QString("GoogleLogin auth=%1").arg(authToken).toUtf8()); + nam->post(header, body); + + } + else if (authToken.length() == 0) + ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com")); + else + { + ShowErrorMessage(QMessageBox::tr("Error reporting the issue, please try again later (or visit hedgewars.googlecode.come directly)")); + authToken = ""; + } + +} + +bool HWForm::getAuthToken(QString str) +{ + QRegExp ex("Auth=(.+)"); + + if (-1 == ex.indexIn(str)) + return false; + + authToken = ex.cap(1); + authToken.remove(QChar('\n')); + + return true; +} + + + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/hwform.h --- a/QTfrontend/hwform.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/hwform.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "netserver.h" #include "game.h" @@ -50,131 +55,158 @@ class HWForm : public QMainWindow { - Q_OBJECT + Q_OBJECT -public: - HWForm(QWidget *parent = 0, QString styleSheet = ""); - Ui_HWForm ui; - GameUIConfig * config; - QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though - void updateXfire(); - void PlayDemoQuick(const QString & demofilename); - void exit(); + public: + HWForm(QWidget *parent = 0, QString styleSheet = ""); + Ui_HWForm ui; + static GameUIConfig * config; + static QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though + void updateXfire(); + void PlayDemoQuick(const QString & demofilename); + void exit(); + void setButtonDescription(QString desc); + void backDescription(); + void GoToVideos(); -private slots: - void GoToSaves(); - void GoToDemos(); - void GoToNet(); - void GoToSelectWeapon(); - void GoToSelectWeaponSet(int index); - void GoToSelectNewWeapon(); - void GoToScheme(int index); - void GoToEditScheme(); - void GoToNewScheme(); - void GoToPage(int id); - void GoBack(); - void OpenSnapshotFolder(); - QString getDemoArguments(); - void AssociateFiles(); - void btnExitPressed(); - void IntermediateSetup(); - void NewTeam(); - void EditTeam(const QString & teamName); - void AfterTeamEdit(); - void DeleteTeam(const QString & teamName); - void DeleteScheme(); - void DeleteWeaponSet(); - void SimpleGame(); - void PlayDemo(); - void startTraining(const QString&); - void StartCampaign(); - void NetConnect(); - void NetConnectServer(const QString & host, quint16 port); - void NetConnectOfficialServer(); - void NetStartServer(); - void NetDisconnect(); - void NetConnected(); - void NetError(const QString & errmsg); - void NetWarning(const QString & wrnmsg); - void NetGameEnter(); - void NetPassword(const QString & nick); - void NetNickTaken(const QString & nick); - void NetAuthFailed(); - void NetTeamAccepted(const QString& team); - void AddNetTeam(const HWTeam& team); - void RemoveNetTeam(const HWTeam& team); - void StartMPGame(); - void GameStateChanged(GameState gameState); - void ForcedDisconnect(const QString & reason); - void ShowErrorMessage(const QString &); - void GetRecord(bool isDemo, const QByteArray & record); - void CreateNetGame(); - void UpdateWeapons(); - void onFrontendFullscreen(bool value); - void Music(bool checked); - void UpdateCampaignPage(int index); + private slots: + void GoToSaves(); + void GoToDemos(); + void GoToNet(); + void GoToSelectWeapon(); + void GoToSelectWeaponSet(int index); + void GoToSelectNewWeapon(); + void GoToScheme(int index); + void GoToEditScheme(); + void GoToNewScheme(); + void GoToPage(int id); + void GoBack(); + void OpenSnapshotFolder(); + QString getDemoArguments(); + void AssociateFiles(); + void btnExitPressed(); + void IntermediateSetup(); + void NewTeam(); + void EditTeam(const QString & teamName); + void AfterTeamEdit(); + void DeleteTeam(const QString & teamName); + void DeleteScheme(); + void DeleteWeaponSet(); + void SimpleGame(); + void PlayDemo(); + void startTraining(const QString&); + void StartCampaign(); + void NetConnect(); + void NetConnectServer(const QString & host, quint16 port); + void NetConnectOfficialServer(); + void NetStartServer(); + void NetDisconnect(); + void NetConnected(); + void NetError(const QString & errmsg); + void NetWarning(const QString & wrnmsg); + void NetGameEnter(); + void NetPassword(const QString & nick); + void NetNickTaken(const QString & nick); + void NetAuthFailed(); + void NetTeamAccepted(const QString& team); + void AddNetTeam(const HWTeam& team); + void RemoveNetTeam(const HWTeam& team); + void StartMPGame(); + void GameStateChanged(GameState gameState); + void ForcedDisconnect(const QString & reason); + void ShowErrorMessage(const QString &); + void GetRecord(RecordType type, const QByteArray & record); + void CreateNetGame(); + void UpdateWeapons(); + void onFrontendFullscreen(bool value); + void onFrontendEffects(bool value); + void Music(bool checked); + void UpdateCampaignPage(int index); + void UpdateCampaignPageProgress(int index); + void InitCampaignPage(); + //Starts the transmission process for the feedback + void SendFeedback(); + //Make a xml representation of the issue to be created + bool CreateIssueXml(); + //Called the first time when receiving authorization token from google, + //second time when receiving the response after posting the issue + void finishedSlot(QNetworkReply* reply); + //Filter the auth token from the reply from google + bool getAuthToken(QString str); - void NetGameChangeStatus(bool isMaster); - void NetGameMaster(); - void NetGameSlave(); + void NetGameChangeStatus(bool isMaster); + void NetGameMaster(); + void NetGameSlave(); + + void AsyncNetServerStart(); + void NetLeftRoom(const QString & reason); + void selectFirstNetScheme(); - void AsyncNetServerStart(); - void NetLeftRoom(const QString & reason); - void selectFirstNetScheme(); - - void saveDemoWithCustomName(); + void saveDemoWithCustomName(); + + private: + void _NetConnect(const QString & hostName, quint16 port, QString nick); + void UpdateTeamsLists(const QStringList* editable_teams=0); + void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo); + void closeEvent(QCloseEvent *event); + void CustomizePalettes(); + void resizeEvent(QResizeEvent * event); + //void keyReleaseEvent(QKeyEvent *event); -private: - void _NetConnect(const QString & hostName, quint16 port, QString nick); - void UpdateTeamsLists(const QStringList* editable_teams=0); - void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo); - void closeEvent(QCloseEvent *event); - void CustomizePalettes(); - void resizeEvent(QResizeEvent * event); - //void keyReleaseEvent(QKeyEvent *event); - - enum PageIDs { - ID_PAGE_SETUP_TEAM = 0, - ID_PAGE_SETUP = 1, - ID_PAGE_MULTIPLAYER = 2, - ID_PAGE_DEMOS = 3, - ID_PAGE_NET = 4, - ID_PAGE_NETGAME = 5, - ID_PAGE_INFO = 6, - ID_PAGE_MAIN = 7, - ID_PAGE_GAMESTATS = 8, - ID_PAGE_SINGLEPLAYER = 9, - ID_PAGE_TRAINING = 10, - ID_PAGE_SELECTWEAPON = 11, - ID_PAGE_NETSERVER = 12, - ID_PAGE_INGAME = 13, - ID_PAGE_ROOMSLIST = 14, - ID_PAGE_CONNECTING = 15, - ID_PAGE_SCHEME = 16, - ID_PAGE_ADMIN = 17, - ID_PAGE_NETTYPE = 18, - ID_PAGE_CAMPAIGN = 19, - ID_PAGE_DRAWMAP = 20, - ID_PAGE_DATADOWNLOAD = 21 + enum PageIDs + { + ID_PAGE_SETUP_TEAM , + ID_PAGE_SETUP , + ID_PAGE_MULTIPLAYER , + ID_PAGE_DEMOS , + ID_PAGE_NET , + ID_PAGE_NETGAME , + ID_PAGE_INFO , + ID_PAGE_MAIN , + ID_PAGE_GAMESTATS , + ID_PAGE_SINGLEPLAYER , + ID_PAGE_TRAINING , + ID_PAGE_SELECTWEAPON , + ID_PAGE_NETSERVER , + ID_PAGE_INGAME , + ID_PAGE_ROOMSLIST , + ID_PAGE_CONNECTING , + ID_PAGE_SCHEME , + ID_PAGE_ADMIN , + ID_PAGE_NETTYPE , + ID_PAGE_CAMPAIGN , + ID_PAGE_DRAWMAP , + ID_PAGE_DATADOWNLOAD , + ID_PAGE_FEEDBACK , + ID_PAGE_VIDEOS, + MAX_PAGE }; - QPointer game; - QPointer pnetserver; - QPointer pRegisterServer; - QPointer editedTeam; - QPointer hwnet; - HWNamegen * namegen; - AmmoSchemeModel * ammoSchemeModel; - QStack PagesStack; - QTime eggTimer; - BGWidget * wBackground; - QSignalMapper * pageSwitchMapper; - QByteArray m_lastDemo; + QPointer game; + QPointer pnetserver; + QPointer pRegisterServer; + QPointer editedTeam; + QPointer hwnet; + HWNamegen * namegen; + AmmoSchemeModel * ammoSchemeModel; + QStack PagesStack; + QTime eggTimer; + BGWidget * wBackground; + QSignalMapper * pageSwitchMapper; + QByteArray m_lastDemo; + QNetworkAccessManager * nam; + QString issueXml; + QString authToken; + + QPropertyAnimation *animationNewSlide; + QPropertyAnimation *animationOldSlide; + QPropertyAnimation *animationNewOpacity; + QPropertyAnimation *animationOldOpacity; #ifdef __APPLE__ - InstallController * panel; + InstallController * panel; #endif - void OnPageShown(quint8 id, quint8 lastid=0); + void OnPageShown(quint8 id, quint8 lastid=0); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/main.cpp --- a/QTfrontend/main.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/main.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,13 @@ #include #include #include +#include #include "hwform.h" #include "hwconsts.h" +#include "newnetclient.h" -#include "HWDataManager.h" +#include "DataManager.h" #ifdef _WIN32 #include @@ -39,52 +41,107 @@ #include "CocoaInitializer.h" #endif + +//Determines the day of easter in year +//from http://aa.usno.navy.mil/faq/docs/easter.php,adapted to C/C++ +QDate calculateEaster(long year) +{ + int c, n, k, i, j, l, m, d; + + c = year/100; + n = year - 19*(year/19); + k = (c - 17)/25; + i = c - c/4 - (c - k)/3 + 19*n + 15; + i = i - 30*(i/30); + i = i - (i/28)*(1 - (i/28)*(29/(i + 1))*((21 - n)/11)); + j = year + year/4 + i + 2 - c + c/4; + j = j - 7*(j/7); + l = i - j; + m = 3 + (l + 40)/44; + d = l + 28 - 31*(m / 4); + + return QDate(year, m, d); +} + +//Checks season and assigns it to the variable season in "hwconsts.h" +void checkSeason() +{ + QDate date = QDate::currentDate(); + + //Christmas? + if (date.month() == 12 && date.day() >= 24 + && date.day() <= 26) + season = SEASON_CHRISTMAS; + //Hedgewars birthday? + else if (date.month() == 10 && date.day() == 31) + { + season = SEASON_HWBDAY; + years_since_foundation = date.year() - 2004; + } + //Easter? + else if (calculateEaster(date.year()) == date) + season = SEASON_EASTER; + else + season = SEASON_NONE; +} + bool checkForDir(const QString & dir) { QDir tmpdir; if (!tmpdir.exists(dir)) if (!tmpdir.mkdir(dir)) { - QMessageBox::critical(0, - QObject::tr("Error"), - QObject::tr("Cannot create directory %1").arg(dir), - QObject::tr("OK")); + QMessageBox directoryMsg(QApplication::activeWindow()); + directoryMsg.setIcon(QMessageBox::Warning); + directoryMsg.setWindowTitle(QMessageBox::tr("Main - Error")); + directoryMsg.setText(QMessageBox::tr("Cannot create directory %1").arg(dir)); + directoryMsg.setWindowModality(Qt::WindowModal); + directoryMsg.exec(); return false; } return true; } -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ HWApplication app(argc, argv); + app.setAttribute(Qt::AA_DontShowIconsInMenus,false); QStringList arguments = app.arguments(); QMap parsedArgs; { QList::iterator i = arguments.begin(); - while(i != arguments.end()) { + while(i != arguments.end()) + { QString arg = *i; QRegExp opt("--(\\S+)=(.+)"); - if(opt.exactMatch(arg)) { + if(opt.exactMatch(arg)) + { parsedArgs[opt.cap(1)] = opt.cap(2); i = arguments.erase(i); - } else { - ++i; + } + else + { + ++i; } } } - if(parsedArgs.contains("data-dir")) { + if(parsedArgs.contains("data-dir")) + { QFileInfo f(parsedArgs["data-dir"]); - if(!f.exists()) { + if(!f.exists()) + { qWarning() << "WARNING: Cannot open DATA_PATH=" << f.absoluteFilePath(); } *cDataDir = f.absoluteFilePath(); custom_data = true; } - if(parsedArgs.contains("config-dir")) { + if(parsedArgs.contains("config-dir")) + { QFileInfo f(parsedArgs["config-dir"]); *cConfigDir = f.absoluteFilePath(); custom_config = true; @@ -98,6 +155,8 @@ Q_INIT_RESOURCE(hedgewars); + qRegisterMetaType("HWTeam"); + bindir->cd("bin"); // workaround over NSIS installer if(cConfigDir->length() == 0) @@ -132,20 +191,7 @@ if (checkForDir(cfgdir->absolutePath())) { // alternative loading/lookup paths - // TODO: Uncomment paths as they're implemented checkForDir(cfgdir->absolutePath() + "/Data"); - //checkForDir(cfgdir->absolutePath() + "/Data/Forts"); - //checkForDir(cfgdir->absolutePath() + "/Data/Graphics"); - //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Flags"); - //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Graves"); - //checkForDir(cfgdir->absolutePath() + "/Data/Graphics/Hats"); - //checkForDir(cfgdir->absolutePath() + "/Data/Maps"); - //checkForDir(cfgdir->absolutePath() + "/Data/Missions"); - //checkForDir(cfgdir->absolutePath() + "/Data/Missions/Campaign"); - //checkForDir(cfgdir->absolutePath() + "/Data/Missions/Training"); - //checkForDir(cfgdir->absolutePath() + "/Data/Sounds"); - //checkForDir(cfgdir->absolutePath() + "/Data/Sounds/voices"); - //checkForDir(cfgdir->absolutePath() + "/Data/Themes"); // config/save paths checkForDir(cfgdir->absolutePath() + "/Demos"); @@ -153,78 +199,26 @@ checkForDir(cfgdir->absolutePath() + "/Screenshots"); checkForDir(cfgdir->absolutePath() + "/Teams"); checkForDir(cfgdir->absolutePath() + "/Logs"); + checkForDir(cfgdir->absolutePath() + "/Videos"); + checkForDir(cfgdir->absolutePath() + "/VideoTemp"); } datadir->cd(bindir->absolutePath()); datadir->cd(*cDataDir); - if(!datadir->cd("hedgewars/Data")) { - QMessageBox::critical(0, QMessageBox::tr("Error"), - QMessageBox::tr("Failed to open data directory:\n%1\n" - "Please check your installation"). - arg(datadir->absolutePath()+"/hedgewars/Data")); + if(!datadir->cd("hedgewars/Data")) + { + QMessageBox missingMsg(QApplication::activeWindow()); + missingMsg.setIcon(QMessageBox::Critical); + missingMsg.setWindowTitle(QMessageBox::tr("Main - Error")); + missingMsg.setText(QMessageBox::tr("Failed to open data directory:\n%1\n\n" + "Please check your installation!"). + arg(datadir->absolutePath()+"/hedgewars/Data")); + missingMsg.setWindowModality(Qt::WindowModal); + missingMsg.exec(); return 1; } - HWDataManager & dataMgr = HWDataManager::instance(); - - { - QStringList themes; - - themes.append(dataMgr.entryList( - "Themes", - QDir::AllDirs | QDir::NoDotAndDotDot) - ); - - QList > icons; - - themes.sort(); - for(int i = themes.size() - 1; i >= 0; --i) - { - QString file = dataMgr.findFileForRead( - QString("Themes/%1/icon.png").arg(themes.at(i)) - ); - - if(QFile::exists(file)) - { // load icon - QPair ic; - ic.first = QIcon(file); - - // load preview icon - ic.second = QIcon( - dataMgr.findFileForRead( - QString("Themes/%1/icon@2x.png").arg(themes.at(i)) - ) - ); - - icons.prepend(ic); - } - else - { - themes.removeAt(i); - } - } - - themesModel = new ThemesModel(themes); - Q_ASSERT(themes.size() == icons.size()); - for(int i = 0; i < icons.size(); ++i) - { - themesModel->setData(themesModel->index(i), icons[i].first, Qt::DecorationRole); - themesModel->setData(themesModel->index(i), icons[i].second, Qt::UserRole); - } - } - - mapList = new QStringList(dataMgr.entryList( - QString("Maps"), - QDir::Dirs | QDir::NoDotAndDotDot - ) - ); - - scriptList = new QStringList(dataMgr.entryList( - QString("Scripts/Multiplayer"), - QDir::Files, - QStringList("*.lua") - ) - ); + DataManager & dataMgr = DataManager::instance(); QTranslator Translator; { @@ -257,24 +251,37 @@ #endif QString style = ""; + QString fname; + + checkSeason(); + //For each season, there is an extra stylesheet + //Todo: change background for easter and birthday + //(simply replace res/BackgroundBirthday.png and res/BackgroundEaster.png + //with an appropriate background + switch (season) + { + case SEASON_CHRISTMAS : + fname = "christmas.css"; + break; + case SEASON_EASTER : + fname = "easter.css"; + break; + case SEASON_HWBDAY : + fname = "birthday.css"; + break; + default : + fname = "qt.css"; + } // load external stylesheet if there is any - QFile extFile(dataMgr.findFileForRead("css/qt.css")); + QFile extFile(dataMgr.findFileForRead("css/" + fname)); - QFile resFile(":/res/css/qt.css"); + QFile resFile(":/res/css/" + fname); - QFile & file = (extFile.exists()?extFile:resFile); + QFile & file = (extFile.exists() ? extFile : resFile); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - QTextStream in(&file); - while (!in.atEnd()) - { - QString line = in.readLine(); - if(!line.isEmpty()) - style.append(line); - } - } + style.append(file.readAll()); app.form = new HWForm(NULL, style); app.form->show(); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/GameStyleModel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/GameStyleModel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,98 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief GameStyleModel class implementation + */ + +#include + +#include "GameStyleModel.h" + + +void GameStyleModel::loadGameStyles() +{ + beginResetModel(); + + + // empty list, so that we can (re)fill it + QStandardItemModel::clear(); + + QList items; + items.append(new QStandardItem("Normal")); + + // define a separator item + QStandardItem * separator = new QStandardItem("---"); + separator->setData(QLatin1String("separator"), Qt::AccessibleDescriptionRole); + separator->setFlags(separator->flags() & ~( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) ); + + items.append(separator); + + + QStringList scripts = DataManager::instance().entryList( + QString("Scripts/Multiplayer"), + QDir::Files, + QStringList("*.lua") + ); + + foreach(QString script, scripts) + { + script = script.remove(".lua", Qt::CaseInsensitive); + + QFile scriptCfgFile(DataManager::instance().findFileForRead( + QString("Scripts/Multiplayer/%2.cfg").arg(script))); + + QString name = script; + name = name.replace("_", " "); + + QString scheme = "locked"; + QString weapons = "locked"; + + if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) + { + QTextStream input(&scriptCfgFile); + input >> scheme; + input >> weapons; + scriptCfgFile.close(); + + if (!scheme.isEmpty()) + scheme.replace("_", " "); + + if (!weapons.isEmpty()) + weapons.replace("_", " "); + } + + QStandardItem * item = new QStandardItem(name); + + item->setData(script, ScriptRole); + item->setData(scheme, SchemeRole); + item->setData(weapons, WeaponsRole); + + items.append(item); + } + + QStandardItemModel::appendColumn(items); + + + endResetModel(); +} + + + + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/GameStyleModel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/GameStyleModel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,48 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief GameStyleModel class definition + */ + +#ifndef HEDGEWARS_GAMESTYLEMODEL_H +#define HEDGEWARS_GAMESTYLEMODEL_H + +#include +#include +#include + +#include "DataManager.h" + +/** + * @brief A model listing available game styles + */ +class GameStyleModel : public QStandardItemModel +{ + Q_OBJECT + + public: + enum DataRoles { ScriptRole = Qt::UserRole+1, SchemeRole, WeaponsRole }; + + public slots: + /// reloads the themes from the DataManager + void loadGameStyles(); +}; + +#endif // HEDGEWARS_GAMESTYLEMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/HatModel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/HatModel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,148 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief HatModel class implementation + */ + +#include "HatModel.h" + +#include +#include +#include +#include "hwform.h" // player hash + +#include "DataManager.h" + +HatModel::HatModel(QObject* parent) : + QAbstractListModel(parent) +{ + hats = QVector >(); +} + +void HatModel::loadHats() +{ + // this method resets the contents of this model (important to know for views). + beginResetModel(); + + // prepare hats Vector + hats.clear(); + + DataManager & dataMgr = DataManager::instance(); + + QPixmap hhpix = QPixmap( + dataMgr.findFileForRead("Graphics/Hedgehog/Idle.png") + ).copy(0, 0, 32, 32); + + // my reserved hats + QStringList hatsList = dataMgr.entryList( + "Graphics/Hats/Reserved", + QDir::Files, + QStringList(playerHash+"*.png") + ); + + int nReserved = hatsList.size(); + + // regular hats + hatsList.append(dataMgr.entryList( + "Graphics/Hats", + QDir::Files, + QStringList("*.png") + ) + ); + + + int nHats = hatsList.size(); + + for (int i = 0; i < nHats; i++) + { + bool isReserved = (i < nReserved); + + QString str = hatsList.at(i); + str = str.remove(QRegExp("\\.png$")); + QPixmap pix( + dataMgr.findFileForRead( + "Graphics/Hats/" + QString(isReserved?"Reserved/":"") + str + + ".png" + ) + ); + + // rename properly + if (isReserved) + str = "Reserved "+str.remove(0,32); + + QPixmap tmppix(32, 37); + tmppix.fill(QColor(Qt::transparent)); + + QPainter painter(&tmppix); + painter.drawPixmap(QPoint(0, 5), hhpix); + painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); + if(pix.width() > 32) + painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32)); + painter.end(); + + if (str == "NoHat") + hats.prepend(qMakePair(str, QIcon(tmppix))); + else + hats.append(qMakePair(str, QIcon(tmppix))); + } + + + endResetModel(); +} + +QVariant HatModel::headerData(int section, + Qt::Orientation orientation, int role) const +{ + Q_UNUSED(section); + Q_UNUSED(orientation); + Q_UNUSED(role); + + return QVariant(); +} + +int HatModel::rowCount(const QModelIndex &parent) const +{ + if (parent.isValid()) + return 0; + else + return hats.size(); +} + +/*int HatModel::columnCount(const QModelIndex & parent) const +{ + if (parent.isValid()) + return 0; + else + return 2; +} +*/ +QVariant HatModel::data(const QModelIndex &index, + int role) const +{ + if (!index.isValid() || index.row() < 0 + || index.row() >= hats.size() + || (role != Qt::DisplayRole && role != Qt::DecorationRole)) + return QVariant(); + + if (role == Qt::DisplayRole) + return hats.at(index.row()).first; + else // role == Qt::DecorationRole + return hats.at(index.row()).second; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/HatModel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/HatModel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,53 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief HatModel class definition + */ + +#ifndef HEDGEWARS_HATMODEL_H +#define HEDGEWARS_HATMODEL_H + +#include +#include +#include +#include +#include + +class HatModel : public QAbstractListModel +{ + Q_OBJECT + + public: + HatModel(QObject *parent = 0); + + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + //int columnCount(const QModelIndex & parent) const; + + public slots: + /// Reloads hats using the DataManager. + void loadHats(); + + QVariant data(const QModelIndex &index, int role) const; + protected: + QVector > hats; +}; + +#endif // HEDGEWARS_HATMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/MapModel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/MapModel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,238 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief MapModel class implementation + */ + +#include "MapModel.h" + + +void MapModel::loadMaps() +{ + // this method resets the contents of this model (important to know for views). + beginResetModel(); + + // we'll need the DataManager a few times, so let's get a reference to it + DataManager & datamgr = DataManager::instance(); + + // fetch list of available maps + QStringList maps = + datamgr.entryList("Maps", QDir::AllDirs | QDir::NoDotAndDotDot); + + // empty list, so that we can (re)fill it + QStandardItemModel::clear(); + + QList genMaps; + QList missionMaps; + QList staticMaps; + + // add generated/handdrawn maps to list + // TODO: icons for these + + genMaps.append( + infoToItem(QIcon(), QComboBox::tr("generated map..."), GeneratedMap, "+rnd+")); + genMaps.append( + infoToItem(QIcon(), QComboBox::tr("generated maze..."), GeneratedMaze, "+maze+")); + genMaps.append( + infoToItem(QIcon(), QComboBox::tr("hand drawn map..."), HandDrawnMap, "+drawn+")); + + // only 2 map relate files are relevant: + // - the cfg file that contains the settings/info of the map + // - the lua file - if it exists it's a mission, otherwise it isn't + QFile mapLuaFile; + QFile mapCfgFile; + + // add mission/static maps to lists + foreach (QString map, maps) + { + mapCfgFile.setFileName( + datamgr.findFileForRead(QString("Maps/%1/map.cfg").arg(map))); + mapLuaFile.setFileName( + datamgr.findFileForRead(QString("Maps/%1/map.lua").arg(map))); + + + if (mapCfgFile.open(QFile::ReadOnly)) + { + QString caption; + QString theme; + quint32 limit = 0; + QString scheme; + QString weapons; + // if there is a lua file for this map, then it's a mission + bool isMission = mapLuaFile.exists(); + MapType type = isMission?MissionMap:StaticMap; + + // load map info from file + QTextStream input(&mapCfgFile); + input >> theme; + input >> limit; + if (isMission) { // scheme and weapons are only relevant for missions + input >> scheme; + input >> weapons; + } + mapCfgFile.close(); + + // let's use some semi-sane hedgehog limit, rather than none + if (limit == 0) + limit = 18; + + + // the default scheme/weaponset for missions. + // if empty we assume the map sets these internally -> locked + if (isMission) + { + if (scheme.isEmpty()) + scheme = "locked"; + else + scheme.replace("_", " "); + + if (weapons.isEmpty()) + weapons = "locked"; + else + weapons.replace("_", " "); + } + + // add a mission caption prefix to missions + if (isMission) + { + // TODO: icon + caption = QComboBox::tr("Mission") + ": " + map; + } + else + caption = map; + + // we know everything there is about the map, let's get am item for it + QStandardItem * item = infoToItem( + QIcon(), caption, type, map, theme, limit, scheme, weapons); + + // append item to the list + if (isMission) + missionMaps.append(item); + else + staticMaps.append(item); + + } + + } + + + // define a separator item + QStandardItem separator("---"); + separator.setData(QLatin1String("separator"), Qt::AccessibleDescriptionRole); + separator.setFlags(separator.flags() & ~( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) ); + + // create list: + // generated+handdrawn maps, 2 saperators, missions, 1 separator, static maps + QList items; + items.append(genMaps); + items.append(separator.clone()); + items.append(separator.clone()); + items.append(missionMaps); + items.append(separator.clone()); + items.append(staticMaps); + + + // create row-index lookup table + + m_mapIndexes.clear(); + + int count = items.size(); + + for (int i = 0; i < count; i++) + { + QStandardItem * si = items.at(i); + QVariant v = si->data(Qt::UserRole + 1); + if (v.canConvert()) + m_mapIndexes.insert(v.value().name, i); + } + + + // store start-index and count of relevant types + + m_typeLoc.insert(GeneratedMap, QPair(0, 1)); + m_typeLoc.insert(GeneratedMaze, QPair(1, 1)); + m_typeLoc.insert(HandDrawnMap, QPair(2, 1)); + // mission maps + int startIdx = genMaps.size() + 2; // start after genMaps and 2 separators + count = missionMaps.size(); + m_typeLoc.insert(MissionMap, QPair(startIdx, count)); + // static maps + startIdx += count + 1; // start after missions and 2 separators + count = staticMaps.size(); + m_typeLoc.insert(StaticMap, QPair(startIdx, count)); + + // store list contents in the item model + QStandardItemModel::appendColumn(items); + + + endResetModel(); +} + + +int MapModel::randomMap(MapType type) const +{ + // return a random index for this type or -1 if none available + QPair loc = m_typeLoc.value(type, QPair(-1,0)); + + int startIdx = loc.first; + int count = loc.second; + + if (count < 1) + return -1; + else + return startIdx + (rand() % count); +} + + +QStandardItem * MapModel::infoToItem( + const QIcon & icon, + const QString caption, + MapType type, + QString name, + QString theme, + quint32 limit, + QString scheme, + QString weapons) +const +{ + QStandardItem * item = new QStandardItem(icon, caption); + MapInfo mapInfo; + QVariant qvar(QVariant::UserType); + + mapInfo.type = type; + mapInfo.name = name; + mapInfo.theme = theme; + mapInfo.limit = limit; + mapInfo.scheme = scheme; + mapInfo.weapons = weapons; + + + qvar.setValue(mapInfo); + item->setData(qvar, Qt::UserRole + 1); + + return item; +} + + +int MapModel::indexOf(const QString & map) const +{ + return m_mapIndexes.value(map, -1); +} + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/MapModel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/MapModel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,120 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief MapModel class definition + */ + +#ifndef HEDGEWARS_MAPMODEL_H +#define HEDGEWARS_MAPMODEL_H + +#include +#include +#include +#include +#include +#include +#include + +#include "DataManager.h" + +/** + * @brief A model that vertically lists available maps + * + * @author sheepluva + * @since 0.9.18 + */ +class MapModel : public QStandardItemModel +{ + Q_OBJECT + + public: + enum MapType { + Invalid, + GeneratedMap, + GeneratedMaze, + HandDrawnMap, + MissionMap, + StaticMap + }; + + /// a struct for holding the attributes of a map. + struct MapInfo + { + MapType type; ///< The map-type + QString name; ///< The internal name. + QString theme; ///< The theme to be used. (can be empty) + quint32 limit; ///< The maximum allowed number of hedgehogs. + QString scheme; ///< Default scheme name or "locked", for mission-maps. + QString weapons; ///< Default weaponset name or "locked", for missions-maps. + }; + + /** + * @brief Returns the row-index of the given map. + * @param map map of which to get the row-index of. + * @return row-index of map or -1 if not available. + */ + int indexOf(const QString & map) const; + + /** + * @brief Returns the row-index of a random map with a specified type. + * @param type desired type of map. + * @return row-index of a map with the desired type, -1 if none found. + */ + int randomMap(MapType type) const; + + public slots: + /// Reloads the maps using the DataManager. + void loadMaps(); + + + private: + /// start-index and map count for each map-type. + QMap > m_typeLoc; + + /// map index lookup table + QHash m_mapIndexes; + + /** + * @brief Creates a QStandardItem, that holds the map info and item appearance. + * The used role for the data is Qt::UserRole + 1. + * @param icon the icon to be displayed (can be an empty QIcon()). + * @param caption the text to be displayed. + * @param type the type of the map. + * @param name the internal name of the map. + * @param theme the theme of the map (or empty if none). + * @param limit the hedgehog limit of the map. + * @param scheme mission map: default scheme name or "locked". + * @param weapons mission map: default weaponset name or "locked". + * @return pointer to item representing the map info: at Qt::UserRole + 1. + */ + QStandardItem * infoToItem( + const QIcon & icon, + const QString caption, + MapType type = Invalid, + QString name = "", + QString theme = "", + quint32 limit = 0, + QString scheme = "", + QString weapons = "") const; +}; + +Q_DECLARE_METATYPE(MapModel::MapInfo) + +#endif // HEDGEWARS_MAPMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/ThemeModel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/ThemeModel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,97 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief ThemeModel class implementation + */ + +#include "ThemeModel.h" + +ThemeModel::ThemeModel(QObject *parent) : + QAbstractListModel(parent) +{ + m_data = QList >(); +} + +int ThemeModel::rowCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + else + return m_data.size(); +} + + +QVariant ThemeModel::data(const QModelIndex &index, int role) const +{ + if(index.column() > 0 || index.row() >= m_data.size()) + return QVariant(); + else + return m_data.at(index.row()).value(role); +} + + +void ThemeModel::loadThemes() +{ + beginResetModel(); + + + DataManager & datamgr = DataManager::instance(); + + QStringList themes = + datamgr.entryList("Themes", QDir::AllDirs | QDir::NoDotAndDotDot); + + m_data.clear(); + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + m_data.reserve(themes.size()); +#endif + + foreach (QString theme, themes) + { + // themes without icon are supposed to be hidden + QString iconpath = + datamgr.findFileForRead(QString("Themes/%1/icon.png").arg(theme)); + + if (!QFile::exists(iconpath)) + continue; + + QMap dataset; + + // set name + dataset.insert(Qt::DisplayRole, theme); + + // load and set icon + QIcon icon(iconpath); + dataset.insert(Qt::DecorationRole, icon); + + // load and set preview icon + QIcon preview(datamgr.findFileForRead(QString("Themes/%1/icon@2x.png").arg(theme))); + dataset.insert(Qt::UserRole, preview); + + m_data.append(dataset); + } + + + endResetModel(); +} + + + + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/ThemeModel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/ThemeModel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,57 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief ThemeModel class definition + */ + +#ifndef HEDGEWARS_THEMEMODEL_H +#define HEDGEWARS_THEMEMODEL_H + +#include +#include +#include +#include + +#include "DataManager.h" + +/** + * @brief A model listing available themes + */ +class ThemeModel : public QAbstractListModel +{ + Q_OBJECT + + public: + explicit ThemeModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + + public slots: + /// reloads the themes from the DataManager + void loadThemes(); + + + private: + QList > m_data; +}; + +#endif // HEDGEWARS_THEMEMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/ammoSchemeModel.cpp --- a/QTfrontend/model/ammoSchemeModel.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/model/ammoSchemeModel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,562 +23,562 @@ #include "hwconsts.h" QList defaultScheme = QList() - << QVariant("Default") // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(45) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(4) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(2) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << QVariant("Default") // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(45) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(4) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(2) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) : QAbstractTableModel(parent), fileConfig(fileName, QSettings::IniFormat) { predefSchemesNames = QStringList() - << "Default" - << "Pro Mode" - << "Shoppa" - << "Clean Slate" - << "Minefield" - << "Barrel Mayhem" - << "Tunnel Hogs" - << "Fort Mode" - << "Timeless" - << "Thinking with Portals" - << "King Mode" - ; + << "Default" + << "Pro Mode" + << "Shoppa" + << "Clean Slate" + << "Minefield" + << "Barrel Mayhem" + << "Tunnel Hogs" + << "Fort Mode" + << "Timeless" + << "Thinking with Portals" + << "King Mode" + ; numberOfDefaultSchemes = predefSchemesNames.size(); spNames = QStringList() - << "name" // 0 - << "fortsmode" // 1 - << "divteams" // 2 - << "solidland" // 3 - << "border" // 4 - << "lowgrav" // 5 - << "laser" // 6 - << "invulnerability" // 7 - << "resethealth" // 8 - << "vampiric" // 9 - << "karma" // 10 - << "artillery" // 11 - << "randomorder" // 12 - << "king" // 13 - << "placehog" // 14 - << "sharedammo" // 15 - << "disablegirders" // 16 - << "disablelandobjects" // 17 - << "aisurvival" // 18 - << "infattack" // 19 - << "resetweps" // 20 - << "perhogammo" // 21 - << "disablewind" // 22 - << "morewind" // 23 - << "tagteam" // 24 - << "bottomborder" // 25 - << "damagefactor" // 26 - << "turntime" // 27 - << "health" // 28 - << "suddendeath" // 29 - << "caseprobability" // 30 - << "minestime" // 31 - << "minesnum" // 32 - << "minedudpct" // 33 - << "explosives" // 34 - << "healthprobability" // 35 - << "healthcaseamount" // 36 - << "waterrise" // 37 - << "healthdecrease" // 38 - << "ropepct" // 39 - << "getawaytime" // 40 - ; + << "name" // 0 + << "fortsmode" // 1 + << "divteams" // 2 + << "solidland" // 3 + << "border" // 4 + << "lowgrav" // 5 + << "laser" // 6 + << "invulnerability" // 7 + << "resethealth" // 8 + << "vampiric" // 9 + << "karma" // 10 + << "artillery" // 11 + << "randomorder" // 12 + << "king" // 13 + << "placehog" // 14 + << "sharedammo" // 15 + << "disablegirders" // 16 + << "disablelandobjects" // 17 + << "aisurvival" // 18 + << "infattack" // 19 + << "resetweps" // 20 + << "perhogammo" // 21 + << "disablewind" // 22 + << "morewind" // 23 + << "tagteam" // 24 + << "bottomborder" // 25 + << "damagefactor" // 26 + << "turntime" // 27 + << "health" // 28 + << "suddendeath" // 29 + << "caseprobability" // 30 + << "minestime" // 31 + << "minesnum" // 32 + << "minedudpct" // 33 + << "explosives" // 34 + << "healthprobability" // 35 + << "healthcaseamount" // 36 + << "waterrise" // 37 + << "healthdecrease" // 38 + << "ropepct" // 39 + << "getawaytime" // 40 + ; QList proMode; proMode - << predefSchemesNames[1] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(15) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(0) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(0) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(2) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[1] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(15) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(0) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(0) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(2) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList shoppa; shoppa - << predefSchemesNames[2] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(true) // solid land 3 - << QVariant(true) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(true) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(30) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(50) // sudden death 29 - << QVariant(1) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(0) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(0) // explosives 34 - << QVariant(0) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[2] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(true) // solid land 3 + << QVariant(true) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(true) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(30) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(50) // sudden death 29 + << QVariant(1) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(0) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(0) // explosives 34 + << QVariant(0) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList cleanslate; cleanslate - << predefSchemesNames[3] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(true) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(true) // inf. attack 19 - << QVariant(true) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(45) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(4) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(2) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[3] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(true) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(true) // inf. attack 19 + << QVariant(true) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(45) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(4) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(2) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList minefield; minefield - << predefSchemesNames[4] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(30) // turn time 27 - << QVariant(50) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(0) // case prob 30 - << QVariant(0) // mines time 31 - << QVariant(80) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(0) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[4] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(30) // turn time 27 + << QVariant(50) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(0) // case prob 30 + << QVariant(0) // mines time 31 + << QVariant(80) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(0) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList barrelmayhem; barrelmayhem - << predefSchemesNames[5] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(30) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(0) // case prob 30 - << QVariant(0) // mines time 31 - << QVariant(0) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(80) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[5] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(30) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(0) // case prob 30 + << QVariant(0) // mines time 31 + << QVariant(0) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(80) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList tunnelhogs; tunnelhogs - << predefSchemesNames[6] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(true) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) // disable girders 16 - << QVariant(true) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(30) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(10) // mines number 32 - << QVariant(10) // mine dud pct 33 - << QVariant(10) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[6] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(true) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) // disable girders 16 + << QVariant(true) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(30) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(10) // mines number 32 + << QVariant(10) // mine dud pct 33 + << QVariant(10) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList forts; forts - << predefSchemesNames[7] // name 0 - << QVariant(true) // fortsmode 1 - << QVariant(true) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(true) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(45) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(0) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(0) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[7] // name 0 + << QVariant(true) // fortsmode 1 + << QVariant(true) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(true) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(45) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(0) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(0) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList timeless; timeless - << predefSchemesNames[8] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(true) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(9999) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(5) // mines number 32 - << QVariant(10) // mine dud pct 33 - << QVariant(2) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(30) // health case amt 36 - << QVariant(0) // water rise amt 37 - << QVariant(0) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[8] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(true) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(9999) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(5) // mines number 32 + << QVariant(10) // mine dud pct 33 + << QVariant(2) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(30) // health case amt 36 + << QVariant(0) // water rise amt 37 + << QVariant(0) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList thinkingportals; thinkingportals - << predefSchemesNames[9] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(true) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(45) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(2) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(5) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(5) // explosives 34 - << QVariant(25) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[9] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(true) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(45) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(2) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(5) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(5) // explosives 34 + << QVariant(25) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; QList kingmode; kingmode - << predefSchemesNames[10] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // reset health 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(true) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) // disable girders 16 - << QVariant(false) // disable land objects 17 - << QVariant(false) // AI survival 18 - << QVariant(false) // inf. attack 19 - << QVariant(false) // reset weps 20 - << QVariant(false) // per hog ammo 21 - << QVariant(false) // no wind 22 - << QVariant(false) // more wind 23 - << QVariant(false) // tag team 24 - << QVariant(false) // bottom border 25 - << QVariant(100) // damage modfier 26 - << QVariant(45) // turn time 27 - << QVariant(100) // init health 28 - << QVariant(15) // sudden death 29 - << QVariant(5) // case prob 30 - << QVariant(3) // mines time 31 - << QVariant(4) // mines number 32 - << QVariant(0) // mine dud pct 33 - << QVariant(2) // explosives 34 - << QVariant(35) // health case pct 35 - << QVariant(25) // health case amt 36 - << QVariant(47) // water rise amt 37 - << QVariant(5) // health dec amt 38 - << QVariant(100) // rope modfier 39 - << QVariant(100) // get away time 40 - ; + << predefSchemesNames[10] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // reset health 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(true) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) // disable girders 16 + << QVariant(false) // disable land objects 17 + << QVariant(false) // AI survival 18 + << QVariant(false) // inf. attack 19 + << QVariant(false) // reset weps 20 + << QVariant(false) // per hog ammo 21 + << QVariant(false) // no wind 22 + << QVariant(false) // more wind 23 + << QVariant(false) // tag team 24 + << QVariant(false) // bottom border 25 + << QVariant(100) // damage modfier 26 + << QVariant(45) // turn time 27 + << QVariant(100) // init health 28 + << QVariant(15) // sudden death 29 + << QVariant(5) // case prob 30 + << QVariant(3) // mines time 31 + << QVariant(4) // mines number 32 + << QVariant(0) // mine dud pct 33 + << QVariant(2) // explosives 34 + << QVariant(35) // health case pct 35 + << QVariant(25) // health case amt 36 + << QVariant(47) // water rise amt 37 + << QVariant(5) // health dec amt 38 + << QVariant(100) // rope modfier 39 + << QVariant(100) // get away time 40 + ; schemes.append(defaultScheme); @@ -595,7 +595,8 @@ int size = fileConfig.beginReadArray("schemes"); - for (int i = 0; i < size; ++i) { + for (int i = 0; i < size; ++i) + { fileConfig.setArrayIndex(i); if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString())) @@ -649,9 +650,9 @@ bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role) { if (!index.isValid() || index.row() < numberOfDefaultSchemes - || index.row() >= schemes.size() - || index.column() >= defaultScheme.size() - || role != Qt::EditRole) + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || role != Qt::EditRole) return false; schemes[index.row()][index.column()] = value; @@ -687,8 +688,8 @@ bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent) { if(count != 1 - || row < numberOfDefaultSchemes - || row >= schemes.size()) + || row < numberOfDefaultSchemes + || row >= schemes.size()) return false; beginRemoveRows(parent, row, row); @@ -703,10 +704,10 @@ QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() < 0 - || index.row() >= schemes.size() - || index.column() >= defaultScheme.size() - || (role != Qt::EditRole && role != Qt::DisplayRole) - ) + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) return QVariant(); return schemes[index.row()][index.column()]; @@ -716,7 +717,8 @@ { fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes); - for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) { + for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) + { fileConfig.setArrayIndex(i); QList scheme = schemes[i + numberOfDefaultSchemes]; @@ -762,10 +764,10 @@ QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() < 0 - || index.row() > 1 - || index.column() >= defaultScheme.size() - || (role != Qt::EditRole && role != Qt::DisplayRole) - ) + || index.row() > 1 + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) return QVariant(); return netScheme[index.column()]; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/ammoSchemeModel.h --- a/QTfrontend/model/ammoSchemeModel.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/model/ammoSchemeModel.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,54 +26,54 @@ class AmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - AmmoSchemeModel(QObject * parent, const QString & fileName); + public: + AmmoSchemeModel(QObject * parent, const QString & fileName); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; - Qt::ItemFlags flags(const QModelIndex & index) const; - bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); - bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); - bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); - QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + Qt::ItemFlags flags(const QModelIndex & index) const; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); + bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); + QVariant data(const QModelIndex &index, int role) const; - int numberOfDefaultSchemes; - QStringList predefSchemesNames; - QStringList spNames; + int numberOfDefaultSchemes; + QStringList predefSchemesNames; + QStringList spNames; -public slots: - void Save(); + public slots: + void Save(); -signals: - void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); +// signals: +// void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); -protected: - QList< QList > schemes; + protected: + QList< QList > schemes; -private: - QSettings fileConfig; + private: + QSettings fileConfig; }; class NetAmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - NetAmmoSchemeModel(QObject * parent); + public: + NetAmmoSchemeModel(QObject * parent); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; - QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + QVariant data(const QModelIndex &index, int role) const; -public slots: - void setNetSchemeConfig(QStringList & cfg); + public slots: + void setNetSchemeConfig(QStringList & cfg); -private: - QList netScheme; + private: + QList netScheme; }; #endif // _AMMO_SCHEME_MODEL_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/hats.cpp --- a/QTfrontend/model/hats.cpp Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2008-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#include -#include -#include -#include "hwconsts.h" -#include "hwform.h" -#include "hats.h" - -#include "HWDataManager.h" - -HatsModel::HatsModel(QObject* parent) : - QAbstractListModel(parent) -{ - HWDataManager & dataMgr = HWDataManager::instance(); - - QPixmap hhpix = QPixmap( - dataMgr.findFileForRead("Graphics/Hedgehog/Idle.png") - ).copy(0, 0, 32, 32); - - // my reserved hats - QStringList hatsList = dataMgr.entryList( - "Graphics/Hats/Reserved", - QDir::Files, - QStringList(playerHash+"*.png") - ); - - int nReserved = hatsList.size(); - - // regular hats - hatsList.append(dataMgr.entryList( - "Graphics/Hats", - QDir::Files, - QStringList("*.png") - ) - ); - - - int nHats = hatsList.size(); - - for (int i = 0; i < nHats; i++) - { - bool isReserved = (i < nReserved); - - QString str = hatsList.at(i); - str = str.remove(QRegExp("\\.png$")); - QPixmap pix( - dataMgr.findFileForRead( - "Graphics/Hats/" + QString(isReserved?"Reserved/":"") + str + - ".png" - ) - ); - - // rename properly - if (isReserved) - str = "Reserved "+str.remove(0,32); - - QPixmap tmppix(32, 37); - tmppix.fill(QColor(Qt::transparent)); - - QPainter painter(&tmppix); - painter.drawPixmap(QPoint(0, 5), hhpix); - painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); - if(pix.width() > 32) - painter.drawPixmap(QPoint(0, 0), pix.copy(32, 0, 32, 32)); - painter.end(); - - if (str == "NoHat") - hats.prepend(qMakePair(str, QIcon(tmppix))); - else - hats.append(qMakePair(str, QIcon(tmppix))); - } -} - -QVariant HatsModel::headerData(int section, - Qt::Orientation orientation, int role) const -{ - Q_UNUSED(section); - Q_UNUSED(orientation); - Q_UNUSED(role); - - return QVariant(); -} - -int HatsModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - else - return hats.size(); -} - -/*int HatsModel::columnCount(const QModelIndex & parent) const -{ - if (parent.isValid()) - return 0; - else - return 2; -} -*/ -QVariant HatsModel::data(const QModelIndex &index, - int role) const -{ - if (!index.isValid() || index.row() < 0 - || index.row() >= hats.size() - || (role != Qt::DisplayRole && role != Qt::DecorationRole)) - return QVariant(); - - if (role == Qt::DisplayRole) - return hats.at(index.row()).first; - else // role == Qt::DecorationRole - return hats.at(index.row()).second; -} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/hats.h --- a/QTfrontend/model/hats.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2008-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#ifndef _HATS_INCLUDED -#define _HATS_INCLUDED - -#include -#include -#include -#include -#include - -class HatsModel : public QAbstractListModel -{ - Q_OBJECT - -public: - HatsModel(QObject *parent = 0); - - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - //int columnCount(const QModelIndex & parent) const; - - QVariant data(const QModelIndex &index, int role) const; -protected: - QVector > hats; -}; - -#endif // _HATS_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/netserverslist.cpp --- a/QTfrontend/model/netserverslist.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/model/netserverslist.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include "netserverslist.h" HWNetServersModel::HWNetServersModel(QObject* parent) : - QAbstractTableModel(parent) + QAbstractTableModel(parent) { } @@ -33,7 +33,7 @@ } QVariant HWNetServersModel::headerData(int section, - Qt::Orientation orientation, int role) const + Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) return QVariant(); @@ -42,12 +42,17 @@ { switch (section) { - case 0: return tr("Title"); - case 1: return tr("IP"); - case 2: return tr("Port"); - default: return QVariant(); + case 0: + return tr("Title"); + case 1: + return tr("IP"); + case 2: + return tr("Port"); + default: + return QVariant(); } - } else + } + else return QString("%1").arg(section + 1); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/netserverslist.h --- a/QTfrontend/model/netserverslist.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/model/netserverslist.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,20 +24,20 @@ class HWNetServersModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT -public: - HWNetServersModel(QObject *parent = 0); + public: + HWNetServersModel(QObject *parent = 0); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; -public slots: - virtual void updateList(); + public slots: + virtual void updateList(); -protected: - QList games; + protected: + QList games; }; #endif // _NET_SERVERSLIST_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/playerslistmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/playerslistmodel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,393 @@ +#include +#include +#include +#include +#include +#include + +#include "playerslistmodel.h" +#include "hwconsts.h" + +PlayersListModel::PlayersListModel(QObject *parent) : + QAbstractListModel(parent) +{ + +} + + +int PlayersListModel::rowCount(const QModelIndex &parent) const +{ + if(parent.isValid()) + return 0; + else + return m_data.size(); +} + + +QVariant PlayersListModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0) + return QVariant(QVariant::Invalid); + + return m_data.at(index.row()).value(role); +} + + +bool PlayersListModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if(!index.isValid() || index.row() < 0 || index.row() >= rowCount() || index.column() != 0) + return false; + + m_data[index.row()].insert(role, value); + + emit dataChanged(index, index); + + return true; +} + + +bool PlayersListModel::insertRow(int row, const QModelIndex &parent) +{ + return insertRows(row, 1, parent); +} + + +bool PlayersListModel::insertRows(int row, int count, const QModelIndex &parent) +{ + if(parent.isValid() || row > rowCount() || row < 0 || count < 1) + return false; + + beginInsertRows(parent, row, row + count - 1); + + for(int i = 0; i < count; ++i) + m_data.insert(row, DataEntry()); + + endInsertRows(); + + return true; +} + + +bool PlayersListModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if(parent.isValid() || row + count > rowCount() || row < 0 || count < 1) + return false; + + beginRemoveRows(parent, row, row + count - 1); + + for(int i = 0; i < count; ++i) + m_data.removeAt(row); + + endRemoveRows(); + + return true; +} + + +void PlayersListModel::addPlayer(const QString & nickname) +{ + insertRow(rowCount()); + + QModelIndex mi = index(rowCount() - 1); + setData(mi, nickname); + + checkFriendIgnore(mi); +} + + +void PlayersListModel::removePlayer(const QString & nickname) +{ + QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); + + if(mil.size()) + removeRow(mil[0].row()); +} + + +void PlayersListModel::playerJoinedRoom(const QString & nickname) +{ + QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); + + if(mil.size()) + { + setData(mil[0], true, RoomFilterRole); + updateIcon(mil[0]); + updateSortData(mil[0]); + } +} + + +void PlayersListModel::playerLeftRoom(const QString & nickname) +{ + QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); + + if(mil.size()) + { + setData(mil[0], false, RoomFilterRole); + setData(mil[0], false, RoomAdmin); + setData(mil[0], false, Ready); + setData(mil[0], false, InGame); + updateIcon(mil[0]); + } +} + + +void PlayersListModel::setFlag(const QString &nickname, StateFlag flagType, bool isSet) +{ + QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); + + if(mil.size()) + { + setData(mil[0], isSet, flagType); + + if(flagType == Friend || flagType == ServerAdmin + || flagType == Ignore || flagType == RoomAdmin) + updateSortData(mil[0]); + + if(flagType == Friend) + { + if(isSet) + m_friendsSet.insert(nickname.toLower()); + else + m_friendsSet.remove(nickname.toLower()); + + saveSet(m_friendsSet, "friends"); + } + + if(flagType == Ignore) + { + if(isSet) + m_ignoredSet.insert(nickname.toLower()); + else + m_ignoredSet.remove(nickname.toLower()); + + saveSet(m_ignoredSet, "ignore"); + } + + updateIcon(mil[0]); + } +} + + +bool PlayersListModel::isFlagSet(const QString & nickname, StateFlag flagType) +{ + QModelIndexList mil = match(index(0), Qt::DisplayRole, nickname, 1, Qt::MatchExactly); + + if(mil.size()) + return mil[0].data(flagType).toBool(); + else + return false; +} + +void PlayersListModel::resetRoomFlags() +{ + for(int i = rowCount() - 1; i >= 0; --i) + { + QModelIndex mi = index(i); + + if(mi.data(RoomFilterRole).toBool()) + { + setData(mi, false, RoomFilterRole); + setData(mi, false, RoomAdmin); + setData(mi, false, Ready); + setData(mi, false, InGame); + + updateSortData(mi); + updateIcon(mi); + } + } +} + +void PlayersListModel::updateIcon(const QModelIndex & index) +{ + quint32 iconNum = 0; + + QList flags; + flags + << index.data(Ready).toBool() + << index.data(ServerAdmin).toBool() + << index.data(RoomAdmin).toBool() + << index.data(Registered).toBool() + << index.data(Friend).toBool() + << index.data(Ignore).toBool() + << index.data(InGame).toBool() + << index.data(RoomFilterRole).toBool() + ; + + for(int i = flags.size() - 1; i >= 0; --i) + if(flags[i]) + iconNum |= 1 << i; + + if(m_icons().contains(iconNum)) + { + setData(index, m_icons().value(iconNum), Qt::DecorationRole); + } + else + { + QPixmap result(24, 16); + result.fill(Qt::transparent); + + QPainter painter(&result); + + if(index.data(RoomFilterRole).toBool()) + { + if(index.data(InGame).toBool()) + { + painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/ingame.png")); + } + else + { + if(index.data(Ready).toBool()) + painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp.png")); + else + painter.drawPixmap(0, 0, 16, 16, QPixmap(":/res/chat/lamp_off.png")); + } + } + + QString mainIconName(":/res/chat/"); + + if(index.data(RoomAdmin).toBool()) + mainIconName += "roomadmin"; + else if(index.data(ServerAdmin).toBool()) + mainIconName += "serveradmin"; + else + mainIconName += "hedgehog"; + + if(!index.data(Registered).toBool()) + mainIconName += "_gray"; + + painter.drawPixmap(8, 0, 16, 16, QPixmap(mainIconName + ".png")); + + if(index.data(Ignore).toBool()) + painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/ignore.png")); + else + if(index.data(Friend).toBool()) + painter.drawPixmap(8, 0, 16, 16, QPixmap(":/res/chat/friend.png")); + + painter.end(); + + QIcon icon(result); + + setData(index, icon, Qt::DecorationRole); + m_icons().insert(iconNum, icon); + } + + if(index.data(Ignore).toBool()) + setData(index, Qt::gray, Qt::ForegroundRole); + else + if(index.data(Friend).toBool()) + setData(index, Qt::green, Qt::ForegroundRole); + else + setData(index, QBrush(QColor(0xff, 0xcc, 0x00)), Qt::ForegroundRole); +} + + +QHash & PlayersListModel::m_icons() +{ + static QHash iconsCache; + + return iconsCache; +} + + +void PlayersListModel::updateSortData(const QModelIndex & index) +{ + QString result = QString("%1%2%3%4%5%6") + // room admins go first, then server admins, then friends + .arg(1 - index.data(RoomAdmin).toInt()) + .arg(1 - index.data(ServerAdmin).toInt()) + .arg(1 - index.data(Friend).toInt()) + // ignored at bottom + .arg(index.data(Ignore).toInt()) + // keep nicknames starting from non-letter character at bottom within group + // assume there are no empty nicks in list + .arg(index.data(Qt::DisplayRole).toString().at(0).isLetter() ? 0 : 1) + // sort ignoring case + .arg(index.data(Qt::DisplayRole).toString().toLower()) + ; + + setData(index, result, SortRole); +} + + +void PlayersListModel::setNickname(const QString &nickname) +{ + m_nickname = nickname; + + loadSet(m_friendsSet, "friends"); + loadSet(m_ignoredSet, "ignore"); + + for(int i = rowCount() - 1; i >= 0; --i) + checkFriendIgnore(index(i)); +} + + +void PlayersListModel::checkFriendIgnore(const QModelIndex &mi) +{ + setData(mi, m_friendsSet.contains(mi.data().toString().toLower()), Friend); + setData(mi, m_ignoredSet.contains(mi.data().toString().toLower()), Ignore); + + updateIcon(mi); + updateSortData(mi); +} + +void PlayersListModel::loadSet(QSet & set, const QString & suffix) +{ + set.clear(); + + QString fileName = QString("%1/%2_%3.txt").arg(cfgdir->absolutePath(), m_nickname.toLower(), suffix); + + QFile txt(fileName); + if(!txt.open(QIODevice::ReadOnly)) + return; + + QTextStream stream(&txt); + stream.setCodec("UTF-8"); + + while(!stream.atEnd()) + { + QString str = stream.readLine(); + if(str.startsWith(";") || str.isEmpty()) + continue; + + set.insert(str.trimmed()); + } + + txt.close(); +} + +void PlayersListModel::saveSet(const QSet & set, const QString & suffix) +{ + qDebug("saving set"); + + QString fileName = QString("%1/%2_%3.txt").arg(cfgdir->absolutePath(), m_nickname.toLower(), suffix); + + QFile txt(fileName); + + // list empty? => rather have no file for the list than an empty one + if (set.isEmpty()) + { + if (txt.exists()) + { + // try to remove file, if successful we're done here. + if (txt.remove()) + return; + } + else + // there is no file + return; + } + + if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) + return; + + QTextStream stream(&txt); + stream.setCodec("UTF-8"); + + stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; + + foreach(const QString & nick, set.values()) + stream << nick << endl; + + txt.close(); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/playerslistmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/playerslistmodel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,65 @@ +#ifndef PLAYERSLISTMODEL_H +#define PLAYERSLISTMODEL_H + +#include +#include +#include +#include +#include + +class PlayersListModel : public QAbstractListModel +{ + Q_OBJECT + +public: + enum StateFlag { + Ready = Qt::UserRole, + ServerAdmin = Qt::UserRole + 1, + RoomAdmin = Qt::UserRole + 2, + Registered = Qt::UserRole + 3, + Friend = Qt::UserRole + 4, + Ignore = Qt::UserRole + 5, + InGame = Qt::UserRole + 6 + }; + + enum SpecialRoles { + SortRole = Qt::UserRole + 100, + RoomFilterRole = Qt::UserRole + 101 + }; + + explicit PlayersListModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DisplayRole); + void setFlag(const QString & nickname, StateFlag flagType, bool isSet); + bool isFlagSet(const QString & nickname, StateFlag flagType); + + bool insertRow(int row, const QModelIndex &parent = QModelIndex()); + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()); + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + +public slots: + void addPlayer(const QString & nickname); + void removePlayer(const QString & nickname); + void playerJoinedRoom(const QString & nickname); + void playerLeftRoom(const QString & nickname); + void resetRoomFlags(); + void setNickname(const QString & nickname); + +private: + QHash & m_icons(); + typedef QHash DataEntry; + QList m_data; + QSet m_friendsSet, m_ignoredSet; + QString m_nickname; + + void updateIcon(const QModelIndex & index); + void updateSortData(const QModelIndex & index); + void loadSet(QSet & set, const QString & suffix); + void saveSet(const QSet & set, const QString & suffix); + void checkFriendIgnore(const QModelIndex & mi); +}; + +#endif // PLAYERSLISTMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/roomslistmodel.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/roomslistmodel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,264 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief RoomsListModel class implementation + */ + +#include +#include +#include + +#include "roomslistmodel.h" +#include "MapModel.h" + +RoomsListModel::RoomsListModel(QObject *parent) : + QAbstractTableModel(parent), + c_nColumns(8) +{ + m_headerData = + QStringList() + << tr("In progress") + << tr("Room Name") + << tr("C") + << tr("T") + << tr("Owner") + << tr("Map") + << tr("Rules") + << tr("Weapons"); + + m_mapModel = DataManager::instance().mapModel(); +} + + +QVariant RoomsListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(orientation == Qt::Vertical || role != Qt::DisplayRole) + return QVariant(); + else + return QVariant(m_headerData.at(section)); +} + + +int RoomsListModel::rowCount(const QModelIndex & parent) const +{ + if(parent.isValid()) + return 0; + else + return m_data.size(); +} + + +int RoomsListModel::columnCount(const QModelIndex & parent) const +{ + if(parent.isValid()) + return 0; + else + return c_nColumns; +} + + +QVariant RoomsListModel::data(const QModelIndex &index, int role) const +{ + int column = index.column(); + int row = index.row(); + + // invalid index + if (!index.isValid()) + return QVariant(); + + // invalid row + if ((row < 0) || (row >= m_data.size())) + return QVariant(); + + // invalid column + if ((column < 0) || (column >= c_nColumns)) + return QVariant(); + + // not a role we have data for + if (role != Qt::DisplayRole) + // only custom-align counters + if ((role != Qt::TextAlignmentRole) + || ((column != PlayerCountColumn) && (column != TeamCountColumn))) + // only decorate name column + if ((role != Qt::DecorationRole) || (column != NameColumn)) + // only dye map column + if ((role != Qt::ForegroundRole) || (column != MapColumn)) + return QVariant(); + + // decorate room name based on room state + if (role == Qt::DecorationRole) + { + const QIcon roomBusyIcon(":/res/iconDamage.png"); + const QIcon roomWaitingIcon(":/res/iconTime.png"); + + if (m_data.at(row).at(0).isEmpty()) + return QVariant(roomWaitingIcon); + else + return QVariant(roomBusyIcon); + } + + QString content = m_data.at(row).at(column); + + if (role == Qt::DisplayRole) + { + // supply in progress flag as bool + if (column == 0) + return QVariant(QString(!content.isEmpty())); + + // display room names + if (column == 5) + { + // special names + if (content[0] == '+') + { + if (content == "+rnd+") return tr("Random Map"); + if (content == "+maze+") return tr("Random Maze"); + if (content == "+drawn+") return tr("Hand-drawn"); + } + + // prefix ? if map not available + if ((m_mapModel->indexOf(content) < 0)) + return QString ("? %1").arg(content); + } + + return content; + } + + // dye map names red if map not available + if (role == Qt::ForegroundRole) + { + if ((m_mapModel->indexOf(content) < 0)) + return QBrush(QColor("darkred")); + else + return QVariant(); + } + + if (role == Qt::TextAlignmentRole) + { + return (int)(Qt::AlignHCenter | Qt::AlignVCenter); + } + + Q_ASSERT(false); + return QVariant(); +} + + +void RoomsListModel::setRoomsList(const QStringList & rooms) +{ + beginResetModel(); + + m_data.clear(); + + int nRooms = rooms.size(); + + for (int i = 0; i < nRooms; i += c_nColumns) + { + QStringList l; + +#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) + l.reserve(c_nColumns); // small optimisation not supported in old Qt +#endif + + for (int t = 0; t < c_nColumns; t++) + { + l.append(rooms[i + t]); + } + + m_data.append(roomInfo2RoomRecord(l)); + } + + endResetModel(); +} + + +void RoomsListModel::addRoom(const QStringList & info) +{ + beginInsertRows(QModelIndex(), 0, 0); + + m_data.prepend(roomInfo2RoomRecord(info)); + + endInsertRows(); +} + + +int RoomsListModel::rowOfRoom(const QString & name) +{ + int size = m_data.size(); + + if (size < 1) + return -1; + + int i = 0; + + // search for record with matching room name + while(m_data[i].at(NameColumn) != name) + { + i++; + if(i >= size) + return -1; + } + + return i; +} + + +void RoomsListModel::removeRoom(const QString & name) +{ + int i = rowOfRoom(name); + + if (i < 0) + return; + + beginRemoveRows(QModelIndex(), i, i); + + m_data.removeAt(i); + + endRemoveRows(); +} + + +void RoomsListModel::updateRoom(const QString & name, const QStringList & info) +{ + int i = rowOfRoom(name); + + if (i < 0) + return; + + m_data[i] = roomInfo2RoomRecord(info); + + emit dataChanged(index(i, 0), index(i, columnCount(QModelIndex()) - 1)); +} + + +QStringList RoomsListModel::roomInfo2RoomRecord(const QStringList & info) +{ + QStringList result; + + result = info; + + // for matters of less memory usage and quicker access store + // the boolean string as either "t" or empty + if (info[StateColumn].toLower() == "true") + result[StateColumn] = "t"; + else + result[StateColumn] = QString(); + + return result; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/roomslistmodel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/model/roomslistmodel.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,72 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief RoomsListModel class definition + */ + +#ifndef HEDGEWARS_ROOMSLISTMODEL_H +#define HEDGEWARS_ROOMSLISTMODEL_H + +#include +#include + +#include "DataManager.h" + +class RoomsListModel : public QAbstractTableModel +{ + Q_OBJECT +public: + // if you add a column here, also incr. c_nColumns in constructor + // also adjust header in constructor to changes + enum Column { + StateColumn, + NameColumn, + PlayerCountColumn, + TeamCountColumn, + OwnerColumn, + MapColumn, + SchemeColumn, + WeaponsColumn + }; + + explicit RoomsListModel(QObject *parent = 0); + + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + QVariant data(const QModelIndex &index, int role) const; + +public slots: + void setRoomsList(const QStringList & rooms); + void addRoom(const QStringList & info); + void removeRoom(const QString & name); + void updateRoom(const QString & name, const QStringList & info); + int rowOfRoom(const QString & name); + +private: + const int c_nColumns; + QList m_data; + QStringList m_headerData; + MapModel * m_mapModel; + + QStringList roomInfo2RoomRecord(const QStringList & info); +}; + +#endif // HEDGEWARS_ROOMSLISTMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/themesmodel.cpp --- a/QTfrontend/model/themesmodel.cpp Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ - -#include "themesmodel.h" - -ThemesModel::ThemesModel(QStringList themes, QObject *parent) : - QAbstractListModel(parent) -{ -#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) - m_data.reserve(themes.size()); -#endif - - foreach(QString theme, themes) - { - m_data.append(QHash()); - m_data.last().insert(Qt::DisplayRole, theme); - } -} - -int ThemesModel::rowCount(const QModelIndex &parent) const -{ - if(parent.isValid()) - return 0; - else - return m_data.size(); -} - -QVariant ThemesModel::data(const QModelIndex &index, int role) const -{ - if(index.column() > 0 || index.row() >= m_data.size()) - return QVariant(); - else - return m_data.at(index.row()).value(role); -} - -bool ThemesModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if(index.column() > 0 || index.row() >= m_data.size()) - return false; - else - { - m_data[index.row()].insert(role, value); - - return true; - } - -} - - - - diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/model/themesmodel.h --- a/QTfrontend/model/themesmodel.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#ifndef THEMESMODEL_H -#define THEMESMODEL_H - -#include -#include -#include - -class ThemesModel : public QAbstractListModel -{ - Q_OBJECT -public: - explicit ThemesModel(QStringList themes, QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole); - -signals: - -public slots: - -private: - - QList > m_data; -}; - -#endif // THEMESMODEL_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/hwmap.cpp --- a/QTfrontend/net/hwmap.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/hwmap.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Ulyanov Igor - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include "hwmap.h" HWMap::HWMap() : - TCPBase(false) + TCPBase(false) { } @@ -84,7 +84,8 @@ } break; } - default: ; + default: + ; } SendIPC("!"); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/hwmap.h --- a/QTfrontend/net/hwmap.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/hwmap.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006 Igor Ulyanov - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,30 +36,30 @@ class HWMap : public TCPBase { - Q_OBJECT + Q_OBJECT - public: - HWMap(); - virtual ~HWMap(); - void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData); + public: + HWMap(); + virtual ~HWMap(); + void getImage(const QString & seed, int templateFilter, MapGenerator mapgen, int maze_size, const QByteArray & drawMapData); - protected: - virtual QStringList getArguments(); - virtual void onClientDisconnect(); - virtual void SendToClientFirst(); + protected: + virtual QStringList getArguments(); + virtual void onClientDisconnect(); + virtual void SendToClientFirst(); - signals: - void ImageReceived(const QImage newImage); - void HHLimitReceived(int hhLimit); + signals: + void ImageReceived(const QImage newImage); + void HHLimitReceived(int hhLimit); - private: - QString m_seed; - int templateFilter; - MapGenerator m_mapgen; - int m_maze_size; - QByteArray m_drawMapData; + private: + QString m_seed; + int templateFilter; + MapGenerator m_mapgen; + int m_maze_size; + QByteArray m_drawMapData; - private slots: + private slots: }; #endif // _HWMAP_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netregister.cpp --- a/QTfrontend/net/netregister.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netregister.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ #include "netregister.h" HWNetRegisterServer::HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port) : - QObject(parent) + QObject(parent) { Q_UNUSED(descr); Q_UNUSED(port); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netregister.h --- a/QTfrontend/net/netregister.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netregister.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,13 +23,13 @@ class HWNetRegisterServer : public QObject { - Q_OBJECT + Q_OBJECT -public: - HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); + public: + HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); -public slots: - virtual void unregister(); + public slots: + virtual void unregister(); }; #endif // _NET_REGISTER_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netserver.cpp --- a/QTfrontend/net/netserver.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netserver.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include - #include "hwconsts.h" #include "netserver.h" @@ -48,5 +46,5 @@ quint16 HWNetServer::getRunningPort() const { - return ds_port; + return ds_port; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netserver.h --- a/QTfrontend/net/netserver.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netserver.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,18 +25,18 @@ class HWNetServer : public QObject { - Q_OBJECT + Q_OBJECT -public: - ~HWNetServer(); - bool StartServer(quint16 port); - void StopServer(); - QString getRunningHostName() const; - quint16 getRunningPort() const; + public: + ~HWNetServer(); + bool StartServer(quint16 port); + void StopServer(); + QString getRunningHostName() const; + quint16 getRunningPort() const; -private: - quint16 ds_port; - QProcess process; + private: + quint16 ds_port; + QProcess process; }; #endif // _NETSERVER_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netudpserver.cpp --- a/QTfrontend/net/netudpserver.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netudpserver.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,30 +22,32 @@ #include "netudpserver.h" HWNetUdpServer::HWNetUdpServer(QObject *parent, const QString & descr, quint16 port) : - HWNetRegisterServer(parent, descr, port), - m_descr(descr) + HWNetRegisterServer(parent, descr, port), + m_descr(descr) { - pUdpSocket = new QUdpSocket(this); - pUdpSocket->bind(46631); - connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); + pUdpSocket = new QUdpSocket(this); + pUdpSocket->bind(46631); + connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); } void HWNetUdpServer::onClientRead() { - while (pUdpSocket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(pUdpSocket->pendingDatagramSize()); - QHostAddress clientAddr; - quint16 clientPort; - pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); - if(datagram.startsWith("hedgewars client")) { - // send answer to client - pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort); + while (pUdpSocket->hasPendingDatagrams()) + { + QByteArray datagram; + datagram.resize(pUdpSocket->pendingDatagramSize()); + QHostAddress clientAddr; + quint16 clientPort; + pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); + if(datagram.startsWith("hedgewars client")) + { + // send answer to client + pUdpSocket->writeDatagram(QString("hedgewars server\n%1").arg(m_descr).toUtf8(), clientAddr, clientPort); + } } - } } void HWNetUdpServer::unregister() { - deleteLater(); + deleteLater(); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netudpserver.h --- a/QTfrontend/net/netudpserver.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netudpserver.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,20 +27,20 @@ class HWNetUdpServer : public HWNetRegisterServer { - Q_OBJECT + Q_OBJECT - public: - HWNetUdpServer(QObject *parent, const QString & descr, quint16 port); + public: + HWNetUdpServer(QObject *parent, const QString & descr, quint16 port); - public slots: - void unregister(); + public slots: + void unregister(); - private slots: - void onClientRead(); + private slots: + void onClientRead(); - private: - QUdpSocket* pUdpSocket; - QString m_descr; + private: + QUdpSocket* pUdpSocket; + QString m_descr; }; #endif // _NET_UDPSERVER_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netudpwidget.cpp --- a/QTfrontend/net/netudpwidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netudpwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include "netudpwidget.h" HWNetUdpModel::HWNetUdpModel(QObject* parent) : - HWNetServersModel(parent) + HWNetServersModel(parent) { pUdpSocket = new QUdpSocket(this); @@ -41,7 +41,8 @@ void HWNetUdpModel::onClientRead() { - while (pUdpSocket->hasPendingDatagrams()) { + while (pUdpSocket->hasPendingDatagrams()) + { QByteArray datagram; datagram.resize(pUdpSocket->pendingDatagramSize()); QHostAddress clientAddr; @@ -50,7 +51,8 @@ pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); QString packet = QString::fromUtf8(datagram.data()); - if(packet.startsWith("hedgewars server")) { + if(packet.startsWith("hedgewars server")) + { QStringList sl; sl << packet.remove(0, 17) << clientAddr.toString() << "46631"; games.append(sl); @@ -64,9 +66,9 @@ int role) const { if (!index.isValid() || index.row() < 0 - || index.row() >= games.size() - || role != Qt::DisplayRole) - return QVariant(); + || index.row() >= games.size() + || role != Qt::DisplayRole) + return QVariant(); return games[index.row()][index.column()]; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/netudpwidget.h --- a/QTfrontend/net/netudpwidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/netudpwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,21 +26,21 @@ class HWNetUdpModel : public HWNetServersModel { - Q_OBJECT + Q_OBJECT -public: - HWNetUdpModel(QObject *parent = 0); + public: + HWNetUdpModel(QObject *parent = 0); - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const; -public slots: - void updateList(); + public slots: + void updateList(); -private slots: - void onClientRead(); + private slots: + void onClientRead(); -private: - QUdpSocket* pUdpSocket; + private: + QUdpSocket* pUdpSocket; }; #endif // _NET_UDPWIDGET_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/newnetclient.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,21 +20,42 @@ #include #include #include +#include #include "hwconsts.h" #include "newnetclient.h" #include "proto.h" #include "game.h" +#include "roomslistmodel.h" +#include "playerslistmodel.h" char delimeter='\n'; HWNewNet::HWNewNet() : - isChief(false), - m_game_connected(false), - loginStep(0), - netClientState(Disconnected) + isChief(false), + m_game_connected(false), + loginStep(0), + netClientState(Disconnected) { -// socket stuff + m_roomsListModel = new RoomsListModel(this); + + m_playersModel = new PlayersListModel(this); + + m_lobbyPlayersModel = new QSortFilterProxyModel(this); + m_lobbyPlayersModel->setSourceModel(m_playersModel); + m_lobbyPlayersModel->setSortRole(PlayersListModel::SortRole); + m_lobbyPlayersModel->setDynamicSortFilter(true); + m_lobbyPlayersModel->sort(0); + + m_roomPlayersModel = new QSortFilterProxyModel(this); + m_roomPlayersModel->setSourceModel(m_playersModel); + m_roomPlayersModel->setSortRole(PlayersListModel::SortRole); + m_roomPlayersModel->setDynamicSortFilter(true); + m_roomPlayersModel->sort(0); + m_roomPlayersModel->setFilterRole(PlayersListModel::RoomFilterRole); + m_roomPlayersModel->setFilterFixedString("true"); + + // socket stuff connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); @@ -100,13 +121,13 @@ void HWNewNet::AddTeam(const HWTeam & team) { QString cmd = QString("ADD_TEAM") + delimeter + - team.name() + delimeter + - team.color().name() + delimeter + - team.grave() + delimeter + - team.fort() + delimeter + - team.voicepack() + delimeter + - team.flag() + delimeter + - QString::number(team.difficulty()); + team.name() + delimeter + + QString::number(team.color()) + delimeter + + team.grave() + delimeter + + team.fort() + delimeter + + team.voicepack() + delimeter + + team.flag() + delimeter + + QString::number(team.difficulty()); for(int i = 0; i < HEDGEHOGS_PER_TEAM; ++i) { @@ -130,19 +151,19 @@ void HWNewNet::ToggleReady() { - RawSendNet(QString("TOGGLE_READY")); + RawSendNet(QString("TOGGLE_READY")); } void HWNewNet::SendNet(const QByteArray & buf) { - QString msg = QString(buf.toBase64()); + QString msg = QString(buf.toBase64()); - RawSendNet(QString("EM%1%2").arg(delimeter).arg(msg)); + RawSendNet(QString("EM%1%2").arg(delimeter).arg(msg)); } void HWNewNet::RawSendNet(const QString & str) { - RawSendNet(str.toUtf8()); + RawSendNet(str.toUtf8()); } void HWNewNet::RawSendNet(const QByteArray & buf) @@ -154,14 +175,17 @@ void HWNewNet::ClientRead() { - while (NetSocket.canReadLine()) { + while (NetSocket.canReadLine()) + { QString s = QString::fromUtf8(NetSocket.readLine()); if (s.endsWith('\n')) s.chop(1); - if (s.size() == 0) { + if (s.size() == 0) + { ParseCmd(cmdbuf); cmdbuf.clear(); - } else + } + else cmdbuf << s; } } @@ -182,8 +206,10 @@ { m_game_connected = false; - switch (socketError) { + switch (socketError) + { case QAbstractSocket::RemoteHostClosedError: + emit disconnected(tr("Remote host has closed connection")); break; case QAbstractSocket::HostNotFoundError: emit disconnected(tr("The host was not found. Please check the host name and port settings.")); @@ -193,7 +219,7 @@ break; default: emit disconnected(NetSocket.errorString()); - } + } } void HWNewNet::SendPasswordHash(const QString & hash) @@ -203,7 +229,7 @@ void HWNewNet::ParseCmd(const QStringList & lst) { - qDebug() << "Server: " << lst; + qDebug() << "Server: " << lst; if(!lst.size()) { @@ -214,13 +240,15 @@ if (lst[0] == "NICK") { mynick = lst[1]; + m_playersModel->setNickname(mynick); return ; } if (lst[0] == "PROTO") return ; - if (lst[0] == "ERROR") { + if (lst[0] == "ERROR") + { if (lst.size() == 2) emit Error(lst[1]); else @@ -228,7 +256,8 @@ return; } - if (lst[0] == "WARNING") { + if (lst[0] == "WARNING") + { if (lst.size() == 2) emit Warning(lst[1]); else @@ -236,11 +265,16 @@ return; } - if (lst[0] == "CONNECTED") { + if (lst[0] == "CONNECTED") + { if(lst.size() < 3 || lst[2].toInt() < cMinServerVersion) { // TODO: Warn user, disconnect qWarning() << "Server too old"; + RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("Server too old")); + Disconnect(); + emit disconnected(tr("The server is too old. Disconnecting now.")); + return; } RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); @@ -251,7 +285,8 @@ return; } - if (lst[0] == "PING") { + if (lst[0] == "PING") + { if (lst.size() > 1) RawSendNet(QString("PONG%1%2").arg(delimeter).arg(lst[1])); else @@ -259,14 +294,21 @@ return; } - if (lst[0] == "ROOMS") { + if (lst[0] == "ROOMS") + { + if(lst.size() % 8 != 1) + { + qWarning("Net: Malformed ROOMS message"); + return; + } QStringList tmp = lst; tmp.removeFirst(); - emit roomsList(tmp); + m_roomsListModel->setRoomsList(tmp); return; } - if (lst[0] == "SERVER_MESSAGE") { + if (lst[0] == "SERVER_MESSAGE") + { if(lst.size() < 2) { qWarning("Net: Empty SERVERMESSAGE message"); @@ -276,7 +318,8 @@ return; } - if (lst[0] == "CHAT") { + if (lst[0] == "CHAT") + { if(lst.size() < 3) { qWarning("Net: Empty CHAT message"); @@ -289,7 +332,8 @@ return; } - if (lst[0] == "INFO") { + if (lst[0] == "INFO") + { if(lst.size() < 5) { qWarning("Net: Malformed INFO message"); @@ -304,7 +348,8 @@ return; } - if (lst[0] == "SERVER_VARS") { + if (lst[0] == "SERVER_VARS") + { QStringList tmp = lst; tmp.removeFirst(); while (tmp.size() >= 2) @@ -329,6 +374,7 @@ QString flags = lst[1]; bool setFlag = flags[0] == '+'; + const QStringList nicks = lst.mid(2); while(flags.size() > 1) { @@ -337,80 +383,75 @@ switch(c) { - case 'r': - { - for(int i = 2; i < lst.size(); ++i) - { - if (lst[i] == mynick) - emit setMyReadyStatus(setFlag); - emit setReadyStatus(lst[i], setFlag); - } - } + // flag indicating if a player is ready to start a game + case 'r': + foreach (const QString & nick, nicks) + { + if (nick == mynick) + { + if (isChief && !setFlag) ToggleReady(); + else emit setMyReadyStatus(setFlag); + } + m_playersModel->setFlag(nick, PlayersListModel::Ready, setFlag); + } + break; + + // flag indicating if a player is a registered user + case 'u': + foreach(const QString & nick, nicks) + m_playersModel->setFlag(nick, PlayersListModel::Registered, setFlag); + break; + + case 'g': + foreach(const QString & nick, nicks) + m_playersModel->setFlag(nick, PlayersListModel::InGame, setFlag); + break; + + // flag indicating if a player is the host/master of the room + case 'h': + foreach (const QString & nick, nicks) + { + if (nick == mynick) + { + isChief = setFlag; + emit roomMaster(isChief); + } + + m_playersModel->setFlag(nick, PlayersListModel::RoomAdmin, setFlag); + } + break; + + // flag indicating if a player is admin (if so -> worship them!) + case 'a': + foreach (const QString & nick, nicks) + { + if (nick == mynick) + emit adminAccess(setFlag); + + m_playersModel->setFlag(nick, PlayersListModel::ServerAdmin, setFlag); + } + break; + + default: + qWarning() << "Net: Unknown client-flag: " << c; } } return; } - if (lst[0] == "ADD_TEAM") { - if(lst.size() != 24) - { - qWarning("Net: Bad ADDTEAM message"); - return; - } - QStringList tmp = lst; - tmp.removeFirst(); - emit AddNetTeam(tmp); - return; - } + if(lst[0] == "KICKED") + { + netClientState = InLobby; + askRoomsList(); + emit LeftRoom(tr("You got kicked")); + m_playersModel->resetRoomFlags(); - if (lst[0] == "REMOVE_TEAM") { - if(lst.size() != 2) - { - qWarning("Net: Bad REMOVETEAM message"); - return; - } - emit RemoveNetTeam(HWTeam(lst[1])); - return; - } - - if(lst[0] == "ROOMABANDONED") { - netClientState = InLobby; - emit LeftRoom(tr("Room destroyed")); return; } - if(lst[0] == "KICKED") { - netClientState = InLobby; - emit LeftRoom(tr("You got kicked")); - return; - } - - if(lst[0] == "JOINED") { - if(lst.size() < 2) - { - qWarning("Net: Bad JOINED message"); - return; - } - - for(int i = 1; i < lst.size(); ++i) - { - if (lst[i] == mynick) - { - netClientState = InRoom; - emit EnteredGame(); - emit roomMaster(isChief); - if (isChief) - emit configAsked(); - } - - emit nickAdded(lst[i], isChief && (lst[i] != mynick)); - emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); - } - return; - } - - if(lst[0] == "LOBBY:JOINED") { + if(lst[0] == "LOBBY:JOINED") + { if(lst.size() < 2) { qWarning("Net: Bad JOINED message"); @@ -428,35 +469,45 @@ emit nickAddedLobby(lst[i], false); emit chatStringLobby(lst[i], tr("%1 *** %2 has joined").arg('\x03').arg("|nick|")); + m_playersModel->addPlayer(lst[i]); } return; } - if(lst[0] == "LEFT") { - if(lst.size() < 2) - { - qWarning("Net: Bad LEFT message"); - return; - } - emit nickRemoved(lst[1]); - if (lst.size() < 3) - emit chatStringFromNet(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); - else - emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); + if(lst[0] == "ROOM" && lst.size() == 10 && lst[1] == "ADD") + { + QStringList tmp = lst; + tmp.removeFirst(); + tmp.removeFirst(); + + m_roomsListModel->addRoom(tmp); return; } - if(lst[0] == "ROOM") { - if(lst.size() < 2) - { - qWarning("Net: Bad ROOM message"); - return; - } - RawSendNet(QString("LIST")); + if(lst[0] == "ROOM" && lst.size() == 11 && lst[1] == "UPD") + { + QStringList tmp = lst; + tmp.removeFirst(); + tmp.removeFirst(); + + QString roomName = tmp.takeFirst(); + m_roomsListModel->updateRoom(roomName, tmp); + + // keep track of room name so correct name is displayed when you become room admin + if(myroom == roomName) + myroom = tmp[1]; + return; } - if(lst[0] == "LOBBY:LEFT") { + if(lst[0] == "ROOM" && lst.size() == 3 && lst[1] == "DEL") + { + m_roomsListModel->removeRoom(lst[2]); + return; + } + + if(lst[0] == "LOBBY:LEFT") + { if(lst.size() < 2) { qWarning("Net: Bad LOBBY:LEFT message"); @@ -467,21 +518,20 @@ emit chatStringLobby(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); else emit chatStringLobby(lst[1], tr("%1 *** %2 has left (%3)").arg('\x03').arg("|nick|", lst[2])); + + m_playersModel->removePlayer(lst[1]); + return; } - if (lst[0] == "RUN_GAME") { - netClientState = InGame; - emit AskForRunGame(); - return; - } - - if (lst[0] == "ASKPASSWORD") { + if (lst[0] == "ASKPASSWORD") + { emit AskForPassword(mynick); return; } - if (lst[0] == "NOTICE") { + if (lst[0] == "NOTICE") + { if(lst.size() < 2) { qWarning("Net: Bad NOTICE message"); @@ -501,72 +551,8 @@ return; } - if (lst[0] == "TEAM_ACCEPTED") { - if (lst.size() != 2) - { - qWarning("Net: Bad TEAM_ACCEPTED message"); - return; - } - emit TeamAccepted(lst[1]); - return; - } - - - if (lst[0] == "CFG") { - if(lst.size() < 3) - { - qWarning("Net: Bad CFG message"); - return; - } - QStringList tmp = lst; - tmp.removeFirst(); - tmp.removeFirst(); - if (lst[1] == "SCHEME") - emit netSchemeConfig(tmp); - else - emit paramChanged(lst[1], tmp); - return; - } - - if (lst[0] == "HH_NUM") { - if (lst.size() != 3) - { - qWarning("Net: Bad TEAM_ACCEPTED message"); - return; - } - HWTeam tmptm(lst[1]); - tmptm.setNumHedgehogs(lst[2].toUInt()); - emit hhnumChanged(tmptm); - return; - } - - if (lst[0] == "TEAM_COLOR") { - if (lst.size() != 3) - { - qWarning("Net: Bad TEAM_COLOR message"); - return; - } - HWTeam tmptm(lst[1]); - tmptm.setColor(QColor(lst[2])); - emit teamColorChanged(tmptm); - return; - } - - if (lst[0] == "EM") { - if(lst.size() < 2) - { - qWarning("Net: Bad EM message"); - return; - } - for(int i = 1; i < lst.size(); ++i) - { - QByteArray em = QByteArray::fromBase64(lst[i].toAscii()); - emit FromNet(em); - } - return; - } - - if (lst[0] == "BYE") { + if (lst[0] == "BYE") + { if (lst.size() < 2) { qWarning("Net: Bad BYE message"); @@ -582,58 +568,229 @@ return; } + if (lst[0] == "ADMIN_ACCESS") + { + // obsolete, see +a client flag + return; + } - if (lst[0] == "ADMIN_ACCESS") { - emit adminAccess(true); + if(netClientState == InLobby && lst[0] == "JOINED") + { + if(lst.size() < 2 || lst[1] != mynick) + { + qWarning("Net: Bad JOINED message"); + return; + } + + for(int i = 1; i < lst.size(); ++i) + { + if (lst[i] == mynick) + { + netClientState = InRoom; + emit EnteredGame(); + emit roomMaster(isChief); + if (isChief) + emit configAsked(); + } + + emit nickAdded(lst[i], isChief && (lst[i] != mynick)); + emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); + m_playersModel->playerJoinedRoom(lst[i]); + } return; } - if (lst[0] == "ROOM_CONTROL_ACCESS") { - if (lst.size() < 2) + if(netClientState == InRoom || netClientState == InGame) + { + if (lst[0] == "EM") + { + if(lst.size() < 2) + { + qWarning("Net: Bad EM message"); + return; + } + for(int i = 1; i < lst.size(); ++i) + { + QByteArray em = QByteArray::fromBase64(lst[i].toAscii()); + emit FromNet(em); + } + return; + } + + if (lst[0] == "ADD_TEAM") + { + if(lst.size() != 24) + { + qWarning("Net: Bad ADDTEAM message"); + return; + } + QStringList tmp = lst; + tmp.removeFirst(); + emit AddNetTeam(tmp); + return; + } + + if (lst[0] == "REMOVE_TEAM") { - qWarning("Net: Bad ROOM_CONTROL_ACCESS message"); + if(lst.size() != 2) + { + qWarning("Net: Bad REMOVETEAM message"); + return; + } + emit RemoveNetTeam(HWTeam(lst[1])); + return; + } + + if(lst[0] == "ROOMABANDONED") + { + netClientState = InLobby; + m_playersModel->resetRoomFlags(); + emit LeftRoom(tr("Room destroyed")); + return; + } + + if (lst[0] == "RUN_GAME") + { + netClientState = InGame; + emit AskForRunGame(); + return; + } + + if (lst[0] == "TEAM_ACCEPTED") + { + if (lst.size() != 2) + { + qWarning("Net: Bad TEAM_ACCEPTED message"); + return; + } + emit TeamAccepted(lst[1]); return; } - isChief = (lst[1] != "0"); - emit roomMaster(isChief); - return; + + if (lst[0] == "CFG") + { + if(lst.size() < 3) + { + qWarning("Net: Bad CFG message"); + return; + } + QStringList tmp = lst; + tmp.removeFirst(); + tmp.removeFirst(); + if (lst[1] == "SCHEME") + emit netSchemeConfig(tmp); + else + emit paramChanged(lst[1], tmp); + return; + } + + if (lst[0] == "HH_NUM") + { + if (lst.size() != 3) + { + qWarning("Net: Bad TEAM_ACCEPTED message"); + return; + } + HWTeam tmptm(lst[1]); + tmptm.setNumHedgehogs(lst[2].toUInt()); + emit hhnumChanged(tmptm); + return; + } + + if (lst[0] == "TEAM_COLOR") + { + if (lst.size() != 3) + { + qWarning("Net: Bad TEAM_COLOR message"); + return; + } + HWTeam tmptm(lst[1]); + tmptm.setColor(lst[2].toInt()); + emit teamColorChanged(tmptm); + return; + } + + if(lst[0] == "JOINED") + { + if(lst.size() < 2) + { + qWarning("Net: Bad JOINED message"); + return; + } + + for(int i = 1; i < lst.size(); ++i) + { + emit nickAdded(lst[i], isChief && (lst[i] != mynick)); + emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); + m_playersModel->playerJoinedRoom(lst[i]); + } + return; + } + + if(lst[0] == "LEFT") + { + if(lst.size() < 2) + { + qWarning("Net: Bad LEFT message"); + return; + } + emit nickRemoved(lst[1]); + if (lst.size() < 3) + emit chatStringFromNet(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); + else + emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); + m_playersModel->playerLeftRoom(lst[1]); + return; + } + + // obsolete + if (lst[0] == "ROOM_CONTROL_ACCESS") + { + if (lst.size() < 2) + { + qWarning("Net: Bad ROOM_CONTROL_ACCESS message"); + return; + } + return; + } } - qWarning() << "Net: Unknown message:" << lst; + qWarning() << "Net: Unknown message or wrong state:" << lst; } void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) { if (isChief) - RawSendNet(QString("HH_NUM%1%2%1%3") - .arg(delimeter) - .arg(team.name()) - .arg(team.numHedgehogs())); + RawSendNet(QString("HH_NUM%1%2%1%3") + .arg(delimeter) + .arg(team.name()) + .arg(team.numHedgehogs())); } void HWNewNet::onTeamColorChanged(const HWTeam& team) { if (isChief) - RawSendNet(QString("TEAM_COLOR%1%2%1%3") - .arg(delimeter) - .arg(team.name()) - .arg(team.color().name())); + RawSendNet(QString("TEAM_COLOR%1%2%1%3") + .arg(delimeter) + .arg(team.name()) + .arg(team.color())); } void HWNewNet::onParamChanged(const QString & param, const QStringList & value) { if (isChief) RawSendNet( - QString("CFG%1%2%1%3") - .arg(delimeter) - .arg(param) - .arg(value.join(QString(delimeter))) - ); + QString("CFG%1%2%1%3") + .arg(delimeter) + .arg(param) + .arg(value.join(QString(delimeter))) + ); } void HWNewNet::chatLineToNet(const QString& str) { - if(str != "") { + if(str != "") + { RawSendNet(QString("CHAT") + delimeter + str); emit(chatStringFromMe(HWProto::formatChatMsg(mynick, str))); } @@ -641,7 +798,8 @@ void HWNewNet::chatLineToLobby(const QString& str) { - if(str != "") { + if(str != "") + { RawSendNet(QString("CHAT") + delimeter + str); emit chatStringLobby(mynick, HWProto::formatChatMsgForFrontend(str)); } @@ -689,8 +847,11 @@ void HWNewNet::gameFinished(bool correctly) { - if (netClientState == InGame) netClientState = InRoom; - RawSendNet(QString("ROUNDFINISHED%1%2").arg(delimeter).arg(correctly ? "1" : "0")); + if (netClientState == InGame) + { + netClientState = InRoom; + RawSendNet(QString("ROUNDFINISHED%1%2").arg(delimeter).arg(correctly ? "1" : "0")); + } } void HWNewNet::banPlayer(const QString & nick) @@ -710,7 +871,8 @@ void HWNewNet::followPlayer(const QString & nick) { - if (!isInRoom()) { + if (!isInRoom()) + { RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick)); isChief = false; } @@ -745,6 +907,7 @@ void HWNewNet::partRoom() { netClientState = InLobby; + m_playersModel->resetRoomFlags(); RawSendNet(QString("PART")); } @@ -784,3 +947,18 @@ } } } + +RoomsListModel * HWNewNet::roomsListModel() +{ + return m_roomsListModel; +} + +QAbstractItemModel *HWNewNet::lobbyPlayersModel() +{ + return m_lobbyPlayersModel; +} + +QAbstractItemModel *HWNewNet::roomPlayersModel() +{ + return m_roomPlayersModel; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/newnetclient.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,147 +31,159 @@ class GameUIConfig; class GameCFGWidget; class TeamSelWidget; +class RoomsListModel; +class PlayersListModel; +class QSortFilterProxyModel; +class QAbstractItemModel; extern char delimeter; class HWNewNet : public QObject { - Q_OBJECT + Q_OBJECT - public: - enum ClientState { Disconnected, Connecting, Connected, InLobby, InRoom, InGame }; + public: + enum ClientState { Disconnected, Connecting, Connected, InLobby, InRoom, InGame }; - HWNewNet(); - ~HWNewNet(); - void Connect(const QString & hostName, quint16 port, const QString & nick); - void Disconnect(); - void SendPasswordHash(const QString & hash); - void NewNick(const QString & nick); - bool isRoomChief(); - bool isInRoom(); - ClientState clientState(); - QString getNick(); - QString getRoom(); - QString getHost(); - - private: - bool isChief; - QString mynick; - QString myroom; - QString myhost; - QTcpSocket NetSocket; - QString seed; - bool m_game_connected; + HWNewNet(); + ~HWNewNet(); + void Connect(const QString & hostName, quint16 port, const QString & nick); + void Disconnect(); + void SendPasswordHash(const QString & hash); + void NewNick(const QString & nick); + bool isRoomChief(); + bool isInRoom(); + ClientState clientState(); + QString getNick(); + QString getRoom(); + QString getHost(); + RoomsListModel * roomsListModel(); + QAbstractItemModel * lobbyPlayersModel(); + QAbstractItemModel * roomPlayersModel(); - template - void SendCfgStrNet(T a) { - QByteArray strmsg; - strmsg.append(a); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - QString _msg = delimeter + QString(enginemsg.toBase64()); - RawSendNet(_msg); - } + private: + bool isChief; + QString mynick; + QString myroom; + QString myhost; + QTcpSocket NetSocket; + QString seed; + bool m_game_connected; + RoomsListModel * m_roomsListModel; + PlayersListModel * m_playersModel; + QSortFilterProxyModel * m_lobbyPlayersModel; + QSortFilterProxyModel * m_roomPlayersModel; - template - void SendCfgStrLoc(T a) { - QByteArray strmsg; - strmsg.append(QString(a).toUtf8()); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - emit FromNet(enginemsg); - } + template + void SendCfgStrNet(T a) + { + QByteArray strmsg; + strmsg.append(a); + quint8 sz = strmsg.size(); + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; + QString _msg = delimeter + QString(enginemsg.toBase64()); + RawSendNet(_msg); + } - QStringList cmdbuf; + template + void SendCfgStrLoc(T a) + { + QByteArray strmsg; + strmsg.append(QString(a).toUtf8()); + quint8 sz = strmsg.size(); + QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; + emit FromNet(enginemsg); + } - void RawSendNet(const QString & buf); - void RawSendNet(const QByteArray & buf); - void ParseCmd(const QStringList & lst); - void handleNotice(int n); + QStringList cmdbuf; - int loginStep; - ClientState netClientState; + void RawSendNet(const QString & buf); + void RawSendNet(const QByteArray & buf); + void ParseCmd(const QStringList & lst); + void handleNotice(int n); + + int loginStep; + ClientState netClientState; - signals: - void AskForRunGame(); - void connected(); - void disconnected(const QString & reason); - void Error(const QString & errmsg); - void Warning(const QString & wrnmsg); - void AskForPassword(const QString & nick); - void NickTaken(const QString & nick); - void AuthFailed(); - void EnteredGame(); - void LeftRoom(const QString & reason); - void nickAdded(const QString& nick, bool notifyNick); - void nickRemoved(const QString& nick); - void nickAddedLobby(const QString& nick, bool notifyNick); - void nickRemovedLobby(const QString& nick); - void FromNet(const QByteArray & buf); - void adminAccess(bool); - void roomMaster(bool); + signals: + void AskForRunGame(); + void connected(); + void disconnected(const QString & reason); + void Error(const QString & errmsg); + void Warning(const QString & wrnmsg); + void AskForPassword(const QString & nick); + void NickTaken(const QString & nick); + void AuthFailed(); + void EnteredGame(); + void LeftRoom(const QString & reason); + void nickAdded(const QString& nick, bool notifyNick); + void nickRemoved(const QString& nick); + void nickAddedLobby(const QString& nick, bool notifyNick); + void nickRemovedLobby(const QString& nick); + void FromNet(const QByteArray & buf); + void adminAccess(bool); + void roomMaster(bool); - void netSchemeConfig(QStringList &); - void paramChanged(const QString & param, const QStringList & value); - void configAsked(); + void netSchemeConfig(QStringList &); + void paramChanged(const QString & param, const QStringList & value); + void configAsked(); - void TeamAccepted(const QString&); - void AddNetTeam(const HWTeam&); - void RemoveNetTeam(const HWTeam&); - void hhnumChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); - void chatStringLobby(const QString&); - void chatStringLobby(const QString&, const QString&); - void chatStringFromNet(const QString&); - void chatStringFromMe(const QString&); - void chatStringFromMeLobby(const QString&); + void TeamAccepted(const QString&); + void AddNetTeam(const HWTeam&); + void RemoveNetTeam(const HWTeam&); + void hhnumChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); + void chatStringLobby(const QString&); + void chatStringLobby(const QString&, const QString&); + void chatStringFromNet(const QString&); + void chatStringFromMe(const QString&); + void chatStringFromMeLobby(const QString&); - void roomsList(const QStringList&); - void serverMessage(const QString &); - void serverMessageNew(const QString &); - void serverMessageOld(const QString &); - void latestProtocolVar(int); + void roomsList(const QStringList&); + void serverMessage(const QString &); + void serverMessageNew(const QString &); + void serverMessageOld(const QString &); + void latestProtocolVar(int); - void setReadyStatus(const QString & nick, bool isReady); - void setMyReadyStatus(bool isReady); + void setMyReadyStatus(bool isReady); - public slots: - void ToggleReady(); - void chatLineToNet(const QString& str); - void chatLineToLobby(const QString& str); - void SendTeamMessage(const QString& str); - void SendNet(const QByteArray & buf); - void AddTeam(const HWTeam & team); - void RemoveTeam(const HWTeam& team); - void onHedgehogsNumChanged(const HWTeam& team); - void onTeamColorChanged(const HWTeam& team); - void onParamChanged(const QString & param, const QStringList & value); + public slots: + void ToggleReady(); + void chatLineToNet(const QString& str); + void chatLineToLobby(const QString& str); + void SendTeamMessage(const QString& str); + void SendNet(const QByteArray & buf); + void AddTeam(const HWTeam & team); + void RemoveTeam(const HWTeam& team); + void onHedgehogsNumChanged(const HWTeam& team); + void onTeamColorChanged(const HWTeam& team); + void onParamChanged(const QString & param, const QStringList & value); - void setServerMessageNew(const QString &); - void setServerMessageOld(const QString &); - void setLatestProtocolVar(int proto); - void askServerVars(); + void setServerMessageNew(const QString &); + void setServerMessageOld(const QString &); + void setLatestProtocolVar(int proto); + void askServerVars(); - void JoinRoom(const QString & room); - void CreateRoom(const QString & room); - void updateRoomName(const QString &); - void askRoomsList(); - void gameFinished(bool correcly); - void banPlayer(const QString &); - void kickPlayer(const QString &); - void infoPlayer(const QString &); - void followPlayer(const QString &); - void startGame(); - void toggleRestrictJoins(); - void toggleRestrictTeamAdds(); - void partRoom(); - void clearAccountsCache(); + void JoinRoom(const QString & room); + void CreateRoom(const QString & room); + void updateRoomName(const QString &); + void askRoomsList(); + void gameFinished(bool correcly); + void banPlayer(const QString &); + void kickPlayer(const QString &); + void infoPlayer(const QString &); + void followPlayer(const QString &); + void startGame(); + void toggleRestrictJoins(); + void toggleRestrictTeamAdds(); + void partRoom(); + void clearAccountsCache(); - private slots: - void ClientRead(); - void OnConnect(); - void OnDisconnect(); - void displayError(QAbstractSocket::SocketError socketError); + private slots: + void ClientRead(); + void OnConnect(); + void OnDisconnect(); + void displayError(QAbstractSocket::SocketError socketError); }; #endif // _NEW_NETCLIENT_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/proto.cpp --- a/QTfrontend/net/proto.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/proto.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/proto.h --- a/QTfrontend/net/proto.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/proto.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,15 +26,15 @@ class HWProto : public QObject { - Q_OBJECT + Q_OBJECT -public: - HWProto(); - static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); - static QByteArray & addByteArrayToBuffer(QByteArray & buf, const QByteArray & msg); - static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); - static QString formatChatMsg(const QString & nick, const QString & msg); - static QString formatChatMsgForFrontend(const QString & msg); + public: + HWProto(); + static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); + static QByteArray & addByteArrayToBuffer(QByteArray & buf, const QByteArray & msg); + static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); + static QString formatChatMsg(const QString & nick, const QString & msg); + static QString formatChatMsgForFrontend(const QString & msg); }; #endif // _PROTO_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/recorder.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/net/recorder.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,130 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include + +#include "recorder.h" +#include "gameuiconfig.h" +#include "hwconsts.h" +#include "game.h" +#include "libav_iteraction.h" + +// Encoding is memory expensive process, so we need to limit maximum number +// of simultaneous encoders. +static const int maxRecorders = 3; +static int numRecorders = 0; + +static QList queue; + +HWRecorder::HWRecorder(GameUIConfig * config, const QString &prefix) : + TCPBase(false) +{ + this->config = config; + this->prefix = prefix; + finished = false; + name = prefix + "." + LibavIteraction::instance().getExtension(config->AVFormat()); +} + +HWRecorder::~HWRecorder() +{ + emit encodingFinished(finished); + if (queue.empty()) + numRecorders--; + else + queue.takeFirst()->Start(); +} + +void HWRecorder::onClientDisconnect() +{ +} + +void HWRecorder::onClientRead() +{ + quint8 msglen; + quint32 bufsize; + while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) && + ((msglen = readbuffer.data()[0]) < bufsize)) + { + QByteArray msg = readbuffer.left(msglen + 1); + readbuffer.remove(0, msglen + 1); + switch (msg.at(1)) + { + case '?': + SendIPC("!"); + break; + case 'p': + emit onProgress((quint8(msg.at(2))*256.0 + quint8(msg.at(3)))*0.0001); + break; + case 'v': + finished = true; + break; + } + } +} + +void HWRecorder::EncodeVideo(const QByteArray & record) +{ + toSendBuf = record; + toSendBuf.replace(QByteArray("\x02TD"), QByteArray("\x02TV")); + toSendBuf.replace(QByteArray("\x02TL"), QByteArray("\x02TV")); + toSendBuf.replace(QByteArray("\x02TN"), QByteArray("\x02TV")); + toSendBuf.replace(QByteArray("\x02TS"), QByteArray("\x02TV")); + + if (numRecorders < maxRecorders) + { + numRecorders++; + Start(); // run engine + } + else + queue.push_back(this); +} + +QStringList HWRecorder::getArguments() +{ + QStringList arguments; + QRect resolution = config->rec_Resolution(); + arguments << cfgdir->absolutePath(); + arguments << QString::number(resolution.width()); + arguments << QString::number(resolution.height()); + arguments << "32"; // bpp + arguments << QString("%1").arg(ipc_port); + arguments << "0"; // fullscreen + arguments << "0"; // sound + arguments << "0"; // music + arguments << "0"; // sound volume + arguments << QString::number(config->timerInterval()); + arguments << datadir->absolutePath(); + arguments << (config->isShowFPSEnabled() ? "1" : "0"); + arguments << (config->isAltDamageEnabled() ? "1" : "0"); + arguments << config->netNick().toUtf8().toBase64(); + arguments << QString::number(config->translateQuality()); + arguments << QString::number(config->stereoMode()); + arguments << HWGame::tr("en.txt"); + arguments << QString::number(config->rec_Framerate()); // framerate numerator + arguments << "1"; // framerate denominator + arguments << prefix; + arguments << config->AVFormat(); + arguments << config->videoCodec(); +// Could use a field to use quality instead. maybe quality could override bitrate - or just pass (and set) both. +// The library does support using both at once after all. + arguments << QString::number(config->rec_Bitrate()*1024); + arguments << (config->recordAudio()? config->audioCodec() : "no"); + + return arguments; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/recorder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/net/recorder.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,58 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef RECORDER_H +#define RECORDER_H + +#include +#include + +#include "tcpBase.h" + +class GameUIConfig; +class VideoItem; + +class HWRecorder : public TCPBase +{ + Q_OBJECT + public: + HWRecorder(GameUIConfig * config, const QString & prefix); + virtual ~HWRecorder(); + + void EncodeVideo(const QByteArray & record); + + VideoItem * item; // used by pagevideos + QString name; + QString prefix; + + protected: + // virtuals from TCPBase + virtual QStringList getArguments(); + virtual void onClientRead(); + virtual void onClientDisconnect(); + + signals: + void onProgress(float progress); // 0 < progress < 1 + void encodingFinished(bool success); + + private: + bool finished; + GameUIConfig * config; +}; + +#endif // RECORDER_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/tcpBase.cpp --- a/QTfrontend/net/tcpBase.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/tcpBase.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +21,7 @@ #include #include - +#include #include #include "hwconsts.h" @@ -31,99 +31,124 @@ TCPBase::~TCPBase() { + if (IPCSocket) + IPCSocket->deleteLater(); } TCPBase::TCPBase(bool demoMode) : - m_isDemoMode(demoMode), - IPCSocket(0) + m_isDemoMode(demoMode), + IPCSocket(0) { - if(!IPCServer) { - IPCServer = new QTcpServer(0); - IPCServer->setMaxPendingConnections(1); - if (!IPCServer->listen(QHostAddress::LocalHost)) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server: %1.") - .arg(IPCServer->errorString())); - exit(0); // FIXME - should be graceful exit here + if(!IPCServer) + { + IPCServer = new QTcpServer(0); + IPCServer->setMaxPendingConnections(1); + if (!IPCServer->listen(QHostAddress::LocalHost)) + { + QMessageBox deniedMsg(QApplication::activeWindow()); + deniedMsg.setIcon(QMessageBox::Critical); + deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error")); + deniedMsg.setText(QMessageBox::tr("Unable to start the server: %1.").arg(IPCServer->errorString())); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + + exit(0); // FIXME - should be graceful exit here (lower Critical -> Warning above when implemented) + } } - } - ipc_port=IPCServer->serverPort(); + ipc_port=IPCServer->serverPort(); } void TCPBase::NewConnection() { - if(IPCSocket) { - // connection should be already finished - return; - } - disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); - IPCSocket = IPCServer->nextPendingConnection(); - if(!IPCSocket) return; - connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); - connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - SendToClientFirst(); + if(IPCSocket) + { + // connection should be already finished + return; + } + disconnect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); + IPCSocket = IPCServer->nextPendingConnection(); + if(!IPCSocket) return; + connect(IPCSocket, SIGNAL(disconnected()), this, SLOT(ClientDisconnect())); + connect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + SendToClientFirst(); + + if(srvsList.size()==1) srvsList.pop_front(); + emit isReadyNow(); } void TCPBase::RealStart() { - connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); - IPCSocket = 0; + connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection())); + IPCSocket = 0; - QProcess * process; - process = new QProcess; - connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); - QStringList arguments=getArguments(); + QProcess * process; + process = new QProcess; + connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError))); + QStringList arguments=getArguments(); - // redirect everything written on stdout/stderr - if(isDevBuild) - process->setProcessChannelMode(QProcess::ForwardedChannels); - process->start(bindir->absolutePath() + "/hwengine", arguments); + // redirect everything written on stdout/stderr + if(isDevBuild) + process->setProcessChannelMode(QProcess::ForwardedChannels); + process->start(bindir->absolutePath() + "/hwengine", arguments); } void TCPBase::ClientDisconnect() { - disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - onClientDisconnect(); + disconnect(IPCSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + onClientDisconnect(); - if(srvsList.size()==1) srvsList.pop_front(); - emit isReadyNow(); - IPCSocket->deleteLater(); - deleteLater(); + /* if(srvsList.size()==1) srvsList.pop_front(); + emit isReadyNow();*/ + IPCSocket->deleteLater(); + + // make sure this object is not in the server list anymore + srvsList.removeOne(this); + + deleteLater(); } void TCPBase::ClientRead() { - QByteArray readed=IPCSocket->readAll(); - if(readed.isEmpty()) return; - readbuffer.append(readed); - onClientRead(); + QByteArray readed=IPCSocket->readAll(); + if(readed.isEmpty()) return; + readbuffer.append(readed); + onClientRead(); } void TCPBase::StartProcessError(QProcess::ProcessError error) { - QMessageBox::critical(0, tr("Error"), - tr("Unable to run engine: %1 (") - .arg(error) + bindir->absolutePath() + "/hwengine)"); + QMessageBox deniedMsg(QApplication::activeWindow()); + deniedMsg.setIcon(QMessageBox::Critical); + deniedMsg.setWindowTitle(QMessageBox::tr("TCP - Error")); + deniedMsg.setText(QMessageBox::tr("Unable to run engine at ") + bindir->absolutePath() + "/hwengine\n" + + QMessageBox::tr("Error code: %1").arg(error)); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + + ClientDisconnect(); } void TCPBase::tcpServerReady() { - disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); + disconnect(srvsList.takeFirst(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); - RealStart(); + RealStart(); } void TCPBase::Start() { - if(srvsList.isEmpty()) { - srvsList.push_back(this); - } else { - connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); - srvsList.push_back(this); - return; - } + if(srvsList.isEmpty()) + { + srvsList.push_back(this); + } + else + { + connect(srvsList.back(), SIGNAL(isReadyNow()), this, SLOT(tcpServerReady())); + srvsList.push_back(this); + return; + } - RealStart(); + RealStart(); } void TCPBase::onClientRead() @@ -150,7 +175,8 @@ if (!IPCSocket) { toSendBuf += buf; - } else + } + else { if (toSendBuf.size() > 0) { @@ -158,9 +184,10 @@ if(m_isDemoMode) demo.append(toSendBuf); toSendBuf.clear(); } - if(!buf.isEmpty()) { - IPCSocket->write(buf); - if(m_isDemoMode) demo.append(buf); + if(!buf.isEmpty()) + { + IPCSocket->write(buf); + if(m_isDemoMode) demo.append(buf); } } } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/net/tcpBase.h --- a/QTfrontend/net/tcpBase.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/net/tcpBase.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,47 +35,47 @@ class TCPBase : public QObject { - Q_OBJECT + Q_OBJECT - public: - TCPBase(bool demoMode); - virtual ~TCPBase(); + public: + TCPBase(bool demoMode); + virtual ~TCPBase(); - signals: - void isReadyNow(); + signals: + void isReadyNow(); - protected: - quint16 ipc_port; + protected: + quint16 ipc_port; - void Start(); + void Start(); - QByteArray readbuffer; + QByteArray readbuffer; - QByteArray toSendBuf; - QByteArray demo; + QByteArray toSendBuf; + QByteArray demo; - void SendIPC(const QByteArray & buf); - void RawSendIPC(const QByteArray & buf); + void SendIPC(const QByteArray & buf); + void RawSendIPC(const QByteArray & buf); - virtual QStringList getArguments()=0; - virtual void onClientRead(); - virtual void onClientDisconnect(); - virtual void SendToClientFirst(); + virtual QStringList getArguments()=0; + virtual void onClientRead(); + virtual void onClientDisconnect(); + virtual void SendToClientFirst(); - private: - static QPointer IPCServer; + private: + static QPointer IPCServer; - bool m_isDemoMode; - void RealStart(); - QPointer IPCSocket; + bool m_isDemoMode; + void RealStart(); + QPointer IPCSocket; - private slots: - void NewConnection(); - void ClientDisconnect(); - void ClientRead(); - void StartProcessError(QProcess::ProcessError error); + private slots: + void NewConnection(); + void ClientDisconnect(); + void ClientRead(); + void StartProcessError(QProcess::ProcessError error); - void tcpServerReady(); + void tcpServerReady(); }; #endif // _TCPBASE_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/BackgroundBirthday.png Binary file QTfrontend/res/BackgroundBirthday.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/BackgroundChristmas.png Binary file QTfrontend/res/BackgroundChristmas.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/BackgroundEaster.png Binary file QTfrontend/res/BackgroundEaster.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/Confetti.png Binary file QTfrontend/res/Confetti.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/Egg.png Binary file QTfrontend/res/Egg.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/Flake.png Binary file QTfrontend/res/Flake.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/Videos.png Binary file QTfrontend/res/Videos.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/friend.png Binary file QTfrontend/res/chat/friend.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/hedgehog.png Binary file QTfrontend/res/chat/hedgehog.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/hedgehog_gray.png Binary file QTfrontend/res/chat/hedgehog_gray.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/ignore.png Binary file QTfrontend/res/chat/ignore.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/ingame.png Binary file QTfrontend/res/chat/ingame.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/lamp.png Binary file QTfrontend/res/chat/lamp.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/lamp_off.png Binary file QTfrontend/res/chat/lamp_off.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/roomadmin.png Binary file QTfrontend/res/chat/roomadmin.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/roomadmin_gray.png Binary file QTfrontend/res/chat/roomadmin_gray.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/serveradmin.png Binary file QTfrontend/res/chat/serveradmin.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat/serveradmin_gray.png Binary file QTfrontend/res/chat/serveradmin_gray.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_default.png Binary file QTfrontend/res/chat_default.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_default_off.png Binary file QTfrontend/res/chat_default_off.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_default_on.png Binary file QTfrontend/res/chat_default_on.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_friend.png Binary file QTfrontend/res/chat_friend.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_friend_off.png Binary file QTfrontend/res/chat_friend_off.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_friend_on.png Binary file QTfrontend/res/chat_friend_on.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_ignore.png Binary file QTfrontend/res/chat_ignore.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_ignore_off.png Binary file QTfrontend/res/chat_ignore_off.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/chat_ignore_on.png Binary file QTfrontend/res/chat_ignore_on.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/css/birthday.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/css/birthday.css Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,248 @@ +/****************************************************************************** + * + * CSS-like definition of Qt frontend appearance + * + ****************************************************************************** + * + * see http://doc.qt.nokia.com/4.5/stylesheet.html + * + ****************************************************************************** + * + * This file can be stored at different locations, but it will be read only + * once, based on first file found in this order: + * + * /Data/css/birthday.css + * /css/birthday.css + * (:/res/css/birthday.css) + * + *****************************************************************************/ + +HWForm,QDialog { +background-image: url(":/res/BackgroundBirthday.png"); +background-position: bottom center; +background-repeat: repeat-x; +background-color: #141250; +} + +* { +color: #ffcc00; +selection-background-color: #ffcc00; +selection-color: #00351d; +} + +a { color:#c8c8ff; } + +QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, +QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item { +background-color: rgba(13, 5, 68, 70%); +} + +QComboBox::separator { +border: solid; border-width: 3px; border-color: #ffcc00; +} + +QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, +QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit, +QComboBox QAbstractItemView, IconedGroupBox, +.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, +QTabWidget::pane, QTabBar::tab { +border: solid; +border-width: 3px; +border-color: #ffcc00; +} + +QPushButton:hover, QLineEdit:hover, QListWidget:hover, +QSpinBox:hover, QToolBox:hover, QComboBox:hover { +border-color: yellow; +} + +QLineEdit, QListWidget,QTableView, QTextBrowser, +QSpinBox, QToolBox, QPlainTextEdit { +border-radius: 10px; +} + +QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, +QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, +IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, +SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit { +font: bold 13px; +} +SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected { +background-position: bottom center; +background-repeat: repeat-x; +background-color: #000000; +} +.QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget { +background-position: bottom center; +background-repeat: repeat-x; +border-radius: 16px; +background-color: rgba(13, 5, 68, 70%); +padding: 6px; +} +/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well +IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, +IconedGroupBox QSpinBox { +border-radius: 0; +} +IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ +IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{ +background-color: #130f2c; +} + + +QPushButton { +border-radius: 8px; +background-origin: margin; +background-position: top left; +background-color: rgba(18, 42, 5, 70%); +} + +QPushButton:pressed{ +border-color: white; +} + +QPushButton:focus { +outline: none; +} + + +QHeaderView { +border-radius: 0; +border-width: 0; +border-bottom-width: 3px; +background-color: #00351d; +} +QTableView { +alternate-background-color: #2f213a; +gridline-color: transparent; +} + +QTabBar::tab { +border-bottom-width: 0; +border-radius: 0; +border-top-left-radius: 6px; +border-top-right-radius: 6px; +padding: 3px; +} +QTabBar::tab:!selected { +color: #0d0544; +background-color: #ffcc00; +} +QSpinBox::up-button{ +background: transparent; +width: 16px; +height: 10px; +} + +QSpinBox::up-arrow { +image: url(":/res/spin_up.png"); +} + +QSpinBox::down-arrow { +image: url(":/res/spin_down.png"); +} + +QSpinBox::down-button { +background: transparent; +width: 16px; +height: 10px; +} + +QComboBox { +border-radius: 10px; +padding: 3px; +} +QComboBox:pressed{ +border-color: white; +} +QComboBox::drop-down{ +border: transparent; +width: 25px; +} +QComboBox::down-arrow { +image: url(":/res/dropdown.png"); +} + +VertScrArea { +background-position: bottom center; +background-repeat: repeat-x; +} + +IconedGroupBox { +border-radius: 16px; +padding: 2px; +} + +QGroupBox::title{ +subcontrol-origin: margin; +subcontrol-position: top left; +text-align: left; +left: 15px; +top: -4px; +} + +QCheckBox::indicator:checked{ +image: url(":/res/checked.png"); +} +QCheckBox::indicator:unchecked{ +image: url(":/res/unchecked.png"); +} + +.QWidget{ +background: transparent; +} + +QTabWidget::pane { +border-top-width: 2px; +} + +QMenu{ +background-color: #ffcc00; +margin: 3px; +} +QMenu::item { +background-color: #0d0544; +border: 1px solid transparent; +font: bold; +padding: 2px 25px 2px 20px; +} +QMenu::item:selected { +background-color: #2d2564; +} +QMenu::indicator { +width: 16px; +height: 16px; +} +QMenu::indicator:non-exclusive:checked{ +image: url(":/res/checked.png"); +} +QMenu::indicator:non-exclusive:unchecked{ +image: url(":/res/unchecked.png"); +} + +QToolTip{ +background-color: #0d0544; +border: 1px solid #ffcc00; +} + +:disabled{ +color: #a0a0a0; +} +SquareLabel, ItemNum { +background-color: #000000; +} + +QSlider::groove::horizontal { +height: 2px; +margin: 2px 0px; +background-color: #ffcc00; +} + +QSlider::handle::horizontal { +border: 0px; +margin: -2px 0px; +border-radius: 3px; +background-color: #ffcc00; +width: 8px; +} + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/css/christmas.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/css/christmas.css Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,248 @@ +/****************************************************************************** + * + * CSS-like definition of Qt frontend appearance + * + ****************************************************************************** + * + * see http://doc.qt.nokia.com/4.5/stylesheet.html + * + ****************************************************************************** + * + * This file can be stored at different locations, but it will be read only + * once, based on first file found in this order: + * + * /Data/css/christmas.css + * /css/christmas.css + * (:/res/css/christmas.css) + * + *****************************************************************************/ + +HWForm,QDialog { +background-image: url(":/res/BackgroundChristmas.png"); +background-position: bottom center; +background-repeat: repeat-x; +background-color: #141250; +} + +* { +color: #ffcc00; +selection-background-color: #ffcc00; +selection-color: #00351d; +} + +a { color:#c8c8ff; } + +QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, +QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item { +background-color: rgba(13, 5, 68, 70%); +} + +QComboBox::separator { +border: solid; border-width: 3px; border-color: #ffcc00; +} + +QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, +QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit, +QComboBox QAbstractItemView, IconedGroupBox, +.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, +QTabWidget::pane, QTabBar::tab { +border: solid; +border-width: 3px; +border-color: #ffcc00; +} + +QPushButton:hover, QLineEdit:hover, QListWidget:hover, +QSpinBox:hover, QToolBox:hover, QComboBox:hover { +border-color: yellow; +} + +QLineEdit, QListWidget,QTableView, QTextBrowser, +QSpinBox, QToolBox, QPlainTextEdit { +border-radius: 10px; +} + +QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, +QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, +IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, +SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit { +font: bold 13px; +} +SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected { +background-position: bottom center; +background-repeat: repeat-x; +background-color: #000000; +} +.QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget { +background-position: bottom center; +background-repeat: repeat-x; +border-radius: 16px; +background-color: rgba(13, 5, 68, 70%); +padding: 6px; +} +/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well +IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, +IconedGroupBox QSpinBox { +border-radius: 0; +} +IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ +IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{ +background-color: #130f2c; +} + + +QPushButton { +border-radius: 8px; +background-origin: margin; +background-position: top left; +background-color: rgba(18, 42, 5, 70%); +} + +QPushButton:pressed{ +border-color: white; +} + +QPushButton:focus { +outline: none; +} + + +QHeaderView { +border-radius: 0; +border-width: 0; +border-bottom-width: 3px; +background-color: #00351d; +} +QTableView { +alternate-background-color: #2f213a; +gridline-color: transparent; +} + +QTabBar::tab { +border-bottom-width: 0; +border-radius: 0; +border-top-left-radius: 6px; +border-top-right-radius: 6px; +padding: 3px; +} +QTabBar::tab:!selected { +color: #0d0544; +background-color: #ffcc00; +} +QSpinBox::up-button{ +background: transparent; +width: 16px; +height: 10px; +} + +QSpinBox::up-arrow { +image: url(":/res/spin_up.png"); +} + +QSpinBox::down-arrow { +image: url(":/res/spin_down.png"); +} + +QSpinBox::down-button { +background: transparent; +width: 16px; +height: 10px; +} + +QComboBox { +border-radius: 10px; +padding: 3px; +} +QComboBox:pressed{ +border-color: white; +} +QComboBox::drop-down{ +border: transparent; +width: 25px; +} +QComboBox::down-arrow { +image: url(":/res/dropdown.png"); +} + +VertScrArea { +background-position: bottom center; +background-repeat: repeat-x; +} + +IconedGroupBox { +border-radius: 16px; +padding: 2px; +} + +QGroupBox::title{ +subcontrol-origin: margin; +subcontrol-position: top left; +text-align: left; +left: 15px; +top: -4px; +} + +QCheckBox::indicator:checked{ +image: url(":/res/checked.png"); +} +QCheckBox::indicator:unchecked{ +image: url(":/res/unchecked.png"); +} + +.QWidget{ +background: transparent; +} + +QTabWidget::pane { +border-top-width: 2px; +} + +QMenu{ +background-color: #ffcc00; +margin: 3px; +} +QMenu::item { +background-color: #0d0544; +border: 1px solid transparent; +font: bold; +padding: 2px 25px 2px 20px; +} +QMenu::item:selected { +background-color: #2d2564; +} +QMenu::indicator { +width: 16px; +height: 16px; +} +QMenu::indicator:non-exclusive:checked{ +image: url(":/res/checked.png"); +} +QMenu::indicator:non-exclusive:unchecked{ +image: url(":/res/unchecked.png"); +} + +QToolTip{ +background-color: #0d0544; +border: 1px solid #ffcc00; +} + +:disabled{ +color: #a0a0a0; +} +SquareLabel, ItemNum { +background-color: #000000; +} + +QSlider::groove::horizontal { +height: 2px; +margin: 2px 0px; +background-color: #ffcc00; +} + +QSlider::handle::horizontal { +border: 0px; +margin: -2px 0px; +border-radius: 3px; +background-color: #ffcc00; +width: 8px; +} + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/css/easter.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/css/easter.css Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,248 @@ +/****************************************************************************** + * + * CSS-like definition of Qt frontend appearance + * + ****************************************************************************** + * + * see http://doc.qt.nokia.com/4.5/stylesheet.html + * + ****************************************************************************** + * + * This file can be stored at different locations, but it will be read only + * once, based on first file found in this order: + * + * /Data/css/easter.css + * /css/easter.css + * (:/res/css/easter.css) + * + *****************************************************************************/ + +HWForm,QDialog { +background-image: url(":/res/BackgroundEaster.png"); +background-position: bottom center; +background-repeat: repeat-x; +background-color: #141250; +} + +* { +color: #ffcc00; +selection-background-color: #ffcc00; +selection-color: #00351d; +} + +a { color:#c8c8ff; } + +QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, +QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item { +background-color: rgba(13, 5, 68, 70%); +} + +QComboBox::separator { +border: solid; border-width: 3px; border-color: #ffcc00; +} + +QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, +QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit, +QComboBox QAbstractItemView, IconedGroupBox, +.QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, +QTabWidget::pane, QTabBar::tab { +border: solid; +border-width: 3px; +border-color: #ffcc00; +} + +QPushButton:hover, QLineEdit:hover, QListWidget:hover, +QSpinBox:hover, QToolBox:hover, QComboBox:hover { +border-color: yellow; +} + +QLineEdit, QListWidget,QTableView, QTextBrowser, +QSpinBox, QToolBox, QPlainTextEdit { +border-radius: 10px; +} + +QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, +QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, +IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, +SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit { +font: bold 13px; +} +SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected { +background-position: bottom center; +background-repeat: repeat-x; +background-color: #000000; +} +.QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget { +background-position: bottom center; +background-repeat: repeat-x; +border-radius: 16px; +background-color: rgba(13, 5, 68, 70%); +padding: 6px; +} +/* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well +IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, +IconedGroupBox QSpinBox { +border-radius: 0; +} +IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ +IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{ +background-color: #130f2c; +} + + +QPushButton { +border-radius: 8px; +background-origin: margin; +background-position: top left; +background-color: rgba(18, 42, 5, 70%); +} + +QPushButton:pressed{ +border-color: white; +} + +QPushButton:focus { +outline: none; +} + + +QHeaderView { +border-radius: 0; +border-width: 0; +border-bottom-width: 3px; +background-color: #00351d; +} +QTableView { +alternate-background-color: #2f213a; +gridline-color: transparent; +} + +QTabBar::tab { +border-bottom-width: 0; +border-radius: 0; +border-top-left-radius: 6px; +border-top-right-radius: 6px; +padding: 3px; +} +QTabBar::tab:!selected { +color: #0d0544; +background-color: #ffcc00; +} +QSpinBox::up-button{ +background: transparent; +width: 16px; +height: 10px; +} + +QSpinBox::up-arrow { +image: url(":/res/spin_up.png"); +} + +QSpinBox::down-arrow { +image: url(":/res/spin_down.png"); +} + +QSpinBox::down-button { +background: transparent; +width: 16px; +height: 10px; +} + +QComboBox { +border-radius: 10px; +padding: 3px; +} +QComboBox:pressed{ +border-color: white; +} +QComboBox::drop-down{ +border: transparent; +width: 25px; +} +QComboBox::down-arrow { +image: url(":/res/dropdown.png"); +} + +VertScrArea { +background-position: bottom center; +background-repeat: repeat-x; +} + +IconedGroupBox { +border-radius: 16px; +padding: 2px; +} + +QGroupBox::title{ +subcontrol-origin: margin; +subcontrol-position: top left; +text-align: left; +left: 15px; +top: -4px; +} + +QCheckBox::indicator:checked{ +image: url(":/res/checked.png"); +} +QCheckBox::indicator:unchecked{ +image: url(":/res/unchecked.png"); +} + +.QWidget{ +background: transparent; +} + +QTabWidget::pane { +border-top-width: 2px; +} + +QMenu{ +background-color: #ffcc00; +margin: 3px; +} +QMenu::item { +background-color: #0d0544; +border: 1px solid transparent; +font: bold; +padding: 2px 25px 2px 20px; +} +QMenu::item:selected { +background-color: #2d2564; +} +QMenu::indicator { +width: 16px; +height: 16px; +} +QMenu::indicator:non-exclusive:checked{ +image: url(":/res/checked.png"); +} +QMenu::indicator:non-exclusive:unchecked{ +image: url(":/res/unchecked.png"); +} + +QToolTip{ +background-color: #0d0544; +border: 1px solid #ffcc00; +} + +:disabled{ +color: #a0a0a0; +} +SquareLabel, ItemNum { +background-color: #000000; +} + +QSlider::groove::horizontal { +height: 2px; +margin: 2px 0px; +background-color: #ffcc00; +} + +QSlider::handle::horizontal { +border: 0px; +margin: -2px 0px; +border-radius: 3px; +background-color: #ffcc00; +width: 8px; +} + diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/res/css/qt.css --- a/QTfrontend/res/css/qt.css Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/res/css/qt.css Sun Oct 28 13:28:23 2012 +0100 @@ -32,8 +32,8 @@ a { color:#c8c8ff; } -QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, -QComboBox QAbstractItemView, QMenu::item { +QLineEdit, QListWidget, QListView, QTableView, QTextBrowser, QSpinBox, QComboBox, +QComboBox QAbstractItemView, QPlainTextEdit, QMenu::item { background-color: rgba(13, 5, 68, 70%); } @@ -41,8 +41,8 @@ border: solid; border-width: 3px; border-color: #ffcc00; } -QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, -QTextBrowser, QSpinBox, QToolBox, QComboBox, +QPushButton, QListWidget, QListView, QTableView, QLineEdit, QHeaderView, +QTextBrowser, QSpinBox, QToolBox, QComboBox, QPlainTextEdit, QComboBox QAbstractItemView, IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, QTabWidget::pane, QTabBar::tab { @@ -51,20 +51,20 @@ border-color: #ffcc00; } -QPushButton:hover, QLineEdit:hover, QListWidget:hover, +QPushButton:hover, QLineEdit:hover, QListWidget:hover, QListView:hover, QSpinBox:hover, QToolBox:hover, QComboBox:hover { border-color: yellow; } -QLineEdit, QListWidget,QTableView, QTextBrowser, -QSpinBox, QToolBox { +QLineEdit, QListWidget, QListView, QTableView, QTextBrowser, +QSpinBox, QToolBox, QPlainTextEdit { border-radius: 10px; } -QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, +QLineEdit, QLabel, QHeaderView, QListWidget, QListView, QTableView, QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, -SelWeaponWidget, QCheckBox, QRadioButton, QPushButton { +SelWeaponWidget, QCheckBox, QRadioButton, QPushButton, QPlainTextEdit { font: bold 13px; } SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected { @@ -116,17 +116,18 @@ alternate-background-color: #2f213a; gridline-color: transparent; } - +QTabWidget::pane { top: -2px; } QTabBar::tab { -border-bottom-width: 0; border-radius: 0; border-top-left-radius: 6px; border-top-right-radius: 6px; padding: 3px; +background-color: #00351d; +color: #ffcc00; } -QTabBar::tab:!selected { -color: #0d0544; -background-color: #ffcc00; +QTabBar::tab:selected { +border-bottom-color: #0d0544; +border-bottom-width: 0; } QSpinBox::up-button{ background: transparent; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/sdlkeys.h --- a/QTfrontend/sdlkeys.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/sdlkeys.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -char sdlkeys[1024][2][128] = { +char sdlkeys[1024][2][128] = +{ {"mousel", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Left button")}, {"mousem", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Middle button")}, {"mouser", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Right button")}, @@ -145,11 +146,12 @@ {"left_alt", QT_TRANSLATE_NOOP("binds (keys)", "Left alt")}, {"right_meta", QT_TRANSLATE_NOOP("binds (keys)", "Right meta")}, {"left_meta", QT_TRANSLATE_NOOP("binds (keys)", "Left meta")} - }; +}; // button name definitions for Microsoft's XBox360 controller // don't modify button order! -char xb360buttons[][128] = { +char xb360buttons[][128] = +{ QT_TRANSLATE_NOOP("binds (keys)", "A button"), QT_TRANSLATE_NOOP("binds (keys)", "B button"), QT_TRANSLATE_NOOP("binds (keys)", "X button"), @@ -164,7 +166,8 @@ // axis name definitions for Microsoft's XBox360 controller // don't modify axis order! -char xbox360axes[][128] = { +char xbox360axes[][128] = +{ QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Right)"), QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Left)"), QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Down)"), diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/team.cpp --- a/QTfrontend/team.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/team.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,11 @@ #include #include #include +#include #include "team.h" #include "hwform.h" -#include "hats.h" +#include "DataManager.h" HWTeam::HWTeam(const QString & teamname) : QObject(0) @@ -37,6 +38,7 @@ OldTeamName = m_name; for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { + m_hedgehogs.append(HWHog()); m_hedgehogs[i].Name = (QLineEdit::tr("hedgehog %1").arg(i+1)); m_hedgehogs[i].Hat = "NoHat"; } @@ -46,12 +48,14 @@ m_flag = "hedgewars"; for(int i = 0; i < BINDS_NUMBER; i++) { + m_binds.append(BindAction()); m_binds[i].action = cbinds[i].action; m_binds[i].strbind = cbinds[i].strbind; } m_rounds = 0; m_wins = 0; m_campaignProgress = 0; + m_color = 0; } HWTeam::HWTeam(const QStringList& strLst) : @@ -70,6 +74,7 @@ m_difficulty = strLst[6].toUInt(); for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { + m_hedgehogs.append(HWHog()); m_hedgehogs[i].Name=strLst[i * 2 + 7]; m_hedgehogs[i].Hat=strLst[i * 2 + 8]; // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat @@ -79,17 +84,19 @@ m_rounds = 0; m_wins = 0; m_campaignProgress = 0; + m_color = 0; } HWTeam::HWTeam() : QObject(0) - , m_difficulty(0) - , m_numHedgehogs(4) - , m_isNetTeam(false) + , m_difficulty(0) + , m_numHedgehogs(4) + , m_isNetTeam(false) { m_name = QString("Team"); for (int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { + m_hedgehogs.append(HWHog()); m_hedgehogs[i].Name.sprintf("hedgehog %d", i); m_hedgehogs[i].Hat = "NoHat"; } @@ -101,32 +108,34 @@ for(int i = 0; i < BINDS_NUMBER; i++) { + m_binds.append(BindAction()); m_binds[i].action = cbinds[i].action; m_binds[i].strbind = cbinds[i].strbind; } m_rounds = 0; m_wins = 0; m_campaignProgress = 0; + m_color = 0; } HWTeam::HWTeam(const HWTeam & other) : - QObject(0) - , OldTeamName(other.OldTeamName) - , m_name(other.m_name) - , m_grave(other.m_grave) - , m_fort(other.m_fort) - , m_flag(other.m_flag) - , m_voicepack(other.m_voicepack) - , m_hedgehogs(other.m_hedgehogs) - , m_difficulty(other.m_difficulty) - , m_binds(other.m_binds) - , m_numHedgehogs(other.m_numHedgehogs) - , m_color(other.m_color) - , m_isNetTeam(other.m_isNetTeam) - , m_owner(other.m_owner) - , m_campaignProgress(other.m_campaignProgress) - , m_rounds(other.m_rounds) - , m_wins(other.m_wins) + QObject(0) + , OldTeamName(other.OldTeamName) + , m_name(other.m_name) + , m_grave(other.m_grave) + , m_fort(other.m_fort) + , m_flag(other.m_flag) + , m_voicepack(other.m_voicepack) + , m_hedgehogs(other.m_hedgehogs) + , m_difficulty(other.m_difficulty) + , m_binds(other.m_binds) + , m_numHedgehogs(other.m_numHedgehogs) + , m_color(other.m_color) + , m_isNetTeam(other.m_isNetTeam) + , m_owner(other.m_owner) + , m_campaignProgress(other.m_campaignProgress) + , m_rounds(other.m_rounds) + , m_wins(other.m_wins) // , AchievementProgress(other.AchievementProgress) { @@ -142,9 +151,9 @@ m_fort = other.m_fort; m_flag = other.m_flag; m_voicepack = other.m_voicepack; -// m_hedgehogs = other.m_hedgehogs; + m_hedgehogs = other.m_hedgehogs; m_difficulty = other.m_difficulty; -// m_binds = other.m_binds; + m_binds = other.m_binds; m_numHedgehogs = other.m_numHedgehogs; m_color = other.m_color; m_isNetTeam = other.m_isNetTeam; @@ -152,6 +161,7 @@ m_campaignProgress = other.m_campaignProgress; m_rounds = other.m_rounds; m_wins = other.m_wins; + m_color = other.m_color; } return *this; @@ -249,10 +259,10 @@ QStringList sl; if (m_isNetTeam) { - sl.push_back(QString("eaddteam %3 %1 %2").arg(m_color.rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toLatin1(), QCryptographicHash::Md5).toHex()))); + sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(QString(QCryptographicHash::hash(m_owner.toUtf8(), QCryptographicHash::Md5).toHex()))); sl.push_back("erdriven"); } - else sl.push_back(QString("eaddteam %3 %1 %2").arg(m_color.rgb() & 0xffffff).arg(m_name).arg(playerHash)); + else sl.push_back(QString("eaddteam %3 %1 %2").arg(qcolor().rgb() & 0xffffff).arg(m_name).arg(playerHash)); sl.push_back(QString("egrave " + m_grave)); sl.push_back(QString("efort " + m_fort)); @@ -266,28 +276,30 @@ for (int t = 0; t < m_numHedgehogs; t++) { - sl.push_back(QString("eaddhh %1 %2 %3") - .arg(QString::number(m_difficulty), - QString::number(InitHealth), - m_hedgehogs[t].Name)); - sl.push_back(QString("ehat %1") - .arg(m_hedgehogs[t].Hat)); + sl.push_back(QString("eaddhh %1 %2 %3") + .arg(QString::number(m_difficulty), + QString::number(InitHealth), + m_hedgehogs[t].Name)); + sl.push_back(QString("ehat %1") + .arg(m_hedgehogs[t].Hat)); } return sl; } bool HWTeam::isNetTeam() const { - return m_isNetTeam; + return m_isNetTeam; } -bool HWTeam::operator==(const HWTeam& t1) const { - return m_name==t1.m_name; +bool HWTeam::operator==(const HWTeam& t1) const +{ + return m_name==t1.m_name; } -bool HWTeam::operator<(const HWTeam& t1) const { - return m_nameitem(m_color)->data().value(); +} + +void HWTeam::setColor(int color) +{ + m_color = color % DataManager::instance().colorsModel()->rowCount(); +} // binds -QString HWTeam::keyBind(unsigned int idx) const { return m_binds[idx].strbind; } - void HWTeam::bindKey(unsigned int idx, const QString & key) { m_binds[idx].strbind = key; } +QString HWTeam::keyBind(unsigned int idx) const +{ + return m_binds[idx].strbind; +} +void HWTeam::bindKey(unsigned int idx, const QString & key) +{ + m_binds[idx].strbind = key; +} // flag -void HWTeam::setFlag(const QString & flag) { m_flag = flag; } -QString HWTeam::flag() const { return m_flag; } +void HWTeam::setFlag(const QString & flag) +{ + m_flag = flag; +} +QString HWTeam::flag() const +{ + return m_flag; +} // fort -void HWTeam::setFort(const QString & fort) { m_fort = fort; } -QString HWTeam::fort() const { return m_fort; } +void HWTeam::setFort(const QString & fort) +{ + m_fort = fort; +} +QString HWTeam::fort() const +{ + return m_fort; +} // grave -void HWTeam::setGrave(const QString & grave) { m_grave = grave; } -QString HWTeam::grave() const { return m_grave; } +void HWTeam::setGrave(const QString & grave) +{ + m_grave = grave; +} +QString HWTeam::grave() const +{ + return m_grave; +} // voicepack - getter/setter -void HWTeam::setVoicepack(const QString & voicepack) { m_voicepack = voicepack; } -QString HWTeam::voicepack() const { return m_voicepack; } +void HWTeam::setVoicepack(const QString & voicepack) +{ + m_voicepack = voicepack; +} +QString HWTeam::voicepack() const +{ + return m_voicepack; +} // campaignProgress - getter -unsigned int HWTeam::campaignProgress() const { return m_campaignProgress; }; +unsigned int HWTeam::campaignProgress() const +{ + return m_campaignProgress; +}; // amount of hedgehogs -unsigned char HWTeam::numHedgehogs() const { return m_numHedgehogs; } - void HWTeam::setNumHedgehogs(unsigned char num) { m_numHedgehogs = num; } +unsigned char HWTeam::numHedgehogs() const +{ + return m_numHedgehogs; +} +void HWTeam::setNumHedgehogs(unsigned char num) +{ + m_numHedgehogs = num; +} // rounds+wins - incrementors -void HWTeam::incRounds() { m_rounds++; } -void HWTeam::incWins() { m_wins++; } - +void HWTeam::incRounds() +{ + m_rounds++; +} +void HWTeam::incWins() +{ + m_wins++; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/team.h --- a/QTfrontend/team.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/team.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * Copyright (c) 2007 Igor Ulyanov * * This program is free software; you can redistribute it and/or modify @@ -44,7 +44,7 @@ // class representing a team class HWTeam : public QObject { - Q_OBJECT + Q_OBJECT public: @@ -62,23 +62,23 @@ bool fileExists(); // attribute getters - unsigned int campaignProgress() const; - QColor color() const; - unsigned int difficulty() const; - QString flag() const; - QString fort() const; - QString grave() const; + unsigned int campaignProgress() const; + int color() const; + QColor qcolor() const; + unsigned int difficulty() const; + QString flag() const; + QString fort() const; + QString grave() const; const HWHog & hedgehog(unsigned int idx) const; - bool isNetTeam() const; - QString keyBind(unsigned int idx) const; - QString name() const; + bool isNetTeam() const; + QString keyBind(unsigned int idx) const; + QString name() const; unsigned char numHedgehogs() const; - QString owner() const; - QString voicepack() const; + QString owner() const; + QString voicepack() const; // attribute setters void bindKey(unsigned int idx, const QString & key); - void setColor(const QColor & color); void setDifficulty(unsigned int level); void setFlag(const QString & flag); void setFort(const QString & fort); @@ -100,6 +100,8 @@ bool operator < (const HWTeam& t1) const; HWTeam & operator = (const HWTeam & other); +public slots: + void setColor(int color); private: @@ -111,13 +113,13 @@ QString m_fort; QString m_flag; QString m_voicepack; - HWHog m_hedgehogs[HEDGEHOGS_PER_TEAM]; + QList m_hedgehogs; quint8 m_difficulty; - BindAction m_binds[BINDS_NUMBER]; + QList m_binds; // class members that contain info for the current game setup quint8 m_numHedgehogs; - QColor m_color; + int m_color; bool m_isNetTeam; QString m_owner; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/ask_quit.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/ask_quit.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,81 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include "hwform.h" +#include "ask_quit.h" +#include "pagevideos.h" + +HWAskQuitDialog::HWAskQuitDialog(QWidget* parent, HWForm * form) : QDialog(parent) +{ + this->form = form; + + setWindowTitle(tr("Do yot really want to quit?")); + + QVBoxLayout * layout = new QVBoxLayout(this); + + QLabel * lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("There are videos that are currently being processed.\n" + "Exiting now will abort them.\n" + "Do yot really want to quit?")); + layout->addWidget(lbLabel); + + lbList = new QLabel(this); + layout->addWidget(lbList); + updateList(); + + QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); + QPushButton * pbYes = dbbButtons->addButton(QDialogButtonBox::Yes); + QPushButton * pbNo = dbbButtons->addButton(QDialogButtonBox::No); + QPushButton * pbMore = dbbButtons->addButton(QPushButton::tr("More info"), QDialogButtonBox::HelpRole); + layout->addWidget(dbbButtons); + + connect(pbYes, SIGNAL(clicked()), this, SLOT(accept())); + connect(pbNo, SIGNAL(clicked()), this, SLOT(reject())); + connect(pbMore, SIGNAL(clicked()), this, SLOT(goToPageVideos())); + + // update list periodically + QTimer * timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(updateList())); + timer->start(200); + + this->setWindowModality(Qt::WindowModal); +} + +void HWAskQuitDialog::goToPageVideos() +{ + reject(); + form->GoToVideos(); +} + +void HWAskQuitDialog::updateList() +{ + QString text = form->ui.pageVideos->getVideosInProgress(); + if (text.isEmpty()) + { + // automatically exit when everything is finished + accept(); + return; + } + lbList->setText(text); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/ask_quit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/ask_quit.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,45 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef ASK_QUIT_H +#define ASK_QUIT_H + +#include + +class QLabel; +class HWForm; +class PageVideos; + +class HWAskQuitDialog : public QDialog +{ + Q_OBJECT + + public: + HWAskQuitDialog(QWidget* parent, HWForm *form); + + private slots: + void goToPageVideos(); + void updateList(); + + private: + HWForm * form; + QLabel * lbList; +}; + + +#endif // INPUT_PASSWORD_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/input_ip.cpp --- a/QTfrontend/ui/dialog/input_ip.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/dialog/input_ip.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,8 @@ connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); + + this->setWindowModality(Qt::WindowModal); } void HWHostPortDialog::setDefaultPort() diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/input_ip.h --- a/QTfrontend/ui/dialog/input_ip.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/dialog/input_ip.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,20 +29,20 @@ class HWHostPortDialog : public QDialog { - Q_OBJECT -public: - HWHostPortDialog(QWidget* parent = 0); + Q_OBJECT + public: + HWHostPortDialog(QWidget* parent = 0); - QLineEdit* leHost; - QSpinBox* sbPort; + QLineEdit* leHost; + QSpinBox* sbPort; -private: - QPushButton* pbOK; - QPushButton* pbCancel; - QPushButton * pbDefault; + private: + QPushButton* pbOK; + QPushButton* pbCancel; + QPushButton * pbDefault; -private slots: - void setDefaultPort(); + private slots: + void setDefaultPort(); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/input_password.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/input_password.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,55 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include + +#include "input_password.h" + +HWPasswordDialog::HWPasswordDialog(QWidget* parent, const QString & label) : QDialog(parent) +{ + setWindowTitle(tr("Password")); + + QGridLayout * layout = new QGridLayout(this); + + QLabel * lbLabel = new QLabel(this); + lbLabel->setText(label); + layout->addWidget(lbLabel, 0, 0); + + lePassword = new QLineEdit(this); + lePassword->setEchoMode(QLineEdit::Password); + layout->addWidget(lePassword, 1, 0); + + cbSave = new QCheckBox(this); + cbSave->setText(QCheckBox::tr("Save password")); + layout->addWidget(cbSave, 2, 0); + + QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); + QPushButton * pbOK = dbbButtons->addButton(QDialogButtonBox::Ok); + QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel); + layout->addWidget(dbbButtons, 3, 0); + + connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); + + this->setWindowModality(Qt::WindowModal); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/input_password.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/input_password.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,38 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef INPUT_PASSWORD_H +#define INPUT_PASSWORD_H + +#include + +class QLineEdit; +class QCheckBox; + +class HWPasswordDialog : public QDialog +{ + Q_OBJECT + public: + HWPasswordDialog(QWidget* parent, const QString & label); + + QLineEdit* lePassword; + QCheckBox* cbSave; +}; + + +#endif // INPUT_PASSWORD_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/upload_video.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/upload_video.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,312 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "upload_video.h" +#include "hwconsts.h" + +// User-agent string used in http requests. +// Don't make it a global varibale - crash on linux because of cVersionString +#define USER_AGENT ("Hedgewars-QtFrontend/" + *cVersionString).toAscii() + +// This is developer key obtained from http://code.google.com/apis/youtube/dashboard/ +// If you are reusing this code outside Hedgewars, don't use this developer key, +// obtain you own at http://code.google.com/apis/youtube/dashboard/ +static const QByteArray devKey = "AI39si5pKjxR0XgNIlmrEFF-LyYD31rps4g2O5dZTxLgD0fvJ2rHxrMrNFY8FYTZrzeI3VlaFVQLKfFnSBugvdZmy8vFzRDefQ"; + +HWUploadVideoDialog::HWUploadVideoDialog(QWidget* parent, const QString &filename, QNetworkAccessManager* netManager) : QDialog(parent) +{ + this->filename = filename; + this->netManager = netManager; + + setWindowTitle(tr("Upload video")); + + // Google requires us to display this, see https://developers.google.com/youtube/terms + QString GoogleNotice = + "

By clicking 'upload,' you certify that you own all rights to the content or that " + "you are authorized by the owner to make the content publicly available on YouTube, " + "and that it otherwise complies with the YouTube Terms of Service located at " + "http://www.youtube.com/t/terms.

"; + + // youtube doesn't understand this characters, even when they are properly escaped + // (either with CDATA or with < or >) + QRegExp rx("[^<>]*"); + + int row = 0; + + QGridLayout * layout = new QGridLayout(this); + layout->setColumnStretch(0, 1); + layout->setColumnStretch(1, 2); + + QLabel * lbLabel = new QLabel(this); + lbLabel->setWordWrap(true); + lbLabel->setText(QLabel::tr( + "Please provide either the YouTube account name " + "or the email address associated with the Google Account.")); + layout->addWidget(lbLabel, row++, 0, 1, 2); + + lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("Account name (or email): ")); + layout->addWidget(lbLabel, row, 0); + + leAccount = new QLineEdit(this); + layout->addWidget(leAccount, row++, 1); + + lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("Password: ")); + layout->addWidget(lbLabel, row, 0); + + lePassword = new QLineEdit(this); + lePassword->setEchoMode(QLineEdit::Password); + layout->addWidget(lePassword, row++, 1); + + cbSave = new QCheckBox(this); + cbSave->setText(QCheckBox::tr("Save account name and password")); + layout->addWidget(cbSave, row++, 0, 1, 2); + + QFrame * hr = new QFrame(this); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + layout->addWidget(hr, row++, 0, 1, 2); + + lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("Video title: ")); + layout->addWidget(lbLabel, row, 0); + + leTitle = new QLineEdit(this); + leTitle->setText(filename); + leTitle->setValidator(new QRegExpValidator(rx, leTitle)); + layout->addWidget(leTitle, row++, 1); + + lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("Video description: ")); + layout->addWidget(lbLabel, row++, 0, 1, 2); + + teDescription = new QPlainTextEdit(this); + layout->addWidget(teDescription, row++, 0, 1, 2); + + lbLabel = new QLabel(this); + lbLabel->setText(QLabel::tr("Tags (comma separated): ")); + layout->addWidget(lbLabel, row, 0); + + leTags = new QLineEdit(this); + leTags->setText("hedgewars"); + leTags->setMaxLength(500); + leTags->setValidator(new QRegExpValidator(rx, leTags)); + layout->addWidget(leTags, row++, 1); + + cbPrivate = new QCheckBox(this); + cbPrivate->setText(QCheckBox::tr("Video is private")); + layout->addWidget(cbPrivate, row++, 0, 1, 2); + + hr = new QFrame(this); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + layout->addWidget(hr, row++, 0, 1, 2); + + lbLabel = new QLabel(this); + lbLabel->setWordWrap(true); + lbLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse); + lbLabel->setTextFormat(Qt::RichText); + lbLabel->setOpenExternalLinks(true); + lbLabel->setText(GoogleNotice); + layout->addWidget(lbLabel, row++, 0, 1, 2); + + QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); + btnUpload = dbbButtons->addButton(tr("Upload"), QDialogButtonBox::ActionRole); + QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel); + layout->addWidget(dbbButtons, row++, 0, 1, 2); + + /* hr = new QFrame(this); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + layout->addWidget(hr, row++, 0, 1, 2);*/ + + connect(btnUpload, SIGNAL(clicked()), this, SLOT(upload())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); + + this->setWindowModality(Qt::WindowModal); +} + +void HWUploadVideoDialog::showEvent(QShowEvent * event) +{ + QDialog::showEvent(event); + + // set width to the same value as height (otherwise dialog has too small width) + QSize s = size(); + QPoint p = pos(); + resize(s.height(), s.height()); + move(p.x() - (s.height() - s.width())/2, p.y()); +} + +void HWUploadVideoDialog::setEditable(bool editable) +{ + leTitle->setEnabled(editable); + leAccount->setEnabled(editable); + lePassword->setEnabled(editable); + btnUpload->setEnabled(editable); +} + +void HWUploadVideoDialog::upload() +{ + setEditable(false); + + // Documentation is at https://developers.google.com/youtube/2.0/developers_guide_protocol_clientlogin#ClientLogin_Authentication + QNetworkRequest request; + request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin")); + request.setRawHeader("User-Agent", USER_AGENT); + request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); + + QString account(QUrl::toPercentEncoding(leAccount->text())); + QString pass(QUrl::toPercentEncoding(lePassword->text())); + QByteArray data = QString("Email=%1&Passwd=%2&service=youtube&source=Hedgewars").arg(account).arg(pass).toAscii(); + + QNetworkReply *reply = netManager->post(request, data); + connect(reply, SIGNAL(finished()), this, SLOT(authFinished())); +} + +static QString XmlEscape(const QString& str) +{ + QString str2 = str; + // youtube doesn't understand this characters, even when they are properly escaped + // (either with CDATA or with < >) + str2.replace('<', ' ').replace('>', ' '); + return "", "]]]]>") + "]]>"; +} + +void HWUploadVideoDialog::authFinished() +{ + QNetworkReply *reply = (QNetworkReply*)sender(); + reply->deleteLater(); + + int HttpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + QByteArray answer = reply->readAll(); + QString authToken = ""; + QList lines = answer.split('\n'); + foreach (const QByteArray& line, lines) + { + QString str(line); + if (!str.startsWith("Auth=", Qt::CaseInsensitive)) + continue; + str.remove(0, 5); + authToken = str; + break; + } + if (authToken.isEmpty()) + { + QString errorStr = QMessageBox::tr("Error while authenticating at google.com:\n"); + if (HttpCode == 403) + errorStr += QMessageBox::tr("Login or password is incorrect"); + else + errorStr += reply->errorString(); + + QMessageBox deniedMsg(this); + deniedMsg.setIcon(QMessageBox::Warning); + deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error")); + deniedMsg.setText(errorStr); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + + setEditable(true); + return; + } + + QByteArray auth = ("GoogleLogin auth=" + authToken).toAscii(); + + // We have authenticated, now we can send metadata and start upload + // Documentation is here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads#Resumable_uploads + QByteArray body = + "" + "" + "" + // "" + "Games" + "" + "" + + XmlEscape(leTitle->text()).toUtf8() + + "" + "" + + XmlEscape(teDescription->toPlainText()).toUtf8() + + "" + "" + + XmlEscape(leTags->text()).toUtf8() + + "" + + (cbPrivate->isChecked()? "" : "") + + "" + ""; + + QNetworkRequest request; + request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads")); + request.setRawHeader("User-Agent", USER_AGENT); + request.setRawHeader("Authorization", auth); + request.setRawHeader("GData-Version", "2"); + request.setRawHeader("X-GData-Key", "key=" + devKey); + request.setRawHeader("Slug", filename.toUtf8()); + request.setRawHeader("Content-Type", "application/atom+xml; charset=UTF-8"); + + reply = netManager->post(request, body); + connect(reply, SIGNAL(finished()), this, SLOT(startUpload())); +} + +void HWUploadVideoDialog::startUpload() +{ + QNetworkReply *reply = (QNetworkReply*)sender(); + reply->deleteLater(); + + location = QString::fromAscii(reply->rawHeader("Location")); + if (location.isEmpty()) + { + QString errorStr = QMessageBox::tr("Error while sending metadata to youtube.com:\n"); + errorStr += reply->errorString(); + + QMessageBox deniedMsg(this); + deniedMsg.setIcon(QMessageBox::Warning); + deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error")); + deniedMsg.setText(errorStr); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + + setEditable(true); + return; + } + + accept(); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/dialog/upload_video.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/upload_video.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,65 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef UPLOAD_VIDEO_H +#define UPLOAD_VIDEO_H + +#include + +class QLineEdit; +class QCheckBox; +class QPlainTextEdit; +class QLabel; +class QNetworkAccessManager; + +class HWUploadVideoDialog : public QDialog +{ + Q_OBJECT + public: + HWUploadVideoDialog(QWidget* parent, const QString& filename, QNetworkAccessManager* netManager); + + QLineEdit* leAccount; + QLineEdit* lePassword; + QCheckBox* cbSave; + + QLineEdit* leTitle; + QPlainTextEdit* teDescription; + QLineEdit* leTags; + QCheckBox* cbPrivate; + + QPushButton* btnUpload; + + QString location; + + private: + QNetworkAccessManager* netManager; + QString filename; + + void setEditable(bool editable); + + protected: + // virtual from QWidget + void showEvent(QShowEvent * event); + + private slots: + void upload(); + void authFinished(); + void startUpload(); +}; + +#endif // UPLOAD_VIDEO_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/mouseoverfilter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/mouseoverfilter.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,68 @@ + +#include +#include +#include +#include +#include +#include + +#include "mouseoverfilter.h" +#include "ui/page/AbstractPage.h" +#include "ui_hwform.h" +#include "hwform.h" +#include "gameuiconfig.h" +#include "DataManager.h" +#include "SDLInteraction.h" + +MouseOverFilter::MouseOverFilter(QObject *parent) : + QObject(parent) +{ +} + +bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event ) +{ + if (event->type() == QEvent::Enter) + { + QWidget * widget = dynamic_cast(dist); + + abstractpage = qobject_cast(ui->Pages->currentWidget()); + + if (widget->whatsThis() != NULL) + abstractpage->setButtonDescription(widget->whatsThis()); + else if (widget->toolTip() != NULL) + abstractpage->setButtonDescription(widget->toolTip()); + + // play a sound when mouse hovers certain ui elements + QPushButton * button = dynamic_cast(dist); + QLineEdit * textfield = dynamic_cast(dist); + QCheckBox * checkbox = dynamic_cast(dist); + QComboBox * droplist = dynamic_cast(dist); + QSlider * slider = dynamic_cast(dist); + QTabWidget * tab = dynamic_cast(dist); + if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) + { + DataManager & dataMgr = DataManager::instance(); + SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/steps.ogg")); + } + + return true; + } + else if (event->type() == QEvent::Leave) + { + abstractpage = qobject_cast(ui->Pages->currentWidget()); + + if (abstractpage->getDefautDescription() != NULL) + { + abstractpage->setButtonDescription( * abstractpage->getDefautDescription()); + } + else + abstractpage->setButtonDescription(""); + } + + return false; +} + +void MouseOverFilter::setUi(Ui_HWForm *uiForm) +{ + ui = uiForm; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/mouseoverfilter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/mouseoverfilter.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,27 @@ +#ifndef MOUSEOVERFILTER_H +#define MOUSEOVERFILTER_H + +#include + +#include "ui_hwform.h" +#include "ui/page/AbstractPage.h" + +class MouseOverFilter : public QObject +{ + Q_OBJECT + public: + explicit MouseOverFilter(QObject *parent = 0); + void setUi(Ui_HWForm *uiForm); + protected: + bool eventFilter( QObject *dist, QEvent *event ); + signals: + + public slots: + + private: + Ui_HWForm *ui; + AbstractPage* abstractpage; + +}; + +#endif // MOUSEOVERFILTER_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/AbstractPage.cpp --- a/QTfrontend/ui/page/AbstractPage.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/AbstractPage.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,16 @@ */ #include "AbstractPage.h" +#include +#include +#include + +#include "qpushbuttonwithsound.h" AbstractPage::AbstractPage(QWidget* parent) { Q_UNUSED(parent); + defautDesc = new QString(); font14 = new QFont("MS Shell Dlg", 14); } @@ -42,24 +48,54 @@ // add back/exit button btnBack = formattedButton(":/res/Exit.png", true); + btnBack->setWhatsThis(tr("Go back")); pageLayout->addWidget(btnBack, 1, 0, 1, 1, Qt::AlignLeft | Qt::AlignBottom); // add body layout as defined by the subclass - pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 2); + pageLayout->addLayout(bodyLayoutDefinition(), 0, 0, 1, 3); + + descLabel = new QLabel(); + descLabel->setAlignment(Qt::AlignCenter); + descLabel->setWordWrap(true); + descLabel->setOpenExternalLinks(true); + descLabel->setFixedHeight(50); + descLabel->setStyleSheet("font-size: 16px"); + pageLayout->addWidget(descLabel, 1, 1); // add footer layout QLayout * fld = footerLayoutDefinition(); if (fld != NULL) - pageLayout->addLayout(fld, 1, 1); + pageLayout->addLayout(fld, 1, 2); // connect signals connect(btnBack, SIGNAL(clicked()), this, SIGNAL(goBack())); connectSignals(); } -QPushButton * AbstractPage::formattedButton(const QString & name, bool hasIcon) +QPushButtonWithSound * AbstractPage::formattedButton(const QString & name, bool hasIcon) { - QPushButton * btn = new QPushButton(this); + QPushButtonWithSound * btn = new QPushButtonWithSound(this); + + if (hasIcon) + { + const QIcon& lp=QIcon(name); + QSize sz = lp.actualSize(QSize(65535, 65535)); + btn->setIcon(lp); + btn->setFixedSize(sz); + btn->setIconSize(sz); + btn->setFlat(true); + btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + } + else + { + btn->setFont(*font14); + btn->setText(name); + } + return btn; +} +QPushButton* AbstractPage::formattedSoundlessButton(const QString & name, bool hasIcon) +{ + QPushButton* btn = new QPushButton(this); if (hasIcon) { @@ -79,16 +115,23 @@ return btn; } -QPushButton * AbstractPage::addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan, int columnSpan, bool hasIcon) +QPushButtonWithSound * AbstractPage::addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan, int columnSpan, bool hasIcon) { - QPushButton * btn = formattedButton(name, hasIcon); + QPushButtonWithSound * btn = formattedButton(name, hasIcon); grid->addWidget(btn, row, column, rowSpan, columnSpan); return btn; } -QPushButton * AbstractPage::addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon) +QPushButtonWithSound * AbstractPage::addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon) { - QPushButton * btn = formattedButton(name, hasIcon); + QPushButtonWithSound * btn = formattedButton(name, hasIcon); + box->addWidget(btn, where); + return btn; +} + +QPushButton* AbstractPage::addSoundlessButton(const QString & name, QBoxLayout * box, int where, bool hasIcon) +{ + QPushButton* btn = formattedSoundlessButton(name, hasIcon); box->addWidget(btn, where); return btn; } @@ -97,3 +140,19 @@ { btnBack->setVisible(visible); } + +void AbstractPage::setButtonDescription(QString desc) +{ + descLabel->setText(desc); +} + +void AbstractPage::setDefautDescription(QString text) +{ + *defautDesc = text; + descLabel->setText(text); +} + +QString * AbstractPage::getDefautDescription() +{ + return defautDesc; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/AbstractPage.h --- a/QTfrontend/ui/page/AbstractPage.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/AbstractPage.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,13 +25,13 @@ #define ABSTRACTPAGE_H #include -#include +#include #include #include #include #include -class QPushButton; +class QPushButtonWithSound; class QGroupBox; class QComboBox; class QLabel; @@ -54,7 +54,28 @@ class AbstractPage : public QWidget { - Q_OBJECT + Q_OBJECT + + public: + + /** + * @brief Changes the desc text (should not be called manualy) + * + * @param desc the description of the widget focused + */ + void setButtonDescription(QString desc); + + /** + * @brief Changes the desc defaut text + * + * @param text the defaut desc + */ + void setDefautDescription(QString text); + + /** + * @brief Get the desc defaut text + */ + QString * getDefautDescription(); signals: /** @@ -91,7 +112,10 @@ * * Use it to define layout (not behavior) of the page's footer. */ - virtual QLayout * footerLayoutDefinition() { return NULL; }; + virtual QLayout * footerLayoutDefinition() + { + return NULL; + }; /** * @brief Used during page construction. @@ -113,7 +137,8 @@ * * @return the button. */ - QPushButton * formattedButton(const QString & name, bool hasIcon = false); + QPushButtonWithSound * formattedButton(const QString & name, bool hasIcon = false); + QPushButton * formattedSoundlessButton(const QString & name, bool hasIcon = false); /** * @brief Creates a default formatted button and adds it to a @@ -129,7 +154,7 @@ * * @return the button. */ - QPushButton * addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan = 1, int columnSpan = 1, bool hasIcon = false); + QPushButtonWithSound * addButton(const QString & name, QGridLayout * grid, int row, int column, int rowSpan = 1, int columnSpan = 1, bool hasIcon = false); /** * @brief Creates a default formatted button and adds it to a @@ -142,7 +167,8 @@ * * @return the button. */ - QPushButton * addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false); + QPushButtonWithSound * addButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false); + QPushButton* addSoundlessButton(const QString & name, QBoxLayout * box, int where, bool hasIcon = false); /** * @brief Changes visibility of the back-button. @@ -153,9 +179,10 @@ QFont * font14; ///< used font - private: + QLabel * descLabel; ///< text description + QString * defautDesc; - QPushButton * btnBack; ///< back button + QPushButtonWithSound * btnBack; ///< back button }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageadmin.cpp --- a/QTfrontend/ui/page/pageadmin.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageadmin.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ // 0 pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3); - + // 1 QLabel * lblSMN = new QLabel(this); lblSMN->setText(tr("Server message for latest version:")); @@ -66,10 +66,10 @@ tb->setOpenExternalLinks(true); tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet()); pageLayout->addWidget(tb, 4, 1, 1, 2); - + // 5 pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0); - + // 6 pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3); @@ -79,8 +79,8 @@ void PageAdmin::connectSignals() { connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars())); - connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); - connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); + connect(leServerMessageNew, SIGNAL(textChanged(QString)), tb, SLOT(setHtml(const QString &))); + connect(leServerMessageOld, SIGNAL(textChanged(QString)), tb, SLOT(setHtml(const QString &))); connect(pbClearAccountsCache, SIGNAL(clicked()), this, SIGNAL(clearAccountsCache())); connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged())); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageadmin.h --- a/QTfrontend/ui/page/pageadmin.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageadmin.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,38 +23,38 @@ class PageAdmin : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageAdmin(QWidget* parent = 0); + public: + PageAdmin(QWidget* parent = 0); -public slots: - void serverMessageNew(const QString & str); - void serverMessageOld(const QString & str); - void protocol(int proto); + public slots: + void serverMessageNew(const QString & str); + void serverMessageOld(const QString & str); + void protocol(int proto); -signals: - void setServerMessageNew(const QString & str); - void setServerMessageOld(const QString & str); - void setProtocol(int proto); - void askServerVars(); - void clearAccountsCache(); + signals: + void setServerMessageNew(const QString & str); + void setServerMessageOld(const QString & str); + void setProtocol(int proto); + void askServerVars(); + void clearAccountsCache(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -private: - QLineEdit * leServerMessageNew; - QLineEdit * leServerMessageOld; - QPushButton * pbSetSM; - QPushButton * pbAsk; - QSpinBox * sbProtocol; - QTextBrowser * tb; - QPushButton * pbClearAccountsCache; + private: + QLineEdit * leServerMessageNew; + QLineEdit * leServerMessageOld; + QPushButton * pbSetSM; + QPushButton * pbAsk; + QSpinBox * sbProtocol; + QTextBrowser * tb; + QPushButton * pbClearAccountsCache; -private slots: - void smChanged(); + private slots: + void smChanged(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagecampaign.cpp --- a/QTfrontend/ui/page/pagecampaign.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagecampaign.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,12 +31,14 @@ pageLayout->setRowStretch(0, 1); pageLayout->setRowStretch(3, 1); - CBSelect = new QComboBox(this); CBTeam = new QComboBox(this); + CBMission = new QComboBox(this); + CBCampaign = new QComboBox(this); pageLayout->addWidget(CBTeam, 1, 1); - pageLayout->addWidget(CBSelect, 2, 1); - + pageLayout->addWidget(CBCampaign, 2, 1); + pageLayout->addWidget(CBMission, 3, 1); + BtnStartCampaign = new QPushButton(this); BtnStartCampaign->setFont(*font14); BtnStartCampaign->setText(QPushButton::tr("Go!")); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagecampaign.h --- a/QTfrontend/ui/page/pagecampaign.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagecampaign.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,17 +23,18 @@ class PageCampaign : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageCampaign(QWidget* parent = 0); + public: + PageCampaign(QWidget* parent = 0); - QPushButton *BtnStartCampaign; - QComboBox *CBSelect; - QComboBox *CBTeam; + QPushButton *BtnStartCampaign; + QComboBox *CBMission; + QComboBox *CBCampaign; + QComboBox *CBTeam; -protected: - QLayout * bodyLayoutDefinition(); + protected: + QLayout * bodyLayoutDefinition(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageconnecting.cpp --- a/QTfrontend/ui/page/pageconnecting.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageconnecting.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageconnecting.h --- a/QTfrontend/ui/page/pageconnecting.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageconnecting.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,17 +23,17 @@ class PageConnecting : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageConnecting(QWidget* parent = 0); + public: + PageConnecting(QWidget* parent = 0); -signals: - void cancelConnection(); + signals: + void cancelConnection(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagedata.cpp --- a/QTfrontend/ui/page/pagedata.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagedata.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include "pagedata.h" #include "databrowser.h" #include "hwconsts.h" +#include "DataManager.h" #include "quazip.h" #include "quazipfile.h" @@ -52,6 +53,7 @@ void PageDataDownload::connectSignals() { connect(web, SIGNAL(anchorClicked(QUrl)), this, SLOT(request(const QUrl&))); + connect(this, SIGNAL(goBack()), this, SLOT(onPageLeave())); } PageDataDownload::PageDataDownload(QWidget* parent) : AbstractPage(parent) @@ -59,7 +61,9 @@ initPage(); web->setOpenLinks(false); - fetchList(); +// fetchList(); + + m_contentDownloaded = false; } void PageDataDownload::request(const QUrl &url) @@ -86,7 +90,8 @@ QProgressBar *progressBar = new QProgressBar(this); progressBarsLayout->addWidget(progressBar); progressBars.insert(reply, progressBar); - } else + } + else { qWarning() << "Page Request" << url.toString(); @@ -166,8 +171,8 @@ zip.setIoDevice(&buffer); if(!zip.open(QuaZip::mdUnzip)) { - qWarning("testRead(): zip.open(): %d", zip.getZipError()); - return false; + qWarning("testRead(): zip.open(): %d", zip.getZipError()); + return false; } QuaZipFile file(&zip); @@ -190,7 +195,8 @@ { QFileInfo fi(filePath); QDir().mkpath(fi.filePath()); - } else + } + else { qDebug() << "Extracting" << filePath; QFile out(filePath); @@ -204,20 +210,25 @@ out.close(); - if(file.getZipError() != UNZ_OK) { + if(file.getZipError() != UNZ_OK) + { qWarning("file.getFileName(): %d", file.getZipError()); return false; } - if(!file.atEnd()) { + if(!file.atEnd()) + { qWarning("read all but not EOF"); return false; } + + m_contentDownloaded = true; } file.close(); - if(file.getZipError()!=UNZ_OK) { + if(file.getZipError()!=UNZ_OK) + { qWarning("file.close(): %d", file.getZipError()); return false; } @@ -227,3 +238,13 @@ return true; } + + +void PageDataDownload::onPageLeave() +{ + if (m_contentDownloaded) + { + m_contentDownloaded = false; + //DataManager::instance().reload(); + } +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagedata.h --- a/QTfrontend/ui/page/pagedata.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagedata.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,31 +29,35 @@ class PageDataDownload : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageDataDownload(QWidget* parent = 0); + public: + PageDataDownload(QWidget* parent = 0); -public slots: - void fetchList(); + public slots: + void fetchList(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -private: - DataBrowser *web; - QHash progressBars; - QVBoxLayout *progressBarsLayout; + private: + DataBrowser *web; + QHash progressBars; + QVBoxLayout *progressBarsLayout; - bool extractDataPack(QByteArray * buf); + bool m_contentDownloaded; ///< true if something was downloaded since last page leave + + bool extractDataPack(QByteArray * buf); -private slots: - void request(const QUrl &url); + private slots: + void request(const QUrl &url); - void pageDownloaded(); - void fileDownloaded(); - void downloadProgress(qint64, qint64); + void pageDownloaded(); + void fileDownloaded(); + void downloadProgress(qint64, qint64); + + void onPageLeave(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagedrawmap.cpp --- a/QTfrontend/ui/page/pagedrawmap.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagedrawmap.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include #include #include +#include #include "pagedrawmap.h" #include "drawmapwidget.h" @@ -28,19 +29,22 @@ { QGridLayout * pageLayout = new QGridLayout(); - pbUndo = addButton(tr("Undo"), pageLayout, 0, 0); - pbClear = addButton(tr("Clear"), pageLayout, 1, 0); - pbLoad = addButton(tr("Load"), pageLayout, 2, 0); - pbSave = addButton(tr("Save"), pageLayout, 3, 0); + cbEraser = new QCheckBox(tr("Eraser"), this); + pageLayout->addWidget(cbEraser, 0, 0); + pbUndo = addButton(tr("Undo"), pageLayout, 1, 0); + pbClear = addButton(tr("Clear"), pageLayout, 2, 0); + pbLoad = addButton(tr("Load"), pageLayout, 3, 0); + pbSave = addButton(tr("Save"), pageLayout, 4, 0); drawMapWidget = new DrawMapWidget(this); - pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1); + pageLayout->addWidget(drawMapWidget, 0, 1, 6, 1); return pageLayout; } void PageDrawMap::connectSignals() { + connect(cbEraser, SIGNAL(toggled(bool)), drawMapWidget, SLOT(setErasing(bool))); connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo())); connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear())); connect(pbLoad, SIGNAL(clicked()), this, SLOT(load())); @@ -62,7 +66,7 @@ void PageDrawMap::save() { - QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); + QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save drawn map"), "./map.hwmap", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); if(!fileName.isEmpty()) drawMapWidget->save(fileName); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagedrawmap.h --- a/QTfrontend/ui/page/pagedrawmap.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagedrawmap.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,26 +25,27 @@ class PageDrawMap : public AbstractPage { - Q_OBJECT + Q_OBJECT + + public: + PageDrawMap(QWidget* parent = 0); -public: - PageDrawMap(QWidget* parent = 0); + DrawMapWidget * drawMapWidget; - DrawMapWidget * drawMapWidget; + protected: + QLayout * bodyLayoutDefinition(); + void connectSignals(); -protected: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + private: + QPushButton * pbUndo; + QPushButton * pbClear; + QPushButton * pbLoad; + QPushButton * pbSave; + QCheckBox * cbEraser; -private: - QPushButton * pbUndo; - QPushButton * pbClear; - QPushButton * pbLoad; - QPushButton * pbSave; - -private slots: - void load(); - void save(); + private slots: + void load(); + void save(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageeditteam.cpp --- a/QTfrontend/ui/page/pageeditteam.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageeditteam.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,13 +26,13 @@ #include #include #include - -#include "sdlkeys.h" +#include +#include #include "SquareLabel.h" -#include "hats.h" #include "HWApplication.h" -#include "HWDataManager.h" +#include "DataManager.h" +#include "HatModel.h" #include "pageeditteam.h" @@ -61,11 +61,12 @@ GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); - HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); + HatModel * hatModel = DataManager::instance().hatModel(); + for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { HHHats[i] = new QComboBox(GBoxHedgehogs); - HHHats[i]->setModel(hatsModel); + HHHats[i]->setModel(hatModel); HHHats[i]->setIconSize(QSize(32, 37)); //HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); //HHHats[i]->setModelColumn(1); @@ -114,9 +115,9 @@ CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); for(int i = 5; i > 0; i--) CBTeamLvl->addItem( - QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), - QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) - ); + QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), + QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) + ); GBTLayout->addWidget(CBTeamLvl, 1, 1); CBGrave = new QComboBox(GBoxTeam); @@ -133,7 +134,7 @@ CBVoicepack = new QComboBox(GBoxTeam); hbox->addWidget(CBVoicepack, 100); - btnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); + btnTestSound = addSoundlessButton(":/res/PlaySound.png", hbox, 1, true); hbox->setStretchFactor(btnTestSound, 1); GBTLayout->addLayout(hbox, 4, 1); @@ -170,7 +171,8 @@ QWidget * curW = NULL; QGridLayout * pagelayout = NULL; QLabel* l = NULL; - while (i < BINDS_NUMBER) { + while (i < BINDS_NUMBER) + { if(cbinds[i].category != NULL) { if(curW != NULL) @@ -195,9 +197,9 @@ l->setText(HWApplication::translate("binds", cbinds[i].name)); l->setAlignment(Qt::AlignRight); pagelayout->addWidget(l, num, 0); + CBBind[i] = new QComboBox(curW); - for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) - CBBind[i]->addItem(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); + CBBind[i]->setModel(DataManager::instance().bindsModel()); pagelayout->addWidget(CBBind[i++], num++, 1); } @@ -206,18 +208,12 @@ QLayout * PageEditTeam::footerLayoutDefinition() { - QHBoxLayout * bottomLayout = new QHBoxLayout(); - - btnSave = addButton(":/res/Save.png", bottomLayout, 0, true);; - btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); - bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom); - - return bottomLayout; + return NULL; } void PageEditTeam::connectSignals() { - connect(btnSave, SIGNAL(clicked()), this, SLOT(saveTeam())); + connect(this, SIGNAL(goBack()), this, SLOT(saveTeam())); signalMapper1 = new QSignalMapper(this); signalMapper2 = new QSignalMapper(this); @@ -228,21 +224,21 @@ for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map())); - signalMapper1->setMapping(HHNameEdit[i], i); + signalMapper1->setMapping(HHNameEdit[i], i); connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map())); - signalMapper2->setMapping(btnRandomHogName[i], i); + signalMapper2->setMapping(btnRandomHogName[i], i); } connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomNames())); - + connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); } PageEditTeam::PageEditTeam(QWidget* parent) : - AbstractPage(parent) + AbstractPage(parent) { initPage(); @@ -250,13 +246,13 @@ m_playerHash = "0000000000000000000000000000000000000000"; - HWDataManager & dataMgr = HWDataManager::instance(); + DataManager & dataMgr = DataManager::instance(); QStringList list; // voicepacks - list = dataMgr.entryList("Sounds/voices", + list = dataMgr.entryList("Sounds/voices", QDir::AllDirs | QDir::NoDotAndDotDot); CBVoicepack->addItems(list); @@ -293,6 +289,9 @@ int idx = list.indexOf("cpu.png"); if (idx >= 0) list.removeAt(idx); + idx = list.indexOf("cpu_plain.png"); + if (idx >= 0) + list.removeAt(idx); idx = list.indexOf("hedgewars.png"); if (idx >= 0) list.removeAt(idx); @@ -338,32 +337,32 @@ void PageEditTeam::CBFort_activated(const QString & fortname) { - HWDataManager & dataMgr = HWDataManager::instance(); + DataManager & dataMgr = DataManager::instance(); QPixmap pix(dataMgr.findFileForRead("Forts/" + fortname + "L.png")); FortPreview->setPixmap(pix); } void PageEditTeam::testSound() { - HWDataManager & dataMgr = HWDataManager::instance(); + DataManager & dataMgr = DataManager::instance(); QString voiceDir = QString("Sounds/voices/") + CBVoicepack->currentText(); QStringList list = dataMgr.entryList( - voiceDir, - QDir::Files, - QStringList() << - "Illgetyou.ogg" << - "Incoming.ogg" << - "Stupid.ogg" << - "Coward.ogg" << - "Firstblood.ogg" - ); + voiceDir, + QDir::Files, + QStringList() << + "Illgetyou.ogg" << + "Incoming.ogg" << + "Stupid.ogg" << + "Coward.ogg" << + "Firstblood.ogg" + ); if (!list.isEmpty()) SDLInteraction::instance().playSoundFile( dataMgr.findFileForRead(voiceDir + "/" + - list[rand() % list.size()]) + list[rand() % list.size()]) ); } @@ -384,9 +383,14 @@ void PageEditTeam::deleteTeam(const QString & name) { - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Teams"), QMessageBox::tr("Really delete this team?"), QMessageBox::Ok | QMessageBox::Cancel, this); + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Teams - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the team '%1'?").arg(name)); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) + if (reallyDeleteMsg.exec() == QMessageBox::Ok) HWTeam(name).deleteFile(); } @@ -427,9 +431,15 @@ CBFort->setCurrentIndex(CBFort->findText(team.fort())); CBVoicepack->setCurrentIndex(CBVoicepack->findText(team.voicepack())); + QStandardItemModel * binds = DataManager::instance().bindsModel(); for(int i = 0; i < BINDS_NUMBER; i++) { - CBBind[i]->setCurrentIndex(CBBind[i]->findData(team.keyBind(i))); + QModelIndexList mdl = binds->match(binds->index(0, 0), Qt::UserRole + 1, team.keyBind(i), 1, Qt::MatchExactly); + + if(mdl.size() == 1) + CBBind[i]->setCurrentIndex(mdl[0].row()); + else + qDebug() << "Binds: cannot find" << team.keyBind(i); } } @@ -455,9 +465,10 @@ team.setVoicepack(CBVoicepack->currentText()); team.setFlag(CBFlag->itemData(CBFlag->currentIndex()).toString()); + QStandardItemModel * binds = DataManager::instance().bindsModel(); for(int i = 0; i < BINDS_NUMBER; i++) { - team.bindKey(i,CBBind[i]->itemData(CBBind[i]->currentIndex()).toString()); + team.bindKey(i, binds->index(CBBind[i]->currentIndex(), 0).data(Qt::UserRole + 1).toString()); } return team; @@ -466,5 +477,4 @@ void PageEditTeam::saveTeam() { data().saveToFile(); - emit teamEdited(); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageeditteam.h --- a/QTfrontend/ui/page/pageeditteam.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageeditteam.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,66 +31,60 @@ class PageEditTeam : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageEditTeam(QWidget* parent); + public: + PageEditTeam(QWidget* parent); - void createTeam(const QString & name, const QString & playerHash); - void editTeam(const QString & name, const QString & playerHash); - void deleteTeam(const QString & name); + void createTeam(const QString & name, const QString & playerHash); + void editTeam(const QString & name, const QString & playerHash); + void deleteTeam(const QString & name); -signals: - void teamEdited(); - -public slots: - void CBFort_activated(const QString & gravename); + public slots: + void CBFort_activated(const QString & gravename); -private: - QSignalMapper* signalMapper1; - QSignalMapper* signalMapper2; - QGroupBox *GBoxHedgehogs; - QGroupBox *GBoxTeam; - QGroupBox *GBoxFort; - QComboBox *CBFort; - SquareLabel *FortPreview; - QComboBox *CBGrave; - QComboBox *CBFlag; - QComboBox *CBTeamLvl; - QComboBox *CBVoicepack; - QGroupBox *GBoxBinds; - QToolBox *BindsBox; - QLineEdit * TeamNameEdit; - QLineEdit * HHNameEdit[HEDGEHOGS_PER_TEAM]; - QComboBox * HHHats[HEDGEHOGS_PER_TEAM]; - QComboBox * CBBind[BINDS_NUMBER]; - HWTeam data(); - QString m_playerHash; + private: + QSignalMapper* signalMapper1; + QSignalMapper* signalMapper2; + QGroupBox *GBoxHedgehogs; + QGroupBox *GBoxTeam; + QGroupBox *GBoxFort; + QComboBox *CBFort; + SquareLabel *FortPreview; + QComboBox *CBGrave; + QComboBox *CBFlag; + QComboBox *CBTeamLvl; + QComboBox *CBVoicepack; + QGroupBox *GBoxBinds; + QToolBox *BindsBox; + QLineEdit * TeamNameEdit; + QLineEdit * HHNameEdit[HEDGEHOGS_PER_TEAM]; + QComboBox * HHHats[HEDGEHOGS_PER_TEAM]; + QComboBox * CBBind[BINDS_NUMBER]; + HWTeam data(); + QString m_playerHash; - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - void loadTeam(const HWTeam & team); + void loadTeam(const HWTeam & team); - // page 1 - QPushButton * btnRandomHogName[HEDGEHOGS_PER_TEAM]; - QPushButton * btnRandomTeam; - QPushButton * btnTestSound; + // page 1 + QPushButton * btnRandomHogName[HEDGEHOGS_PER_TEAM]; + QPushButton * btnRandomTeam; + QPushButton * btnTestSound; - // footer - QPushButton * btnSave; - -private slots: - void saveTeam(); - void setRandomNames(); + private slots: + void saveTeam(); + void setRandomNames(); - void setRandomName(int hh_index); - - /// Plays a random voice sound of the currently edited team. - void testSound(); + void setRandomName(int hh_index); - void fixHHname(int idx); + /// Plays a random voice sound of the currently edited team. + void testSound(); + + void fixHHname(int idx); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagefeedback.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/page/pagefeedback.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,82 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + +#include "pagefeedback.h" +#include "hwconsts.h" + +QLayout * PageFeedback::bodyLayoutDefinition() +{ + QVBoxLayout * pageLayout = new QVBoxLayout(); + QHBoxLayout * summaryLayout = new QHBoxLayout(); + + info = new QLabel(); + info->setText( + "" + "

Please give us a feedback!

" + "

We are always happy about suggestions, ideas or bug reports.

" + "

The feedback will be posted as a new issue on our Google Code page.

" + "

" + ); + pageLayout->addWidget(info); + + label_summary = new QLabel(); + label_summary->setText(QLabel::tr("Summary ")); + summaryLayout->addWidget(label_summary); + summary = new QLineEdit(); + summaryLayout->addWidget(summary); + pageLayout->addLayout(summaryLayout); + + label_description = new QLabel(); + label_description->setText(QLabel::tr("Description")); + pageLayout->addWidget(label_description, 0, Qt::AlignHCenter); + description = new QTextBrowser(); + description->setReadOnly(false); + pageLayout->addWidget(description); + + return pageLayout; +} + +QLayout * PageFeedback::footerLayoutDefinition() +{ + QHBoxLayout * bottomLayout = new QHBoxLayout(); + + bottomLayout->setStretch(0,1); + //TODO: create logo for send button + BtnSend = addButton("Send", bottomLayout, 0, false); + bottomLayout->insertStretch(0); + + return bottomLayout; +} + +void PageFeedback::connectSignals() +{ + //TODO +} + +PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent) +{ + initPage(); + +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagefeedback.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/page/pagefeedback.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,44 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef PAGE_FEEDBACK_H +#define PAGE_FEEDBACK_H + +#include "AbstractPage.h" + +class PageFeedback : public AbstractPage +{ + Q_OBJECT + + public: + PageFeedback(QWidget * parent = 0); + + QPushButton * BtnSend; + QLineEdit * summary; + QTextBrowser * description; + QLabel * info; + QLabel * label_summary; + QLabel * label_description; + + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); +}; + +#endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagegamestats.cpp --- a/QTfrontend/ui/page/pagegamestats.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagegamestats.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2010-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,7 +62,7 @@ gbl->addWidget(labelGameStats); gb->setLayout(gbl); pageLayout->addWidget(gb, 1, 1, 1, 2); - + // graph graphic = new FitGraphicsView(gb); l = new QLabel(this); @@ -73,7 +73,7 @@ gbl->addWidget(graphic); graphic->scale(1.0, -1.0); graphic->setBackgroundBrush(QBrush(Qt::black)); - + labelGameWin = new QLabel(this); labelGameWin->setTextFormat(Qt::RichText); pageLayout->addWidget(labelGameWin, 0, 0, 1, 2); @@ -140,7 +140,7 @@ while (i != healthPoints.constEnd()) { quint32 c = i.key(); - QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); + //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); QVector hps = i.value(); QPainterPath path; @@ -160,38 +160,45 @@ void PageGameStats::GameStats(char type, const QString & info) { - switch(type) { - case 'r' : { + switch(type) + { + case 'r' : + { labelGameWin->setText(QString("

%1

").arg(info)); break; } - case 'D' : { + case 'D' : + { int i = info.indexOf(' '); QString message = "

" + PageGameStats::tr("The best shot award was won by %1 with %2 pts.").arg(info.mid(i + 1), info.left(i)) + "

"; AddStatText(message); break; } - case 'k' : { + case 'k' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("The best killer is %1 with %2 kills in a turn.", "", num).arg(info.mid(i + 1), info.left(i)) + "

"; AddStatText(message); break; } - case 'K' : { + case 'K' : + { int num = info.toInt(); QString message = "

" + PageGameStats::tr("A total of %1 hedgehog(s) were killed during this round.", "", num).arg(num) + "

"; AddStatText(message); break; } - case 'H' : { + case 'H' : + { int i = info.indexOf(' '); quint32 clan = info.left(i).toInt(); quint32 hp = info.mid(i + 1).toUInt(); healthPoints[clan].append(hp); break; } - case 'T': { // local team stats + case 'T': // local team stats + { //AddStatText("

local team: " + info + "

"); QStringList infol = info.split(":"); HWTeam team(infol[0]); @@ -204,9 +211,10 @@ //team.SaveToFile(); // don't save yet } break; - } + } - case 'P' : { + case 'P' : + { int i = info.indexOf(' '); playerPosition++; QString color = info.left(i); @@ -227,17 +235,17 @@ switch (playerPosition) { case 1: - image = ""; - break; - case 2: - image = ""; - break; - case 3: - image = ""; - break; - default: - image = ""; - break; + image = ""; + break; + case 2: + image = ""; + break; + case 3: + image = ""; + break; + default: + image = ""; + break; } QString message; @@ -246,23 +254,26 @@ message = QString("

%1 %2. %3 ").arg(image, QString::number(playerPosition), playername, clanColor.name()) + killstring + "

"; labelGameRank->setText(labelGameRank->text() + message); - break; + break; } - case 's' : { + case 's' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 thought it's good to shoot his own hedgehogs with %2 pts.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; AddStatText(message); break; } - case 'S' : { + case 'S' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 killed %2 of his own hedgehogs.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; AddStatText(message); break; } - case 'B' : { + case 'B' : + { int i = info.indexOf(' '); int num = info.left(i).toInt(); QString message = "

" + PageGameStats::tr("%1 was scared and skipped turn %2 times.", "", num).arg(info.mid(i + 1)).arg(num) + "

"; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagegamestats.h --- a/QTfrontend/ui/page/pagegamestats.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagegamestats.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2010-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,47 +27,47 @@ class FitGraphicsView : public QGraphicsView { - Q_OBJECT + Q_OBJECT -public: - FitGraphicsView(QWidget* parent = 0); + public: + FitGraphicsView(QWidget* parent = 0); -protected: - void resizeEvent(QResizeEvent * event); + protected: + void resizeEvent(QResizeEvent * event); }; class PageGameStats : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageGameStats(QWidget* parent = 0); + public: + PageGameStats(QWidget* parent = 0); - QPushButton *btnSave; - QLabel *labelGameStats; - QLabel *labelGameWin; - QLabel *labelGameRank; - FitGraphicsView * graphic; + QPushButton *btnSave; + QLabel *labelGameStats; + QLabel *labelGameWin; + QLabel *labelGameRank; + FitGraphicsView * graphic; -public slots: - void GameStats(char type, const QString & info); - void clear(); - void renderStats(); - -signals: - void saveDemoRequested(); + public slots: + void GameStats(char type, const QString & info); + void clear(); + void renderStats(); + + signals: + void saveDemoRequested(); -private: - void AddStatText(const QString & msg); + private: + void AddStatText(const QString & msg); - QMap > healthPoints; - unsigned int playerPosition; - quint32 lastColor; + QMap > healthPoints; + unsigned int playerPosition; + quint32 lastColor; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif // STATSPAGE_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageinfo.cpp --- a/QTfrontend/ui/page/pageinfo.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageinfo.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,6 +41,7 @@ { QHBoxLayout * bottomLayout = new QHBoxLayout(); BtnSnapshots = addButton(":/res/Star.png", bottomLayout, 0, true); + BtnSnapshots->setWhatsThis(tr("Open the snapshot folder")); bottomLayout->setAlignment(BtnSnapshots, Qt::AlignRight | Qt::AlignVCenter); return bottomLayout; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageinfo.h --- a/QTfrontend/ui/page/pageinfo.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageinfo.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,18 +25,18 @@ class PageInfo : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageInfo(QWidget* parent = 0); + public: + PageInfo(QWidget* parent = 0); - QPushButton *BtnSnapshots; - About *about; + QPushButton *BtnSnapshots; + About *about; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageingame.cpp --- a/QTfrontend/ui/page/pageingame.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageingame.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageingame.h --- a/QTfrontend/ui/page/pageingame.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageingame.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ class PageInGame : public AbstractPage { - Q_OBJECT + Q_OBJECT public: PageInGame(QWidget * parent = 0); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagemain.cpp --- a/QTfrontend/ui/page/pagemain.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagemain.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ - + #include #include #include @@ -42,21 +42,36 @@ pageLayout->setRowStretch(4, 1); BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); - BtnSinglePlayer->setToolTip(tr("Local Game (Play a game on a single computer)")); + BtnSinglePlayer->setToolTip(tr("Local Game")); + BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer")); pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); - BtnNet->setToolTip(tr("Network Game (Play a game across a network)")); + BtnNet->setToolTip(tr("Network Game")); + BtnNet->setWhatsThis(tr("Play a game across a network")); pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); // button order matters for overlapping (what's on top and what isn't) BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); BtnInfo->setStyleSheet("border: transparent;background: transparent;"); + //BtnInfo->setToolTip(tr("Credits")); //tooltip looks horrible with transparent background buttons + BtnInfo->setWhatsThis(tr("Read about who is behind the Hedgewars Project")); pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); - BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 4, 0, 1, 4, false); +#if 0 + BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false); + BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars")); + pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter); +#endif + + BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false); + //BtnDataDownload->setToolTip(tr(Downloadable Content")); + BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website")); pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter); + // disable exit button sound + btnBack->isSoundEnabled = false; + return pageLayout; } @@ -67,12 +82,19 @@ mainNote = new QLabel(this); mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); mainNote->setWordWrap(true); - + bottomLayout->addWidget(mainNote, 0); bottomLayout->setStretch(0,1); - BtnSetup = addButton(":/res/Settings.png", bottomLayout, 1, true); - bottomLayout->setStretch(1,0); + btnBack->setWhatsThis(tr("Exit game")); + +#ifdef VIDEOREC + BtnVideos = addButton(":/res/Videos.png", bottomLayout, 1, true); + BtnVideos->setWhatsThis(tr("Manage videos recorded from game")); +#endif + + BtnSetup = addButton(":/res/Settings.png", bottomLayout, 2, true); + BtnSetup->setWhatsThis(tr("Edit game preferences")); return bottomLayout; } @@ -91,72 +113,74 @@ if(!isDevBuild) { - mainNote->setText(QLabel::tr("Tip: ") + randomTip()); + setDefautDescription(QLabel::tr("Tip: ") + randomTip()); } else - mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); + { + setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); + } } QString PageMain::randomTip() const { QStringList Tips; - Tips << tr("Simply pick the same color as a friend to play together as a team. Each of you will still control his or her own hedgehogs but they'll win or lose together.", "Tips"); - Tips << tr("Some weapons might do only low damage but they can be a lot more devastating in the right situation. Try to use the Desert Eagle to knock multiple hedgehogs into the water.", "Tips"); - Tips << tr("If you're unsure what to do and don't want to waste ammo, skip one round. But don't let too much time pass as there will be Sudden Death!", "Tips"); - Tips << tr("Want to save ropes? Release the rope in mid air and then shoot again. As long as you don't touch the ground you'll reuse your rope without wasting ammo!", "Tips"); - Tips << tr("If you'd like to keep others from using your preferred nickname on the official server, register an account at http://www.hedgewars.org/.", "Tips"); - Tips << tr("You're bored of default gameplay? Try one of the missions - they'll offer different gameplay depending on the one you picked.", "Tips"); - Tips << tr("By default the game will always record the last game played as a demo. Select 'Local Game' and pick the 'Demos' button on the lower right corner to play or manage them.", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you've got problems, ask on our forums but please don't expect 24/7 support!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you like it, help us with a small donation or contribute your own work!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. Share it with your family and friends as you like!", "Tips"); - Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If someone sold you the game, you should try get a refund!", "Tips"); - Tips << tr("From time to time there will be official tournaments. Upcoming events will be announced at http://www.hedgewars.org/ some days in advance.", "Tips"); - Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips"); - Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips"); - Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips"); - Tips << tr("Connect one or more gamepads before starting the game to be able to assign their controls to your teams.", "Tips"); - Tips << tr("Create an account on %1 to keep others from using your most favourite nickname while playing on the official server.", "Tips").arg("http://www.hedgewars.org/"); - Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips"); - Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips"); - Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to update the associated drivers.", "Tips"); - Tips << tr("We're open to suggestions and constructive feedback. If you don't like something or got a great idea, let us know!", "Tips"); - Tips << tr("Especially while playing online be polite and always remember there might be some minors playing with or against you as well!", "Tips"); - Tips << tr("Special game modes such as 'Vampirism' or 'Karma' allow you to develop completely new tactics. Try them in a custom game!", "Tips"); - Tips << tr("The Windows version of Hedgewars supports Xfire. Make sure to add Hedgewars to its game list so your friends can see you playing.", "Tips"); - Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips"); - Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips"); - Tips << tr("No hedgehogs were harmed in making this game.", "Tips"); - Tips << tr("There are three different jumps available. Tap [high jump] twice to do a very high/backwards jump.", "Tips"); - Tips << tr("Afraid of falling off a cliff? Hold down [precise] to turn [left] or [right] without actually moving.", "Tips"); - Tips << tr("Some weapons require special strategies or just lots of training, so don't give up on a particular tool if you miss an enemy once.", "Tips"); - Tips << tr("Most weapons won't work once they touch the water. The Homing Bee as well as the Cake are exceptions to this.", "Tips"); - Tips << tr("The Old Limbuger only causes a small explosion. However the wind affected smelly cloud can poison lots of hogs at once.", "Tips"); - Tips << tr("The Piano Strike is the most damaging air strike. You'll lose the hedgehog performing it, so there's a huge downside as well.", "Tips"); - Tips << tr("The Homing Bee can be tricky to use. Its turn radius depends on its velocity, so try to not use full power.", "Tips"); - Tips << tr("Sticky Mines are a perfect tool to create small chain reactions knocking enemy hedgehogs into dire situations ... or water.", "Tips"); - Tips << tr("The Hammer is most effective when used on bridges or girders. Hit hogs will just break through the ground.", "Tips"); - Tips << tr("If you're stuck behind an enemy hedgehog, use the Hammer to free yourself without getting damaged by an explosion.", "Tips"); - Tips << tr("The Cake's maximum walking distance depends on the ground it has to pass. Use [attack] to detonate it early.", "Tips"); - Tips << tr("The Flame Thrower is a weapon but it can be used for tunnel digging as well.", "Tips"); - Tips << tr("Use the Molotov or Flame Thrower to temporary keep hedgehogs from passing terrain such as tunnels or platforms.", "Tips"); - Tips << tr("Want to know who's behind the game? Click on the Hedgewars logo in the main menu to see the credits.", "Tips"); - Tips << tr("Like Hedgewars? Become a fan on %1 or follow us on %2!", "Tips").arg("Facebook").arg("Twitter"); - Tips << tr("Feel free to draw your own graves, hats, flags or even maps and themes! But note that you'll have to share them somewhere to use them online.", "Tips"); - Tips << tr("Really want to wear a specific hat? Donate to us and receive an exclusive hat of your choice!", "Tips"); - // The following tip will require links to app store entries first. - //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); - // the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866 - Tips << tr("Keep your video card drivers up to date to avoid issues playing the game.", "Tips"); - Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); + Tips << tr("Simply pick the same color as a friend to play together as a team. Each of you will still control his or her own hedgehogs but they'll win or lose together.", "Tips"); + Tips << tr("Some weapons might do only low damage but they can be a lot more devastating in the right situation. Try to use the Desert Eagle to knock multiple hedgehogs into the water.", "Tips"); + Tips << tr("If you're unsure what to do and don't want to waste ammo, skip one round. But don't let too much time pass as there will be Sudden Death!", "Tips"); + Tips << tr("Want to save ropes? Release the rope in mid air and then shoot again. As long as you don't touch the ground you'll reuse your rope without wasting ammo!", "Tips"); + Tips << tr("If you'd like to keep others from using your preferred nickname on the official server, register an account at http://www.hedgewars.org/.", "Tips"); + Tips << tr("You're bored of default gameplay? Try one of the missions - they'll offer different gameplay depending on the one you picked.", "Tips"); + Tips << tr("By default the game will always record the last game played as a demo. Select 'Local Game' and pick the 'Demos' button on the lower right corner to play or manage them.", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you've got problems, ask on our forums but please don't expect 24/7 support!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you like it, help us with a small donation or contribute your own work!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. Share it with your family and friends as you like!", "Tips"); + Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If someone sold you the game, you should try get a refund!", "Tips"); + Tips << tr("From time to time there will be official tournaments. Upcoming events will be announced at http://www.hedgewars.org/ some days in advance.", "Tips"); + Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips"); + Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips"); + Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips"); + Tips << tr("Connect one or more gamepads before starting the game to be able to assign their controls to your teams.", "Tips"); + Tips << tr("Create an account on %1 to keep others from using your most favourite nickname while playing on the official server.", "Tips").arg("http://www.hedgewars.org/"); + Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips"); + Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips"); + Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to update the associated drivers.", "Tips"); + Tips << tr("We're open to suggestions and constructive feedback. If you don't like something or got a great idea, let us know!", "Tips"); + Tips << tr("Especially while playing online be polite and always remember there might be some minors playing with or against you as well!", "Tips"); + Tips << tr("Special game modes such as 'Vampirism' or 'Karma' allow you to develop completely new tactics. Try them in a custom game!", "Tips"); + Tips << tr("The Windows version of Hedgewars supports Xfire. Make sure to add Hedgewars to its game list so your friends can see you playing.", "Tips"); + Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips"); + Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips"); + Tips << tr("No hedgehogs were harmed in making this game.", "Tips"); + Tips << tr("There are three different jumps available. Tap [high jump] twice to do a very high/backwards jump.", "Tips"); + Tips << tr("Afraid of falling off a cliff? Hold down [precise] to turn [left] or [right] without actually moving.", "Tips"); + Tips << tr("Some weapons require special strategies or just lots of training, so don't give up on a particular tool if you miss an enemy once.", "Tips"); + Tips << tr("Most weapons won't work once they touch the water. The Homing Bee as well as the Cake are exceptions to this.", "Tips"); + Tips << tr("The Old Limbuger only causes a small explosion. However the wind affected smelly cloud can poison lots of hogs at once.", "Tips"); + Tips << tr("The Piano Strike is the most damaging air strike. You'll lose the hedgehog performing it, so there's a huge downside as well.", "Tips"); + Tips << tr("The Homing Bee can be tricky to use. Its turn radius depends on its velocity, so try to not use full power.", "Tips"); + Tips << tr("Sticky Mines are a perfect tool to create small chain reactions knocking enemy hedgehogs into dire situations ... or water.", "Tips"); + Tips << tr("The Hammer is most effective when used on bridges or girders. Hit hogs will just break through the ground.", "Tips"); + Tips << tr("If you're stuck behind an enemy hedgehog, use the Hammer to free yourself without getting damaged by an explosion.", "Tips"); + Tips << tr("The Cake's maximum walking distance depends on the ground it has to pass. Use [attack] to detonate it early.", "Tips"); + Tips << tr("The Flame Thrower is a weapon but it can be used for tunnel digging as well.", "Tips"); + Tips << tr("Use the Molotov or Flame Thrower to temporary keep hedgehogs from passing terrain such as tunnels or platforms.", "Tips"); + Tips << tr("Want to know who's behind the game? Click on the Hedgewars logo in the main menu to see the credits.", "Tips"); + Tips << tr("Like Hedgewars? Become a fan on %1 or follow us on %2!", "Tips").arg("Facebook").arg("Twitter"); + Tips << tr("Feel free to draw your own graves, hats, flags or even maps and themes! But note that you'll have to share them somewhere to use them online.", "Tips"); + Tips << tr("Really want to wear a specific hat? Donate to us and receive an exclusive hat of your choice!", "Tips"); + // The following tip will require links to app store entries first. + //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); + // the ios version is located here: http://itunes.apple.com/us/app/hedgewars/id391234866 + Tips << tr("Keep your video card drivers up to date to avoid issues playing the game.", "Tips"); + Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); #ifdef _WIN32 - Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); #elif defined __APPLE__ - Tips << tr("You can find your Hedgewars configuration files under \"Library/Application Support/Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \"Library/Application Support/Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); #else - Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); + Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); #endif - return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; + return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagemain.h --- a/QTfrontend/ui/page/pagemain.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagemain.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,24 +23,26 @@ class PageMain : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageMain(QWidget * parent = 0); + public: + PageMain(QWidget * parent = 0); - QPushButton * BtnSinglePlayer; - QPushButton * BtnNet; - QPushButton * BtnSetup; - QPushButton * BtnInfo; - QPushButton * BtnDataDownload; - QLabel * mainNote; + QPushButton * BtnSinglePlayer; + QPushButton * BtnNet; + QPushButton * BtnSetup; + QPushButton * BtnFeedback; + QPushButton * BtnInfo; + QPushButton * BtnDataDownload; + QPushButton * BtnVideos; + QLabel * mainNote; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QString randomTip() const; + QString randomTip() const; }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagemultiplayer.cpp --- a/QTfrontend/ui/page/pagemultiplayer.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagemultiplayer.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagemultiplayer.h --- a/QTfrontend/ui/page/pagemultiplayer.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagemultiplayer.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,24 +26,24 @@ class PageMultiplayer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageMultiplayer(QWidget* parent = 0); + public: + PageMultiplayer(QWidget* parent = 0); - GameCFGWidget *gameCFG; - TeamSelWidget *teamsSelect; - QPushButton *BtnStartMPGame; + GameCFGWidget *gameCFG; + TeamSelWidget *teamsSelect; + QPushButton *BtnStartMPGame; -signals: - void SetupClicked(); + signals: + void SetupClicked(); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QPushButton * btnSetup; + QPushButton * btnSetup; }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenet.cpp --- a/QTfrontend/ui/page/pagenet.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenet.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -108,7 +108,12 @@ QModelIndex mi = tvServersList->currentIndex(); if(!mi.isValid()) { - QMessageBox::information(this, tr("Error"), tr("Please select server from the list above")); + QMessageBox serverMsg(this); + serverMsg.setIcon(QMessageBox::Warning); + serverMsg.setWindowTitle(QMessageBox::tr("Netgame - Error")); + serverMsg.setText(QMessageBox::tr("Please select a server from the list")); + serverMsg.setWindowModality(Qt::WindowModal); + serverMsg.exec(); return; } QString host = model->index(mi.row(), 1).data().toString(); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenet.h --- a/QTfrontend/ui/page/pagenet.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenet.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,33 +23,33 @@ class PageNet : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNet(QWidget* parent = 0); + public: + PageNet(QWidget* parent = 0); - QPushButton* BtnUpdateSList; - QTableView * tvServersList; - QPushButton * BtnNetConnect; - QPushButton * BtnNetSvrStart; - QPushButton * BtnSpecifyServer; + QPushButton* BtnUpdateSList; + QTableView * tvServersList; + QPushButton * BtnNetConnect; + QPushButton * BtnNetSvrStart; + QPushButton * BtnSpecifyServer; -public slots: - void updateServersList(); + public slots: + void updateServersList(); -signals: - void connectClicked(const QString & host, quint16 port); + signals: + void connectClicked(const QString & host, quint16 port); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QGroupBox * ConnGroupBox; - QGridLayout * GBClayout; + QGroupBox * ConnGroupBox; + QGridLayout * GBClayout; -private slots: - void slotConnect(); + private slots: + void slotConnect(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenetgame.cpp --- a/QTfrontend/ui/page/pagenetgame.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenetgame.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,8 +38,8 @@ // chatwidget pChatWidget = new HWChatWidget(this, m_gameSettings, true); - pChatWidget->setShowReady(true); // show status bulbs by default pChatWidget->setShowFollow(false); // don't show follow in nicks' context menus + pChatWidget->setIgnoreListKick(true); // kick ignored players automatically pageLayout->addWidget(pChatWidget, 2, 0, 1, 2); pageLayout->setRowStretch(1, 100); pageLayout->setRowStretch(2, 100); @@ -67,6 +67,7 @@ leRoomName->setMinimumWidth(200); leRoomName->setMaximumWidth(400); + //Button to signify whether the player is ready to start playing BtnGo = new QPushButton(this); BtnGo->setToolTip(QPushButton::tr("Ready")); BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); @@ -74,7 +75,6 @@ BtnGo->setMinimumWidth(50); BtnGo->setMinimumHeight(50); - bottomLayout->addWidget(leRoomName); BtnUpdate = addButton(QAction::tr("Update"), bottomLayout, 1); @@ -152,10 +152,12 @@ else { leRoomName->clear(); - QMessageBox::critical(this, - tr("Error"), - tr("Please enter room name"), - tr("OK")); + QMessageBox roomMsg(this); + roomMsg.setIcon(QMessageBox::Warning); + roomMsg.setWindowTitle(QMessageBox::tr("Netgame - Error")); + roomMsg.setText(QMessageBox::tr("Please enter room name")); + roomMsg.setWindowModality(Qt::WindowModal); + roomMsg.exec(); } } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenetgame.h --- a/QTfrontend/ui/page/pagenetgame.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenetgame.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,53 +29,53 @@ class PageNetGame : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetGame(QWidget* parent, QSettings * gameSettings); + public: + PageNetGame(QWidget* parent, QSettings * gameSettings); - /** - * Sets the room name to display. - * @param roomName room name to be displayed. - */ - void setRoomName(const QString & roomName); + /** + * Sets the room name to display. + * @param roomName room name to be displayed. + */ + void setRoomName(const QString & roomName); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); - QPushButton *BtnGo; - QPushButton *BtnMaster; - QPushButton *BtnStart; - QPushButton *BtnUpdate; + QPushButton *BtnGo; + QPushButton *BtnMaster; + QPushButton *BtnStart; + QPushButton *BtnUpdate; - QAction * restrictJoins; - QAction * restrictTeamAdds; + QAction * restrictJoins; + QAction * restrictTeamAdds; - HWChatWidget* pChatWidget; + HWChatWidget* pChatWidget; - TeamSelWidget* pNetTeamsWidget; - GameCFGWidget* pGameCFG; + TeamSelWidget* pNetTeamsWidget; + GameCFGWidget* pGameCFG; -public slots: - void setReadyStatus(bool isReady); - void setUser(const QString & nickname); - void onUpdateClick(); - void setMasterMode(bool isMaster); + public slots: + void setReadyStatus(bool isReady); + void setUser(const QString & nickname); + void onUpdateClick(); + void setMasterMode(bool isMaster); -signals: - void SetupClicked(); - void askForUpdateRoomName(const QString &); + signals: + void SetupClicked(); + void askForUpdateRoomName(const QString &); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - QSettings * m_gameSettings; + QSettings * m_gameSettings; - HistoryLineEdit * leRoomName; - QPushButton * btnSetup; + HistoryLineEdit * leRoomName; + QPushButton * btnSetup; }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenetserver.cpp --- a/QTfrontend/ui/page/pagenetserver.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenetserver.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenetserver.h --- a/QTfrontend/ui/page/pagenetserver.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenetserver.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,25 +23,25 @@ class PageNetServer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetServer(QWidget* parent = 0); + public: + PageNetServer(QWidget* parent = 0); - QPushButton *BtnStart; - QPushButton *BtnDefault; - QLabel *labelSD; - QLineEdit *leServerDescr; - QLabel *labelPort; - QSpinBox *sbPort; + QPushButton *BtnStart; + QPushButton *BtnDefault; + QLabel *labelSD; + QLineEdit *leServerDescr; + QLabel *labelPort; + QSpinBox *sbPort; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private slots: - void setDefaultPort(); + private slots: + void setDefaultPort(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenettype.cpp --- a/QTfrontend/ui/page/pagenettype.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenettype.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +33,9 @@ pageLayout->setColumnStretch(3, 10); BtnLAN = addButton(tr("LAN game"), pageLayout, 1, 2); + BtnLAN->setWhatsThis(tr("Join or host your own game server in a Local Area Network.")); BtnOfficialServer = addButton(tr("Official server"), pageLayout, 2, 2); + BtnOfficialServer->setWhatsThis(tr("Join hundreds of players online!")); // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet) //BtnOfficialServer->setEnabled(false); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagenettype.h --- a/QTfrontend/ui/page/pagenettype.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagenettype.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,16 +23,16 @@ class PageNetType : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageNetType(QWidget* parent = 0); + public: + PageNetType(QWidget* parent = 0); - QPushButton * BtnLAN; - QPushButton * BtnOfficialServer; + QPushButton * BtnLAN; + QPushButton * BtnOfficialServer; -protected: - QLayout * bodyLayoutDefinition(); + protected: + QLayout * bodyLayoutDefinition(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageoptions.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,36 +28,37 @@ #include #include #include +#include +#include +#include #include "pageoptions.h" #include "hwconsts.h" #include "fpsedit.h" #include "igbox.h" +#include "DataManager.h" // TODO cleanup QLayout * PageOptions::bodyLayoutDefinition() { - QGridLayout * pageLayout = new QGridLayout(); - pageLayout->setColumnStretch(0, 100); - pageLayout->setColumnStretch(1, 100); - pageLayout->setColumnStretch(2, 100); - pageLayout->setRowStretch(0, 0); - //pageLayout->setRowStretch(1, 100); - pageLayout->setRowStretch(2, 0); - pageLayout->setContentsMargins(7, 7, 7, 0); - pageLayout->setSpacing(0); + QVBoxLayout * pageLayout = new QVBoxLayout(); + QTabWidget * tabs = new QTabWidget(this); + pageLayout->addWidget(tabs); + QWidget * page1 = new QWidget(this); + QWidget * page2 = new QWidget(this); + tabs->addTab(page1, tr("General")); + tabs->addTab(page2, tr("Advanced")); - QGroupBox * gbTwoBoxes = new QGroupBox(this); - pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); - QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes); - gbTBLayout->setMargin(0); - gbTBLayout->setSpacing(0); - gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + { // page 1 + QGridLayout * page1Layout = new QGridLayout(page1); + //gbTBLayout->setMargin(0); + page1Layout->setSpacing(0); + page1Layout->setAlignment(Qt::AlignTop | Qt::AlignLeft); - QPixmap pmNew(":/res/new.png"); - QPixmap pmEdit(":/res/edit.png"); - QPixmap pmDelete(":/res/delete.png"); + QPixmap pmNew(":/res/new.png"); + QPixmap pmEdit(":/res/edit.png"); + QPixmap pmDelete(":/res/delete.png"); { teamsBox = new IconedGroupBox(this); @@ -102,12 +103,12 @@ LblNoEditTeam->setVisible(false); GBTlayout->addWidget(LblNoEditTeam, 0, 0); - gbTBLayout->addWidget(teamsBox, 0, 0); + page1Layout->addWidget(teamsBox, 0, 0); } { IconedGroupBox* groupWeapons = new IconedGroupBox(this); - + //groupWeapons->setContentTopPadding(0); //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); @@ -123,21 +124,21 @@ WeaponsLayout->addWidget(SchemesName, 1, 1); SchemeNew = new QPushButton(groupWeapons); - SchemeNew->setToolTip(tr("New scheme")); + SchemeNew->setWhatsThis(tr("New scheme")); SchemeNew->setIconSize(pmNew.size()); SchemeNew->setIcon(pmNew); SchemeNew->setMaximumWidth(pmNew.width() + 6); WeaponsLayout->addWidget(SchemeNew, 1, 2); SchemeEdit = new QPushButton(groupWeapons); - SchemeEdit->setToolTip(tr("Edit scheme")); + SchemeEdit->setWhatsThis(tr("Edit scheme")); SchemeEdit->setIconSize(pmEdit.size()); SchemeEdit->setIcon(pmEdit); SchemeEdit->setMaximumWidth(pmEdit.width() + 6); WeaponsLayout->addWidget(SchemeEdit, 1, 3); SchemeDelete = new QPushButton(groupWeapons); - SchemeDelete->setToolTip(tr("Delete scheme")); + SchemeDelete->setWhatsThis(tr("Delete scheme")); SchemeDelete->setIconSize(pmDelete.size()); SchemeDelete->setIcon(pmDelete); SchemeDelete->setMaximumWidth(pmDelete.width() + 6); @@ -151,64 +152,44 @@ WeaponsLayout->addWidget(WeaponsName, 2, 1); WeaponNew = new QPushButton(groupWeapons); - WeaponNew->setToolTip(tr("New weapon set")); + WeaponNew->setWhatsThis(tr("New weapon set")); WeaponNew->setIconSize(pmNew.size()); WeaponNew->setIcon(pmNew); WeaponNew->setMaximumWidth(pmNew.width() + 6); WeaponsLayout->addWidget(WeaponNew, 2, 2); WeaponEdit = new QPushButton(groupWeapons); - WeaponEdit->setToolTip(tr("Edit weapon set")); + WeaponEdit->setWhatsThis(tr("Edit weapon set")); WeaponEdit->setIconSize(pmEdit.size()); WeaponEdit->setIcon(pmEdit); WeaponEdit->setMaximumWidth(pmEdit.width() + 6); WeaponsLayout->addWidget(WeaponEdit, 2, 3); WeaponDelete = new QPushButton(groupWeapons); - WeaponDelete->setToolTip(tr("Delete weapon set")); + WeaponDelete->setWhatsThis(tr("Delete weapon set")); WeaponDelete->setIconSize(pmDelete.size()); WeaponDelete->setIcon(pmDelete); WeaponDelete->setMaximumWidth(pmDelete.width() + 6); WeaponsLayout->addWidget(WeaponDelete, 2, 4); - WeaponTooltip = new QCheckBox(this); - WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips")); - WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4); - - gbTBLayout->addWidget(groupWeapons, 1, 0); + page1Layout->addWidget(groupWeapons, 1, 0); } { IconedGroupBox* groupMisc = new IconedGroupBox(this); //groupMisc->setContentTopPadding(0); - groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); groupMisc->setIcon(QIcon(":/res/miscicon.png")); //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); groupMisc->setTitle(QGroupBox::tr("Misc")); QGridLayout * MiscLayout = new QGridLayout(groupMisc); - labelNN = new QLabel(groupMisc); - labelNN->setText(QLabel::tr("Net nick")); - MiscLayout->addWidget(labelNN, 0, 0); - - editNetNick = new QLineEdit(groupMisc); - editNetNick->setMaxLength(20); - editNetNick->setText(QLineEdit::tr("unnamed")); - connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); - MiscLayout->addWidget(editNetNick, 0, 1); - - labelNetPassword = new QLabel(groupMisc); - labelNetPassword->setText(QLabel::tr("Password")); - MiscLayout->addWidget(labelNetPassword, 1, 0); - - editNetPassword = new QLineEdit(groupMisc); - editNetPassword->setEchoMode(QLineEdit::Password); - MiscLayout->addWidget(editNetPassword, 1, 1); - + // Label for "Language" QLabel *labelLanguage = new QLabel(groupMisc); labelLanguage->setText(QLabel::tr("Locale") + " *"); - MiscLayout->addWidget(labelLanguage, 2, 0); + MiscLayout->addWidget(labelLanguage, 0, 0); + // List of installed languages CBLanguage = new QComboBox(groupMisc); QDir tmpdir; tmpdir.cd(cfgdir->absolutePath()); @@ -233,29 +214,35 @@ CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); } - MiscLayout->addWidget(CBLanguage, 2, 1); + MiscLayout->addWidget(CBLanguage, 0, 1); - CBAltDamage = new QCheckBox(groupMisc); - CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); - MiscLayout->addWidget(CBAltDamage, 3, 0, 1, 2); + // Label and field for net nick + labelNN = new QLabel(groupMisc); + labelNN->setText(QLabel::tr("Nickname")); + MiscLayout->addWidget(labelNN, 1, 0); + + editNetNick = new QLineEdit(groupMisc); + editNetNick->setMaxLength(20); + editNetNick->setText(QLineEdit::tr("anonymous")); + MiscLayout->addWidget(editNetNick, 1, 1); - CBNameWithDate = new QCheckBox(groupMisc); - CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); - MiscLayout->addWidget(CBNameWithDate, 4, 0, 1, 2); + // checkbox and field for password + CBSavePassword = new QCheckBox(groupMisc); + CBSavePassword->setText(QCheckBox::tr("Save password")); + MiscLayout->addWidget(CBSavePassword, 2, 0); - BtnAssociateFiles = new QPushButton(groupMisc); - BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); - BtnAssociateFiles->setEnabled(!custom_data && !custom_config); - MiscLayout->addWidget(BtnAssociateFiles, 5, 0, 1, 2); + editNetPassword = new QLineEdit(groupMisc); + editNetPassword->setEchoMode(QLineEdit::Password); + MiscLayout->addWidget(editNetPassword, 2, 1); -#ifdef __APPLE__ -#ifdef SPARKLE_ENABLED + #ifdef __APPLE__ + #ifdef SPARKLE_ENABLED CBAutoUpdate = new QCheckBox(groupMisc); CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); - MiscLayout->addWidget(CBAutoUpdate, 6, 0, 1, 3); -#endif -#endif - gbTBLayout->addWidget(groupMisc, 2, 0); + MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3); + #endif + #endif + page1Layout->addWidget(groupMisc, 2, 0); } { @@ -275,7 +262,7 @@ GBAlayout->addWidget(CBFrontendFullscreen); CBFrontendEffects = new QCheckBox(AGGroupBox); - CBFrontendEffects->setText(QCheckBox::tr("Frontend effects") + " *"); + CBFrontendEffects->setText(QCheckBox::tr("Frontend effects")); GBAlayout->addWidget(CBFrontendEffects); CBEnableFrontendSound = new QCheckBox(AGGroupBox); @@ -302,13 +289,13 @@ CBFullscreen = new QCheckBox(AGGroupBox); CBFullscreen->setText(QCheckBox::tr("Fullscreen")); - GBAlayout->addWidget(CBFullscreen); + GBAreslayout->addWidget(CBFullscreen); QLabel * quality = new QLabel(AGGroupBox); quality->setText(QLabel::tr("Quality")); quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); GBAqualayout->addWidget(quality); - + SLQuality = new QSlider(Qt::Horizontal, AGGroupBox); SLQuality->setTickPosition(QSlider::TicksBelow); SLQuality->setMaximum(5); @@ -338,7 +325,6 @@ CBStereoMode->addItem(QComboBox::tr("Blue/Red grayscale")); CBStereoMode->addItem(QComboBox::tr("Red/Green grayscale")); CBStereoMode->addItem(QComboBox::tr("Green/Red grayscale")); - connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); GBAstereolayout->addWidget(CBStereoMode); GBAlayout->addLayout(GBAstereolayout); @@ -349,23 +335,25 @@ hr->setFixedHeight(10); GBAlayout->addWidget(hr); - QHBoxLayout * GBAvollayout = new QHBoxLayout(0); + QGridLayout * GBAvollayout = new QGridLayout(); QLabel * vol = new QLabel(AGGroupBox); vol->setText(QLabel::tr("Initial sound volume")); - GBAvollayout->addWidget(vol); + GBAvollayout->addWidget(vol, 0, 0, 1, 2); GBAlayout->addLayout(GBAvollayout); volumeBox = new QSpinBox(AGGroupBox); volumeBox->setRange(0, 100); volumeBox->setSingleStep(5); - GBAvollayout->addWidget(volumeBox); + GBAvollayout->addWidget(volumeBox, 0, 2); CBEnableSound = new QCheckBox(AGGroupBox); CBEnableSound->setText(QCheckBox::tr("Enable sound")); - GBAlayout->addWidget(CBEnableSound); + GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1); CBEnableMusic = new QCheckBox(AGGroupBox); CBEnableMusic->setText(QCheckBox::tr("Enable music")); - GBAlayout->addWidget(CBEnableMusic); + GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2); + + GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize); hr = new QFrame(AGGroupBox); hr->setFrameStyle(QFrame::HLine); @@ -373,32 +361,138 @@ hr->setFixedHeight(10); GBAlayout->addWidget(hr); + CBAltDamage = new QCheckBox(AGGroupBox); + CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); + GBAlayout->addWidget(CBAltDamage); + + page1Layout->addWidget(AGGroupBox, 0, 1, 3, 1); + } + + page1Layout->addWidget(new QWidget(this), 3, 0); + + } + + { // page 2 + QGridLayout * page2Layout = new QGridLayout(page2); + + { + IconedGroupBox * gbColors = new IconedGroupBox(this); + gbColors->setIcon(QIcon(":/res/lightbulb_on.png")); + gbColors->setTitle(QGroupBox::tr("Custom colors")); + page2Layout->addWidget(gbColors, 0, 0); + QGridLayout * gbCLayout = new QGridLayout(gbColors); + + QSignalMapper * mapper = new QSignalMapper(this); + + QStandardItemModel * model = DataManager::instance().colorsModel(); + + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onColorModelDataChanged(QModelIndex,QModelIndex))); + for(int i = 0; i < model->rowCount(); ++i) + { + QPushButton * btn = new QPushButton(this); + btn->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + gbCLayout->addWidget(btn, i / 3, i % 3); + btn->setStyleSheet(QString("background: %1").arg(model->item(i)->data().value().name())); + m_colorButtons.append(btn); + connect(btn, SIGNAL(clicked()), mapper, SLOT(map())); + mapper->setMapping(btn, i); + } + + connect(mapper, SIGNAL(mapped(int)), this, SLOT(colorButtonClicked(int))); + + QPushButton * btn = new QPushButton(this); + gbCLayout->addWidget(btn, (model->rowCount() - 1) / 3 + 1, 0, 1, 3); + btn->setText(tr("Reset to default colors")); + connect(btn, SIGNAL(clicked()), &DataManager::instance(), SLOT(resetColors())); + } + + { + IconedGroupBox * gbMisc = new IconedGroupBox(this); + gbMisc->setIcon(QIcon(":/res/Settings.png")); + gbMisc->setTitle(QGroupBox::tr("Miscellaneous")); + page2Layout->addWidget(gbMisc, 0, 1); + QVBoxLayout * gbCLayout = new QVBoxLayout(gbMisc); + QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); QLabel * maxfps = new QLabel(AGGroupBox); maxfps->setText(QLabel::tr("FPS limit")); GBAfpslayout->addWidget(maxfps); - GBAlayout->addLayout(GBAfpslayout); fpsedit = new FPSEdit(AGGroupBox); GBAfpslayout->addWidget(fpsedit); CBShowFPS = new QCheckBox(AGGroupBox); CBShowFPS->setText(QCheckBox::tr("Show FPS")); - GBAlayout->addWidget(CBShowFPS); + GBAfpslayout->addWidget(CBShowFPS); + + gbCLayout->addLayout(GBAfpslayout); + + + WeaponTooltip = new QCheckBox(this); + WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips")); + gbCLayout->addWidget(WeaponTooltip); + - hr = new QFrame(AGGroupBox); - hr->setFrameStyle(QFrame::HLine); - hr->setLineWidth(3); - hr->setFixedHeight(10); - GBAlayout->addWidget(hr); + CBNameWithDate = new QCheckBox(this); + CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); + gbCLayout->addWidget(CBNameWithDate); + + BtnAssociateFiles = new QPushButton(this); + BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); + BtnAssociateFiles->setVisible(!custom_data && !custom_config); + gbCLayout->addWidget(BtnAssociateFiles); + } + + { + IconedGroupBox * gbProxy = new IconedGroupBox(this); + gbProxy->setIcon(QIcon(":/res/Settings.png")); + gbProxy->setTitle(QGroupBox::tr("Proxy settings")); + page2Layout->addWidget(gbProxy, 1, 0); + QGridLayout * gbLayout = new QGridLayout(gbProxy); - QLabel *restartNote = new QLabel(this); - restartNote->setText(QString("* ") + QLabel::tr("Restart game to apply")); - restartNote->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); - GBAlayout->addWidget(restartNote); + QStringList sl; + sl + << tr("Proxy host") + << tr("Proxy port") + << tr("Proxy login") + << tr("Proxy password") + ; + for(int i = 0; i < sl.size(); ++i) + { + QLabel * l = new QLabel(gbProxy); + l->setText(sl[i]); + gbLayout->addWidget(l, i + 1, 0); + } + + cbProxyType = new QComboBox(gbProxy); + cbProxyType->addItems(QStringList() + << tr("No proxy") + << tr("System proxy settings") + << tr("Socks5 proxy") + << tr("HTTP proxy")); + gbLayout->addWidget(cbProxyType, 0, 1); - gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1); + leProxy = new QLineEdit(gbProxy); + gbLayout->addWidget(leProxy, 1, 1); + + sbProxyPort = new QSpinBox(gbProxy); + sbProxyPort->setMaximum(65535); + gbLayout->addWidget(sbProxyPort, 2, 1); + + leProxyLogin = new QLineEdit(gbProxy); + gbLayout->addWidget(leProxyLogin, 3, 1); + + leProxyPassword = new QLineEdit(gbProxy); + leProxyPassword->setEchoMode(QLineEdit::Password); + gbLayout->addWidget(leProxyPassword, 4, 1); + + + connect(cbProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(onProxyTypeChanged())); + onProxyTypeChanged(); } + page2Layout->addWidget(new QWidget(this), 2, 0); + } + previousQuality = this->SLQuality->value(); previousResolutionIndex = this->CBResolution->currentIndex(); previousFullscreenValue = this->CBFullscreen->isChecked(); @@ -408,18 +502,17 @@ QLayout * PageOptions::footerLayoutDefinition() { - QHBoxLayout * bottomLayout = new QHBoxLayout(); - btnSave = addButton(":/res/Save.png", bottomLayout, 0, true); - btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); - bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom); - return bottomLayout; + return NULL; } void PageOptions::connectSignals() { + connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); connect(CBResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setResolution(int))); connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(int))); - connect(SLQuality, SIGNAL(valueChanged(int)), this, SLOT(setQuality(int))); + connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); + connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); + connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); } PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) @@ -431,13 +524,16 @@ { bool forced = (index == 7 || index == 8 || index == 9); - if (index != 0) { + if (index != 0) + { this->SLQuality->setValue(this->SLQuality->maximum()); this->SLQuality->setEnabled(false); this->CBFullscreen->setEnabled(!forced); this->CBFullscreen->setChecked(forced ? true : previousFullscreenValue); this->CBResolution->setCurrentIndex(forced ? 0 : previousResolutionIndex); - } else { + } + else + { this->SLQuality->setEnabled(true); this->CBFullscreen->setEnabled(true); this->SLQuality->setValue(previousQuality); @@ -478,6 +574,14 @@ editNetNick->setText(editNetNick->text().trimmed()); } +void PageOptions::savePwdChanged(int state) { + if (state == 0) { + editNetPassword->setEnabled(false); + editNetPassword->setText(""); + } else + editNetPassword->setEnabled(true); +} + void PageOptions::requestEditSelectedTeam() { emit editTeamRequested(CBTeamName->currentText()); @@ -496,3 +600,37 @@ CBTeamName->setVisible(enabled); LblNoEditTeam->setVisible(!enabled); } + +void PageOptions::colorButtonClicked(int i) +{ + if(i < 0 || i >= m_colorButtons.size()) + return; + + QPalette p = m_colorButtons[i]->palette(); + QColor c = QColorDialog::getColor(p.color(QPalette::Button)); + + if(c.isValid()) + { + DataManager::instance().colorsModel()->item(i)->setData(c); + m_colorButtons[i]->setStyleSheet(QString("background: %1").arg(c.name())); + } +} + +void PageOptions::onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight) +{ + Q_UNUSED(bottomRight); + + QStandardItemModel * model = DataManager::instance().colorsModel(); + + m_colorButtons[topLeft.row()]->setStyleSheet(QString("background: %1").arg(model->item(topLeft.row())->data().value().name())); +} + +void PageOptions::onProxyTypeChanged() +{ + bool b = cbProxyType->currentIndex() != NoProxy && cbProxyType->currentIndex() != SystemProxy ; + + sbProxyPort->setEnabled(b); + leProxy->setEnabled(b); + leProxyLogin->setEnabled(b); + leProxyPassword->setEnabled(b); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageoptions.h --- a/QTfrontend/ui/page/pageoptions.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageoptions.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,84 +23,101 @@ class FPSEdit; class IconedGroupBox; +class QSignalMapper; class PageOptions : public AbstractPage { - Q_OBJECT - -public: - PageOptions(QWidget* parent = 0); + Q_OBJECT - QCheckBox *WeaponTooltip; - QPushButton *WeaponNew; - QPushButton *WeaponEdit; - QPushButton *WeaponDelete; - QComboBox *WeaponsName; - QPushButton *SchemeNew; - QPushButton *SchemeEdit; - QPushButton *SchemeDelete; - QComboBox *SchemesName; + public: + enum ProxyTypes { + NoProxy = 0, + SystemProxy = 1, + Socks5Proxy = 2, + HTTPProxy = 3 + }; - QComboBox *CBLanguage; + PageOptions(QWidget* parent = 0); - IconedGroupBox *teamsBox;; - QPushButton *BtnAssociateFiles; - QComboBox *CBTeamName; - IconedGroupBox *AGGroupBox; - QComboBox *CBResolution; - QComboBox *CBStereoMode; - QCheckBox *CBEnableSound; - QCheckBox *CBEnableFrontendSound; - QCheckBox *CBEnableMusic; - QCheckBox *CBEnableFrontendMusic; - QCheckBox *CBFullscreen; - QCheckBox *CBFrontendFullscreen; - QCheckBox *CBShowFPS; - QCheckBox *CBAltDamage; - QCheckBox *CBNameWithDate; + QCheckBox *WeaponTooltip; + QPushButton *WeaponNew; + QPushButton *WeaponEdit; + QPushButton *WeaponDelete; + QComboBox *WeaponsName; + QPushButton *SchemeNew; + QPushButton *SchemeEdit; + QPushButton *SchemeDelete; + QComboBox *SchemesName; + + QComboBox *CBLanguage; + + IconedGroupBox *teamsBox; + QPushButton *BtnAssociateFiles; + QComboBox *CBTeamName; + IconedGroupBox *AGGroupBox; + QComboBox *CBResolution; + QComboBox *CBStereoMode; + QCheckBox *CBEnableSound; + QCheckBox *CBEnableFrontendSound; + QCheckBox *CBEnableMusic; + QCheckBox *CBEnableFrontendMusic; + QCheckBox *CBFullscreen; + QCheckBox *CBFrontendFullscreen; + QCheckBox *CBShowFPS; + QCheckBox *CBSavePassword; + QCheckBox *CBAltDamage; + QCheckBox *CBNameWithDate; #ifdef __APPLE__ - QCheckBox *CBAutoUpdate; + QCheckBox *CBAutoUpdate; #endif - FPSEdit *fpsedit; - QPushButton *btnSave; - QLabel *labelNN; - QLabel *labelNetPassword; - QSpinBox * volumeBox; - QLineEdit *editNetNick; - QLineEdit *editNetPassword; - QSlider *SLQuality; - QCheckBox *CBFrontendEffects; + FPSEdit *fpsedit; + QLabel *labelNN; + QSpinBox * volumeBox; + QLineEdit *editNetNick; + QLineEdit *editNetPassword; + QSlider *SLQuality; + QCheckBox *CBFrontendEffects; + QComboBox * cbProxyType; + QSpinBox * sbProxyPort; + QLineEdit * leProxy; + QLineEdit * leProxyLogin; + QLineEdit * leProxyPassword; - void setTeamOptionsEnabled(bool enabled); + void setTeamOptionsEnabled(bool enabled); -signals: - void newTeamRequested(); - void editTeamRequested(const QString & teamName); - void deleteTeamRequested(const QString & teamName); + signals: + void newTeamRequested(); + void editTeamRequested(const QString & teamName); + void deleteTeamRequested(const QString & teamName); -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); - bool previousFullscreenValue; - int previousResolutionIndex; - int previousQuality; - QLabel *LblNoEditTeam; - QPushButton *BtnNewTeam; - QPushButton *BtnEditTeam; - QPushButton *BtnDeleteTeam; + bool previousFullscreenValue; + int previousResolutionIndex; + int previousQuality; + QLabel *LblNoEditTeam; + QPushButton *BtnNewTeam; + QPushButton *BtnEditTeam; + QPushButton *BtnDeleteTeam; + QList m_colorButtons; -private slots: - void forceFullscreen(int index); - void setFullscreen(int state); - void setResolution(int state); - void setQuality(int value); - void trimNetNick(); - void requestEditSelectedTeam(); - void requestDeleteSelectedTeam(); + private slots: + void forceFullscreen(int index); + void setFullscreen(int state); + void setResolution(int state); + void setQuality(int value); + void trimNetNick(); + void requestEditSelectedTeam(); + void requestDeleteSelectedTeam(); + void savePwdChanged(int state); + void colorButtonClicked(int i); + void onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); + void onProxyTypeChanged(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageplayrecord.cpp --- a/QTfrontend/ui/page/pageplayrecord.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageplayrecord.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include "pageplayrecord.h" + #include #include #include @@ -26,12 +28,13 @@ #include #include "hwconsts.h" -#include "pageplayrecord.h" + +#include "DataManager.h" QLayout * PagePlayDemo::bodyLayoutDefinition() { QGridLayout * pageLayout = new QGridLayout(); - + pageLayout->setColumnStretch(0, 1); pageLayout->setColumnStretch(1, 2); pageLayout->setColumnStretch(2, 1); @@ -61,6 +64,7 @@ { connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord())); connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord())); + connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(refresh())); } PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent) @@ -81,7 +85,8 @@ dir.cd("Demos"); extension = "hwd"; BtnPlayDemo->setText(QPushButton::tr("Play demo")); - } else + } + else { dir.cd("Saves"); extension = "hws"; @@ -102,15 +107,25 @@ } } + +void PagePlayDemo::refresh() +{ + if (this->isVisible()) + FillFromDir(recType); +} + + void PagePlayDemo::renameRecord() { QListWidgetItem * curritem = DemosList->currentItem(); if (!curritem) { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); + QMessageBox recordMsg(this); + recordMsg.setIcon(QMessageBox::Warning); + recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); + recordMsg.setText(QMessageBox::tr("Please select record from the list")); + recordMsg.setWindowModality(Qt::WindowModal); + recordMsg.exec(); return ; } QFile rfile(curritem->data(Qt::UserRole).toString()); @@ -124,14 +139,21 @@ if(ok && newname.size()) { QString newfullname = QString("%1/%2.%3.%4") - .arg(finfo.absolutePath()) - .arg(newname) - .arg(*cProtoVer) - .arg(finfo.suffix()); + .arg(finfo.absolutePath()) + .arg(newname) + .arg(*cProtoVer) + .arg(finfo.suffix()); ok = rfile.rename(newfullname); if(!ok) - QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname); + { + QMessageBox renameMsg(this); + renameMsg.setIcon(QMessageBox::Warning); + renameMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); + renameMsg.setText(QMessageBox::tr("Cannot rename to ") + newfullname); + renameMsg.setWindowModality(Qt::WindowModal); + renameMsg.exec(); + } else FillFromDir(recType); } @@ -142,10 +164,12 @@ QListWidgetItem * curritem = DemosList->currentItem(); if (!curritem) { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); + QMessageBox recordMsg(this); + recordMsg.setIcon(QMessageBox::Warning); + recordMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); + recordMsg.setText(QMessageBox::tr("Please select record from the list")); + recordMsg.setWindowModality(Qt::WindowModal); + recordMsg.exec(); return ; } QFile rfile(curritem->data(Qt::UserRole).toString()); @@ -154,9 +178,20 @@ ok = rfile.remove(); if(!ok) - QMessageBox::critical(this, tr("Error"), tr("Cannot delete file")); + { + QMessageBox removeMsg(this); + removeMsg.setIcon(QMessageBox::Warning); + removeMsg.setWindowTitle(QMessageBox::tr("Record Play - Error")); + removeMsg.setText(QMessageBox::tr("Cannot delete file ") + rfile.fileName()); + removeMsg.setWindowModality(Qt::WindowModal); + removeMsg.exec(); + } else - FillFromDir(recType); + { + int i = DemosList->row(curritem); + delete curritem; + DemosList->setCurrentRow(i < DemosList->count() ? i : DemosList->count() - 1); + } } bool PagePlayDemo::isSave() diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageplayrecord.h --- a/QTfrontend/ui/page/pageplayrecord.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageplayrecord.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,33 +28,37 @@ class PagePlayDemo : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - enum RecordType { - RT_Demo, - RT_Save - }; + public: + enum RecordType + { + RT_Demo, + RT_Save + }; - PagePlayDemo(QWidget* parent = 0); + PagePlayDemo(QWidget* parent = 0); - void FillFromDir(RecordType rectype); - bool isSave(); + void FillFromDir(RecordType rectype); + bool isSave(); - QPushButton *BtnPlayDemo; - QPushButton *BtnRenameRecord; - QPushButton *BtnRemoveRecord; - QListWidget *DemosList; + QPushButton *BtnPlayDemo; + QPushButton *BtnRenameRecord; + QPushButton *BtnRemoveRecord; + QListWidget *DemosList; + + public slots: + void refresh(); -private: - QLayout * bodyLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + void connectSignals(); - RecordType recType; + RecordType recType; -private slots: - void renameRecord(); - void removeRecord(); + private slots: + void renameRecord(); + void removeRecord(); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageroomslist.cpp --- a/QTfrontend/ui/page/pageroomslist.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageroomslist.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,11 @@ #include #include #include -#include +#include + +#include + +#include "roomslistmodel.h" #include "ammoSchemeModel.h" #include "pageroomslist.h" @@ -44,7 +48,7 @@ newRoomLayout->addWidget(roomName); pageLayout->addLayout(newRoomLayout, 0, 0, 1, 2); - roomsList = new QTableWidget(this); + roomsList = new QTableView(this); roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); roomsList->verticalHeader()->setVisible(false); roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); @@ -61,7 +65,7 @@ filterLayout->addWidget(stateLabel); filterLayout->addWidget(CBState); - filterLayout->addSpacing(30); + filterLayout->addStretch(1); QLabel * ruleLabel = new QLabel(this); ruleLabel->setText(tr("Rules:")); @@ -69,7 +73,7 @@ filterLayout->addWidget(ruleLabel); filterLayout->addWidget(CBRules); - filterLayout->addSpacing(30); + filterLayout->addStretch(1); QLabel * weaponLabel = new QLabel(this); weaponLabel->setText(tr("Weapons:")); @@ -77,14 +81,17 @@ filterLayout->addWidget(weaponLabel); filterLayout->addWidget(CBWeapons); - filterLayout->addSpacing(30); + filterLayout->addStretch(1); QLabel * searchLabel = new QLabel(this); searchLabel->setText(tr("Search:")); searchText = new QLineEdit(this); searchText->setMaxLength(60); + searchText->setMinimumWidth(100); + searchText->setMaximumWidth(360); filterLayout->addWidget(searchLabel); filterLayout->addWidget(searchText); + filterLayout->setStretchFactor(searchText, 2); pageLayout->addLayout(filterLayout, 4, 0, 1, 2); @@ -94,7 +101,6 @@ BtnCreate = addButton(tr("Create"), pageLayout, 0, 2); BtnJoin = addButton(tr("Join"), pageLayout, 1, 2); - BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 2); BtnClear = addButton(tr("Clear"), pageLayout, 4, 2); // strech all but the buttons column @@ -136,22 +142,30 @@ connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); - connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); connect(BtnClear, SIGNAL(clicked()), this, SLOT(onClearClick())); connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); - connect(CBState, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); - connect(CBRules, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); - connect(CBWeapons, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); - connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onRefreshClick())); + connect(CBState, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged())); + connect(CBRules, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged())); + connect(CBWeapons, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged())); + connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onFilterChanged())); connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection); + + // sorting + connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), + this, SLOT(onSortIndicatorChanged(int, Qt::SortOrder))); } PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings) : - AbstractPage(parent) + AbstractPage(parent) { m_gameSettings = gameSettings; + roomsModel = NULL; + stateFilteredModel = NULL; + schemeFilteredModel = NULL; + weaponsFilteredModel = NULL; + initPage(); // not the most elegant solution but it works @@ -160,12 +174,11 @@ CBRules->addItem(ammoSchemeModel->predefSchemesNames.at(i).toAscii().constData()); CBWeapons->addItem(QComboBox::tr("Any")); - for (int i = 0; i < cDefaultAmmos.count(); i++) { + for (int i = 0; i < cDefaultAmmos.count(); i++) + { QPair ammo = cDefaultAmmos.at(i); CBWeapons->addItem(ammo.first.toAscii().constData()); } - - gameInLobby = false; } @@ -191,6 +204,7 @@ BtnAdmin->setVisible(flag); } +/* void PageRoomsList::setRoomsList(const QStringList & list) { QBrush red(QColor(255, 0, 0)); @@ -199,24 +213,17 @@ QBrush green(QColor(0, 255, 0)); listFromServer = list; - + QString selection = ""; - + if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0)) selection = item->text(); - + roomsList->clear(); roomsList->setColumnCount(7); roomsList->setHorizontalHeaderLabels( - QStringList() << - QTableWidget::tr("Room Name") << - QTableWidget::tr("C") << - QTableWidget::tr("T") << - QTableWidget::tr("Owner") << - QTableWidget::tr("Map") << - QTableWidget::tr("Rules") << - QTableWidget::tr("Weapons") - ); + + ); // set minimum sizes // roomsList->horizontalHeader()->resizeSection(0, 200); @@ -240,52 +247,79 @@ { // if we are joining a game // TODO: Should NOT be done here - if (gameInLobby) { - if (gameInLobbyName == list[i + 1]) { + if (gameInLobby) + { + if (gameInLobbyName == list[i + 1]) + { gameCanBeJoined = list[i].compare("True"); } } - + // check filter settings - #define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue - - if (list[i].compare("True") && CBState->currentIndex() == 2) { NO_FILTER_MATCH; } - if (list[i].compare("False") && CBState->currentIndex() == 1) { NO_FILTER_MATCH; } - if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText())) { NO_FILTER_MATCH; } - if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText())) { NO_FILTER_MATCH; } +#define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue + + if (list[i].compare("True") && CBState->currentIndex() == 2) + { + NO_FILTER_MATCH; + } + if (list[i].compare("False") && CBState->currentIndex() == 1) + { + NO_FILTER_MATCH; + } + if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText())) + { + NO_FILTER_MATCH; + } + if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText())) + { + NO_FILTER_MATCH; + } bool found = list[i + 1].contains(searchText->text(), Qt::CaseInsensitive); - if (!found) { - for (int a = 4; a <= 7; ++a) { + if (!found) + { + for (int a = 4; a <= 7; ++a) + { QString compString = list[i + a]; - if (a == 5 && compString == "+rnd+") { + if (a == 5 && compString == "+rnd+") + { compString = "Random Map"; - } else if (a == 5 && compString == "+maze+") { + } + else if (a == 5 && compString == "+maze+") + { compString = "Random Maze"; - } else if (a == 5 && compString == "+drawn+") { + } + else if (a == 5 && compString == "+drawn+") + { compString = "Drawn Map"; } - if (compString.contains(searchText->text(), Qt::CaseInsensitive)) { + if (compString.contains(searchText->text(), Qt::CaseInsensitive)) + { found = true; break; } } } - if (!searchText->text().isEmpty() && !found) { NO_FILTER_MATCH; } - + if (!searchText->text().isEmpty() && !found) + { + NO_FILTER_MATCH; + } + QTableWidgetItem * item; item = new QTableWidgetItem(list[i + 1]); // room name item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - + // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.) if(list[i].compare("True")) { item->setIcon(QIcon(":/res/iconTime.png"));// game is in lobby - item->setToolTip(tr("This game is in lobby.\nYou may join and start playing once the game starts.")); + item->setToolTip(tr("Waiting...")); + item->setWhatsThis(tr("This game is in lobby: you may join and start playing once the game starts.")); } else { item->setIcon(QIcon(":/res/iconDamage.png"));// game has started - item->setToolTip(tr("This game is in progress.\nYou may join and spectate now but you'll have to wait for the game to end to start playing.")); + item->setToolTip(tr("In progress...")); + item->setWhatsThis(tr("This game is in progress: you may join and spectate now but you'll have to wait for the game to end to start playing.")); } roomsList->setItem(r, 0, item); @@ -293,13 +327,13 @@ item = new QTableWidgetItem(list[i + 2]); // number of clients item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setTextAlignment(Qt::AlignCenter); - item->setToolTip(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2])); + item->setWhatsThis(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2])); roomsList->setItem(r, 1, item); item = new QTableWidgetItem(list[i + 3]); // number of teams item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setTextAlignment(Qt::AlignCenter); - item->setToolTip(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3])); + item->setWhatsThis(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3])); //Should we highlight "full" games? Might get misinterpreted //if(list[i + 3].toInt() >= cMaxTeams) // item->setForeground(red); @@ -307,7 +341,7 @@ item = new QTableWidgetItem(list[i + 4].left(15)); // name of host item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4])); + item->setWhatsThis(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4])); roomsList->setItem(r, 3, item); if(list[i + 5] == "+rnd+") @@ -325,7 +359,7 @@ else { item = new QTableWidgetItem(list[i + 5]); // selected map - + // check to see if we've got this map // not perfect but a start if(!mapList->contains(list[i + 5])) @@ -335,24 +369,24 @@ } else { - // todo: mission icon? + // todo: mission icon? // FIXME - need real icons. Disabling until then // item->setIcon(QIcon(":/res/mapCustom.png")); } } - + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("Games may be played on precreated or randomized maps.")); + item->setWhatsThis(tr("Games may be played on precreated or randomized maps.")); roomsList->setItem(r, 4, item); item = new QTableWidgetItem(list[i + 6].left(24)); // selected game scheme item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism.")); + item->setWhatsThis(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism.")); roomsList->setItem(r, 5, item); item = new QTableWidgetItem(list[i + 7].left(24)); // selected weapon scheme item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("The Weapon Scheme defines available weapons and their ammunition count.")); + item->setWhatsThis(tr("The Weapon Scheme defines available weapons and their ammunition count.")); roomsList->setItem(r, 6, item); if(!list[i + 1].compare(selection) && !selection.isEmpty()) @@ -368,54 +402,60 @@ roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents); // TODO: Should NOT be done here - if (gameInLobby) { + if (gameInLobby) + { gameInLobby = false; - if (gameCanBeJoined) { + if (gameCanBeJoined) + { emit askForJoinRoom(gameInLobbyName); - } else { + } + else + { emit askJoinConfirmation(gameInLobbyName); } } // roomsList->resizeColumnsToContents(); } +*/ void PageRoomsList::onCreateClick() { if (roomName->text().size()) emit askForCreateRoom(roomName->text()); else - QMessageBox::critical(this, - tr("Error"), - tr("Please enter room name"), - tr("OK")); + { + QMessageBox roomNameMsg(this); + roomNameMsg.setIcon(QMessageBox::Warning); + roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error")); + roomNameMsg.setText(QMessageBox::tr("Please enter room name")); + roomNameMsg.setWindowModality(Qt::WindowModal); + roomNameMsg.exec(); + } } void PageRoomsList::onJoinClick() { - QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); - if (!curritem) + QModelIndexList mdl = roomsList->selectionModel()->selectedRows(); + + if(mdl.size() != 1) { - QMessageBox::critical(this, - tr("Error"), - tr("Please select room from the list"), - tr("OK")); + QMessageBox roomNameMsg(this); + roomNameMsg.setIcon(QMessageBox::Warning); + roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error")); + roomNameMsg.setText(QMessageBox::tr("Please select room from the list")); + roomNameMsg.setWindowModality(Qt::WindowModal); + roomNameMsg.exec(); return; } - for (int i = 0; i < listFromServer.size(); i += 8) { - if (listFromServer[i + 1] == curritem->data(Qt::DisplayRole).toString()) { - gameInLobby = listFromServer[i].compare("True"); - break; - } - } - - if (gameInLobby) { - gameInLobbyName = curritem->data(Qt::DisplayRole).toString(); - emit askForRoomList(); - } else { - emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); - } + bool gameInLobby = roomsList->model()->index(mdl[0].row(), 0).data().toString().compare("True"); + QString roomName = roomsList->model()->index(mdl[0].row(), 1).data().toString(); + + if (!gameInLobby) + emit askJoinConfirmation(roomName); + else + emit askForJoinRoom(roomName); } void PageRoomsList::onRefreshClick() @@ -433,10 +473,15 @@ void PageRoomsList::onJoinConfirmation(const QString & room) { - if (QMessageBox::warning(this, - tr("Warning"), - tr("The game you are trying to join has started.\nDo you still want to join the room?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) + + QMessageBox reallyJoinMsg(this); + reallyJoinMsg.setIcon(QMessageBox::Question); + reallyJoinMsg.setWindowTitle(QMessageBox::tr("Room Name - Are you sure?")); + reallyJoinMsg.setText(QMessageBox::tr("The game you are trying to join has started.\nDo you still want to join the room?")); + reallyJoinMsg.setWindowModality(Qt::WindowModal); + reallyJoinMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + + if (reallyJoinMsg.exec() == QMessageBox::Ok) { emit askForJoinRoom(room); } @@ -451,3 +496,133 @@ { chatWidget->setUser(nickname); } + +void PageRoomsList::setModel(RoomsListModel * model) +{ + // filter chain: + // model -> stateFilteredModel -> schemeFilteredModel -> + // -> weaponsFilteredModel -> roomsModel (search filter+sorting) + + if (roomsModel == NULL) + { + roomsModel = new QSortFilterProxyModel(this); + roomsModel->setDynamicSortFilter(true); + roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive); + roomsModel->sort(RoomsListModel::StateColumn, Qt::AscendingOrder); + + stateFilteredModel = new QSortFilterProxyModel(this); + schemeFilteredModel = new QSortFilterProxyModel(this); + weaponsFilteredModel = new QSortFilterProxyModel(this); + + stateFilteredModel->setDynamicSortFilter(true); + schemeFilteredModel->setDynamicSortFilter(true); + weaponsFilteredModel->setDynamicSortFilter(true); + + roomsModel->setFilterKeyColumn(-1); // search in all columns + stateFilteredModel->setFilterKeyColumn(RoomsListModel::StateColumn); + schemeFilteredModel->setFilterKeyColumn(RoomsListModel::SchemeColumn); + weaponsFilteredModel->setFilterKeyColumn(RoomsListModel::WeaponsColumn); + + roomsModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + schemeFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + weaponsFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + + schemeFilteredModel->setSourceModel(stateFilteredModel); + weaponsFilteredModel->setSourceModel(schemeFilteredModel); + roomsModel->setSourceModel(weaponsFilteredModel); + + // let the table view display the last model in the filter chain + roomsList->setModel(roomsModel); + } + + stateFilteredModel->setSourceModel(model); + + roomsList->hideColumn(RoomsListModel::StateColumn); + + QHeaderView * h = roomsList->horizontalHeader(); + + h->setSortIndicatorShown(true); + h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder); + h->setResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch); + + if (!restoreHeaderState()) + { + h->resizeSection(RoomsListModel::PlayerCountColumn, 32); + h->resizeSection(RoomsListModel::TeamCountColumn, 32); + h->resizeSection(RoomsListModel::OwnerColumn, 100); + h->resizeSection(RoomsListModel::MapColumn, 100); + h->resizeSection(RoomsListModel::SchemeColumn, 100); + h->resizeSection(RoomsListModel::WeaponsColumn, 100); + } + + + // save header state on change + connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), + this, SLOT(saveHeaderState())); + connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), + this, SLOT(saveHeaderState())); +} + + +void PageRoomsList::onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order) +{ + if (roomsModel == NULL) + return; + + if (logicalIndex == 0) + { + roomsModel->sort(0, Qt::AscendingOrder); + return; + } + + // three state sorting: asc -> dsc -> default (by room state) + if ((order == Qt::AscendingOrder) && (logicalIndex == roomsModel->sortColumn())) + roomsList->horizontalHeader()->setSortIndicator( + RoomsListModel::StateColumn, Qt::AscendingOrder); + else + roomsModel->sort(logicalIndex, order); +} + + +void PageRoomsList::onFilterChanged() +{ + if (roomsModel == NULL) + return; + + roomsModel->setFilterWildcard(QString("*%1*").arg(searchText->text())); + + int stateIdx = CBState->currentIndex(); + // any = 0, in lobby/false = 1, in progress/true = 2 + + if (stateIdx == 0) + stateFilteredModel->setFilterWildcard("*"); // "any" + else + stateFilteredModel->setFilterFixedString(QString(stateIdx == 2)); + + if (CBRules->currentIndex() == 0) + schemeFilteredModel->setFilterWildcard("*"); // "any" + else + schemeFilteredModel->setFilterWildcard( + QString("*%1*").arg(CBRules->currentText())); + + if (CBWeapons->currentIndex() == 0) + weaponsFilteredModel->setFilterWildcard("*"); // "any" + else + weaponsFilteredModel->setFilterWildcard( + QString("*%1*").arg(CBWeapons->currentText())); +} + + +bool PageRoomsList::restoreHeaderState() +{ + if (!m_gameSettings->contains("frontend/roomslist_header")) + return false; + return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64( + (m_gameSettings->value("frontend/roomslist_header").toString().toAscii()))); +} + +void PageRoomsList::saveHeaderState() +{ + m_gameSettings->setValue("frontend/roomslist_header", + QString(roomsList->horizontalHeader()->saveState().toBase64())); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageroomslist.h --- a/QTfrontend/ui/page/pageroomslist.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageroomslist.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,63 +23,71 @@ class HWChatWidget; class AmmoSchemeModel; +class QTableView; +class RoomsListModel; +class QSortFilterProxyModel; class PageRoomsList : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageRoomsList(QWidget* parent, QSettings * config); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); + public: + PageRoomsList(QWidget* parent, QSettings * config); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); - QLineEdit * roomName; - QLineEdit * searchText; - QTableWidget * roomsList; - QPushButton * BtnCreate; - QPushButton * BtnJoin; - QPushButton * BtnRefresh; - QPushButton * BtnAdmin; - QPushButton * BtnClear; - QComboBox * CBState; - QComboBox * CBRules; - QComboBox * CBWeapons; - HWChatWidget * chatWidget; - QLabel * lblCount; + QLineEdit * roomName; + QLineEdit * searchText; + QTableView * roomsList; + QPushButton * BtnCreate; + QPushButton * BtnJoin; + QPushButton * BtnAdmin; + QPushButton * BtnClear; + QComboBox * CBState; + QComboBox * CBRules; + QComboBox * CBWeapons; + HWChatWidget * chatWidget; + QLabel * lblCount; + + void setModel(RoomsListModel * model); + + public slots: + void setAdmin(bool); + void setUser(const QString & nickname); + void updateNickCounter(int cnt); -public slots: - void setAdmin(bool); - void setRoomsList(const QStringList & list); - void setUser(const QString & nickname); - void updateNickCounter(int cnt); + signals: + void askForCreateRoom(const QString &); + void askForJoinRoom(const QString &); + void askForRoomList(); + void askJoinConfirmation(const QString &); -signals: - void askForCreateRoom(const QString &); - void askForJoinRoom(const QString &); - void askForRoomList(); - void askJoinConfirmation(const QString &); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private slots: + void onCreateClick(); + void onJoinClick(); + void onRefreshClick(); + void onClearClick(); + void onJoinConfirmation(const QString &); + void onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order); + void onFilterChanged(); + void saveHeaderState(); -private slots: - void onCreateClick(); - void onJoinClick(); - void onRefreshClick(); - void onClearClick(); - void onJoinConfirmation(const QString &); + private: + QSettings * m_gameSettings; + QSortFilterProxyModel * roomsModel; + QSortFilterProxyModel * stateFilteredModel; + QSortFilterProxyModel * schemeFilteredModel; + QSortFilterProxyModel * weaponsFilteredModel; -private: - QSettings * m_gameSettings; + AmmoSchemeModel * ammoSchemeModel; - bool gameInLobby; - QString gameInLobbyName; - QStringList listFromServer; - AmmoSchemeModel * ammoSchemeModel; - + bool restoreHeaderState(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagescheme.cpp --- a/QTfrontend/ui/page/pagescheme.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagescheme.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,11 +50,11 @@ // TODO name stuff and put CSS into main style sheet gbGameModes->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); + "background-color: #130f2c; background-image:url();" + "}"); gbBasicSettings->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); + "background-color: #130f2c; background-image:url();" + "}"); gbGameModes->setSizePolicy(sp); gbBasicSettings->setSizePolicy(sp); @@ -68,103 +68,128 @@ // Left TBW_mode_Forts = new ToggleButtonWidget(gbGameModes, ":/res/btnForts@2x.png"); - TBW_mode_Forts->setToolTip("" + ToggleButtonWidget::tr("Fort Mode") + ":
" + tr("Defend your fort and destroy the opponents, two team colours max!")); + TBW_mode_Forts->setToolTip("" + ToggleButtonWidget::tr("Fort Mode") + ""); + TBW_mode_Forts->setWhatsThis(tr("Defend your fort and destroy the opponents, two team colours max!")); glGMLayout->addWidget(TBW_mode_Forts,0,0,1,1); TBW_teamsDivide = new ToggleButtonWidget(gbGameModes, ":/res/btnTeamsDivide@2x.png"); - TBW_teamsDivide->setToolTip("" + ToggleButtonWidget::tr("Divide Teams") + ":
" + tr("Teams will start on opposite sides of the terrain, two team colours max!")); + TBW_teamsDivide->setToolTip("" + ToggleButtonWidget::tr("Divide Teams") + ""); + TBW_teamsDivide->setWhatsThis(tr("Teams will start on opposite sides of the terrain, two team colours max!")); glGMLayout->addWidget(TBW_teamsDivide,0,1,1,1); TBW_solid = new ToggleButtonWidget(gbGameModes, ":/res/btnSolid@2x.png"); - TBW_solid->setToolTip("" + ToggleButtonWidget::tr("Solid Land") + ":
" + tr("Land can not be destroyed!")); + TBW_solid->setToolTip("" + ToggleButtonWidget::tr("Solid Land") + ""); + TBW_solid->setWhatsThis(tr("Land can not be destroyed!")); glGMLayout->addWidget(TBW_solid,0,2,1,1); TBW_border = new ToggleButtonWidget(gbGameModes, ":/res/btnBorder@2x.png"); - TBW_border->setToolTip("" + ToggleButtonWidget::tr("Add Border") + ":
" + tr("Add an indestructible border around the terrain")); + TBW_border->setToolTip("" + ToggleButtonWidget::tr("Add Border") + ""); + TBW_border->setWhatsThis(tr("Add an indestructible border around the terrain")); glGMLayout->addWidget(TBW_border,0,3,1,1); TBW_lowGravity = new ToggleButtonWidget(gbGameModes, ":/res/btnLowGravity@2x.png"); - TBW_lowGravity->setToolTip("" + ToggleButtonWidget::tr("Low Gravity") + ":
" + tr("Lower gravity")); + TBW_lowGravity->setToolTip("" + ToggleButtonWidget::tr("Low Gravity") + ""); + TBW_lowGravity->setWhatsThis(tr("Lower gravity")); glGMLayout->addWidget(TBW_lowGravity,0,4,1,1); TBW_laserSight = new ToggleButtonWidget(gbGameModes, ":/res/btnLaserSight@2x.png"); - TBW_laserSight->setToolTip("" + ToggleButtonWidget::tr("Laser Sight") + ":
" + tr("Assisted aiming with laser sight")); + TBW_laserSight->setToolTip("" + ToggleButtonWidget::tr("Laser Sight") + ""); + TBW_laserSight->setWhatsThis(tr("Assisted aiming with laser sight")); glGMLayout->addWidget(TBW_laserSight,1,0,1,1); TBW_invulnerable = new ToggleButtonWidget(gbGameModes, ":/res/btnInvulnerable@2x.png"); - TBW_invulnerable->setToolTip("" + ToggleButtonWidget::tr("Invulnerable") + ":
" + tr("All hogs have a personal forcefield")); + TBW_invulnerable->setToolTip("" + ToggleButtonWidget::tr("Invulnerable") + ""); + TBW_invulnerable->setWhatsThis(tr("All hogs have a personal forcefield")); glGMLayout->addWidget(TBW_invulnerable,1,1,1,1); TBW_resethealth = new ToggleButtonWidget(gbGameModes, ":/res/btnResetHealth@2x.png"); - TBW_resethealth->setToolTip("" + ToggleButtonWidget::tr("Reset Health") + ":
" + tr("All (living) hedgehogs are fully restored at the end of turn")); + TBW_resethealth->setToolTip("" + ToggleButtonWidget::tr("Reset Health") + ""); + TBW_resethealth->setWhatsThis(tr("All (living) hedgehogs are fully restored at the end of turn")); glGMLayout->addWidget(TBW_resethealth,1,2,1,1); TBW_vampiric = new ToggleButtonWidget(gbGameModes, ":/res/btnVampiric@2x.png"); - TBW_vampiric->setToolTip("" + ToggleButtonWidget::tr("Vampirism") + ":
" + tr("Gain 80% of the damage you do back in health")); + TBW_vampiric->setToolTip("" + ToggleButtonWidget::tr("Vampirism") + ""); + TBW_vampiric->setWhatsThis(tr("Gain 80% of the damage you do back in health")); glGMLayout->addWidget(TBW_vampiric,1,3,1,1); TBW_karma = new ToggleButtonWidget(gbGameModes, ":/res/btnKarma@2x.png"); - TBW_karma->setToolTip("" + ToggleButtonWidget::tr("Karma") + ":
" + tr("Share your opponents pain, share their damage")); + TBW_karma->setToolTip("" + ToggleButtonWidget::tr("Karma") + ""); + TBW_karma->setWhatsThis(tr("Share your opponents pain, share their damage")); glGMLayout->addWidget(TBW_karma,1,4,1,1); TBW_artillery = new ToggleButtonWidget(gbGameModes, ":/res/btnArtillery@2x.png"); - TBW_artillery->setToolTip("" + ToggleButtonWidget::tr("Artillery") + ":
" + tr("Your hogs are unable to move, put your artillery skills to the test")); + TBW_artillery->setToolTip("" + ToggleButtonWidget::tr("Artillery") + ""); + TBW_artillery->setWhatsThis(tr("Your hogs are unable to move, put your artillery skills to the test")); glGMLayout->addWidget(TBW_artillery,2,0,1,1); TBW_randomorder = new ToggleButtonWidget(gbGameModes, ":/res/btnRandomOrder@2x.png"); - TBW_randomorder->setToolTip("" + ToggleButtonWidget::tr("Random Order") + ":
" + tr("Order of play is random instead of in room order.")); + TBW_randomorder->setToolTip("" + ToggleButtonWidget::tr("Random Order") + ""); + TBW_randomorder->setWhatsThis(tr("Order of play is random instead of in room order.")); glGMLayout->addWidget(TBW_randomorder,2,1,1,1); TBW_king = new ToggleButtonWidget(gbGameModes, ":/res/btnKing@2x.png"); - TBW_king->setToolTip("" + ToggleButtonWidget::tr("King") + ":
" + tr("Play with a King. If he dies, your side dies.")); + TBW_king->setToolTip("" + ToggleButtonWidget::tr("King") + ""); + TBW_king->setWhatsThis(tr("Play with a King. If he dies, your side dies.")); glGMLayout->addWidget(TBW_king,2,2,1,1); TBW_placehog = new ToggleButtonWidget(gbGameModes, ":/res/btnPlaceHog@2x.png"); - TBW_placehog->setToolTip("" + ToggleButtonWidget::tr("Place Hedgehogs") + ":
" + tr("Take turns placing your hedgehogs before the start of play.")); + TBW_placehog->setToolTip("" + ToggleButtonWidget::tr("Place Hedgehogs") + ""); + TBW_placehog->setWhatsThis(tr("Take turns placing your hedgehogs before the start of play.")); glGMLayout->addWidget(TBW_placehog,2,3,1,1); TBW_sharedammo = new ToggleButtonWidget(gbGameModes, ":/res/btnSharedAmmo@2x.png"); - TBW_sharedammo->setToolTip("" + ToggleButtonWidget::tr("Clan Shares Ammo") + ":
" + tr("Ammo is shared between all teams that share a colour.")); + TBW_sharedammo->setToolTip("" + ToggleButtonWidget::tr("Clan Shares Ammo") + ""); + TBW_sharedammo->setWhatsThis(tr("Ammo is shared between all teams that share a colour.")); glGMLayout->addWidget(TBW_sharedammo,2,4,1,1); TBW_disablegirders = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableGirders@2x.png"); - TBW_disablegirders->setToolTip("" + ToggleButtonWidget::tr("Disable Girders") + ":
" + tr("Disable girders when generating random maps.")); + TBW_disablegirders->setToolTip("" + ToggleButtonWidget::tr("Disable Girders") + ""); + TBW_disablegirders->setWhatsThis(tr("Disable girders when generating random maps.")); glGMLayout->addWidget(TBW_disablegirders,3,0,1,1); TBW_disablelandobjects = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableLandObjects@2x.png"); - TBW_disablelandobjects->setToolTip("" + ToggleButtonWidget::tr("Disable Land Objects") + ":
" + tr("Disable land objects when generating random maps.")); + TBW_disablelandobjects->setToolTip("" + ToggleButtonWidget::tr("Disable Land Objects") + ""); + TBW_disablelandobjects->setWhatsThis(tr("Disable land objects when generating random maps.")); glGMLayout->addWidget(TBW_disablelandobjects,3,1,1,1); TBW_aisurvival = new ToggleButtonWidget(gbGameModes, ":/res/btnAISurvival@2x.png"); - TBW_aisurvival->setToolTip("" + ToggleButtonWidget::tr("AI Survival Mode") + ":
" + tr("AI respawns on death.")); + TBW_aisurvival->setToolTip("" + ToggleButtonWidget::tr("AI Survival Mode") + ""); + TBW_aisurvival->setWhatsThis(tr("AI respawns on death.")); glGMLayout->addWidget(TBW_aisurvival,3,2,1,1); TBW_infattack = new ToggleButtonWidget(gbGameModes, ":/res/btnInfAttack@2x.png"); - TBW_infattack->setToolTip("" + ToggleButtonWidget::tr("Unlimited Attacks") + ":
" + tr("Attacking does not end your turn.")); + TBW_infattack->setToolTip("" + ToggleButtonWidget::tr("Unlimited Attacks") + ""); + TBW_infattack->setWhatsThis(tr("Attacking does not end your turn.")); glGMLayout->addWidget(TBW_infattack,3,3,1,1); TBW_resetweps = new ToggleButtonWidget(gbGameModes, ":/res/btnResetWeps@2x.png"); - TBW_resetweps->setToolTip("" + ToggleButtonWidget::tr("Reset Weapons") + ":
" + tr("Weapons are reset to starting values each turn.")); + TBW_resetweps->setToolTip("" + ToggleButtonWidget::tr("Reset Weapons") + ""); + TBW_resetweps->setWhatsThis(tr("Weapons are reset to starting values each turn.")); glGMLayout->addWidget(TBW_resetweps,3,4,1,1); TBW_perhogammo = new ToggleButtonWidget(gbGameModes, ":/res/btnPerHogAmmo@2x.png"); - TBW_perhogammo->setToolTip("" + ToggleButtonWidget::tr("Per Hedgehog Ammo") + ":
" + tr("Each hedgehog has its own ammo. It does not share with the team.")); + TBW_perhogammo->setToolTip("" + ToggleButtonWidget::tr("Per Hedgehog Ammo") + ""); + TBW_perhogammo->setWhatsThis(tr("Each hedgehog has its own ammo. It does not share with the team.")); glGMLayout->addWidget(TBW_perhogammo,4,0,1,1); TBW_nowind = new ToggleButtonWidget(gbGameModes, ":/res/btnNoWind@2x.png"); - TBW_nowind->setToolTip("" + ToggleButtonWidget::tr("Disable Wind") + ":
" + tr("You will not have to worry about wind anymore.")); + TBW_nowind->setToolTip("" + ToggleButtonWidget::tr("Disable Wind") + ""); + TBW_nowind->setWhatsThis(tr("You will not have to worry about wind anymore.")); glGMLayout->addWidget(TBW_nowind,4,1,1,1); TBW_morewind = new ToggleButtonWidget(gbGameModes, ":/res/btnMoreWind@2x.png"); - TBW_morewind->setToolTip("" + ToggleButtonWidget::tr("More Wind") + ":
" + tr("Wind will affect almost everything.")); + TBW_morewind->setToolTip("" + ToggleButtonWidget::tr("More Wind") + ""); + TBW_morewind->setWhatsThis(tr("Wind will affect almost everything.")); glGMLayout->addWidget(TBW_morewind,4,2,1,1); TBW_tagteam = new ToggleButtonWidget(gbGameModes, ":/res/btnTagTeam@2x.png"); - TBW_tagteam->setToolTip("" + ToggleButtonWidget::tr("Tag Team") + ":
" + tr("Teams in each clan take successive turns sharing their turn time.")); + TBW_tagteam->setToolTip("" + ToggleButtonWidget::tr("Tag Team") + ""); + TBW_tagteam->setWhatsThis(tr("Teams in each clan take successive turns sharing their turn time.")); glGMLayout->addWidget(TBW_tagteam,4,3,1,1); TBW_bottomborder = new ToggleButtonWidget(gbGameModes, ":/res/btnBottomBorder@2x.png"); - TBW_bottomborder->setToolTip("" + ToggleButtonWidget::tr("Add Bottom Border") + ":
" + tr("Add an indestructible border along the bottom")); + TBW_bottomborder->setToolTip("" + ToggleButtonWidget::tr("Add Bottom Border") + ""); + TBW_bottomborder->setWhatsThis(tr("Add an indestructible border along the bottom")); glGMLayout->addWidget(TBW_bottomborder,4,4,1,1); @@ -381,7 +406,7 @@ SB_GetAwayTime->setValue(100); SB_GetAwayTime->setSingleStep(25); glBSLayout->addWidget(SB_GetAwayTime,14,2,1,1); - + l = new QLabel(gbBasicSettings); l->setText(QLabel::tr("Scheme Name:")); @@ -470,7 +495,7 @@ mapper->addMapping(SB_WaterRise, 37); mapper->addMapping(SB_HealthDecrease, 38); mapper->addMapping(SB_RopeModifier, 39); - mapper->addMapping(SB_GetAwayTime, 40); + mapper->addMapping(SB_GetAwayTime, 40); mapper->toFirst(); } @@ -491,11 +516,30 @@ void PageScheme::deleteRow() { - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel); + int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes; + if (selectScheme->currentIndex() < numberOfDefaultSchemes) + { + QMessageBox deniedMsg(this); + deniedMsg.setIcon(QMessageBox::Warning); + deniedMsg.setWindowTitle(QMessageBox::tr("Schemes - Warning")); + deniedMsg.setText(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText())); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + } + else + { + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Schemes - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the game scheme '%1'?").arg(selectScheme->currentText())); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) { - QAbstractItemModel * model = mapper->model(); - model->removeRow(selectScheme->currentIndex()); + if (reallyDeleteMsg.exec() == QMessageBox::Ok) + { + QAbstractItemModel * model = mapper->model(); + model->removeRow(selectScheme->currentIndex()); + } } } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagescheme.h --- a/QTfrontend/ui/page/pagescheme.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagescheme.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,79 +26,78 @@ class PageScheme : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageScheme(QWidget* parent = 0); + public: + PageScheme(QWidget* parent = 0); - QPushButton * BtnCopy; - QPushButton * BtnNew; - QPushButton * BtnDelete; - QPushButton * btnSave; - QComboBox * selectScheme; + QPushButton * BtnCopy; + QPushButton * BtnNew; + QPushButton * BtnDelete; + QComboBox * selectScheme; - void setModel(QAbstractItemModel * model); + void setModel(QAbstractItemModel * model); -public slots: - void newRow(); - void copyRow(); - void deleteRow(); + public slots: + void newRow(); + void copyRow(); + void deleteRow(); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private: - QDataWidgetMapper * mapper; - ToggleButtonWidget * TBW_mode_Forts; - ToggleButtonWidget * TBW_teamsDivide; - ToggleButtonWidget * TBW_solid; - ToggleButtonWidget * TBW_border; - ToggleButtonWidget * TBW_lowGravity; - ToggleButtonWidget * TBW_laserSight; - ToggleButtonWidget * TBW_invulnerable; - ToggleButtonWidget * TBW_resethealth; - ToggleButtonWidget * TBW_vampiric; - ToggleButtonWidget * TBW_karma; - ToggleButtonWidget * TBW_artillery; - ToggleButtonWidget * TBW_randomorder; - ToggleButtonWidget * TBW_king; - ToggleButtonWidget * TBW_placehog; - ToggleButtonWidget * TBW_sharedammo; - ToggleButtonWidget * TBW_disablegirders; - ToggleButtonWidget * TBW_disablelandobjects; - ToggleButtonWidget * TBW_aisurvival; - ToggleButtonWidget * TBW_infattack; - ToggleButtonWidget * TBW_resetweps; - ToggleButtonWidget * TBW_perhogammo; - ToggleButtonWidget * TBW_nowind; - ToggleButtonWidget * TBW_morewind; - ToggleButtonWidget * TBW_tagteam; - ToggleButtonWidget * TBW_bottomborder; + private: + QDataWidgetMapper * mapper; + ToggleButtonWidget * TBW_mode_Forts; + ToggleButtonWidget * TBW_teamsDivide; + ToggleButtonWidget * TBW_solid; + ToggleButtonWidget * TBW_border; + ToggleButtonWidget * TBW_lowGravity; + ToggleButtonWidget * TBW_laserSight; + ToggleButtonWidget * TBW_invulnerable; + ToggleButtonWidget * TBW_resethealth; + ToggleButtonWidget * TBW_vampiric; + ToggleButtonWidget * TBW_karma; + ToggleButtonWidget * TBW_artillery; + ToggleButtonWidget * TBW_randomorder; + ToggleButtonWidget * TBW_king; + ToggleButtonWidget * TBW_placehog; + ToggleButtonWidget * TBW_sharedammo; + ToggleButtonWidget * TBW_disablegirders; + ToggleButtonWidget * TBW_disablelandobjects; + ToggleButtonWidget * TBW_aisurvival; + ToggleButtonWidget * TBW_infattack; + ToggleButtonWidget * TBW_resetweps; + ToggleButtonWidget * TBW_perhogammo; + ToggleButtonWidget * TBW_nowind; + ToggleButtonWidget * TBW_morewind; + ToggleButtonWidget * TBW_tagteam; + ToggleButtonWidget * TBW_bottomborder; - QSpinBox * SB_DamageModifier; - QSpinBox * SB_TurnTime; - QSpinBox * SB_InitHealth; - QSpinBox * SB_SuddenDeath; - QSpinBox * SB_WaterRise; - QSpinBox * SB_HealthDecrease; - FreqSpinBox * SB_CaseProb; - QSpinBox * SB_HealthCrates; - QSpinBox * SB_CrateHealth; - QSpinBox * SB_MinesTime; - QSpinBox * SB_Mines; - QSpinBox * SB_MineDuds; - QSpinBox * SB_Explosives; - QSpinBox * SB_RopeModifier; - QSpinBox * SB_GetAwayTime; - QLineEdit * LE_name; + QSpinBox * SB_DamageModifier; + QSpinBox * SB_TurnTime; + QSpinBox * SB_InitHealth; + QSpinBox * SB_SuddenDeath; + QSpinBox * SB_WaterRise; + QSpinBox * SB_HealthDecrease; + FreqSpinBox * SB_CaseProb; + QSpinBox * SB_HealthCrates; + QSpinBox * SB_CrateHealth; + QSpinBox * SB_MinesTime; + QSpinBox * SB_Mines; + QSpinBox * SB_MineDuds; + QSpinBox * SB_Explosives; + QSpinBox * SB_RopeModifier; + QSpinBox * SB_GetAwayTime; + QLineEdit * LE_name; - QGroupBox * gbGameModes; - QGroupBox * gbBasicSettings; + QGroupBox * gbGameModes; + QGroupBox * gbBasicSettings; -private slots: - void schemeSelected(int); + private slots: + void schemeSelected(int); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageselectweapon.cpp --- a/QTfrontend/ui/page/pageselectweapon.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageselectweapon.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,17 +53,13 @@ bottomLayout->setColumnStretch(1,1); bottomLayout->setColumnStretch(2,1); - btnSave = addButton(":/res/Save.png", bottomLayout, 0, 3, 2, 1, true); - btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); - bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom); - return bottomLayout; } void PageSelectWeapon::connectSignals() { connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault())); - connect(btnSave, SIGNAL(clicked()), pWeapons, SLOT(save())); + connect(this, SIGNAL(goBack()), pWeapons, SLOT(save())); connect(BtnNew, SIGNAL(clicked()), pWeapons, SLOT(newWeaponsName())); connect(BtnCopy, SIGNAL(clicked()), pWeapons, SLOT(copy())); connect(selectWeaponSet, SIGNAL(currentIndexChanged(const QString&)), pWeapons, SLOT(setWeaponsName(const QString&))); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pageselectweapon.h --- a/QTfrontend/ui/page/pageselectweapon.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pageselectweapon.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,23 +25,22 @@ class PageSelectWeapon : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageSelectWeapon(QWidget* parent = 0); + public: + PageSelectWeapon(QWidget* parent = 0); - QPushButton *btnSave; - QPushButton *BtnDefault; - QPushButton *BtnDelete; - QPushButton *BtnNew; - QPushButton *BtnCopy; - SelWeaponWidget* pWeapons; - QComboBox* selectWeaponSet; + QPushButton *BtnDefault; + QPushButton *BtnDelete; + QPushButton *BtnNew; + QPushButton *BtnCopy; + SelWeaponWidget* pWeapons; + QComboBox* selectWeaponSet; -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagesingleplayer.cpp --- a/QTfrontend/ui/page/pagesingleplayer.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagesingleplayer.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,19 +36,23 @@ topLine->addStretch(); BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true); - BtnSimpleGamePage->setToolTip(tr("Simple Game (a quick game against the computer, settings are chosen for you)")); + BtnSimpleGamePage->setToolTip(tr("Simple Game")); + BtnSimpleGamePage->setWhatsThis(tr("Play a quick game against the computer with random settings")); topLine->addSpacing(60); BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true); - BtnMultiplayer->setToolTip(tr("Multiplayer (play a hotseat game against your friends, or AI teams)")); + BtnMultiplayer->setToolTip(tr("Multiplayer")); + BtnMultiplayer->setWhatsThis(tr("Play a hotseat game against your friends, or AI teams")); topLine->addStretch(); BtnCampaignPage = addButton(":/res/Campaign.png", middleLine, 0, true); - BtnCampaignPage->setToolTip(tr("Campaign Mode (...)")); - BtnCampaignPage->setVisible(false); + BtnCampaignPage->setToolTip(tr("Campaign Mode")); + BtnCampaignPage->setWhatsThis(tr("Campaign Mode")); + BtnCampaignPage->setVisible(true); BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true); - BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions)")); + BtnTrainPage->setToolTip(tr("Training Mode")); + BtnTrainPage->setWhatsThis(tr("Practice your skills in a range of training missions")); return vLayout; } @@ -59,10 +63,12 @@ bottomLine->addStretch(); BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); - BtnDemos->setToolTip(tr("Demos (Watch recorded demos)")); + BtnDemos->setToolTip(tr("Demos")); + BtnDemos->setWhatsThis(tr("Watch recorded demos")); BtnLoad = addButton(":/res/Load.png", bottomLine, 2, true); BtnLoad->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); - BtnLoad->setToolTip(tr("Load (Load a previously saved game)")); + BtnLoad->setToolTip(tr("Load")); + BtnLoad->setWhatsThis(tr("Load a previously saved game")); bottomLine->setStretch(1,0); bottomLine->setStretch(2,0); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagesingleplayer.h --- a/QTfrontend/ui/page/pagesingleplayer.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagesingleplayer.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,23 +25,23 @@ class PageSinglePlayer : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageSinglePlayer(QWidget* parent = 0); + public: + PageSinglePlayer(QWidget* parent = 0); - QPushButton *BtnSimpleGamePage; - QPushButton *BtnTrainPage; - QPushButton *BtnCampaignPage; - QPushButton *BtnMultiplayer; - QPushButton *BtnLoad; - QPushButton *BtnDemos; - GameCFGWidget *gameCFG; + QPushButton *BtnSimpleGamePage; + QPushButton *BtnTrainPage; + QPushButton *BtnCampaignPage; + QPushButton *BtnMultiplayer; + QPushButton *BtnLoad; + QPushButton *BtnDemos; + GameCFGWidget *gameCFG; -private: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + private: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); }; #endif diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagetraining.cpp --- a/QTfrontend/ui/page/pagetraining.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagetraining.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ #include #include "hwconsts.h" -#include "HWDataManager.h" +#include "DataManager.h" #include "pagetraining.h" @@ -40,7 +40,6 @@ // declare start button, caption and description btnPreview = formattedButton(":/res/Trainings.png", true); - btnPreview->setToolTip(QPushButton::tr("Go!")); // make both rows equal height pageLayout->setRowStretch(0, 1); @@ -76,6 +75,7 @@ // mission list lstMissions = new QListWidget(this); + lstMissions->setWhatsThis(tr("Pick the mission or training to play")); pageLayout->addWidget(lstMissions, 1, 0, 1, 2); // span 2 columns // let's not make the list use more space than needed @@ -90,6 +90,7 @@ QBoxLayout * bottomLayout = new QVBoxLayout(); btnStart = formattedButton(QPushButton::tr("Go!")); + btnStart->setWhatsThis(tr("Start fighting")); btnStart->setFixedWidth(140); bottomLayout->addWidget(btnStart); @@ -114,7 +115,7 @@ { initPage(); - HWDataManager & dataMgr = HWDataManager::instance(); + DataManager & dataMgr = DataManager::instance(); // get locale QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", @@ -125,12 +126,12 @@ loc = QLocale::system().name(); QString infoFile = dataMgr.findFileForRead( - QString("Locale/missions_" + loc + ".txt")); + QString("Locale/missions_" + loc + ".txt")); // if file is non-existant try with language only if (!QFile::exists(infoFile)) infoFile = dataMgr.findFileForRead(QString( - "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt")); + "Locale/missions_" + loc.remove(QRegExp("_.*$")) + ".txt")); // fallback if file for current locale is non-existant if (!QFile::exists(infoFile)) @@ -145,7 +146,7 @@ QStringList missionList = dataMgr.entryList( "Missions/Training", QDir::Files, QStringList("*.lua")). - replaceInStrings(QRegExp("\\.lua$"), ""); + replaceInStrings(QRegExp("\\.lua$"), ""); // scripts to lost - TODO: model? foreach (const QString & mission, missionList) @@ -185,15 +186,15 @@ void PageTraining::updateInfo() { - HWDataManager & dataMgr = HWDataManager::instance(); + DataManager & dataMgr = DataManager::instance(); if (lstMissions->currentItem()) { // TODO also use .pngs in userdata folder QString thumbFile = dataMgr.findFileForRead( - "Graphics/Missions/Training/" + - lstMissions->currentItem()->data(Qt::UserRole).toString() + - "@2x.png"); + "Graphics/Missions/Training/" + + lstMissions->currentItem()->data(Qt::UserRole).toString() + + "@2x.png"); if (QFile::exists(thumbFile)) btnPreview->setIcon(QIcon(thumbFile)); @@ -201,13 +202,13 @@ btnPreview->setIcon(QIcon(":/res/Trainings.png")); QString realName = lstMissions->currentItem()->data( - Qt::UserRole).toString(); + Qt::UserRole).toString(); - QString caption = m_info->value(realName + ".name", - lstMissions->currentItem()->text()).toString(); + QString caption = m_info->value(realName + ".name", + lstMissions->currentItem()->text()).toString(); QString description = m_info->value(realName + ".desc", - tr("No description available")).toString(); + tr("No description available")).toString(); lblCaption->setText("

" + caption +"

"); lblDescription->setText(description); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagetraining.h --- a/QTfrontend/ui/page/pagetraining.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/page/pagetraining.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,34 +23,34 @@ class PageTraining : public AbstractPage { - Q_OBJECT + Q_OBJECT -public: - PageTraining(QWidget* parent = 0); + public: + PageTraining(QWidget* parent = 0); -signals: - void startMission(const QString & scriptName); + signals: + void startMission(const QString & scriptName); -protected: - QLayout * bodyLayoutDefinition(); - QLayout * footerLayoutDefinition(); - void connectSignals(); + protected: + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); -private: - QPushButton * btnPreview; - QPushButton * btnStart; - QLabel * lblCaption; - QLabel * lblDescription; - QListWidget * lstMissions; - QSettings * m_info; + private: + QPushButton * btnPreview; + QPushButton * btnStart; + QLabel * lblCaption; + QLabel * lblDescription; + QListWidget * lstMissions; + QSettings * m_info; -private slots: - void startSelected(); - void updateInfo(); + private slots: + void startSelected(); + void updateInfo(); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagevideos.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/page/pagevideos.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1160 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hwconsts.h" +#include "pagevideos.h" +#include "igbox.h" +#include "libav_iteraction.h" +#include "gameuiconfig.h" +#include "recorder.h" +#include "ask_quit.h" +#include "upload_video.h" + +static const QSize ThumbnailSize(350, 350*3/5); + +// columns in table with list of video files +enum VideosColumns +{ + vcName, + vcSize, + vcProgress, // either encoding or uploading + + vcNumColumns, +}; + +// this class is used for items in first column in file-table +class VideoItem : public QTableWidgetItem +{ + // note: QTableWidgetItem is not Q_OBJECT + + public: + VideoItem(const QString& name); + ~VideoItem(); + + QString name; + QString prefix; // original filename without extension + QString desc; // description (duration, resolution, etc...) + QString uploadUrl; // http://youtu.be/??????? + HWRecorder * pRecorder; // non NULL if file is being encoded + QNetworkReply * pUploading; // non NULL if file is being uploaded + bool seen; // used when updating directory + float lastSizeUpdate; + float progress; + + bool ready() + { return !pRecorder; } + + QString path() + { return cfgdir->absoluteFilePath("Videos/" + name); } +}; + +VideoItem::VideoItem(const QString& name) + : QTableWidgetItem(name, UserType) +{ + this->name = name; + pRecorder = NULL; + pUploading = NULL; + lastSizeUpdate = 0; + progress = 0; +} + +VideoItem::~VideoItem() +{} + +QLayout * PageVideos::bodyLayoutDefinition() +{ + QGridLayout * pPageLayout = new QGridLayout(); + pPageLayout->setColumnStretch(0, 1); + pPageLayout->setColumnStretch(1, 2); + pPageLayout->setRowStretch(0, 1); + pPageLayout->setRowStretch(1, 1); + + // options + { + IconedGroupBox* pOptionsGroup = new IconedGroupBox(this); + pOptionsGroup->setIcon(QIcon(":/res/Settings.png")); // FIXME + pOptionsGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + pOptionsGroup->setTitle(QGroupBox::tr("Video recording options")); + QGridLayout * pOptLayout = new QGridLayout(pOptionsGroup); + + // label for format + QLabel *labelFormat = new QLabel(pOptionsGroup); + labelFormat->setText(QLabel::tr("Format")); + pOptLayout->addWidget(labelFormat, 0, 0); + + // list of supported formats + comboAVFormats = new QComboBox(pOptionsGroup); + pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4); + LibavIteraction::instance().fillFormats(comboAVFormats); + + // separator + QFrame * hr = new QFrame(pOptionsGroup); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + pOptLayout->addWidget(hr, 1, 0, 1, 5); + + // label for audio codec + QLabel *labelACodec = new QLabel(pOptionsGroup); + labelACodec->setText(QLabel::tr("Audio codec")); + pOptLayout->addWidget(labelACodec, 2, 0); + + // list of supported audio codecs + comboAudioCodecs = new QComboBox(pOptionsGroup); + pOptLayout->addWidget(comboAudioCodecs, 2, 1, 1, 3); + + // checkbox 'record audio' + checkRecordAudio = new QCheckBox(pOptionsGroup); + checkRecordAudio->setText(QCheckBox::tr("Record audio")); + pOptLayout->addWidget(checkRecordAudio, 2, 4); + + // separator + hr = new QFrame(pOptionsGroup); + hr->setFrameStyle(QFrame::HLine); + hr->setLineWidth(3); + hr->setFixedHeight(10); + pOptLayout->addWidget(hr, 3, 0, 1, 5); + + // label for video codec + QLabel *labelVCodec = new QLabel(pOptionsGroup); + labelVCodec->setText(QLabel::tr("Video codec")); + pOptLayout->addWidget(labelVCodec, 4, 0); + + // list of supported video codecs + comboVideoCodecs = new QComboBox(pOptionsGroup); + pOptLayout->addWidget(comboVideoCodecs, 4, 1, 1, 4); + + // label for resolution + QLabel *labelRes = new QLabel(pOptionsGroup); + labelRes->setText(QLabel::tr("Resolution")); + pOptLayout->addWidget(labelRes, 5, 0); + + // width + widthEdit = new QLineEdit(pOptionsGroup); + widthEdit->setValidator(new QIntValidator(this)); + pOptLayout->addWidget(widthEdit, 5, 1); + + // x + QLabel *labelX = new QLabel(pOptionsGroup); + labelX->setText("X"); + pOptLayout->addWidget(labelX, 5, 2); + + // height + heightEdit = new QLineEdit(pOptionsGroup); + heightEdit->setValidator(new QIntValidator(pOptionsGroup)); + pOptLayout->addWidget(heightEdit, 5, 3); + + // checkbox 'use game resolution' + checkUseGameRes = new QCheckBox(pOptionsGroup); + checkUseGameRes->setText(QCheckBox::tr("Use game resolution")); + pOptLayout->addWidget(checkUseGameRes, 5, 4); + + // label for framerate + QLabel *labelFramerate = new QLabel(pOptionsGroup); + labelFramerate->setText(QLabel::tr("Framerate")); + pOptLayout->addWidget(labelFramerate, 6, 0); + + // framerate + framerateBox = new QSpinBox(pOptionsGroup); + framerateBox->setRange(1, 200); + framerateBox->setSingleStep(1); + pOptLayout->addWidget(framerateBox, 6, 1); + + // label for Bitrate + QLabel *labelBitrate = new QLabel(pOptionsGroup); + labelBitrate->setText(QLabel::tr("Bitrate (Kbps)")); + pOptLayout->addWidget(labelBitrate, 6, 2); + + // bitrate + bitrateBox = new QSpinBox(pOptionsGroup); + bitrateBox->setRange(100, 5000); + bitrateBox->setSingleStep(100); + pOptLayout->addWidget(bitrateBox, 6, 3); + + // button 'set default options' + btnDefaults = new QPushButton(pOptionsGroup); + btnDefaults->setText(QPushButton::tr("Set default options")); + pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5); + + pPageLayout->addWidget(pOptionsGroup, 1, 0); + } + + // list of videos + { + IconedGroupBox* pTableGroup = new IconedGroupBox(this); + pTableGroup->setIcon(QIcon(":/res/graphicsicon.png")); // FIXME + pTableGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + pTableGroup->setTitle(QGroupBox::tr("Videos")); + + QStringList columns; + columns << tr("Name"); + columns << tr("Size"); + columns << ""; + + filesTable = new QTableWidget(pTableGroup); + filesTable->setColumnCount(vcNumColumns); + filesTable->setHorizontalHeaderLabels(columns); + filesTable->setSelectionBehavior(QAbstractItemView::SelectRows); + filesTable->setSelectionMode(QAbstractItemView::SingleSelection); + filesTable->setEditTriggers(QAbstractItemView::SelectedClicked); + filesTable->verticalHeader()->hide(); + filesTable->setMinimumWidth(400); + + QHeaderView * header = filesTable->horizontalHeader(); + header->setResizeMode(vcName, QHeaderView::ResizeToContents); + header->setResizeMode(vcSize, QHeaderView::Fixed); + header->resizeSection(vcSize, 100); + header->setStretchLastSection(true); + + btnOpenDir = new QPushButton(QPushButton::tr("Open videos directory"), pTableGroup); + + QVBoxLayout *box = new QVBoxLayout(pTableGroup); + box->addWidget(filesTable); + box->addWidget(btnOpenDir); + + pPageLayout->addWidget(pTableGroup, 0, 1, 2, 1); + } + + // description + { + IconedGroupBox* pDescGroup = new IconedGroupBox(this); + pDescGroup->setIcon(QIcon(":/res/graphicsicon.png")); // FIXME + pDescGroup->setTitle(QGroupBox::tr("Description")); + + QVBoxLayout* pDescLayout = new QVBoxLayout(pDescGroup); + QHBoxLayout* pTopDescLayout = new QHBoxLayout(0); // picture and text + QHBoxLayout* pBottomDescLayout = new QHBoxLayout(0); // buttons + + // label with thumbnail picture + labelThumbnail = new QLabel(pDescGroup); + labelThumbnail->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + labelThumbnail->setMaximumSize(ThumbnailSize); + labelThumbnail->setStyleSheet( + "QFrame {" + "border: solid;" + "border-width: 3px;" + "border-color: #ffcc00;" + "border-radius: 4px;" + "}" ); + clearThumbnail(); + pTopDescLayout->addWidget(labelThumbnail, 2); + + // label with file description + labelDesc = new QLabel(pDescGroup); + labelDesc->setAlignment(Qt::AlignLeft | Qt::AlignTop); + labelDesc->setTextInteractionFlags(Qt::TextSelectableByMouse | + Qt::TextSelectableByKeyboard | + Qt::LinksAccessibleByMouse | + Qt::LinksAccessibleByKeyboard); + labelDesc->setTextFormat(Qt::RichText); + labelDesc->setOpenExternalLinks(true); + pTopDescLayout->addWidget(labelDesc, 1); + + // buttons: play and delete + btnPlay = new QPushButton(QPushButton::tr("Play"), pDescGroup); + btnPlay->setEnabled(false); + pBottomDescLayout->addWidget(btnPlay); + btnDelete = new QPushButton(QPushButton::tr("Delete"), pDescGroup); + btnDelete->setEnabled(false); + pBottomDescLayout->addWidget(btnDelete); + btnToYouTube = new QPushButton(QPushButton::tr("Upload to YouTube"), pDescGroup); + btnToYouTube->setEnabled(false); + pBottomDescLayout->addWidget(btnToYouTube); + + pDescLayout->addStretch(1); + pDescLayout->addLayout(pTopDescLayout, 0); + pDescLayout->addStretch(1); + pDescLayout->addLayout(pBottomDescLayout, 0); + + pPageLayout->addWidget(pDescGroup, 0, 0); + } + + return pPageLayout; +} + +QLayout * PageVideos::footerLayoutDefinition() +{ + return NULL; +} + +void PageVideos::connectSignals() +{ + connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int))); + connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int))); + connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int))); + connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions())); + connect(filesTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(cellDoubleClicked(int, int))); + connect(filesTable, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int, int))); + connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged())); + connect(btnPlay, SIGNAL(clicked()), this, SLOT(playSelectedFile())); + connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles())); + connect(btnToYouTube, SIGNAL(clicked()), this, SLOT(uploadToYouTube())); + connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory())); +} + +PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent), + config(0), netManager(0) +{ + nameChangedFromCode = false; + numRecorders = 0; + numUploads = 0; + initPage(); +} + +void PageVideos::init(GameUIConfig * config) +{ + this->config = config; + + QString path = cfgdir->absolutePath() + "/Videos"; + QFileSystemWatcher * pWatcher = new QFileSystemWatcher(this); + pWatcher->addPath(path); + connect(pWatcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(updateFileList(const QString &))); + updateFileList(path); + + startEncoding(); // this is for videos recorded from demos which were executed directly (without frontend) +} + +// user changed file format, we need to update list of codecs +void PageVideos::changeAVFormat(int index) +{ + // remember selected codecs + QString prevVCodec = videoCodec(); + QString prevACodec = audioCodec(); + + // clear lists of codecs + comboVideoCodecs->clear(); + comboAudioCodecs->clear(); + + // get list of codecs for specified format + LibavIteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs); + + // disable audio if there is no audio codec + if (comboAudioCodecs->count() == 0) + { + checkRecordAudio->setChecked(false); + checkRecordAudio->setEnabled(false); + } + else + checkRecordAudio->setEnabled(true); + + // restore selected codecs if possible + int iVCodec = comboVideoCodecs->findData(prevVCodec); + if (iVCodec != -1) + comboVideoCodecs->setCurrentIndex(iVCodec); + int iACodec = comboAudioCodecs->findData(prevACodec); + if (iACodec != -1) + comboAudioCodecs->setCurrentIndex(iACodec); +} + +// user switched checkbox 'use game resolution' +void PageVideos::changeUseGameRes(int state) +{ + if (state && config) + { + // set resolution to game resolution + QRect resolution = config->vid_Resolution(); + widthEdit->setText(QString::number(resolution.width())); + heightEdit->setText(QString::number(resolution.height())); + } + widthEdit->setEnabled(!state); + heightEdit->setEnabled(!state); +} + +// user switched checkbox 'record audio' +void PageVideos::changeRecordAudio(int state) +{ + comboAudioCodecs->setEnabled(!!state); +} + +void PageVideos::setDefaultCodecs() +{ + if (tryCodecs("mp4", "libx264", "libmp3lame")) + return; + if (tryCodecs("mp4", "libx264", "libfaac")) + return; + if (tryCodecs("mp4", "libx264", "libvo_aacenc")) + return; + if (tryCodecs("mp4", "libx264", "aac")) + return; + if (tryCodecs("mp4", "libx264", "mp2")) + return; + if (tryCodecs("avi", "libxvid", "libmp3lame")) + return; + if (tryCodecs("avi", "libxvid", "ac3_fixed")) + return; + if (tryCodecs("avi", "libxvid", "mp2")) + return; + if (tryCodecs("avi", "mpeg4", "libmp3lame")) + return; + if (tryCodecs("avi", "mpeg4", "ac3_fixed")) + return; + if (tryCodecs("avi", "mpeg4", "mp2")) + return; + + // this shouldn't happen, just in case + if (tryCodecs("ogg", "libtheora", "libvorbis")) + return; + tryCodecs("ogg", "libtheora", "flac"); +} + +void PageVideos::setDefaultOptions() +{ + framerateBox->setValue(25); + bitrateBox->setValue(400); + checkRecordAudio->setChecked(true); + checkUseGameRes->setChecked(true); + setDefaultCodecs(); +} + +bool PageVideos::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec) +{ + // first we should change format + int iFormat = comboAVFormats->findData(format); + if (iFormat == -1) + return false; + comboAVFormats->setCurrentIndex(iFormat); + // format was changed, so lists of codecs were automatically updated to codecs supported by this format + + // try to find video codec + int iVCodec = comboVideoCodecs->findData(vcodec); + if (iVCodec == -1) + return false; + comboVideoCodecs->setCurrentIndex(iVCodec); + + // try to find audio codec + int iACodec = comboAudioCodecs->findData(acodec); + if (iACodec == -1 && checkRecordAudio->isChecked()) + return false; + if (iACodec != -1) + comboAudioCodecs->setCurrentIndex(iACodec); + + return true; +} + +// get file size as string +static QString FileSizeStr(const QString & path) +{ + quint64 size = QFileInfo(path).size(); + + quint64 KiB = 1024; + quint64 MiB = 1024*KiB; + quint64 GiB = 1024*MiB; + QString sizeStr; + if (size >= GiB) + return QString("%1 GiB").arg(QString::number(float(size)/GiB, 'f', 2)); + if (size >= MiB) + return QString("%1 MiB").arg(QString::number(float(size)/MiB, 'f', 2)); + if (size >= KiB) + return QString("%1 KiB").arg(QString::number(float(size)/KiB, 'f', 2)); + return PageVideos::tr("%1 bytes", "", size).arg(QString::number(size)); +} + +// set file size in file list in specified row +void PageVideos::updateSize(int row) +{ + VideoItem * item = nameItem(row); + QString path = item->ready()? item->path() : cfgdir->absoluteFilePath("VideoTemp/" + item->pRecorder->name); + filesTable->item(row, vcSize)->setText(FileSizeStr(path)); +} + +// There is a button 'Open videos dir', so it is possible that user will open +// this dir and rename/delete some files there, so we should handle this. +void PageVideos::updateFileList(const QString & path) +{ + // mark all files as non seen + int numRows = filesTable->rowCount(); + for (int i = 0; i < numRows; i++) + nameItem(i)->seen = false; + + QStringList files = QDir(path).entryList(QDir::Files); + foreach (const QString & name, files) + { + int row = -1; + foreach (QTableWidgetItem * item, filesTable->findItems(name, Qt::MatchExactly)) + { + if (item->type() != QTableWidgetItem::UserType || !((VideoItem*)item)->ready()) + continue; + row = item->row(); + break; + } + if (row == -1) + row = appendRow(name); + VideoItem * item = nameItem(row); + item->seen = true; + item->desc = ""; + updateSize(row); + } + + // remove all non seen files + for (int i = 0; i < filesTable->rowCount();) + { + VideoItem * item = nameItem(i); + if (item->ready() && !item->seen) + filesTable->removeRow(i); + else + i++; + } +} + +void PageVideos::addRecorder(HWRecorder* pRecorder) +{ + int row = appendRow(pRecorder->name); + VideoItem * item = nameItem(row); + item->pRecorder = pRecorder; + pRecorder->item = item; + + // add progress bar + QProgressBar * progressBar = new QProgressBar(filesTable); + progressBar->setMinimum(0); + progressBar->setMaximum(10000); + progressBar->setValue(0); + connect(pRecorder, SIGNAL(onProgress(float)), this, SLOT(updateProgress(float))); + connect(pRecorder, SIGNAL(encodingFinished(bool)), this, SLOT(encodingFinished(bool))); + filesTable->setCellWidget(row, vcProgress, progressBar); + + numRecorders++; +} + +void PageVideos::setProgress(int row, VideoItem* item, float value) +{ + QProgressBar * progressBar = (QProgressBar*)filesTable->cellWidget(row, vcProgress); + progressBar->setValue(value*10000); + progressBar->setFormat(QString("%1%").arg(value*100, 0, 'f', 2)); + item->progress = value; +} + +void PageVideos::updateProgress(float value) +{ + HWRecorder * pRecorder = (HWRecorder*)sender(); + VideoItem * item = pRecorder->item; + int row = filesTable->row(item); + + // update file size every percent + if (value - item->lastSizeUpdate > 0.01) + { + updateSize(row); + item->lastSizeUpdate = value; + } + + setProgress(row, item, value); +} + +void PageVideos::encodingFinished(bool success) +{ + numRecorders--; + + HWRecorder * pRecorder = (HWRecorder*)sender(); + VideoItem * item = (VideoItem*)pRecorder->item; + int row = filesTable->row(item); + + if (success) + { + // move file to destination + success = cfgdir->rename("VideoTemp/" + pRecorder->name, "Videos/" + item->name); + if (!success) + { + // unable to rename for some reason (maybe user entered incorrect name); + // try to use temp name instead. + success = cfgdir->rename("VideoTemp/" + pRecorder->name, "Videos/" + pRecorder->name); + if (success) + setName(item, pRecorder->name); + } + } + + if (!success) + { + filesTable->removeRow(row); + return; + } + + filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar + item->pRecorder = NULL; + updateSize(row); + updateDescription(); +} + +void PageVideos::cellDoubleClicked(int row, int column) +{ + Q_UNUSED(column); + + play(row); +} + +void PageVideos::cellChanged(int row, int column) +{ + // user can only edit name + if (column != vcName || nameChangedFromCode) + return; + + // user has edited filename, so we should rename the file + VideoItem * item = nameItem(row); + QString oldName = item->name; + QString newName = item->text(); + if (!newName.contains('.')) // user forgot an extension + { + // restore old extension + int pt = oldName.lastIndexOf('.'); + if (pt != -1) + { + newName += oldName.right(oldName.length() - pt); + setName(item, newName); + } + } +#ifdef Q_WS_WIN + // there is a bug in qt, QDir::rename() doesn't fail on such names but damages files + if (newName.contains(QRegExp("[\"*:<>?\/|]"))) + { + setName(item, oldName); + return; + } +#endif + if (item->ready() && !cfgdir->rename("Videos/" + oldName, "Videos/" + newName)) + { + // unable to rename for some reason (maybe user entered incorrect name), + // therefore restore old name in cell + setName(item, oldName); + return; + } + item->name = newName; + updateDescription(); +} + +void PageVideos::setName(VideoItem * item, const QString & newName) +{ + nameChangedFromCode = true; + item->setText(newName); + nameChangedFromCode = false; + item->name = newName; +} + +int PageVideos::appendRow(const QString & name) +{ + int row = filesTable->rowCount(); + filesTable->setRowCount(row+1); + + // add 'name' item + QTableWidgetItem * item = new VideoItem(name); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable); + nameChangedFromCode = true; + filesTable->setItem(row, vcName, item); + nameChangedFromCode = false; + + // add 'size' item + item = new QTableWidgetItem(); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setTextAlignment(Qt::AlignRight); + filesTable->setItem(row, vcSize, item); + + // add 'progress' item + item = new QTableWidgetItem(); + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + filesTable->setItem(row, vcProgress, item); + + return row; +} + +VideoItem* PageVideos::nameItem(int row) +{ + return (VideoItem*)filesTable->item(row, vcName); +} + +void PageVideos::clearThumbnail() +{ + // add empty (transparent) image for proper sizing + QPixmap pic(ThumbnailSize); + pic.fill(QColor(0,0,0,0)); + labelThumbnail->setPixmap(pic); +} + +void PageVideos::updateDescription() +{ + VideoItem * item = nameItem(filesTable->currentRow()); + if (!item) + { + // nothing is selected => clear description and return + labelDesc->clear(); + clearThumbnail(); + btnPlay->setEnabled(false); + btnDelete->setEnabled(false); + btnToYouTube->setEnabled(false); + return; + } + + btnPlay->setEnabled(item->ready()); + btnToYouTube->setEnabled(item->ready()); + btnDelete->setEnabled(true); + btnDelete->setText(item->ready()? QPushButton::tr("Delete") : QPushButton::tr("Cancel")); + btnToYouTube->setText(item->pUploading? QPushButton::tr("Cancel uploading") : QPushButton::tr("Upload to YouTube")); + + // construct string with desctiption of this file to display it + QString desc = item->name + "\n\n"; + + if (!item->ready()) + desc += tr("(in progress...)"); + else + { + QString path = item->path(); + desc += tr("Date: ") + QFileInfo(path).created().toString(Qt::DefaultLocaleLongDate) + '\n'; + desc += tr("Size: ") + FileSizeStr(path) + '\n'; + if (item->desc.isEmpty()) + { + // Extract description from file; + // It will contain duration, resolution, etc and also comment added by hwengine. + item->desc = LibavIteraction::instance().getFileInfo(path); + + // extract prefix (original name) from description (it is enclosed in prefix[???]prefix) + int prefixBegin = item->desc.indexOf("prefix["); + int prefixEnd = item->desc.indexOf("]prefix"); + if (prefixBegin != -1 && prefixEnd != -1) + { + item->prefix = item->desc.mid(prefixBegin + 7, prefixEnd - (prefixBegin + 7)); + item->desc.remove(prefixBegin, prefixEnd + 7 - prefixBegin); + } + } + desc += item->desc + '\n'; + } + + if (item->prefix.isEmpty()) + { + // try to extract prefix from file name instead + if (item->ready()) + item->prefix = item->name; + else + item->prefix = item->pRecorder->name; + + // remove extension + int pt = item->prefix.lastIndexOf('.'); + if (pt != -1) + item->prefix.truncate(pt); + } + + if (item->ready() && item->uploadUrl.isEmpty()) + { + // try to load url from file + QFile * file = new QFile(cfgdir->absoluteFilePath("VideoTemp/" + item->prefix + "-url.txt"), this); + if (!file->open(QIODevice::ReadOnly)) + item->uploadUrl = "no"; + else + { + QByteArray data = file->readAll(); + file->close(); + item->uploadUrl = QString::fromUtf8(data.data()); + } + } + if (item->uploadUrl != "no") + desc += QString("%1").arg(item->uploadUrl); + desc.replace("\n", "
"); + + labelDesc->setText(desc); + + if (!item->prefix.isEmpty()) + { + QString thumbName = cfgdir->absoluteFilePath("VideoTemp/" + item->prefix); + QPixmap pic; + if (pic.load(thumbName + ".png") || pic.load(thumbName + ".bmp")) + { + if (pic.height()*ThumbnailSize.width() > pic.width()*ThumbnailSize.height()) + pic = pic.scaledToWidth(ThumbnailSize.width()); + else + pic = pic.scaledToHeight(ThumbnailSize.height()); + labelThumbnail->setPixmap(pic); + } + else + clearThumbnail(); + } +} + +// user selected another cell, so we should change description +void PageVideos::currentCellChanged() +{ + updateDescription(); +} + +// open video file in external media player +void PageVideos::play(int row) +{ + VideoItem * item = nameItem(row); + if (item && item->ready()) + QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(item->path()))); +} + +void PageVideos::playSelectedFile() +{ + int index = filesTable->currentRow(); + if (index != -1) + play(index); +} + +void PageVideos::deleteSelectedFiles() +{ + int index = filesTable->currentRow(); + if (index == -1) + return; + + VideoItem * item = nameItem(index); + if (!item) + return; + + // ask user if (s)he is serious + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the video '%1'?").arg(item->name)); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + + if (reallyDeleteMsg.exec() != QMessageBox::Ok) + return; + + // remove + if (!item->ready()) + item->pRecorder->deleteLater(); + else + cfgdir->remove("Videos/" + item->name); + +// this code is for removing several files when multiple selection is enabled +#if 0 + QList items = filesTable->selectedItems(); + int num = items.size() / vcNumColumns; + if (num == 0) + return; + + // ask user if (s)he is serious + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to remove %1 file(s)?", "", num).arg(num)); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + + if (reallyDeleteMsg.exec() != QMessageBox::Ok) + return; + + // remove + foreach (QTableWidgetItem * witem, items) + { + if (witem->type() != QTableWidgetItem::UserType) + continue; + VideoItem * item = (VideoItem*)witem; + if (!item->ready()) + item->pRecorder->deleteLater(); + else + cfgdir->remove("Videos/" + item->name); + } +#endif +} + +void PageVideos::keyPressEvent(QKeyEvent * pEvent) +{ + if (filesTable->hasFocus()) + { + if (pEvent->key() == Qt::Key_Delete) + { + deleteSelectedFiles(); + return; + } + if (pEvent->key() == Qt::Key_Enter) // doesn't work + { + playSelectedFile(); + return; + } + } + AbstractPage::keyPressEvent(pEvent); +} + +void PageVideos::openVideosDirectory() +{ + QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Videos"); + QDesktopServices::openUrl(QUrl("file:///" + path)); +} + +// clear VideoTemp directory (except for thumbnails and upload links) +void PageVideos::clearTemp() +{ + QDir temp(cfgdir->absolutePath() + "/VideoTemp"); + QStringList files = temp.entryList(QDir::Files); + foreach (const QString& file, files) + { + if (!file.endsWith(".bmp") && !file.endsWith(".png") && !file.endsWith("-url.txt")) + temp.remove(file); + } +} + +bool PageVideos::tryQuit(HWForm * form) +{ + bool quit = true; + if (numRecorders != 0 || numUploads != 0) + { + // ask user what to do - abort or wait + HWAskQuitDialog * askd = new HWAskQuitDialog(this, form); + askd->deleteLater(); + quit = askd->exec(); + } + if (quit) + clearTemp(); + return quit; +} + +// returns multi-line string with list of videos in progress +/* it will look like this: +foo.avi (15.21% - encoding) +bar.avi (18.21% - uploading) +*/ +QString PageVideos::getVideosInProgress() +{ + QString list = ""; + int count = filesTable->rowCount(); + for (int i = 0; i < count; i++) + { + VideoItem * item = nameItem(i); + QString process; + if (!item->ready()) + process = tr("encoding"); + else if (item->pUploading) + process = tr("uploading"); + else + continue; + float progress = 100*item->progress; + if (progress > 99.99) + progress = 99.99; // displaying 100% may be confusing + list += item->name + " (" + QString::number(progress, 'f', 2) + "% - " + process + ")\n"; + } + return list; +} + +void PageVideos::startEncoding(const QByteArray & record) +{ + QDir videoTempDir(cfgdir->absolutePath() + "/VideoTemp/"); + QStringList files = videoTempDir.entryList(QStringList("*.txtout"), QDir::Files); + foreach (const QString & str, files) + { + QString prefix = str; + prefix.chop(7); // remove ".txtout" + videoTempDir.rename(prefix + ".txtout", prefix + ".txtin"); // rename this file to not open it twice + + HWRecorder* pRecorder = new HWRecorder(config, prefix); + + if (!record.isEmpty()) + pRecorder->EncodeVideo(record); + else + { + // this is for videos recorded from demos which were executed directly (without frontend) + QFile demofile(videoTempDir.absoluteFilePath(prefix + ".hwd")); + if (!demofile.open(QIODevice::ReadOnly)) + continue; + QByteArray demo = demofile.readAll(); + if (demo.isEmpty()) + continue; + pRecorder->EncodeVideo(demo); + } + addRecorder(pRecorder); + } +} + +VideoItem * PageVideos::itemFromReply(QNetworkReply* reply, int & row) +{ + VideoItem * item = NULL; + int count = filesTable->rowCount(); + // find corresponding item (maybe there is a better way to implement this?) + for (int i = 0; i < count; i++) + { + item = nameItem(i); + if (item->pUploading == reply) + { + row = i; + break; + } + } + return item; +} + +void PageVideos::uploadProgress(qint64 bytesSent, qint64 bytesTotal) +{ + QNetworkReply* reply = (QNetworkReply*)sender(); + int row; + VideoItem * item = itemFromReply(reply, row); + setProgress(row, item, bytesSent*1.0/bytesTotal); +} + +void PageVideos::uploadFinished() +{ + QNetworkReply* reply = (QNetworkReply*)sender(); + reply->deleteLater(); + + int row; + VideoItem * item = itemFromReply(reply, row); + if (!item) + return; + + item->pUploading = NULL; + + // extract video id from reply + QString videoid; + QXmlStreamReader xml(reply); + while (!xml.atEnd()) + { + xml.readNext(); + if (xml.qualifiedName() == "yt:videoid") + { + videoid = xml.readElementText(); + break; + } + } + + if (!videoid.isEmpty()) + { + item->uploadUrl = "http://youtu.be/" + videoid; + updateDescription(); + + // save url in file + QFile * file = new QFile(cfgdir->absoluteFilePath("VideoTemp/" + item->prefix + "-url.txt"), this); + if (file->open(QIODevice::WriteOnly)) + { + file->write(item->uploadUrl.toUtf8()); + file->close(); + } + } + + filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar + numUploads--; +} + +// this will protect saved youtube password from those who cannot read source code +static QString protectPass(QString str) +{ + QByteArray array = str.toUtf8(); + for (int i = 0; i < array.size(); i++) + array[i] = array[i] ^ 0xC4 ^ i; + array = array.toBase64(); + return QString::fromAscii(array.data()); +} + +static QString unprotectPass(QString str) +{ + QByteArray array = QByteArray::fromBase64(str.toAscii()); + for (int i = 0; i < array.size(); i++) + array[i] = array[i] ^ 0xC4 ^ i; + return QString::fromUtf8(array); +} + +void PageVideos::uploadToYouTube() +{ + int row = filesTable->currentRow(); + VideoItem * item = nameItem(row); + + if (item->pUploading) + { + // ask user if (s)he is serious + QMessageBox reallyStopMsg(this); + reallyStopMsg.setIcon(QMessageBox::Question); + reallyStopMsg.setWindowTitle(QMessageBox::tr("Videos - Are you sure?")); + reallyStopMsg.setText(QMessageBox::tr("Do you really want to cancel uploading %1?").arg(item->name)); + reallyStopMsg.setWindowModality(Qt::WindowModal); + reallyStopMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + + if (reallyStopMsg.exec() != QMessageBox::Ok) + return; + item->pUploading->deleteLater(); + filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar + numUploads--; + return; + } + + if (!netManager) + netManager = new QNetworkAccessManager(this); + + HWUploadVideoDialog* dlg = new HWUploadVideoDialog(this, item->name, netManager); + dlg->deleteLater(); + if (config->value("youtube/save").toBool()) + { + dlg->cbSave->setChecked(true); + dlg->leAccount->setText(config->value("youtube/name").toString()); + dlg->lePassword->setText(unprotectPass(config->value("youtube/pswd").toString())); + } + + bool result = dlg->exec(); + + if (dlg->cbSave->isChecked()) + { + config->setValue("youtube/save", true); + config->setValue("youtube/name", dlg->leAccount->text()); + config->setValue("youtube/pswd", protectPass(dlg->lePassword->text())); + } + else + { + config->setValue("youtube/save", false); + config->setValue("youtube/name", ""); + config->setValue("youtube/pswd", ""); + } + + if (!result) + return; + + QNetworkRequest request(QUrl(dlg->location)); + request.setRawHeader("Content-Type", "application/octet-stream"); + + QFile * file = new QFile(item->path(), this); + if (!file->open(QIODevice::ReadOnly)) + return; + + // add progress bar + QProgressBar * progressBar = new QProgressBar(filesTable); + progressBar->setMinimum(0); + progressBar->setMaximum(10000); + progressBar->setValue(0); + // make it different from progress-bar used during encoding (use blue color) + progressBar->setStyleSheet("* {color: #00ccff; selection-background-color: #00ccff;}" ); + filesTable->setCellWidget(row, vcProgress, progressBar); + + QNetworkReply* reply = netManager->put(request, file); + file->setParent(reply); // automatically close file when needed + item->pUploading = reply; + connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64))); + connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished())); + numUploads++; + + updateDescription(); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/page/pagevideos.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/page/pagevideos.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,126 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#ifndef PAGE_VIDEOS_H +#define PAGE_VIDEOS_H + +#include "AbstractPage.h" + +class QNetworkAccessManager; +class QNetworkReply; +class GameUIConfig; +class HWRecorder; +class VideoItem; +class HWForm; + +class PageVideos : public AbstractPage +{ + Q_OBJECT + + public: + PageVideos(QWidget* parent = 0); + + QSpinBox *framerateBox; + QSpinBox *bitrateBox; + QLineEdit *widthEdit; + QLineEdit *heightEdit; + QCheckBox *checkUseGameRes; + QCheckBox *checkRecordAudio; + + QString format() + { return comboAVFormats->itemData(comboAVFormats->currentIndex()).toString(); } + + QString videoCodec() + { return comboVideoCodecs->itemData(comboVideoCodecs->currentIndex()).toString(); } + + QString audioCodec() + { return comboAudioCodecs->itemData(comboAudioCodecs->currentIndex()).toString(); } + + void setDefaultCodecs(); + bool tryCodecs(const QString & format, const QString & vcodec, const QString & acodec); + void addRecorder(HWRecorder* pRecorder); + bool tryQuit(HWForm *form); + QString getVideosInProgress(); // get multi-line string with list of videos in progress + void startEncoding(const QByteArray & record = QByteArray()); + void init(GameUIConfig * config); + + private: + // virtuals from AbstractPage + QLayout * bodyLayoutDefinition(); + QLayout * footerLayoutDefinition(); + void connectSignals(); + + // virtual from QWidget + void keyPressEvent(QKeyEvent * pEvent); + + void setName(VideoItem * item, const QString & newName); + void updateSize(int row); + int appendRow(const QString & name); + VideoItem* nameItem(int row); + void play(int row); + void updateDescription(); + void clearTemp(); + void clearThumbnail(); + void setProgress(int row, VideoItem* item, float value); + VideoItem * itemFromReply(QNetworkReply* reply, int & row); + + GameUIConfig * config; + QNetworkAccessManager* netManager; + + // options group + QComboBox *comboAVFormats; + QComboBox *comboVideoCodecs; + QComboBox *comboAudioCodecs; + QPushButton *btnDefaults; + + // file list group + QTableWidget *filesTable; + QPushButton *btnOpenDir; + + // description group + QPushButton *btnPlay, *btnDelete, *btnToYouTube; + QLabel *labelDesc; + QLabel *labelThumbnail; + + // this flag is used to distinguish if cell was changed from code or by user + // (in signal cellChanged) + bool nameChangedFromCode; + + int numRecorders, numUploads; + + private slots: + void changeAVFormat(int index); + void changeUseGameRes(int state); + void changeRecordAudio(int state); + void setDefaultOptions(); + void encodingFinished(bool success); + void updateProgress(float value); + void cellDoubleClicked(int row, int column); + void cellChanged(int row, int column); + void currentCellChanged(); + void playSelectedFile(); + void deleteSelectedFiles(); + void openVideosDirectory(); + void updateFileList(const QString & path); + void uploadToYouTube(); + void uploadProgress(qint64 bytesSent, qint64 bytesTotal); + void uploadFinished(); +}; + +#endif // PAGE_VIDEOS_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/qaspectratiolayout.cpp --- a/QTfrontend/ui/qaspectratiolayout.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/qaspectratiolayout.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -4,116 +4,141 @@ #include "qaspectratiolayout.h" -QAspectRatioLayout::QAspectRatioLayout(QWidget* parent, int spacing) : QLayout(parent) { - init(spacing); +QAspectRatioLayout::QAspectRatioLayout(QWidget* parent, int spacing) : QLayout(parent) +{ + init(spacing); } -QAspectRatioLayout::QAspectRatioLayout(int spacing) { - init(spacing); +QAspectRatioLayout::QAspectRatioLayout(int spacing) +{ + init(spacing); } -QAspectRatioLayout::~QAspectRatioLayout() { - delete item; - delete lastReceivedRect; - delete _geometry; +QAspectRatioLayout::~QAspectRatioLayout() +{ + delete item; + delete lastReceivedRect; + delete _geometry; } -void QAspectRatioLayout::init(int spacing) { - item = 0; - lastReceivedRect = new QRect(0, 0, 0, 0); - _geometry = new QRect(0, 0, 0, 0); - setSpacing(spacing); +void QAspectRatioLayout::init(int spacing) +{ + item = 0; + lastReceivedRect = new QRect(0, 0, 0, 0); + _geometry = new QRect(0, 0, 0, 0); + setSpacing(spacing); } /* Adds item if place isn't already taken. */ -void QAspectRatioLayout::add(QLayoutItem* item) { - if(!hasItem()) { - replaceItem(item); - } +void QAspectRatioLayout::add(QLayoutItem* item) +{ + if(!hasItem()) + { + replaceItem(item); + } } /* Adds item if place isn't already taken. */ -void QAspectRatioLayout::addItem(QLayoutItem* item) { - if(!hasItem()) { - replaceItem(item); - } +void QAspectRatioLayout::addItem(QLayoutItem* item) +{ + if(!hasItem()) + { + replaceItem(item); + } } /* Adds widget if place isn't already taken. */ -void QAspectRatioLayout::addWidget(QWidget* widget) { - if(!hasItem()) { - replaceItem(new QWidgetItem(widget)); - } +void QAspectRatioLayout::addWidget(QWidget* widget) +{ + if(!hasItem()) + { + replaceItem(new QWidgetItem(widget)); + } } /* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::take() { - QLayoutItem* item = 0; - if(this->hasItem()) { - item = this->item; - this->item = 0; - } - return item; +QLayoutItem* QAspectRatioLayout::take() +{ + QLayoutItem* item = 0; + if(this->hasItem()) + { + item = this->item; + this->item = 0; + } + return item; } /* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::takeAt(int index) { - if(index != 0) { - return 0; - } - return this->take(); +QLayoutItem* QAspectRatioLayout::takeAt(int index) +{ + if(index != 0) + { + return 0; + } + return this->take(); } /* Returns the item pointer. */ -QLayoutItem* QAspectRatioLayout::itemAt(int index) const { - if(index != 0) { - return 0; - } - if(hasItem()) { - return this->item; - } +QLayoutItem* QAspectRatioLayout::itemAt(int index) const +{ + if(index != 0) + { return 0; + } + if(hasItem()) + { + return this->item; + } + return 0; } /* Checks if we have an item. */ -bool QAspectRatioLayout::hasItem() const { - return this->item != 0; +bool QAspectRatioLayout::hasItem() const +{ + return this->item != 0; } /* Returns the count of items which can be either 0 or 1. */ -int QAspectRatioLayout::count() const { - int returnValue = 0; - if(hasItem()) { - returnValue = 1; - } - return returnValue; +int QAspectRatioLayout::count() const +{ + int returnValue = 0; + if(hasItem()) + { + returnValue = 1; + } + return returnValue; } /* Replaces the item with the new and returns the old. */ -QLayoutItem* QAspectRatioLayout::replaceItem(QLayoutItem* item) { - QLayoutItem* old = 0; - if(this->hasItem()) { - old = this->item; - } - this->item = item; - setGeometry(*this->_geometry); - return old; +QLayoutItem* QAspectRatioLayout::replaceItem(QLayoutItem* item) +{ + QLayoutItem* old = 0; + if(this->hasItem()) + { + old = this->item; + } + this->item = item; + setGeometry(*this->_geometry); + return old; } /* Tells which way layout expands. */ -Qt::Orientations QAspectRatioLayout::expandingDirections() const { - return Qt::Horizontal | Qt::Vertical; +Qt::Orientations QAspectRatioLayout::expandingDirections() const +{ + return Qt::Horizontal | Qt::Vertical; } /* Tells which size is preferred. */ -QSize QAspectRatioLayout::sizeHint() const { - return this->item->minimumSize(); +QSize QAspectRatioLayout::sizeHint() const +{ + return this->item->minimumSize(); } /* Tells minimum size. */ -QSize QAspectRatioLayout::minimumSize() const { - return this->item->minimumSize(); +QSize QAspectRatioLayout::minimumSize() const +{ + return this->item->minimumSize(); } /* @@ -121,86 +146,99 @@ * It isn't since width isn't enough to calculate * proper size. */ -bool QAspectRatioLayout::hasHeightForWidth() const { - return false; +bool QAspectRatioLayout::hasHeightForWidth() const +{ + return false; } /* Replaces lastReceivedRect. */ -void QAspectRatioLayout::setLastReceivedRect(const QRect& rect) { - QRect* oldRect = this->lastReceivedRect; - this->lastReceivedRect = new QRect(rect.topLeft(), rect.size()); - delete oldRect; +void QAspectRatioLayout::setLastReceivedRect(const QRect& rect) +{ + QRect* oldRect = this->lastReceivedRect; + this->lastReceivedRect = new QRect(rect.topLeft(), rect.size()); + delete oldRect; } /* Returns geometry */ -QRect QAspectRatioLayout::geometry() { - return QRect(*this->_geometry); +QRect QAspectRatioLayout::geometry() +{ + return QRect(*this->_geometry); } /* Sets geometry to given size. */ -void QAspectRatioLayout::setGeometry(const QRect& rect) { - /* - * We check if the item is set and - * if size is the same previously received. - * If either is false nothing is done. - */ - if(!this->hasItem() || - areRectsEqual(*this->lastReceivedRect, rect)) { - return; - } - /* Replace the last received rectangle. */ - setLastReceivedRect(rect); - /* Calculate proper size for the item relative to the received size. */ - QSize properSize = calculateProperSize(rect.size()); - /* Calculate center location in the rect and with item size. */ - QPoint properLocation = calculateCenterLocation(rect.size(), properSize); - /* Set items geometry */ - this->item->setGeometry(QRect(properLocation, properSize)); - QRect* oldRect = this->_geometry; - /* Cache the calculated geometry. */ - this->_geometry = new QRect(properLocation, properSize); - delete oldRect; - /* Super classes setGeometry */ - QLayout::setGeometry(*this->_geometry); +void QAspectRatioLayout::setGeometry(const QRect& rect) +{ + /* + * We check if the item is set and + * if size is the same previously received. + * If either is false nothing is done. + */ + if(!this->hasItem() || + areRectsEqual(*this->lastReceivedRect, rect)) + { + return; + } + /* Replace the last received rectangle. */ + setLastReceivedRect(rect); + /* Calculate proper size for the item relative to the received size. */ + QSize properSize = calculateProperSize(rect.size()); + /* Calculate center location in the rect and with item size. */ + QPoint properLocation = calculateCenterLocation(rect.size(), properSize); + /* Set items geometry */ + this->item->setGeometry(QRect(properLocation, properSize)); + QRect* oldRect = this->_geometry; + /* Cache the calculated geometry. */ + this->_geometry = new QRect(properLocation, properSize); + delete oldRect; + /* Super classes setGeometry */ + QLayout::setGeometry(*this->_geometry); } /* Takes the shortest side and creates QSize * with the shortest side as width and height. */ -QSize QAspectRatioLayout::calculateProperSize(QSize from) const { - QSize properSize; - if(from.height() * 2 < from.width()) { - properSize.setHeight(from.height() - this->margin()); - properSize.setWidth(from.height() * 2 - this->margin()); - } - else { - properSize.setWidth(from.width() - this->margin()); - properSize.setHeight(from.width() / 2 - this->margin()); - } - return properSize; +QSize QAspectRatioLayout::calculateProperSize(QSize from) const +{ + QSize properSize; + if(from.height() * 2 < from.width()) + { + properSize.setHeight(from.height() - this->margin()); + properSize.setWidth(from.height() * 2 - this->margin()); + } + else + { + properSize.setWidth(from.width() - this->margin()); + properSize.setHeight(from.width() / 2 - this->margin()); + } + return properSize; } /* Calculates center location from the given height and width for item size. */ QPoint QAspectRatioLayout::calculateCenterLocation(QSize from, - QSize itemSize) const { - QPoint centerLocation; - if((from.width() - itemSize.width()) > 0) { - centerLocation.setX((from.width() - itemSize.width())/2); - } - if((from.height() - itemSize.height()) > 0) { - centerLocation.setY((from.height() - itemSize.height())/2); - } - return centerLocation; + QSize itemSize) const +{ + QPoint centerLocation; + if((from.width() - itemSize.width()) > 0) + { + centerLocation.setX((from.width() - itemSize.width())/2); + } + if((from.height() - itemSize.height()) > 0) + { + centerLocation.setY((from.height() - itemSize.height())/2); + } + return centerLocation; } /* Compares if two QRects are equal. */ bool QAspectRatioLayout::areRectsEqual(const QRect& a, - const QRect& b) const { - bool result = false; - if(a.x() == b.x() && - a.y() == b.y() && - a.height() == b.height() && - a.width() == b.width()) { - result = true; - } - return result; + const QRect& b) const +{ + bool result = false; + if(a.x() == b.x() && + a.y() == b.y() && + a.height() == b.height() && + a.width() == b.width()) + { + result = true; + } + return result; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/qaspectratiolayout.h --- a/QTfrontend/ui/qaspectratiolayout.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/qaspectratiolayout.h Sun Oct 28 13:28:23 2012 +0100 @@ -16,7 +16,7 @@ { Q_OBJECT -public: + public: QAspectRatioLayout(QWidget* parent, int spacing =-1); QAspectRatioLayout(int spacing = -1); ~QAspectRatioLayout(); @@ -24,7 +24,7 @@ /* Convenience method */ virtual void add(QLayoutItem* item); -/* http://doc.trolltech.com/qlayout.html#addItem */ + /* http://doc.trolltech.com/qlayout.html#addItem */ virtual void addItem(QLayoutItem* item); /* http://doc.trolltech.com/qlayout.html#addWidget */ virtual void addWidget(QWidget* widget); @@ -42,7 +42,7 @@ virtual QLayoutItem* take(); virtual bool hasItem() const; -/* http://doc.trolltech.com/qlayout.html#expandingDirections */ + /* http://doc.trolltech.com/qlayout.html#expandingDirections */ virtual Qt::Orientations expandingDirections() const; /* @@ -60,7 +60,7 @@ /* http://doc.trolltech.com/qlayoutitem.html#hasHeightForWidth */ virtual bool hasHeightForWidth() const; -private: + private: /* Saves the last received rect. */ void setLastReceivedRect(const QRect& rect); /* Used to initialize the object. */ diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/FreqSpinBox.cpp --- a/QTfrontend/ui/widget/FreqSpinBox.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/FreqSpinBox.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/FreqSpinBox.h --- a/QTfrontend/ui/widget/FreqSpinBox.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/FreqSpinBox.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,23 +35,23 @@ */ class FreqSpinBox : public QSpinBox { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent widget. - */ - FreqSpinBox(QWidget * parent); + public: + /** + * @brief Class constructor. + * @param parent parent widget. + */ + FreqSpinBox(QWidget * parent); -protected: - /** - * Returns it's value as localized frequency. - * 'Never', 'Every Turn', 'Every 2 Turns', etc. - * @param value integer value to be representing as string. - * @return the turn frequence-like string representation. - */ - QString textFromValue(int value) const; + protected: + /** + * Returns it's value as localized frequency. + * 'Never', 'Every Turn', 'Every 2 Turns', etc. + * @param value integer value to be representing as string. + * @return the turn frequence-like string representation. + */ + QString textFromValue(int value) const; }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/HistoryLineEdit.cpp --- a/QTfrontend/ui/widget/HistoryLineEdit.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/HistoryLineEdit.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ #include "HistoryLineEdit.h" HistoryLineEdit::HistoryLineEdit(QWidget * parent, int maxHistorySize) -: QLineEdit(parent) + : QLineEdit(parent) { m_curHistEntryIdx = 0; m_maxHistorySize = maxHistorySize; @@ -80,10 +80,10 @@ { // save possible changes to new entry if ((m_curHistEntryIdx >= m_history->size() || - (text() != m_history->at(m_curHistEntryIdx)))) - { - rememberCurrentText(); - } + (text() != m_history->at(m_curHistEntryIdx)))) + { + rememberCurrentText(); + } if (isGoingUp) m_curHistEntryIdx--; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/HistoryLineEdit.h --- a/QTfrontend/ui/widget/HistoryLineEdit.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/HistoryLineEdit.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,72 +38,72 @@ /** * @brief QLineEdit that features a history of previous contents, * re-selectable using the arrow keys. - * + * * @author sheepluva * @since 0.9.17 */ class HistoryLineEdit : public QLineEdit { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent QWidget. - * @param maxHistorySize maximum amount of history entries kept. - */ - HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); + public: + /** + * @brief Class constructor. + * @param parent parent QWidget. + * @param maxHistorySize maximum amount of history entries kept. + */ + HistoryLineEdit(QWidget * parent = 0, int maxHistorySize = 64); - /** - * @brief Class destructor. - */ - ~HistoryLineEdit(); + /** + * @brief Class destructor. + */ + ~HistoryLineEdit(); - /** - * @brief Appends current text to history (if not only whitespaces); - */ - void rememberCurrentText(); + /** + * @brief Appends current text to history (if not only whitespaces); + */ + void rememberCurrentText(); - /** - * @brief Forget all history. - */ - void reset(); + /** + * @brief Forget all history. + */ + void reset(); -public slots: - /** - * @brief Clears the contents. - */ - void clear(); + public slots: + /** + * @brief Clears the contents. + */ + void clear(); -protected: - /** - * @brief Overrides method of parent class. - * Arrow keys are used for navigating the history. - * - * All other keys are forwarded to the parent's method. - * - * @param event the key event. - */ - virtual void keyPressEvent(QKeyEvent * event); + protected: + /** + * @brief Overrides method of parent class. + * Arrow keys are used for navigating the history. + * + * All other keys are forwarded to the parent's method. + * + * @param event the key event. + */ + virtual void keyPressEvent(QKeyEvent * event); -private: - int m_maxHistorySize; ///< the maximum allowed size for the history - int m_curHistEntryIdx; ///< the index of the displayed used entry + private: + int m_maxHistorySize; ///< the maximum allowed size for the history + int m_curHistEntryIdx; ///< the index of the displayed used entry - QStringList * m_history; ///< history of previous inputs + QStringList * m_history; ///< history of previous inputs - /** - * @brief Navigates content history in the desired direction. - * - * Note: no wrap-around on purpose (so that holding down/up will get the - * the user to the respective end rather than into an endless cycle :P) - * - * @param isGoingUp true: next older entry, false: next more recent entry. - */ - void navigateHistory(bool isGoingUp); + /** + * @brief Navigates content history in the desired direction. + * + * Note: no wrap-around on purpose (so that holding down/up will get the + * the user to the respective end rather than into an endless cycle :P) + * + * @param isGoingUp true: next older entry, false: next more recent entry. + */ + void navigateHistory(bool isGoingUp); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/SmartLineEdit.cpp --- a/QTfrontend/ui/widget/SmartLineEdit.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/SmartLineEdit.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ #include "SmartLineEdit.h" SmartLineEdit::SmartLineEdit(QWidget * parent, int maxHistorySize) -: HistoryLineEdit(parent, maxHistorySize) + : HistoryLineEdit(parent, maxHistorySize) { m_whitespace = QRegExp("\\s"); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/SmartLineEdit.h --- a/QTfrontend/ui/widget/SmartLineEdit.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/SmartLineEdit.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,108 +45,108 @@ *
  • A Keyword can either be a command (if first word) or * a nickname (completed regardless of position in text).
  • * - * + * * @author sheepluva * @since 0.9.17 */ class SmartLineEdit : public HistoryLineEdit { - Q_OBJECT + Q_OBJECT -public: - /** - * @brief Class constructor. - * @param parent parent QWidget. - * @param maxHistorySize maximum amount of history entries kept. - */ - SmartLineEdit(QWidget * parent = 0, int maxHistorySize = 64); + public: + /** + * @brief Class constructor. + * @param parent parent QWidget. + * @param maxHistorySize maximum amount of history entries kept. + */ + SmartLineEdit(QWidget * parent = 0, int maxHistorySize = 64); - /** - * @brief Class destructor. - */ - ~SmartLineEdit(); + /** + * @brief Class destructor. + */ + ~SmartLineEdit(); - /** - * @brief Adds commands to the auto-completion feature. - * @param commands list of commands to be added. - */ - void addCommands(const QStringList & commands); + /** + * @brief Adds commands to the auto-completion feature. + * @param commands list of commands to be added. + */ + void addCommands(const QStringList & commands); - /** - * @brief Adds a single nickname to the auto-completion feature. - * @param nickname name to be added. - */ - void addNickname(const QString & nickname); + /** + * @brief Adds a single nickname to the auto-completion feature. + * @param nickname name to be added. + */ + void addNickname(const QString & nickname); - /** - * @brief Removes commands from the auto-completion feature. - * @param commands list of commands to be removed. - */ - void removeCommands(const QStringList & commands); + /** + * @brief Removes commands from the auto-completion feature. + * @param commands list of commands to be removed. + */ + void removeCommands(const QStringList & commands); - /** - * @brief Removes a single nickname from the auto-completion feature. - * @param nickname name to be removed. - */ - void removeNickname(const QString & nickname); + /** + * @brief Removes a single nickname from the auto-completion feature. + * @param nickname name to be removed. + */ + void removeNickname(const QString & nickname); - /** - * @brief Forget all keywords and input history. - */ - void reset(); + /** + * @brief Forget all keywords and input history. + */ + void reset(); -protected: - /** - * @brief Overrides method of parent class. - * Forward pressed TAB to parent class' method (for focus handling etc) - * only if line is empty. - * - * @param event the event. - * @return returns true if the event was recognized. - */ - virtual bool event(QEvent * event); + protected: + /** + * @brief Overrides method of parent class. + * Forward pressed TAB to parent class' method (for focus handling etc) + * only if line is empty. + * + * @param event the event. + * @return returns true if the event was recognized. + */ + virtual bool event(QEvent * event); - /** - * @brief Overrides method of parent class. - * Autocompletes if TAB is reported as pressed key in the key event, - * ESC leads to the contents being cleared. - * - * Other keys are forwarded to parent method. - * - * @param event the key event. - */ - virtual void keyPressEvent(QKeyEvent * event); + /** + * @brief Overrides method of parent class. + * Autocompletes if TAB is reported as pressed key in the key event, + * ESC leads to the contents being cleared. + * + * Other keys are forwarded to parent method. + * + * @param event the key event. + */ + virtual void keyPressEvent(QKeyEvent * event); -private: - QRegExp m_whitespace; ///< regexp that matches a whitespace + private: + QRegExp m_whitespace; ///< regexp that matches a whitespace - QStringList * m_cmds; ///< list of recognized commands - QStringList * m_nicks; ///< list of recognized nicknames + QStringList * m_cmds; ///< list of recognized commands + QStringList * m_nicks; ///< list of recognized nicknames - /// recognized nicknames, sorted case-insensitive - QMap * m_sorted_nicks; + /// recognized nicknames, sorted case-insensitive + QMap * m_sorted_nicks; - // these variables contain information about the last replacement - // they get reset whenever cursor is moved or text is changed + // these variables contain information about the last replacement + // they get reset whenever cursor is moved or text is changed - QString m_beforeMatch; ///< the string that was just matched - bool m_hasJustMatched; ///< whether this widget just did an auto-completion - QString m_prefix; ///< prefix of the text replacement this widget just did - QString m_postfix; ///< postfix of the text replacement this widget just did + QString m_beforeMatch; ///< the string that was just matched + bool m_hasJustMatched; ///< whether this widget just did an auto-completion + QString m_prefix; ///< prefix of the text replacement this widget just did + QString m_postfix; ///< postfix of the text replacement this widget just did - /** - * @brief Autocompletes the contents based on the known commands and/or names. - */ - void autoComplete(); + /** + * @brief Autocompletes the contents based on the known commands and/or names. + */ + void autoComplete(); -private slots: - /** - * @brief Resets the information about the last match and text replacement. - */ - void resetAutoCompletionStatus(); + private slots: + /** + * @brief Resets the information about the last match and text replacement. + */ + void resetAutoCompletionStatus(); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/SquareLabel.cpp --- a/QTfrontend/ui/widget/SquareLabel.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/SquareLabel.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ SquareLabel::SquareLabel(QWidget * parent) : QWidget(parent) { - if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); + //if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); } void SquareLabel::paintEvent(QPaintEvent * event) @@ -33,10 +33,13 @@ QPainter painter(this); int pixsize; - if (width() > height()) { + if (width() > height()) + { pixsize = height(); painter.translate((width() - pixsize) / 2, 0); - } else { + } + else + { pixsize = width(); painter.translate(0, (height() - pixsize) / 2); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/SquareLabel.h --- a/QTfrontend/ui/widget/SquareLabel.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/SquareLabel.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,17 +24,17 @@ class SquareLabel : public QWidget { - Q_OBJECT + Q_OBJECT -public: - SquareLabel(QWidget * parent = 0); + public: + SquareLabel(QWidget * parent = 0); - void setPixmap(const QPixmap & pixmap); -protected: - virtual void paintEvent(QPaintEvent * event); + void setPixmap(const QPixmap & pixmap); + protected: + virtual void paintEvent(QPaintEvent * event); -private: - QPixmap pixmap; + private: + QPixmap pixmap; }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/about.cpp --- a/QTfrontend/ui/widget/about.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/about.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ #include "about.h" About::About(QWidget * parent) : - QWidget(parent) + QWidget(parent) { QGridLayout *mainLayout = new QGridLayout(this); @@ -45,16 +45,16 @@ QLabel *lbl1 = new QLabel(this); lbl1->setOpenExternalLinks(true); lbl1->setText( - "" - "

    Hedgewars

    " - "

    " + QLabel::tr("Version") + " " + *cVersionString + "

    " - "

    http://www.hedgewars.org/


    " + - QLabel::tr("This program is distributed under the GNU General Public License v2") + - "
    " - ); + "" + "

    Hedgewars

    " + "

    " + QLabel::tr("Version") + " " + *cVersionString + "

    " + "

    http://www.hedgewars.org/


    " + + QLabel::tr("This program is distributed under the GNU General Public License v2") + + "
    " + ); lbl1->setWordWrap(true); mainLayout->addWidget(lbl1, 0, 1); @@ -62,33 +62,37 @@ lbl2->setOpenExternalLinks(true); lbl2->setText( - "" + - QString("

    ") + - QLabel::tr("Developers:") + - "

    " - "Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
    " - "Many frontend improvements: Igor Ulyanov <disinbox@gmail.com>
    " - "Many engine and frontend improvements: Derek Pomery <nemo@m8y.org>
    " - "Drill rocket, Ballgun, RC Plane weapons: Martin Boze <afffect@gmail.com>
    " - "Mine number and time game settings: David A. Cuadrado <krawek@gmail.com>
    " - "Frontend improvements: Martin Minarik <ttsmj@pokec.sk>
    " - "Frontend improvements: Kristian Lehmann <email@thexception.net>
    " - "Mac OS X/iPhone port, OpenGL-ES conversion: Vittorio Giovara <vittorio.giovara@gmail.com>
    " - "Many engine and frontend improvements (and bugs): Richard Karolyi <sheepluva@" "ercatec.net>
    " - "Gamepad and Lua integration: Mario Liebisch <mario.liebisch@gmail.com>
    " - "Many engine improvements and graphics: Carlos Vives <mail@carlosvives.es>
    " - "Maze maps: Henning Kühn <prg@cooco.de>
    " - "Engine and frontend improvements: Henrik Rostedt <henrik.rostedt@gmail.com>
    " - "Lua game modes and missions: John Lambert <redgrinner@gmail.com>
    " - "Frontend improvements: Mayur Pawashe <zorgiepoo@gmail.com>
    " - "Android port: Richard Deurwaarder <xeli@xelification.com>
    " - "

    " + + "" + + QString("

    ") + + QLabel::tr("Developers:") + + "

    " + "Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
    " + "Many frontend improvements: Igor Ulyanov <disinbox@gmail.com>
    " + "Many engine and frontend improvements: Derek Pomery <nemo@m8y.org>
    " + "Drill rocket, Ballgun, RC Plane weapons: Martin Boze <afffect@gmail.com>
    " + "Mine number and time game settings: David A. Cuadrado <krawek@gmail.com>
    " + "Frontend improvements: Martin Minarik <ttsmj@pokec.sk>
    " + "Frontend improvements: Kristian Lehmann <email@thexception.net>
    " + "Mac OS X/iPhone port, OpenGL-ES conversion: Vittorio Giovara <vittorio.giovara@gmail.com>
    " + "Many engine and frontend improvements (and bugs): Richard Karolyi <sheepluva@" "ercatec.net>
    " + "Gamepad and Lua integration: Mario Liebisch <mario.liebisch@gmail.com>
    " + "Many engine improvements and graphics: Carlos Vives <mail@carlosvives.es>
    " + "Maze maps: Henning Kühn <prg@cooco.de>
    " + "Engine and frontend improvements: Henrik Rostedt <henrik.rostedt@gmail.com>
    " + "Lua game modes and missions: John Lambert <redgrinner@gmail.com>
    " + "Frontend improvements: Mayur Pawashe <zorgiepoo@gmail.com>
    " + "Android port: Richard Deurwaarder <xeli@xelification.com>
    " + "Android netplay, portability abstraction: Simeon Maxein <smaxein@googlemail.com>
    " + "WebGL port, some pas2c and GLES2 work: Meng Xiangyun <xymengxy@gmail.com>
    " + "Video recording: Stepan Podoskin <stepik-777@mail.ru>
    " + "Campaign support, first campaign: Szabolcs Orbàn <szabibibi@gmail.com>
    " + "

    " + - QLabel::tr("Art:") + "

    " - + QString::fromUtf8( + QLabel::tr("Art:") + "" + + QString::fromUtf8( "

    John Dum <fizzy@gmail.com>" "
    " "Joshua Frese <joshfrese@gmail.com>" @@ -105,30 +109,30 @@ "
    " "Hats: Trey Perry <tx.perry.j@gmail.com>" "

    ") + - QLabel::tr("Sounds:") + "

    " - "Hedgehogs voice: Stephen Alexander <ArmagonNo1@gmail.com>" - "
    " - "John Dum <fizzy@gmail.com>" - "
    " - "Jonatan Nilsson <jonatanfan@gmail.com>" - "
    " - "Daniel Martin <elhombresinremedio@gmail.com>" - "

    " + + QLabel::tr("Sounds:") + "

    " + "Hedgehogs voice: Stephen Alexander <ArmagonNo1@gmail.com>" + "
    " + "John Dum <fizzy@gmail.com>" + "
    " + "Jonatan Nilsson <jonatanfan@gmail.com>" + "
    " + "Daniel Martin <elhombresinremedio@gmail.com>" + "

    " + - QLabel::tr("Translations:") + "

    " - + QString::fromUtf8( + QLabel::tr("Translations:") + "

    " + + QString::fromUtf8( "Brazilian Portuguese: Romulo Fernandes Machado <abra185@gmail.com>
    " "Bulgarian: Svetoslav Stefanov
    " "Czech: Petr Řezáček <rezacek@gmail.com>
    " "Chinese: Jie Luo <lililjlj@gmail.com>
    " "English: Andrey Korotaev <unC0Rr@gmail.com>
    " "Finnish: Nina Kuisma <ninnnu@gmail.com>
    " - "French: Antoine Turmel <geekshadow@gmail.com>
    " + "French: Antoine Turmel <geekshadow@gmail.com>, Clement Woitrain <sphrixclement@gmail.com>
    " "German: Peter Hüwe <PeterHuewe@gmx.de>, Mario Liebisch <mario.liebisch@gmail.com>, Richard Karolyi <sheepluva@" "ercatec.net>
    " "Greek: <talos_kriti@yahoo.gr>
    " "Italian: Luca Bonora <bonora.luca@gmail.com>, Marco Bresciani
    " "Japanese: ADAM Etienne <etienne.adam@gmail.com>
    " - "Korean: Anthony Bellew <webmaster@anthonybellew.com>
    " + "Korean: Anthony Bellew <anthonyreflected@gmail.com>
    " "Lithuanian: Lukas Urbonas <lukasu08@gmail.com>
    " "Polish: Maciej Mroziński <mynick2@o2.pl>, Wojciech Latkowski <magik17l@gmail.com>, Piotr Mitana, Maciej Górny
    " "Portuguese: Fábio Canário <inufabie@gmail.com>
    " @@ -139,13 +143,13 @@ "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>, Igor Paliychuk <mansonigor@gmail.com>, Eugene Sakara <eresid@gmail.com>" "

    ") + - QLabel::tr("Special thanks:") + "

    " - "Aleksey Andreev <blaknayabr@gmail.com>
    " - "Aleksander Rudalev <alexv@pomorsu.ru>
    " - "Natasha Korotaeva <layout@pisem.net>
    " - "Adam Higerd (aka ahigerd at FreeNode)" - "

    " - ); + QLabel::tr("Special thanks:") + "

    " + "Aleksey Andreev <blaknayabr@gmail.com>
    " + "Aleksander Rudalev <alexv@pomorsu.ru>
    " + "Natasha Korotaeva <layout@pisem.net>
    " + "Adam Higerd (aka ahigerd at FreeNode)" + "

    " + ); mainLayout->addWidget(lbl2, 1, 1); setAcceptDrops(true); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/about.h --- a/QTfrontend/ui/widget/about.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/about.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,17 +26,17 @@ class About : public QWidget { - Q_OBJECT + Q_OBJECT -public: - About(QWidget * parent = 0); + public: + About(QWidget * parent = 0); -protected: - virtual void dragEnterEvent(QDragEnterEvent * event); - virtual void dropEvent(QDropEvent * event); + protected: + virtual void dragEnterEvent(QDragEnterEvent * event); + virtual void dropEvent(QDropEvent * event); -private: - QTextBrowser * lbl2; + private: + QTextBrowser * lbl2; }; #endif // _ABOUT_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/bgwidget.cpp --- a/QTfrontend/ui/widget/bgwidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/bgwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Kristian Lehmann - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ */ #include "bgwidget.h" +#include "hwconsts.h" SpritePosition::SpritePosition(QWidget * parent, int sw, int sh) { @@ -82,10 +83,31 @@ fX = qrand() % (wParent->width() + 1); } -BGWidget::BGWidget(QWidget * parent) : QWidget(parent) +BGWidget::BGWidget(QWidget * parent) : QWidget(parent), enabled(false) { setAttribute(Qt::WA_NoSystemBackground, true); - sprite.load(":/res/Star.png"); + + QString fname; + + //For each season, there is a replacement for the star (Star.png) + //Todo: change element for easter and birthday + //Simply replace Confetti.png and Egg.png with an appropriate graphic) + switch (season) + { + case SEASON_CHRISTMAS : + fname = "Flake.png"; + break; + case SEASON_EASTER : + fname = "Egg.png"; + break; + case SEASON_HWBDAY : + fname = "Confetti.png"; + break; + default : + fname = "Star.png"; + } + + sprite.load(":/res/" + fname); setAutoFillBackground(false); @@ -100,7 +122,7 @@ QPainter p; p.begin(rotatedSprites[i]); - // p.setRenderHint(QPainter::Antialiasing); + // p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::SmoothPixmapTransform); p.translate(translate.x(), translate.y()); p.rotate(4 * i); @@ -123,6 +145,8 @@ void BGWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event); + if (!enabled) + return; QPainter p; @@ -139,6 +163,9 @@ void BGWidget::animate() { + if (!enabled) + return; + for (int i = 0; i < SPRITE_MAX; i++) { QPoint oldPos = spritePositions[i]->pos(); @@ -159,6 +186,7 @@ void BGWidget::stopAnimation() { timerAnimation->stop(); + repaint(); } void BGWidget::init() diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/bgwidget.h --- a/QTfrontend/ui/widget/bgwidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/bgwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Kristian Lehmann - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,44 +34,46 @@ class SpritePosition { -public: - SpritePosition(QWidget * parent, int sw, int sh); - ~SpritePosition(); -private: - float fX; - float fY; - float fXMov; - float fYMov; - int iAngle; - QWidget * wParent; - int iSpriteHeight; - int iSpriteWidth; -public: - void move(); - void reset(); - QPoint pos(); - int getAngle(); - void init(); + public: + SpritePosition(QWidget * parent, int sw, int sh); + ~SpritePosition(); + private: + float fX; + float fY; + float fXMov; + float fYMov; + int iAngle; + QWidget * wParent; + int iSpriteHeight; + int iSpriteWidth; + public: + void move(); + void reset(); + QPoint pos(); + int getAngle(); + void init(); }; class BGWidget : public QWidget { - Q_OBJECT -public: - BGWidget(QWidget * parent); - ~BGWidget(); - void startAnimation(); - void stopAnimation(); - void init(); -private: - QImage sprite; - QTimer * timerAnimation; - SpritePosition * spritePositions[SPRITE_MAX]; - QImage * rotatedSprites[360]; -protected: - void paintEvent(QPaintEvent * event); -private slots: - void animate(); + Q_OBJECT + public: + BGWidget(QWidget * parent); + ~BGWidget(); + void startAnimation(); + void stopAnimation(); + void init(); + bool enabled; + + private: + QImage sprite; + QTimer * timerAnimation; + SpritePosition * spritePositions[SPRITE_MAX]; + QImage * rotatedSprites[360]; + protected: + void paintEvent(QPaintEvent * event); + private slots: + void animate(); }; #endif // BGWIDGET_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/chatwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,88 +19,26 @@ #include #include -#include #include -#include #include -#include -#include #include #include #include -#include #include -#include #include #include - -#include +#include +#include +#include +#include - -#include "HWDataManager.h" +#include "DataManager.h" #include "hwconsts.h" #include "gameuiconfig.h" +#include "playerslistmodel.h" #include "chatwidget.h" -ListWidgetNickItem::ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored) : QListWidgetItem(nick) -{ - this->aFriend = isFriend; - this->isIgnored = isIgnored; -} - -void ListWidgetNickItem::setFriend(bool isFriend) -{ - this->aFriend = isFriend; -} - -void ListWidgetNickItem::setIgnored(bool isIgnored) -{ - this->isIgnored = isIgnored; -} - -bool ListWidgetNickItem::isFriend() -{ - return aFriend; -} - -bool ListWidgetNickItem::ignored() -{ - return isIgnored; -} - -bool ListWidgetNickItem::operator< (const QListWidgetItem & other) const -{ - // case in-sensitive comparison of the associated strings - // chars that are no letters are sorted at the end of the list - - ListWidgetNickItem otherNick = const_cast(dynamic_cast(other)); - - // ignored always down - if (isIgnored != otherNick.ignored()) - return !isIgnored; - - // friends always up - if (aFriend != otherNick.isFriend()) - return aFriend; - - QString txt1 = text().toLower(); - QString txt2 = other.text().toLower(); - - bool firstIsShorter = (txt1.size() < txt2.size()); - int len = firstIsShorter?txt1.size():txt2.size(); - - for (int i = 0; i < len; i++) - { - if (txt1[i] == txt2[i]) - continue; - if (txt1[i].isLetter() != txt2[i].isLetter()) - return txt1[i].isLetter(); - return (txt1[i] < txt2[i]); - } - - return firstIsShorter; -} QString * HWChatWidget::s_styleSheet = NULL; QStringList * HWChatWidget::s_displayNone = NULL; @@ -126,7 +64,7 @@ if (orgStyleSheet.isEmpty()) { // load external stylesheet if there is any - QFile extFile(HWDataManager::instance().findFileForRead("css/chat.css")); + QFile extFile(DataManager::instance().findFileForRead("css/chat.css")); QFile resFile(":/res/css/chat.css"); @@ -175,11 +113,11 @@ QRegExp nohierarchy("^.[^ .]+$"); QStringList victims = QString(style). - remove(displayed). // remove visible stuff - trimmed(). - split(split). // get a list of the names - filter(nohierarchy). // only direct class names - replaceInStrings(QRegExp("^."),""); // crop . + remove(displayed). // remove visible stuff + trimmed(). + split(split). // get a list of the names + filter(nohierarchy). // only direct class names + replaceInStrings(QRegExp("^."),""); // crop . if (victims.contains("timestamp")) @@ -240,21 +178,29 @@ HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : - QWidget(parent), - mainLayout(this) + QWidget(parent), + mainLayout(this) { this->gameSettings = gameSettings; this->notify = notify; + + m_isAdmin = false; + m_autoKickEnabled = false; + if(gameSettings->value("frontend/sound", true).toBool()) { - if (notify) - m_helloSound = HWDataManager::instance().findFileForRead( - "Sounds/voices/Classic/Hello.ogg"); + QStringList vpList = + QStringList() << "Classic" << "Default" << "Mobster" << "Russian"; - m_hilightSound = HWDataManager::instance().findFileForRead( - "Sounds/beep.ogg"); + foreach (QString vp, vpList) + { + m_helloSounds.append(DataManager::instance().findFileForRead( + QString("Sounds/voices/%1/Hello.ogg").arg(vp))); + } - //m_hilightSound = m_helloSound;//"Sounds/beep.ogg"; + m_hilightSound = DataManager::instance().findFileForRead( + "Sounds/beep.ogg"); + } mainLayout.setSpacing(1); @@ -278,19 +224,22 @@ chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); chatText->setOpenLinks(false); connect(chatText, SIGNAL(anchorClicked(const QUrl&)), - this, SLOT(linkClicked(const QUrl&))); + this, SLOT(linkClicked(const QUrl&))); mainLayout.addWidget(chatText, 0, 0, 2, 1); - chatNicks = new QListWidget(this); + chatNicks = new QListView(this); + chatNicks->setIconSize(QSize(24, 16)); + chatNicks->setSelectionMode(QAbstractItemView::SingleSelection); + chatNicks->setEditTriggers(QAbstractItemView::NoEditTriggers); chatNicks->setMinimumHeight(10); chatNicks->setMinimumWidth(10); - chatNicks->setSortingEnabled(true); chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), - this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); - connect(chatNicks, SIGNAL(currentRowChanged(int)), - this, SLOT(chatNickSelected(int))); + chatNicks->setContextMenuPolicy(Qt::CustomContextMenu); + + connect(chatNicks, SIGNAL(doubleClicked(QModelIndex)), + this, SLOT(chatNickDoubleClicked(QModelIndex))); + + connect(chatNicks, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(nicksContextMenuRequested(QPoint))); mainLayout.addWidget(chatNicks, 0, 1, 3, 1); @@ -325,10 +274,12 @@ chatNicks->insertAction(0, acInfo); chatNicks->insertAction(0, acIgnore); - showReady = false; setShowFollow(true); setAcceptDrops(true); + + m_nicksMenu = new QMenu(this); + clear(); } @@ -341,149 +292,41 @@ { // decode nick QString nick = QString::fromUtf8(QByteArray::fromBase64(link.encodedQuery())); - QList items = chatNicks->findItems(nick, Qt::MatchExactly); + QModelIndexList mil = chatNicks->model()->match(chatNicks->model()->index(0, 0), Qt::DisplayRole, nick); - bool isOffline = (items.size() < 1); - - QMenu * popup = new QMenu(this); + bool isOffline = (mil.size() < 1); if (isOffline) { m_clickedNick = nick; - chatNickSelected(0); // update friend and ignore entry - chatNicks->setCurrentItem(NULL, QItemSelectionModel::Clear); + chatNicks->selectionModel()->clearSelection(); } else { - // selecting an item will automatically scroll there, so let's save old position - QScrollBar * scrollBar = chatNicks->verticalScrollBar(); - int oldScrollPos = scrollBar->sliderPosition(); - // select the nick which we want to see the actions for - chatNicks->setCurrentItem(items[0], QItemSelectionModel::Clear); - // selecting an item will automatically scroll there, so let's save old position - scrollBar->setSliderPosition(oldScrollPos); + chatNicks->selectionModel()->select(mil[0], QItemSelectionModel::ClearAndSelect); } - // load actions - QList actions = chatNicks->actions(); - - foreach(QAction * action, actions) - { - if ((!isOffline) || (action->data().toBool())) - popup->addAction(action); - } - - // display menu popup at mouse cursor position - popup->popup(QCursor::pos()); + nicksContextMenuRequested(chatNicks->mapFromGlobal(QCursor::pos())); } } void HWChatWidget::setShowFollow(bool enabled) { - if (enabled) { + if (enabled) + { if (!(chatNicks->actions().contains(acFollow))) chatNicks->insertAction(acFriend, acFollow); } - else { + else + { if (chatNicks->actions().contains(acFollow)) chatNicks->removeAction(acFollow); } } -void HWChatWidget::loadList(QStringList & list, const QString & file) -{ - list.clear(); - QFile txt(cfgdir->absolutePath() + "/" + file); - if(!txt.open(QIODevice::ReadOnly)) - return; - QTextStream stream(&txt); - stream.setCodec("UTF-8"); - - while(!stream.atEnd()) - { - QString str = stream.readLine(); - if(str.startsWith(";") || str.length() == 0) - continue; - list << str.trimmed(); - } - //readd once we require newer Qt than 4.4 - //list.removeDuplicates(); - txt.close(); -} - -void HWChatWidget::saveList(QStringList & list, const QString & file) +void HWChatWidget::setIgnoreListKick(bool enabled) { - QFile txt(cfgdir->absolutePath() + "/" + file); - - // list empty? => rather have no file for the list than an empty one - if (list.isEmpty()) - { - if (txt.exists()) - { - // try to remove file, if successful we're done here. - if (txt.remove()) - return; - } - else - // there is no file - return; - } - - if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) - return; - QTextStream stream(&txt); - stream.setCodec("UTF-8"); - - stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; - for(int i = 0; i < list.size(); i++) - stream << list[i] << endl; - txt.close(); -} - -void HWChatWidget::updateNickItem(QListWidgetItem *nickItem) -{ - QString nick = nickItem->text(); - ListWidgetNickItem * item = dynamic_cast(nickItem); - - item->setFriend(friendsList.contains(nick, Qt::CaseInsensitive)); - item->setIgnored(ignoreList.contains(nick, Qt::CaseInsensitive)); - - if(item->ignored()) - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on.png" : ":/res/chat_ignore_off.png") : ":/res/chat_ignore.png")); - item->setForeground(Qt::gray); - } - else if(item->isFriend()) - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on.png" : ":/res/chat_friend_off.png") : ":/res/chat_friend.png")); - item->setForeground(Qt::green); - } - else - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on.png" : ":/res/chat_default_off.png") : ":/res/chat_default.png")); - item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00))); - } -} - -void HWChatWidget::updateNickItems() -{ - for(int i = 0; i < chatNicks->count(); i++) - updateNickItem(chatNicks->item(i)); - - chatNicks->sortItems(); -} - -void HWChatWidget::loadLists(const QString & nick) -{ - loadList(ignoreList, nick.toLower() + "_ignore.txt"); - loadList(friendsList, nick.toLower() + "_friends.txt"); - updateNickItems(); -} - -void HWChatWidget::saveLists(const QString & nick) -{ - saveList(ignoreList, nick.toLower() + "_ignore.txt"); - saveList(friendsList, nick.toLower() + "_friends.txt"); + m_autoKickEnabled = enabled; } @@ -510,7 +353,7 @@ { if (nickname != m_userNick) return QString("%2").arg( - QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); + QString(nickname.toUtf8().toBase64())).arg(Qt::escape(nickname)); // unlinked nick (if own one) return QString("%1").arg(Qt::escape(nickname)); @@ -526,16 +369,24 @@ void HWChatWidget::onChatString(const QString& nick, const QString& str) { - bool isFriend = false; + QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); + if(!playersSortFilterModel) + return; + + PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); - if (!nick.isEmpty()) { + if(!players) + return; + + if (!nick.isEmpty()) + { // don't show chat lines that are from ignored nicks - if (ignoreList.contains(nick, Qt::CaseInsensitive)) + if (players->isFlagSet(nick, PlayersListModel::Ignore)) return; - // friends will get special treatment, of course - isFriend = friendsList.contains(nick, Qt::CaseInsensitive); } + bool isFriend = (!nick.isEmpty()) && players->isFlagSet(nick, PlayersListModel::Friend); + QString formattedStr = Qt::escape(str.mid(1)); // make hedgewars.org urls actual links formattedStr = formattedStr.replace(URLREGEXP, "\\3"); @@ -564,7 +415,7 @@ bool isHL = false; if ((c != 3) && (!nick.isEmpty()) && - (nick != m_userNick) && (!m_userNick.isEmpty())) + (nick != m_userNick) && (!m_userNick.isEmpty())) { QString lcStr = str.toLower(); @@ -623,20 +474,35 @@ chatText->moveCursor(QTextCursor::End); } + void HWChatWidget::nickAdded(const QString & nick, bool notifyNick) { - bool isIgnored = ignoreList.contains(nick, Qt::CaseInsensitive); - QListWidgetItem * item = new ListWidgetNickItem(nick, friendsList.contains(nick, Qt::CaseInsensitive), isIgnored); - updateNickItem(item); - chatNicks->addItem(item); + QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); + if(!playersSortFilterModel) + return; + + PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); + + if(!players) + return; + + bool isIgnored = players->isFlagSet(nick, PlayersListModel::Ignore); + + if (isIgnored && m_isAdmin && m_autoKickEnabled) + { + emit kick(nick); + return; + } if ((!isIgnored) && (nick != m_userNick)) // don't auto-complete own name chatEditLine->addNickname(nick); - emit nickCountUpdate(chatNicks->count()); + emit nickCountUpdate(chatNicks->model()->rowCount()); - if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) { - SDLInteraction::instance().playSoundFile(m_helloSound); + if(notifyNick && notify && gameSettings->value("frontend/sound", true).toBool()) + { + SDLInteraction::instance().playSoundFile( + m_helloSounds.at(rand() % m_helloSounds.size())); } } @@ -644,10 +510,7 @@ { chatEditLine->removeNickname(nick); - foreach(QListWidgetItem * item, chatNicks->findItems(nick, Qt::MatchExactly)) - chatNicks->takeItem(chatNicks->row(item)); - - emit nickCountUpdate(chatNicks->count()); + emit nickCountUpdate(chatNicks->model()->rowCount()); } void HWChatWidget::clear() @@ -661,7 +524,7 @@ chatText->clear(); chatStrings.clear(); - chatNicks->clear(); + //chatNicks->clear(); // clear and re compile regexp for highlighting m_highlights.clear(); @@ -683,7 +546,7 @@ foreach (QString word, list) { m_highlights.append(QRegExp( - hlRegExp.arg(QRegExp::escape(word.toLower())))); + hlRegExp.arg(QRegExp::escape(word.toLower())))); } } @@ -708,184 +571,135 @@ void HWChatWidget::onKick() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - { - displayNotice(tr("Kicking %1 ...").arg(Qt::escape(curritem->text()))); - emit kick(curritem->text()); - } + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + if(mil.size()) + emit kick(mil[0].data().toString()); } void HWChatWidget::onBan() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit ban(curritem->text()); + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + if(mil.size()) + emit ban(mil[0].data().toString()); } void HWChatWidget::onInfo() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit info(curritem->text()); + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + if(mil.size()) + emit info(mil[0].data().toString()); } void HWChatWidget::onFollow() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit follow(curritem->text()); + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + if(mil.size()) + emit follow(mil[0].data().toString()); } void HWChatWidget::onIgnore() { - QListWidgetItem * curritem = chatNicks->currentItem(); - QString nick = ""; - if(curritem != NULL) - nick = curritem->text(); + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + QString nick; + if(mil.size()) + nick = mil[0].data().toString(); else nick = m_clickedNick; - if(ignoreList.contains(nick, Qt::CaseInsensitive)) // already on list - remove him + QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); + if(!playersSortFilterModel) + return; + + PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); + + if(!players) + return; + + if(players->isFlagSet(nick, PlayersListModel::Ignore)) { - ignoreList.removeAll(nick.toLower()); + players->setFlag(nick, PlayersListModel::Ignore, false); chatEditLine->addNickname(nick); displayNotice(tr("%1 has been removed from your ignore list").arg(linkedNick(nick))); } else // not on list - add { // don't consider ignored people friends - if(friendsList.contains(nick, Qt::CaseInsensitive)) + if(players->isFlagSet(nick, PlayersListModel::Friend)) emit onFriend(); - // scroll down on first ignore added so that people see where that nick went to - if (ignoreList.isEmpty()) - chatNicks->scrollToBottom(); - - ignoreList << nick.toLower(); + players->setFlag(nick, PlayersListModel::Ignore, true); chatEditLine->removeNickname(nick); displayNotice(tr("%1 has been added to your ignore list").arg(linkedNick(nick))); } - if(curritem != NULL) - { - updateNickItem(curritem); // update icon/sort order/etc - chatNicks->sortItems(); - chatNickSelected(0); // update context menu - } + if(mil.size()) + chatNicks->scrollTo(chatNicks->selectionModel()->selectedRows()[0]); } void HWChatWidget::onFriend() { - QListWidgetItem * curritem = chatNicks->currentItem(); - QString nick = ""; - if(curritem != NULL) - nick = curritem->text(); + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + QString nick; + if(mil.size()) + nick = mil[0].data().toString(); else nick = m_clickedNick; - if(friendsList.contains(nick, Qt::CaseInsensitive)) // already on list - remove him + QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); + if(!playersSortFilterModel) + return; + + PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); + + if(!players) + return; + + if(players->isFlagSet(nick, PlayersListModel::Friend)) { - friendsList.removeAll(nick.toLower()); + players->setFlag(nick, PlayersListModel::Friend, false); + chatEditLine->removeNickname(nick); displayNotice(tr("%1 has been removed from your friends list").arg(linkedNick(nick))); } else // not on list - add { - // don't ignore the new friend - if(ignoreList.contains(nick, Qt::CaseInsensitive)) + if(players->isFlagSet(nick, PlayersListModel::Ignore)) emit onIgnore(); - // scroll up on first friend added so that people see where that nick went to - if (friendsList.isEmpty()) - chatNicks->scrollToTop(); - - friendsList << nick.toLower(); + players->setFlag(nick, PlayersListModel::Friend, true); + chatEditLine->addNickname(nick); displayNotice(tr("%1 has been added to your friends list").arg(linkedNick(nick))); } - if(curritem != NULL) - { - updateNickItem(curritem); // update icon/sort order/etc - chatNicks->sortItems(); - chatNickSelected(0); // update context menu - } + if(mil.size()) + chatNicks->scrollTo(chatNicks->selectionModel()->selectedRows()[0]); } -void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item) +void HWChatWidget::chatNickDoubleClicked(const QModelIndex &index) { - if (item != NULL) - m_clickedNick = item->text(); - else - m_clickedNick = ""; + m_clickedNick = index.data().toString(); + QList actions = chatNicks->actions(); actions.first()->activate(QAction::Trigger); } -void HWChatWidget::chatNickSelected(int index) -{ - Q_UNUSED(index); - - QListWidgetItem* item = chatNicks->currentItem(); - QString nick = ""; - if (item != NULL) - nick = item->text(); - else - nick = m_clickedNick; - - // update context menu labels according to possible action - if(ignoreList.contains(nick, Qt::CaseInsensitive)) - { - acIgnore->setText(QAction::tr("Unignore")); - acIgnore->setIcon(QIcon(":/res/unignore.png")); - } - else - { - acIgnore->setText(QAction::tr("Ignore")); - acIgnore->setIcon(QIcon(":/res/ignore.png")); - } - - if(friendsList.contains(nick, Qt::CaseInsensitive)) - { - acFriend->setText(QAction::tr("Remove friend")); - acFriend->setIcon(QIcon(":/res/remfriend.png")); - } - else - { - acFriend->setText(QAction::tr("Add friend")); - acFriend->setIcon(QIcon(":/res/addfriend.png")); - } -} - -void HWChatWidget::setShowReady(bool s) -{ - showReady = s; -} - -void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) -{ - QList items = chatNicks->findItems(nick, Qt::MatchExactly); - if (items.size() != 1) - { - qWarning("Bug: cannot find user in chat"); - return; - } - - items[0]->setData(Qt::UserRole, isReady); // bulb status - updateNickItem(items[0]); - - // ensure we're still showing the status bulbs - showReady = true; -} void HWChatWidget::adminAccess(bool b) { chatNicks->removeAction(acKick); chatNicks->removeAction(acBan); + m_isAdmin = b; + if(b) { chatNicks->insertAction(0, acKick); -// chatNicks->insertAction(0, acBan); + chatNicks->insertAction(0, acBan); } } @@ -949,7 +763,7 @@ void HWChatWidget::saveStyleSheet() { QString dest = - HWDataManager::instance().findFileForWrite("css/chat.css"); + DataManager::instance().findFileForWrite("css/chat.css"); QFile file(dest); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -1006,3 +820,75 @@ nickRemoved(nickname); clear(); } + + +void HWChatWidget::setUsersModel(QAbstractItemModel *model) +{ + chatNicks->selectionModel()->deleteLater(); + + chatNicks->setModel(model); + chatNicks->setModelColumn(0); +} + +void HWChatWidget::nicksContextMenuRequested(const QPoint &pos) +{ + QModelIndexList mil = chatNicks->selectionModel()->selectedRows(); + + QString nick; + + if(mil.size()) + nick = mil[0].data().toString(); + else + nick = m_clickedNick; + + QSortFilterProxyModel * playersSortFilterModel = qobject_cast(chatNicks->model()); + if(!playersSortFilterModel) + return; + + PlayersListModel * players = qobject_cast(playersSortFilterModel->sourceModel()); + + if(!players) + return; + + bool isSelf = (nick == m_userNick); + + acFollow->setVisible(!isSelf); + + // update context menu labels according to possible action + if(players->isFlagSet(nick, PlayersListModel::Ignore)) + { + acIgnore->setText(QAction::tr("Unignore")); + acIgnore->setIcon(QIcon(":/res/unignore.png")); + } + else + { + acIgnore->setText(QAction::tr("Ignore")); + acIgnore->setIcon(QIcon(":/res/ignore.png")); + acIgnore->setVisible(!isSelf); + } + + if(players->isFlagSet(nick, PlayersListModel::Friend)) + { + acFriend->setText(QAction::tr("Remove friend")); + acFriend->setIcon(QIcon(":/res/remfriend.png")); + } + else + { + acFriend->setText(QAction::tr("Add friend")); + acFriend->setIcon(QIcon(":/res/addfriend.png")); + acFriend->setVisible(!isSelf); + } + + if (m_isAdmin) + { + acKick->setVisible(!isSelf); + acBan->setVisible(!isSelf); + } + + m_nicksMenu->clear(); + + foreach(QAction * action, chatNicks->actions()) + m_nicksMenu->addAction(action); + + m_nicksMenu->popup(chatNicks->mapToGlobal(pos)); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/chatwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,39 +21,24 @@ #define _CHAT_WIDGET_INCLUDED #include -#include #include #include #include #include #include +#include +#include #include "SDLInteraction.h" #include "SmartLineEdit.h" -class ListWidgetNickItem; class QTextBrowser; class QLineEdit; -class QListWidget; +class QListView; class QSettings; - -/// Class for custom nickname sorting -class ListWidgetNickItem : public QListWidgetItem -{ -public: - ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); - bool operator<(const QListWidgetItem & other) const; - void setFriend(bool isFriend); - void setIgnored(bool isIgnored); - bool isFriend(); - bool ignored(); - -private: - bool aFriend; - bool isIgnored; -}; - +class QAbstractItemModel; +class QMenu; /** * @brief Chat widget. @@ -66,94 +51,89 @@ class HWChatWidget : public QWidget { - Q_OBJECT + Q_OBJECT - public: - HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); - void loadLists(const QString & nick); - void saveLists(const QString & nick); - void setShowReady(bool s); - void setShowFollow(bool enabled); - QStringList ignoreList, friendsList; - static const QString & styleSheet(); - void displayError(const QString & message); - void displayNotice(const QString & message); - void displayWarning(const QString & message); - void setUser(const QString & nickname); + public: + HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); + void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible) + void setShowFollow(bool enabled); + static const QString & styleSheet(); + void displayError(const QString & message); + void displayNotice(const QString & message); + void displayWarning(const QString & message); + void setUser(const QString & nickname); + void setUsersModel(QAbstractItemModel * model); -protected: - virtual void dragEnterEvent(QDragEnterEvent * event); - virtual void dropEvent(QDropEvent * event); + protected: + virtual void dragEnterEvent(QDragEnterEvent * event); + virtual void dropEvent(QDropEvent * event); -private: - static QString * s_styleSheet; - static QStringList * s_displayNone; - static bool s_isTimeStamped; - static QString s_tsFormat; - static const QRegExp URLREGEXP; + private: + static QString * s_styleSheet; + static QStringList * s_displayNone; + static bool s_isTimeStamped; + static QString s_tsFormat; + static const QRegExp URLREGEXP; - static void setStyleSheet(const QString & styleSheet = ""); + static void setStyleSheet(const QString & styleSheet = ""); - void loadList(QStringList & list, const QString & file); - void saveList(QStringList & list, const QString & file); - void updateNickItem(QListWidgetItem *item); - void updateNickItems(); - void addLine(const QString & cssClass, QString line, bool isHighlight = false); - bool parseCommand(const QString & line); - void discardStyleSheet(); - void saveStyleSheet(); - QString linkedNick(const QString & nickname); + void addLine(const QString & cssClass, QString line, bool isHighlight = false); + bool parseCommand(const QString & line); + void discardStyleSheet(); + void saveStyleSheet(); + QString linkedNick(const QString & nickname); + + public slots: + void onChatString(const QString& str); + void onChatString(const QString& nick, const QString& str); + void onServerMessage(const QString& str); + void nickAdded(const QString& nick, bool notifyNick); + void nickRemoved(const QString& nick); + void clear(); + void adminAccess(bool); - public slots: - void onChatString(const QString& str); - void onChatString(const QString& nick, const QString& str); - void onServerMessage(const QString& str); - void nickAdded(const QString& nick, bool notifyNick); - void nickRemoved(const QString& nick); - void clear(); - void setReadyStatus(const QString & nick, bool isReady); - void adminAccess(bool); - - signals: - void chatLine(const QString& str); - void kick(const QString & str); - void ban(const QString & str); - void info(const QString & str); - void follow(const QString &); - void nickCountUpdate(int cnt); + signals: + void chatLine(const QString& str); + void kick(const QString & str); + void ban(const QString & str); + void info(const QString & str); + void follow(const QString &); + void nickCountUpdate(int cnt); - private: - QGridLayout mainLayout; - QTextBrowser* chatText; - QStringList chatStrings; - QListWidget* chatNicks; - SmartLineEdit* chatEditLine; - QAction * acInfo; - QAction * acKick; - QAction * acBan; - QAction * acFollow; - QAction * acIgnore; - QAction * acFriend; - QSettings * gameSettings; - QString m_helloSound; - QString m_hilightSound; - QString m_userNick; - QString m_clickedNick; - QList m_highlights; ///< regular expressions used for highlighting - bool notify; - bool showReady; + private: + bool m_isAdmin; + QGridLayout mainLayout; + QTextBrowser* chatText; + QStringList chatStrings; + QListView* chatNicks; + SmartLineEdit* chatEditLine; + QAction * acInfo; + QAction * acKick; + QAction * acBan; + QAction * acFollow; + QAction * acIgnore; + QAction * acFriend; + QSettings * gameSettings; + QMenu * m_nicksMenu; + QStringList m_helloSounds; + QString m_hilightSound; + QString m_userNick; + QString m_clickedNick; + QList m_highlights; ///< regular expressions used for highlighting + bool notify; + bool m_autoKickEnabled; - private slots: - void returnPressed(); - void onBan(); - void onKick(); - void onInfo(); - void onFollow(); - void onIgnore(); - void onFriend(); - void chatNickDoubleClicked(QListWidgetItem * item); - void chatNickSelected(int index); - void linkClicked(const QUrl & link); + private slots: + void returnPressed(); + void onBan(); + void onKick(); + void onInfo(); + void onFollow(); + void onIgnore(); + void onFriend(); + void chatNickDoubleClicked(const QModelIndex & index); + void linkClicked(const QUrl & link); + void nicksContextMenuRequested(const QPoint & pos); }; #endif // _CHAT_WIDGET_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/colorwidget.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/colorwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,84 @@ +#include +#include +#include +#include + +#include "colorwidget.h" +#include "hwconsts.h" + +ColorWidget::ColorWidget(QStandardItemModel *colorsModel, QWidget *parent) : + QFrame(parent) +{ + m_colorsModel = colorsModel; + + setColor(0); + setAutoFillBackground(true); + + connect(m_colorsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); +} + +ColorWidget::~ColorWidget() +{ + +} + +void ColorWidget::setColor(int color) +{ + Q_ASSERT_X(color >= 0 && color < m_colorsModel->rowCount(), "ColorWidget::setColor", "Color index out of range"); + + m_color = color; + + QStandardItem * item = m_colorsModel->item(m_color); + + setStyleSheet(QString("border: 2px solid orange; border-radius: 8px; background: %1").arg(item->data().value().name())); + /* + QPalette p = palette(); + p.setColor(QPalette::Window, item->data().value()); + setPalette(p); + */ + + emit colorChanged(m_color); +} + +int ColorWidget::getColor() +{ + return m_color; +} + +void ColorWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + if(m_color >= topLeft.row() && m_color <= bottomRight.row()) + setColor(m_color); +} + +void ColorWidget::mousePressEvent(QMouseEvent * event) +{ + switch(event->button()) + { + case Qt::LeftButton: + nextColor(); + break; + case Qt::RightButton: + previousColor(); + break; + default:; + } +} + +void ColorWidget::wheelEvent(QWheelEvent *event) +{ + if(event->delta() > 0) + previousColor(); + else + nextColor(); +} + +void ColorWidget::nextColor() +{ + setColor((m_color + 1) % m_colorsModel->rowCount()); +} + +void ColorWidget::previousColor() +{ + setColor((m_color + m_colorsModel->rowCount() - 1) % m_colorsModel->rowCount()); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/colorwidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/colorwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,42 @@ +#ifndef COLORWIDGET_H +#define COLORWIDGET_H + +#include +#include + +namespace Ui { +class ColorWidget; +} + +class QStandardItemModel; + +class ColorWidget : public QFrame +{ + Q_OBJECT + +public: + explicit ColorWidget(QStandardItemModel *colorsModel, QWidget *parent = 0); + ~ColorWidget(); + + void setColors(QStandardItemModel * colorsModel); + void setColor(int color); + int getColor(); + +signals: + void colorChanged(int color); + +private: + int m_color; + QStandardItemModel * m_colorsModel; + +private slots: + void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + +protected: + void mousePressEvent(QMouseEvent * event); + void wheelEvent(QWheelEvent * event); + void nextColor(); + void previousColor(); +}; + +#endif // COLORWIDGET_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/databrowser.cpp --- a/QTfrontend/ui/widget/databrowser.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/databrowser.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,3 +1,26 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief DataBrowser class implementation + */ + #include #include #include @@ -24,19 +47,18 @@ { return resources.take(name.toString()); } - else - if(!requestedResources.contains(name.toString())) - { - qDebug() << "Requesting resource" << name.toString(); - requestedResources.insert(name.toString()); + else if(!requestedResources.contains(name.toString())) + { + qDebug() << "Requesting resource" << name.toString(); + requestedResources.insert(name.toString()); - QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + name.toString())); - newRequest.setAttribute(typeAttribute, type); - newRequest.setAttribute(urlAttribute, name); + QNetworkRequest newRequest(QUrl("http://www.hedgewars.org" + name.toString())); + newRequest.setAttribute(typeAttribute, type); + newRequest.setAttribute(urlAttribute, name); - QNetworkReply *reply = manager->get(newRequest); - connect(reply, SIGNAL(finished()), this, SLOT(resourceDownloaded())); - } + QNetworkReply *reply = manager->get(newRequest); + connect(reply, SIGNAL(finished()), this, SLOT(resourceDownloaded())); + } } return QVariant(); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/databrowser.h --- a/QTfrontend/ui/widget/databrowser.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/databrowser.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,5 +1,28 @@ -#ifndef DATABROWSER_H -#define DATABROWSER_H +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief DataBrowser class definition + */ + +#ifndef HEDGEWARS_DATABROWSER_H +#define HEDGEWARS_DATABROWSER_H #include #include @@ -8,26 +31,26 @@ class DataBrowser : public QTextBrowser { - Q_OBJECT -public: - explicit DataBrowser(QWidget *parent = 0); + Q_OBJECT + public: + explicit DataBrowser(QWidget *parent = 0); -signals: + signals: -public slots: + public slots: -private: - QNetworkAccessManager *manager; - - // hash and set of QString instead of QUrl to support Qt versions - // older than 4.7 (those have no support for qHash(const QUrl &)) - QHash resources; - QSet requestedResources; + private: + QNetworkAccessManager *manager; - QVariant loadResource(int type, const QUrl & name); + // hash and set of QString instead of QUrl to support Qt versions + // older than 4.7 (those have no support for qHash(const QUrl &)) + QHash resources; + QSet requestedResources; -private slots: - void resourceDownloaded(); + QVariant loadResource(int type, const QUrl & name); + + private slots: + void resourceDownloaded(); }; -#endif // DATABROWSER_H +#endif // HEDGEWARS_DATABROWSER_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/drawmapwidget.cpp --- a/QTfrontend/ui/widget/drawmapwidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/drawmapwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include #include #include +#include #include "drawmapwidget.h" @@ -39,19 +40,22 @@ void DrawMapWidget::changeEvent(QEvent *e) { QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; } } void DrawMapWidget::setScene(DrawMapScene * scene) { + m_scene = scene; + ui->graphicsView->setScene(scene); - m_scene = scene; + connect(scene, SIGNAL(pathChanged()), this, SLOT(pathChanged())); } void DrawMapWidget::resizeEvent(QResizeEvent * event) @@ -79,6 +83,11 @@ if(m_scene) m_scene->clearMap(); } +void DrawMapWidget::setErasing(bool erasing) +{ + if(m_scene) m_scene->setErasing(erasing); +} + void DrawMapWidget::save(const QString & fileName) { if(m_scene) @@ -86,7 +95,14 @@ QFile file(fileName); if(!file.open(QIODevice::WriteOnly)) - QMessageBox::warning(this, tr("File error"), tr("Cannot open file '%1' for writing").arg(fileName)); + { + QMessageBox errorMsg(this); + errorMsg.setIcon(QMessageBox::Warning); + errorMsg.setWindowTitle(QMessageBox::tr("File error")); + errorMsg.setText(QMessageBox::tr("Cannot open '%1' for writing").arg(fileName)); + errorMsg.setWindowModality(Qt::WindowModal); + errorMsg.exec(); + } else file.write(qCompress(m_scene->encode()).toBase64()); } @@ -99,8 +115,65 @@ QFile f(fileName); if(!f.open(QIODevice::ReadOnly)) - QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName)); + { + QMessageBox errorMsg(this); + errorMsg.setIcon(QMessageBox::Warning); + errorMsg.setWindowTitle(QMessageBox::tr("File error")); + errorMsg.setText(QMessageBox::tr("Cannot open '%1' for reading").arg(fileName)); + errorMsg.setWindowModality(Qt::WindowModal); + errorMsg.exec(); + } else m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll()))); } } + +void DrawMapWidget::pathChanged() +{ + ui->lblPoints->setNum(m_scene->pointsCount()); +} + + + +DrawMapView::DrawMapView(QWidget *parent) : + QGraphicsView(parent) +{ + setMouseTracking(true); + + m_scene = 0; +} + + +DrawMapView::~DrawMapView() +{ + +} + +void DrawMapView::setScene(DrawMapScene *scene) +{ + m_scene = scene; + + QGraphicsView::setScene(scene); +} + +// Why don't I ever recieve this event? +void DrawMapView::enterEvent(QEvent *event) +{ + if(m_scene) + m_scene->showCursor(); + + QGraphicsView::enterEvent(event); +} + +void DrawMapView::leaveEvent(QEvent *event) +{ + if(m_scene) + m_scene->hideCursor(); + + QGraphicsView::leaveEvent(event); +} + +bool DrawMapView::viewportEvent(QEvent *event) +{ + return QGraphicsView::viewportEvent(event); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/drawmapwidget.h --- a/QTfrontend/ui/widget/drawmapwidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/drawmapwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,33 +23,61 @@ #include #include #include +#include #include "qaspectratiolayout.h" #include "drawmapscene.h" -namespace Ui { + +class DrawMapView : public QGraphicsView +{ + Q_OBJECT + +public: + explicit DrawMapView(QWidget *parent = 0); + ~DrawMapView(); + + void setScene(DrawMapScene *scene); + +protected: + void enterEvent(QEvent * event); + void leaveEvent(QEvent * event); + bool viewportEvent(QEvent * event); + +private: + DrawMapScene * m_scene; +}; + +namespace Ui +{ class Ui_DrawMapWidget { - public: - QGraphicsView *graphicsView; - - void setupUi(QWidget *drawMapWidget) - { - QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget); - arLayout->setMargin(0); + public: + DrawMapView *graphicsView; + QLabel * lblPoints; - graphicsView = new QGraphicsView(drawMapWidget); - arLayout->addWidget(graphicsView); - - retranslateUi(drawMapWidget); + void setupUi(QWidget *drawMapWidget) + { + QVBoxLayout * vbox = new QVBoxLayout(drawMapWidget); + vbox->setMargin(0); + lblPoints = new QLabel("0", drawMapWidget); + vbox->addWidget(lblPoints); + QAspectRatioLayout * arLayout = new QAspectRatioLayout(); + arLayout->setMargin(0); + vbox->addLayout(arLayout); - QMetaObject::connectSlotsByName(drawMapWidget); - } // setupUi + graphicsView = new DrawMapView(drawMapWidget); + arLayout->addWidget(graphicsView); + + retranslateUi(drawMapWidget); - void retranslateUi(QWidget *drawMapWidget) - { - Q_UNUSED(drawMapWidget); - } // retranslateUi + QMetaObject::connectSlotsByName(drawMapWidget); + } // setupUi + + void retranslateUi(QWidget *drawMapWidget) + { + Q_UNUSED(drawMapWidget); + } // retranslateUi }; @@ -58,29 +86,33 @@ class DrawMapWidget : public QWidget { - Q_OBJECT + Q_OBJECT -public: - explicit DrawMapWidget(QWidget *parent = 0); - ~DrawMapWidget(); + public: + explicit DrawMapWidget(QWidget *parent = 0); + ~DrawMapWidget(); - void setScene(DrawMapScene * scene); + void setScene(DrawMapScene * scene); -public slots: - void undo(); - void clear(); - void save(const QString & fileName); - void load(const QString & fileName); + public slots: + void undo(); + void clear(); + void setErasing(bool erasing); + void save(const QString & fileName); + void load(const QString & fileName); -protected: - void changeEvent(QEvent *e); - virtual void resizeEvent(QResizeEvent * event); - virtual void showEvent(QShowEvent * event); + protected: + void changeEvent(QEvent *e); + virtual void resizeEvent(QResizeEvent * event); + virtual void showEvent(QShowEvent * event); -private: - Ui::DrawMapWidget *ui; + private: + Ui::DrawMapWidget *ui; - DrawMapScene * m_scene; + DrawMapScene * m_scene; + + private slots: + void pathChanged(); }; #endif // DRAWMAPWIDGET_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/fpsedit.cpp --- a/QTfrontend/ui/widget/fpsedit.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/fpsedit.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/fpsedit.h --- a/QTfrontend/ui/widget/fpsedit.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/fpsedit.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,13 +23,13 @@ class FPSEdit : public QSpinBox { - Q_OBJECT + Q_OBJECT -public: - FPSEdit(QWidget * parent = 0); + public: + FPSEdit(QWidget * parent = 0); -protected: - QString textFromValue (int value) const; + protected: + QString textFromValue (int value) const; }; #endif // _FPSEDIT_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/frameTeam.cpp --- a/QTfrontend/ui/widget/frameTeam.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/frameTeam.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,13 +20,15 @@ #include #include #include +#include #include "frameTeam.h" #include "teamselhelper.h" #include "hwconsts.h" +#include "DataManager.h" FrameTeams::FrameTeams(QWidget* parent) : - QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) + QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); @@ -36,17 +38,15 @@ mainLayout.setSpacing(1); mainLayout.setContentsMargins(4, 4, 4, 4); - int i = 0; - while(colors[i] != 0) - availableColors.push_back(QColor(colors[i++])); - resetColors(); + this->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); } void FrameTeams::setInteractivity(bool interactive) { nonInteractive = !interactive; - for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) { + for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) + { TeamShowWidget* pts = dynamic_cast(it.value()); if(!pts) throw; pts->setInteractivity(interactive); @@ -55,74 +55,82 @@ void FrameTeams::resetColors() { - currentColor=availableColors.end() - 1; // ensure next color is the first one + currentColor = DataManager::instance().colorsModel()->rowCount() - 1; // ensure next color is the first one } -QColor FrameTeams::getNextColor() const +int FrameTeams::getNextColor() { - QList::ConstIterator nextColor=currentColor; - ++nextColor; - if (nextColor==availableColors.end()) nextColor=availableColors.begin(); - return *nextColor; + currentColor = (currentColor + 1) % DataManager::instance().colorsModel()->rowCount(); + return currentColor; } void FrameTeams::addTeam(HWTeam team, bool willPlay) { - TeamShowWidget* pTeamShowWidget = new TeamShowWidget(team, willPlay, this); - if(nonInteractive) pTeamShowWidget->setInteractivity(false); + TeamShowWidget* pTeamShowWidget = new TeamShowWidget(team, willPlay, this); + if(nonInteractive) pTeamShowWidget->setInteractivity(false); // int hght=teamToWidget.empty() ? 0 : teamToWidget.begin()->second->size().height(); - mainLayout.addWidget(pTeamShowWidget); - teamToWidget.insert(team, pTeamShowWidget); - QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); - QCoreApplication::postEvent(parentWidget(), pevent); + mainLayout.addWidget(pTeamShowWidget); + teamToWidget.insert(team, pTeamShowWidget); + QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); + QCoreApplication::postEvent(parentWidget(), pevent); } void FrameTeams::removeTeam(HWTeam team) { - tmapTeamToWidget::iterator it=teamToWidget.find(team); - if(it==teamToWidget.end()) return; - mainLayout.removeWidget(it.value()); - it.value()->deleteLater(); - teamToWidget.erase(it); + tmapTeamToWidget::iterator it=teamToWidget.find(team); + if(it==teamToWidget.end()) return; + mainLayout.removeWidget(it.value()); + it.value()->deleteLater(); + teamToWidget.erase(it); + QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); + QCoreApplication::postEvent(parentWidget(), pevent); } void FrameTeams::resetTeams() { - for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ) { - mainLayout.removeWidget(it.value()); - it.value()->deleteLater(); - teamToWidget.erase(it++); - } + for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ) + { + mainLayout.removeWidget(it.value()); + it.value()->deleteLater(); + teamToWidget.erase(it++); + } + QResizeEvent* pevent=new QResizeEvent(parentWidget()->size(), parentWidget()->size()); + QCoreApplication::postEvent(parentWidget(), pevent); } void FrameTeams::setHHNum(const HWTeam& team) { - TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team)); - if(!pTeamShowWidget) return; - pTeamShowWidget->setHHNum(team.numHedgehogs()); + TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team)); + if(!pTeamShowWidget) return; + pTeamShowWidget->setHHNum(team.numHedgehogs()); } void FrameTeams::setTeamColor(const HWTeam& team) { - TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team)); - if(!pTeamShowWidget) return; - pTeamShowWidget->changeTeamColor(team.color()); + TeamShowWidget* pTeamShowWidget = dynamic_cast(getTeamWidget(team)); + if(!pTeamShowWidget) return; + pTeamShowWidget->changeTeamColor(team.color()); } QWidget* FrameTeams::getTeamWidget(HWTeam team) { //qDebug() << "FrameTeams::getTeamWidget getNetID() = " << team.getNetID(); - tmapTeamToWidget::iterator it=teamToWidget.find(team); - QWidget* ret = it!=teamToWidget.end() ? it.value() : 0; - return ret; + tmapTeamToWidget::iterator it=teamToWidget.find(team); + QWidget* ret = it!=teamToWidget.end() ? it.value() : 0; + return ret; } bool FrameTeams::isFullTeams() const { - return overallHedgehogs==maxHedgehogsPerGame; + return overallHedgehogs==maxHedgehogsPerGame; } void FrameTeams::emitTeamColorChanged(const HWTeam& team) { - emit teamColorChanged(team); + emit teamColorChanged(team); } + +QSize FrameTeams::sizeHint() const +{ + return QSize(-1, teamToWidget.size() * 39 + 9); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/frameTeam.h --- a/QTfrontend/ui/widget/frameTeam.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/frameTeam.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,41 +28,41 @@ class FrameTeams : public QFrame { - Q_OBJECT + Q_OBJECT - friend class CHedgehogerWidget; - friend class TeamShowWidget; + friend class CHedgehogerWidget; + friend class TeamShowWidget; - public: - FrameTeams(QWidget* parent=0); - QWidget* getTeamWidget(HWTeam team); - bool isFullTeams() const; - void resetColors(); - void resetTeams(); - void setHHNum(const HWTeam& team); - void setTeamColor(const HWTeam& team); - void setInteractivity(bool interactive); - QColor getNextColor() const; + public: + FrameTeams(QWidget* parent=0); + QWidget* getTeamWidget(HWTeam team); + bool isFullTeams() const; + void resetColors(); + void resetTeams(); + void setHHNum(const HWTeam& team); + void setTeamColor(const HWTeam& team); + void setInteractivity(bool interactive); + int getNextColor(); + QSize sizeHint() const; - signals: - void teamColorChanged(const HWTeam&); + signals: + void teamColorChanged(const HWTeam&); - public slots: - void addTeam(HWTeam team, bool willPlay); - void removeTeam(HWTeam team); + public slots: + void addTeam(HWTeam team, bool willPlay); + void removeTeam(HWTeam team); - private: - const int maxHedgehogsPerGame; - int overallHedgehogs; - QList availableColors; - QList::Iterator currentColor; + private: + const int maxHedgehogsPerGame; + int overallHedgehogs; + int currentColor; - void emitTeamColorChanged(const HWTeam& team); + void emitTeamColorChanged(const HWTeam& team); - QVBoxLayout mainLayout; - typedef QMap tmapTeamToWidget; - tmapTeamToWidget teamToWidget; - bool nonInteractive; + QVBoxLayout mainLayout; + typedef QMap tmapTeamToWidget; + tmapTeamToWidget teamToWidget; + bool nonInteractive; }; #endif // _FRAME_TAM_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/gamecfgwidget.cpp --- a/QTfrontend/ui/widget/gamecfgwidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/gamecfgwidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,15 +28,16 @@ #include "gamecfgwidget.h" #include "igbox.h" -#include "HWDataManager.h" +#include "DataManager.h" #include "hwconsts.h" #include "ammoSchemeModel.h" #include "proto.h" +#include "GameStyleModel.h" GameCFGWidget::GameCFGWidget(QWidget* parent) : - QGroupBox(parent) - , mainLayout(this) - , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") + QGroupBox(parent) + , mainLayout(this) + , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") { mainLayout.setMargin(0); // mainLayout.setSizeConstraint(QLayout::SetMinimumSize); @@ -56,39 +57,8 @@ Scripts = new QComboBox(GBoxOptions); GBoxOptionsLayout->addWidget(Scripts, 1, 1); - Scripts->addItem("Normal"); - Scripts->insertSeparator(1); - - for (int i = 0; i < scriptList->size(); ++i) { - QString script = (*scriptList)[i].remove(".lua", Qt::CaseInsensitive); - QList scriptInfo; - scriptInfo.push_back(script); - QFile scriptCfgFile(HWDataManager::instance().findFileForRead( - QString("Scripts/Multiplayer/%2.cfg").arg(script))); - if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly)) { - QString scheme; - QString weapons; - QTextStream input(&scriptCfgFile); - input >> scheme; - input >> weapons; - if (scheme.isEmpty()) - scheme = "locked"; - scheme.replace("_", " "); - if (weapons.isEmpty()) - weapons = "locked"; - weapons.replace("_", " "); - scriptInfo.push_back(scheme); - scriptInfo.push_back(weapons); - scriptCfgFile.close(); - } - else - { - scriptInfo.push_back("locked"); - scriptInfo.push_back("locked"); - } - Scripts->addItem(script.replace("_", " "), scriptInfo); - } - + Scripts->setModel(DataManager::instance().gameStyleModel()); + m_curScript = Scripts->currentText(); connect(Scripts, SIGNAL(currentIndexChanged(int)), this, SLOT(scriptChanged(int))); QWidget *SchemeWidget = new QWidget(GBoxOptions); @@ -104,7 +74,7 @@ SchemeWidgetLayout->addWidget(new QLabel(QLabel::tr("Scheme"), SchemeWidget), 0, 0); QPixmap pmEdit(":/res/edit.png"); - + QPushButton * goToSchemePage = new QPushButton(SchemeWidget); goToSchemePage->setToolTip(tr("Edit schemes")); goToSchemePage->setIconSize(pmEdit.size()); @@ -144,6 +114,8 @@ connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); connect(pMapContainer, SIGNAL(drawMapRequested()), this, SIGNAL(goToDrawMap())); connect(pMapContainer, SIGNAL(drawnMapChanged(const QByteArray &)), this, SLOT(onDrawnMapChanged(const QByteArray &))); + + connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); } void GameCFGWidget::jumpToSchemes() @@ -228,6 +200,10 @@ { QList bcfg; int mapgen = pMapContainer->get_mapgen(); + if (Scripts->currentIndex() > 0) + { + bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex(), GameStyleModel::ScriptRole).toString()).toUtf8(); + } QString currentMap = pMapContainer->getCurrentMap(); if (currentMap.size() > 0) @@ -240,11 +216,6 @@ } bcfg << QString("etheme " + pMapContainer->getCurrentTheme()).toUtf8(); - if (Scripts->currentIndex() > 0) - { - bcfg << QString("escript Scripts/Multiplayer/%1.lua").arg(Scripts->itemData(Scripts->currentIndex()).toList()[0].toString()).toUtf8(); - } - bcfg << QString("eseed " + pMapContainer->getCurrentSeed()).toUtf8(); bcfg << QString("e$gmflags %1").arg(getGameFlags()).toUtf8(); bcfg << QString("e$damagepct %1").arg(schemeData(26).toInt()).toUtf8(); @@ -283,13 +254,14 @@ } break; } - default: ; + default: + ; } QByteArray result; foreach(QByteArray ba, bcfg) - HWProto::addByteArrayToBuffer(result, ba); + HWProto::addByteArrayToBuffer(result, ba); return result; } @@ -298,13 +270,23 @@ { bool illegal = ammo.size() != cDefaultAmmoStore->size(); if (illegal) - QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme")); + { + QMessageBox illegalMsg(this); + illegalMsg.setIcon(QMessageBox::Warning); + illegalMsg.setWindowTitle(QMessageBox::tr("Error")); + illegalMsg.setText(QMessageBox::tr("Cannot use the ammo '%1'!").arg(name)); + illegalMsg.setWindowModality(Qt::WindowModal); + illegalMsg.exec(); + } int pos = WeaponsName->findText(name); - if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones + if ((pos == -1) || illegal) // prevent from overriding schemes with bad ones + { WeaponsName->addItem(name, ammo); WeaponsName->setCurrentIndex(WeaponsName->count() - 1); - } else { + } + else + { WeaponsName->setItemData(pos, ammo); WeaponsName->setCurrentIndex(pos); } @@ -335,38 +317,47 @@ if (slValue.size() == 1) { QString value = slValue[0]; - if (param == "MAP") { + if (param == "MAP") + { pMapContainer->setMap(value); return; } - if (param == "SEED") { + if (param == "SEED") + { pMapContainer->setSeed(value); - if (!seedRegexp.exactMatch(value)) { + if (!seedRegexp.exactMatch(value)) + { pMapContainer->seedEdit->setVisible(true); - } + } return; } - if (param == "THEME") { + if (param == "THEME") + { pMapContainer->setTheme(value); return; } - if (param == "TEMPLATE") { + if (param == "TEMPLATE") + { pMapContainer->setTemplateFilter(value.toUInt()); return; } - if (param == "MAPGEN") { + if (param == "MAPGEN") + { pMapContainer->setMapgen((MapGenerator)value.toUInt()); return; } - if (param == "MAZE_SIZE") { + if (param == "MAZE_SIZE") + { pMapContainer->setMazeSize(value.toUInt()); return; } - if (param == "SCRIPT") { + if (param == "SCRIPT") + { Scripts->setCurrentIndex(Scripts->findText(value)); return; } - if (param == "DRAWNMAP") { + if (param == "DRAWNMAP") + { pMapContainer->setDrawnMapData(qUncompress(QByteArray::fromBase64(slValue[0].toLatin1()))); return; } @@ -374,7 +365,8 @@ if (slValue.size() == 2) { - if (param == "AMMO") { + if (param == "AMMO") + { setNetAmmo(slValue[0], slValue[1]); return; } @@ -389,12 +381,12 @@ pMapContainer->seedEdit->setVisible(true); pMapContainer->setAllMapParameters( - slValue[0], - (MapGenerator)slValue[1].toUInt(), - slValue[2].toUInt(), - seed, - slValue[4].toUInt() - ); + slValue[0], + (MapGenerator)slValue[1].toUInt(), + slValue[2].toUInt(), + seed, + slValue[4].toUInt() + ); return; } } @@ -404,7 +396,8 @@ void GameCFGWidget::ammoChanged(int index) { - if (index >= 0) { + if (index >= 0) + { emit paramChanged( "AMMO", QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString() @@ -487,28 +480,34 @@ for(int i = 0; i < size; ++i) sl << schemeData(i).toString(); - emit paramChanged("SCHEME", sl); + if (sl.size()!=1) emit paramChanged("SCHEME", sl); // this is a stupid hack for the fact that SCHEME is being sent once, empty. Still need to find out why. - if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) { + if (isEnabled() && bindEntries->isEnabled() && bindEntries->isChecked()) + { QString schemeName = GameSchemes->itemText(index); - for (int i = 0; i < WeaponsName->count(); i++) { - QString weapName = WeaponsName->itemText(i); - int res = QString::compare(weapName, schemeName, Qt::CaseSensitive); - if (0 == res) { - WeaponsName->setCurrentIndex(i); - emit ammoChanged(i); - break; - } + for (int i = 0; i < WeaponsName->count(); i++) + { + QString weapName = WeaponsName->itemText(i); + int res = QString::compare(weapName, schemeName, Qt::CaseSensitive); + if (0 == res) + { + WeaponsName->setCurrentIndex(i); + emit ammoChanged(i); + break; + } } } } void GameCFGWidget::scriptChanged(int index) { + const QString & name = Scripts->itemText(index); + m_curScript = name; + if(isEnabled() && index > 0) { - QString scheme = Scripts->itemData(Scripts->currentIndex()).toList()[1].toString(); - QString weapons = Scripts->itemData(Scripts->currentIndex()).toList()[2].toString(); + QString scheme = Scripts->itemData(index, GameStyleModel::SchemeRole).toString(); + QString weapons = Scripts->itemData(index, GameStyleModel::WeaponsRole).toString(); if (scheme == "locked") { @@ -551,7 +550,7 @@ WeaponsName->setEnabled(true); bindEntries->setEnabled(true); } - emit paramChanged("SCRIPT", QStringList(Scripts->itemText(index))); + emit paramChanged("SCRIPT", QStringList(name)); } void GameCFGWidget::mapgenChanged(MapGenerator m) @@ -573,3 +572,17 @@ { emit paramChanged("DRAWNMAP", QStringList(qCompress(data, 9).toBase64())); } + + +void GameCFGWidget::updateModelViews() +{ + // restore game-style selection + if (!m_curScript.isEmpty()) + { + int idx = Scripts->findText(m_curScript); + if (idx >= 0) + Scripts->setCurrentIndex(idx); + else + Scripts->setCurrentIndex(0); + } +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/gamecfgwidget.h --- a/QTfrontend/ui/widget/gamecfgwidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/gamecfgwidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,53 +34,55 @@ class GameCFGWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT -public: - GameCFGWidget(QWidget* parent); - quint32 getGameFlags() const; - quint32 getInitHealth() const; - QByteArray getFullConfig() const; - QComboBox * Scripts; - QComboBox * GameSchemes; - QComboBox * WeaponsName; - HWMapContainer* pMapContainer; - QTableView * tv; - QVariant schemeData(int column) const; + public: + GameCFGWidget(QWidget* parent); + quint32 getGameFlags() const; + quint32 getInitHealth() const; + QByteArray getFullConfig() const; + QComboBox * Scripts; + QComboBox * GameSchemes; + QComboBox * WeaponsName; + HWMapContainer* pMapContainer; + QTableView * tv; + QVariant schemeData(int column) const; -public slots: - void setParam(const QString & param, const QStringList & value); - void fullNetConfig(); - void resendSchemeData(); + public slots: + void setParam(const QString & param, const QStringList & value); + void fullNetConfig(); + void resendSchemeData(); + + signals: + void paramChanged(const QString & param, const QStringList & value); + void goToSchemes(int); + void goToWeapons(int); + void goToDrawMap(); -signals: - void paramChanged(const QString & param, const QStringList & value); - void goToSchemes(int); - void goToWeapons(int); - void goToDrawMap(); + private slots: + void ammoChanged(int index); + void mapChanged(const QString &); + void templateFilterChanged(int); + void seedChanged(const QString &); + void themeChanged(const QString &); + void schemeChanged(int); + void scriptChanged(int); + void jumpToSchemes(); + void jumpToWeapons(); + void mapgenChanged(MapGenerator m); + void maze_sizeChanged(int s); + void onDrawnMapChanged(const QByteArray & data); + void updateModelViews(); -private slots: - void ammoChanged(int index); - void mapChanged(const QString &); - void templateFilterChanged(int); - void seedChanged(const QString &); - void themeChanged(const QString &); - void schemeChanged(int); - void scriptChanged(int); - void jumpToSchemes(); - void jumpToWeapons(); - void mapgenChanged(MapGenerator m); - void maze_sizeChanged(int s); - void onDrawnMapChanged(const QByteArray & data); + private: + QGridLayout mainLayout; + QCheckBox * bindEntries; + QString curNetAmmoName; + QString curNetAmmo; + QRegExp seedRegexp; + QString m_curScript; -private: - QGridLayout mainLayout; - QCheckBox * bindEntries; - QString curNetAmmoName; - QString curNetAmmo; - QRegExp seedRegexp; - - void setNetAmmo(const QString& name, const QString& ammo); + void setNetAmmo(const QString& name, const QString& ammo); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/hedgehogerWidget.cpp --- a/QTfrontend/ui/widget/hedgehogerWidget.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/hedgehogerWidget.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Ulyanov Igor - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,58 +19,93 @@ #include "hedgehogerWidget.h" +#include + #include "frameTeam.h" CHedgehogerWidget::CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent) : ItemNum(im, img, parent, 1) { - // TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now - /*if(parent) { - pOurFrameTeams = dynamic_cast(parent->parentWidget()); - } - if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) { - numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs; - } else numItems = 4; - pOurFrameTeams->overallHedgehogs += numItems;*/ + // TODO: maxHedgehogsPerGame doesn't reset properly and won't match map limits for now + /*if(parent) { + pOurFrameTeams = dynamic_cast(parent->parentWidget()); + } + if(pOurFrameTeams->overallHedgehogs + 4 > pOurFrameTeams->maxHedgehogsPerGame) { + numItems = pOurFrameTeams->maxHedgehogsPerGame - pOurFrameTeams->overallHedgehogs; + } else numItems = 4; + pOurFrameTeams->overallHedgehogs += numItems;*/ + + this->setMinimumWidth(48); } void CHedgehogerWidget::incItems() { - //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) { + //if (pOurFrameTeams->overallHedgehogs < pOurFrameTeams->maxHedgehogsPerGame) { numItems++; //pOurFrameTeams->overallHedgehogs++; emit hedgehogsNumChanged(); - //} + //} } void CHedgehogerWidget::decItems() { - numItems--; - //pOurFrameTeams->overallHedgehogs--; - emit hedgehogsNumChanged(); + numItems--; + //pOurFrameTeams->overallHedgehogs--; + emit hedgehogsNumChanged(); } CHedgehogerWidget::~CHedgehogerWidget() { - // TODO: not called? - //pOurFrameTeams->overallHedgehogs-=numItems; + // TODO: not called? + //pOurFrameTeams->overallHedgehogs-=numItems; } void CHedgehogerWidget::setNonInteractive() { - nonInteractive=true; + nonInteractive=true; } void CHedgehogerWidget::setHHNum(unsigned int num) { - /*unsigned int diff = num - numItems; - numItems += diff; - pOurFrameTeams->overallHedgehogs += diff;*/ - numItems = num; - repaint(); + /*unsigned int diff = num - numItems; + numItems += diff; + pOurFrameTeams->overallHedgehogs += diff;*/ + numItems = num; + repaint(); } unsigned char CHedgehogerWidget::getHedgehogsNum() const { - return numItems; + return numItems; } + +void CHedgehogerWidget::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + + if (this->width() >= 11 * numItems + 26) + ItemNum::paintEvent(event); + else + { + int width = this->width() - 38; + QPainter painter(this); + + for(int i=0; iwidth() - 12, 23, QString::number(numItems)); + +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/hedgehogerWidget.h --- a/QTfrontend/ui/widget/hedgehogerWidget.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/hedgehogerWidget.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Ulyanov Igor - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,25 +26,27 @@ class CHedgehogerWidget : public ItemNum { - Q_OBJECT + Q_OBJECT - public: - CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent); - virtual ~CHedgehogerWidget(); - unsigned char getHedgehogsNum() const; - void setHHNum (unsigned int num); - void setNonInteractive(); + public: + CHedgehogerWidget(const QImage& im, const QImage& img, QWidget * parent); + virtual ~CHedgehogerWidget(); + unsigned char getHedgehogsNum() const; + void setHHNum (unsigned int num); + void setNonInteractive(); - signals: - void hedgehogsNumChanged(); + signals: + void hedgehogsNumChanged(); - protected: - virtual void incItems(); - virtual void decItems(); + protected: + virtual void incItems(); + virtual void decItems(); - private: - CHedgehogerWidget(); - FrameTeams* pOurFrameTeams; + virtual void paintEvent(QPaintEvent* event); + + private: + CHedgehogerWidget(); + FrameTeams* pOurFrameTeams; }; #endif // _HEDGEHOGER_WIDGET diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/igbox.cpp --- a/QTfrontend/ui/widget/igbox.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/igbox.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,27 +29,27 @@ // Has issues with border-radius on children // setAttribute(Qt::WA_PaintOnScreen, true); titleLeftPadding = 49; - contentTopPadding = 15; + contentTopPadding = 5; } void IconedGroupBox::setIcon(const QIcon & icon) { if (this->icon.isNull()) setStyleSheet(QString( - "IconedGroupBox{" - "margin-top: 46px;" - "margin-left: 12px;" - "padding: %1px 2px 5px 2px;" - "}" - "IconedGroupBox::title{" - "subcontrol-origin: margin;" - "subcontrol-position: top left;" - "padding-left: %2px;" - "padding-top: %1px;" - "text-align: left;" - "}" - ).arg(contentTopPadding).arg(titleLeftPadding) - ); + "IconedGroupBox{" + "margin-top: 46px;" + "margin-left: 12px;" + "padding: %1px 2px 5px 2px;" + "}" + "IconedGroupBox::title{" + "subcontrol-origin: margin;" + "subcontrol-position: top left;" + "padding-left: %2px;" + "padding-top: 15px;" + "text-align: left;" + "}" + ).arg(contentTopPadding).arg(titleLeftPadding) + ); this->icon = icon; repaint(); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/igbox.h --- a/QTfrontend/ui/widget/igbox.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/igbox.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,21 +24,21 @@ class IconedGroupBox : public QGroupBox { - Q_OBJECT + Q_OBJECT -public: - IconedGroupBox(QWidget * parent = 0); + public: + IconedGroupBox(QWidget * parent = 0); - void setIcon(const QIcon & icon); - void setTitleTextPadding(int px); - void setContentTopPadding(int px); -protected: - virtual void paintEvent(QPaintEvent * event); + void setIcon(const QIcon & icon); + void setTitleTextPadding(int px); + void setContentTopPadding(int px); + protected: + virtual void paintEvent(QPaintEvent * event); -private: - QIcon icon; - int titleLeftPadding; - int contentTopPadding; + private: + QIcon icon; + int titleLeftPadding; + int contentTopPadding; }; #endif // _IGBOX_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/itemNum.cpp --- a/QTfrontend/ui/widget/itemNum.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/itemNum.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Igor Ulyanov + * Copyright (c) 2006-2012 Igor Ulyanov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,11 +23,11 @@ #include ItemNum::ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min, unsigned char max) : - QFrame(parent), m_im(im), m_img(img), infinityState(false), nonInteractive(false), minItems(min), maxItems(max), - numItems(min+2 >= max ? min : min+2) + QFrame(parent), m_im(im), m_img(img), infinityState(false), nonInteractive(false), minItems(min), maxItems(max), + numItems(min+2 >= max ? min : min+2) { enabled = true; - if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); + //if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); } ItemNum::~ItemNum() @@ -36,29 +36,40 @@ void ItemNum::mousePressEvent ( QMouseEvent * event ) { - if(nonInteractive) return; - if(event->button()==Qt::LeftButton && enabled) { - event->accept(); - if((infinityState && numItems <= maxItems) || (!infinityState && numItems < maxItems)) { - incItems(); - } else { - numItems = minItems+1; - // appears there's an emit in there - decItems(); + if(nonInteractive) return; + if(event->button()==Qt::LeftButton && enabled) + { + event->accept(); + if((infinityState && numItems <= maxItems) || (!infinityState && numItems < maxItems)) + { + incItems(); + } + else + { + numItems = minItems+1; + // appears there's an emit in there + decItems(); + } } - } else if (event->button()==Qt::RightButton && enabled) { - event->accept(); - if(numItems > minItems) { - decItems(); - } else { - numItems = maxItems+(infinityState?0:-1); - incItems(); + else if (event->button()==Qt::RightButton && enabled) + { + event->accept(); + if(numItems > minItems) + { + decItems(); + } + else + { + numItems = maxItems+(infinityState?0:-1); + incItems(); + } } - } else { - event->ignore(); - return; - } - repaint(); + else + { + event->ignore(); + return; + } + repaint(); } void ItemNum::wheelEvent ( QWheelEvent * event ) { @@ -86,57 +97,67 @@ if(numItems > minItems) decItems(); } - repaint(); + repaint(); } QSize ItemNum::sizeHint () const { - return QSize((maxItems+1)*12, 32); + return QSize((maxItems+1)*12, 32); } void ItemNum::paintEvent(QPaintEvent* event) { - Q_UNUSED(event); + Q_UNUSED(event); - QPainter painter(this); + QPainter painter(this); - if (numItems==maxItems+1) { - QRect target(0, 0, 100, 32); - if (enabled) { - painter.drawImage(target, QImage(":/res/infinity.png")); - } else { - painter.drawImage(target, QImage(":/res/infinitygrey.png")); + if (numItems==maxItems+1) + { + QRect target(0, 0, 100, 32); + if (enabled) + { + painter.drawImage(target, QImage(":/res/infinity.png")); + } + else + { + painter.drawImage(target, QImage(":/res/infinitygrey.png")); + } } - } else { - for(int i=0; i + * Copyright (c) 2006-2012 Igor Ulyanov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,38 +24,37 @@ class ItemNum : public QFrame { - Q_OBJECT + Q_OBJECT - public: - void setInfinityState(bool value); - void setEnabled(bool value); - unsigned char getItemsNum() const; - void setItemsNum(const unsigned char num); + public: + void setInfinityState(bool value); + void setEnabled(bool value); + unsigned char getItemsNum() const; + void setItemsNum(const unsigned char num); - private: - QImage m_im; - QImage m_img; - bool infinityState; - bool enabled; + protected: + QImage m_im; + QImage m_img; + bool infinityState; + bool enabled; - protected: - ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min=2, unsigned char max=8); - virtual QSize sizeHint () const; - virtual ~ItemNum()=0; + ItemNum(const QImage& im, const QImage& img, QWidget * parent, unsigned char min=2, unsigned char max=8); + virtual QSize sizeHint () const; + virtual ~ItemNum()=0; + + bool nonInteractive; + unsigned char minItems; + unsigned char maxItems; + unsigned char numItems; - bool nonInteractive; - unsigned char minItems; - unsigned char maxItems; - unsigned char numItems; + // from QWidget + virtual void mousePressEvent ( QMouseEvent * event ); + virtual void wheelEvent ( QWheelEvent * event ); + virtual void paintEvent(QPaintEvent* event); - // from QWidget - virtual void mousePressEvent ( QMouseEvent * event ); - virtual void wheelEvent ( QWheelEvent * event ); - virtual void paintEvent(QPaintEvent* event); - - // to be implemented in child - virtual void incItems()=0; - virtual void decItems()=0; + // to be implemented in child + virtual void incItems()=0; + virtual void decItems()=0; }; #endif // _ITEM_NUM_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/mapContainer.cpp --- a/QTfrontend/ui/widget/mapContainer.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/mapContainer.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Igor Ulyanov + * Copyright (c) 2006-2012 Igor Ulyanov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,28 +29,33 @@ #include #include #include -#include #include #include "hwconsts.h" #include "mapContainer.h" #include "igbox.h" #include "HWApplication.h" +#include "ThemeModel.h" HWMapContainer::HWMapContainer(QWidget * parent) : QWidget(parent), mainLayout(this), pMap(0), - mapgen(MAPGEN_REGULAR) + mapgen(MAPGEN_REGULAR), + m_previewSize(256, 128) { hhSmall.load(":/res/hh_small.png"); hhLimit = 18; templateFilter = 0; + linearGrad = QLinearGradient(QPoint(128, 0), QPoint(128, 128)); + linearGrad.setColorAt(1, QColor(0, 0, 192)); + linearGrad.setColorAt(0, QColor(66, 115, 225)); + mainLayout.setContentsMargins(HWApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), - 1, - HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), - HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + 1, + HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), + HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); QWidget* mapWidget = new QWidget(this); mainLayout.addWidget(mapWidget, 0, 0, Qt::AlignHCenter); @@ -68,99 +73,10 @@ chooseMap = new QComboBox(mapWidget); chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - chooseMap->addItem( -// FIXME - need real icons. Disabling until then -//QIcon(":/res/mapRandom.png"), -QComboBox::tr("generated map...")); - chooseMap->addItem( -// FIXME - need real icons. Disabling until then -//QIcon(":/res/mapMaze.png"), -QComboBox::tr("generated maze...")); - - chooseMap->addItem(QComboBox::tr("hand drawn map...")); - chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions - - chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions - - int missionindex = chooseMap->count(); - numMissions = 0; - QFile mapLuaFile; - QFile mapCfgFile; - for (int i = 0; i < mapList->size(); ++i) { - QString map = (*mapList)[i]; - mapCfgFile.setFileName( - QString("%1/Data/Maps/%2/map.cfg") - .arg(cfgdir->absolutePath()) - .arg(map)); - if (mapCfgFile.exists()) { - mapLuaFile.setFileName( - QString("%1/Data/Maps/%2/map.lua") - .arg(cfgdir->absolutePath()) - .arg(map)); - } else { - mapCfgFile.setFileName( - QString("%1/Maps/%2/map.cfg") - .arg(datadir->absolutePath()) - .arg(map)); - mapLuaFile.setFileName( - QString("%1/Maps/%2/map.lua") - .arg(datadir->absolutePath()) - .arg(map)); - } + m_mapModel = DataManager::instance().mapModel(); + chooseMap->setEditable(false); + chooseMap->setModel(m_mapModel); - if (mapCfgFile.open(QFile::ReadOnly)) { - QString theme; - quint32 limit = 0; - QString scheme; - QString weapons; - QList mapInfo; - bool isMission = mapLuaFile.exists(); - - QTextStream input(&mapCfgFile); - input >> theme; - input >> limit; - input >> scheme; - input >> weapons; - mapInfo.push_back(map); - mapInfo.push_back(theme); - if (limit) - mapInfo.push_back(limit); - else - mapInfo.push_back(18); - - - mapInfo.push_back(isMission); - - if (scheme.isEmpty()) - scheme = "locked"; - scheme.replace("_", " "); - - if (weapons.isEmpty()) - weapons = "locked"; - weapons.replace("_", " "); - - mapInfo.push_back(scheme); - mapInfo.push_back(weapons); - - if(isMission) - { - chooseMap->insertItem(missionindex++, -// FIXME - need real icons. Disabling until then -//QIcon(":/res/mapMission.png"), -QComboBox::tr("Mission") + ": " + map, mapInfo); - numMissions++; - } - else - chooseMap->addItem( -// FIXME - need real icons. Disabling until then -//QIcon(":/res/mapCustom.png"), -map, mapInfo); - mapCfgFile.close(); - } - } - chooseMap->insertSeparator(missionindex); // separator between missions and maps - - connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int))); mapLayout->addWidget(chooseMap, 1, 1); QLabel * lblMap = new QLabel(tr("Map"), mapWidget); @@ -203,14 +119,16 @@ //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon mapLayout->addWidget(gbThemes, 0, 2, 3, 1); - + // disallow row to be collapsed (so it can't get ignored when Qt applies rowSpan of gbThemes) + mapLayout->setRowMinimumHeight(2, 13); QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); gbTLayout->setContentsMargins(0, 0, 0 ,0); gbTLayout->setSpacing(0); lvThemes = new QListView(mapWidget); lvThemes->setMinimumHeight(30); lvThemes->setFixedWidth(140); - lvThemes->setModel(themesModel); + m_themeModel = DataManager::instance().themeModel(); + lvThemes->setModel(m_themeModel); lvThemes->setIconSize(QSize(16, 16)); lvThemes->setEditTriggers(QListView::NoEditTriggers); @@ -218,17 +136,17 @@ // override default style to tighten up theme scroller lvThemes->setStyleSheet(QString( - "QListView{" - "border: solid;" - "border-width: 0px;" - "border-radius: 0px;" - "border-color: transparent;" - "background-color: #0d0544;" - "color: #ffcc00;" - "font: bold 13px;" - "}" - ) - ); + "QListView{" + "border: solid;" + "border-width: 0px;" + "border-radius: 0px;" + "border-color: transparent;" + "background-color: #0d0544;" + "color: #ffcc00;" + "font: bold 13px;" + "}" + ) + ); gbTLayout->addWidget(lvThemes); lvThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); @@ -259,22 +177,28 @@ setRandomSeed(); setRandomTheme(); + + chooseMap->setCurrentIndex(0); + mapChanged(0); + // use signal "activated" rather than currentIndexChanged + // because index is somtimes changed a few times in a row programmatically + connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int))); + + // update model views after model changes (to e.g. re-adjust separators) + connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); } void HWMapContainer::setImage(const QImage newImage) { - QPixmap px(256, 128); - QPixmap pxres(256, 128); + QPixmap px(m_previewSize); + QPixmap pxres(px.size()); QPainter p(&pxres); px.fill(Qt::yellow); QBitmap bm = QBitmap::fromImage(newImage); px.setMask(bm); - QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); - linearGrad.setColorAt(1, QColor(0, 0, 192)); - linearGrad.setColorAt(0, QColor(66, 115, 225)); - p.fillRect(QRect(0, 0, 256, 128), linearGrad); + p.fillRect(pxres.rect(), linearGrad); p.drawPixmap(QPoint(0, 0), px); addInfoToPreview(pxres); @@ -289,51 +213,65 @@ void HWMapContainer::mapChanged(int index) { - switch(index) { - case MAPGEN_REGULAR: - mapgen = MAPGEN_REGULAR; - updatePreview(); - gbThemes->show(); - lblFilter->show(); - cbTemplateFilter->show(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged("+rnd+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - case MAPGEN_MAZE: - mapgen = MAPGEN_MAZE; + if (chooseMap->currentIndex() != index) + chooseMap->setCurrentIndex(index); + + if (index < 0) + { + m_mapInfo.type = MapModel::Invalid; updatePreview(); - gbThemes->show(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->show(); - cbMazeSize->show(); - emit mapChanged("+maze+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - case MAPGEN_DRAWN: - mapgen = MAPGEN_DRAWN; - updatePreview(); - gbThemes->show(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged("+drawn+"); - emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); - break; - default: - mapgen = MAPGEN_MAP; - updatePreview(); - gbThemes->hide(); - lblFilter->hide(); - cbTemplateFilter->hide(); - maze_size_label->hide(); - cbMazeSize->hide(); - emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); + return; } + Q_ASSERT(chooseMap->itemData(index, Qt::UserRole + 1).canConvert()); + m_mapInfo = chooseMap->itemData(index, Qt::UserRole + 1).value(); + m_curMap = m_mapInfo.name; + + switch(m_mapInfo.type) + { + case MapModel::GeneratedMap: + mapgen = MAPGEN_REGULAR; + gbThemes->show(); + lblFilter->show(); + cbTemplateFilter->show(); + maze_size_label->hide(); + cbMazeSize->hide(); + break; + case MapModel::GeneratedMaze: + mapgen = MAPGEN_MAZE; + gbThemes->show(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->show(); + cbMazeSize->show(); + break; + case MapModel::HandDrawnMap: + mapgen = MAPGEN_DRAWN; + gbThemes->show(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->hide(); + cbMazeSize->hide(); + break; + default: + mapgen = MAPGEN_MAP; + gbThemes->hide(); + lblFilter->hide(); + cbTemplateFilter->hide(); + maze_size_label->hide(); + cbMazeSize->hide(); + m_theme = m_mapInfo.theme; + } + + // the map has no pre-defined theme, so let's use the selected one + if (m_mapInfo.theme.isEmpty()) + { + m_theme = lvThemes->currentIndex().data().toString(); + emit themeChanged(m_theme); + } + + updatePreview(); + emit mapChanged(m_curMap); emit mapgenChanged(mapgen); } @@ -350,7 +288,8 @@ p.setBrush(QColor(0, 0, 0)); p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); p.setFont(QFont("MS Shell Dlg", 10)); - p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); + QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; + p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); imageButt->setIcon(finalImage); @@ -359,40 +298,38 @@ void HWMapContainer::askForGeneratedPreview() { - if (pMap) - { - disconnect(pMap, 0, this, SLOT(setImage(const QImage))); - disconnect(pMap, 0, this, SLOT(setHHLimit(int))); - pMap = 0; - } - pMap = new HWMap(); connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); + connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *))); pMap->getImage(m_seed, getTemplateFilter(), get_mapgen(), getMazeSize(), getDrawnMapData() - ); + ); + + setHHLimit(0); + + const QPixmap waitIcon(":/res/iconTime.png"); + + QPixmap waitImage(m_previewSize); + QPainter p(&waitImage); + + p.fillRect(waitImage.rect(), linearGrad); + int x = (waitImage.width() - waitIcon.width()) / 2; + int y = (waitImage.height() - waitIcon.height()) / 2; + p.drawPixmap(QPoint(x, y), waitIcon); + + addInfoToPreview(waitImage); } void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) { - QString theme = current.data().toString(); - QList mapInfo; - mapInfo.push_back(QString("+rnd+")); - mapInfo.push_back(theme); - mapInfo.push_back(18); - mapInfo.push_back(false); - chooseMap->setItemData(0, mapInfo); - mapInfo[0] = QString("+maze+"); - chooseMap->setItemData(1, mapInfo); - mapInfo[0] = QString("+drawn+"); - chooseMap->setItemData(2, mapInfo); + m_theme = current.data().toString(); gbThemes->setIcon(qVariantValue(current.data(Qt::UserRole))); - emit themeChanged(theme); + emit themeChanged(m_theme); } QString HWMapContainer::getCurrentSeed() const @@ -403,18 +340,17 @@ QString HWMapContainer::getCurrentMap() const { if(chooseMap->currentIndex() < MAPGEN_MAP) return QString(); - return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); + return(m_curMap); } QString HWMapContainer::getCurrentTheme() const { - return chooseMap->itemData(chooseMap->currentIndex()).toList()[1].toString(); + return(m_theme); } bool HWMapContainer::getCurrentIsMission() const { - if(!chooseMap->currentIndex()) return false; - return chooseMap->itemData(chooseMap->currentIndex()).toList()[3].toBool(); + return(m_mapInfo.type == MapModel::MissionMap); } int HWMapContainer::getCurrentHHLimit() const @@ -424,12 +360,12 @@ QString HWMapContainer::getCurrentScheme() const { - return chooseMap->itemData(chooseMap->currentIndex()).toList()[4].toString(); + return(m_mapInfo.scheme); } QString HWMapContainer::getCurrentWeapons() const { - return chooseMap->itemData(chooseMap->currentIndex()).toList()[5].toString(); + return(m_mapInfo.weapons); } quint32 HWMapContainer::getTemplateFilter() const @@ -440,7 +376,7 @@ void HWMapContainer::resizeEvent ( QResizeEvent * event ) { Q_UNUSED(event); - //imageButt->setIconSize(imageButt->size()); + //imageButt->setIconSize(imageButt->size()); } void HWMapContainer::intSetSeed(const QString & seed) @@ -453,40 +389,28 @@ void HWMapContainer::setSeed(const QString & seed) { intSetSeed(seed); - if (chooseMap->currentIndex() < MAPGEN_DRAWN) + if ((m_mapInfo.type == MapModel::GeneratedMap) || (m_mapInfo.type == MapModel::GeneratedMaze)) updatePreview(); } void HWMapContainer::intSetMap(const QString & map) { - int id = 0; - for(int i = 0; i < chooseMap->count(); i++) - if(!chooseMap->itemData(i).isNull() && chooseMap->itemData(i).toList()[0].toString() == map) - { - id = i; - break; - } + m_curMap = map; - if(id > 0) { - if (pMap) - { - disconnect(pMap, 0, this, SLOT(setImage(const QImage))); - disconnect(pMap, 0, this, SLOT(setHHLimit(int))); - pMap = 0; - } - chooseMap->setCurrentIndex(id); - } + int id = m_mapModel->indexOf(map); + + mapChanged(id); } -void HWMapContainer::setMap(const QString &map) +void HWMapContainer::setMap(const QString & map) { - intSetMap(map); - updatePreview(); + if ((m_mapInfo.type == MapModel::Invalid) || (map != m_mapInfo.name)) + intSetMap(map); } void HWMapContainer::setTheme(const QString & theme) { - QModelIndexList mdl = themesModel->match(themesModel->index(0), Qt::DisplayRole, theme); + QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, theme); if(mdl.size()) lvThemes->setCurrentIndex(mdl.at(0)); @@ -494,53 +418,41 @@ void HWMapContainer::setRandomMap() { + int idx; + setRandomSeed(); - switch(chooseMap->currentIndex()) + switch(m_mapInfo.type) { - case MAPGEN_REGULAR: - case MAPGEN_MAZE: - setRandomTheme(); - break; - case MAPGEN_DRAWN: - emit drawMapRequested(); - break; - default: - if(chooseMap->currentIndex() <= numMissions + MAPGEN_MAP + 1) - setRandomMission(); - else - setRandomStatic(); - break; + case MapModel::GeneratedMap: + case MapModel::GeneratedMaze: + setRandomTheme(); + break; + case MapModel::HandDrawnMap: + emit drawMapRequested(); + break; + case MapModel::MissionMap: + case MapModel::StaticMap: + // get random map of same type + idx = m_mapModel->randomMap(m_mapInfo.type); + mapChanged(idx); + break; + case MapModel::Invalid: + mapChanged(0); } } -void HWMapContainer::setRandomStatic() -{ - int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); - chooseMap->setCurrentIndex(i); - mapChanged(i); -} - -void HWMapContainer::setRandomMission() -{ - int i = MAPGEN_MAP + 2 + rand() % numMissions; - chooseMap->setCurrentIndex(i); - mapChanged(i); -} void HWMapContainer::setRandomSeed() { - m_seed = QUuid::createUuid().toString(); - seedEdit->setText(m_seed); + setSeed(QUuid::createUuid().toString()); emit seedChanged(m_seed); - if (chooseMap->currentIndex() < MAPGEN_MAP) - updatePreview(); } void HWMapContainer::setRandomTheme() { - if(!themesModel->rowCount()) return; - quint32 themeNum = rand() % themesModel->rowCount(); - lvThemes->setCurrentIndex(themesModel->index(themeNum)); + if(!m_themeModel->rowCount()) return; + quint32 themeNum = rand() % m_themeModel->rowCount(); + lvThemes->setCurrentIndex(m_themeModel->index(themeNum)); } void HWMapContainer::intSetTemplateFilter(int filter) @@ -552,7 +464,8 @@ void HWMapContainer::setTemplateFilter(int filter) { intSetTemplateFilter(filter); - updatePreview(); + if (m_mapInfo.type == MapModel::GeneratedMap) + updatePreview(); } MapGenerator HWMapContainer::get_mapgen(void) const @@ -574,23 +487,52 @@ void HWMapContainer::setMazeSize(int size) { intSetMazeSize(size); - updatePreview(); + if (m_mapInfo.type == MapModel::GeneratedMaze) + updatePreview(); } void HWMapContainer::intSetMapgen(MapGenerator m) { - mapgen = m; + if (mapgen != m) + { + mapgen = m; - if(m != MAPGEN_MAP) - chooseMap->setCurrentIndex(m); + switch (m) + { + case MAPGEN_REGULAR: + m_mapInfo.type = MapModel::GeneratedMap; + break; + case MAPGEN_MAZE: + m_mapInfo.type = MapModel::GeneratedMaze; + break; + case MAPGEN_DRAWN: + m_mapInfo.type = MapModel::HandDrawnMap; + break; + case MAPGEN_MAP: + switch (m_mapInfo.type) + { + case MapModel::GeneratedMap: + case MapModel::GeneratedMaze: + case MapModel::HandDrawnMap: + m_mapInfo.type = MapModel::Invalid; + default: + break; + } + break; + } - emit mapgenChanged(m); + if(m != MAPGEN_MAP) + chooseMap->setCurrentIndex(m); + + emit mapgenChanged(m); + } } void HWMapContainer::setMapgen(MapGenerator m) { intSetMapgen(m); - updatePreview(); + if(m != MAPGEN_MAP) + updatePreview(); } void HWMapContainer::setDrawnMapData(const QByteArray & ar) @@ -637,41 +579,83 @@ void HWMapContainer::updatePreview() { - int curIndex = chooseMap->currentIndex(); + if (pMap) + { + disconnect(pMap, 0, this, SLOT(setImage(const QImage))); + disconnect(pMap, 0, this, SLOT(setHHLimit(int))); + pMap = 0; + } - switch(curIndex) + QPixmap failIcon; + + switch(m_mapInfo.type) { - case MAPGEN_REGULAR: - askForGeneratedPreview(); - break; - case MAPGEN_MAZE: - askForGeneratedPreview(); - break; - case MAPGEN_DRAWN: - askForGeneratedPreview(); - break; - default: - QPixmap mapImage; - QFile tmpfile; - tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); - if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(curIndex).toList()[0].toString() + "/preview.png"); - if(!mapImage.load(QFileInfo(tmpfile).absoluteFilePath())) { - imageButt->setIcon(QIcon()); - return; - } + case MapModel::Invalid: + failIcon = QPixmap(":/res/btnDisabled.png"); + imageButt->setIcon(failIcon); + imageButt->setIconSize(failIcon.size()); + break; + case MapModel::GeneratedMap: + askForGeneratedPreview(); + break; + case MapModel::GeneratedMaze: + askForGeneratedPreview(); + break; + case MapModel::HandDrawnMap: + askForGeneratedPreview(); + break; + default: + QPixmap mapImage; + bool success = mapImage.load( + DataManager::instance().findFileForRead( + "Maps/" + m_mapInfo.name + "/preview.png") + ); - hhLimit = chooseMap->itemData(curIndex).toList()[2].toInt(); - addInfoToPreview(mapImage); + if(!success) + { + imageButt->setIcon(QIcon()); + return; + } + + hhLimit = m_mapInfo.limit; + addInfoToPreview(mapImage); } } void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl) { - intSetMap(map); intSetMapgen(m); intSetMazeSize(mazesize); intSetSeed(seed); intSetTemplateFilter(tmpl); + // this one last because it will refresh the preview + intSetMap(map); +} - updatePreview(); + +void HWMapContainer::updateModelViews() +{ + // restore theme selection + // do this before map selection restore, because map may overwrite theme + if (!m_theme.isEmpty()) + { + QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, m_theme); + if (mdl.size() > 0) + lvThemes->setCurrentIndex(mdl.at(0)); + else + setRandomTheme(); + } + + // restore map selection + if ((!m_curMap.isEmpty()) && (chooseMap->currentIndex() < 0)) + intSetMap(m_curMap); + else + updatePreview(); } + + +void HWMapContainer::onPreviewMapDestroyed(QObject * map) +{ + if (map == pMap) + pMap = 0; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/mapContainer.h --- a/QTfrontend/ui/widget/mapContainer.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/mapContainer.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,12 +27,16 @@ #include #include +#include "DataManager.h" + #include "hwmap.h" #include "drawmapscene.h" +#include "MapModel.h" class QPushButton; class IconedGroupBox; class QListView; +class SeparatorPainter; class MapFileErrorException { @@ -40,89 +44,97 @@ class HWMapContainer : public QWidget { - Q_OBJECT + Q_OBJECT - public: - HWMapContainer(QWidget * parent=0); - QString getCurrentSeed() const; - QString getCurrentMap() const; - QString getCurrentTheme() const; - int getCurrentHHLimit() const; - QString getCurrentScheme() const; - QString getCurrentWeapons() const; - quint32 getTemplateFilter() const; - MapGenerator get_mapgen(void) const; - int getMazeSize(void) const; - bool getCurrentIsMission() const; - QByteArray getDrawnMapData(); - DrawMapScene * getDrawMapScene(); - void mapDrawingFinished(); - QLineEdit* seedEdit; + public: + HWMapContainer(QWidget * parent=0); + QString getCurrentSeed() const; + QString getCurrentMap() const; + QString getCurrentTheme() const; + int getCurrentHHLimit() const; + QString getCurrentScheme() const; + QString getCurrentWeapons() const; + quint32 getTemplateFilter() const; + MapGenerator get_mapgen(void) const; + int getMazeSize(void) const; + bool getCurrentIsMission() const; + QByteArray getDrawnMapData(); + DrawMapScene * getDrawMapScene(); + void mapDrawingFinished(); + QLineEdit* seedEdit; - public slots: - void askForGeneratedPreview(); - void setSeed(const QString & seed); - void setMap(const QString & map); - void setTheme(const QString & theme); - void setTemplateFilter(int); - void setMapgen(MapGenerator m); - void setMazeSize(int size); - void setDrawnMapData(const QByteArray & ar); - void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl); + public slots: + void askForGeneratedPreview(); + void setSeed(const QString & seed); + void setMap(const QString & map); + void setTheme(const QString & theme); + void setTemplateFilter(int); + void setMapgen(MapGenerator m); + void setMazeSize(int size); + void setDrawnMapData(const QByteArray & ar); + void setAllMapParameters(const QString & map, MapGenerator m, int mazesize, const QString & seed, int tmpl); + void updateModelViews(); + void onPreviewMapDestroyed(QObject * map); - signals: - void seedChanged(const QString & seed); - void mapChanged(const QString & map); - void themeChanged(const QString & theme); - void newTemplateFilter(int filter); - void mapgenChanged(MapGenerator m); - void mazeSizeChanged(int s); - void drawMapRequested(); - void drawnMapChanged(const QByteArray & data); + signals: + void seedChanged(const QString & seed); + void mapChanged(const QString & map); + void themeChanged(const QString & theme); + void newTemplateFilter(int filter); + void mapgenChanged(MapGenerator m); + void mazeSizeChanged(int s); + void drawMapRequested(); + void drawnMapChanged(const QByteArray & data); - private slots: - void setImage(const QImage newImage); - void setHHLimit(int hhLimit); - void mapChanged(int index); - void setRandomSeed(); - void setRandomTheme(); - void setRandomMap(); - void setRandomStatic(); - void setRandomMission(); - void themeSelected(const QModelIndex & current, const QModelIndex &); - void addInfoToPreview(QPixmap image); - void seedEdited(); + private slots: + void setImage(const QImage newImage); + void setHHLimit(int hhLimit); + void mapChanged(int index); + void setRandomSeed(); + void setRandomTheme(); + void setRandomMap(); + void themeSelected(const QModelIndex & current, const QModelIndex &); + void addInfoToPreview(QPixmap image); + void seedEdited(); - protected: - virtual void resizeEvent ( QResizeEvent * event ); + protected: + virtual void resizeEvent ( QResizeEvent * event ); - private: - QGridLayout mainLayout; - QPushButton* imageButt; - QComboBox* chooseMap; - IconedGroupBox* gbThemes; - QListView* lvThemes; - HWMap* pMap; - QString m_seed; - QPushButton* seedSet; - QLabel* seedLabel; - int hhLimit; - int templateFilter; - QPixmap hhSmall; - QLabel* lblFilter; - QComboBox* cbTemplateFilter; - QLabel *maze_size_label; - QComboBox *cbMazeSize; - MapGenerator mapgen; - int numMissions; - DrawMapScene drawMapScene; + private: + QGridLayout mainLayout; + QPushButton* imageButt; + QComboBox* chooseMap; + MapModel * m_mapModel; + IconedGroupBox* gbThemes; + QListView* lvThemes; + ThemeModel * m_themeModel; + HWMap* pMap; + QString m_seed; + QPushButton* seedSet; + QLabel* seedLabel; + int hhLimit; + int templateFilter; + QPixmap hhSmall; + QLabel* lblFilter; + QComboBox* cbTemplateFilter; + QLabel *maze_size_label; + QComboBox *cbMazeSize; + MapGenerator mapgen; + DrawMapScene drawMapScene; - void intSetSeed(const QString & seed); - void intSetMap(const QString & map); - void intSetMapgen(MapGenerator m); - void intSetTemplateFilter(int); - void intSetMazeSize(int size); - void updatePreview(); + void intSetSeed(const QString & seed); + void intSetMap(const QString & map); + void intSetMapgen(MapGenerator m); + void intSetTemplateFilter(int); + void intSetMazeSize(int size); + void updatePreview(); + + MapModel::MapInfo m_mapInfo; + QString m_theme; + QString m_curMap; + + QLinearGradient linearGrad; ///< for preview background + QSize m_previewSize; }; #endif // _HWMAP_CONTAINER_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/qpushbuttonwithsound.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,43 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include + +#include "qpushbuttonwithsound.h" +#include "DataManager.h" +#include "SDLInteraction.h" +#include "hwform.h" +#include "gameuiconfig.h" + +QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) : + QPushButton(parent), + isSoundEnabled(true) +{ + connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked())); +} + +void QPushButtonWithSound::buttonClicked() +{ + if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled()) + return; + + DataManager & dataMgr = DataManager::instance(); + + if (this->isEnabled()) + SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/roperelease.ogg")); +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/qpushbuttonwithsound.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,38 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef QPUSHBUTTONWITHSOUND_H +#define QPUSHBUTTONWITHSOUND_H + +#include + +class QPushButtonWithSound : public QPushButton +{ + Q_OBJECT + public: + explicit QPushButtonWithSound(QWidget *parent = 0); + bool isSoundEnabled; + signals: + + public slots: + private slots: + void buttonClicked(); + +}; + +#endif // QPUSHBUTTONWITHSOUND_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/selectWeapon.cpp --- a/QTfrontend/ui/widget/selectWeapon.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/selectWeapon.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -81,8 +81,8 @@ } SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) : - QFrame(parent), - m_numItems(numItems) + QFrame(parent), + m_numItems(numItems) { wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this); @@ -127,9 +127,9 @@ int j = -1; int i = 0, k = 0; - for(; i < m_numItems; ++i) { + for(; i < m_numItems; ++i) + { if (i == 6) continue; - if (i == 52) continue; // Disable structures for now if (k % 4 == 0) ++j; SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), QImage(":/res/ammopicgrey.png"), this); weaponItems[i].append(swi); @@ -159,10 +159,12 @@ { bool enable = true; for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { enable = false; } - for(int i = 0; i < m_numItems; ++i) { + for(int i = 0; i < m_numItems; ++i) + { twi::iterator it = weaponItems.find(i); if (it == weaponItems.end()) continue; it.value()[0]->setItemsNum(ammo[i].digitValue()); @@ -180,7 +182,8 @@ void SelWeaponWidget::setDefault() { for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { return; } setWeapons(*cDefaultAmmoStore); @@ -188,20 +191,18 @@ void SelWeaponWidget::save() { - for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { - QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first)); - return; - } - + // TODO make this return if success or not, so that the page can react + // properly and not goBack if saving failed if (m_name->text() == "") return; QString state1; QString state2; QString state3; QString state4; + QString stateFull; - for(int i = 0; i < m_numItems; ++i) { + for(int i = 0; i < m_numItems; ++i) + { twi::const_iterator it = weaponItems.find(i); int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' state1.append(QString::number(num)); @@ -212,11 +213,33 @@ int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum(); state4.append(QString::number(am)); } - if (curWeaponsName != "") { + + stateFull = state1 + state2 + state3 + state4; + + for(int i = 0; i < cDefaultAmmos.size(); i++) + { + if (cDefaultAmmos[i].first.compare(m_name->text()) == 0) + { + // don't show warning if no change + if (cDefaultAmmos[i].second.compare(stateFull) == 0) + return; + + QMessageBox deniedMsg(this); + deniedMsg.setIcon(QMessageBox::Warning); + deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning")); + deniedMsg.setText(QMessageBox::tr("Cannot overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first)); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); + return; + } + } + + if (curWeaponsName != "") + { // remove old entry wconf->remove(curWeaponsName); } - wconf->setValue(m_name->text(), state1 + state2 + state3 + state4); + wconf->setValue(m_name->text(), stateFull); emit weaponsChanged(); } @@ -236,14 +259,26 @@ if (curWeaponsName == "") return; for(int i = 0; i < cDefaultAmmos.size(); i++) - if (!cDefaultAmmos[i].first.compare(m_name->text())) { - QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set '%1'!").arg(cDefaultAmmos[i].first)); + if (!cDefaultAmmos[i].first.compare(m_name->text())) + { + QMessageBox deniedMsg(this); + deniedMsg.setIcon(QMessageBox::Warning); + deniedMsg.setWindowTitle(QMessageBox::tr("Weapons - Warning")); + deniedMsg.setText(QMessageBox::tr("Cannot delete default weapon set '%1'!").arg(cDefaultAmmos[i].first)); + deniedMsg.setWindowModality(Qt::WindowModal); + deniedMsg.exec(); return; } - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); + QMessageBox reallyDeleteMsg(this); + reallyDeleteMsg.setIcon(QMessageBox::Question); + reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Weapons - Are you sure?")); + reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the weapon set '%1'?").arg(curWeaponsName)); + reallyDeleteMsg.setWindowModality(Qt::WindowModal); + reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) { + if (reallyDeleteMsg.exec() == QMessageBox::Ok) + { wconf->remove(curWeaponsName); emit weaponsDeleted(); } @@ -252,10 +287,11 @@ void SelWeaponWidget::newWeaponsName() { QString newName = tr("new"); - if(wconf->contains(newName)) { + if(wconf->contains(newName)) + { //name already used -> look for an appropriate name: int i=2; - while(wconf->contains(newName = tr("new")+QString::number(i++))); + while(wconf->contains(newName = tr("new")+QString::number(i++))) ; } setWeaponsName(newName); } @@ -266,9 +302,12 @@ curWeaponsName = name; - if(name != "" && wconf->contains(name)) { + if(name != "" && wconf->contains(name)) + { setWeapons(wconf->value(name).toString()); - } else { + } + else + { setWeapons(*cDefaultAmmoStore); } } @@ -280,13 +319,15 @@ void SelWeaponWidget::copy() { - if(wconf->contains(curWeaponsName)) { + if(wconf->contains(curWeaponsName)) + { QString ammo = getWeaponsString(curWeaponsName); QString newName = tr("copy of") + " " + curWeaponsName; - if(wconf->contains(newName)) { + if(wconf->contains(newName)) + { //name already used -> look for an appropriate name: int i=2; - while(wconf->contains(newName = tr("copy of") + " " + curWeaponsName+QString::number(i++))); + while(wconf->contains(newName = tr("copy of") + " " + curWeaponsName+QString::number(i++))) ; } setWeaponsName(newName); setWeapons(ammo); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/selectWeapon.h --- a/QTfrontend/ui/widget/selectWeapon.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/selectWeapon.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,62 +31,62 @@ class SelWeaponItem : public QWidget { - Q_OBJECT + Q_OBJECT -public: - SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0); + public: + SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QImage imagegrey, QWidget* parent=0); - unsigned char getItemsNum() const; - void setItemsNum(const unsigned char num); - void setEnabled(bool value); + unsigned char getItemsNum() const; + void setItemsNum(const unsigned char num); + void setEnabled(bool value); - private: - WeaponItem* item; + private: + WeaponItem* item; }; class SelWeaponWidget : public QFrame { - Q_OBJECT + Q_OBJECT - public: - SelWeaponWidget(int numItems, QWidget* parent=0); - QString getWeaponsString(const QString& name) const; - QStringList getWeaponNames() const; + public: + SelWeaponWidget(int numItems, QWidget* parent=0); + QString getWeaponsString(const QString& name) const; + QStringList getWeaponNames() const; - public slots: - void setDefault(); - void setWeapons(const QString& ammo); - //sets the name of the current set - void setWeaponsName(const QString& name); - void deleteWeaponsName(); - void newWeaponsName(); - void save(); - void copy(); + public slots: + void setDefault(); + void setWeapons(const QString& ammo); + //sets the name of the current set + void setWeaponsName(const QString& name); + void deleteWeaponsName(); + void newWeaponsName(); + void save(); + void copy(); - signals: - void weaponsChanged(); - void weaponsDeleted(); + signals: + void weaponsChanged(); + void weaponsDeleted(); - private: - //the name of the current weapon set - QString curWeaponsName; + private: + //the name of the current weapon set + QString curWeaponsName; - QLineEdit* m_name; + QLineEdit* m_name; - //storage for all the weapons sets - QSettings* wconf; + //storage for all the weapons sets + QSettings* wconf; - const int m_numItems; - int operator [] (unsigned int weaponIndex) const; + const int m_numItems; + int operator [] (unsigned int weaponIndex) const; - typedef QList ItemsList; - typedef QMap twi; - twi weaponItems; - //layout element for each tab: - QGridLayout* p1Layout; - QGridLayout* p2Layout; - QGridLayout* p3Layout; - QGridLayout* p4Layout; + typedef QList ItemsList; + typedef QMap twi; + twi weaponItems; + //layout element for each tab: + QGridLayout* p1Layout; + QGridLayout* p2Layout; + QGridLayout* p3Layout; + QGridLayout* p4Layout; }; #endif // _SELECT_WEAPON_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/teamselect.cpp --- a/QTfrontend/ui/widget/teamselect.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/teamselect.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,28 +32,34 @@ void TeamSelWidget::addTeam(HWTeam team) { - if(team.isNetTeam()) { - framePlaying->addTeam(team, true); - curPlayingTeams.push_back(team); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(netTeamStatusChanged(const HWTeam&))); - connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), + if(team.isNetTeam()) + { + framePlaying->addTeam(team, true); + curPlayingTeams.push_back(team); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(netTeamStatusChanged(const HWTeam&))); + connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), this, SLOT(hhNumChanged(const HWTeam&))); - dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), + dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), this, SLOT(proxyTeamColorChanged(const HWTeam&))); - } else { - frameDontPlaying->addTeam(team, false); - m_curNotPlayingTeams.push_back(team); - if(m_acceptOuter) { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); - } else { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); } - } - emit setEnabledGameStart(curPlayingTeams.size()>1); + else + { + frameDontPlaying->addTeam(team, false); + m_curNotPlayingTeams.push_back(team); + if(m_acceptOuter) + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(pre_changeTeamStatus(HWTeam))); + } + else + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); + } + } + emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::setInteractivity(bool interactive) @@ -87,15 +93,15 @@ void TeamSelWidget::changeHHNum(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); if(itPlay==curPlayingTeams.end()) { qWarning() << QString("changeHHNum: team '%1' not found").arg(team.name()); return; } - itPlay->setNumHedgehogs(team.numHedgehogs()); + itPlay->setNumHedgehogs(team.numHedgehogs()); - framePlaying->setHHNum(team); + framePlaying->setHHNum(team); } void TeamSelWidget::changeTeamColor(const HWTeam& team) @@ -114,93 +120,111 @@ void TeamSelWidget::removeNetTeam(const HWTeam& team) { //qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName); - for(;;) { + for(;;) + { QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); if(itPlay==curPlayingTeams.end()) { qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.name()); break; } - if(itPlay->isNetTeam()) { + if(itPlay->isNetTeam()) + { QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); framePlaying->removeTeam(team); curPlayingTeams.erase(itPlay); break; } + else + { + qWarning() << QString("removeNetTeam: team '%1' was actually a local team!").arg(team.name()); + break; + } } emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); } //void TeamSelWidget::removeTeam(__attribute__ ((unused)) HWTeam team) //{ - //curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); +//curDontPlayingTeams.erase(std::find(curDontPlayingTeams.begin(), curDontPlayingTeams.end(), team)); //} void TeamSelWidget::changeTeamStatus(HWTeam team) { - QList::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + QList::iterator itDontPlay=std::find(m_curNotPlayingTeams.begin(), m_curNotPlayingTeams.end(), team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); + bool willBePlaying=itDontPlay!=m_curNotPlayingTeams.end(); - if(!willBePlaying) { - // playing team => dont playing - m_curNotPlayingTeams.push_back(*itPlay); - emit teamNotPlaying(*itPlay); - curPlayingTeams.erase(itPlay); - } else { - // return if max playing teams reached - if(framePlaying->isFullTeams()) return; - // dont playing team => playing - team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) - itDontPlay->setColor(framePlaying->getNextColor()); - curPlayingTeams.push_back(*itDontPlay); - if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); - m_curNotPlayingTeams.erase(itDontPlay); - } + if(!willBePlaying) + { + // playing team => dont playing + m_curNotPlayingTeams.push_back(*itPlay); + emit teamNotPlaying(*itPlay); + curPlayingTeams.erase(itPlay); + } + else + { + // return if max playing teams reached + if(framePlaying->isFullTeams()) return; + // dont playing team => playing + itDontPlay->setColor(framePlaying->getNextColor()); + team=*itDontPlay; // for net team info saving in framePlaying (we have only name with netID from network) + curPlayingTeams.push_back(*itDontPlay); + if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); + m_curNotPlayingTeams.erase(itDontPlay); + } - FrameTeams* pRemoveTeams; - FrameTeams* pAddTeams; - if(!willBePlaying) { - pRemoveTeams=framePlaying; - pAddTeams=frameDontPlaying; - } else { - pRemoveTeams=frameDontPlaying; - pAddTeams=framePlaying; - } + FrameTeams* pRemoveTeams; + FrameTeams* pAddTeams; + if(!willBePlaying) + { + pRemoveTeams=framePlaying; + pAddTeams=frameDontPlaying; + } + else + { + pRemoveTeams=frameDontPlaying; + pAddTeams=framePlaying; + } - pAddTeams->addTeam(team, willBePlaying); - pRemoveTeams->removeTeam(team); - if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) { - connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); - } else { - connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); - } - if(willBePlaying) { - connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), - this, SLOT(hhNumChanged(const HWTeam&))); - dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); - connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), - this, SLOT(proxyTeamColorChanged(const HWTeam&))); - emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); - } + pAddTeams->addTeam(team, willBePlaying); + pRemoveTeams->removeTeam(team); + if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) + { + connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(pre_changeTeamStatus(HWTeam))); + } + else + { + connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), + this, SLOT(changeTeamStatus(HWTeam))); + } + if(willBePlaying) + { + connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), + this, SLOT(hhNumChanged(const HWTeam&))); + dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); + connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), + this, SLOT(proxyTeamColorChanged(const HWTeam&))); + emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); + } - QSize szh=pAddTeams->sizeHint(); - QSize szh1=pRemoveTeams->sizeHint(); - if(szh.isValid() && szh1.isValid()) { - pAddTeams->resize(pAddTeams->size().width(), szh.height()); - pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); - } + QSize szh=pAddTeams->sizeHint(); + QSize szh1=pRemoveTeams->sizeHint(); + if(szh.isValid() && szh1.isValid()) + { + pAddTeams->resize(pAddTeams->size().width(), szh.height()); + pRemoveTeams->resize(pRemoveTeams->size().width(), szh1.height()); + } - emit setEnabledGameStart(curPlayingTeams.size()>1); + emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int fixedHeight) @@ -213,18 +237,18 @@ area->setMinimumHeight(fixedHeight); area->setMaximumHeight(fixedHeight); area->setStyleSheet( - "FrameTeams{" - "border: solid;" - "border-width: 1px;" - "border-radius: 16px;" - "border-color: #ffcc00;" - "}" + "FrameTeams{" + "border: solid;" + "border-width: 1px;" + "border-radius: 16px;" + "border-color: #ffcc00;" + "}" ); } } TeamSelWidget::TeamSelWidget(QWidget* parent) : - QGroupBox(parent), mainLayout(this), m_acceptOuter(false) + QGroupBox(parent), mainLayout(this), m_acceptOuter(false) { setTitle(QGroupBox::tr("Playing teams")); framePlaying = new FrameTeams(); @@ -238,44 +262,44 @@ void TeamSelWidget::setAcceptOuter(bool acceptOuter) { - m_acceptOuter=acceptOuter; + m_acceptOuter=acceptOuter; } void TeamSelWidget::resetPlayingTeams(const QList& teamslist) { - //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { - //framePlaying->removeTeam(*it); - //} - framePlaying->resetTeams(); - framePlaying->resetColors(); - curPlayingTeams.clear(); - //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { - //frameDontPlaying->removeTeam(*it); - //} - frameDontPlaying->resetTeams(); - m_curNotPlayingTeams.clear(); + //for(it=curPlayingTeams.begin(); it!=curPlayingTeams.end(); it++) { + //framePlaying->removeTeam(*it); + //} + framePlaying->resetTeams(); + framePlaying->resetColors(); + curPlayingTeams.clear(); + //for(it=curDontPlayingTeams.begin(); it!=curDontPlayingTeams.end(); it++) { + //frameDontPlaying->removeTeam(*it); + //} + frameDontPlaying->resetTeams(); + m_curNotPlayingTeams.clear(); - foreach(HWTeam team, teamslist) + foreach(HWTeam team, teamslist) addTeam(team); } -bool TeamSelWidget::isPlaying(HWTeam team) const +bool TeamSelWidget::isPlaying(const HWTeam &team) const { - return std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team)!=curPlayingTeams.end(); + return curPlayingTeams.contains(team); } QList TeamSelWidget::getPlayingTeams() const { - return curPlayingTeams; + return curPlayingTeams; } QList TeamSelWidget::getNotPlayingTeams() const { - return m_curNotPlayingTeams; + return m_curNotPlayingTeams; } -void TeamSelWidget::pre_changeTeamStatus(HWTeam team) +void TeamSelWidget::pre_changeTeamStatus(const HWTeam & team) { - team.setColor(framePlaying->getNextColor()); - emit acceptRequested(team); + //team.setColor(framePlaying->getNextColor()); + emit acceptRequested(team); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/teamselect.h --- a/QTfrontend/ui/widget/teamselect.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/teamselect.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,48 +36,48 @@ class TeamSelWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT - public: - TeamSelWidget(QWidget* parent); - void setAcceptOuter(bool acceptOuter); - void removeNetTeam(const HWTeam& team); - void resetPlayingTeams(const QList& teamslist); - bool isPlaying(HWTeam team) const; - QList getPlayingTeams() const; - QList getNotPlayingTeams() const; - void setInteractivity(bool interactive); + public: + TeamSelWidget(QWidget* parent); + void setAcceptOuter(bool acceptOuter); + void removeNetTeam(const HWTeam& team); + void resetPlayingTeams(const QList& teamslist); + bool isPlaying(const HWTeam &team) const; + QList getPlayingTeams() const; + QList getNotPlayingTeams() const; + void setInteractivity(bool interactive); - public slots: - void addTeam(HWTeam team); - void netTeamStatusChanged(const HWTeam& team); - void changeHHNum(const HWTeam&); - void changeTeamColor(const HWTeam&); - void changeTeamStatus(HWTeam team); + public slots: + void addTeam(HWTeam team); + void netTeamStatusChanged(const HWTeam& team); + void changeHHNum(const HWTeam&); + void changeTeamColor(const HWTeam&); + void changeTeamStatus(HWTeam team); - signals: - void setEnabledGameStart(bool); - void teamWillPlay(HWTeam team); - void teamNotPlaying(const HWTeam& team); - void hhogsNumChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); - void acceptRequested(HWTeam team); + signals: + void setEnabledGameStart(bool); + void teamWillPlay(const HWTeam& team); + void teamNotPlaying(const HWTeam& team); + void hhogsNumChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); + void acceptRequested(const HWTeam& team); - private slots: - void pre_changeTeamStatus(HWTeam); - void hhNumChanged(const HWTeam& team); - void proxyTeamColorChanged(const HWTeam& team); + private slots: + void pre_changeTeamStatus(const HWTeam&); + void hhNumChanged(const HWTeam& team); + void proxyTeamColorChanged(const HWTeam& team); - private: - void addScrArea(FrameTeams* pfteams, QColor color, int maxHeight); - FrameTeams* frameDontPlaying; - FrameTeams* framePlaying; + private: + void addScrArea(FrameTeams* pfteams, QColor color, int maxHeight); + FrameTeams* frameDontPlaying; + FrameTeams* framePlaying; - QVBoxLayout mainLayout; - bool m_acceptOuter; + QVBoxLayout mainLayout; + bool m_acceptOuter; - QList curPlayingTeams; - QList m_curNotPlayingTeams; + QList curPlayingTeams; + QList m_curNotPlayingTeams; }; #endif // _TEAM_SELECT_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/teamselhelper.cpp --- a/QTfrontend/ui/widget/teamselhelper.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/teamselhelper.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,22 +20,26 @@ #include #include #include +#include #include #include "teamselhelper.h" #include "hwconsts.h" #include "frameTeam.h" +#include "colorwidget.h" +#include "DataManager.h" void TeamLabel::teamButtonClicked() { - emit teamActivated(text()); + emit teamActivated(text()); } -TeamShowWidget::TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent) : - QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), - colorButt(0) +TeamShowWidget::TeamShowWidget(const HWTeam & team, bool isPlaying, FrameTeams * parent) : + QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), + colorWidget(0) { + m_parentFrameTeams = parent; QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); setPalette(newPalette); @@ -46,39 +50,42 @@ this->setMaximumHeight(38); this->setMinimumHeight(38); QIcon difficultyIcon=team.isNetTeam() ? - QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty())) - : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty())); + QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty())) + : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty())); butt = new QPushButton(difficultyIcon, team.name().replace("&","&&"), this); butt->setFlat(true); butt->setToolTip(team.owner()); mainLayout.addWidget(butt); butt->setStyleSheet("QPushButton{" - "icon-size: 48px;" - "text-align: left;" - "background-color: #0d0544;" - "color: orange;" - "font: bold;" - "border-width: 2px;" - "margin: 6px 0px 6px 0px;" - "}"); + "icon-size: 48px;" + "text-align: left;" + "background-color: #0d0544;" + "color: orange;" + "font: bold;" + "border-width: 2px;" + "margin: 6px 0px 6px 0px;" + "}"); - if(m_isPlaying) { + if(m_isPlaying) + { // team color - colorButt = new QPushButton(this); - colorButt->setMaximumWidth(26); - colorButt->setMinimumHeight(26); - colorButt->setGeometry(0, 0, 26, 26); - - changeTeamColor(); - connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); - mainLayout.addWidget(colorButt); + colorWidget = new ColorWidget(DataManager::instance().colorsModel(), this); + colorWidget->setMinimumWidth(26); + colorWidget->setMaximumWidth(26); + colorWidget->setMinimumHeight(26); + colorWidget->setMaximumHeight(26); + colorWidget->setColor(team.color()); + connect(colorWidget, SIGNAL(colorChanged(int)), this, SLOT(onColorChanged(int))); + mainLayout.addWidget(colorWidget); phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), QImage(":/res/hh25x25grey.png"), this); connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); phhoger->setHHNum(team.numHedgehogs()); mainLayout.addWidget(phhoger); - } else { + } + else + { } QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); @@ -87,28 +94,29 @@ void TeamShowWidget::setInteractivity(bool interactive) { - if(m_team.isNetTeam()) { + if(m_team.isNetTeam()) + { butt->setEnabled(interactive); } - colorButt->setEnabled(interactive); + colorWidget->setEnabled(interactive); phhoger->setEnabled(interactive); } void TeamShowWidget::setHHNum(unsigned int num) { - phhoger->setHHNum(num); + phhoger->setHHNum(num); } void TeamShowWidget::hhNumChanged() { - m_team.setNumHedgehogs(phhoger->getHedgehogsNum()); - emit hhNmChanged(m_team); + m_team.setNumHedgehogs(phhoger->getHedgehogsNum()); + emit hhNmChanged(m_team); } void TeamShowWidget::activateTeam() { - emit teamStatusChanged(m_team); + emit teamStatusChanged(m_team); } /*HWTeamTempParams TeamShowWidget::getTeamParams() const @@ -120,35 +128,20 @@ return params; }*/ -void TeamShowWidget::changeTeamColor(QColor color) + +void TeamShowWidget::changeTeamColor(int color) { - FrameTeams* pOurFrameTeams=dynamic_cast(parentWidget()); - if(!color.isValid()) { - if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { - pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); - } - color=*pOurFrameTeams->currentColor; - } else { - // set according color iterator - pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), - pOurFrameTeams->availableColors.end(), color); - if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { - // error condition - pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); - } - } + colorWidget->setColor(color); +} - colorButt->setStyleSheet(QString("QPushButton{" - "background-color: %1;" - "border-width: 1px;" - "border-radius: 2px;" - "}").arg(pOurFrameTeams->currentColor->name())); +void TeamShowWidget::onColorChanged(int color) +{ + m_team.setColor(color); - m_team.setColor(color); emit teamColorChanged(m_team); } HWTeam TeamShowWidget::getTeam() const { - return m_team; + return m_team; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/teamselhelper.h --- a/QTfrontend/ui/widget/teamselhelper.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/teamselhelper.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,53 +28,56 @@ #include "teamselect.h" #include "hedgehogerWidget.h" +class ColorWidget; + class TeamLabel : public QLabel { - Q_OBJECT + Q_OBJECT - public: - TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; + public: + TeamLabel(const QString& inp_str) : QLabel(inp_str) {}; - signals: - void teamActivated(QString team_name); + signals: + void teamActivated(QString team_name); - public slots: - void teamButtonClicked(); + public slots: + void teamButtonClicked(); }; class TeamShowWidget : public QWidget { - Q_OBJECT + Q_OBJECT - public slots: - void changeTeamColor(QColor color=QColor()); - void hhNumChanged(); + public slots: + void changeTeamColor(int color = 0); + void hhNumChanged(); - private slots: - void activateTeam(); + private slots: + void activateTeam(); + void onColorChanged(int color); - public: - TeamShowWidget(HWTeam team, bool isPlaying, QWidget * parent); - void setPlaying(bool isPlaying); - void setHHNum(unsigned int num); - void setInteractivity(bool interactive); - HWTeam getTeam() const; + public: + TeamShowWidget(const HWTeam &team, bool isPlaying, FrameTeams * parent); + void setPlaying(bool isPlaying); + void setHHNum(unsigned int num); + void setInteractivity(bool interactive); + HWTeam getTeam() const; - private: - TeamShowWidget(); - QHBoxLayout mainLayout; - HWTeam m_team; - bool m_isPlaying; - CHedgehogerWidget* phhoger; - QPushButton* colorButt; - QPushButton* butt; -// QPushButton* bText; + private: + TeamShowWidget(); + QHBoxLayout mainLayout; + HWTeam m_team; + bool m_isPlaying; + CHedgehogerWidget* phhoger; + ColorWidget* colorWidget; + QPushButton* butt; + FrameTeams * m_parentFrameTeams; - signals: - void teamStatusChanged(HWTeam team); - void hhNmChanged(const HWTeam&); - void teamColorChanged(const HWTeam&); + signals: + void teamStatusChanged(HWTeam team); + void hhNmChanged(const HWTeam&); + void teamColorChanged(const HWTeam&); }; #endif // _TEAMSEL_HELPER_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/togglebutton.cpp --- a/QTfrontend/ui/widget/togglebutton.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/togglebutton.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Kristian Lehmann - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/togglebutton.h --- a/QTfrontend/ui/widget/togglebutton.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/togglebutton.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Kristian Lehmann - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,15 +28,15 @@ class ToggleButtonWidget : public QPushButton { - Q_OBJECT -public: - ToggleButtonWidget(QWidget * parent, QString img); - ~ToggleButtonWidget(); -private: - QPixmap pmChecked; - QPixmap pmDisabled; -private slots: - void eventToggled(bool checked); + Q_OBJECT + public: + ToggleButtonWidget(QWidget * parent, QString img); + ~ToggleButtonWidget(); + private: + QPixmap pmChecked; + QPixmap pmDisabled; + private slots: + void eventToggled(bool checked); }; #endif // TOGGLEBUTTONWIDGET_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/vertScrollArea.cpp --- a/QTfrontend/ui/widget/vertScrollArea.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/vertScrollArea.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006 Igor Ulyanov - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #include VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) : - QScrollArea(parent) + QScrollArea(parent) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Background, frameColor); diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/vertScrollArea.h --- a/QTfrontend/ui/widget/vertScrollArea.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/vertScrollArea.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006 Igor Ulyanov - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,13 +24,13 @@ class VertScrArea : public QScrollArea { - Q_OBJECT + Q_OBJECT -public: - VertScrArea(QColor frameColor, QWidget * parent = 0); + public: + VertScrArea(QColor frameColor, QWidget * parent = 0); -protected: - virtual void resizeEvent(QResizeEvent * event); + protected: + virtual void resizeEvent(QResizeEvent * event); }; #endif // _VERT_SCROLL_AREA_INCLUDED diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/weaponItem.cpp --- a/QTfrontend/ui/widget/weaponItem.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/weaponItem.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include "weaponItem.h" WeaponItem::WeaponItem(const QImage& im, const QImage& img, QWidget * parent) : - ItemNum(im, img, parent, 0) + ItemNum(im, img, parent, 0) { } @@ -30,11 +30,11 @@ void WeaponItem::incItems() { - ++numItems; + ++numItems; } void WeaponItem::decItems() { - --numItems; + --numItems; } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui/widget/weaponItem.h --- a/QTfrontend/ui/widget/weaponItem.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui/widget/weaponItem.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2006-2008 Igor Ulyanov - * Copyright (c) 2008-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,21 +24,21 @@ class WeaponItem : public ItemNum { - Q_OBJECT + Q_OBJECT - public: - WeaponItem(const QImage& im, const QImage& img, QWidget * parent); - virtual ~WeaponItem(); + public: + WeaponItem(const QImage& im, const QImage& img, QWidget * parent); + virtual ~WeaponItem(); - signals: - void hedgehogsNumChanged(); + signals: + void hedgehogsNumChanged(); - protected: - virtual void incItems(); - virtual void decItems(); + protected: + virtual void incItems(); + virtual void decItems(); - private: - WeaponItem(); + private: + WeaponItem(); }; #endif // _WEAPON_ITEM diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui_hwform.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include "pagetraining.h" #include "pagenetserver.h" #include "pageoptions.h" +#include "pagefeedback.h" #include "pageingame.h" #include "pagescheme.h" #include "pagenettype.h" @@ -45,6 +46,7 @@ #include "pagegamestats.h" #include "pageplayrecord.h" #include "pagedata.h" +#include "pagevideos.h" #include "hwconsts.h" void Ui_HWForm::setupUi(HWForm *HWForm) @@ -141,4 +143,10 @@ pageDataDownload = new PageDataDownload(); Pages->addWidget(pageDataDownload); + + pageFeedback = new PageFeedback(); + Pages->addWidget(pageFeedback); + + pageVideos = new PageVideos(); + Pages->addWidget(pageVideos); } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/ui_hwform.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ class PageMultiplayer; class PagePlayDemo; class PageOptions; +class PageFeedback; class PageNet; class PageNetServer; class PageNetChat; @@ -42,6 +43,7 @@ class PageAdmin; class PageNetType; class PageDrawMap; +class PageVideos; class QStackedLayout; class QFont; class QWidget; @@ -50,39 +52,41 @@ class Ui_HWForm { -public: - QWidget *centralWidget; + public: + QWidget *centralWidget; - PageMain *pageMain; - PageEditTeam *pageEditTeam; - PageMultiplayer *pageMultiplayer; - PagePlayDemo *pagePlayDemo; - PageOptions *pageOptions; - PageNet *pageNet; - PageNetServer * pageNetServer; - PageNetChat *pageNetChat; - PageNetGame *pageNetGame; - PageInfo *pageInfo; - PageDataDownload *pageDataDownload; - PageGameStats *pageGameStats; - PageSinglePlayer *pageSinglePlayer; - PageTraining *pageTraining; - PageSelectWeapon *pageSelectWeapon; - PageInGame *pageInGame; - PageRoomsList *pageRoomsList; - PageConnecting *pageConnecting; - PageScheme *pageScheme; - PageAdmin *pageAdmin; - PageNetType *pageNetType; - PageCampaign *pageCampaign; - PageDrawMap *pageDrawMap; + PageMain *pageMain; + PageEditTeam *pageEditTeam; + PageMultiplayer *pageMultiplayer; + PagePlayDemo *pagePlayDemo; + PageOptions *pageOptions; + PageFeedback *pageFeedback; + PageNet *pageNet; + PageNetServer * pageNetServer; + PageNetChat *pageNetChat; + PageNetGame *pageNetGame; + PageInfo *pageInfo; + PageDataDownload *pageDataDownload; + PageGameStats *pageGameStats; + PageSinglePlayer *pageSinglePlayer; + PageTraining *pageTraining; + PageSelectWeapon *pageSelectWeapon; + PageInGame *pageInGame; + PageRoomsList *pageRoomsList; + PageConnecting *pageConnecting; + PageScheme *pageScheme; + PageAdmin *pageAdmin; + PageNetType *pageNetType; + PageCampaign *pageCampaign; + PageDrawMap *pageDrawMap; + PageVideos *pageVideos; - QStackedLayout *Pages; - QFont *font14; + QStackedLayout *Pages; + QFont *font14; - void setupUi(HWForm *HWForm); - void SetupFonts(); - void SetupPages(QWidget *Parent, HWForm *HWForm); + void setupUi(HWForm *HWForm); + void SetupFonts(); + void SetupPages(QWidget *Parent, HWForm *HWForm); }; #endif // UI_HWFORM_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/DataManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/util/DataManager.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,215 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief DataManager class implementation + */ + +#include +#include +#include +#include + +#include "hwconsts.h" +#include "HWApplication.h" +#include "sdlkeys.h" + +#include "DataManager.h" + +#include "GameStyleModel.h" +#include "HatModel.h" +#include "MapModel.h" +#include "ThemeModel.h" + +DataManager::DataManager() +{ + m_userData = new QDir(cfgdir->absolutePath()); + if (!m_userData->cd("Data")) + m_userData = NULL; + + m_defaultData = new QDir(datadir->absolutePath()); + + m_hatModel = NULL; + m_mapModel = NULL; + m_themeModel = NULL; + m_colorsModel = NULL; + m_bindsModel = NULL; +} + + +DataManager & DataManager::instance() +{ + static DataManager instance; + return instance; +} + + +QStringList DataManager::entryList( + const QString & subDirectory, + QDir::Filters filters, + const QStringList & nameFilters +) const +{ + QStringList result; + + if (m_userData != NULL) + { + QDir tmpDir(*m_userData); + if (tmpDir.cd(subDirectory)) + result.append(tmpDir.entryList(nameFilters, filters)); + } + + QDir tmpDir(*m_defaultData); + if (tmpDir.cd(subDirectory)) + result.append(tmpDir.entryList(nameFilters, filters)); + + result.removeDuplicates(); + + // sort case-insensitive + QMap sortedFileNames; + foreach ( QString fn, result) + { + sortedFileNames.insert(fn.toLower(), fn); + } + result = sortedFileNames.values(); + + return result; +} + + +QString DataManager::findFileForRead( + const QString & relativeDataFilePath) const +{ + QString path; + + if (m_userData != NULL) + path = m_userData->absolutePath()+"/"+relativeDataFilePath; + + if ((!path.isEmpty()) && (!QFile::exists(path))) + path = m_defaultData->absolutePath()+"/"+relativeDataFilePath; + + return path; +} + + +QString DataManager::findFileForWrite( + const QString & relativeDataFilePath) const +{ + if (m_userData != NULL) + { + QString path = m_userData->absolutePath()+"/"+relativeDataFilePath; + + // create folders if needed + QDir tmp; + tmp.mkpath(QFileInfo(path).absolutePath()); + + return path; + } + + + return ""; +} + +GameStyleModel * DataManager::gameStyleModel() +{ + if (m_gameStyleModel == NULL) { + m_gameStyleModel = new GameStyleModel(); + m_gameStyleModel->loadGameStyles(); + } + return m_gameStyleModel; +} + +HatModel * DataManager::hatModel() +{ + if (m_hatModel == NULL) { + m_hatModel = new HatModel(); + m_hatModel->loadHats(); + } + return m_hatModel; +} + +MapModel * DataManager::mapModel() +{ + if (m_mapModel == NULL) { + m_mapModel = new MapModel(); + m_mapModel->loadMaps(); + } + return m_mapModel; +} + +ThemeModel * DataManager::themeModel() +{ + if (m_themeModel == NULL) { + m_themeModel = new ThemeModel(); + m_themeModel->loadThemes(); + } + return m_themeModel; +} + +QStandardItemModel * DataManager::colorsModel() +{ + if(m_colorsModel == NULL) + { + m_colorsModel = new QStandardItemModel(); + + int i = 0; + while(colors[i]) + { + QStandardItem * item = new QStandardItem(); + item->setData(QColor(colors[i])); + m_colorsModel->appendRow(item); + ++i; + } + } + + return m_colorsModel; +} + +QStandardItemModel * DataManager::bindsModel() +{ + if(m_bindsModel == NULL) + { + m_bindsModel = new QStandardItemModel(); + + for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) + { + QStandardItem * item = new QStandardItem(); + item->setData(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), Qt::DisplayRole); + item->setData(sdlkeys[j][0], Qt::UserRole + 1); + m_bindsModel->appendRow(item); + } + } + + return m_bindsModel; +} + +void DataManager::reload() +{ + // removed for now (also code was a bit unclean, could lead to segfault if + // reload() is called before all members are initialized - because currently + // they are initialized in the getter methods rather than the constructor) +} + +void DataManager::resetColors() +{ + for(int i = colorsModel()->rowCount() - 1; i >= 0; --i) + { + m_colorsModel->item(i)->setData(QColor(colors[i])); + } +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/DataManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/util/DataManager.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,166 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +/** + * @file + * @brief DataManager class definition + */ + +#ifndef HEDGEWARS_DATAMANAGER_H +#define HEDGEWARS_DATAMANAGER_H + +#include +#include +#include + +class GameStyleModel; +class HatModel; +class MapModel; +class ThemeModel; +class QStandardItemModel; + +/** + * @brief Offers access to the data files of hedgewars. + * + * @see singleton pattern + * + * @author sheepluva + * @since 0.9.17 + */ +class DataManager: public QObject +{ + Q_OBJECT + + public: + /** + * @brief Returns reference to the singleton instance of this class. + * + * @see singleton pattern + * + * @return reference to the instance. + */ + static DataManager & instance(); + + /** + * @brief Returns a sorted list of data directory entries. + * + * @param subDirectory sub-directory to search. + * @param filters filters for entry type. + * @param nameFilters filters by name patterns. + * @return a sorted list of matches in the subDirectory of data directory. + */ + QStringList entryList(const QString & subDirectory, + QDir::Filters filters = QDir::NoFilter, + const QStringList & nameFilters = QStringList("*") + ) const; + + /** + * @brief Returns the path for the desires data file. + * + * Use this method if you want to read an existing data file. + * + * @param relativeDataFilePath relative path of the data file. + * @return real path to the file. + */ + QString findFileForRead(const QString & relativeDataFilePath) const; + + + /** + * @brief Returns the path for the data file that is to be written. + * + * Use this method if you want to create or write into a data file. + * + * @param relativeDataFilePath relative path of data file write path. + * @return destination of path data file. + */ + QString findFileForWrite(const QString & relativeDataFilePath) const; + + + /** + * @brief Returns pointer to a model of available game styles. + * + * The model is updated automatically on data reload. + * + * @return game style model pointer. + */ + GameStyleModel * gameStyleModel(); + + /** + * @brief Returns pointer to a model of available hats. + * + * The model is updated automatically on data reload. + * + * @return hat model pointer. + */ + HatModel * hatModel(); + + /** + * @brief Returns pointer to a model of available maps. + * + * The model is updated automatically on data reload. + * + * @return map model pointer. + */ + MapModel * mapModel(); + + /** + * @brief Returns pointer to a model of available themes. + * + * The model is updated automatically on data reload. + * + * @return theme model pointer. + */ + ThemeModel * themeModel(); + + QStandardItemModel * colorsModel(); + QStandardItemModel * bindsModel(); + + public slots: + /// Reloads data from storage. + void reload(); + void resetColors(); + + + signals: + /// This signal is emitted after the data has been updated. + void updated(); + + + private: + /** + * @brief Class constructor of the singleton. + * + * Not to be used from outside the class, + * use the static {@link DataManager::instance()} instead. + * + * @see singleton pattern + */ + DataManager(); + + QDir * m_defaultData; ///< directory of the installed data + QDir * m_userData; ///< directory of custom data in the user's directory + + GameStyleModel * m_gameStyleModel; ///< game style model instance + HatModel * m_hatModel; ///< hat model instance + MapModel * m_mapModel; ///< map model instance + ThemeModel * m_themeModel; ///< theme model instance + QStandardItemModel * m_colorsModel; + QStandardItemModel * m_bindsModel; +}; + +#endif // HEDGEWARS_DATAMANAGER_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/HWDataManager.cpp --- a/QTfrontend/util/HWDataManager.cpp Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,117 +0,0 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -/** - * @file - * @brief HWDataManager class implementation - */ - -#include -#include - -#include - -#include "hwconsts.h" - -#include "HWDataManager.h" - - -HWDataManager::HWDataManager() -{ - userData = new QDir(cfgdir->absolutePath()); - if (!userData->cd("Data")) - userData = NULL; - - defaultData = new QDir(datadir->absolutePath()); -} - - -HWDataManager & HWDataManager::instance() -{ - static HWDataManager instance; - return instance; -} - - -QStringList HWDataManager::entryList( - const QString & subDirectory, - QDir::Filters filters, - const QStringList & nameFilters - ) const -{ - QStringList result; - - if (userData != NULL) - { - QDir tmpDir(*userData); - if (tmpDir.cd(subDirectory)) - result.append(tmpDir.entryList(nameFilters, filters)); - } - - QDir tmpDir(*defaultData); - if (tmpDir.cd(subDirectory)) - result.append(tmpDir.entryList(nameFilters, filters)); - - result.removeDuplicates(); - - // sort case-insensitive - QMap sortedFileNames; - foreach ( QString fn, result) - { - sortedFileNames.insert(fn.toLower(), fn); - } - result = sortedFileNames.values(); - - return result; -} - - -QString HWDataManager::findFileForRead( - const QString & relativeDataFilePath) const -{ - QString path; - - if (userData != NULL) - path = userData->absolutePath()+"/"+relativeDataFilePath; - - if ((!path.isEmpty()) && (!QFile::exists(path))) - path = defaultData->absolutePath()+"/"+relativeDataFilePath; - - return path; -} - - -QString HWDataManager::findFileForWrite( - const QString & relativeDataFilePath) const -{ - if (userData != NULL) - { - QString path = userData->absolutePath()+"/"+relativeDataFilePath; - - // create folders if needed - QDir tmp; - tmp.mkpath(QFileInfo(path).absolutePath()); - - return path; - } - - - return ""; -} - diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/HWDataManager.h --- a/QTfrontend/util/HWDataManager.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2006-2007 Igor Ulyanov - * Copyright (c) 2007-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -/** - * @file - * @brief HWDataManager class definition - */ - -#ifndef HEDGEWARS_HWDATAMANAGER_H -#define HEDGEWARS_HWDATAMANAGER_H - -#include -#include - -#include - -class QDir; -class QFile; -class QStringList; - -/** - * @brief Offers access to the data files of hedgewars. - * - * @see singleton pattern - * - * @author sheepluva - * @since 0.9.17 - */ -class HWDataManager -{ -public: - /** - * @brief Returns reference to the singleton instance of this class. - * - * @see singleton pattern - * - * @return reference to the instance. - */ - static HWDataManager & instance(); - - /** - * @brief Returns a sorted list of data directory entries. - * - * @param subDirectory sub-directory to search. - * @param filters filters for entry type. - * @param nameFilters filters by name patterns. - * @return a sorted list of matches in the subDirectory of data directory. - */ - QStringList entryList(const QString & subDirectory, - QDir::Filters filters = QDir::NoFilter, - const QStringList & nameFilters = QStringList("*") - ) const; - - /** - * @brief Returns the path for the desires data file. - * - * Use this method if you want to read an existing data file. - * - * @param relativeDataFilePath relative path of the data file. - * @return real path to the file. - */ - QString findFileForRead(const QString & relativeDataFilePath) const; - - - /** - * @brief Returns the path for the data file that is to be written. - * - * Use this method if you want to create or write into a data file. - * - * @param relativeDataFilePath relative path of data file write path. - * @return destination of path data file. - */ - QString findFileForWrite(const QString & relativeDataFilePath) const; - - -private: - /** - * @brief Class constructor of the singleton. - * - * Not to be used from outside the class, - * use the static {@link HWDataManager::instance()} instead. - * - * @see singleton pattern - */ - HWDataManager(); - - QDir * defaultData; ///< directory of the installed data - QDir * userData; ///< directory of custom data in the user's directory -}; - -#endif // HEDGEWARS_HWDATAMANAGER_H diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/SDLInteraction.cpp --- a/QTfrontend/util/SDLInteraction.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/util/SDLInteraction.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,7 +64,10 @@ if (m_audioInitialized) { if (m_music != NULL) + { + Mix_HaltMusic(); Mix_FreeMusic(m_music); + } Mix_CloseAudio(); } SDL_Quit(); @@ -84,7 +87,8 @@ if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) { result << "640x480"; - } else + } + else { for(int i = 0; modes[i]; ++i) if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) @@ -191,10 +195,11 @@ if (!m_soundMap->contains(soundFile)) m_soundMap->insert(soundFile, Mix_LoadWAV(soundFile.toLocal8Bit().constData())); - Mix_PlayChannel(-1, m_soundMap->value(soundFile), 0); + //FIXME: this is a hack, but works as long as we have few concurrent playing sounds + if (Mix_Playing(lastchannel) == false) + lastchannel = Mix_PlayChannel(-1, m_soundMap->value(soundFile), 0); } - void SDLInteraction::setMusicTrack(const QString & musicFile) { bool wasPlayingMusic = m_isPlayingMusic; @@ -236,9 +241,11 @@ void SDLInteraction::stopMusic() { - if (m_isPlayingMusic && (m_music != NULL)) { + if (m_isPlayingMusic && (m_music != NULL)) + { // fade out music to finish 0,5 seconds from now - while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) { + while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) + { SDL_Delay(100); } } diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/SDLInteraction.h --- a/QTfrontend/util/SDLInteraction.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/util/SDLInteraction.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2007-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,75 +32,77 @@ /** * @brief Class for interacting with SDL (used for music and keys) - * + * * @see singleton pattern */ class SDLInteraction { -private: - /** - * @brief Class constructor of the singleton. - * - * Not to be used from outside the class, - * use the static {@link HWDataManager::instance()} instead. - * - * @see singleton pattern - */ - SDLInteraction(); + private: + /** + * @brief Class constructor of the singleton. + * + * Not to be used from outside the class, + * use the static {@link DataManager::instance()} instead. + * + * @see singleton pattern + */ + SDLInteraction(); - /// Initializes SDL for sound output if needed. - void SDLAudioInit(); + /// Initializes SDL for sound output if needed. + void SDLAudioInit(); - bool m_audioInitialized; ///< true if audio is initialized already - Mix_Music * m_music; ///< pointer to the music channel of the mixer - QString m_musicTrack; ///< path to the music track; - bool m_isPlayingMusic; ///< true if music was started but not stopped again. + bool m_audioInitialized; ///< true if audio is initialized already + Mix_Music * m_music; ///< pointer to the music channel of the mixer + QString m_musicTrack; ///< path to the music track; + bool m_isPlayingMusic; ///< true if music was started but not stopped again. - QMap * m_soundMap; ///< maps sound file paths to channels + QMap * m_soundMap; ///< maps sound file paths to channels + + int lastchannel; ///< channel of the last music played -public: - /** - * @brief Returns reference to the singleton instance of this class. - * - * @see singleton pattern - * - * @return reference to the instance. - */ - static SDLInteraction & instance(); + public: + /** + * @brief Returns reference to the singleton instance of this class. + * + * @see singleton pattern + * + * @return reference to the instance. + */ + static SDLInteraction & instance(); - /// Class Destructor. - ~SDLInteraction(); + /// Class Destructor. + ~SDLInteraction(); - /** - * @brief Returns available (screen) resolutions. - * - * @return list of resolutions in the format WIDTHxHEIGHT. - */ - QStringList getResolutions() const; + /** + * @brief Returns available (screen) resolutions. + * + * @return list of resolutions in the format WIDTHxHEIGHT. + */ + QStringList getResolutions() const; - /// Adds all available joystick controlls to the list of SDL keys. - void addGameControllerKeys() const; + /// Adds all available joystick controlls to the list of SDL keys. + void addGameControllerKeys() const; - /** - * @brief Plays a sound file. - * - * @param soundFile path of the sound file. - */ - void playSoundFile(const QString & soundFile); + /** + * @brief Plays a sound file. + * + * @param soundFile path of the sound file. + */ + void playSoundFile(const QString & soundFile); - /** - * @brief Sets the music track to be played (or not). - * - * @param musicFile path of the music file. - */ - void setMusicTrack(const QString & musicFile); + /** + * @brief Sets the music track to be played (or not). + * + * @param musicFile path of the music file. + */ + void setMusicTrack(const QString & musicFile); - /// Starts the background music if not already playing. - void startMusic(); + /// Starts the background music if not already playing. + void startMusic(); - /// Fades out and stops the background music (if playing). - void stopMusic(); + /// Fades out and stops the background music (if playing). + void stopMusic(); }; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/libav_iteraction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/util/libav_iteraction.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,356 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "libav_iteraction.h" + +#if VIDEOREC +extern "C" +{ +#include "libavformat/avformat.h" +} + +#include +#include +#include + +#include "HWApplication.h" + +struct Codec +{ + CodecID id; + bool isAudio; + QString shortName; // used for identification + QString longName; // used for displaying to user + bool isRecomended; +}; + +struct Format +{ + QString shortName; + QString longName; + bool isRecomended; + QString extension; + QVector codecs; +}; + +QList codecs; +QMap formats; + +// test if given format supports given codec +bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id) +{ +#if LIBAVFORMAT_VERSION_MAJOR >= 54 + return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1; +#else + if (ofmt->codec_tag) + return !!av_codec_get_tag(ofmt->codec_tag, codec_id); + return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec; +#endif +} + +LibavIteraction::LibavIteraction() : QObject() +{ + // initialize libav and register all codecs and formats + av_register_all(); + + // get list of all codecs + AVCodec* pCodec = NULL; + while (pCodec = av_codec_next(pCodec)) + { +#if LIBAVCODEC_VERSION_MAJOR >= 54 + if (!av_codec_is_encoder(pCodec)) +#else + if (!pCodec->encode) +#endif + continue; + + if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO) + continue; + + // this encoders seems to be buggy + if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0) + continue; + + // doesn't support stereo sound + if (strcmp(pCodec->name, "real_144") == 0) + continue; + + if (!pCodec->long_name || strlen(pCodec->long_name) == 0) + continue; + + if (pCodec->type == AVMEDIA_TYPE_VIDEO) + { + if (pCodec->supported_framerates != NULL) + continue; + + // check if codec supports yuv 4:2:0 format + if (!pCodec->pix_fmts) + continue; + bool yuv420Supported = false; + for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++) + if (*pfmt == PIX_FMT_YUV420P) + { + yuv420Supported = true; + break; + } + if (!yuv420Supported) + continue; + } + if (pCodec->type == AVMEDIA_TYPE_AUDIO) + { + // check if codec supports signed 16-bit format + if (!pCodec->sample_fmts) + continue; + bool s16Supported = false; + for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++) + if (*pfmt == AV_SAMPLE_FMT_S16) + { + s16Supported = true; + break; + } + if (!s16Supported) + continue; + } + // add codec to list of codecs + codecs.push_back(Codec()); + Codec & codec = codecs.back(); + codec.id = pCodec->id; + codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO; + codec.shortName = pCodec->name; + codec.longName = pCodec->long_name; + + codec.isRecomended = false; + if (strcmp(pCodec->name, "libx264") == 0) + { + codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)"; + codec.isRecomended = true; + } + else if (strcmp(pCodec->name, "libxvid") == 0) + { + codec.longName = "MPEG-4 Part 2 (Xvid)"; + codec.isRecomended = true; + } + else if (strcmp(pCodec->name, "libmp3lame") == 0) + { + codec.longName = "MP3 (MPEG audio layer 3) (LAME)"; + codec.isRecomended = true; + } + else + codec.longName = pCodec->long_name; + + if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0) + codec.isRecomended = true; + + // FIXME: remove next line + //codec.longName += QString(" (%1)").arg(codec.shortName); + } + + // get list of all formats + AVOutputFormat* pFormat = NULL; + while (pFormat = av_oformat_next(pFormat)) + { + if (!pFormat->extensions) + continue; + + // skip some strange formats to not confuse users + if (strstr(pFormat->long_name, "raw")) + continue; + + Format format; + bool hasVideoCodec = false; + for (QList::iterator codec = codecs.begin(); codec != codecs.end(); ++codec) + { + if (!FormatQueryCodec(pFormat, codec->id)) + continue; + format.codecs.push_back(&*codec); + if (!codec->isAudio) + hasVideoCodec = true; + } + if (!hasVideoCodec) + continue; + + QString ext(pFormat->extensions); + ext.truncate(strcspn(pFormat->extensions, ",")); + format.extension = ext; + format.shortName = pFormat->name; + format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext); + + // FIXME: remove next line + //format.longName += QString(" (%1)").arg(format.shortName); + + format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0; + + formats[pFormat->name] = format; + } +} + +void LibavIteraction::fillFormats(QComboBox * pFormats) +{ + // first insert recomended formats + foreach(const Format & format, formats) + if (format.isRecomended) + pFormats->addItem(format.longName, format.shortName); + + // remember where to place separator between recomended and other formats + int sep = pFormats->count(); + + // insert remaining formats + foreach(const Format & format, formats) + if (!format.isRecomended) + pFormats->addItem(format.longName, format.shortName); + + // insert separator if necessary + if (sep != 0 && sep != pFormats->count()) + pFormats->insertSeparator(sep); +} + +void LibavIteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs) +{ + Format & format = formats[fmt]; + + // first insert recomended codecs + foreach(Codec * codec, format.codecs) + { + if (codec->isRecomended) + { + if (codec->isAudio) + pACodecs->addItem(codec->longName, codec->shortName); + else + pVCodecs->addItem(codec->longName, codec->shortName); + } + } + + // remember where to place separators between recomended and other codecs + int vsep = pVCodecs->count(); + int asep = pACodecs->count(); + + // insert remaining codecs + foreach(Codec * codec, format.codecs) + { + if (!codec->isRecomended) + { + if (codec->isAudio) + pACodecs->addItem(codec->longName, codec->shortName); + else + pVCodecs->addItem(codec->longName, codec->shortName); + } + } + + // insert separators if necessary + if (vsep != 0 && vsep != pVCodecs->count()) + pVCodecs->insertSeparator(vsep); + if (asep != 0 && asep != pACodecs->count()) + pACodecs->insertSeparator(asep); +} + +QString LibavIteraction::getExtension(const QString & format) +{ + return formats[format].extension; +} + +// get information abaout file (duration, resolution etc) in multiline string +QString LibavIteraction::getFileInfo(const QString & filepath) +{ + AVFormatContext* pContext = NULL; + QByteArray utf8path = filepath.toUtf8(); + if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0) + return ""; +#if LIBAVFORMAT_VERSION_MAJOR < 54 + if (av_find_stream_info(pContext) < 0) +#else + if (avformat_find_stream_info(pContext, NULL) < 0) +#endif + return ""; + + int s = float(pContext->duration)/AV_TIME_BASE; + QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60); + for (int i = 0; i < (int)pContext->nb_streams; i++) + { + AVStream* pStream = pContext->streams[i]; + if (!pStream) + continue; + AVCodecContext* pCodec = pContext->streams[i]->codec; + if (!pCodec) + continue; + + if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO) + { + desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height); + if (pStream->avg_frame_rate.den) + { + float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den; + desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2); + } + } + else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO) + desc += tr("Audio: "); + else + continue; + AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id); + desc += pDecoder? pDecoder->name : "unknown"; + desc += "\n"; + } + AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0); + if (pComment) + desc += QString("\n") + pComment->value; +#if LIBAVFORMAT_VERSION_MAJOR < 54 + av_close_input_file(pContext); +#else + avformat_close_input(&pContext); +#endif + return desc; +} + +#else +LibavIteraction::LibavIteraction() : QObject() +{ + +} + +void LibavIteraction::fillFormats(QComboBox * pFormats) +{ + Q_UNUSED(pFormats); +} + +void LibavIteraction::fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs) +{ + Q_UNUSED(format); + Q_UNUSED(pVCodecs); + Q_UNUSED(pACodecs); +} + +QString LibavIteraction::getExtension(const QString & format) +{ + Q_UNUSED(format); + + return QString(); +} + +QString LibavIteraction::getFileInfo(const QString & filepath) +{ + Q_UNUSED(filepath); + + return QString(); +} +#endif + +LibavIteraction & LibavIteraction::instance() +{ + static LibavIteraction instance; + return instance; +} diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/libav_iteraction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/util/libav_iteraction.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,51 @@ +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef LIBAV_ITERACTION +#define LIBAV_ITERACTION + +#include + +/** + * @brief Class for interacting with ffmpeg/libav libraries + * + * @see singleton pattern + */ +class LibavIteraction : public QObject +{ + Q_OBJECT; + + LibavIteraction(); + +public: + + static LibavIteraction & instance(); + + // fill combo box with known file formats + void fillFormats(QComboBox * pFormats); + + // fill combo boxes with known codecs for given formats + void fillCodecs(const QString & format, QComboBox * pVCodecs, QComboBox * pACodecs); + + QString getExtension(const QString & format); + + // get information about file (duration, resolution etc) in multiline string + QString getFileInfo(const QString & filepath); +}; + +#endif // LIBAV_ITERACTION diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/namegen.cpp --- a/QTfrontend/util/namegen.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/util/namegen.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Martin Minarik - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ #include #include "hwform.h" -#include "HWDataManager.h" +#include "DataManager.h" #include "namegen.h" @@ -79,7 +79,7 @@ // there is a chance that this hog has the same hat as the previous one // let's reuse the hat-specific dict in this case - if ((i == 0) or (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) + if ((i == 0) || (team.hedgehog(i).Hat != team.hedgehog(i-1).Hat)) { dicts = dictsForHat(team.hedgehog(i).Hat); dict = dictContents(dicts[rand()%(dicts.size())]); @@ -125,8 +125,8 @@ QStringList list; // find .txt to load the names from - QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( - "Names/%1.txt").arg(filename))); + QFile * file = new QFile(DataManager::instance().findFileForRead(QString( + "Names/%1.txt").arg(filename))); if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -143,7 +143,7 @@ delete file; if (list.size() == 0) - list.append(filename); + list.append(filename); return list; } @@ -154,8 +154,8 @@ QStringList list; // find .cfg to load the dicts from - QFile * file = new QFile(HWDataManager::instance().findFileForRead(QString( - "Names/%1.cfg").arg(hatname))); + QFile * file = new QFile(DataManager::instance().findFileForRead(QString( + "Names/%1.cfg").arg(hatname))); if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -172,7 +172,7 @@ delete file; if (list.size() == 0) - list.append(QString("generic")); + list.append(QString("generic")); return list; } @@ -184,7 +184,7 @@ // find .ini to load the names from QFile * file = new QFile( - HWDataManager::instance().findFileForRead(QString("Names/types.ini"))); + DataManager::instance().findFileForRead(QString("Names/types.ini"))); if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) @@ -243,11 +243,11 @@ QStringList Graves; //list all available Graves - Graves.append(HWDataManager::instance().entryList( - "Graphics/Graves", - QDir::Files, - QStringList("*.png") - ).replaceInStrings(QRegExp("\\.png$"), "") + Graves.append(DataManager::instance().entryList( + "Graphics/Graves", + QDir::Files, + QStringList("*.png") + ).replaceInStrings(QRegExp("\\.png$"), "") ); if(Graves.size()==0) @@ -265,11 +265,11 @@ QStringList Forts; //list all available Forts - Forts.append(HWDataManager::instance().entryList( - "Forts", - QDir::Files, - QStringList("*L.png") - ).replaceInStrings(QRegExp("L\\.png$"), "") + Forts.append(DataManager::instance().entryList( + "Forts", + QDir::Files, + QStringList("*L.png") + ).replaceInStrings(QRegExp("L\\.png$"), "") ); if(Forts.size()==0) diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/util/namegen.h --- a/QTfrontend/util/namegen.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/util/namegen.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,7 @@ /* * Hedgewars, a free turn based strategy game * Copyright (c) 2009 Martin Minarik - * Copyright (c) 2009-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,12 +27,12 @@ class HWNamegen { -public: + public: - static void teamRandomName(HWTeam & team, const int HedgehogNumber); - static void teamRandomNames(HWTeam & team, const bool changeteamname); + static void teamRandomName(HWTeam & team, const int HedgehogNumber); + static void teamRandomNames(HWTeam & team, const bool changeteamname); -private: + private: HWNamegen(); static QList TypesTeamnames; diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/xfire.cpp --- a/QTfrontend/xfire.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/xfire.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2010-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "xfire.h" #include "../misc/xfire/xfiregameclient.h" +#ifdef USE_XFIRE // use_xfire: stores if xfire is loaded and functions should do something at all bool use_xfire = false; char *keys[XFIRE_KEY_COUNT]; @@ -81,3 +82,4 @@ return; XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values); } +#endif // USE_XFIRE diff -r 41b0a9955c47 -r ddcdedd3330b QTfrontend/xfire.h --- a/QTfrontend/xfire.h Thu Nov 24 13:44:30 2011 +0100 +++ b/QTfrontend/xfire.h Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ /* * Hedgewars, a free turn based strategy game - * Copyright (c) 2010-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b README_WINDOWS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README_WINDOWS Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1 @@ +For instructions, please visit: http://code.google.com/p/hedgewars/wiki/BuildingOnWindows diff -r 41b0a9955c47 -r ddcdedd3330b bin/CMakeLists.txt diff -r 41b0a9955c47 -r ddcdedd3330b cmake_modules/FindFFMPEG.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/FindFFMPEG.cmake Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,94 @@ +# - Try to find ffmpeg libraries (libavcodec, libavformat and libavutil) +# Once done this will define +# +# FFMPEG_FOUND - system has ffmpeg or libav +# FFMPEG_INCLUDE_DIR - the ffmpeg include directory +# FFMPEG_LIBRARIES - Link these to use ffmpeg +# FFMPEG_LIBAVCODEC +# FFMPEG_LIBAVFORMAT +# FFMPEG_LIBAVUTIL +# +# Copyright (c) 2008 Andreas Schneider +# Modified for other libraries by Lasse Kärkkäinen +# Modified for Hedgewars by Stepik777 +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# + +if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + # in cache already + set(FFMPEG_FOUND TRUE) +else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_FFMPEG_AVCODEC libavcodec) + pkg_check_modules(_FFMPEG_AVFORMAT libavformat) + pkg_check_modules(_FFMPEG_AVUTIL libavutil) + endif (PKG_CONFIG_FOUND) + + find_path(FFMPEG_AVCODEC_INCLUDE_DIR + NAMES libavcodec/avcodec.h + PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} + /usr/include /usr/local/include #system level + /opt/local/include #macports + /sw/include #fink + PATH_SUFFIXES ffmpeg libav + ) + + find_library(FFMPEG_LIBAVCODEC + NAMES avcodec + PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} + /usr/lib /usr/local/lib #system level + /opt/local/lib #macports + /sw/lib #fink + ) + + find_library(FFMPEG_LIBAVFORMAT + NAMES avformat + PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} + /usr/lib /usr/local/lib #system level + /opt/local/lib #macports + /sw/lib #fink + ) + + find_library(FFMPEG_LIBAVUTIL + NAMES avutil + PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} + /usr/lib /usr/local/lib #system level + /opt/local/lib #macports + /sw/lib #fink + ) + + if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT) + set(FFMPEG_FOUND TRUE) + endif() + + if (FFMPEG_FOUND) + set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR}) + + set(FFMPEG_LIBRARIES + ${FFMPEG_LIBAVCODEC} + ${FFMPEG_LIBAVFORMAT} + ${FFMPEG_LIBAVUTIL} + ) + if (APPLE) + set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "bz2" "-framework CoreVideo" "-framework VideoDecodeAcceleration") + endif(APPLE) + + endif (FFMPEG_FOUND) + + if (FFMPEG_FOUND) + if (NOT FFMPEG_FIND_QUIETLY) + message(STATUS "Found FFMPEG/LibAV: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}") + endif (NOT FFMPEG_FIND_QUIETLY) + else (FFMPEG_FOUND) + if (FFMPEG_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find libavcodec or libavformat or libavutil") + endif (FFMPEG_FIND_REQUIRED) + endif (FFMPEG_FOUND) + +endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + diff -r 41b0a9955c47 -r ddcdedd3330b cmake_modules/FindLua.cmake --- a/cmake_modules/FindLua.cmake Thu Nov 24 13:44:30 2011 +0100 +++ b/cmake_modules/FindLua.cmake Sun Oct 28 13:28:23 2012 +0100 @@ -1,21 +1,34 @@ # Find the Lua library -# +# -------------------- +# On Android/Windows/OSX this just defines the name of the library that +# will be compiled from our bundled sources +# On Linux it will try to load the system library and fallback to compiling +# the bundled one when nothing is found + +set(LUA_FOUND false) -IF(WIN32) - SET(LUA_DEFAULT lua.dll) -ELSE(WIN32) - IF(APPLE) - SET(LUA_DEFAULT lua) - ELSE(APPLE) - #locate the system's lua library - FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib) - IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND") - #UNSET(LUA_DEFAULT) - MESSAGE(FATAL_ERROR "Couldn't find Lua 5.1 library!") - ENDIF() - #remove the path (fpc doesn't like it - why?) - GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME) - ENDIF(APPLE) -ENDIF(WIN32) +if (ANDROID) + SET(LUA_DEFAULT "liblua5.1.so") +else (ANDROID) + IF(WIN32) + SET(LUA_DEFAULT lua.dll) + ELSE(WIN32) + IF(APPLE) + SET(LUA_DEFAULT lua) + ELSE(APPLE) + #locate the system's lua library + FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib) + IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND") + set(LUA_DEFAULT lua) + ELSE() + set(LUA_FOUND true) + message(STATUS "LibLua 5.1 found at ${LUA_DEFAULT}") + #remove the path (fpc doesn't like it - why?) + GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME) + ENDIF() + ENDIF(APPLE) + ENDIF(WIN32) +ENDIF(ANDROID) + SET(LUA_LIBRARY ${LUA_DEFAULT} CACHE STRING "Lua library to link to; file name without path only!") -#UNSET(LUA_DEFAULT) + diff -r 41b0a9955c47 -r ddcdedd3330b cmake_modules/FindSDL_Extras.cmake --- a/cmake_modules/FindSDL_Extras.cmake Thu Nov 24 13:44:30 2011 +0100 +++ b/cmake_modules/FindSDL_Extras.cmake Sun Oct 28 13:28:23 2012 +0100 @@ -1,22 +1,5 @@ #if the headers are not installed, the newer apis won't be activated -#find which version of SDL we are building against -find_file(sdl_h SDL_version.h ${SDL_INCLUDE_DIR}) -if(sdl_h) - file(STRINGS ${sdl_h} sdl_majorversion_tmp REGEX "SDL_MAJOR_VERSION[\t' ']+[0-9]+") - file(STRINGS ${sdl_h} sdl_minorversion_tmp REGEX "SDL_MINOR_VERSION[\t' ']+[0-9]+") - file(STRINGS ${sdl_h} sdl_patchversion_tmp REGEX "SDL_PATCHLEVEL[\t' ']+[0-9]+") - string(REGEX MATCH ".([0-9]+)" sdl_majorversion "${sdl_majorversion_tmp}") - string(REGEX MATCH ".([0-9]+)" sdl_minorversion "${sdl_minorversion_tmp}") - string(REGEX MATCH ".([0-9]+)" sdl_patchversion "${sdl_patchversion_tmp}") - math(EXPR sdl_version "${sdl_majorversion}*10000 + ${sdl_minorversion}*100 + ${sdl_patchversion}") - - if(NOT (sdl_version LESS "010300")) - message(STATUS "Enabling SDL-1.3+ calls") - set(pascal_compiler_flags_cmn "-dSDL13" ${pascal_compiler_flags_cmn}) - endif() -endif() - #find which version of SDL_mixer we have (for Mix_Init) find_file(sdlmixer_h SDL_mixer.h ${SDLMIXER_INCLUDE_DIR}) if(sdlmixer_h) @@ -29,8 +12,8 @@ math(EXPR sdlmixer_version "${sdlmixer_majorversion}*10000 + ${sdlmixer_minorversion}*100 + ${sdlmixer_patchversion}") if(sdlmixer_version GREATER "10209") - message(STATUS "Enabling enhanced SDL_Mixer calls") - set(pascal_compiler_flags_cmn "-dSDL_MIXER_NEWER" ${pascal_compiler_flags_cmn}) + message(STATUS "Mix_Init() is present") + set(pascal_flags "-dSDL_MIXER_NEWER" ${pascal_flags}) endif() endif() @@ -46,8 +29,8 @@ math(EXPR sdlimage_version "${sdlimage_majorversion}*10000 + ${sdlimage_minorversion}*100 + ${sdlimage_patchversion}") if(sdlimage_version GREATER "010207") - message(STATUS "Enabling enhanced SDL_Image calls") - set(pascal_compiler_flags_cmn "-dSDL_IMAGE_NEWER" ${pascal_compiler_flags_cmn}) + message(STATUS "IMG_Init() is present") + set(pascal_flags "-dSDL_IMAGE_NEWER" ${pascal_flags}) endif() endif() diff -r 41b0a9955c47 -r ddcdedd3330b doc/hwdemo.png Binary file doc/hwdemo.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/Actions.hs --- a/gameServer/Actions.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/Actions.hs Sun Oct 28 13:28:23 2012 +0100 @@ -1,4 +1,5 @@ {-# LANGUAGE CPP, OverloadedStrings #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} module Actions where import Control.Concurrent @@ -20,7 +21,9 @@ import System.Process import Network.Socket ----------------------------- +#if defined(OFFICIAL_SERVER) import OfficialServer.GameReplayStore +#endif import CoreTypes import Utils import ClientIO @@ -36,7 +39,9 @@ | MoveToRoom RoomIndex | MoveToLobby B.ByteString | RemoveTeam B.ByteString + | SendTeamRemovalMessage B.ByteString | RemoveRoom + | FinishGame | UnreadyRoomClients | JoinLobby | ProtocolError B.ByteString @@ -48,10 +53,12 @@ | BanClient NominalDiffTime B.ByteString ClientIndex | BanIP B.ByteString NominalDiffTime B.ByteString | BanList + | Unban B.ByteString | ChangeMaster | RemoveClientTeams ClientIndex | ModifyClient (ClientInfo -> ClientInfo) | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo) + | ModifyRoomClients (ClientInfo -> ClientInfo) | ModifyRoom (RoomInfo -> RoomInfo) | ModifyServerInfo (ServerInfo -> ServerInfo) | AddRoom B.ByteString B.ByteString @@ -144,9 +151,14 @@ io $ infoM "Clients" (show ci ++ " quits: " ++ B.unpack msg) - processAction $ AnswerClients [chan] ["BYE", msg] when loggedIn $ processAction $ AnswerClients clientsChans ["LOBBY:LEFT", clNick, msg] + mapM processAction + [ + AnswerClients [chan] ["BYE", msg] + , ModifyClient (\c -> c{nick = "", logonPassed = False}) -- this will effectively hide client from others while he isn't deleted from list + ] + s <- get put $! s{removedClients = ci `Set.insert` removedClients s} @@ -158,7 +170,7 @@ s <- get put $! s{removedClients = ci `Set.delete` removedClients s} - + sp <- gets (shutdownPending . serverInfo) cls <- allClientsS io $ when (sp && null cls) $ throwIO ShutdownException @@ -174,6 +186,12 @@ io $ modifyClient rnc f ci return () +processAction (ModifyRoomClients f) = do + rnc <- gets roomsClients + ri <- clientRoomA + roomClIDs <- io $ roomClientsIndicesM rnc ri + io $ mapM_ (modifyClient rnc f) roomClIDs + processAction (ModifyRoom f) = do rnc <- gets roomsClients @@ -207,46 +225,64 @@ (Just ci) <- gets clientIndex ri <- clientRoomA rnc <- gets roomsClients - (gameProgress, playersNum) <- io $ room'sM rnc ((isJust . gameInfo) &&& playersIn) ri - ready <- client's isReady + playersNum <- io $ room'sM rnc playersIn ri master <- client's isMaster -- client <- client's id clNick <- client's nick chans <- othersChans if master then - if gameProgress && playersNum > 1 then - mapM_ processAction [ChangeMaster, AnswerClients chans ["LEFT", clNick, msg], NoticeMessage AdminLeft, RemoveClientTeams ci] + if playersNum > 1 then + mapM_ processAction [ChangeMaster, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] else processAction RemoveRoom else - mapM_ processAction [AnswerClients chans ["LEFT", clNick, msg], RemoveClientTeams ci] + mapM_ processAction [RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] -- when not removing room - when (not master || (gameProgress && playersNum > 1)) . io $ do + ready <- client's isReady + when (not master || playersNum > 1) . io $ do modifyRoom rnc (\r -> r{ playersIn = playersIn r - 1, readyPlayers = if ready then readyPlayers r - 1 else readyPlayers r }) ri moveClientToLobby rnc ci + processAction ChangeMaster = do (Just ci) <- gets clientIndex + proto <- client's clientProto ri <- clientRoomA rnc <- gets roomsClients newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri newMaster <- io $ client'sM rnc id newMasterId - let newRoomName = nick newMaster + oldRoomName <- io $ room'sM rnc name ri + oldMaster <- client's nick + thisRoomChans <- liftM (map sendChan) $ roomClientsS ri + let newRoomName = if proto < 42 then nick newMaster else oldRoomName mapM_ processAction [ - ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), - ModifyClient2 newMasterId (\c -> c{isMaster = True}), - AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] + ModifyRoom (\r -> r{masterID = newMasterId + , name = newRoomName + , isRestrictedJoins = False + , isRestrictedTeams = False + , readyPlayers = if isReady newMaster then readyPlayers r else readyPlayers r + 1}) + , ModifyClient2 newMasterId (\c -> c{isMaster = True, isReady = True}) + , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] + , AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster] + , AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster] + , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+hr", nick newMaster] ] + newRoom' <- io $ room'sM rnc id ri + chans <- liftM (map sendChan) $! sameProtoClientsS proto + processAction $ AnswerClients chans ("ROOM" : "UPD" : oldRoomName : roomInfo newRoomName newRoom') + + processAction (AddRoom roomName roomPassword) = do Just clId <- gets clientIndex rnc <- gets roomsClients - proto <- io $ client'sM rnc clientProto clId + proto <- client's clientProto + n <- client's nick let rm = newRoom{ masterID = clId, @@ -259,11 +295,10 @@ processAction $ MoveToRoom rId - chans <- liftM (map sendChan) $! roomClientsS lobbyId + chans <- liftM (map sendChan) $! sameProtoClientsS proto mapM_ processAction [ - AnswerClients chans ["ROOM", "ADD", roomName] - , ModifyClient (\cl -> cl{isMaster = True}) + AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm) ] @@ -273,52 +308,82 @@ ri <- io $ clientRoomM rnc clId roomName <- io $ room'sM rnc name ri others <- othersChans - lobbyChans <- liftM (map sendChan) $! roomClientsS lobbyId + proto <- client's clientProto + chans <- liftM (map sendChan) $! sameProtoClientsS proto mapM_ processAction [ - AnswerClients lobbyChans ["ROOM", "DEL", roomName], + AnswerClients chans ["ROOM", "DEL", roomName], AnswerClients others ["ROOMABANDONED", roomName] ] io $ removeRoom rnc ri -processAction (UnreadyRoomClients) = do - rnc <- gets roomsClients +processAction UnreadyRoomClients = do ri <- clientRoomA roomPlayers <- roomClientsS ri - roomClIDs <- io $ roomClientsIndicesM rnc ri pr <- client's clientProto - processAction $ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr (map nick roomPlayers) - io $ mapM_ (modifyClient rnc (\cl -> cl{isReady = False})) roomClIDs - processAction $ ModifyRoom (\r -> r{readyPlayers = 0}) + mapM_ processAction [ + AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr . map nick . filter (not . isMaster) $ roomPlayers + , ModifyRoomClients (\cl -> cl{isReady = isMaster cl}) + , ModifyRoom (\r -> r{readyPlayers = 1}) + ] where notReadyMessage p nicks = if p < 38 then "NOT_READY" : nicks else "CLIENT_FLAGS" : "-r" : nicks +processAction FinishGame = do + rnc <- gets roomsClients + ri <- clientRoomA + thisRoomChans <- liftM (map sendChan) $ roomClientsS ri + answerRemovedTeams <- io $ + room'sM rnc (map (\t -> AnswerClients thisRoomChans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo) ri + + mapM_ processAction $ + SaveReplay + : ModifyRoom + (\r -> r{ + gameInfo = Nothing, + readyPlayers = 0 + } + ) + : UnreadyRoomClients + : answerRemovedTeams + + +processAction (SendTeamRemovalMessage teamName) = do + chans <- othersChans + mapM_ processAction [ + AnswerClients chans ["EM", rmTeamMsg], + ModifyRoom (\r -> r{ + gameInfo = liftM (\g -> g{ + teamsInGameNumber = teamsInGameNumber g - 1 + , roundMsgs = roundMsgs g Seq.|> rmTeamMsg + }) $ gameInfo r + }) + ] + + rnc <- gets roomsClients + ri <- clientRoomA + gi <- io $ room'sM rnc gameInfo ri + when (isJust gi && 0 == teamsInGameNumber (fromJust gi)) $ + processAction FinishGame + where + rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName + + processAction (RemoveTeam teamName) = do rnc <- gets roomsClients ri <- clientRoomA inGame <- io $ room'sM rnc (isJust . gameInfo) ri chans <- othersChans - if not $ inGame then - mapM_ processAction [ - AnswerClients chans ["REMOVE_TEAM", teamName], - ModifyRoom (\r -> r{teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r}) - ] - else - mapM_ processAction [ - AnswerClients chans ["EM", rmTeamMsg], - ModifyRoom (\r -> r{ - teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r, - gameInfo = liftM (\g -> g{ - leftTeams = teamName : leftTeams g, - roundMsgs = roundMsgs g Seq.|> rmTeamMsg - }) $ gameInfo r - }) - ] - where - rmTeamMsg = toEngineMsg $ 'F' `B.cons` teamName + mapM_ processAction $ + ModifyRoom (\r -> r{ + teams = Prelude.filter (\t -> teamName /= teamname t) $ teams r + , gameInfo = liftM (\g -> g{leftTeams = teamName : leftTeams g}) $ gameInfo r + }) + : AnswerClients chans ["REMOVE_TEAM", teamName] + : [SendTeamRemovalMessage teamName | inGame] processAction (RemoveClientTeams clId) = do @@ -377,11 +442,22 @@ processAction JoinLobby = do chan <- client's sendChan clientNick <- client's nick - (lobbyNicks, clientsChans) <- liftM (unzip . Prelude.map (nick &&& sendChan) . Prelude.filter logonPassed) $! allClientsS - mapM_ processAction $ - AnswerClients clientsChans ["LOBBY:JOINED", clientNick] - : AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks) - : [ModifyClient (\cl -> cl{logonPassed = True}), SendServerMessage] + isAuthenticated <- liftM (not . B.null) $ client's webPassword + isAdmin <- client's isAdministrator + loggedInClients <- liftM (Prelude.filter logonPassed) $! allClientsS + let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients + let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients + let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients + let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin]] + mapM_ processAction . concat $ [ + [AnswerClients clientsChans ["LOBBY:JOINED", clientNick]] + , [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)] + , [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks] + , [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks] + , [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS", B.concat["+" , clFlags], clientNick] | not $ B.null clFlags] + , [ModifyClient (\cl -> cl{logonPassed = True})] + , [SendServerMessage] + ] processAction (KickClient kickId) = do @@ -412,11 +488,15 @@ processAction BanList = do ch <- client's sendChan - bans <- gets (bans . serverInfo) + b <- gets (B.pack . unlines . map show . bans . serverInfo) processAction $ - AnswerClients [ch] ["BANLIST", B.pack $ show bans] - + AnswerClients [ch] ["BANLIST", b] +processAction (Unban entry) = do + processAction $ ModifyServerInfo (\s -> s{bans = filter f $ bans s}) + where + f (BanByIP bip _ _) = bip == entry + f (BanByNick bn _ _) = bn == entry processAction (KickRoomClient kickId) = do modify (\s -> s{clientIndex = Just kickId}) @@ -481,9 +561,11 @@ where kickTimeouted rnc ci = do pq <- io $ client'sM rnc pingsQueue ci - when (pq > 0) $ + when (pq > 0) $ do withStateT (\as -> as{clientIndex = Just ci}) $ processAction (ByeClient "Ping timeout") +-- when (pq > 1) $ +-- processAction $ DeleteClient ci -- smth went wrong with client io threads, issue DeleteClient here processAction StatsAction = do @@ -495,7 +577,7 @@ where st irnc = (length $ allRooms irnc, length $ allClients irnc) -processAction RestartServer = do +processAction RestartServer = do sp <- gets (shutdownPending . serverInfo) when (not sp) $ do sock <- gets (fromJust . serverSocket . serverInfo) diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/CMakeLists.txt --- a/gameServer/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -1,43 +1,44 @@ -find_program(ghc_executable ghc) - -if(NOT ghc_executable) - message(FATAL_ERROR "Cannot find GHC") -endif(NOT ghc_executable) set(hwserver_sources - OfficialServer/DBInteraction.hs - Actions.hs - ClientIO.hs - CoreTypes.hs - HWProtoCore.hs - HWProtoInRoomState.hs - HWProtoLobbyState.hs - HWProtoNEState.hs - NetRoutines.hs - Opts.hs - ServerCore.hs - Utils.hs - hedgewars-server.hs - ) + OfficialServer/DBInteraction.hs + Actions.hs + ClientIO.hs + ConfigFile.hs + Consts.hs + CoreTypes.hs + EngineInteraction.hs + HWProtoCore.hs + HWProtoInRoomState.hs + HWProtoLobbyState.hs + HWProtoNEState.hs + HandlerUtils.hs + NetRoutines.hs + Opts.hs + RoomsAndClients.hs + ServerCore.hs + ServerState.hs + Store.hs + Utils.hs + hedgewars-server.hs + ) set(hwserv_main ${hedgewars_SOURCE_DIR}/gameServer/hedgewars-server.hs) set(ghc_flags - --make ${hwserv_main} - -i${hedgewars_SOURCE_DIR}/gameServer - -o ${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX} - -odir ${CMAKE_CURRENT_BINARY_DIR} - -hidir ${CMAKE_CURRENT_BINARY_DIR}) - -set(ghc_flags ${haskell_compiler_flags_cmn} ${ghc_flags}) + --make ${hwserv_main} + -i${hedgewars_SOURCE_DIR}/gameServer + -o ${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX} + -odir ${CMAKE_CURRENT_BINARY_DIR} + -hidir ${CMAKE_CURRENT_BINARY_DIR} + ${haskell_flags}) add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}" - COMMAND "${ghc_executable}" - ARGS ${ghc_flags} - MAIN_DEPENDENCY ${hwserv_main} - DEPENDS ${hwserver_sources} - ) + COMMAND "${ghc_executable}" + ARGS ${ghc_flags} + MAIN_DEPENDENCY ${hwserv_main} + DEPENDS ${hwserver_sources} + ) add_custom_target(hedgewars-server ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}") diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/ClientIO.hs --- a/gameServer/ClientIO.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/ClientIO.hs Sun Oct 28 13:28:23 2012 +0100 @@ -43,15 +43,18 @@ clientRecvLoop :: Socket -> Chan CoreMessage -> Chan [B.ByteString] -> ClientIndex -> (forall a. IO a -> IO a) -> IO () clientRecvLoop s chan clChan ci restore = - myThreadId >>= + (myThreadId >>= \t -> (restore $ forkIO (clientSendLoop s t clChan ci) >> listenLoop s chan ci >> return "Connection closed") + `Exception.catch` (\(e :: ShutdownThreadException) -> return . B.pack . show $ e) `Exception.catch` (\(e :: Exception.IOException) -> return . B.pack . show $ e) - `Exception.catch` (\(e :: ShutdownThreadException) -> return . B.pack . show $ e) - >>= clientOff >> remove + `Exception.catch` (\(e :: Exception.SomeException) -> return . B.pack . show $ e) + >>= clientOff) `Exception.finally` remove where clientOff msg = writeChan chan $ ClientMessage (ci, ["QUIT", msg]) - remove = writeChan chan $ Remove ci + remove = do + clientOff "Client is in some weird state" + writeChan chan $ Remove ci @@ -63,12 +66,11 @@ killReciever . B.unpack $ quitMessage answer Exception.handle - (\(e :: Exception.IOException) -> unless (isQuit answer) . killReciever $ show e) $ + (\(e :: Exception.SomeException) -> unless (isQuit answer) . killReciever $ show e) $ sendAll s $ B.unlines answer `B.snoc` '\n' if isQuit answer then - do - Exception.handle (\(_ :: Exception.IOException) -> putStrLn "error on sClose") $ sClose s + sClose s else clientSendLoop s tId chan ci diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/Consts.hs --- a/gameServer/Consts.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/Consts.hs Sun Oct 28 13:28:23 2012 +0100 @@ -4,4 +4,4 @@ import qualified Data.ByteString.Char8 as B serverVersion :: B.ByteString -serverVersion = "0" +serverVersion = "1" diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/CoreTypes.hs Sun Oct 28 13:28:23 2012 +0100 @@ -34,6 +34,7 @@ pingsQueue :: !Word, isMaster :: Bool, isReady :: !Bool, + isInGame :: Bool, isAdministrator :: Bool, clientClan :: Maybe B.ByteString, teamsInGame :: Word @@ -62,24 +63,29 @@ hedgehogs :: [HedgehogInfo] } deriving (Show, Read) - + data GameInfo = GameInfo { roundMsgs :: Seq B.ByteString, leftTeams :: [B.ByteString], teamsAtStart :: [TeamInfo], + teamsInGameNumber :: Int, allPlayersHaveRegisteredAccounts :: Bool, giMapParams :: Map.Map B.ByteString B.ByteString, giParams :: Map.Map B.ByteString [B.ByteString] } deriving (Show, Read) - ---newGameInfo :: -> GameInfo -newGameInfo = + +newGameInfo :: [TeamInfo] + -> Int + -> Bool + -> Map.Map ByteString ByteString + -> Map.Map ByteString [ByteString] + -> GameInfo +newGameInfo = GameInfo Data.Sequence.empty [] - [] data RoomInfo = RoomInfo @@ -94,6 +100,7 @@ readyPlayers :: !Int, isRestrictedJoins :: Bool, isRestrictedTeams :: Bool, + roomBansList :: [B.ByteString], mapParams :: Map.Map B.ByteString B.ByteString, params :: Map.Map B.ByteString [B.ByteString] } @@ -111,6 +118,7 @@ 0 False False + [] ( Map.fromList $ Prelude.zipWith (,) ["MAP", "MAPGEN", "MAZE_SIZE", "SEED", "TEMPLATE"] @@ -134,7 +142,7 @@ latestReleaseVersion :: Word16, earliestCompatibleVersion :: Word16, listenPort :: PortNumber, - nextRoomID :: Int, + --nextRoomID :: Int, dbHost :: B.ByteString, dbName :: B.ByteString, dbLogin :: B.ByteString, @@ -154,11 +162,11 @@ ServerInfo True "

    http://www.hedgewars.org/

    " - "

    Hedgewars 0.9.16 is out! Please update.

    Download page here" - 39 - 31 -- 0.9.13 + "

    Hedgewars 0.9.17 is out! Please update.

    Download page here" + 41 + 43 -- 0.9.18 46631 - 0 + --0 "" "" "" @@ -192,6 +200,7 @@ data Notice = NickAlreadyInUse | AdminLeft + | WrongPassword deriving Enum data ShutdownException = diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/EngineInteraction.hs --- a/gameServer/EngineInteraction.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/EngineInteraction.hs Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,6 @@ module EngineInteraction where import qualified Data.Set as Set -import qualified Data.List as List import Control.Monad import qualified Codec.Binary.Base64 as Base64 import qualified Data.ByteString.Char8 as B @@ -31,6 +30,7 @@ legalMessages = Set.fromList $ "M#+LlRrUuDdZzAaSjJ,sNpPwtghbc12345" ++ slotMessages slotMessages = "\128\129\130\131\132\133\134\135\136\137\138" + gameInfo2Replay :: GameInfo -> B.ByteString gameInfo2Replay GameInfo{roundMsgs = rm, teamsAtStart = teams, diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/HWProtoCore.hs Sun Oct 28 13:28:23 2012 +0100 @@ -51,7 +51,7 @@ let clRoom = room rnc roomId let roomMasterSign = if isMaster cl then "@" else "" let adminSign = if isAdministrator cl then "@" else "" - let roomInfo = if roomId /= lobbyId then B.concat [roomMasterSign, "room ", name clRoom] else adminSign `B.append` "lobby" + let rInfo = if roomId /= lobbyId then B.concat [roomMasterSign, "room ", name clRoom] else adminSign `B.append` "lobby" let roomStatus = if isJust $ gameInfo clRoom then if teamsInGame cl > 0 then "(playing)" else "(spectating)" else @@ -65,7 +65,7 @@ nick cl, B.concat ["[", hostStr, "]"], protoNumber2ver $ clientProto cl, - B.concat ["[", roomInfo, "]", roomStatus] + B.concat ["[", rInfo, "]", roomStatus] ] diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/HWProtoInRoomState.hs Sun Oct 28 13:28:23 2012 +0100 @@ -2,7 +2,7 @@ module HWProtoInRoomState where import qualified Data.Map as Map -import Data.Sequence((|>), empty) +import Data.Sequence((|>)) import Data.List import Data.Maybe import qualified Data.ByteString.Char8 as B @@ -79,10 +79,10 @@ hhsList [_] = error "Hedgehogs list with odd elements number" hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs newTeamHHNum r = min 4 (canAddNumber r) - maxTeams r + maxTeams r | roomProto r < 38 = 6 | otherwise = 8 - + handleCmd_inRoom ["REMOVE_TEAM", tName] = do (ci, _) <- ask @@ -157,21 +157,25 @@ handleCmd_inRoom ["TOGGLE_READY"] = do cl <- thisClient chans <- roomClientsChans - return [ - ModifyClient (\c -> c{isReady = not $ isReady cl}), - ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}), - AnswerClients chans $ if clientProto cl < 38 then - [if isReady cl then "NOT_READY" else "READY", nick cl] - else - ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl] - ] + if isMaster cl then + return [] + else + return [ + ModifyRoom (\r -> r{readyPlayers = readyPlayers r + (if isReady cl then -1 else 1)}), + ModifyClient (\c -> c{isReady = not $ isReady cl}), + AnswerClients chans $ if clientProto cl < 38 then + [if isReady cl then "NOT_READY" else "READY", nick cl] + else + ["CLIENT_FLAGS", if isReady cl then "-r" else "+r", nick cl] + ] handleCmd_inRoom ["START_GAME"] = do (ci, rnc) <- ask cl <- thisClient rm <- thisRoom chans <- roomClientsChans - + + let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then @@ -179,10 +183,12 @@ return [ ModifyRoom (\r -> r{ - gameInfo = Just $ newGameInfo allPlayersRegistered (mapParams rm) (params rm) + gameInfo = Just $ newGameInfo (teams rm) (length $ teams rm) allPlayersRegistered (mapParams rm) (params rm) } - ), - AnswerClients chans ["RUN_GAME"] + ) + , AnswerClients chans ["RUN_GAME"] + , AnswerClients chans $ "CLIENT_FLAGS" : "+g" : nicks + , ModifyRoomClients (\c -> c{isInGame = True}) ] else return [Warning "Less than two clans!"] @@ -210,21 +216,20 @@ rm <- thisRoom chans <- roomClientsChans - if isMaster cl && (isJust $ gameInfo rm) then - return $ - SaveReplay - : ModifyRoom - (\r -> r{ - gameInfo = Nothing, - readyPlayers = 0 - } - ) - : UnreadyRoomClients - : answerRemovedTeams chans rm + let clTeams = map teamname . filter (\t -> teamowner t == nick cl) . teams $ rm + let unsetInGameState = [AnswerClients chans ["CLIENT_FLAGS", "-g", nick cl], ModifyClient (\c -> c{isInGame = False})] + + if isInGame cl then + if isJust $ gameInfo rm then + if (isMaster cl && isCorrect) then + return $ FinishGame : unsetInGameState + else + return $ unsetInGameState ++ map SendTeamRemovalMessage clTeams + else + return unsetInGameState else - return [] + return [] -- don't accept this message twice where - answerRemovedTeams chans = map (\t -> AnswerClients chans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo isCorrect = correctly == "1" -- compatibility with clients with protocol < 38 @@ -252,7 +257,9 @@ handleCmd_inRoom ["ROOM_NAME", newName] = do cl <- thisClient rs <- allRoomInfos - + rm <- thisRoom + chans <- sameProtoChans + return $ if not $ isMaster cl then [ProtocolError "Not room master"] @@ -260,7 +267,10 @@ if isJust $ find (\r -> newName == name r) rs then [Warning "Room with such name already exists"] else - [ModifyRoom (\r -> r{name = newName})] + [ModifyRoom roomUpdate, + AnswerClients chans ("ROOM" : "UPD" : name rm : roomInfo (nick cl) (roomUpdate rm))] + where + roomUpdate r = r{name = newName} handleCmd_inRoom ["KICK", kickNick] = do @@ -280,4 +290,16 @@ where engineMsg cl = toEngineMsg $ B.concat ["b", nick cl, "(team): ", msg, "\x20\x20"] -handleCmd_inRoom _ = return [ProtocolError "Incorrect command (state: in room)"] +handleCmd_inRoom ["BAN", banNick] = do + (_, rnc) <- ask + maybeClientId <- clientByNick banNick + let banId = fromJust maybeClientId + master <- liftM isMaster thisClient + return [ModifyRoom (\r -> r{roomBansList = (host $ rnc `client` banId) : roomBansList r}) | master && isJust maybeClientId] + + +handleCmd_inRoom ["LIST"] = return [] -- for old clients (<= 0.9.17) + +handleCmd_inRoom (s:_) = return [ProtocolError $ "Incorrect command '" `B.append` s `B.append` "' (state: in room)"] + +handleCmd_inRoom [] = return [ProtocolError "Empty command (state: in room)"] diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/HWProtoLobbyState.hs Sun Oct 28 13:28:23 2012 +0100 @@ -6,6 +6,7 @@ import Data.Maybe import Data.List import Control.Monad.Reader +import qualified Data.ByteString.Char8 as B -------------------------------------- import CoreTypes import Actions @@ -24,6 +25,7 @@ AnswerClients [clChan] ["TEAM_COLOR", teamname team, teamcolor team], AnswerClients [clChan] ["HH_NUM", teamname team, showB $ hhnum team]] + handleCmd_lobby :: CmdHandler @@ -31,19 +33,8 @@ (ci, irnc) <- ask let cl = irnc `client` ci rooms <- allRoomInfos - let roomsInfoList = concatMap (roomInfo irnc) . filter (\r -> (roomProto r == clientProto cl) && not (isRestrictedJoins r)) + let roomsInfoList = concatMap (\r -> roomInfo (nick $ irnc `client` masterID r) r) . filter (\r -> (roomProto r == clientProto cl)) return [AnswerClients [sendChan cl] ("ROOMS" : roomsInfoList rooms)] - where - roomInfo irnc r = [ - showB $ isJust $ gameInfo r, - name r, - showB $ playersIn r, - showB $ length $ teams r, - nick $ irnc `client` masterID r, - Map.findWithDefault "+rnd+" "MAP" (mapParams r), - head (Map.findWithDefault ["Default"] "SCHEME" (params r)), - head (Map.findWithDefault ["Default"] "AMMO" (params r)) - ] handleCmd_lobby ["CHAT", msg] = do @@ -60,8 +51,10 @@ [Warning "Room exists"] else [ - AddRoom rName roomPassword, - AnswerClients [sendChan cl] ["CLIENT_FLAGS", "-r", nick cl] + AddRoom rName roomPassword + , AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl] + , ModifyClient (\cl -> cl{isMaster = True, isReady = True}) + , ModifyRoom (\r -> r{readyPlayers = 1}) ] @@ -79,19 +72,25 @@ let sameProto = clientProto cl == roomProto jRoom let jRoomClients = map (client irnc) $ roomClients irnc jRI let nicks = map nick jRoomClients + let ownerNick = nick . fromJust $ find isMaster jRoomClients let chans = map sendChan (cl : jRoomClients) + let isBanned = host cl `elem` roomBansList jRoom return $ - if isNothing maybeRI || not sameProto then + if isNothing maybeRI || not sameProto then [Warning "No such room"] else if isRestrictedJoins jRoom then [Warning "Joining restricted"] + else if isBanned then + [Warning "You are banned in this room"] else if roomPassword /= password jRoom then - [Warning "Wrong password"] + [NoticeMessage WrongPassword] else [ - MoveToRoom jRI, - AnswerClients [sendChan cl] $ "JOINED" : nicks, - AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] + MoveToRoom jRI + , AnswerClients [sendChan cl] $ "JOINED" : nicks + , AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] + , AnswerClients [sendChan cl] $ ["WARNING", "Room admin is " `B.append` ownerNick] + , AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", ownerNick] ] ++ map (readynessMessage cl) jRoomClients ++ answerFullConfig cl (mapParams jRoom) (params jRoom) @@ -134,7 +133,6 @@ handleCmd_lobby ["FOLLOW", asknick] = do (_, rnc) <- ask ci <- clientByNick asknick - cl <- thisClient let ri = clientRoom rnc $ fromJust ci let clRoom = room rnc ri if isNothing ci || ri == lobbyId then @@ -157,18 +155,21 @@ cl <- thisClient banId <- clientByNick banNick return [BanClient 60 reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci] - + handleCmd_lobby ["BANIP", ip, reason, duration] = do - (ci, _) <- ask cl <- thisClient return [BanIP ip (readInt_ duration) reason | isAdministrator cl] - + handleCmd_lobby ["BANLIST"] = do - (ci, _) <- ask cl <- thisClient return [BanList | isAdministrator cl] +handleCmd_lobby ["UNBAN", entry] = do + cl <- thisClient + return [Unban entry | isAdministrator cl] + + handleCmd_lobby ["SET_SERVER_VAR", "MOTD_NEW", newMessage] = do cl <- thisClient return [ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator cl] @@ -182,7 +183,7 @@ return [ModifyServerInfo (\si -> si{latestReleaseVersion = readNum}) | isAdministrator cl && readNum > 0] where readNum = readInt_ protoNum - + handleCmd_lobby ["GET_SERVER_VAR"] = do cl <- thisClient return [SendServerVars | isAdministrator cl] @@ -193,7 +194,7 @@ handleCmd_lobby ["RESTART_SERVER"] = do cl <- thisClient - return [RestartServer] + return [RestartServer | isAdministrator cl] handleCmd_lobby _ = return [ProtocolError "Incorrect command (state: in lobby)"] diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/HandlerUtils.hs --- a/gameServer/HandlerUtils.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/HandlerUtils.hs Sun Oct 28 13:28:23 2012 +0100 @@ -48,6 +48,12 @@ (ci, rnc) <- ask return [sendChan (rnc `client` ci)] +sameProtoChans :: Reader (ClientIndex, IRnC) [ClientChan] +sameProtoChans = do + (ci, rnc) <- ask + let p = clientProto (rnc `client` ci) + return . map sendChan . filter (\c -> clientProto c == p) . map (client rnc) $ allClients rnc + answerClient :: [B.ByteString] -> Reader (ClientIndex, IRnC) [Action] answerClient msg = liftM ((: []) . flip AnswerClients msg) thisClientChans diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/NetRoutines.hs Sun Oct 28 13:28:23 2012 +0100 @@ -3,7 +3,6 @@ import Network.Socket import Control.Concurrent.Chan -import qualified Control.Exception as Exception import Data.Time import Control.Monad import Data.Unique @@ -41,6 +40,7 @@ False False False + False Nothing 0 ) diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/OfficialServer/DBInteraction.hs --- a/gameServer/OfficialServer/DBInteraction.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/OfficialServer/DBInteraction.hs Sun Oct 28 13:28:23 2012 +0100 @@ -60,7 +60,7 @@ CheckAccount clId clUid clNick _ -> do let cacheEntry = clNick `Map.lookup` accountsCache currentTime <- getCurrentTime - if (isNothing cacheEntry) || (currentTime `diffUTCTime` (fst . fromJust) cacheEntry > 2 * 24 * 60 * 60) then + if (isNothing cacheEntry) || (currentTime `diffUTCTime` (fst . fromJust) cacheEntry > 10 * 60) then do SIO.hPutStrLn hIn $ show q hFlush hIn diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/RoomsAndClients.hs --- a/gameServer/RoomsAndClients.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/RoomsAndClients.hs Sun Oct 28 13:28:23 2012 +0100 @@ -1,3 +1,5 @@ +{-# LANGUAGE BangPatterns, GeneralizedNewtypeDeriving #-} + module RoomsAndClients( RoomIndex(), ClientIndex(), @@ -34,24 +36,25 @@ import Store import Control.Monad +import Control.DeepSeq data Room r = Room { - roomClients' :: [ClientIndex], - room' :: r + roomClients' :: ![ClientIndex], + room' :: !r } data Client c = Client { - clientRoom' :: RoomIndex, - client' :: c + clientRoom' :: !RoomIndex, + client' :: !c } newtype RoomIndex = RoomIndex ElemIndex - deriving (Eq) + deriving (Eq, NFData) newtype ClientIndex = ClientIndex ElemIndex - deriving (Eq, Show, Read, Ord) + deriving (Eq, Show, Read, Ord, NFData) instance Show RoomIndex where show (RoomIndex i) = 'r' : show i @@ -82,10 +85,10 @@ roomAddClient :: ClientIndex -> Room r -> Room r -roomAddClient cl rm = let cls = cl : roomClients' rm; nr = rm{roomClients' = cls} in cls `seq` nr +roomAddClient cl rm = let cls = cl : roomClients' rm; nr = rm{roomClients' = cls} in cls `deepseq` nr roomRemoveClient :: ClientIndex -> Room r -> Room r -roomRemoveClient cl rm = let cls = filter (/= cl) $ roomClients' rm; nr = rm{roomClients' = cls} in cls `seq` nr +roomRemoveClient cl rm = let cls = filter (/= cl) $ roomClients' rm; nr = rm{roomClients' = cls} in cls `deepseq` nr addRoom :: MRoomsAndClients r c -> r -> IO RoomIndex diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/ServerCore.hs --- a/gameServer/ServerCore.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/ServerCore.hs Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,5 @@ module ServerCore where -import Network import Control.Concurrent import Control.Monad import System.Log.Logger @@ -43,7 +42,7 @@ ClientMessage (ci, cmd) -> do liftIO $ debugM "Clients" $ show ci ++ ": " ++ show cmd - + removed <- gets removedClients unless (ci `Set.member` removed) $ do modify (\s -> s{clientIndex = Just ci}) @@ -75,8 +74,6 @@ (fromJust $ serverSocket si) (coreChan si) - return () - _ <- forkIO $ timerLoop 0 $ coreChan si startDBConnection si diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/ServerState.hs --- a/gameServer/ServerState.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/ServerState.hs Sun Oct 28 13:28:23 2012 +0100 @@ -6,11 +6,13 @@ client's, allClientsS, roomClientsS, + sameProtoClientsS, io ) where import Control.Monad.State.Strict -import Data.Set as Set +import Data.Set as Set(Set) +import Data.Word ---------------------- import RoomsAndClients import CoreTypes @@ -43,5 +45,10 @@ rnc <- gets roomsClients io $ roomClientsM rnc ri +sameProtoClientsS :: Word16 -> StateT ServerState IO [ClientInfo] +sameProtoClientsS p = liftM f allClientsS + where + f = filter (\c -> clientProto c == p) + io :: IO a -> StateT ServerState IO a io = liftIO diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/Store.hs --- a/gameServer/Store.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/Store.hs Sun Oct 28 13:28:23 2012 +0100 @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns, GeneralizedNewtypeDeriving #-} module Store( ElemIndex(), MStore(), @@ -17,17 +18,18 @@ indices ) where -import qualified Data.Array.IArray as IA -import qualified Data.Array.IO as IOA import qualified Data.IntSet as IntSet +import qualified Data.Vector as V +import qualified Data.Vector.Mutable as MV import Data.IORef import Control.Monad +import Control.DeepSeq newtype ElemIndex = ElemIndex Int - deriving (Eq, Show, Read, Ord) -newtype MStore e = MStore (IORef (IntSet.IntSet, IntSet.IntSet, IOA.IOArray Int e)) -newtype IStore e = IStore (IntSet.IntSet, IA.Array Int e) + deriving (Eq, Show, Read, Ord, NFData) +newtype MStore e = MStore (IORef (IntSet.IntSet, IntSet.IntSet, MV.IOVector e)) +newtype IStore e = IStore (IntSet.IntSet, V.Vector e) firstIndex :: ElemIndex @@ -48,7 +50,7 @@ newStore :: IO (MStore e) newStore = do - newar <- IOA.newArray_ (0, initialSize - 1) + newar <- MV.new initialSize new <- newIORef (IntSet.empty, IntSet.fromAscList [0..initialSize - 1], newar) return (MStore new) @@ -56,11 +58,10 @@ growStore :: MStore e -> IO () growStore (MStore ref) = do (busyElems, freeElems, arr) <- readIORef ref - (_, m') <- IOA.getBounds arr - let newM' = growFunc (m' + 1) - 1 - newArr <- IOA.newArray_ (0, newM') - sequence_ [IOA.readArray arr i >>= IOA.writeArray newArr i | i <- [0..m']] - writeIORef ref (busyElems, freeElems `IntSet.union` IntSet.fromAscList [m'+1..newM'], newArr) + let oldSize = MV.length arr + let newSize = growFunc oldSize + newArr <- MV.grow arr (newSize - oldSize) + writeIORef ref (busyElems, freeElems `IntSet.union` IntSet.fromAscList [oldSize .. newSize-1], newArr) growIfNeeded :: MStore e -> IO () @@ -72,20 +73,18 @@ truncateIfNeeded :: MStore e -> IO () truncateIfNeeded (MStore ref) = do (busyElems, _, arr) <- readIORef ref - (_, m') <- IOA.getBounds arr - let newM' = truncFunc (m' + 1) - 1 - when (newM' < m' && (not $ IntSet.null busyElems) && IntSet.findMax busyElems <= newM') $ do - newArr <- IOA.newArray_ (0, newM') - sequence_ [IOA.readArray arr i >>= IOA.writeArray newArr i | i <- IntSet.toList busyElems] - writeIORef ref (busyElems, IntSet.fromAscList [0..newM'] `IntSet.difference` busyElems, newArr) + let oldSize = MV.length arr + let newSize = truncFunc oldSize + when (newSize < oldSize && (not $ IntSet.null busyElems) && IntSet.findMax busyElems < newSize) $ do + writeIORef ref (busyElems, IntSet.fromAscList [0..newSize - 1] `IntSet.difference` busyElems, MV.take newSize arr) addElem :: MStore e -> e -> IO ElemIndex addElem m@(MStore ref) element = do growIfNeeded m (busyElems, freeElems, arr) <- readIORef ref - let (n, freeElems') = IntSet.deleteFindMin freeElems - IOA.writeArray arr n element + let (!n, freeElems') = IntSet.deleteFindMin freeElems + MV.write arr n element writeIORef ref (IntSet.insert n busyElems, freeElems', arr) return $ ElemIndex n @@ -93,32 +92,32 @@ removeElem :: MStore e -> ElemIndex -> IO () removeElem m@(MStore ref) (ElemIndex n) = do (busyElems, freeElems, arr) <- readIORef ref - IOA.writeArray arr n (error $ "Store: no element " ++ show n) + MV.write arr n (error $ "Store: no element " ++ show n) writeIORef ref (IntSet.delete n busyElems, IntSet.insert n freeElems, arr) truncateIfNeeded m readElem :: MStore e -> ElemIndex -> IO e -readElem (MStore ref) (ElemIndex n) = readIORef ref >>= \(_, _, arr) -> IOA.readArray arr n +readElem (MStore ref) (ElemIndex n) = readIORef ref >>= \(_, _, arr) -> MV.read arr n writeElem :: MStore e -> ElemIndex -> e -> IO () -writeElem (MStore ref) (ElemIndex n) el = readIORef ref >>= \(_, _, arr) -> IOA.writeArray arr n el +writeElem (MStore ref) (ElemIndex n) el = readIORef ref >>= \(_, _, arr) -> MV.write arr n el modifyElem :: MStore e -> (e -> e) -> ElemIndex -> IO () modifyElem (MStore ref) f (ElemIndex n) = do (_, _, arr) <- readIORef ref - IOA.readArray arr n >>= IOA.writeArray arr n . f + MV.read arr n >>= MV.write arr n . f elemExists :: MStore e -> ElemIndex -> IO Bool elemExists (MStore ref) (ElemIndex n) = do - (_, free, _) <- readIORef ref + (_, !free, _) <- readIORef ref return $ n `IntSet.notMember` free indicesM :: MStore e -> IO [ElemIndex] indicesM (MStore ref) = do - (busy, _, _) <- readIORef ref + (!busy, _, _) <- readIORef ref return $ map ElemIndex $ IntSet.toList busy @@ -126,13 +125,13 @@ m2i :: MStore e -> IO (IStore e) m2i (MStore ref) = do (a, _, c') <- readIORef ref - c <- IOA.unsafeFreeze c' + c <- V.unsafeFreeze c' return $ IStore (a, c) i2m :: MStore e -> IStore e -> IO () i2m (MStore ref) (IStore (_, arr)) = do (b, e, _) <- readIORef ref - a <- IOA.unsafeThaw arr + a <- V.unsafeThaw arr writeIORef ref (b, e, a) withIStore :: MStore e -> (IStore e -> a) -> IO a @@ -155,7 +154,7 @@ -- IStore code (!) :: IStore e -> ElemIndex -> e -(!) (IStore (_, arr)) (ElemIndex i) = (IA.!) arr i +(!) (IStore (_, arr)) (ElemIndex i) = (V.!) arr i indices :: IStore e -> [ElemIndex] indices (IStore (busy, _)) = map ElemIndex $ IntSet.toList busy diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/Utils.hs --- a/gameServer/Utils.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/Utils.hs Sun Oct 28 13:28:23 2012 +0100 @@ -4,19 +4,17 @@ import Data.Char import Data.Word import qualified Data.Map as Map -import qualified Data.Set as Set import qualified Data.Char as Char import Numeric import Network.Socket import System.IO import qualified Data.List as List import Control.Monad -import qualified Codec.Binary.Base64 as Base64 import qualified Data.ByteString.Lazy as BL import qualified Text.Show.ByteString as BS import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.UTF8 as UTF8 -import qualified Data.ByteString as BW +import Data.Maybe ------------------------------------------------- import CoreTypes @@ -88,6 +86,8 @@ , (38, "0.9.16-dev") , (39, "0.9.16") , (40, "0.9.17-dev") + , (41, "0.9.17") + , (42, "0.9.18-dev") ] askFromConsole :: B.ByteString -> IO B.ByteString @@ -119,3 +119,16 @@ caseInsensitiveCompare a b = f a == f b where f = map Char.toUpper . UTF8.toString + + +roomInfo :: B.ByteString -> RoomInfo -> [B.ByteString] +roomInfo n r = [ + showB $ isJust $ gameInfo r, + name r, + showB $ playersIn r, + showB $ length $ teams r, + n, + Map.findWithDefault "+rnd+" "MAP" (mapParams r), + head (Map.findWithDefault ["Default"] "SCHEME" (params r)), + head (Map.findWithDefault ["Default"] "AMMO" (params r)) + ] diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/hedgewars-server.cabal --- a/gameServer/hedgewars-server.cabal Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/hedgewars-server.cabal Sun Oct 28 13:28:23 2012 +0100 @@ -18,7 +18,7 @@ base >= 4.3, unix, containers, - array, + vector, bytestring, bytestring-show, network >= 2.3, diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/stresstest.hs --- a/gameServer/stresstest.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/stresstest.hs Sun Oct 28 13:28:23 2012 +0100 @@ -14,10 +14,10 @@ import System.Posix #endif -session 0 nick room = ["NICK", nick, "", "PROTO", "38", "", "PING", "", "CHAT", "lobby 1", "", "PONG", "", "CREATE_ROOM", room, "", "CHAT", "room 1", "", "QUIT", "creator", ""] -session 1 nick room = ["NICK", nick, "", "PROTO", "38", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "part-quit", ""] -session 2 nick room = ["NICK", nick, "", "PROTO", "38", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "QUIT", "quit", ""] -session 3 nick room = ["NICK", nick, "", "PROTO", "38", "", "CHAT", "lobby 1", "", "CREATE_ROOM", room, "", "", "PONG", "CHAT", "room 1", "", "PART", "creator", "", "QUIT", "part-quit", ""] +session 0 nick room = ["NICK", nick, "", "PROTO", "42", "", "PING", "", "CHAT", "lobby 1", "", "PONG", "", "CREATE_ROOM", room, "", "CHAT", "room 1", "", "QUIT", "creator", ""] +session 1 nick room = ["NICK", nick, "", "PROTO", "42", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "part-quit", ""] +session 2 nick room = ["NICK", nick, "", "PROTO", "42", "", "LIST", "", "JOIN_ROOM", room, "", "PONG", "", "CHAT", "room 2", "", "QUIT", "quit", ""] +session 3 nick room = ["NICK", nick, "", "PROTO", "42", "", "CHAT", "lobby 1", "", "CREATE_ROOM", room, "", "", "PONG", "CHAT", "room 1", "", "PART", "creator", "", "QUIT", "part-quit", ""] emulateSession sock s = do mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (100000::Int, 600000) >>= threadDelay) s diff -r 41b0a9955c47 -r ddcdedd3330b gameServer/stresstest3.hs --- a/gameServer/stresstest3.hs Thu Nov 24 13:44:30 2011 +0100 +++ b/gameServer/stresstest3.hs Sun Oct 28 13:28:23 2012 +0100 @@ -47,7 +47,7 @@ waitPacket "CONNECTED" sendPacket ["NICK", "test" ++ show n] waitPacket "NICK" - sendPacket ["PROTO", "31"] + sendPacket ["PROTO", "41"] waitPacket "PROTO" b <- waitPacket "LOBBY:JOINED" --io $ print b diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/ArgParsers.inc --- a/hedgewars/ArgParsers.inc Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/ArgParsers.inc Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,51 +16,54 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) -procedure playReplayFileWithParameters(); forward; - -procedure internalSetGameTypeLandPreviewFromParameters(); -begin - if ParamStr(3) = '--stats-only' then - playReplayFileWithParameters() - else - begin - val(ParamStr(2), ipcPort); - GameType:= gmtLandPreview; - if ParamStr(3) <> 'landpreview' then - GameType:= gmtSyntax - end -end; procedure internalStartGameWithParameters(); var tmp: LongInt; begin UserPathPrefix:= ParamStr(1); - val(ParamStr(2), cScreenWidth); - val(ParamStr(3), cScreenHeight); - val(ParamStr(4), cBits); - val(ParamStr(5), ipcPort); + cScreenWidth:= StrToInt(ParamStr(2)); + cScreenHeight:= StrToInt(ParamStr(3)); + cBits:= StrToInt(ParamStr(4)); + ipcPort:= StrToInt(ParamStr(5)); cFullScreen:= ParamStr(6) = '1'; - isSoundEnabled:= ParamStr(7) = '1'; - isMusicEnabled:= ParamStr(8) = '1'; - val(ParamStr(9), cInitVolume); - val(ParamStr(10), cTimerInterval); + SetSound(ParamStr(7) = '1'); + SetMusic(ParamStr(8) = '1'); + SetVolume(StrToInt(ParamStr(9))); + cTimerInterval:= StrToInt(ParamStr(10)); PathPrefix:= ParamStr(11); cShowFPS:= ParamStr(12) = '1'; cAltDamage:= ParamStr(13) = '1'; UserNick:= DecodeBase64(ParamStr(14)); - val(ParamStr(15), cReducedQuality); - val(ParamStr(16), tmp); - cGrayScale:= false; + cReducedQuality:= StrToInt(ParamStr(15)); + tmp:= StrToInt(ParamStr(16)); + GrayScale:= false; if (tmp > 9) and (tmp < 16) then begin - cGrayScale:= true; + GrayScale:= true; cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) end - else if tmp <= 9 then cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) - else cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); + else if tmp <= 9 then + cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) + else + cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); cLocaleFName:= ParamStr(17); end; +{$IFDEF USE_VIDEO_RECORDING} +procedure internalStartVideoRecordingWithParameters(); +begin + internalStartGameWithParameters(); + GameType:= gmtRecord; + cVideoFramerateNum:= StrToInt(ParamStr(18)); + cVideoFramerateDen:= StrToInt(ParamStr(19)); + RecPrefix:= ParamStr(20); + cAVFormat:= ParamStr(21); + cVideoCodec:= ParamStr(22); + cVideoQuality:= StrToInt(ParamStr(23)); + cAudioCodec:= ParamStr(24); +end; +{$ENDIF} + procedure setVideo(screenWidth: LongInt; screenHeight: LongInt; bitsStr: LongInt); begin cScreenWidth:= screenWidth; @@ -69,11 +72,11 @@ end; procedure setVideoWithParameters(screenWidthParam: string; screenHeightParam: string; bitsParam: string); -var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt: LongInt; +var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt, c: LongInt; begin - val(screenWidthParam, screenWidthAsInt); - val(screenHeightParam, screenHeightAsInt); - val(bitsParam, bitsStrAsInt); + val(screenWidthParam, screenWidthAsInt, c); + val(screenHeightParam, screenHeightAsInt, c); + val(bitsParam, bitsStrAsInt, c); setVideo(screenWidthAsInt,screenHeightAsInt,bitsStrAsInt) end; @@ -99,16 +102,16 @@ procedure setAudio(initialVolume: LongInt; musicEnabled: boolean; soundEnabled: boolean); begin - cInitVolume:= initialVolume; - isMusicEnabled:= musicEnabled; - isSoundEnabled:= soundEnabled + SetVolume(initialVolume); + SetMusic(musicEnabled); + SetSound(soundEnabled); end; procedure setAudioWithParameters(initialVolumeParam: string; musicEnabledParam: string; soundEnabledParam: string); -var initialVolumeAsInt: LongInt; +var initialVolumeAsInt, c: LongInt; musicEnabled, soundEnabled: boolean; begin - val(initialVolumeParam, initialVolumeAsInt); + val(initialVolumeParam, initialVolumeAsInt, c); musicEnabled:= musicEnabledParam = '1'; soundEnabled:= soundEnabledParam = '1'; setAudio(initialVolumeAsInt,musicEnabled, soundEnabled) @@ -136,7 +139,7 @@ languageFileParam:string; fullScreenParam:string; showFPSParam:string; altDamageParam:string; timeItervalParam:string; reducedQualityParam: string); var showFPS, altDamage, reducedQuality: boolean; - timeIterval: LongInt; + timeIterval, c: LongInt; begin setMultimediaOptionsWithParameters(screenWidthParam,screenHeightParam, bitsParam, initialVolumeParam,musicEnabledParam,soundEnabledParam, @@ -145,7 +148,7 @@ setShowFPS(showFPS); altDamage:= altDamageParam = '1'; - val(timeItervalParam, timeIterval); + val(timeItervalParam, timeIterval, c); reducedQuality:= reducedQualityParam = '1'; setAltDamageTimerValueAndQuality(altDamage,timeIterval,reducedQuality); end; @@ -159,7 +162,7 @@ recordFileName:= ParamStr(3); paramIndex:= 4; wrongParameter:= false; - while (paramIndex <= ParamCount) and not wrongParameter do + while (paramIndex <= ParamCount) and (not wrongParameter) do begin if ParamStr(paramIndex) = '--set-video' then //--set-video [screen width] [screen height] [color dept] @@ -229,8 +232,8 @@ if ParamStr(paramIndex) = '--stats-only' then begin cOnlyStats:= true; - isSoundEnabled:= false; - isMusicEnabled:= false; + SetSound(false); + SetMusic(false); cReducedQuality:= $FFFFFFFF xor rqLowRes; // HACK paramIndex:= paramIndex + 1 end diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -3,7 +3,6 @@ find_package(SDL_net) find_package(SDL_ttf) find_package(SDL_mixer) -find_package(Lua) include(${CMAKE_MODULE_PATH}/FindSDL_Extras.cmake) @@ -15,9 +14,12 @@ set(engine_sources ${hwengine_project} + LuaPas.pas + PNGh.pas SDLh.pas uAI.pas uAIActions.pas + uAILandMarks.pas uAIAmmoTests.pas uAIMisc.pas uAmmos.pas @@ -28,16 +30,24 @@ uCommandHandlers.pas uConsole.pas uConsts.pas + uCursor.pas uDebug.pas uFloat.pas uGame.pas uGears.pas + uGearsHandlers.pas + uGearsHandlersRope.pas + uGearsHedgehog.pas + uGearsList.pas uGearsRender.pas + uGearsUtils.pas uIO.pas - uKeys.pas + uInputHandler.pas uLand.pas + uLandGenMaze.pas uLandGraphics.pas uLandObjects.pas + uLandOutline.pas uLandPainted.pas uLandTemplates.pas uLandTexture.pas @@ -54,14 +64,15 @@ uStore.pas uTeams.pas uTextures.pas + uTouch.pas uTypes.pas uUtils.pas uVariables.pas + uVideoRec.pas uVisualGears.pas uWorld.pas GSHandlers.inc VGSHandlers.inc - HHHandlers.inc ArgParsers.inc options.inc adler32.pas @@ -71,17 +82,16 @@ if(BUILD_ENGINE_LIBRARY) message(STATUS "Engine will be built as library (experimental)") set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas) - set(engine_sources ${hwengine_project} PascalExports.pas ${engine_sources}) - set(pascal_compiler_flags_cmn "-dHWLIBRARY" ${pascal_compiler_flags_cmn}) + set(pascal_flags "-dHWLIBRARY" ${pascal_flags}) # create position independent code, only required for x68_64 builds, similar to -fPIC if(CMAKE_SIZEOF_VOID_P MATCHES "8") - set(pascal_compiler_flags_cmn "-Cg" ${pascal_compiler_flags_cmn}) + set(pascal_flags "-Cg" ${pascal_flags}) endif(CMAKE_SIZEOF_VOID_P MATCHES "8") - # due to compiling/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail + # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail if(APPLE AND current_macosx_version GREATER "10.5") - set(pascal_compiler_flags_cmn "-k-no_order_inits" ${pascal_compiler_flags_cmn}) + set(pascal_flags "-k-no_order_inits" ${pascal_flags}) endif() if (APPLE) @@ -89,7 +99,11 @@ endif (APPLE) endif(BUILD_ENGINE_LIBRARY) -find_program(fpc_executable fpc) +IF(FPC) + set(fpc_executable ${FPC}) +ELSE() + find_program(fpc_executable fpc) +ENDIF() if(fpc_executable) exec_program(${fpc_executable} ARGS "-iV" OUTPUT_VARIABLE fpc_output) @@ -117,6 +131,26 @@ if(powerpc_build) set(powerpc_build "powerpc") endif() + + #on OSX we need to provide the SDL_main() function when building as executable + if(NOT BUILD_ENGINE_LIBRARY) + #let's look for the installed sdlmain file; if it is not found, let's build our own + find_package(SDL REQUIRED) + #remove the ";-framework Cocoa" from the SDL_LIBRARY variable + string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}") + #find libsdmain.a + find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/) + + if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") + include_directories(${SDL_INCLUDE_DIR}) + add_library (SDLmain STATIC SDLMain.m) + #add a dependency to the hwengine target + set(engine_sources ${engine_sources} SDLmain) + set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a") + endif() + + set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags}) + endif() endif(APPLE) @@ -127,49 +161,86 @@ string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") - message(STATUS "Freepascal version installed: ${fpc_vers_major}.${fpc_vers_minor}") - math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") + message(STATUS "Found Freepascal: ${fpc_executable} (version ${fpc_vers_major}.${fpc_vers_minor})") + math(EXPR fpc_version "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") - if(fpc_ver LESS "020200") + if(fpc_version LESS "020200") message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0") - elseif(APPLE AND x86_64_build AND (fpc_ver LESS "020400")) - message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications on Mac OS X") + elseif(APPLE AND (fpc_version LESS "020600")) + message(FATAL_ERROR "Minimum required version of FreePascal is 2.6.0 on Mac OS X") endif() else() - message(FATAL_ERROR "No Pascal compiler found!") + message(FATAL_ERROR "No FreePascal compiler found!") endif() -set(pascal_compiler ${fpc_executable}) -set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project}) - #DEPENDECIES AND EXECUTABLES SECTION +if(NOT NOPNG) + find_package(PNG) + if(${PNG_FOUND}) + set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags}) + if(APPLE) # fpc png unit doesn't pull the library (see bug 21833) + set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags}) + endif() + else() + message(STATUS "Screenshots will be in BMP format because libpng was not found") + endif() +else() + message(STATUS "Screenshots will be in BMP format per user request") +endif() + + + +#this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 +if(fpc_version LESS "020600") + add_custom_target(ENGINECLEAN COMMAND ${CMAKE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars") +endif() + + +if(NOT NOVIDEOREC) + set(FFMPEG_FIND_QUIETLY true) + find_package(FFMPEG) + if(${FFMPEG_FOUND}) + include_directories(${FFMPEG_INCLUDE_DIR}) + set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags}) + IF (WIN32) + # there are some problems with linking our avwrapper as static lib, so link it as shared + add_library(avwrapper SHARED avwrapper.c) + target_link_libraries(avwrapper ${FFMPEG_LIBRARIES}) + install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_dir}) + ELSE() + add_library(avwrapper STATIC avwrapper.c) + set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags}) + ENDIF() + if(fpc_version LESS "020600") + add_dependencies(avwrapper ENGINECLEAN) + endif() + else() + message(STATUS "Could NOT find FFMPEG/LibAV, video recording will be disabled") + endif() +else() + message(STATUS "Video recording disabled by user") +endif() + +set(fpc_flags ${noexecstack_flags} ${pascal_flags} ${hwengine_project}) + IF(NOT APPLE) #here is the command for standard executables or for shared library add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" - COMMAND "${pascal_compiler}" - ARGS ${pascal_compiler_flags} + COMMAND "${fpc_executable}" + ARGS ${fpc_flags} MAIN_DEPENDENCY ${hwengine_project} DEPENDS ${engine_sources} ) ELSE() - #let's build sdlmain, which is absent from the framework - find_package(SDL REQUIRED) - - set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) - include_directories(${SDL_INCLUDE_DIR}) - - add_library (SDLmain STATIC SDLMain.m) - - #these are the dependencies for building a universal binary on Mac OS X foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build}) set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list}) add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" - COMMAND "${pascal_compiler}" - ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch} + COMMAND "${fpc_executable}" + ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch} MAIN_DEPENDENCY ${hwengine_project} - DEPENDS ${engine_sources} SDLmain lua + DEPENDS ${engine_sources} ) add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}") endforeach() @@ -183,10 +254,15 @@ add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}") -IF(NOT APPLE) - add_custom_target(ENGINECLEAN COMMAND ${CMAKE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars") + +#when system Lua is not found we need to compile it before engine +if(NOT LUA_FOUND) + add_dependencies(${engine_output_name} lua) +endif() + +#this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 +if((fpc_version LESS "020600") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND})) add_dependencies(${engine_output_name} ENGINECLEAN) -ENDIF() +endif() install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) - diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/GL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/GL.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,3 @@ +#pragma once + +#include diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/GSHandlers.inc Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,6 +53,7 @@ sX:= dX / steps; sY:= dY / steps; end + else begin sX:= dX; @@ -84,216 +85,83 @@ if (gi^.Kind = gtHedgehog) then begin d := r - hwRound(Distance(gi^.X - x, gi^.Y - y)); - if (d > 1) and not gi^.Invulnerable and (GetRandom(2) = 0) then + if (d > 1) and (not gi^.Invulnerable) and (GetRandom(2) = 0) then begin if (CurrentHedgehog^.Gear = gi) then - PlaySound(sndOops, gi^.Hedgehog^.Team^.voicepack) + PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) + else begin if (gi^.State and gstMoving) = 0 then + begin + gi^.dX.isNegative:= X r div 2 then - PlaySound(sndNooo, gi^.Hedgehog^.Team^.voicepack) + PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) else - PlaySound(sndUhOh, gi^.Hedgehog^.Team^.voicepack); + PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack); end; end; end; + gi := gi^.NextGear end; end; procedure HideHog(HH: PHedgehog); begin -ScriptCall('onHogHide', HH^.Gear^.Uid); -DeleteCI(HH^.Gear); -if FollowGear = HH^.Gear then FollowGear:= nil; -if lastGearByUID = HH^.Gear then lastGearByUID := nil; -RemoveGearFromList(HH^.Gear); -with HH^.Gear^ do - begin - Z := cHHZ; - Active := false; - State:= State and not (gstHHDriven or gstAttacking or gstAttacked); - Message := Message and not gmAttack; + ScriptCall('onHogHide', HH^.Gear^.Uid); + DeleteCI(HH^.Gear); + if FollowGear = HH^.Gear then + FollowGear:= nil; + + if lastGearByUID = HH^.Gear then + lastGearByUID := nil; + + HH^.Gear^.Message:= HH^.Gear^.Message or gmRemoveFromList; + with HH^.Gear^ do + begin + Z := cHHZ; + HH^.Gear^.Active:= false; + State:= State and (not (gstHHDriven or gstAttacking or gstAttacked)); + Message := Message and (not gmAttack); end; -HH^.GearHidden:= HH^.Gear; -HH^.Gear:= nil + HH^.GearHidden:= HH^.Gear; + HH^.Gear:= nil end; procedure RestoreHog(HH: PHedgehog); begin -HH^.Gear:=HH^.GearHidden; -HH^.GearHidden:= nil; -InsertGearToList(HH^.Gear); -HH^.Gear^.State:= (HH^.Gear^.State and not (gstHHDriven or gstInvisible or gstAttacking)) or gstAttacked; -AddGearCI(HH^.Gear); -HH^.Gear^.Active:= true; -ScriptCall('onHogRestore', HH^.Gear^.Uid) + HH^.Gear:=HH^.GearHidden; + HH^.GearHidden:= nil; + InsertGearToList(HH^.Gear); + HH^.Gear^.State:= (HH^.Gear^.State and (not (gstHHDriven or gstInvisible or gstAttacking))) or gstAttacked; + AddGearCI(HH^.Gear); + HH^.Gear^.Active:= true; + ScriptCall('onHogRestore', HH^.Gear^.Uid) end; + //////////////////////////////////////////////////////////////////////////////// procedure doStepDrowningGear(Gear: PGear); -forward; - -function CheckGearDrowning(Gear: PGear): boolean; -var - skipSpeed, skipAngle, skipDecay: hwFloat; - i, maxDrops, X, Y: LongInt; - vdX, vdY: real; - particle: PVisualGear; - isSubmersible: boolean; -begin - isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); - // probably needs tweaking. might need to be in a case statement based upon gear type - Y:= hwRound(Gear^.Y); - if cWaterLine < Y + Gear^.Radius then - begin - skipSpeed := _0_25; - skipAngle := _1_9; - skipDecay := _0_87; - X:= hwRound(Gear^.X); - vdX:= hwFloat2Float(Gear^.dX); - vdY:= hwFloat2Float(Gear^.dY); - // this could perhaps be a tiny bit higher. - if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) and - (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then - begin - Gear^.dY.isNegative := true; - Gear^.dY := Gear^.dY * skipDecay; - Gear^.dX := Gear^.dX * skipDecay; - CheckGearDrowning := false; - PlaySound(sndSkip) - end - else - begin - if not isSubmersible then - begin - CheckGearDrowning := true; - Gear^.State := gstDrowning; - Gear^.RenderTimer := false; - if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) and - (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then - if Gear^.Kind = gtHedgehog then - begin - if Gear^.Hedgehog^.Effects[heResurrectable] then - ResurrectHedgehog(Gear) - else - begin - Gear^.doStep := @doStepDrowningGear; - Gear^.State := Gear^.State and (not gstHHDriven); - AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); - end - end - else Gear^.doStep := @doStepDrowningGear; - if Gear^.Kind = gtFlake then exit // skip splashes - end; - if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) or - (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01))) then - // don't play splash if they are already way past the surface - PlaySound(sndSplash) - end; - - if ((cReducedQuality and rqPlainSplash) = 0) and - (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) or - (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01)))) then - begin - AddVisualGear(X, cWaterLine, vgtSplash); - - maxDrops := (Gear^.Radius div 2) + round(vdX * Gear^.Radius * 2) + round(vdY * Gear^.Radius * 2); - for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do - begin - particle := AddVisualGear(X - 3 + Random(6), cWaterLine, vgtDroplet); - if particle <> nil then - begin - particle^.dX := particle^.dX - vdX / 10; - particle^.dY := particle^.dY - vdY / 5; - end - end - end; - if isSubmersible and (CurAmmoGear^.Pos = 0) then CurAmmoGear^.Pos := 1000 - end - else - CheckGearDrowning := false; -end; - -procedure CheckCollision(Gear: PGear); inline; -begin - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then - Gear^.State := Gear^.State or gstCollision - else Gear^.State := Gear^.State and not gstCollision -end; - -procedure CheckCollisionWithLand(Gear: PGear); inline; -begin - if TestCollisionX(Gear, hwSign(Gear^.dX)) or TestCollisionY(Gear, hwSign(Gear^.dY) - ) - then Gear^.State := Gear^.State or gstCollision - else Gear^.State := Gear^.State and not gstCollision -end; - -procedure CheckHHDamage(Gear: PGear); -var - dmg: Longword; - i: LongInt; - particle: PVisualGear; -begin - if _0_4 < Gear^.dY then - begin - dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); - PlaySound(sndBump); - if dmg < 1 then exit; - - for i:= min(12, (3 + dmg div 10)) downto 0 do - begin - particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); - if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); - end; - - if (Gear^.Invulnerable) then exit; - - //if _0_6 < Gear^.dY then - // PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) - //else - // PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); - - if Gear^.LastDamage <> nil then - ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) - else - ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); - end -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure CalcRotationDirAngle(Gear: PGear); -var - dAngle: real; -begin - dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; - if not Gear^.dX.isNegative then - Gear^.DirAngle := Gear^.DirAngle + dAngle - else - Gear^.DirAngle := Gear^.DirAngle - dAngle; - - if Gear^.DirAngle < 0 then Gear^.DirAngle := Gear^.DirAngle + 360 - else if 360 < Gear^.DirAngle then Gear^.DirAngle := Gear^.DirAngle - 360 -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure doStepDrowningGear(Gear: PGear); -begin + begin AllInactive := false; Gear^.Y := Gear^.Y + cDrownSpeed; Gear^.X := Gear^.X + Gear^.dX * cDrownSpeed; // Create some bubbles (0.5% might be better but causes too few bubbles sometimes) - if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cSDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then + if ((not SuddenDeathDmg and (WaterOpacity < $FF)) + or (SuddenDeathDmg and (SDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble) else if Random(12) = 0 then AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble); - if (not SuddenDeathDmg and (cWaterOpacity > $FE)) or (SuddenDeathDmg and (cSDWaterOpacity > $FE)) or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then + if (not SuddenDeathDmg and (WaterOpacity > $FE)) + or (SuddenDeathDmg and (SDWaterOpacity > $FE)) + or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then DeleteGear(Gear); -end; + end; //////////////////////////////////////////////////////////////////////////////// procedure doStepFallingGear(Gear: PGear); @@ -304,10 +172,25 @@ collV, collH: LongInt; land: word; begin - // clip velocity at 1.9 - over 1 per pixel, but really shouldn't cause many actual problems. - if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862; - if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862; - Gear^.State := Gear^.State and not gstCollision; + // clip velocity at 2 - over 1 per pixel, but really shouldn't cause many actual problems. +{$IFNDEF WEB} + if Gear^.dX.Round > 2 then + Gear^.dX.QWordValue:= 8589934592; + if Gear^.dY.Round > 2 then + Gear^.dY.QWordValue:= 8589934592; +{$ELSE} + if Gear^.dX.Round > 2 then + begin + Gear^.dX.Round:= 2; + Gear^.dX.Frac:= 0 + end; + if Gear^.dY.QWordValue > 2 then + begin + Gear^.dY.Round:= 2; + Gear^.dY.Frac:= 0 + end; +{$ENDIF} + Gear^.State := Gear^.State and (not gstCollision); collV := 0; collH := 0; tdX := Gear^.dX; @@ -315,7 +198,9 @@ // might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips) - if (hwRound(Gear^.X) < LAND_WIDTH div -2) or (hwRound(Gear^.X) > LAND_WIDTH * 3 div 2) then Gear^.State := Gear^.State or gstCollision; + if (hwRound(Gear^.X) < min(LAND_WIDTH div -2, -2048)) + or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then + Gear^.State := Gear^.State or gstCollision; if Gear^.dY.isNegative then begin @@ -324,23 +209,28 @@ if land <> 0 then begin collV := -1; - if land and lfIce <> 0 then Gear^.dX := Gear^.dX * (_1 - (_1 - Gear^.Friction) / _10) - else Gear^.dX := Gear^.dX * Gear^.Friction; + if land and lfIce <> 0 then + Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) + else + Gear^.dX := Gear^.dX * Gear^.Friction; Gear^.dY := - Gear^.dY * Gear^.Elasticity; Gear^.State := Gear^.State or gstCollision end - else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then collV := 1; + else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then + collV := 1; end else - begin + begin // Gear^.dY.isNegative is false land:= TestCollisionYwithGear(Gear, 1); if land <> 0 then begin collV := 1; isFalling := false; - if land and lfIce <> 0 then Gear^.dX := Gear^.dX * (_1 - (_1 - Gear^.Friction) / _10) - else Gear^.dX := Gear^.dX * Gear^.Friction; + if land and lfIce <> 0 then + Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) + else + Gear^.dX := Gear^.dX * Gear^.Friction; Gear^.dY := - Gear^.dY * Gear^.Elasticity; Gear^.State := Gear^.State or gstCollision @@ -348,7 +238,7 @@ else begin isFalling := true; - if (Gear^.AdvBounce=1) and not Gear^.dY.isNegative and (TestCollisionYwithGear(Gear, -1) <> 0) then + if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, -1) <> 0) then collV := -1 end end; @@ -364,8 +254,8 @@ else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then collH := -hwSign(Gear^.dX); //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then - if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=-1) or ((tdX.QWordValue + - tdY.QWordValue) > _0_2.QWordValue)) then + if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=-1) + or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)) then begin Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; Gear^.dY := tdX*Gear^.Elasticity; @@ -375,31 +265,32 @@ Gear^.AdvBounce := 10; end; - if Gear^.AdvBounce > 1 then dec(Gear^.AdvBounce); + if Gear^.AdvBounce > 1 then + dec(Gear^.AdvBounce); if isFalling then begin Gear^.dY := Gear^.dY + cGravity; - if (GameFlags and gfMoreWind) <> 0 then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density - end; + if (GameFlags and gfMoreWind) <> 0 then + Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density + end; Gear^.X := Gear^.X + Gear^.dX; Gear^.Y := Gear^.Y + Gear^.dY; if Gear^.Kind <> gtBee then CheckGearDrowning(Gear); //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and - if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) and - (not isFalling) then - Gear^.State := Gear^.State and not gstMoving + if (not isFalling) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) then + Gear^.State := Gear^.State and (not gstMoving) else - Gear^.State := Gear^.State or gstMoving; + Gear^.State := Gear^.State or gstMoving; if (Gear^.nImpactSounds > 0) and - (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or - ((Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving))) and - (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or - ((Gear^.Radius >= 3) and ((Gear^.dX.QWordValue > _0_1.QWordValue) or - (Gear^.dY.QWordValue > _0_1.QWordValue)))) then + (Gear^.State and gstCollision <> 0) and + (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and + (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or + ((Gear^.Radius >= 3) and + ((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then PlaySound(TSound(ord(Gear^.ImpactSound) + LongInt(GetRandom(Gear^.nImpactSounds))), true); end; @@ -425,35 +316,35 @@ end; if (Gear^.Kind = gtBall) and ((Gear^.State and gstTmpFlag) <> 0) then - begin + begin CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx); - end; + end; if (Gear^.Kind = gtGasBomb) and ((GameTicks mod 200) = 0) then - begin + begin vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); if vg <> nil then vg^.Tint:= $FFC0C000; - end; + end; if Gear^.Timer = 0 then - begin + begin case Gear^.Kind of gtGrenade: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, Gear^.Hedgehog, EXPLAutoSound); gtClusterBomb: begin - x := hwRound(Gear^.X); - y := hwRound(Gear^.Y); - doMakeExplosion(x, y, 20, Gear^.Hedgehog, EXPLAutoSound); - for i:= 0 to 4 do - begin - dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5; - dY := (GetRandom - _3) * _0_08; - FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25) - end + x := hwRound(Gear^.X); + y := hwRound(Gear^.Y); + doMakeExplosion(x, y, 20, Gear^.Hedgehog, EXPLAutoSound); + for i:= 0 to 4 do + begin + dX := rndSign(GetRandomf * _0_1) + Gear^.dX / 5; + dY := (GetRandomf - _3) * _0_08; + FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25) + end end; gtWatermelon: begin @@ -462,8 +353,8 @@ doMakeExplosion(x, y, 75, Gear^.Hedgehog, EXPLAutoSound); for i:= 0 to 5 do begin - dX := rndSign(GetRandom * _0_1) + Gear^.dX / 5; - dY := (GetRandom - _1_5) * _0_3; + dX := rndSign(GetRandomf * _0_1) + Gear^.dX / 5; + dY := (GetRandomf - _1_5) * _0_3; FollowGear:= AddGear(x, y, gtMelonPiece, 0, dX, dY, 75); FollowGear^.DirAngle := i * 60 end @@ -476,8 +367,8 @@ for i:= 0 to 127 do begin - dX := AngleCos(i * 16) * _0_5 * (GetRandom + _1); - dY := AngleSin(i * 16) * _0_5 * (GetRandom + _1); + dX := AngleCos(i * 16) * _0_5 * (GetRandomf + _1); + dY := AngleSin(i * 16) * _0_5 * (GetRandomf + _1); if i mod 2 = 0 then begin AddGear(x, y, gtFlame, gstTmpFlag, dX, dY, 0); @@ -500,32 +391,32 @@ FollowGear:= AddGear(hwRound(Gear^.X) - 30 + x, hwRound(Gear^.Y) - 20 + y, gtPoisonCloud, 0, _0, _0, 0); end end; + end; + DeleteGear(Gear); + exit end; - DeleteGear(Gear); - exit -end; - -CalcRotationDirAngle(Gear); - -if Gear^.Kind = gtHellishBomb then -begin - - if Gear^.Timer = 3000 then - begin - Gear^.nImpactSounds := 0; - PlaySound(sndHellish); - end; - - if (GameTicks and $3F) = 0 then - if (Gear^.State and gstCollision) = 0 then - AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace); -end; + + CalcRotationDirAngle(Gear); + + if Gear^.Kind = gtHellishBomb then + begin + + if Gear^.Timer = 3000 then + begin + Gear^.nImpactSounds := 0; + PlaySound(sndHellish); + end; + + if (GameTicks and $3F) = 0 then + if (Gear^.State and gstCollision) = 0 then + AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace); + end; end; //////////////////////////////////////////////////////////////////////////////// procedure doStepMolotov(Gear: PGear); var - s: Longword; + s: Longword; i, gX, gY: LongInt; dX, dY: hwFloat; smoke, glass: PVisualGear; @@ -540,13 +431,18 @@ if (GameTicks mod s) = 0 then begin // adjust angle to match the texture - if Gear^.dX.isNegative then i:= 130 else i:= 50; + if Gear^.dX.isNegative then + i:= 130 + else + i:= 50; + smoke:= AddVisualGear(hwRound(Gear^.X)-round(cos((Gear^.DirAngle+i) * pi / 180)*20), hwRound(Gear^.Y)-round(sin((Gear^.DirAngle+i) * pi / 180)*20), vgtSmoke); - if smoke <> nil then smoke^.Scale:= 0.75; + if smoke <> nil then + smoke^.Scale:= 0.75; end; if (Gear^.State and gstCollision) <> 0 then - begin + begin PlaySound(sndMolotov); gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y); @@ -566,18 +462,19 @@ begin Frame:= 2; Tint:= $41B83ED0 - i * $10081000; - Angle:= random * 360; + Angle:= random(360); dx:= 0.0000001; dy:= 0; - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; FrameTicks:= 750; State:= ord(sprEgg) end; end; for i:= 0 to 24 do begin - dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandom + _1); - dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1); + dX := AngleCos(i * 2) * ((_0_15*(i div 5))) * (GetRandomf + _1); + dY := AngleSin(i * 8) * _0_5 * (GetRandomf + _1); AddGear(gX, gY, gtFlame, gstTmpFlag, dX, dY, 0); AddGear(gX, gY, gtFlame, gstTmpFlag, dX,-dY, 0); AddGear(gX, gY, gtFlame, gstTmpFlag,-dX, dY, 0); @@ -585,7 +482,7 @@ end; DeleteGear(Gear); exit - end; + end; end; //////////////////////////////////////////////////////////////////////////////// @@ -595,13 +492,14 @@ AllInactive := false; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); exit end; - if (Gear^.Kind = gtMelonPiece) or (Gear^.Kind = gtBall) then + if (Gear^.Kind = gtMelonPiece) + or (Gear^.Kind = gtBall) then CalcRotationDirAngle(Gear) else if (GameTicks and $1F) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) @@ -611,7 +509,8 @@ procedure doStepShell(Gear: PGear); begin AllInactive := false; - if (GameFlags and gfMoreWind) = 0 then Gear^.dX := Gear^.dX + cWindSpeed; + if (GameFlags and gfMoreWind) = 0 then + Gear^.dX := Gear^.dX + cWindSpeed; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then begin @@ -629,7 +528,8 @@ particle: PVisualGear; begin AllInactive := false; - if (GameFlags and gfMoreWind) = 0 then Gear^.dX := Gear^.dX + cWindSpeed; + if (GameFlags and gfMoreWind) = 0 then + Gear^.dX := Gear^.dX + cWindSpeed; doStepFallingGear(Gear); CalcRotationDirAngle(Gear); if (Gear^.State and gstCollision) <> 0 then @@ -637,11 +537,12 @@ kick:= hwRound((hwAbs(Gear^.dX)+hwAbs(Gear^.dY)) * _20); Gear^.dY.isNegative:= not Gear^.dY.isNegative; Gear^.dX.isNegative:= not Gear^.dX.isNegative; - AmmoShove(Gear, 1, kick); + AmmoShove(Gear, 0, kick); for i:= 15 + kick div 10 downto 0 do begin particle := AddVisualGear(hwRound(Gear^.X) + Random(25), hwRound(Gear^.Y) + Random(25), vgtDust); - if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) + if particle <> nil then + particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) end; DeleteGear(Gear); exit @@ -649,13 +550,14 @@ if ((GameTicks and $1F) = 0) and (Random(3) = 0) then begin particle:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust); - if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) + if particle <> nil then + particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) end end; //////////////////////////////////////////////////////////////////////////////// procedure doStepSnowflake(Gear: PGear); -var xx, yy, px, py: LongInt; +var xx, yy, px, py, rx, ry, lx, ly: LongInt; move, draw, allpx, gun: Boolean; s: PSDL_Surface; p: PLongwordArray; @@ -667,10 +569,11 @@ draw:= false; if gun then begin - Gear^.State:= Gear^.State and not gstInvisible; + Gear^.State:= Gear^.State and (not gstInvisible); doStepFallingGear(Gear); CheckCollision(Gear); - if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then draw:= true; + if ((Gear^.State and gstCollision) <> 0) or ((Gear^.State and gstMoving) = 0) then + draw:= true; xx:= hwRound(Gear^.X); yy:= hwRound(Gear^.Y); end @@ -678,32 +581,39 @@ begin with Gear^ do begin - State:= State and not gstInvisible; + State:= State and (not gstInvisible); X:= X + cWindSpeed * 3200 + dX; Y:= Y + dY + cGravity * vobFallSpeed * 8; // using same value as flakes to try and get similar results xx:= hwRound(X); yy:= hwRound(Y); if vobVelocity <> 0 then begin - DirAngle := DirAngle + (Angle / 1250000000); - if DirAngle < 0 then DirAngle := DirAngle + 360 - else if 360 < DirAngle then DirAngle := DirAngle - 360; + DirAngle := DirAngle + (Damage / 1000); + if DirAngle < 0 then + DirAngle := DirAngle + 360 + else if 360 < DirAngle then + DirAngle := DirAngle - 360; end; - +(* +We aren't using frametick right now, so just a waste of cycles. inc(Health, 8); if longword(Health) > vobFrameTicks then begin dec(Health, vobFrameTicks); inc(Timer); - if Timer = vobFramesCount then Timer:= 0 + if Timer = vobFramesCount then + Timer:= 0 end; +*) // move back to cloud layer - if yy > cWaterLine then move:= true - else if ((yy and LAND_HEIGHT_MASK) <> 0) or (xx > LAND_WIDTH + 512) or (xx < -512) then move:=true + if yy > cWaterLine then + move:= true + else if (xx > snowRight) or (xx < snowLeft) then + move:=true // Solid pixel encountered - else if ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then + else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then begin - lf:= Land[yy, xx] and (lfObject or lfBasic); + lf:= Land[yy, xx] and (lfObject or lfBasic or lfIndestructible); // If there's room below keep falling if (((yy-1) and LAND_HEIGHT_MASK) = 0) and (Land[yy-1, xx] = 0) then begin @@ -742,7 +652,8 @@ begin // we've collided with land. draw some stuff and get back into the clouds move:= true; - if (Pos > 20) and ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtRope)) then + if (Pos > 20) and ((CurAmmoGear = nil) + or (CurAmmoGear^.Kind <> gtRope)) then begin ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// if not gun then @@ -756,43 +667,46 @@ for py:= 0 to Pred(s^.h) do begin for px:= 0 to Pred(s^.w) do - if ((((yy + py) and LAND_HEIGHT_MASK) = 0) and (((xx + px) and LAND_WIDTH_MASK) = 0)) and ((Land[yy + py, xx + px] and $FF) = 0) then + begin + lx:=xx + px; ly:=yy + py; + if (ly and LAND_HEIGHT_MASK = 0) and (lx and LAND_WIDTH_MASK = 0) and (Land[ly, lx] and $FF = 0) then begin - if gun then + rx:= lx; + ry:= ly; + if cReducedQuality and rqBlurryLand <> 0 then begin - // try to avoid speckles. might need disabling - LandDirty[yy div 32, xx div 32]:= 1; - Land[yy + py, xx + px]:= (Land[yy + py, xx + px] or lfDamaged or lfObject) and not lfBasic; - end - else if Land[yy + py, xx + px] and $FF00 = 0 then Land[yy + py, xx + px]:= lf; - if (cReducedQuality and rqBlurryLand) = 0 then - begin + rx:= rx div 2;ry:= ry div 2; + end; + if Land[yy + py, xx + px] and $FF00 = 0 then if gun then - LandPixels[yy + py, xx + px]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask) - else LandPixels[yy + py, xx + px]:= addBgColor(LandPixels[yy + py, xx + px], p^[px]); - end - else - begin - if gun then - LandPixels[(yy + py) div 2, (xx + px) div 2]:= (cExplosionBorderColor and not AMask) or (p^[px] and AMask) - else LandPixels[(yy + py) div 2, (xx + px) div 2]:= addBgColor(LandPixels[(yy + py) div 2, (xx + px) div 2], p^[px]); - end; + begin + LandDirty[yy div 32, xx div 32]:= 1; + if LandPixels[ry, rx] = 0 then + Land[ly, lx]:= lfDamaged or lfObject + else Land[ly, lx]:= lfDamaged or lfBasic + end + else Land[ly, lx]:= lf; + if gun then + LandPixels[ry, rx]:= (ExplosionBorderColor and (not AMask)) or (p^[px] and AMask) + else LandPixels[ry, rx]:= addBgColor(LandPixels[ry, rx], p^[px]); end - else allpx:= false; + else allpx:= false + end; p:= @(p^[s^.pitch shr 2]) end; + // Why is this here. For one thing, there's no test on +1 being safe. + //Land[py, px+1]:= lfBasic; - Land[py, px+1]:= lfBasic; - - if allpx then UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w)) + if allpx then + UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true) else begin UpdateLandTexture( max(0, min(LAND_WIDTH, xx)), min(LAND_WIDTH - xx, Pred(s^.w)), max(0, min(LAND_WIDTH, yy)), - min(LAND_HEIGHT - yy, Pred(s^.h)) + min(LAND_HEIGHT - yy, Pred(s^.h)), false // could this be true without unnecessarily creating blanks? ); end; ////////////////////////////////// TODO - ASK UNC0RR FOR A GOOD HOME FOR THIS //////////////////////////////////// @@ -807,8 +721,8 @@ exit end; Gear^.Pos:= 0; - Gear^.X:= int2hwFloat(GetRandom(LAND_WIDTH+1024)-512); - Gear^.Y:= int2hwFloat(750+(GetRandom(50)-25)); + Gear^.X:= int2hwFloat(LongInt(GetRandom(snowRight - snowLeft)) + snowLeft); + Gear^.Y:= int2hwFloat(LongInt(LAND_HEIGHT + GetRandom(50)) - 1325); Gear^.State:= Gear^.State or gstInvisible; end end; @@ -816,9 +730,17 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepGrave(Gear: PGear); begin + if (Gear^.Message and gmDestroy) <> 0 then + begin + DeleteGear(Gear); + exit + end; + AllInactive := false; + if Gear^.dY.isNegative then - if TestCollisionY(Gear, -1) then Gear^.dY := _0; + if TestCollisionY(Gear, -1) then + Gear^.dY := _0; if not Gear^.dY.isNegative then if TestCollisionY(Gear, 1) then @@ -829,7 +751,8 @@ Gear^.Active := false; exit end - else if Gear^.dY < - _0_03 then PlaySound(Gear^.ImpactSound) + else if Gear^.dY < - _0_03 then + PlaySound(Gear^.ImpactSound) end; Gear^.Y := Gear^.Y + Gear^.dY; @@ -854,32 +777,32 @@ // if water entered or left if nuw <> uw then - begin + begin AddVisualGear(gX, cWaterLine, vgtSplash); AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); AddVisualGear(gX - 3 + Random(6), cWaterLine, vgtDroplet); - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); if nuw then - begin + begin Gear^.SoundChannel := LoopSound(sndBeeWater); Gear^.Tag := 1; end else - begin + begin Gear^.SoundChannel := LoopSound(sndBee); Gear^.Tag := 0; + end; end; - end; if Gear^.Timer = 0 then Gear^.RenderTimer:= false else - begin + begin if (GameTicks and $F) = 0 then - begin + begin if (GameTicks and $30) = 0 then AddVisualGear(gX, gY, vgtBeeTrace); Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX)); @@ -888,18 +811,18 @@ t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); Gear^.dX := Gear^.dX * t; Gear^.dY := Gear^.dY * t; - end; + end; Gear^.X := Gear^.X + Gear^.dX; Gear^.Y := Gear^.Y + Gear^.dY; - end; + end; CheckCollision(Gear); if ((Gear^.State and gstCollision) <> 0) then - begin - StopSound(Gear^.SoundChannel); + begin + StopSoundChan(Gear^.SoundChannel); doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); for i:= 0 to 31 do begin @@ -910,8 +833,10 @@ Scale:= 0.75; dx:= 0.001 * (random(200)); dy:= 0.001 * (random(200)); - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= random(250) + 250; State:= ord(sprTargetBee); end; @@ -922,15 +847,15 @@ if (Gear^.Timer > 0) then dec(Gear^.Timer) else - begin + begin if nuw then - begin - StopSound(Gear^.SoundChannel); + begin + StopSoundChan(Gear^.SoundChannel); CheckGearDrowning(Gear); - end + end else doStepFallingGear(Gear); - end; + end; end; procedure doStepBee(Gear: PGear); @@ -941,16 +866,16 @@ Gear^.dY := Gear^.dY + cGravity; CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); exit end; dec(Gear^.Timer); if Gear^.Timer = 0 then - begin - Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and not gmAttack; - Gear^.Hedgehog^.Gear^.State:= Gear^.Hedgehog^.Gear^.State and not gstAttacking; + begin + Gear^.Hedgehog^.Gear^.Message:= Gear^.Hedgehog^.Gear^.Message and (not gmAttack); + Gear^.Hedgehog^.Gear^.State:= Gear^.Hedgehog^.Gear^.State and (not gstAttacking); AttackBar:= 0; Gear^.SoundChannel := LoopSound(sndBee); @@ -958,7 +883,7 @@ // save initial speed in otherwise unused Friction variable Gear^.Friction := Distance(Gear^.dX, Gear^.dY); Gear^.doStep := @doStepBeeWork - end; + end; end; //////////////////////////////////////////////////////////////////////////////// @@ -967,10 +892,10 @@ AllInactive := false; inc(Gear^.Timer); if Gear^.Timer > 75 then - begin + begin DeleteGear(Gear); AfterAttack - end + end end; procedure doStepShotgunShot(Gear: PGear); @@ -981,48 +906,54 @@ AllInactive := false; if ((Gear^.State and gstAnimation) = 0) then - begin + begin dec(Gear^.Timer); if Gear^.Timer = 0 then - begin + begin PlaySound(sndShotgunFire); shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); if shell <> nil then - begin + begin shell^.dX := gear^.dX.QWordValue / -17179869184; shell^.dY := gear^.dY.QWordValue / -17179869184; shell^.Frame := 0 - end; + end; Gear^.State := Gear^.State or gstAnimation - end; - exit - end - else inc(Gear^.Timer); - - i := 200; + end; + exit + end else + if(Gear^.Hedgehog^.Gear = nil) or ((Gear^.Hedgehog^.Gear^.State and gstMoving) <> 0) then + begin + DeleteGear(Gear); + AfterAttack; + exit + end + else + inc(Gear^.Timer); + + i := 200; repeat Gear^.X := Gear^.X + Gear^.dX; Gear^.Y := Gear^.Y + Gear^.dY; CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin Gear^.X := Gear^.X + Gear^.dX * 8; Gear^.Y := Gear^.Y + Gear^.dY * 8; ShotgunShot(Gear); Gear^.doStep := @doStepShotIdle; exit - end; + end; CheckGearDrowning(Gear); if (Gear^.State and gstDrowning) <> 0 then - begin + begin Gear^.doStep := @doStepShotIdle; exit - end; + end; dec(i) until i = 0; - if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) - then + if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then Gear^.doStep := @doStepShotIdle end; @@ -1044,6 +975,7 @@ // Bullet trail VGear := AddVisualGear(hwRound(ox), hwRound(oy), vgtLineTrail); + if VGear <> nil then begin VGear^.X:= hwFloat2Float(ox); @@ -1053,12 +985,12 @@ // reached edge of land. assume infinite beam. Extend it way out past camera if (hwRound(Bullet^.X) and LAND_WIDTH_MASK <> 0) - or (hwRound(Bullet^.Y) and LAND_HEIGHT_MASK <> 0) then + or (hwRound(Bullet^.Y) and LAND_HEIGHT_MASK <> 0) then // only extend if not under water if hwRound(Bullet^.Y) < cWaterLine then begin - VGear^.dX := VGear^.dX + LAND_WIDTH * (VGear^.dX - VGear^.X); - VGear^.dY := VGear^.dY + LAND_WIDTH * (VGear^.dY - VGear^.Y); + VGear^.dX := VGear^.dX + max(LAND_WIDTH,4096) * (VGear^.dX - VGear^.X); + VGear^.dY := VGear^.dY + max(LAND_WIDTH,4096) * (VGear^.dY - VGear^.Y); end; VGear^.Timer := 200; @@ -1081,18 +1013,19 @@ Gear^.Y := Gear^.Y + Gear^.dY; x := hwRound(Gear^.X); y := hwRound(Gear^.Y); - if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) - and (Land[y, x] <> 0) then inc(Gear^.Damage); + + if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] <> 0) then + inc(Gear^.Damage); // let's interrupt before a collision to give portals a chance to catch the bullet if (Gear^.Damage = 1) and (Gear^.Tag = 0) and (Land[y, x] > 255) then - begin + begin Gear^.Tag := 1; Gear^.Damage := 0; Gear^.X := Gear^.X - Gear^.dX; Gear^.Y := Gear^.Y - Gear^.dY; CheckGearDrowning(Gear); break; - end + end else Gear^.Tag := 0; @@ -1102,48 +1035,48 @@ else AmmoShove(Gear, Gear^.Timer, 20); CheckGearDrowning(Gear); - dec(i) + dec(i) until (i = 0) or (Gear^.Damage > Gear^.Health) or ((Gear^.State and gstDrowning) <> 0); + if Gear^.Damage > 0 then - begin + begin DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); dec(Gear^.Health, Gear^.Damage); Gear^.Damage := 0 - end; - if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Damage < Gear^.Health) and ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cSDWaterOpacity < $FF))) then - begin + end; + if ((Gear^.State and gstDrowning) <> 0) and (Gear^.Damage < Gear^.Health) and ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then + begin for i:=(Gear^.Health - Gear^.Damage) * 4 downto 0 do - begin + begin if Random(6) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble); Gear^.X := Gear^.X + Gear^.dX; Gear^.Y := Gear^.Y + Gear^.dY; + end; end; - end; if (Gear^.Health <= 0) - or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) - or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then - begin - if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then - cLaserSighting := false; - if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and - ((GameFlags and gfArtillery) = 0) then cArtillery := false; + or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) + or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then + begin + if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then + cLaserSighting := false; + if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and ((GameFlags and gfArtillery) = 0) then + cArtillery := false; // Bullet Hit - if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) - and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then - begin - VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit); - if VGear <> nil then - begin - VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY); + if (hwRound(Gear^.X) and LAND_WIDTH_MASK = 0) and (hwRound(Gear^.Y) and LAND_HEIGHT_MASK = 0) then + begin + VGear := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBulletHit); + if VGear <> nil then + begin + VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY); + end; + end; + + spawnBulletTrail(Gear); + Gear^.doStep := @doStepShotIdle end; - end; - - spawnBulletTrail(Gear); - Gear^.doStep := @doStepShotIdle - end; end; procedure doStepDEagleShot(Gear: PGear); @@ -1166,21 +1099,22 @@ HedgehogChAngle(HHGear); if not cLaserSighting then // game does not have default laser sight. turn it on and give them a chance to aim - begin + begin cLaserSighting := true; HHGear^.Message := 0; - if (HHGear^.Angle - 32 >= 0) then dec(HHGear^.Angle,32) - end; + if (HHGear^.Angle >= 32) then + dec(HHGear^.Angle,32) + end; if (HHGear^.Message and gmAttack) <> 0 then - begin + begin shell := AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); if shell <> nil then - begin + begin shell^.dX := gear^.dX.QWordValue / -8589934592; shell^.dY := gear^.dY.QWordValue / -8589934592; shell^.Frame := 1 - end; + end; Gear^.State := Gear^.State or gstAnimation; Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _0_5; Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5; @@ -1189,56 +1123,59 @@ Gear^.X := Gear^.X + Gear^.dX * 3; Gear^.Y := Gear^.Y + Gear^.dY * 3; Gear^.doStep := @doStepBulletWork; - end + end else if (GameTicks mod 32) = 0 then if (GameTicks mod 4096) < 2048 then - begin - if (HHGear^.Angle + 1 <= cMaxAngle) then inc(HHGear^.Angle) - end + begin + if (HHGear^.Angle + 1 <= cMaxAngle) then + inc(HHGear^.Angle) + end else - if (HHGear^.Angle - 1 >= 0) then dec(HHGear^.Angle); + if (HHGear^.Angle >= 1) then + dec(HHGear^.Angle); if (TurnTimeLeft > 0) then dec(TurnTimeLeft) else - begin + begin DeleteGear(Gear); AfterAttack - end; + end; end; //////////////////////////////////////////////////////////////////////////////// procedure doStepActionTimer(Gear: PGear); begin - dec(Gear^.Timer); - case Gear^.Kind of - gtATStartGame: +dec(Gear^.Timer); +case Gear^.Kind of + gtATStartGame: begin AllInactive := false; if Gear^.Timer = 0 then - begin + begin AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState); - end + end end; gtATFinishGame: begin AllInactive := false; if Gear^.Timer = 1000 then - begin + begin ScreenFade := sfToBlack; ScreenFadeValue := 0; ScreenFadeSpeed := 1; - end; + end; if Gear^.Timer = 0 then - begin - SendIPC('N'); - SendIPC('q'); + begin + SendIPC(_S'N'); + SendIPC(_S'q'); GameState := gsExit - end + end end; end; -if Gear^.Timer = 0 then DeleteGear(Gear) +if Gear^.Timer = 0 then + DeleteGear(Gear) end; //////////////////////////////////////////////////////////////////////////////// @@ -1250,11 +1187,13 @@ AllInactive := false; HHGear := Gear^.Hedgehog^.Gear; dec(Gear^.Timer); - if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then dec(TurnTimeLeft); - if (TurnTimeLeft = 0) or (Gear^.Timer = 0)or((Gear^.Message and gmDestroy) <> 0)or((HHGear^.State and gstHHDriven) = - 0) then - begin - StopSound(Gear^.SoundChannel); + if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then + dec(TurnTimeLeft); + if (TurnTimeLeft = 0) or (Gear^.Timer = 0) + or((Gear^.Message and gmDestroy) <> 0) + or((HHGear^.State and gstHHDriven) =0) then + begin + StopSoundChan(Gear^.SoundChannel); DeleteGear(Gear); AfterAttack; doStepHedgehogMoving(HHGear); // for gfInfAttack @@ -1267,7 +1206,7 @@ begin HHGear^.State := HHGear^.State or gstNoDamage; doMakeExplosion(x, y + 7, 6, Gear^.Hedgehog, EXPLDontDraw); - HHGear^.State := HHGear^.State and not gstNoDamage + HHGear^.State := HHGear^.State and (not gstNoDamage) end; if (Gear^.Timer mod 47) = 0 then @@ -1300,29 +1239,34 @@ end else begin - if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), lfIndestructible) then + if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y + Gear^.dY + cGravity), $FF00) then begin Gear^.dY := Gear^.dY + cGravity; Gear^.Y := Gear^.Y + Gear^.dY end; - if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer := 1 + if hwRound(Gear^.Y) > cWaterLine then + Gear^.Timer := 1 end; Gear^.X := Gear^.X + HHGear^.dX; - if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)-cHHRadius, lfIndestructible) then + if CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y)-cHHRadius, $FF00) then begin HHGear^.X := Gear^.X; HHGear^.Y := Gear^.Y - int2hwFloat(cHHRadius) end; if (Gear^.Message and gmAttack) <> 0 then - if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer := 1 - else + if (Gear^.State and gsttmpFlag) <> 0 then + Gear^.Timer := 1 + else //there would be a mistake. else - if (Gear^.State and gsttmpFlag) = 0 then Gear^.State := Gear^.State or gsttmpFlag; - if ((Gear^.Message and gmLeft) <> 0) then Gear^.dX := - _0_3 + if (Gear^.State and gsttmpFlag) = 0 then + Gear^.State := Gear^.State or gsttmpFlag; + if ((Gear^.Message and gmLeft) <> 0) then + Gear^.dX := - _0_3 else - if ((Gear^.Message and gmRight) <> 0) then Gear^.dX := _0_3 + if ((Gear^.Message and gmRight) <> 0) then + Gear^.dX := _0_3 else Gear^.dX := _0; end; @@ -1337,12 +1281,12 @@ y := hwRound(Gear^.Y) - cHHRadius * 2; while y < hwRound(Gear^.Y) do - begin + begin ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); ar[i].Right := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); inc(y, 2); inc(i) - end; + end; DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); Gear^.dY := HHGear^.dY; @@ -1365,7 +1309,8 @@ begin AllInactive := false; dec(Gear^.Timer); - if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then dec(TurnTimeLeft); + if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then + dec(TurnTimeLeft); HHGear := Gear^.Hedgehog^.Gear; @@ -1384,7 +1329,8 @@ if ((HHGear^.State and gstMoving) <> 0) then begin doStepHedgehogMoving(HHGear); - if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer := 0 + if (HHGear^.State and gstHHDriven) = 0 then + Gear^.Timer := 0 end; if Gear^.Timer mod cHHStepTicks = 0 then @@ -1397,7 +1343,7 @@ if ((HHGear^.State and gstMoving) = 0) then begin - HHGear^.State := HHGear^.State and not gstAttacking; + HHGear^.State := HHGear^.State and (not gstAttacking); prevX := hwRound(HHGear^.X); // why the call to HedgehogStep then a further increment of X? @@ -1415,16 +1361,14 @@ if BTSteps = 7 then begin BTSteps := 0; - if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6, - Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)), - lfIndestructible) then + if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6,Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)),lfIndestructible) then begin Gear^.X := HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); Gear^.Y := HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); end; HHGear^.State := HHGear^.State or gstNoDamage; AmmoShove(Gear, 2, 15); - HHGear^.State := HHGear^.State and not gstNoDamage + HHGear^.State := HHGear^.State and (not gstNoDamage) end; end; @@ -1437,7 +1381,8 @@ cHHStepTicks, cHHRadius * 2 + 7); end; - if (TurnTimeLeft = 0) or (Gear^.Timer = 0) or ((HHGear^.Message and gmAttack) <> 0) then + if (TurnTimeLeft = 0) or (Gear^.Timer = 0) + or ((HHGear^.Message and gmAttack) <> 0) then begin HHGear^.Message := 0; HHGear^.State := HHGear^.State and (not gstNotKickable); @@ -1459,464 +1404,40 @@ end; //////////////////////////////////////////////////////////////////////////////// - -procedure doStepRope(Gear: PGear); -forward; - -procedure doStepRopeAfterAttack(Gear: PGear); -var - HHGear: PGear; -begin - HHGear := Gear^.Hedgehog^.Gear; - if ((HHGear^.State and gstHHDriven) = 0) - or (CheckGearDrowning(HHGear)) - or (TestCollisionYwithGear(HHGear, 1) <> 0) then - begin - DeleteGear(Gear); - isCursorVisible := false; - ApplyAmmoChanges(HHGear^.Hedgehog^); - exit - end; - - HedgehogChAngle(HHGear); - - if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); - - if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then HHGear^.dY := _0; - HHGear^.X := HHGear^.X + HHGear^.dX; - HHGear^.Y := HHGear^.Y + HHGear^.dY; - HHGear^.dY := HHGear^.dY + cGravity; - if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density; - - if (Gear^.Message and gmAttack) <> 0 then - begin - Gear^.X := HHGear^.X; - Gear^.Y := HHGear^.Y; - - ApplyAngleBounds(Gear^.Hedgehog^, amRope); - - Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); - Gear^.dY := -AngleCos(HHGear^.Angle); - Gear^.Friction := _450 * _0_01 * cRopePercent; - Gear^.Elasticity := _0; - Gear^.State := Gear^.State and not gsttmpflag; - Gear^.doStep := @doStepRope; - end -end; - -procedure doStepRopeWork(Gear: PGear); -var - HHGear: PGear; - len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; - lx, ly, cd: LongInt; - haveCollision, - haveDivided: boolean; - -procedure DeleteMe; -begin - with HHGear^ do - begin - Message := Message and not gmAttack; - State := (State or gstMoving) and not gstWinner; - end; - DeleteGear(Gear) -end; - -procedure WaitCollision; -begin - with HHGear^ do - begin - Message := Message and not gmAttack; - State := State or gstMoving; - end; - RopePoints.Count := 0; - Gear^.Elasticity := _0; - Gear^.doStep := @doStepRopeAfterAttack -end; - -begin - HHGear := Gear^.Hedgehog^.Gear; - - if ((HHGear^.State and gstHHDriven) = 0) - or (CheckGearDrowning(HHGear)) then - begin - PlaySound(sndRopeRelease); - DeleteMe; - exit - end; - - if (Gear^.Message and gmLeft <> 0) and not TestCollisionXwithGear(HHGear, -1) then - HHGear^.dX := HHGear^.dX - _0_0002; - - if (Gear^.Message and gmRight <> 0) and not TestCollisionXwithGear(HHGear, 1) then - HHGear^.dX := HHGear^.dX + _0_0002; - - // vector between hedgehog and rope attaching point - ropeDx := HHGear^.X - Gear^.X; - ropeDy := HHGear^.Y - Gear^.Y; - - if TestCollisionYwithGear(HHGear, 1) = 0 then - begin - - // depending on the rope vector we know which X-side to check for collision - // in order to find out if the hog can still be moved by gravity - if ropeDx.isNegative = RopeDy.IsNegative then - cd:= -1 - else - cd:= 1; - - // apply gravity if there is no obstacle - if not TestCollisionXwithGear(HHGear, cd) then - HHGear^.dY := HHGear^.dY + cGravity; - - if (GameFlags and gfMoreWind) <> 0 then - // apply wind if there's no obstacle - if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then - HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density; - end; - - mdX := ropeDx + HHGear^.dX; - mdY := ropeDy + HHGear^.dY; - len := _1 / Distance(mdX, mdY); - // rope vector plus hedgehog direction vector normalized - mdX := mdX * len; - mdY := mdY * len; - - // for visual purposes only - Gear^.dX := mdX; - Gear^.dY := mdY; - - ///// - tx := HHGear^.X; - ty := HHGear^.Y; - - if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then - if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) - or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then - Gear^.Elasticity := Gear^.Elasticity + _0_3; - - if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then - if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) - or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then - Gear^.Elasticity := Gear^.Elasticity - _0_3; - - HHGear^.X := Gear^.X + mdX * Gear^.Elasticity; - HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity; - - HHGear^.dX := HHGear^.X - tx; - HHGear^.dY := HHGear^.Y - ty; - //// - - - haveDivided := false; - // check whether rope needs dividing - - len := Gear^.Elasticity - _5; - nx := Gear^.X + mdX * len; - ny := Gear^.Y + mdY * len; - tx := mdX * _0_3; // should be the same as increase step - ty := mdY * _0_3; - - while len > _3 do - begin - lx := hwRound(nx); - ly := hwRound(ny); - if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then - begin - ny := _1 / Distance(ropeDx, ropeDy); - // old rope pos - nx := ropeDx * ny; - ny := ropeDy * ny; - - with RopePoints.ar[RopePoints.Count] do - begin - X := Gear^.X; - Y := Gear^.Y; - if RopePoints.Count = 0 then RopePoints.HookAngle := DxDy2Angle(Gear^.dY, Gear^.dX); - b := (nx * HHGear^.dY) > (ny * HHGear^.dX); - dLen := len - end; - with RopePoints.rounded[RopePoints.Count] do - begin - X := hwRound(Gear^.X); - Y := hwRound(Gear^.Y); - end; - - Gear^.X := Gear^.X + nx * len; - Gear^.Y := Gear^.Y + ny * len; - inc(RopePoints.Count); - TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); - Gear^.Elasticity := Gear^.Elasticity - len; - Gear^.Friction := Gear^.Friction - len; - haveDivided := true; - break - end; - nx := nx - tx; - ny := ny - ty; - - // len := len - _0_3 // should be the same as increase step - len.QWordValue := len.QWordValue - _0_3.QWordValue; - end; - - if not haveDivided then - if RopePoints.Count > 0 then // check whether the last dividing point could be removed - begin - tx := RopePoints.ar[Pred(RopePoints.Count)].X; - ty := RopePoints.ar[Pred(RopePoints.Count)].Y; - mdX := tx - Gear^.X; - mdY := ty - Gear^.Y; - if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then - begin - dec(RopePoints.Count); - Gear^.X := RopePoints.ar[RopePoints.Count].X; - Gear^.Y := RopePoints.ar[RopePoints.Count].Y; - Gear^.Elasticity := Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; - Gear^.Friction := Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen; - - // restore hog position - len := _1 / Distance(mdX, mdY); - mdX := mdX * len; - mdY := mdY * len; - - HHGear^.X := Gear^.X - mdX * Gear^.Elasticity; - HHGear^.Y := Gear^.Y - mdY * Gear^.Elasticity; - end - end; - - haveCollision := false; - if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then - begin - HHGear^.dX := -_0_6 * HHGear^.dX; - haveCollision := true - end; - if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then - begin - HHGear^.dY := -_0_6 * HHGear^.dY; - haveCollision := true - end; - - if haveCollision - and (Gear^.Message and (gmLeft or gmRight) <> 0) - and (Gear^.Message and (gmUp or gmDown) <> 0) then - begin - HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); - HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) - end; - - len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY); - if len > _0_64 then - begin - len := _0_8 / hwSqrt(len); - HHGear^.dX := HHGear^.dX * len; - HHGear^.dY := HHGear^.dY * len; - end; - - haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)]) <> 0); - - if not haveCollision then - begin - // backup gear location - tx:= Gear^.X; - ty:= Gear^.Y; - - if RopePoints.Count > 0 then - begin - // set gear location to the remote end of the rope, the attachment point - Gear^.X:= RopePoints.ar[0].X; - Gear^.Y:= RopePoints.ar[0].Y; - end; - - CheckCollision(Gear); - // if we haven't found any collision yet then check the other side too - if (Gear^.State and gstCollision) = 0 then - begin - Gear^.dX.isNegative:= not Gear^.dX.isNegative; - Gear^.dY.isNegative:= not Gear^.dY.isNegative; - CheckCollision(Gear); - Gear^.dX.isNegative:= not Gear^.dX.isNegative; - Gear^.dY.isNegative:= not Gear^.dY.isNegative; - end; - - haveCollision:= (Gear^.State and gstCollision) <> 0; - - // restore gear location - Gear^.X:= tx; - Gear^.Y:= ty; - end; - - // if the attack key is pressed, lose rope contact as well - if (Gear^.Message and gmAttack) <> 0 then - haveCollision:= false; - - if not haveCollision then - begin - if (Gear^.State and gsttmpFlag) <> 0 then - with Gear^.Hedgehog^ do - begin - PlaySound(sndRopeRelease); - if CurAmmoType <> amParachute then - WaitCollision - else - DeleteMe - end - end - else - if (Gear^.State and gsttmpFlag) = 0 then - Gear^.State := Gear^.State or gsttmpFlag; -end; - -procedure doStepRopeAttach(Gear: PGear); -var - HHGear: PGear; - tx, ty, tt: hwFloat; - -procedure RemoveFromAmmo; -begin - if (Gear^.State and gstAttacked) = 0 then - begin - OnUsedAmmo(HHGear^.Hedgehog^); - Gear^.State := Gear^.State or gstAttacked - end; - ApplyAmmoChanges(HHGear^.Hedgehog^) -end; - -begin - Gear^.X := Gear^.X - Gear^.dX; - Gear^.Y := Gear^.Y - Gear^.dY; - Gear^.Elasticity := Gear^.Elasticity + _1; - - HHGear := Gear^.Hedgehog^.Gear; - DeleteCI(HHGear); - - if (HHGear^.State and gstMoving) <> 0 then - begin - if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); - if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then HHGear^.dY := _0; - - HHGear^.X := HHGear^.X + HHGear^.dX; - Gear^.X := Gear^.X + HHGear^.dX; - - if TestCollisionYwithGear(HHGear, 1) <> 0 then - begin - CheckHHDamage(HHGear); - HHGear^.dY := _0 - //HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); - end - else - begin - HHGear^.Y := HHGear^.Y + HHGear^.dY; - Gear^.Y := Gear^.Y + HHGear^.dY; - HHGear^.dY := HHGear^.dY + cGravity; - if (GameFlags and gfMoreWind) <> 0 then HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density - end; - - tt := Gear^.Elasticity; - tx := _0; - ty := _0; - while tt > _20 do - begin - if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)] and $FF00) <> 0) then - begin - Gear^.X := Gear^.X + tx; - Gear^.Y := Gear^.Y + ty; - Gear^.Elasticity := tt; - Gear^.doStep := @doStepRopeWork; - PlaySound(sndRopeAttach); - with HHGear^ do - begin - State := State and not (gstAttacking or gstHHJumping or gstHHHJump); - Message := Message and not gmAttack - end; - - RemoveFromAmmo; - - tt := _0; - exit - end; - tx := tx + Gear^.dX + Gear^.dX; - ty := ty + Gear^.dY + Gear^.dY; - tt := tt - _2; - end; - end; - - CheckCollision(Gear); - - if (Gear^.State and gstCollision) <> 0 then - if Gear^.Elasticity < _10 then - Gear^.Elasticity := _10000 - else - begin - Gear^.doStep := @doStepRopeWork; - PlaySound(sndRopeAttach); - with HHGear^ do - begin - State := State and not (gstAttacking or gstHHJumping or gstHHHJump); - Message := Message and not gmAttack - end; - - RemoveFromAmmo; - - exit - end; - - if (Gear^.Elasticity > Gear^.Friction) - or ((Gear^.Message and gmAttack) = 0) - or ((HHGear^.State and gstHHDriven) = 0) - or (HHGear^.Damage > 0) then - begin - with Gear^.Hedgehog^.Gear^ do - begin - State := State and not gstAttacking; - Message := Message and not gmAttack - end; - DeleteGear(Gear) - end; - CheckGearDrowning(HHGear) -end; - -procedure doStepRope(Gear: PGear); -begin - Gear^.dX := - Gear^.dX; - Gear^.dY := - Gear^.dY; - Gear^.doStep := @doStepRopeAttach; - PlaySound(sndRopeShot) -end; - -//////////////////////////////////////////////////////////////////////////////// procedure doStepMine(Gear: PGear); var vg: PVisualGear; begin if (Gear^.State and gstMoving) <> 0 then - begin + begin DeleteCI(Gear); doStepFallingGear(Gear); if (Gear^.State and gstMoving) = 0 then - begin + begin AddGearCI(Gear); Gear^.dX := _0; Gear^.dY := _0 - end; + end; CalcRotationDirAngle(Gear); AllInactive := false - end - else - if ((GameTicks and $3F) = 25) then - doStepFallingGear(Gear); + end + else if (GameTicks and $3F) = 25 then + doStepFallingGear(Gear); if (Gear^.Health = 0) then begin - if not Gear^.dY.isNegative and (Gear^.dY > _0_2) and (TestCollisionYwithGear(Gear, 1) <> 0) then - inc(Gear^.Damage, hwRound(Gear^.dY * _70)) - else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) then - inc(Gear^.Damage, hwRound(Gear^.dX * _70)) - else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and (TestCollisionYwithGear(Gear, -1) <> 0) then - inc(Gear^.Damage, hwRound(Gear^.dY * -_70)) - else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then - inc(Gear^.Damage, hwRound(Gear^.dX * -_70)); + if not Gear^.dY.isNegative and (Gear^.dY > _0_2) and (TestCollisionYwithGear(Gear, 1) <> 0) then + inc(Gear^.Damage, hwRound(Gear^.dY * _70)) + else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) then + inc(Gear^.Damage, hwRound(Gear^.dX * _70)) + else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and (TestCollisionYwithGear(Gear, -1) <> 0) then + inc(Gear^.Damage, hwRound(Gear^.dY * -_70)) + else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then + inc(Gear^.Damage, hwRound(Gear^.dX * -_70)); - if (Gear^.Damage > random(30)) and ((GameTicks and $FF) = 0) then + if ((GameTicks and $FF) = 0) and (Gear^.Damage > random(30)) then begin vg:= AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); - if vg <> nil then vg^.Scale:= 0.5 + if vg <> nil then + vg^.Scale:= 0.5 end; if (Gear^.Damage > 35) then @@ -1931,18 +1452,19 @@ if ((Gear^.State and gstAttacking) = 0) then begin if ((GameTicks and $1F) = 0) then - if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State := Gear^.State or - gstAttacking + if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then + Gear^.State := Gear^.State or gstAttacking end else // gstAttacking <> 0 begin AllInactive := false; - if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick); + if (Gear^.Timer and $FF) = 0 then + PlaySound(sndMineTick); if Gear^.Timer = 0 then begin - if ((Gear^.State and gstWait) <> 0) or - (cMineDudPercent = 0) or - (getRandom(100) > cMineDudPercent) then + if ((Gear^.State and gstWait) <> 0) + or (cMineDudPercent = 0) + or (getRandom(100) > cMineDudPercent) then begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear) @@ -1950,65 +1472,77 @@ else begin vg:= AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); - if vg <> nil then vg^.Scale:= 0.5; + if vg <> nil then + vg^.Scale:= 0.5; PlaySound(sndVaporize); Gear^.Health := 0; Gear^.Damage := 0; - Gear^.State := Gear^.State and not gstAttacking + Gear^.State := Gear^.State and (not gstAttacking) end; exit end; dec(Gear^.Timer); end else // gsttmpFlag = 0 - if (TurnTimeLeft = 0) or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) or (Gear^.Hedgehog^.Gear = nil) then Gear^.State := Gear^.State or gsttmpFlag; + if (TurnTimeLeft = 0) + or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) + or (Gear^.Hedgehog^.Gear = nil) then + Gear^.State := Gear^.State or gsttmpFlag; end; //////////////////////////////////////////////////////////////////////////////// procedure doStepSMine(Gear: PGear); begin // TODO: do real calculation? - if TestCollisionXwithGear(Gear, 2) or (TestCollisionYwithGear(Gear, -2) <> 0) or TestCollisionXwithGear(Gear, -2) or (TestCollisionYwithGear(Gear, 2) <> 0) then - begin - if (hwAbs(Gear^.dX) > _0) or (hwAbs(Gear^.dY) > _0) then - begin + if TestCollisionXwithGear(Gear, 2) + or (TestCollisionYwithGear(Gear, -2) <> 0) + or TestCollisionXwithGear(Gear, -2) + or (TestCollisionYwithGear(Gear, 2) <> 0) then + begin + if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then + begin PlaySound(sndRopeAttach); Gear^.dX:= _0; Gear^.dY:= _0; AddGearCI(Gear); - end; - end + end; + end else - begin + begin DeleteCI(Gear); doStepFallingGear(Gear); AllInactive := false; CalcRotationDirAngle(Gear); - end; + end; if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then - begin + begin if ((Gear^.State and gstAttacking) = 0) then - begin + begin if ((GameTicks and $1F) = 0) then - if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State := Gear^.State or - gstAttacking - end + if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then + Gear^.State := Gear^.State or gstAttacking + end else // gstAttacking <> 0 begin AllInactive := false; - if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick); if Gear^.Timer = 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); exit - end; + end else + if (Gear^.Timer and $FF) = 0 then + PlaySound(sndMineTick); + dec(Gear^.Timer); + end end - end else // gsttmpFlag = 0 - if (TurnTimeLeft = 0) or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) or (Gear^.Hedgehog^.Gear = nil) then Gear^.State := Gear^.State or gsttmpFlag; + if (TurnTimeLeft = 0) + or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) + or (Gear^.Hedgehog^.Gear = nil) then + Gear^.State := Gear^.State or gsttmpFlag; end; //////////////////////////////////////////////////////////////////////////////// @@ -2016,15 +1550,16 @@ begin doStepFallingGear(Gear); AllInactive := false; - if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); + if Gear^.Timer mod 166 = 0 then + inc(Gear^.Tag); if Gear^.Timer = 1000 then // might need better timing makeHogsWorry(Gear^.X, Gear^.Y, 75); if Gear^.Timer = 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); exit - end; + end; dec(Gear^.Timer); end; @@ -2040,42 +1575,44 @@ i: LongInt; particle: PVisualGear; begin - if (Gear^.dY.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then SetLittle(Gear^.dY); + if (Gear^.dY.QWordValue = 0) and (Gear^.dY.QWordValue = 0) and (TestCollisionYwithGear(Gear, 1) = 0) then + SetLittle(Gear^.dY); Gear^.State := Gear^.State or gstAnimation; - if ((Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0)) then - begin + + if ((Gear^.dX.QWordValue <> 0) + or (Gear^.dY.QWordValue <> 0)) then + begin DeleteCI(Gear); AllInactive := false; if not Gear^.dY.isNegative and (Gear^.dY > _0_2) and (TestCollisionYwithGear(Gear, 1) <> 0) then - begin + begin Gear^.State := Gear^.State or gsttmpFlag; inc(Gear^.Damage, hwRound(Gear^.dY * _70)); for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do - begin - particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, - vgtDust); - if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) + begin + particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12,vgtDust); + if particle <> nil then + particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480) + end end - end - else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) - then - inc(Gear^.Damage, hwRound(Gear^.dX * _70)) - else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and (TestCollisionYwithGear(Gear, -1) <> 0) - then - inc(Gear^.Damage, hwRound(Gear^.dY * -_70)) - else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) - then - inc(Gear^.Damage, hwRound(Gear^.dX * -_70)); + else if not Gear^.dX.isNegative and (Gear^.dX > _0_2) and TestCollisionXwithGear(Gear, 1) then + inc(Gear^.Damage, hwRound(Gear^.dX * _70)) + + else if Gear^.dY.isNegative and (Gear^.dY < -_0_2) and (TestCollisionYwithGear(Gear, -1) <> 0) then + inc(Gear^.Damage, hwRound(Gear^.dY * -_70)) + + else if Gear^.dX.isNegative and (Gear^.dX < -_0_2) and TestCollisionXwithGear(Gear, -1) then + inc(Gear^.Damage, hwRound(Gear^.dX * -_70)); doStepFallingGear(Gear); CalcRotationDirAngle(Gear); //CheckGearDrowning(Gear) - end + end else - begin + begin Gear^.State := Gear^.State or gsttmpFlag; AddGearCI(Gear) - end; + end; (* Attempt to make a barrel knock itself over an edge. Would need more checks to avoid issues like burn damage @@ -2093,9 +1630,10 @@ if Gear^.dX.QWordValue = 0 then AddGearCI(Gear) end; *) - if not Gear^.dY.isNegative and (Gear^.dY < _0_001) and (TestCollisionYwithGear(Gear, 1) <> 0) then Gear - ^.dY := _0; - if hwAbs(Gear^.dX) < _0_001 then Gear^.dX := _0; + if not Gear^.dY.isNegative and (Gear^.dY < _0_001) and (TestCollisionYwithGear(Gear, 1) <> 0) then + Gear^.dY := _0; + if hwAbs(Gear^.dX) < _0_001 then + Gear^.dX := _0; if (Gear^.Health > 0) and ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then if (cBarrelHealth div Gear^.Health) > 2 then @@ -2104,7 +1642,8 @@ AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); dec(Gear^.Health, Gear^.Damage); Gear^.Damage := 0; - if Gear^.Health <= 0 then Gear^.doStep := @doStepCase; + if Gear^.Health <= 0 then + Gear^.doStep := @doStepCase; // Hand off to doStepCase for the explosion end; @@ -2116,26 +1655,29 @@ exBoom: boolean; dX, dY: HWFloat; hog: PHedgehog; + sparkles: PVisualGear; + gi: PGear; begin k := Gear^.Kind; exBoom := false; if (Gear^.Message and gmDestroy) > 0 then - begin + begin DeleteGear(Gear); FreeActionsList; SetAllToActive; // something (hh, mine, etc...) could be on top of the case with CurrentHedgehog^ do - if Gear <> nil then Gear^.Message := Gear^.Message and not (gmLJump or gmHJump); + if Gear <> nil then + Gear^.Message := Gear^.Message and (not (gmLJump or gmHJump)); exit - end; + end; if k = gtExplosives then - begin + begin //if V > _0_03 then Gear^.State:= Gear^.State or gstAnimation; - if (hwAbs(Gear^.dX) > _0_15) or ((hwAbs(Gear^.dY) > _0_15) and (hwAbs(Gear^.dX) > _0_02)) - then Gear^.doStep := @doStepRollingBarrel; + if (hwAbs(Gear^.dX) > _0_15) or ((hwAbs(Gear^.dY) > _0_15) and (hwAbs(Gear^.dX) > _0_02)) then + Gear^.doStep := @doStepRollingBarrel; if (Gear^.Health > 0) and ((Gear^.Health * 100 div cBarrelHealth) < random(90)) and ((GameTicks and $FF) = 0) then if (cBarrelHealth div Gear^.Health) > 2 then @@ -2146,10 +1688,59 @@ Gear^.Damage := 0; if Gear^.Health <= 0 then exBoom := true; - end; + end + else + begin + if (Gear^.Pos <> posCaseHealth) and (GameTicks and $3FF = 0) then // stir it up every second or so + begin + gi := GearsList; + while gi <> nil do + begin + if gi^.Kind = gtGenericFaller then + begin + gi^.Active:= true; + gi^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); + gi^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); + gi^.dX:= _90-(GetRandomf*_360); + gi^.dY:= _90-(GetRandomf*_360) + end; + gi := gi^.NextGear + end + end; + + if Gear^.Timer = 500 then + begin +(* Can't make sparkles team coloured without working out what the next team is going to be. This should be solved, really, since it also screws up + voices. Reinforcements voices is heard for active team, not team-to-be. Either that or change crate spawn from end of turn to start, although that + has its own complexities. *) + // Abuse a couple of gear values to track origin + Gear^.Angle:= hwRound(Gear^.Y); + Gear^.Tag:= random(2); + inc(Gear^.Timer) + end; + if Gear^.Timer < 1833 then inc(Gear^.Timer); + if Gear^.Timer = 1000 then + begin + sparkles:= AddVisualGear(hwRound(Gear^.X), Gear^.Angle, vgtDust, 1); + if sparkles <> nil then + begin + sparkles^.dX:= 0; + sparkles^.dY:= 0; + sparkles^.Angle:= 270; + if Gear^.Tag = 1 then + sparkles^.Tint:= $3744D7FF + else sparkles^.Tint:= $FAB22CFF + end; + end; + if Gear^.Timer < 1000 then + begin + AllInactive:= false; + exit + end + end; if (Gear^.Damage > 0) or exBoom then - begin + begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); hog:= Gear^.Hedgehog; @@ -2158,52 +1749,63 @@ // <-- delete gear! if k = gtCase then - begin + begin doMakeExplosion(x, y, 25, hog, EXPLAutoSound); for i:= 0 to 63 do AddGear(x, y, gtFlame, 0, _0, _0, 0); - end + end else if k = gtExplosives then - begin + begin doMakeExplosion(x, y, 75, hog, EXPLAutoSound); for i:= 0 to 31 do - begin - dX := AngleCos(i * 64) * _0_5 * (getrandom + _1); - dY := AngleSin(i * 64) * _0_5 * (getrandom + _1); + begin + dX := AngleCos(i * 64) * _0_5 * (getrandomf + _1); + dY := AngleSin(i * 64) * _0_5 * (getrandomf + _1); AddGear(x, y, gtFlame, 0, dX, dY, 0); AddGear(x, y, gtFlame, gstTmpFlag, -dX, -dY, 0); - end - end; - exit - end; - - if (Gear^.dY.QWordValue <> 0) or (TestCollisionYwithGear(Gear, 1) = 0) then - begin + end + end; + exit + end; + + if (Gear^.dY.QWordValue <> 0) + or (TestCollisionYwithGear(Gear, 1) = 0) then + begin AllInactive := false; + Gear^.dY := Gear^.dY + cGravity; + + if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then + Gear^.dY := _0; + Gear^.Y := Gear^.Y + Gear^.dY; - if (not Gear^.dY.isNegative) and (Gear^.dY > _0_001) then SetAllHHToActive; - if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then Gear^.dY := _0; + + if (not Gear^.dY.isNegative) and (Gear^.dY > _0_001) then + SetAllHHToActive; + if (not Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, 1) <> 0) then - begin + begin if (Gear^.dY > _0_2) and (k = gtExplosives) then inc(Gear^.Damage, hwRound(Gear^.dY * _70)); if Gear^.dY > _0_2 then for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do - AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust) - ; + AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); + Gear^.dY := - Gear^.dY * Gear^.Elasticity; - if Gear^.dY > - _0_001 then Gear^.dY := _0 + if Gear^.dY > - _0_001 then + Gear^.dY := _0 else if Gear^.dY < - _0_03 then - PlaySound(Gear^.ImpactSound); - end; + PlaySound(Gear^.ImpactSound); + end; //if Gear^.dY > - _0_001 then Gear^.dY:= _0 CheckGearDrowning(Gear); - end; - - if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) - else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) + end; + + if (Gear^.dY.QWordValue = 0) then + AddGearCI(Gear) + else if (Gear^.dY.QWordValue <> 0) then + DeleteCI(Gear) end; //////////////////////////////////////////////////////////////////////////////// @@ -2218,13 +1820,13 @@ else if Gear^.Tag = 1 then Gear^.Tag := 2 else if Gear^.Tag = 2 then - if Gear^.Timer > 0 then - dec(Gear^.Timer) + if Gear^.Timer > 0 then + dec(Gear^.Timer) else - begin + begin DeleteGear(Gear); exit; - end; + end; doStepCase(Gear) end; @@ -2235,10 +1837,10 @@ AllInactive := false; dec(Gear^.Timer); if Gear^.Timer = 0 then - begin + begin DeleteGear(Gear); AfterAttack - end + end end; //////////////////////////////////////////////////////////////////////////////// @@ -2291,7 +1893,7 @@ if not sticky then AllInactive := false; if TestCollisionYwithGear(Gear, 1) = 0 then - begin + begin AllInactive := false; if ((GameTicks mod 100) = 0) then @@ -2308,26 +1910,29 @@ if Gear^.dX.QWordValue > _0_01.QWordValue then Gear^.dX := Gear^.dX * _0_995; + Gear^.dY := Gear^.dY + cGravity; // if sticky then Gear^.dY := Gear^.dY + cGravity; - if Gear^.dY.QWordValue > _0_2.QWordValue then Gear^.dY := Gear^.dY * _0_995; + + if Gear^.dY.QWordValue > _0_2.QWordValue then + Gear^.dY := Gear^.dY * _0_995; //if sticky then Gear^.X := Gear^.X + Gear^.dX else Gear^.X := Gear^.X + Gear^.dX + cWindSpeed * 640; Gear^.Y := Gear^.Y + Gear^.dY; if (hwRound(Gear^.Y) > cWaterLine) then - begin + begin gX := hwRound(Gear^.X); for i:= 0 to 3 do AddVisualGear(gX - 16 + Random(32), cWaterLine - 16 + Random(16), vgtSteam); PlaySound(sndVaporize); DeleteGear(Gear); exit + end end - end else - begin + begin if sticky then begin Gear^.Radius := 7; @@ -2348,7 +1953,7 @@ inc(Gear^.Damage) end else - begin + begin gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y); // Standard fire @@ -2368,12 +1973,16 @@ Gear^.dY:= tdY; Gear^.Radius := 1; end - else if ((GameTicks and $3) = 3) then doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage); + else if ((GameTicks and $3) = 3) then + doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage); //DrawExplosion(gX, gY, 4); + if ((GameTicks and $7) = 0) and (Random(2) = 0) then - for i:= 1 to Random(2)+1 do + for i:= Random(2) downto 0 do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); - if Gear^.Health > 0 then dec(Gear^.Health); + + if Gear^.Health > 0 then + dec(Gear^.Health); Gear^.Timer := 450 - Gear^.Tag * 8 end else @@ -2383,40 +1992,33 @@ begin DrawExplosion(gX, gY, 4); - for i:= 0 to Random(3) do + for i:= Random(3) downto 0 do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); end; // This one is interesting. I think I understand the purpose, but I wonder if a bit more fuzzy of kicking could be done with getrandom. Gear^.Timer := 100 - Gear^.Tag * 3; - if (Gear^.Damage > 3000+Gear^.Tag*1500) then Gear^.Health := 0 + if (Gear^.Damage > 3000+Gear^.Tag*1500) then + Gear^.Health := 0 + end end - end - end; + end; if Gear^.Health = 0 then - begin + begin gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y); if not sticky then - begin + begin if ((GameTicks and $3) = 0) and (Random(1) = 0) then - begin - for i:= 1 to Random(2)+1 do - begin + for i:= Random(2) downto 0 do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); - end; - end; - end + end else - begin - for i:= 0 to Random(3) do - begin + for i:= Random(3) downto 0 do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); - end; - end; DeleteGear(Gear) - end; + end; end; //////////////////////////////////////////////////////////////////////////////// @@ -2426,35 +2028,35 @@ begin AllInactive := false; if ((Gear^.Message and gmDestroy) <> 0) then - begin + begin DeleteGear(Gear); AfterAttack; exit - end; + end; HHGear := Gear^.Hedgehog^.Gear; if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then - begin + begin Gear^.Tag := hwRound(HHGear^.Y); DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); HHGear^.State := HHGear^.State or gstNoDamage; Gear^.Y := HHGear^.Y; AmmoShove(Gear, 30, 40); - HHGear^.State := HHGear^.State and not gstNoDamage - end; + HHGear^.State := HHGear^.State and (not gstNoDamage) + end; HHGear^.dY := HHGear^.dY + cGravity; if not (HHGear^.dY.isNegative) then - begin + begin HHGear^.State := HHGear^.State or gstMoving; DeleteGear(Gear); AfterAttack; exit - end; + end; if CheckLandValue(hwRound(HHGear^.X), hwRound(HHGear^.Y + HHGear^.dY + SignAs(_6,Gear^.dY)), - lfIndestructible) then - HHGear^.Y := HHGear^.Y + HHGear^.dY + lfIndestructible) then + HHGear^.Y := HHGear^.Y + HHGear^.dY end; procedure doStepFirePunch(Gear: PGear); @@ -2475,7 +2077,7 @@ Gear^.doStep := @doStepFirePunchWork; DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); - AddVoice(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack) + PlaySoundV(TSound(ord(sndFirePunch1) + GetRandom(6)), HHGear^.Hedgehog^.Team^.voicepack) end; //////////////////////////////////////////////////////////////////////////////// @@ -2489,29 +2091,36 @@ inc(Gear^.Timer); if (TestCollisionYwithGear(HHGear, 1) <> 0) - or ((HHGear^.State and gstHHDriven) = 0) - or CheckGearDrowning(HHGear) - or ((Gear^.Message and gmAttack) <> 0) then - begin + or ((HHGear^.State and gstHHDriven) = 0) + or CheckGearDrowning(HHGear) + or ((Gear^.Message and gmAttack) <> 0) then + begin with HHGear^ do - begin + begin Message := 0; SetLittle(dX); dY := _0; State := State or gstMoving; - end; + end; DeleteGear(Gear); isCursorVisible := false; ApplyAmmoChanges(HHGear^.Hedgehog^); exit - end; + end; HHGear^.X := HHGear^.X + cWindSpeed * 200; - if (Gear^.Message and gmLeft) <> 0 then HHGear^.X := HHGear^.X - cMaxWindSpeed * 80 - else if (Gear^.Message and gmRight) <> 0 then HHGear^.X := HHGear^.X + cMaxWindSpeed * 80; - if (Gear^.Message and gmUp) <> 0 then HHGear^.Y := HHGear^.Y - cGravity * 40 - else if (Gear^.Message and gmDown) <> 0 then HHGear^.Y := HHGear^.Y + cGravity * 40; + if (Gear^.Message and gmLeft) <> 0 then + HHGear^.X := HHGear^.X - cMaxWindSpeed * 80 + + else if (Gear^.Message and gmRight) <> 0 then + HHGear^.X := HHGear^.X + cMaxWindSpeed * 80; + + if (Gear^.Message and gmUp) <> 0 then + HHGear^.Y := HHGear^.Y - cGravity * 40 + + else if (Gear^.Message and gmDown) <> 0 then + HHGear^.Y := HHGear^.Y + cGravity * 40; // don't drift into obstacles if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then @@ -2531,8 +2140,8 @@ AfterAttack; - HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked or gstMoving); - HHGear^.Message := HHGear^.Message and not gmAttack; + HHGear^.State := HHGear^.State and (not (gstAttacking or gstAttacked or gstMoving)); + HHGear^.Message := HHGear^.Message and (not gmAttack); Gear^.doStep := @doStepParachuteWork; @@ -2549,31 +2158,27 @@ if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then begin dec(Gear^.Health); - case Gear^.State of - 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * - Gear^.Tag, _0, 0); - 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * - Gear^.Tag, _0, 0); - 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * - Gear^.Tag, _0, 0); - 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * - Gear^.Tag, _0, Gear^.Timer + 1); + case Gear^.State of + 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); + 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); + 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); + 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1); //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed * // Gear^.Tag, _0, 5000); end; Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag); - StopSound(Gear^.SoundChannel, 4000); + StopSoundChan(Gear^.SoundChannel, 4000); end; if (GameTicks and $3F) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); - if (hwRound(Gear^.X) > (LAND_WIDTH+2048)) or (hwRound(Gear^.X) < -2048) then - begin + if (hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) then + begin // avoid to play forever (is this necessary?) - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); DeleteGear(Gear) - end; + end; end; procedure doStepAirAttack(Gear: PGear); @@ -2581,15 +2186,15 @@ AllInactive := false; if Gear^.X.QWordValue = 0 then - begin + begin Gear^.Tag := 1; Gear^.X := -_2048; - end + end else - begin + begin Gear^.Tag := -1; - Gear^.X := int2hwFloat(LAND_WIDTH + 2048); - end; + Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048); + end; Gear^.Y := int2hwFloat(topY-300); Gear^.dX := int2hwFloat(Gear^.Target.X - 5 * Gear^.Tag * 15); @@ -2615,12 +2220,12 @@ AllInactive := false; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); performRumble(); exit - end; + end; if (GameTicks and $3F) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) end; @@ -2640,27 +2245,25 @@ x := HHGear^.X; y := HHGear^.Y; - if (Distance(tx - x, ty - y) > _256) or - not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprAmGirder].Width div 2, - Gear^.Target.Y - SpritesData[sprAmGirder].Height div 2, - sprAmGirder, Gear^.State, true, false) then - begin + if (Distance(tx - x, ty - y) > _256) + or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprAmGirder].Width div 2, Gear^.Target.Y - SpritesData[sprAmGirder].Height div 2, sprAmGirder, Gear^.State, true, false)) then + begin PlaySound(sndDenied); - HHGear^.Message := HHGear^.Message and not gmAttack; - HHGear^.State := HHGear^.State and not gstAttacking; + HHGear^.Message := HHGear^.Message and (not gmAttack); + HHGear^.State := HHGear^.State and (not gstAttacking); HHGear^.State := HHGear^.State or gstHHChooseTarget; isCursorVisible := true; DeleteGear(Gear) - end + end else - begin + begin PlaySound(sndPlaced); DeleteGear(Gear); AfterAttack; - end; - - HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked); - HHGear^.Message := HHGear^.Message and not gmAttack; + end; + + HHGear^.State := HHGear^.State and (not (gstAttacking or gstAttacked)); + HHGear^.Message := HHGear^.Message and (not gmAttack); end; //////////////////////////////////////////////////////////////////////////////// @@ -2668,30 +2271,34 @@ var HHGear: PGear; begin - Gear^.Hedgehog^.Unplaced := false; HHGear := Gear^.Hedgehog^.Gear; - HHGear^.Y := HHGear^.Y + HHGear^.dY; - HHGear^.X := HHGear^.X + HHGear^.dX; - // hedgehog falling to collect cases - HHGear^.dY := HHGear^.dY + cGravity; - if (TestCollisionYwithGear(HHGear, 1) <> 0) - or CheckGearDrowning(HHGear) then - begin + doStepHedgehogMoving(HHGear); + // if not infattack mode wait for hedgehog finish falling to collect cases + if ((GameFlags and gfInfAttack) <> 0) + or ((HHGear^.State and gstMoving) = 0) + or (Gear^.Hedgehog^.Gear^.Damage > 0) + or ((HHGear^.State and gstDrowning) = 1) then + begin DeleteGear(Gear); AfterAttack - end + end end; procedure doStepTeleportAnim(Gear: PGear); begin + if (Gear^.Hedgehog^.Gear^.Damage > 0) then + begin + DeleteGear(Gear); + AfterAttack; + end; inc(Gear^.Timer); if Gear^.Timer = 65 then - begin + begin Gear^.Timer := 0; inc(Gear^.Pos); if Gear^.Pos = 11 then Gear^.doStep := @doStepTeleportAfter - end; + end; end; procedure doStepTeleport(Gear: PGear); @@ -2702,18 +2309,18 @@ HHGear := Gear^.Hedgehog^.Gear; if not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprHHTelepMask].Width div 2, - Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2, - sprHHTelepMask, 0, false, false) then - begin - HHGear^.Message := HHGear^.Message and not gmAttack; - HHGear^.State := HHGear^.State and not gstAttacking; + Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2, + sprHHTelepMask, 0, false, false) then + begin + HHGear^.Message := HHGear^.Message and (not gmAttack); + HHGear^.State := HHGear^.State and (not gstAttacking); HHGear^.State := HHGear^.State or gstHHChooseTarget; DeleteGear(Gear); isCursorVisible := true; PlaySound(sndDenied) - end + end else - begin + begin DeleteCI(HHGear); SetAllHHToActive; Gear^.doStep := @doStepTeleportAnim; @@ -2727,8 +2334,10 @@ HHGear^.X := int2hwFloat(Gear^.Target.X); HHGear^.Y := int2hwFloat(Gear^.Target.Y); HHGear^.State := HHGear^.State or gstMoving; + Gear^.Hedgehog^.Unplaced := false; + isCursorVisible := false; playSound(sndWarp) - end; + end; Gear^.Target.X:= NoPointX end; @@ -2736,54 +2345,53 @@ procedure doStepSwitcherWork(Gear: PGear); var HHGear: PGear; - Msg, State: Longword; + hedgehog: PHedgehog; + State: Longword; begin AllInactive := false; - if ((Gear^.Message and not gmSwitch) <> 0) or (TurnTimeLeft = 0) then - begin - HHGear := Gear^.Hedgehog^.Gear; - Msg := Gear^.Message and not gmSwitch; + if ((Gear^.Message and (not gmSwitch)) <> 0) or (TurnTimeLeft = 0) then + begin + hedgehog := Gear^.Hedgehog; + //Msg := Gear^.Message and (not gmSwitch); DeleteGear(Gear); - ApplyAmmoChanges(HHGear^.Hedgehog^); + ApplyAmmoChanges(hedgehog^); HHGear := CurrentHedgehog^.Gear; ApplyAmmoChanges(HHGear^.Hedgehog^); - HHGear^.Message := Msg; + //HHGear^.Message := Msg; exit - end; + end; if (Gear^.Message and gmSwitch) <> 0 then - begin + begin HHGear := CurrentHedgehog^.Gear; - HHGear^.Message := HHGear^.Message and not gmSwitch; - Gear^.Message := Gear^.Message and not gmSwitch; + HHGear^.Message := HHGear^.Message and (not gmSwitch); + Gear^.Message := Gear^.Message and (not gmSwitch); State := HHGear^.State; HHGear^.State := 0; + HHGear^.Z := cHHZ; HHGear^.Active := false; - HHGear^.Z := cHHZ; - RemoveGearFromList(HHGear); - InsertGearToList(HHGear); + HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList; PlaySound(sndSwitchHog); repeat - CurrentTeam^.CurrHedgehog := Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^. - HedgehogsNumber); + CurrentTeam^.CurrHedgehog := Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0); - CurrentHedgehog := @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; + SwitchCurrentHedgehog(@CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]); + AmmoMenuInvalidated:= true; HHGear := CurrentHedgehog^.Gear; HHGear^.State := State; HHGear^.Active := true; FollowGear := HHGear; HHGear^.Z := cCurrHHZ; - RemoveGearFromList(HHGear); - InsertGearToList(HHGear); + HHGear^.Message:= HHGear^.Message or gmRemoveFromList or gmAddToList; Gear^.X := HHGear^.X; Gear^.Y := HHGear^.Y - end; + end; end; procedure doStepSwitcher(Gear: PGear); @@ -2795,10 +2403,10 @@ HHGear := Gear^.Hedgehog^.Gear; OnUsedAmmo(HHGear^.Hedgehog^); with HHGear^ do - begin - State := State and not gstAttacking; - Message := Message and not gmAttack - end + begin + State := State and (not gstAttacking); + Message := Message and (not gmAttack) + end end; //////////////////////////////////////////////////////////////////////////////// @@ -2814,21 +2422,21 @@ doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLAutoSound); Gear^.dX.isNegative := not dxn; Gear^.dY.isNegative := not dyn; for i:= 0 to 4 do - begin - dX := Gear^.dX + (GetRandom - _0_5) * _0_03; - dY := Gear^.dY + (GetRandom - _0_5) * _0_03; + begin + dX := Gear^.dX + (GetRandomf - _0_5) * _0_03; + dY := Gear^.dY + (GetRandomf - _0_5) * _0_03; AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); - end; + end; DeleteGear(Gear); exit - end; + end; if (GameTicks and $3F) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) @@ -2836,8 +2444,6 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepKamikazeWork(Gear: PGear); - -const upd: Longword = 0; var i: LongWord; HHGear: PGear; @@ -2846,7 +2452,8 @@ begin AllInactive := false; hasWishes:= ((Gear^.Message and (gmPrecise or gmSwitch)) = (gmPrecise or gmSwitch)); - if hasWishes then Gear^.AdvBounce:= 1; + if hasWishes then + Gear^.AdvBounce:= 1; HHGear := Gear^.Hedgehog^.Gear; HHGear^.State := HHGear^.State or gstNoDamage; @@ -2860,7 +2467,7 @@ if sparkles <> nil then begin sparkles^.Tint:= ((random(210)+45) shl 24) or ((random(210)+45) shl 16) or ((random(210)+45) shl 8) or $FF; - sparkles^.Angle:= random * 360; + sparkles^.Angle:= random(360); end end; @@ -2878,33 +2485,34 @@ // or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); dec(i) - until (i = 0) or (Gear^.Damage > Gear^.Health); + until (i = 0) + or (Gear^.Damage > Gear^.Health); inc(upd); if upd > 3 then - begin + begin if Gear^.Health < 1500 then - begin + begin if Gear^.AdvBounce <> 0 then Gear^.Pos := 3 else Gear^.Pos := 2; - end; + end; AmmoShove(Gear, 30, 40); DrawTunnel(HHGear^.X - HHGear^.dX * 10, - HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, + HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, HHGear^.dX, HHGear^.dY, 20 + cHHRadius * 2, cHHRadius * 2 + 7); upd := 0 - end; + end; if Gear^.Health < Gear^.Damage then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); if hasWishes then for i:= 0 to 31 do @@ -2914,23 +2522,25 @@ with sparkles^ do begin Tint:= ((random(210)+45) shl 24) or ((random(210)+45) shl 16) or ((random(210)+45) shl 8) or $FF; - Angle:= random * 360; + Angle:= random(360); dx:= 0.001 * (random(200)); dy:= 0.001 * (random(200)); - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= random(400) + 250 end end; AfterAttack; + HHGear^.Message:= HHGear^.Message or gmDestroy; DeleteGear(Gear); - DeleteGear(HHGear); end else - begin + begin dec(Gear^.Health, Gear^.Damage); Gear^.Damage := 0 - end + end end; procedure doStepKamikazeIdle(Gear: PGear); @@ -2940,7 +2550,7 @@ if Gear^.Timer = 0 then begin Gear^.Pos := 1; - PlaySound(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack); + PlaySoundV(sndKamikaze, Gear^.Hedgehog^.Team^.voicepack); Gear^.doStep := @doStepKamikazeWork end end; @@ -2967,7 +2577,6 @@ //////////////////////////////////////////////////////////////////////////////// const cakeh = 27; - cakeDmg = 75; var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; @@ -2979,7 +2588,8 @@ AllInactive := false; inc(Gear^.Tag); - if Gear^.Tag < 2250 then exit; + if Gear^.Tag < 2250 then + exit; doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, Gear^.Hedgehog, EXPLAutoSound); AfterAttack; @@ -2989,112 +2599,87 @@ procedure doStepCakeDown(Gear: PGear); var gi: PGear; - dmg: LongInt; + dmg, dmgBase: LongInt; + fX, fY, tdX, tdY: hwFloat; begin AllInactive := false; inc(Gear^.Tag); - if Gear^.Tag < 100 then exit; + if Gear^.Tag < 100 then + exit; Gear^.Tag := 0; if Gear^.Pos = 0 then - begin + begin +///////////// adapted from doMakeExplosion /////////////////////////// + //fX:= Gear^.X; + //fY:= Gear^.Y; + //fX.QWordValue:= fX.QWordValue and $FFFFFFFF00000000; + //fY.QWordValue:= fY.QWordValue and $FFFFFFFF00000000; + fX:= int2hwFloat(hwRound(Gear^.X)); + fY:= int2hwFloat(hwRound(Gear^.Y)); + dmgBase:= cakeDmg shl 1 + cHHRadius div 2; gi := GearsList; while gi <> nil do - begin - dmg := cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); - if (dmg > 1) and (gi^.Kind = gtHedgehog) then - if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then - gi^.State := gi^.State or gstLoser - else - gi^.State := gi^.State or gstWinner; + begin + if gi^.Kind = gtHedgehog then + begin + dmg:= 0; + tdX:= gi^.X-fX; + tdY:= gi^.Y-fY; + if hwRound(hwAbs(tdX)+hwAbs(tdY)) < dmgBase then + dmg:= dmgBase - max(hwRound(Distance(tdX, tdY)),gi^.Radius); + if (dmg > 1) then dmg:= ModifyDamage(min(dmg div 2, cakeDmg), gi); + if (dmg > 1) then + if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then + gi^.State := gi^.State or gstLoser + else + gi^.State := gi^.State or gstWinner; + end; gi := gi^.NextGear - end; + end; +////////////////////////////////////////////////////////////////////// Gear^.doStep := @doStepCakeExpl; PlaySound(sndCake) - end + end else dec(Gear^.Pos) end; procedure doStepCakeWork(Gear: PGear); - -const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); -var - xx, yy, xxn, yyn: LongInt; - da: LongInt; +var tdx, tdy: hwFloat; - -procedure PrevAngle; -begin - Gear^.Angle := (LongInt(Gear^.Angle) + 4 - dA) mod 4 -end; - -procedure NextAngle; -begin - Gear^.Angle := (LongInt(Gear^.Angle) + 4 + dA) mod 4 -end; - begin AllInactive := false; inc(Gear^.Tag); - if Gear^.Tag < 7 then exit; - - dA := hwSign(Gear^.dX); - xx := dirs[Gear^.Angle].x; - yy := dirs[Gear^.Angle].y; - xxn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; - yyn := dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; - - if (xx = 0) then - if TestCollisionYwithGear(Gear, yy) <> 0 then - PrevAngle - else - begin - Gear^.Tag := 0; - Gear^.Y := Gear^.Y + int2hwFloat(yy); - if not TestCollisionXwithGear(Gear, xxn) then - begin - Gear^.X := Gear^.X + int2hwFloat(xxn); - NextAngle + if Gear^.Tag < 7 then + exit; + + dec(Gear^.Health); + Gear^.Timer := Gear^.Health*10; + if Gear^.Health mod 100 = 0 then + Gear^.PortalCounter:= 0; + // This is not seconds, but at least it is *some* feedback + if (Gear^.Health = 0) or ((Gear^.Message and gmAttack) <> 0) then + begin + FollowGear := Gear; + Gear^.RenderTimer := false; + Gear^.doStep := @doStepCakeDown; + exit end; - end; - - if (yy = 0) then - if TestCollisionXwithGear(Gear, xx) then - PrevAngle - else - begin - Gear^.Tag := 0; - Gear^.X := Gear^.X + int2hwFloat(xx); - if not TestCollisionY(Gear, yyn) then - begin - Gear^.Y := Gear^.Y + int2hwFloat(yyn); - NextAngle - end; - end; + + cakeStep(Gear); if Gear^.Tag = 0 then - begin + begin CakeI := (CakeI + 1) mod cakeh; tdx := CakePoints[CakeI].x - Gear^.X; tdy := - CakePoints[CakeI].y + Gear^.Y; CakePoints[CakeI].x := Gear^.X; CakePoints[CakeI].y := Gear^.Y; Gear^.DirAngle := DxDy2Angle(tdx, tdy); - end; - - dec(Gear^.Health); - Gear^.Timer := Gear^.Health*10; - if Gear^.Health mod 100 = 0 then Gear^.PortalCounter:= 0; - // This is not seconds, but at least it is *some* feedback - if (Gear^.Health = 0) or ((Gear^.Message and gmAttack) <> 0) then - begin - FollowGear := Gear; - Gear^.RenderTimer := false; - Gear^.doStep := @doStepCakeDown - end + end; end; procedure doStepCakeUp(Gear: PGear); @@ -3104,20 +2689,22 @@ AllInactive := false; inc(Gear^.Tag); - if Gear^.Tag < 100 then exit; + if Gear^.Tag < 100 then + exit; Gear^.Tag := 0; if Gear^.Pos = 6 then - begin + begin for i:= 0 to Pred(cakeh) do - begin + begin CakePoints[i].x := Gear^.X; CakePoints[i].y := Gear^.Y - end; + end; CakeI := 0; Gear^.doStep := @doStepCakeWork - end - else inc(Gear^.Pos) + end + else + inc(Gear^.Pos) end; procedure doStepCakeFall(Gear: PGear); @@ -3125,11 +2712,13 @@ AllInactive := false; Gear^.dY := Gear^.dY + cGravity; - if TestCollisionYwithGear(Gear, 1) <> 0 then Gear^.doStep := @doStepCakeUp + if TestCollisionYwithGear(Gear, 1) <> 0 then + Gear^.doStep := @doStepCakeUp else begin Gear^.Y := Gear^.Y + Gear^.dY; - if CheckGearDrowning(Gear) then AfterAttack + if CheckGearDrowning(Gear) then + AfterAttack end end; @@ -3141,8 +2730,7 @@ HHGear := Gear^.Hedgehog^.Gear; HHGear^.Message := HHGear^.Message and (not gmAttack); - DeleteCI(HHGear); - Gear^.IntersectGear:= nil; + Gear^.CollisionMask:= $FF7F; FollowGear := Gear; @@ -3152,23 +2740,22 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepSeductionWork(Gear: PGear); var i: LongInt; - hogs: TPGearArray; + hogs: PGearArrayS; begin AllInactive := false; hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius); - if Length(hogs) > 0 then - begin - for i:= 0 to High(hogs) do - begin - if hogs[i] <> CurrentHedgehog^.Gear then + if hogs.size > 0 then + begin + for i:= 0 to hogs.size - 1 do + with hogs.ar^[i]^ do begin - //d:= Distance(Gear^.X - hogs[i]^.X, Gear^.Y - hogs[i]^.Y); - hogs[i]^.dX:= _50 * cGravity * (Gear^.X - hogs[i]^.X) / _25; - //if Gear^.X < hogs[i]^.X then hogs[i]^.dX.isNegative:= true; - hogs[i]^.dY:= -_450 * cGravity; - hogs[i]^.Active:= true; - end - end; + if hogs.ar^[i] <> CurrentHedgehog^.Gear then + begin + dX:= _50 * cGravity * (Gear^.X - X) / _25; + dY:= -_450 * cGravity; + Active:= true; + end + end; end ; AfterAttack; DeleteGear(Gear); @@ -3207,7 +2794,7 @@ Gear^.Timer := 0; inc(Gear^.Pos); if Gear^.Pos = 5 then - PlaySound(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack) + PlaySoundV(sndYoohoo, Gear^.Hedgehog^.Team^.voicepack) end; if (Gear^.Pos = 14) and (RealTicks and $3 = 0) then @@ -3218,8 +2805,10 @@ begin dx:= 0.001 * (random(200)); dy:= 0.001 * (random(200)); - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= random(750) + 1000; State:= ord(sprSeduction) end; @@ -3241,10 +2830,11 @@ var i: LongWord; begin - if (Gear^.Tag = 0) or (cWaterLine = 0) then - begin - DeleteGear(Gear); - exit + if (Gear^.Tag = 0) + or (cWaterLine = 0) then + begin + DeleteGear(Gear); + exit end; AllInactive := false; @@ -3256,12 +2846,12 @@ exit; if cWaterLine > 0 then - begin + begin dec(cWaterLine); for i:= 0 to LAND_WIDTH - 1 do Land[cWaterLine, i] := 0; SetAllToActive - end; + end; dec(Gear^.Tag); end; @@ -3287,23 +2877,25 @@ if (Gear^.Timer mod 30) = 0 then AddVisualGear(hwRound(Gear^.X + _20 * Gear^.dX), hwRound(Gear^.Y + _20 * Gear^.dY), vgtDust); if (CheckGearDrowning(Gear)) then - begin - StopSound(Gear^.SoundChannel); + begin + StopSoundChan(Gear^.SoundChannel); exit end end; - t := CheckGearsCollision(Gear); + if GameTicks > Gear^.FlightTime then + t := CheckGearsCollision(Gear) + + else t := nil; //fixes drill not exploding when touching HH bug - if (Gear^.Timer = 0) or (t^.Count <> 0) or - ( ((Gear^.State and gsttmpFlag) = 0) and - (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) - and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) + + if (Gear^.Timer = 0) or ((t <> nil) and (t^.Count <> 0)) + or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX)))) // CheckLandValue returns true if the type isn't matched - or not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible) then + or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then begin //out of time or exited ground - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); if (Gear^.State and gsttmpFlag) <> 0 then doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound) else @@ -3311,9 +2903,10 @@ DeleteGear(Gear); exit end - else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) then - begin - StopSound(Gear^.SoundChannel); + + else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) then + begin + StopSoundChan(Gear^.SoundChannel); Gear^.Tag := 1; Gear^.doStep := @doStepDrill end; @@ -3341,21 +2934,25 @@ AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); if ((Gear^.State and gstCollision) <> 0) then - begin + begin //hit Gear^.dX := oldDx; Gear^.dY := oldDy; - t := CheckGearsCollision(Gear); - if (t^.Count = 0) then - begin + if GameTicks > Gear^.FlightTime then + t := CheckGearsCollision(Gear) + else + t := nil; + if (t = nil) or (t^.Count = 0) then + begin //hit the ground not the HH t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); Gear^.dX := Gear^.dX * t2; Gear^.dY := Gear^.dY * t2; - end - else - begin + end + + else if (t <> nil) then + begin //explode right on contact with HH if (Gear^.State and gsttmpFlag) <> 0 then doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound) @@ -3363,30 +2960,31 @@ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); exit; - end; + end; Gear^.SoundChannel := LoopSound(sndDrillRocket); Gear^.doStep := @doStepDrillDrilling; + if (Gear^.State and gsttmpFlag) <> 0 then gear^.RenderTimer:= true; - dec(Gear^.Timer) - end + if Gear^.Timer > 0 then dec(Gear^.Timer) + end else if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Tag <> 0) then - begin - if Gear^.Timer = 0 then + begin + if Gear^.Timer > 0 then + dec(Gear^.Timer) + else begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); - DeleteGear(Gear); + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); + DeleteGear(Gear); end - else - dec(Gear^.Timer); - end; + end; end; //////////////////////////////////////////////////////////////////////////////// procedure doStepBallgunWork(Gear: PGear); var - HHGear: PGear; + HHGear, ball: PGear; rx, ry: hwFloat; gX, gY: LongInt; begin @@ -3397,23 +2995,21 @@ gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle); gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle); if (Gear^.Timer mod 100) = 0 then - begin - rx := rndSign(getRandom * _0_1); - ry := rndSign(getRandom * _0_1); - - AddGear(gx, gy, gtBall, 0, - SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, - AngleCos(HHGear^.Angle) * ( - _0_8) + ry, - 0); + begin + rx := rndSign(getRandomf * _0_1); + ry := rndSign(getRandomf * _0_1); + + ball:= AddGear(gx, gy, gtBall, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0); + ball^.CollisionMask:= $FF7F; PlaySound(sndGun); - end; - - if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then - begin + end; + + if (Gear^.Timer = 0) or ((HHGear^.State and gstHHDriven) = 0) then + begin DeleteGear(Gear); AfterAttack - end + end end; procedure doStepBallgun(Gear: PGear); @@ -3421,7 +3017,7 @@ HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; - HHGear^.Message := HHGear^.Message and not (gmUp or gmDown); + HHGear^.Message := HHGear^.Message and (not (gmUp or gmDown)); HHGear^.State := HHGear^.State or gstNotKickable; Gear^.doStep := @doStepBallgunWork end; @@ -3443,34 +3039,36 @@ HHGear := Gear^.Hedgehog^.Gear; FollowGear := Gear; - if Gear^.Timer > 0 then dec(Gear^.Timer); + if Gear^.Timer > 0 then + dec(Gear^.Timer); fChanged := false; if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then - begin + begin fChanged := true; - if Gear^.Angle > 2048 then dec(Gear^.Angle) - else - if Gear^.Angle < 2048 then inc(Gear^.Angle) + if Gear^.Angle > 2048 then + dec(Gear^.Angle) + else if Gear^.Angle < 2048 then + inc(Gear^.Angle) else fChanged := false end else - begin + begin if ((Gear^.Message and gmLeft) <> 0) then - begin + begin fChanged := true; Gear^.Angle := (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 - end; + end; if ((Gear^.Message and gmRight) <> 0) then - begin + begin fChanged := true; Gear^.Angle := (Gear^.Angle + cAngleSpeed) mod 4096 - end - end; + end + end; if fChanged then - begin + begin Gear^.dX.isNegative := (Gear^.Angle > 2048); if Gear^.dX.isNegative then trueAngle := 4096 - Gear^.Angle @@ -3479,7 +3077,7 @@ Gear^.dX := SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; Gear^.dY := AngleCos(trueAngle) * -_0_25; - end; + end; Gear^.X := Gear^.X + Gear^.dX; Gear^.Y := Gear^.Y + Gear^.dY; @@ -3491,20 +3089,19 @@ AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); if ((HHGear^.Message and gmAttack) <> 0) and (Gear^.Health <> 0) then - begin - HHGear^.Message := HHGear^.Message and not gmAttack; + begin + HHGear^.Message := HHGear^.Message and (not gmAttack); AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); dec(Gear^.Health) - end; - - if ((HHGear^.Message and gmLJump) <> 0) - and ((Gear^.State and gsttmpFlag) = 0) then - begin + end; + + if ((HHGear^.Message and gmLJump) <> 0) and ((Gear^.State and gsttmpFlag) = 0) then + begin Gear^.State := Gear^.State or gsttmpFlag; PauseMusic; playSound(sndRideOfTheValkyries); - end; + end; // pickup bonuses t := CheckGearNear(Gear, gtCase, 36, 36); @@ -3514,35 +3111,37 @@ CheckCollision(Gear); if ((Gear^.State and gstCollision) <> 0) or CheckGearDrowning(Gear) then - begin - StopSound(Gear^.SoundChannel); + begin + StopSoundChan(Gear^.SoundChannel); StopSound(sndRideOfTheValkyries); ResumeMusic; if ((Gear^.State and gstCollision) <> 0) then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, Gear^.Hedgehog, EXPLAutoSound); for i:= 0 to 15 do - begin - dX := AngleCos(i * 64) * _0_5 * (GetRandom + _1); - dY := AngleSin(i * 64) * _0_5 * (GetRandom + _1); + begin + dX := AngleCos(i * 64) * _0_5 * (GetRandomf + _1); + dY := AngleSin(i * 64) * _0_5 * (GetRandomf + _1); AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); - end; + end; DeleteGear(Gear) - end; + end; AfterAttack; CurAmmoGear := nil; if (GameFlags and gfInfAttack) = 0 then begin - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; + TurnTimeLeft:= 14 * 125; end; HHGear^.Message := 0; - ParseCommand('/taunt '#1, true) - end + ParseCommand('/taunt ' + #1, true) + end end; procedure doStepRCPlane(Gear: PGear); @@ -3554,7 +3153,9 @@ HHGear^.State := HHGear^.State or gstNotKickable; Gear^.Angle := HHGear^.Angle; Gear^.Tag := hwSign(HHGear^.dX); - if HHGear^.dX.isNegative then Gear^.Angle := 4096 - Gear^.Angle; + + if HHGear^.dX.isNegative then + Gear^.Angle := 4096 - Gear^.Angle; Gear^.doStep := @doStepRCPlaneWork end; @@ -3568,7 +3169,8 @@ bubble: PVisualGear; begin isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; - if Gear^.Pos > 0 then dec(Gear^.Pos); + if Gear^.Pos > 0 then + dec(Gear^.Pos); AllInactive := false; HHGear := Gear^.Hedgehog^.Gear; //dec(Gear^.Timer); @@ -3592,7 +3194,8 @@ for i:= random(10)+10 downto 0 do begin bubble := AddVisualGear(hwRound(HHGear^.X) - 8 + random(16), hwRound(HHGear^.Y) + 16 + random(8), vgtBubble); - if bubble <> nil then bubble^.dY:= random(20)/10+0.1; + if bubble <> nil then + bubble^.dY:= random(20)/10+0.1; end end else HHGear^.dY := HHGear^.dY - move; @@ -3635,30 +3238,35 @@ Gear^.MsgParam := 0 end; - if Gear^.Health < 0 then Gear^.Health := 0; + if Gear^.Health < 0 then + Gear^.Health := 0; + i:= Gear^.Health div 20; + if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then begin Gear^.Damage:= i; //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate); - if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); - Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + - '%', cWhiteColor, fntSmall) + FreeTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + '%', cWhiteColor, fntSmall) end; - if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then Gear^ - .State := Gear^.State and not gsttmpFlag; - HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight); + if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then + Gear^.State := Gear^.State and (not gsttmpFlag); + + HHGear^.Message := HHGear^.Message and (not (gmUp or gmPrecise or gmLeft or gmRight)); HHGear^.State := HHGear^.State or gstMoving; Gear^.X := HHGear^.X; Gear^.Y := HHGear^.Y; - // For some reason I need to reapply followgear here, something else grabs it otherwise. - // This is probably not needed anymore - if not CurrentTeam^.ExtDriven then FollowGear := HHGear; - - if not isUnderWater and hasBorder and ((HHGear^.X < _0) or (hwRound(HHGear^.X) > LAND_WIDTH)) then HHGear^.dY.isNegative:= false; - if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear); + + if not isUnderWater and hasBorder and ((HHGear^.X < _0) + or (hwRound(HHGear^.X) > LAND_WIDTH)) then + HHGear^.dY.isNegative:= false; + + if ((Gear^.State and gsttmpFlag) = 0) + or (HHGear^.dY < _0) then + doStepHedgehogMoving(HHGear); if // (Gear^.Health = 0) (HHGear^.Damage <> 0) @@ -3668,22 +3276,22 @@ // allow brief ground touches - to be fair on this, might need another counter or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and (TestCollisionYwithGear(HHGear, 1) <> 0)) or ((Gear^.Message and gmAttack) <> 0) then - begin - with HHGear^ do begin - Message := 0; - Active := true; - State := State or gstMoving - end; - DeleteGear(Gear); - isCursorVisible := false; - ApplyAmmoChanges(HHGear^.Hedgehog^); + with HHGear^ do + begin + Message := 0; + Active := true; + State := State or gstMoving + end; + DeleteGear(Gear); + isCursorVisible := false; + ApplyAmmoChanges(HHGear^.Hedgehog^); // if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); // Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', cWhiteColor, fntSmall) //AddCaption(trmsg[sidFuel]+': '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate); - end + end end; procedure doStepJetpack(Gear: PGear); @@ -3697,15 +3305,16 @@ FollowGear := HHGear; AfterAttack; with HHGear^ do - begin - State := State and not gstAttacking; - Message := Message and not (gmAttack or gmUp or gmPrecise or gmLeft or gmRight); + begin + State := State and (not gstAttacking); + Message := Message and (not (gmAttack or gmUp or gmPrecise or gmLeft or gmRight)); + if (dY < _0_1) and (dY > -_0_1) then - begin + begin Gear^.State := Gear^.State or gsttmpFlag; dY := dY - _0_2 + end end - end end; //////////////////////////////////////////////////////////////////////////////// @@ -3716,9 +3325,9 @@ if Gear^.Timer < 2000 then inc(Gear^.Timer, 1) else - begin + begin DeleteGear(Gear); - end; + end; end; procedure doStepBirdyFly(Gear: PGear); @@ -3740,7 +3349,7 @@ if Gear^.Pos > 0 then dec(Gear^.Pos, 1) else if (HHGear^.Message and (gmLeft or gmRight or gmUp)) <> 0 then - Gear^.Pos := 500; + Gear^.Pos := 500; if HHGear^.dX.isNegative then Gear^.Tag := -1 @@ -3749,11 +3358,14 @@ if (HHGear^.Message and gmUp) <> 0 then begin - if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then + if (not HHGear^.dY.isNegative) + or (HHGear^.Y > -_256) then HHGear^.dY := HHGear^.dY - move; + dec(Gear^.Health, fuel); Gear^.MsgParam := Gear^.MsgParam or gmUp; end; + if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true; if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then begin @@ -3762,14 +3374,16 @@ Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight)); end; - if Gear^.Health < 0 then Gear^.Health := 0; + if Gear^.Health < 0 then + Gear^.Health := 0; + if ((GameTicks and $FF) = 0) and (Gear^.Health < 500) then for i:= ((500-Gear^.Health) div 250) downto 0 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFeather); if (HHGear^.Message and gmAttack <> 0) then begin - HHGear^.Message := HHGear^.Message and not gmAttack; + HHGear^.Message := HHGear^.Message and (not gmAttack); if Gear^.FlightTime > 0 then begin AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + 32, gtEgg, 0, Gear^.dX * _0_5, Gear^.dY, 0); @@ -3779,8 +3393,9 @@ end; if HHGear^.Message and (gmUp or gmPrecise or gmLeft or gmRight) <> 0 then - Gear^.State := Gear^.State and not gsttmpFlag; - HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight); + Gear^.State := Gear^.State and (not gsttmpFlag); + + HHGear^.Message := HHGear^.Message and (not (gmUp or gmPrecise or gmLeft or gmRight)); HHGear^.State := HHGear^.State or gstMoving; Gear^.X := HHGear^.X; @@ -3789,34 +3404,36 @@ // this is probably not needed anymore if not CurrentTeam^.ExtDriven then FollowGear := HHGear; - if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear); + if ((Gear^.State and gsttmpFlag) = 0) + or (HHGear^.dY < _0) then + doStepHedgehogMoving(HHGear); if (Gear^.Health = 0) - or (HHGear^.Damage <> 0) - or CheckGearDrowning(HHGear) - or (TurnTimeLeft = 0) - // allow brief ground touches - to be fair on this, might need another counter - or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and (TestCollisionYwithGear(HHGear, 1) <> 0)) - or ((Gear^.Message and gmAttack) <> 0) then - begin - with HHGear^ do + or (HHGear^.Damage <> 0) + or CheckGearDrowning(HHGear) + or (TurnTimeLeft = 0) + // allow brief ground touches - to be fair on this, might need another counter + or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and (TestCollisionYwithGear(HHGear, 1) <> 0)) + or ((Gear^.Message and gmAttack) <> 0) then begin - Message := 0; - Active := true; - State := State or gstMoving - end; - Gear^.State := Gear^.State or gstAnimation or gstTmpFlag; - if HHGear^.dY < _0 then - begin - Gear^.dX := HHGear^.dX; - Gear^.dY := HHGear^.dY; - end; - Gear^.Timer := 0; - Gear^.doStep := @doStepBirdyDisappear; - CurAmmoGear := nil; - isCursorVisible := false; - AfterAttack; - end + with HHGear^ do + begin + Message := 0; + Active := true; + State := State or gstMoving + end; + Gear^.State := Gear^.State or gstAnimation or gstTmpFlag; + if HHGear^.dY < _0 then + begin + Gear^.dX := HHGear^.dX; + Gear^.dY := HHGear^.dY; + end; + Gear^.Timer := 0; + Gear^.doStep := @doStepBirdyDisappear; + CurAmmoGear := nil; + isCursorVisible := false; + AfterAttack; + end end; procedure doStepBirdyDescend(Gear: PGear); @@ -3827,21 +3444,21 @@ dec(Gear^.Timer, 1) else if Gear^.Hedgehog^.Gear = nil then begin - DeleteGear(Gear); - AfterAttack; - exit + DeleteGear(Gear); + AfterAttack; + exit end; HHGear := Gear^.Hedgehog^.Gear; - HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight); + HHGear^.Message := HHGear^.Message and (not (gmUp or gmPrecise or gmLeft or gmRight)); if abs(hwRound(HHGear^.Y - Gear^.Y)) > 32 then - begin + begin if Gear^.Timer = 0 then Gear^.Y := Gear^.Y + _0_1 - end + end else if Gear^.Timer = 0 then begin - Gear^.doStep := @doStepBirdyFly; - HHGear^.dY := -_0_2 + Gear^.doStep := @doStepBirdyFly; + HHGear^.dY := -_0_2 end end; @@ -3851,26 +3468,27 @@ if Gear^.Timer < 2000 then inc(Gear^.Timer, 1) else - begin + begin Gear^.Timer := 500; Gear^.dX := _0; Gear^.dY := _0; - Gear^.State := Gear^.State and not gstAnimation; + Gear^.State := Gear^.State and (not gstAnimation); Gear^.doStep := @doStepBirdyDescend; - end + end end; procedure doStepBirdy(Gear: PGear); var HHGear: PGear; begin - gear^.State := gear^.State or gstAnimation and not gstTmpFlag; + gear^.State := gear^.State or gstAnimation and (not gstTmpFlag); Gear^.doStep := @doStepBirdyAppear; + if CurrentHedgehog = nil then - begin + begin DeleteGear(Gear); exit - end; + end; HHGear := CurrentHedgehog^.Gear; @@ -3883,8 +3501,8 @@ FollowGear := HHGear; with HHGear^ do begin - State := State and not gstAttacking; - Message := Message and not (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) + State := State and (not gstAttacking); + Message := Message and (not (gmAttack or gmUp or gmPrecise or gmLeft or gmRight)) end end; @@ -3901,43 +3519,44 @@ CalcRotationDirAngle(Gear); if (Gear^.State and gstCollision) <> 0 then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLPoisoned, $C0E0FFE0); PlaySound(sndEggBreak); AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg); vg := AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEgg); - if vg <> nil then vg^.Frame := 2; + if vg <> nil then + vg^.Frame := 2; for i:= 10 downto 0 do - begin + begin vg := AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), hwRound(Gear^.Y) - 3 + Random(6), vgtDust); - if vg <> nil then vg^.dX := vg^.dX + (Gear^.dX.QWordValue / 21474836480); - end; + if vg <> nil then + vg^.dX := vg^.dX + (Gear^.dX.QWordValue / 21474836480); + end; DeleteGear(Gear); exit - end; + end; end; //////////////////////////////////////////////////////////////////////////////// procedure doPortalColorSwitch(); var CurWeapon: PAmmo; begin - if (CurrentHedgehog <> nil) - and (CurrentHedgehog^.Gear <> nil) - and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then - With CurrentHedgehog^ do - if (CurAmmoType = amPortalGun) then - begin - CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gmSwitch; + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.Message and gmSwitch) <> 0) then + with CurrentHedgehog^ do + if (CurAmmoType = amPortalGun) then + begin + CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch); - CurWeapon:= GetAmmoEntry(CurrentHedgehog^); - if CurWeapon^.Pos <> 0 then - CurWeapon^.Pos := 0 - else + CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); + if CurWeapon^.Pos <> 0 then + CurWeapon^.Pos := 0 + + else CurWeapon^.Pos := 1; - end; + end; end; procedure doStepPortal(Gear: PGear); @@ -3952,28 +3571,28 @@ // destroy portal if ground it was attached too is gone if ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)] and $FF00) = 0) - or (Gear^.Timer < 1) - or (Gear^.Hedgehog <> CurrentHedgehog) - or (hwRound(Gear^.Y) > cWaterLine) then - begin + or (Gear^.Timer < 1) + or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) + or (hwRound(Gear^.Y) > cWaterLine) then + begin deleteGear(Gear); EXIT; - end; + end; if (TurnTimeLeft < 1) - or (Gear^.Health < 1) then + or (Gear^.Health < 1) then dec(Gear^.Timer); if Gear^.Timer < 10000 then gear^.RenderTimer := true; // abort if there is no other portal connected to this one - if (Gear^.IntersectGear = nil) then + if (Gear^.LinkedGear = nil) then exit; - if ((Gear^.IntersectGear^.Tag and 1) = 0) then // or if it's still moving; + if ((Gear^.LinkedGear^.Tag and 1) = 0) then // or if it's still moving; exit; - conPortal := Gear^.IntersectGear; + conPortal := Gear^.LinkedGear; // check all gears for stuff to port through iterator := nil; @@ -3991,17 +3610,13 @@ break; // don't port portals or other gear that wouldn't make sense - if (iterator^.Kind in [gtPortal, gtRope, gtRCPlane]) - or (iterator^.PortalCounter > 32) then - continue; + if (iterator^.Kind in [gtPortal, gtRope, gtAirAttack]) + or (iterator^.PortalCounter > 32) then + continue; // don't port hogs on rope // TODO: this will also prevent hogs while falling after rope use from // falling through portals... fix that! - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) - and (iterator = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = - gtRope) then - continue; // check if gear fits through portal if (iterator^.Radius > Gear^.Radius) then @@ -4012,39 +3627,38 @@ // too far away? if (iterator^.X < Gear^.X - r) - or (iterator^.X > Gear^.X + r) - or (iterator^.Y < Gear^.Y - r) - or (iterator^.Y > Gear^.Y + r) then + or (iterator^.X > Gear^.X + r) + or (iterator^.Y < Gear^.Y - r) + or (iterator^.Y > Gear^.Y + r) then continue; - hasdxy := (((iterator^.dX.QWordValue <> 0) or (iterator^.dY.QWordValue <> 0)) - or ((iterator^.State or gstMoving) = 0)); + hasdxy := (((iterator^.dX.QWordValue <> 0) or (iterator^.dY.QWordValue <> 0)) or ((iterator^.State or gstMoving) = 0)); // in case the object is not moving, let's asume it's falling towards the portal if not hasdxy then - begin + begin if Gear^.Y < iterator^.Y then continue; ox:= Gear^.X - iterator^.X; oy:= Gear^.Y - iterator^.Y; - end + end else - begin + begin ox:= iterator^.dX; oy:= iterator^.dY; - end; + end; // cake will need extra treatment... it's so delicious and moist! iscake:= (iterator^.Kind = gtCake); // won't port stuff that does not move towards the front/portal entrance if iscake then - begin - if not ((iterator^.X - Gear^.X)*ox + (iterator^.Y - Gear^.Y)*oy).isNegative then + begin + if not (((iterator^.X - Gear^.X)*ox + (iterator^.Y - Gear^.Y)*oy).isNegative) then continue; - end + end else - if not (Gear^.dX*ox + Gear^.dY*oy).isNegative then + if not ((Gear^.dX*ox + Gear^.dY*oy).isNegative) then continue; isbullet:= (iterator^.Kind in [gtShotgunShot, gtDEagleShot, gtSniperRifleShot, gtSineGunShot]); @@ -4052,23 +3666,23 @@ r:= int2hwFloat(iterator^.Radius); if not (isbullet or iscake) then - begin + begin // wow! good candidate there, let's see if the distance and direction is okay! if hasdxy then - begin + begin s := r / Distance(iterator^.dX, iterator^.dY); ox:= iterator^.X + s * iterator^.dX; oy:= iterator^.Y + s * iterator^.dY; - end + end else - begin + begin ox:= iterator^.X; oy:= iterator^.Y + r; - end; + end; if (hwRound(Distance(Gear^.X-ox,Gear^.Y-oy)) > Gear^.Radius + 1 ) then continue; - end; + end; // draw bullet trail if isbullet then @@ -4083,7 +3697,7 @@ continue; // only port bullets close to the portal - if isBullet and not (hwAbs(poffs) < _3) then + if isBullet and (not (hwAbs(poffs) < _3)) then continue; // @@ -4104,39 +3718,41 @@ ny := Gear^.dX; // ... decide where the top is based on the hog's direction when firing the portal if Gear^.Elasticity.isNegative then - nx.isNegative := not nx.isNegative + nx.isNegative := (not nx.isNegative) else ny.isNegative := not ny.isNegative; // calc gear offset in portal normal vector direction noffs:= (nx * ox + ny * oy); - if isBullet and (hwRound(hwAbs(noffs)) >= Gear^.Radius) then + if isBullet and (noffs.Round >= Longword(Gear^.Radius)) then continue; // avoid gravity related loops of not really moving gear - if not (iscake or isbullet) and (Gear^.dY.isNegative) and (conPortal^.dY.isNegative) - and ((iterator^.dX.QWordValue + iterator^.dY.QWordValue) < _0_08.QWordValue) - and (iterator^.PortalCounter > 0) then - continue; + if not (iscake or isbullet) + and (Gear^.dY.isNegative) + and (conPortal^.dY.isNegative) + and ((iterator^.dX.QWordValue + iterator^.dY.QWordValue) < _0_08.QWordValue) + and (iterator^.PortalCounter > 0) then + continue; // calc gear speed along to the vector and the normal vector of the portal if hasdxy then - begin + begin pspeed:= (Gear^.dX * iterator^.dX + Gear^.dY * iterator^.dY); nspeed:= (nx * iterator^.dX + ny * iterator^.dY); - end + end else - begin + begin pspeed:= hwAbs(cGravity * oy); nspeed:= _0; - end; + end; // creating normal vector of connected (exit) portal nx := conPortal^.dY; ny := conPortal^.dX; if conPortal^.Elasticity.isNegative then - nx.isNegative := not nx.isNegative + nx.isNegative := (not nx.isNegative) else ny.isNegative := not ny.isNegative; @@ -4151,37 +3767,38 @@ // make the gear's exit position close to the portal while // still respecting the movement direction - // determine the distance (in exit vector direction) - // that we want the gear at - if iscake then - ox:= (r - _0_7) - else - ox:= (r * _1_5); - s:= ox / poffs; - poffs:= ox; - if (nspeed.QWordValue <> 0) and (pspeed > _0) then - noffs:= noffs * s * (nspeed / pspeed); + // determine the distance (in exit vector direction) + // that we want the gear at + if iscake then + ox:= (r - _0_7) + else + ox:= (r * _1_5); + s:= ox / poffs; + poffs:= ox; + if (nspeed.QWordValue <> 0) + and (pspeed > _0) then + noffs:= noffs * s * (nspeed / pspeed); // move stuff with high normal offset closer to the portal's center if not isbullet then - begin + begin s := hwAbs(noffs) + r - int2hwFloat(Gear^.Radius); if s > _0 then noffs:= noffs - SignAs(s,noffs) - end; + end; iterator^.X := conPortal^.X + poffs * conPortal^.dX + noffs * nx; iterator^.Y := conPortal^.Y + poffs * conPortal^.dY + noffs * ny; - if not hasdxy and not (conPortal^.dY.isNegative) then - begin + if not hasdxy and (not (conPortal^.dY.isNegative)) then + begin iterator^.dY:= iterator^.dY + hwAbs(cGravity * (iterator^.Y - conPortal^.Y)) - end; + end; // see if the space on the exit side actually is enough if not (isBullet or isCake) then - begin + begin // TestCollisionXwithXYShift requires a hwFloat for xShift ox.QWordValue := _1.QWordValue; ox.isNegative := not iterator^.dX.isNegative; @@ -4197,74 +3814,91 @@ or TestCollisionX(iterator, sx); if not isCollision then - begin + begin // check center area (with half the radius so that the // the square check won't check more pixels than we want to) iterator^.Radius := 1 + resetr div 2; rh := resetr div 4; isCollision := TestCollisionYwithXYShift(iterator, 0, -sy * rh, sy, false) or TestCollisionXwithXYShift(iterator, ox * rh, 0, sx, false); - end; + end; iterator^.Radius := resetr; if isCollision then - begin + begin // collision! oh crap! go back! iterator^.X := resetx; iterator^.Y := resety; iterator^.dX := resetdx; iterator^.dY := resetdy; continue; + end; end; - end; // // You're now officially portaled! // // Until loops are reliably broken - if iscake then iterator^.PortalCounter:= 33 + if iscake then + iterator^.PortalCounter:= 33 else begin inc(iterator^.PortalCounter); - iterator^.State:= iterator^.State and not gstHHHJump + iterator^.Active:= true; + iterator^.State:= iterator^.State and (not gstHHHJump) end; - if not isbullet and (iterator^.Kind <> gtFlake) then + // is it worth adding an arcsin table? Just how often would we end up doing something like this? + // SYNCED ANGLE UPDATE + if iterator^.Kind = gtRCPlane then + begin + // recycling as temp vars + resety.isNegative:= false; + resety.QWordValue:= 4294967296 * 112; + resetx.isNegative:= false; + resetx.QWordValue:= 4294967296 * 35; + resetdx.isNegative:= false; + resetdx.QWordValue:= 4294967296 * 1152; + + resetdy:=hwAbs(iterator^.dX*4); + resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx; + iterator^.Angle:= hwRound(resetdy*_2048 / _PI); + if not iterator^.dY.isNegative then iterator^.Angle:= 2048-iterator^.Angle; + if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; + end + // VISUAL USE OF ANGLE ONLY + else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then + begin + iterator^.Angle:= DxDy2AttackAngle(iterator^.dX, iterator^.dY); + iterator^.Angle:= 2048-iterator^.Angle; + if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; + end; + + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) + and (iterator = CurrentHedgehog^.Gear) + and (CurAmmoGear <> nil) + and (CurAmmoGear^.Kind =gtRope) then + CurAmmoGear^.PortalCounter:= 1; + + if not isbullet and (iterator^.State and gstInvisible = 0) + and (iterator^.Kind <> gtFlake) then FollowGear := iterator; // store X/Y values of exit for net bullet trail if isbullet then - begin + begin iterator^.Elasticity:= iterator^.X; iterator^.Friction := iterator^.Y; - end; - - // This jiggles gears, to ensure a portal connection just placed under a gear takes effect. - iterator:= GearsList; - while iterator <> nil do - begin - if (iterator^.Kind <> gtPortal) and - ((iterator^.Hedgehog <> CurrentHedgehog) or ((iterator^.Message and gmAllStoppable) = 0)) then - begin - iterator^.Active:= true; - if iterator^.dY.QWordValue = _0.QWordValue then iterator^.dY.isNegative:= false; - iterator^.State:= iterator^.State or gstMoving; - DeleteCI(iterator); - //inc(iterator^.dY.QWordValue,10); - end; - iterator:= iterator^.NextGear end; - if Gear^.Health > 1 then dec(Gear^.Health); + if Gear^.Health > 1 then + dec(Gear^.Health); end; end; -procedure doStepMovingPortal_real(Gear: PGear); -var - x, y, tx, ty: LongInt; - s: hwFloat; + procedure loadNewPortalBall(oldPortal: PGear; destroyGear: Boolean); var @@ -4273,7 +3907,7 @@ if CurrentHedgehog <> nil then with CurrentHedgehog^ do begin - CurWeapon:= GetAmmoEntry(CurrentHedgehog^); + CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); if (CurAmmoType = amPortalGun) then begin if not destroyGear then @@ -4289,9 +3923,14 @@ CurWeapon^.Timer := 0; end end; - if destroyGear then oldPortal^.Timer:= 0; + if destroyGear then + oldPortal^.Timer:= 0; end; +procedure doStepMovingPortal_real(Gear: PGear); +var + x, y, tx, ty: LongInt; + s: hwFloat; begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); @@ -4300,15 +3939,17 @@ // avoid compiler hints if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > 255) then - begin + begin Gear^.State := Gear^.State or gstCollision; - Gear^.State := Gear^.State and not gstMoving; - if not CalcSlopeTangent(Gear, x, y, tx, ty, 255) - or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain - begin + Gear^.State := Gear^.State and (not gstMoving); + + if (Land[y, x] and lfBouncy <> 0) + or (not CalcSlopeTangent(Gear, x, y, tx, ty, 255)) + or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain + begin loadNewPortalBall(Gear, true); EXIT; - end; + end; // making a normalized normal vector s := _1/DistanceI(tx,ty); @@ -4316,13 +3957,12 @@ Gear^.dY := -s * tx; Gear^.DirAngle := DxDy2Angle(-Gear^.dY,Gear^.dX); - if not Gear^.dX.isNegative then Gear^.DirAngle := 180-Gear^.DirAngle; - - if ((Gear^.IntersectGear = nil) - or (hwRound(Distance(Gear^.X - Gear^.IntersectGear^.X,Gear^.Y-Gear^.IntersectGear^.Y)) >= - Gear^.Radius*2)) - then - begin + if not Gear^.dX.isNegative then + Gear^.DirAngle := 180-Gear^.DirAngle; + + if ((Gear^.LinkedGear = nil) + or (hwRound(Distance(Gear^.X - Gear^.LinkedGear^.X,Gear^.Y-Gear^.LinkedGear^.Y)) >=Gear^.Radius*2)) then + begin loadNewPortalBall(Gear, false); inc(Gear^.Tag); Gear^.doStep := @doStepPortal; @@ -4330,18 +3970,21 @@ else loadNewPortalBall(Gear, true); end - else if (y > cWaterLine) or (y < -LAND_WIDTH) - or (x > 2*LAND_WIDTH) or (x < -LAND_WIDTH) then - loadNewPortalBall(Gear, true); + + else if (y > cWaterLine) + or (y < -max(LAND_WIDTH,4096)) + or (x > 2*max(LAND_WIDTH,4096)) + or (x < -max(LAND_WIDTH,4096)) then + loadNewPortalBall(Gear, true); end; procedure doStepMovingPortal(Gear: PGear); begin doPortalColorSwitch(); doStepPerPixel(Gear, @doStepMovingPortal_real, true); - if (Gear^.Timer < 1) - or (Gear^.Hedgehog <> CurrentHedgehog) then - deleteGear(Gear); + if (Gear^.Timer < 1) + or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) then + deleteGear(Gear); end; procedure doStepPortalShot(newPortal: PGear); @@ -4360,16 +4003,16 @@ newPortal^.dX := newPortal^.dX * s; newPortal^.dY := newPortal^.dY * s; - newPortal^.IntersectGear := nil; + newPortal^.LinkedGear := nil; if CurrentHedgehog <> nil then - With CurrentHedgehog^ do - begin - CurWeapon:= GetAmmoEntry(CurrentHedgehog^); + with CurrentHedgehog^ do + begin + CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); // let's save the HH's dX's direction so we can decide where the "top" of the portal hole newPortal^.Elasticity.isNegative := CurrentHedgehog^.Gear^.dX.isNegative; // when doing a backjump the dx is the opposite of the facing direction - if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then + if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative; // make portal gun look unloaded @@ -4378,27 +4021,47 @@ iterator := GearsList; while iterator <> nil do - begin + begin if (iterator^.Kind = gtPortal) then - if (iterator <> newPortal) and (iterator^.Timer > 0) then - begin - if (iterator^.Tag and 2) = (newPortal^.Tag and 2) then + if (iterator <> newPortal) and (iterator^.Timer > 0) and (iterator^.Hedgehog = CurrentHedgehog) then begin + if ((iterator^.Tag and 2) = (newPortal^.Tag and 2)) then + begin iterator^.Timer:= 0; - end + end else - begin + begin // link portals with each other - newPortal^.IntersectGear := iterator; - iterator^.IntersectGear := newPortal; + newPortal^.LinkedGear := iterator; + iterator^.LinkedGear := newPortal; iterator^.Health := newPortal^.Health; + end; end; - end; iterator^.PortalCounter:= 0; iterator := iterator^.NextGear + end; + + if newPortal^.LinkedGear <> nil then + begin + // This jiggles gears, to ensure a portal connection just placed under a gear takes effect. + iterator:= GearsList; + while iterator <> nil do + begin + if not (iterator^.Kind in [gtPortal, gtAirAttack, gtKnife]) and ((iterator^.Hedgehog <> CurrentHedgehog) + or ((iterator^.Message and gmAllStoppable) = 0)) then + begin + iterator^.Active:= true; + if iterator^.dY.QWordValue = _0.QWordValue then + iterator^.dY.isNegative:= false; + iterator^.State:= iterator^.State or gstMoving; + DeleteCI(iterator); + //inc(iterator^.dY.QWordValue,10); + end; + iterator:= iterator^.NextGear + end + end end; - end; - newPortal^.State := newPortal^.State and not gstCollision; + newPortal^.State := newPortal^.State and (not gstCollision); newPortal^.State := newPortal^.State or gstMoving; newPortal^.doStep := @doStepMovingPortal; end; @@ -4411,31 +4074,31 @@ begin AllInactive := false; if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and - ((CurrentHedgehog^.Gear^.Message and gmSlot) <> 0) then - begin - case CurrentHedgehog^.Gear^.MsgParam of - 0: PlaySound(sndPiano0); - 1: PlaySound(sndPiano1); - 2: PlaySound(sndPiano2); - 3: PlaySound(sndPiano3); - 4: PlaySound(sndPiano4); - 5: PlaySound(sndPiano5); - 6: PlaySound(sndPiano6); - 7: PlaySound(sndPiano7); - else PlaySound(sndPiano8); - end; + ((CurrentHedgehog^.Gear^.Message and gmSlot) <> 0) then + begin + case CurrentHedgehog^.Gear^.MsgParam of + 0: PlaySound(sndPiano0); + 1: PlaySound(sndPiano1); + 2: PlaySound(sndPiano2); + 3: PlaySound(sndPiano3); + 4: PlaySound(sndPiano4); + 5: PlaySound(sndPiano5); + 6: PlaySound(sndPiano6); + 7: PlaySound(sndPiano7); + else PlaySound(sndPiano8); + end; AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote); CurrentHedgehog^.Gear^.MsgParam := 0; - CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and not gmSlot; + CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSlot); end; if (*((Gear^.Pos = 3) and ((GameFlags and gfSolidLand) <> 0)) or*) (Gear^.Pos = 5) then begin Gear^.dY := Gear^.dY + cGravity * 2; Gear^.Y := Gear^.Y + Gear^.dY; - CheckGearDrowning(Gear); - if (Gear^.State and gstDrowning) <> 0 then + if CheckGearDrowning(Gear) then begin + Gear^.Y:= Gear^.Y + _50; OnUsedAmmo(CurrentHedgehog^); if CurrentHedgehog^.Gear <> nil then begin @@ -4444,7 +4107,8 @@ CurrentHedgehog^.Gear^.X := Gear^.X; CurrentHedgehog^.Gear^.Y := int2hwFloat(cWaterLine+cVisibleWater)+_128; CurrentHedgehog^.Unplaced := false; - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:= 0 end; ResumeMusic @@ -4457,6 +4121,7 @@ if (Gear^.State and gstDrowning) <> 0 then begin + Gear^.Y:= Gear^.Y + _50; OnUsedAmmo(CurrentHedgehog^); if CurrentHedgehog^.Gear <> nil then begin @@ -4465,7 +4130,8 @@ CurrentHedgehog^.Gear^.X := Gear^.X; CurrentHedgehog^.Gear^.Y := int2hwFloat(cWaterLine+cVisibleWater)+_128; CurrentHedgehog^.Unplaced := false; - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:= 0 end; ResumeMusic @@ -4479,7 +4145,7 @@ doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 80 + r0, Gear^.Hedgehog, EXPLAutoSound); for r0:= 0 to 4 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtNote); - Gear^.dY := odY * -1 + cGravity * 2; + Gear^.dY := cGravity * 2 - odY; Gear^.Pos := Gear^.Pos + 1; end else @@ -4507,10 +4173,11 @@ sdY := hwAbs(ldX) + hwAbs(ldY); sdX := _1 - hwAbs(ldX/sdY); sdY := _1 - hwAbs(ldY/sdY); - if (ldX.isNegative = ldY.isNegative) then sdY := -sdY; + if (ldX.isNegative = ldY.isNegative) then + sdY := -sdY; // initial angle depends on current GameTicks - t := GameTicks mod 4096; + t := getRandom(4096); // used for a work-around detection of area that is within land array, but outside borders @@ -4538,35 +4205,35 @@ // if borders are on, stop outside land array if hasBorder and (((x and LAND_WIDTH_MASK) <> 0) or ((y and LAND_HEIGHT_MASK) <> 0)) then - begin + begin Gear^.Damage := 0; Gear^.Health := 0; - end + end else - begin + begin if (rY <= cWaterLine) or (y <= cWaterLine) then - begin - if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) - and (Land[y, x] <> 0) then begin - if justCollided then - begin - Gear^.Damage := 0; - Gear^.Health := 0; - end - else - begin - inc(Gear^.Damage,3); - justCollided := true; - end; - end + if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) + and (Land[y, x] <> 0) then + begin + if justCollided then + begin + Gear^.Damage := 0; + Gear^.Health := 0; + end + else + begin + inc(Gear^.Damage,3); + justCollided := true; + end; + end else justCollided := false; // kick nearby hogs, dig tunnel and add some fire // if at least 5 collisions occured if Gear^.Damage > 0 then - begin + begin DrawExplosion(rX,rY,Gear^.Radius); // kick nearby hogs @@ -4577,27 +4244,40 @@ // add some fire to the tunnel if getRandom(6) = 0 then - AddGear(x - Gear^.Radius + LongInt(getRandom(2 * Gear^.Radius)), y - - getRandom(Gear^.Radius + 1), gtFlame, gsttmpFlag, _0, _0, 0); - end; - - if getRandom(100) = 0 then + begin + tmp:= GetRandom(2 * Gear^.Radius); + AddGear(x - Gear^.Radius + tmp, y - GetRandom(Gear^.Radius + 1), gtFlame, gsttmpFlag, _0, _0, 0) + end + end; + + if random(100) = 0 then AddVisualGear(x, y, vgtSmokeTrace); - end - else dec(Gear^.Health, 5); // if underwater get additional damage - end; + end + else dec(Gear^.Health, 5); // if underwater get additional damage + end; dec(Gear^.Health); // decrease bullet size towards the end - if (Gear^.Radius > 4) then begin - if (Gear^.Health <= (initHealth div 3)) then dec(Gear^.Radius) end - else if (Gear^.Radius > 3) then begin - if (Gear^.Health <= (initHealth div 4)) then dec(Gear^.Radius) end + if (Gear^.Radius > 4) then + begin + if (Gear^.Health <= (initHealth div 3)) then + dec(Gear^.Radius) + end + else if (Gear^.Radius > 3) then + begin + if (Gear^.Health <= (initHealth div 4)) then + dec(Gear^.Radius) + end else if (Gear^.Radius > 2) then begin - if (Gear^.Health <= (initHealth div 5)) then dec(Gear^.Radius) end - else if (Gear^.Radius > 1) then begin - if (Gear^.Health <= (initHealth div 6)) then dec(Gear^.Radius) end; + if (Gear^.Health <= (initHealth div 5)) then + dec(Gear^.Radius) + end + else if (Gear^.Radius > 1) then + begin + if (Gear^.Health <= (initHealth div 6)) then + dec(Gear^.Radius) + end; until (Gear^.Health <= 0); @@ -4606,7 +4286,7 @@ end; procedure doStepSineGunShot(Gear: PGear); -var +var HHGear: PGear; begin PlaySound(sndSineGun); @@ -4628,7 +4308,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFlamethrowerWork(Gear: PGear); var - HHGear: PGear; + HHGear, flame: PGear; rx, ry, speed: hwFloat; i, gX, gY: LongInt; begin @@ -4642,13 +4322,17 @@ begin if (HHGear^.Message and gmRight) <> 0 then begin - if HHGear^.dX.isNegative and (Gear^.Tag < 20) then inc(Gear^.Tag) - else if Gear^.Tag > 5 then dec(Gear^.Tag); + if HHGear^.dX.isNegative and (Gear^.Tag < 20) then + inc(Gear^.Tag) + else if Gear^.Tag > 5 then + dec(Gear^.Tag); end else if (HHGear^.Message and gmLeft) <> 0 then begin - if HHGear^.dX.isNegative and (Gear^.Tag > 5) then dec(Gear^.Tag) - else if Gear^.Tag < 20 then inc(Gear^.Tag); + if HHGear^.dX.isNegative and (Gear^.Tag > 5) then + dec(Gear^.Tag) + else if Gear^.Tag < 20 then + inc(Gear^.Tag); end end; @@ -4658,23 +4342,27 @@ dec(Gear^.Health); if (Gear^.Health mod 5) = 0 then begin - rx := rndSign(getRandom * _0_1); - ry := rndSign(getRandom * _0_1); + rx := rndSign(getRandomf * _0_1); + ry := rndSign(getRandomf * _0_1); speed := _0_5 * (_10 / Gear^.Tag); - AddGear(gx, gy, gtFlame, gstTmpFlag, + flame:= AddGear(gx, gy, gtFlame, gstTmpFlag, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); + flame^.CollisionMask:= $FF7F; if (Gear^.Health mod 30) = 0 then - AddGear(gx, gy, gtFlame, 0, + begin + flame:= AddGear(gx, gy, gtFlame, 0, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); + flame^.CollisionMask:= $FF7F; + end end; Gear^.Timer:= Gear^.Tag end; - if (Gear^.Health = 0) or (HHGear^.Damage <> 0) then + if (Gear^.Health = 0) or ((HHGear^.State and gstHHDriven) = 0) then begin DeleteGear(Gear); AfterAttack @@ -4685,7 +4373,7 @@ if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then begin Gear^.Damage:= i; - if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); + FreeTexture(Gear^.Tex); Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + '%', cWhiteColor, fntSmall) end @@ -4697,7 +4385,7 @@ HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; - HHGear^.Message := HHGear^.Message and not (gmUp or gmDown or gmLeft or gmRight); + HHGear^.Message := HHGear^.Message and (not (gmUp or gmDown or gmLeft or gmRight)); HHGear^.State := HHGear^.State or gstNotKickable; Gear^.doStep := @doStepFlamethrowerWork end; @@ -4705,7 +4393,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepLandGunWork(Gear: PGear); var - HHGear: PGear; + HHGear, land: PGear; rx, ry, speed: hwFloat; i, gX, gY: LongInt; begin @@ -4719,13 +4407,17 @@ begin if (HHGear^.Message and gmRight) <> 0 then begin - if HHGear^.dX.isNegative and (Gear^.Tag < 20) then inc(Gear^.Tag) - else if Gear^.Tag > 5 then dec(Gear^.Tag); + if HHGear^.dX.isNegative and (Gear^.Tag < 20) then + inc(Gear^.Tag) + else if Gear^.Tag > 5 then + dec(Gear^.Tag); end else if (HHGear^.Message and gmLeft) <> 0 then begin - if HHGear^.dX.isNegative and (Gear^.Tag > 5) then dec(Gear^.Tag) - else if Gear^.Tag < 20 then inc(Gear^.Tag); + if HHGear^.dX.isNegative and (Gear^.Tag > 5) then + dec(Gear^.Tag) + else if Gear^.Tag < 20 then + inc(Gear^.Tag); end end; @@ -4734,20 +4426,21 @@ begin dec(Gear^.Health); - rx := rndSign(getRandom * _0_1); - ry := rndSign(getRandom * _0_1); + rx := rndSign(getRandomf * _0_1); + ry := rndSign(getRandomf * _0_1); speed := (_3 / Gear^.Tag); - AddGear(gx, gy, gtFlake, gstTmpFlag, + land:= AddGear(gx, gy, gtFlake, gstTmpFlag, SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - speed) + ry, 0); + land^.CollisionMask:= $FF7F; Gear^.Timer:= Gear^.Tag end; - if (Gear^.Health = 0) or (HHGear^.Damage <> 0) or ((HHGear^.Message and gmAttack) <> 0) then - begin - HHGear^.Message:= HHGear^.Message and not gmAttack; + if (Gear^.Health = 0) or ((HHGear^.State and gstHHDriven) = 0) or ((HHGear^.Message and gmAttack) <> 0) then + begin + HHGear^.Message:= HHGear^.Message and (not gmAttack); DeleteGear(Gear); AfterAttack end @@ -4757,7 +4450,7 @@ if (i <> Gear^.Damage) and ((GameTicks and $3F) = 0) then begin Gear^.Damage:= i; - if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); + FreeTexture(Gear^.Tex); Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(i) + '%', cWhiteColor, fntSmall) end @@ -4769,7 +4462,7 @@ HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; - HHGear^.Message := HHGear^.Message and not (gmUp or gmDown or gmLeft or gmRight or gmAttack); + HHGear^.Message := HHGear^.Message and (not (gmUp or gmDown or gmLeft or gmRight or gmAttack)); HHGear^.State := HHGear^.State or gstNotKickable; Gear^.doStep := @doStepLandGunWork end; @@ -4778,10 +4471,10 @@ procedure doStepPoisonCloud(Gear: PGear); begin if Gear^.Timer = 0 then - begin + begin DeleteGear(Gear); exit - end; + end; dec(Gear^.Timer); Gear^.X:= Gear^.X + Gear^.dX; Gear^.Y:= Gear^.Y + Gear^.dY; @@ -4816,10 +4509,11 @@ if (tmp^.Kind = gtHedgehog) or (tmp^.Kind = gtMine) or (tmp^.Kind = gtExplosives) then begin //tmp^.State:= tmp^.State or gstFlatened; - ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown); + if not tmp^.Invulnerable then + ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown); //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3); tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0); - tmp2^.IntersectGear:= tmp; + tmp2^.LinkedGear:= tmp; SetAllToActive end else @@ -4827,7 +4521,7 @@ end end; -HHGear^.State:= HHGear^.State and not gstNoDamage; +HHGear^.State:= HHGear^.State and (not gstNoDamage); Gear^.Timer:= 250; Gear^.doStep:= @doStepIdle end; @@ -4838,7 +4532,7 @@ HitGear: PGear; begin AllInactive := false; - HitGear := Gear^.IntersectGear; + HitGear := Gear^.LinkedGear; dec(Gear^.Timer); if (HitGear = nil) or (Gear^.Timer = 0) or ((Gear^.Message and gmDestroy) <> 0) then begin @@ -4877,7 +4571,8 @@ begin Gear^.dY := Gear^.dY + cGravity; Gear^.Y := Gear^.Y + Gear^.dY; - if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer := 1 + if hwRound(Gear^.Y) > cWaterLine then + Gear^.Timer := 1 end; Gear^.X := Gear^.X + HitGear^.dX; @@ -4897,12 +4592,12 @@ y := hwRound(Gear^.Y) - cHHRadius * 2; while y < hwRound(Gear^.Y) do - begin + begin ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); ar[i].Right := hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); inc(y, 2); inc(i) - end; + end; DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); Gear^.dY := HHGear^.dY; @@ -4915,7 +4610,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepResurrectorWork(Gear: PGear); var - graves: TPGearArray; + graves: PGearArrayS; resgear: PGear; hh: PHedgehog; i: LongInt; @@ -4935,21 +4630,24 @@ if ((Gear^.Message and gmUp) <> 0) then begin - if (GameTicks and $F) <> 0 then exit; + if (GameTicks and $F) <> 0 then + exit; end - else if (GameTicks and $1FF) <> 0 then exit; + else if (GameTicks and $1FF) <> 0 then + exit; if Gear^.Power < 45 then begin inc(Gear^.Power); - if TestCollisionYwithGear(hh^.Gear, -1) = 0 then hh^.Gear^.Y := hh^.Gear^.Y - _1; + if TestCollisionYwithGear(hh^.Gear, -1) = 0 then + hh^.Gear^.Y := hh^.Gear^.Y - _1; end; graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius); - if Length(graves) = 0 then - begin - StopSound(Gear^.SoundChannel); + if graves.size = 0 then + begin + StopSoundChan(Gear^.SoundChannel); Gear^.Timer := 250; Gear^.doStep := @doStepIdle; exit; @@ -4957,12 +4655,13 @@ if ((Gear^.Message and gmAttack) <> 0) and (hh^.Gear^.Health > 0) and (TurnTimeLeft > 0) then begin - if Length(graves) <= Gear^.Tag then Gear^.Tag:= 0; + if LongInt(graves.size) <= Gear^.Tag then Gear^.Tag:= 0; dec(hh^.Gear^.Health); if (hh^.Gear^.Health = 0) and (hh^.Gear^.Damage = 0) then hh^.Gear^.Damage:= 1; RenderHealth(hh^); - inc(graves[Gear^.Tag]^.Health); + RecountTeamHealth(hh^.Team); + inc(graves.ar^[Gear^.Tag]^.Health); inc(Gear^.Tag) {-for i:= 0 to High(graves) do begin if hh^.Gear^.Health > 0 then begin @@ -4974,27 +4673,28 @@ else begin // now really resurrect the hogs with the hp saved in the graves - for i:= 0 to High(graves) do - if graves[i]^.Health > 0 then + for i:= 0 to graves.size - 1 do + if graves.ar^[i]^.Health > 0 then begin - resgear := AddGear(hwRound(graves[i]^.X), hwRound(graves[i]^.Y), - gtHedgehog, gstWait, _0, _0, 0); - resgear^.Hedgehog := graves[i]^.Hedgehog; - resgear^.Health := graves[i]^.Health; - PHedgehog(graves[i]^.Hedgehog)^.Gear := resgear; - DeleteGear(graves[i]); + resgear := AddGear(hwRound(graves.ar^[i]^.X), hwRound(graves.ar^[i]^.Y), gtHedgehog, gstWait, _0, _0, 0); + resgear^.Hedgehog := graves.ar^[i]^.Hedgehog; + resgear^.Health := graves.ar^[i]^.Health; + PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := resgear; + graves.ar^[i]^.Message:= graves.ar^[i]^.Message or gmDestroy; + graves.ar^[i]^.Active:= true; RenderHealth(resgear^.Hedgehog^); RecountTeamHealth(resgear^.Hedgehog^.Team); - resgear^.Hedgehog^.Effects[heResurrected]:= true; + resgear^.Hedgehog^.Effects[heResurrected]:= 1; // only make hat-less hedgehogs look like zombies, preserve existing hats + if resgear^.Hedgehog^.Hat = 'NoHat' then - LoadHedgehogHat(resgear, 'Reserved/Zombie'); + LoadHedgehogHat(resgear^.Hedgehog^, 'Reserved/Zombie'); end; hh^.Gear^.dY := _0; hh^.Gear^.dX := _0; doStepHedgehogMoving(hh^.Gear); - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); Gear^.Timer := 250; Gear^.doStep := @doStepIdle; end @@ -5003,24 +4703,24 @@ procedure doStepResurrector(Gear: PGear); var - graves: TPGearArray; + graves: PGearArrayS; i: LongInt; begin AllInactive := false; graves := GearsNear(Gear^.X, Gear^.Y, gtGrave, Gear^.Radius); - if Length(graves) > 0 then - begin - for i:= 0 to High(graves) do + if graves.size > 0 then + begin + for i:= 0 to graves.size - 1 do begin - PHedgehog(graves[i]^.Hedgehog)^.Gear := nil; - graves[i]^.Health := 0; + PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := nil; + graves.ar^[i]^.Health := 0; end; Gear^.doStep := @doStepResurrectorWork; end else begin - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); Gear^.Timer := 250; Gear^.doStep := @doStepIdle; end @@ -5041,8 +4741,8 @@ gY := hwRound(Gear^.Y); for i:= 0 to 10 do begin - dX := AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandom + _1); - dY := AngleSin(i * 8) * _0_5 * (GetRandom + _1); + dX := AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandomf + _1); + dY := AngleSin(i * 8) * _0_5 * (GetRandomf + _1); AddGear(gX, gY, gtFlame, 0, dX, dY, 0); AddGear(gX, gY, gtFlame, 0, dX, -dY, 0); AddGear(gX, gY, gtFlame, 0, -dX, dY, 0); @@ -5052,13 +4752,13 @@ exit end; if (Gear^.Timer = 0) then - begin + begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLAutoSound); for i:= -19 to 19 do FollowGear := AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); DeleteGear(Gear); exit - end; + end; if (GameTicks and $3F) = 0 then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); dec(Gear^.Timer) @@ -5068,53 +4768,84 @@ procedure doStepStructure(Gear: PGear); var x, y: LongInt; + HH: PHedgehog; + t: PGear; begin + HH:= Gear^.Hedgehog; + if (Gear^.State and gstMoving) <> 0 then begin AddGearCI(Gear); Gear^.dX:= _0; Gear^.dY:= _0; - Gear^.State:= Gear^.State and not gstMoving; - end; - - if CurAmmoGear = Gear then - begin - if (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then - begin - DeleteGear(Gear); - exit - end; - if Gear = CurAmmoGear then CurAmmoGear := nil; - Gear^.Hedgehog:= CurrentHedgehog; - RemoveGearFromList(CurrentHedgehog^.Gear); - CurrentHedgehog^.Gear^.Z := cHHZ; - CurrentHedgehog^.Gear^.Active := false; - CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstHHDriven; - CurrentHedgehog^.GearHidden:= CurrentHedgehog^.Gear; - CurrentHedgehog^.Gear:= nil; - Gear^.Tag:= TotalRounds + Gear^.Tag; - AddGearCI(Gear); + Gear^.State:= Gear^.State and (not gstMoving); end; dec(Gear^.Health, Gear^.Damage); - Gear^.Damage := 0; + Gear^.Damage:= 0; - if (Gear^.Tag = TotalRounds) or (Gear^.Health <= 0) then - begin - if Gear^.Hedgehog <> nil then + if Gear^.Pos = 1 then + begin + AddGearCI(Gear); + AfterAttack; + if Gear = CurAmmoGear then + CurAmmoGear:= nil; + if HH^.Gear <> nil then + HideHog(HH); + Gear^.Pos:= 2 + end; + + if Gear^.Pos = 2 then + begin + if ((GameTicks mod 100) = 0) and (Gear^.Timer < 1000) then begin - Gear^.Hedgehog^.Gear:= Gear^.Hedgehog^.GearHidden; - Gear^.Hedgehog^.GearHidden:= nil; - Gear^.Hedgehog^.Gear^.X:= Gear^.X; - Gear^.Hedgehog^.Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Radius + cHHRadius); - InsertGearToList(Gear^.Hedgehog^.Gear); - Gear^.Hedgehog:= nil; - SetAllHHToActive; + if (Gear^.Timer mod 10) = 0 then + begin + DeleteCI(Gear); + Gear^.Y:= Gear^.Y - _0_5; + AddGearCI(Gear); + end; + inc(Gear^.Timer); end; + if Gear^.Tag <= TotalRounds then + Gear^.Pos:= 3; end; + if Gear^.Pos = 3 then + if Gear^.Timer < 1000 then + begin + if (Gear^.Timer mod 10) = 0 then + begin + DeleteCI(Gear); + Gear^.Y:= Gear^.Y - _0_5; + AddGearCI(Gear); + end; + inc(Gear^.Timer); + end + else + begin + if HH^.GearHidden <> nil then + RestoreHog(HH); + Gear^.Pos:= 4; + end; + + if Gear^.Pos = 4 then + if ((GameTicks mod 1000) = 0) and ((GameFlags and gfInvulnerable) = 0) then + begin + t:= GearsList; + while t <> nil do + begin + if (t^.Kind = gtHedgehog) and (t^.Hedgehog^.Team^.Clan = HH^.Team^.Clan) then + t^.Invulnerable:= true; + t:= t^.NextGear; + end; + end; + if Gear^.Health <= 0 then begin + if HH^.GearHidden <> nil then + RestoreHog(HH); + x := hwRound(Gear^.X); y := hwRound(Gear^.Y); @@ -5146,7 +4877,7 @@ HH:= Gear^.Hedgehog; if Gear^.Pos = 2 then begin - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); if (Gear^.Timer = 0) then begin if (HH^.Gear <> nil) and (HH^.Gear^.State and gstInvisible = 0) then @@ -5174,21 +4905,23 @@ begin inc(Gear^.Power); if (Gear^.Power = 172) and (HH^.Gear <> nil) and - (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and - ((HH^.Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then - with HH^.Gear^ do - begin - State:= State or gstAnimation; - Tag:= 2; - Timer:= 0; - Pos:= 0 - end + (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and + ((HH^.Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then + with HH^.Gear^ do + begin + State:= State or gstAnimation; + Tag:= 2; + Timer:= 0; + Pos:= 0 + end end; -if (Gear^.Pos = 3) and (GameTicks and $1F = 0) and (Gear^.Power > 0) then dec(Gear^.Power); -if (Gear^.Pos = 1) and (Gear^.Power = 255) and ((GameTicks mod 2000) = 1000) then Gear^.Pos:= 2; +if (Gear^.Pos = 3) and (GameTicks and $1F = 0) and (Gear^.Power > 0) then + dec(Gear^.Power); +if (Gear^.Pos = 1) and (Gear^.Power = 255) and ((GameTicks mod 2000) = 1000) then + Gear^.Pos:= 2; if (Gear^.Pos = 3) and (Gear^.Power = 0) then begin - StopSound(Gear^.SoundChannel); + StopSoundChan(Gear^.SoundChannel); if HH^.GearHidden = nil then begin DeleteGear(Gear); @@ -5196,7 +4929,7 @@ end; Gear^.Pos:= 4; // This condition might need tweaking - Gear^.Timer:= GetRandom(cHedgehogTurnTime*TeamsCount)+cHedgehogTurnTime + Gear^.Timer:= GetRandom(cHedgehogTurnTime*TeamsCount*2)+cHedgehogTurnTime*2 end; if (Gear^.Pos = 4) then @@ -5204,24 +4937,32 @@ cnt:= 0; for j:= 0 to Pred(HH^.Team^.Clan^.TeamsNumber) do for i:= 0 to Pred(HH^.Team^.Clan^.Teams[j]^.HedgehogsNumber) do - if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) and - ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) and - (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > - HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt); + if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) + and ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) + and (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then + inc(cnt); if (cnt = 0) or SuddenDeathDmg or (Gear^.Timer = 0) then begin - Gear^.SoundChannel := LoopSound(sndTardis); - Gear^.Pos:= 1; - Gear^.Power:= 0; - Gear^.Timer:= 0; - if HH^.GearHidden <> nil then FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH,true); + if HH^.GearHidden <> nil then + FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH,true); + if HH^.GearHidden <> nil then begin Gear^.X:= HH^.GearHidden^.X; Gear^.Y:= HH^.GearHidden^.Y; - //HH^.Gear:=HH^.GearHidden; - //HH^.GearHidden:= nil; - //HH^.Gear^.State:= HH^.Gear^.State or gstInvisible; + end; + Gear^.Timer:= 0; + + if (HH^.GearHidden <> nil) and (cnt = 0) then // do an emergency jump back in this case. the team needs you! + begin + AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplosion); + Gear^.Pos:= 2; + Gear^.Power:= 255; + end + else begin + Gear^.SoundChannel := LoopSound(sndTardis); + Gear^.Pos:= 1; + Gear^.Power:= 0; end end else dec(Gear^.Timer); @@ -5245,8 +4986,8 @@ begin if HH^.Gear <> nil then begin - HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack; - HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking; + HH^.Gear^.Message := HH^.Gear^.Message and (not gmAttack); + HH^.Gear^.State:= HH^.Gear^.State and (not gstAttacking); end; PlaySound(sndDenied); DeleteGear(gear); @@ -5255,16 +4996,16 @@ cnt:= 0; for j:= 0 to Pred(HH^.Team^.Clan^.TeamsNumber) do for i:= 0 to Pred(HH^.Team^.Clan^.Teams[j]^.HedgehogsNumber) do - if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) and - ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) and - (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > - HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then inc(cnt); + if (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear <> nil) + and ((HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.State and gstDrowning) = 0) + and (HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Health > HH^.Team^.Clan^.Teams[j]^.Hedgehogs[i].Gear^.Damage) then + inc(cnt); if cnt < 2 then begin if HH^.Gear <> nil then begin - HH^.Gear^.Message := HH^.Gear^.Message and not gmAttack; - HH^.Gear^.State:= HH^.Gear^.State and not gstAttacking; + HH^.Gear^.Message := HH^.Gear^.Message and (not gmAttack); + HH^.Gear^.State:= HH^.Gear^.State and (not gstAttacking); end; PlaySound(sndDenied); DeleteGear(gear); @@ -5276,3 +5017,422 @@ //////////////////////////////////////////////////////////////////////////////// +(* +WIP. The ice gun will have the following effects. It has been proposed by sheepluva that it take the appearance of a large freezer +spewing ice cubes. The cubes will be visual gears only. The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect. +For now we assume a "ray" like a deagle projected out from the gun. +All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks. This is a simplifying assumption for "gun was applying freezing effect to the same target". + * When fired at water a layer of ice textured land is added above the water. + * When fired at non-ice land (land and $FF00 and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed. + * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen. As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head. If the effect is interrupted before reaching the top, the freezing state is cleared. +A frozen hog will animate differently. To be decided, but possibly in a similar fashion to a grave when it comes to explosions. The hog might (possibly) not be damaged by explosions. This might make freezing potentially useful for friendlies in a bad position. It might be better to allow damage though. +A frozen hog stays frozen for a certain number of turns. Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again. +*) +procedure doStepIceGun(Gear: PGear); +var + HHGear: PGear; + ndX, ndY: hwFloat; + i, t, gX, gY: LongInt; + hogs: PGearArrayS; +begin + HHGear := Gear^.Hedgehog^.Gear; + if (Gear^.Health = 0) or (HHGear = nil) or (HHGear^.Damage <> 0) then + begin + DeleteGear(Gear); + AfterAttack; + exit + end + else + begin + t:= Gear^.Health div 10; + if (t <> Gear^.Damage) and ((GameTicks and $3F) = 0) then + begin + Gear^.Damage:= t; + FreeTexture(Gear^.Tex); + Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(t) + + '%', cWhiteColor, fntSmall) + end + end; + if GameTicks mod 10 = 0 then dec(Gear^.Health); + with Gear^ do + begin + HedgehogChAngle(HHGear); + ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4; + ndY:= -AngleCos(HHGear^.Angle) * _4; + if (ndX <> dX) or (ndY <> dY) or + ((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and + (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0))) then + begin + dX:= ndX; + dY:= ndY; + Pos:= 0; + Target.X:= NoPointX; + LastDamage:= nil; + X:= HHGear^.X; + Y:= HHGear^.Y; +(* unfreeze all semifrozen hogs - make this generic hog cleanup + iter := GearsList; + while iter <> nil do + begin + if (iter^.Kind = gtHedgehog) and + (iter^.Hedgehog^.Effects[heFrozen] < 0) then + iter^.Hedgehog^.Effects[heFrozen]:= 0; + iter:= iter^.NextGear + end *) + end + else + begin + X:= X + dX; + Y:= Y + dY; + gX:= hwRound(X); + gY:= hwRound(Y); + if Target.X = NoPointX then t:= hwRound(hwSqr(X-HHGear^.X)+hwSqr(Y-HHGear^.Y)); + if Target.X <> NoPointX then + begin + if (abs(gX-Target.X) < 2) and (abs(gY-Target.Y) < 2) then + begin + X:= HHGear^.X; + Y:= HHGear^.Y + end; +// freeze nearby hogs + if GameTicks mod 10 = 0 then dec(Gear^.Health); + hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius); + if hogs.size > 0 then + for i:= 0 to hogs.size - 1 do + if hogs.ar^[i] <> HHGear then + begin + //if Gear^.Hedgehog^.Effects[heFrozen]:= 0; + end; + inc(Pos) + end + else if (t > 400) and ((gY > cWaterLine) or + (((gX and LAND_WIDTH_MASK = 0) and (gY and LAND_HEIGHT_MASK = 0)) + and (Land[gY, gX] <> 0))) then + begin + Target.X:= gX; + Target.Y:= gY; + X:= HHGear^.X; + Y:= HHGear^.Y + end; + if (gX > max(LAND_WIDTH,4096)*2) or + (gX < -max(LAND_WIDTH,4096)) or + (gY < -max(LAND_HEIGHT,4096)) or + (gY > max(LAND_HEIGHT,4096)+512) then + begin + X:= HHGear^.X; + Y:= HHGear^.Y + end + end + end; +end; + +procedure doStepAddAmmo(Gear: PGear); +var a: TAmmoType; + gi: PGear; +begin +if Gear^.Timer > 0 then dec(Gear^.Timer) +else + begin + if Gear^.Pos = posCaseUtility then + a:= GetUtility(Gear^.Hedgehog) + else + a:= GetAmmo(Gear^.Hedgehog); + CheckSum:= CheckSum xor GameTicks; + gi := GearsList; + while gi <> nil do + begin + with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; + AddRandomness(CheckSum); + gi := gi^.NextGear + end; + AddPickup(Gear^.Hedgehog^, a, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); + DeleteGear(Gear) + end; +end; + +procedure doStepGenericFaller(Gear: PGear); +begin +if Gear^.Timer < $FFFFFFFF then + if Gear^.Timer > 0 then + dec(Gear^.Timer) + else + begin + DeleteGear(Gear); + exit + end; + +doStepFallingGear(Gear); +end; + +procedure doStepCreeper(Gear: PGear); +var hogs: PGearArrayS; + HHGear: PGear; + tdX: hwFloat; + dir: LongInt; +begin +doStepFallingGear(Gear); +if Gear^.Timer > 0 then dec(Gear^.Timer); +// creeper sleep phase +if (Gear^.Hedgehog = nil) and (Gear^.Timer > 0) then exit; + +if Gear^.Hedgehog <> nil then HHGear:= Gear^.Hedgehog^.Gear +else HHGear:= nil; + +// creeper boom phase +if (Gear^.State and gstTmpFlag <> 0) then + begin + if (Gear^.Timer = 0) then + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 300, CurrentHedgehog, EXPLAutoSound); + DeleteGear(Gear) + end; + // ssssss he essssscaped + if (Gear^.Timer > 250) and ((HHGear = nil) or + (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) > 180) and + (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > _180))) then + begin + Gear^.State:= Gear^.State and (not gstTmpFlag); + Gear^.Timer:= 0 + end; + exit + end; + +// Search out a new target, as target seek time has expired, target is dead, target is out of range, or we did not have a target +if (HHGear = nil) or (Gear^.Timer = 0) or + (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) > Gear^.Angle) and + (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > int2hwFloat(Gear^.Angle))) + then + begin + hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Angle); + if hogs.size > 1 then + Gear^.Hedgehog:= hogs.ar^[GetRandom(hogs.size)]^.Hedgehog + else if hogs.size = 1 then Gear^.Hedgehog:= hogs.ar^[0]^.Hedgehog + else Gear^.Hedgehog:= nil; + if Gear^.Hedgehog <> nil then Gear^.Timer:= 5000; + exit + end; + +// we have a target. move the creeper. +if HHGear <> nil then + begin + // GOTCHA + if ((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) < 50) and + (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) < _50) then + begin + // hisssssssssss + Gear^.State:= Gear^.State or gstTmpFlag; + Gear^.Timer:= 1500; + exit + end; + if (Gear^.State and gstMoving <> 0) then + begin + Gear^.dY:= _0; + Gear^.dX:= _0; + end + else if (GameTicks and $FF = 0) then + begin + tdX:= HHGear^.X-Gear^.X; + dir:= hwSign(tdX); + if not TestCollisionX(Gear, dir) then + Gear^.X:= Gear^.X + signAs(_1,tdX); + if TestCollisionXwithXYShift(Gear, signAs(_10,tdX), 0, dir) then + begin + Gear^.dX:= SignAs(_0_15, tdX); + Gear^.dY:= -_0_3; + Gear^.State:= Gear^.State or gstMoving + end + end; + end; +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepKnife(Gear: PGear); +var ox, oy: LongInt; + la: hwFloat; +begin + // Gear is shrunk so it can actually escape the hog without carving into the terrain + if (Gear^.Radius = 6) and (Gear^.CollisionMask = $FFFF) then Gear^.Radius:= 16; + if Gear^.Timer > 0 then dec(Gear^.Timer); + if (Gear^.State and gstMoving <> 0) and (Gear^.State and gstCollision = 0) then + begin + DeleteCI(Gear); + // used for damage and impact calc. needs balancing I think + Gear^.Health:= hwRound(hwSqr((hwAbs(Gear^.dY)+hwAbs(Gear^.dX))*_4)); + doStepFallingGear(Gear); + AllInactive := false; + CalcRotationDirAngle(Gear) + end + else if (Gear^.CollisionIndex = -1) and (Gear^.Timer = 0) then + begin + ox:= 0; oy:= 0; + if TestCollisionYwithGear(Gear, -1) <> 0 then oy:= -1; + if TestCollisionXwithGear(Gear, 1) then ox:= 1; + if TestCollisionXwithGear(Gear, -1) then ox:= -1; + if TestCollisionYwithGear(Gear, 1) <> 0 then oy:= 1; + if Gear^.Health > 0 then + PlaySound(sndRopeAttach); +(* + la:= _10000; + if (ox <> 0) or (oy <> 0) then + la:= CalcSlopeNearGear(Gear, ox, oy); + if la = _10000 then + begin + // debug for when we couldn't get an angle + //AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeWhite); +*) + Gear^.DirAngle:= DxDy2Angle(Gear^.dX, Gear^.dY) + (random(30)-15); + if (Gear^.dX.isNegative and Gear^.dY.isNegative) or + ((not Gear^.dX.isNegative) and (not Gear^.dY.isNegative)) then Gear^.DirAngle:= Gear^.DirAngle-90; + // end + // else Gear^.DirAngle:= hwFloat2Float(la)*90; // sheepluva's comment claims 45deg = 0.5 - yet orientation doesn't seem consistent? + // AddFileLog('la: '+floattostr(la)+' DirAngle: '+inttostr(round(Gear^.DirAngle))); + Gear^.dX:= _0; + Gear^.dY:= _0; + Gear^.State:= Gear^.State and (not gstMoving) or gstCollision; + Gear^.Radius:= 20; + if Gear^.Health > 0 then AmmoShove(Gear, Gear^.Health, 0); + Gear^.Radius:= 16; + Gear^.Health:= 0; + Gear^.Timer:= 500; + AddGearCI(Gear) + end + else if GameTicks and $3F = 0 then + begin + if (TestCollisionYwithGear(Gear, -1) = 0) + and (not TestCollisionXwithGear(Gear, 1)) + and (not TestCollisionXwithGear(Gear, -1)) + and (TestCollisionYwithGear(Gear, 1) = 0) then Gear^.State:= Gear^.State and (not gstCollision) or gstMoving; + end +end; +(* + This didn't end up getting used, but, who knows, might be reasonable for javellin or something +// Make the knife initial angle based on the hog attack angle, or is that too hard? +procedure doStepKnife(Gear: PGear); +var t, + gx, gy, ga, // gear x,y,angle + lx, ly, la, // land x,y,angle + ox, oy, // x,y offset + w, h, // wXh of clip area + tx, ty // tip position in sprite + : LongInt; + surf: PSDL_Surface; + s: hwFloat; + +begin + Gear^.dY := Gear^.dY + cGravity; + if (GameFlags and gfMoreWind) <> 0 then + Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density; + Gear^.X := Gear^.X + Gear^.dX; + Gear^.Y := Gear^.Y + Gear^.dY; + CheckGearDrowning(Gear); + gx:= hwRound(Gear^.X); + gy:= hwRound(Gear^.Y); + if Gear^.State and gstDrowning <> 0 then exit; + with Gear^ do + begin + if CheckLandValue(gx, gy, $FF00) then + begin + t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); + + if t < 0 then inc(t, 4096) + else if 4095 < t then dec(t, 4096); + Angle:= t; + + DirAngle:= Angle / 4096 * 360 + end + else + begin +//This is the set of postions for the knife. +//Using FlipSurface and copyToXY the knife can be written to the LandPixels at 32 positions, and an appropriate line drawn in Land. + t:= Angle mod 1024; + case t div 128 of + 0: begin + ox:= 2; oy:= 5; + w := 25; h:= 5; + tx:= 0; ty:= 2 + end; + 1: begin + ox:= 2; oy:= 15; + w:= 24; h:= 8; + tx:= 0; ty:= 7 + end; + 2: begin + ox:= 2; oy:= 27; + w:= 23; h:= 12; + tx:= -12; ty:= -5 + end; + 3: begin + ox:= 2; oy:= 43; + w:= 21; h:= 15; + tx:= 0; ty:= 14 + end; + 4: begin + ox:= 29; oy:= 8; + w:= 19; h:= 19; + tx:= 0; ty:= 17 + end; + 5: begin + ox:= 29; oy:= 32; + w:= 15; h:= 21; + tx:= 0; ty:= 20 + end; + 6: begin + ox:= 51; oy:= 3; + w:= 11; h:= 23; + tx:= 0; ty:= 22 + end; + 7: begin + ox:= 51; oy:= 34; + w:= 7; h:= 24; + tx:= 0; ty:= 23 + end + end; + + surf:= SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, RMask, GMask, BMask, AMask); + copyToXYFromRect(SpritesData[sprKnife].Surface, surf, ox, oy, w, h, 0, 0); + // try to make the knife hit point first + lx := 0; + ly := 0; + if CalcSlopeTangent(Gear, gx, gy, lx, ly, 255) then + begin + la:= vector2Angle(int2hwFloat(lx), int2hwFloat(ly)); + ga:= vector2Angle(dX, dY); + AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle)); + // change to 0 to 4096 forced by LongWord in Gear + if la < 0 then la:= 4096+la; + if ga < 0 then ga:= 4096+ga; + if ((Angle > ga) and (Angle < la)) or ((Angle < ga) and (Angle > la)) then + begin + if Angle >= 2048 then dec(Angle, 2048) + else if Angle < 2048 then inc(Angle, 2048) + end; + AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle)) + end; + case Angle div 1024 of + 0: begin + flipSurface(surf, true); + flipSurface(surf, true); + BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy-(h-ty), w, surf) + end; + 1: begin + flipSurface(surf, false); + BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy-ty, w, surf) + end; + 2: begin // knife was actually drawn facing this way... + BlitImageAndGenerateCollisionInfo(gx-tx, gy-ty, w, surf) + end; + 3: begin + flipSurface(surf, true); + BlitImageAndGenerateCollisionInfo(gx-tx, gy-(h-ty), w, surf) + end + end; + SDL_FreeSurface(surf); + // this needs to calculate actual width/height + land clipping since update texture doesn't. + // i.e. this will crash if you fire near sides of map, but until I get the blit right, not going to put real values + UpdateLandTexture(hwRound(X)-32, 64, hwRound(Y)-32, 64, true); + DeleteGear(Gear); + exit + end + end; +end; +*) diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1155 +0,0 @@ -(* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - *) - -//////////////////////////////////////////////////////////////////////////////// - -procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); -begin -if (Source = dsFall) or (Source = dsExplosion) then - case random(3) of - 0: PlaySound(sndOoff1, Hedgehog^.Team^.voicepack); - 1: PlaySound(sndOoff2, Hedgehog^.Team^.voicepack); - 2: PlaySound(sndOoff3, Hedgehog^.Team^.voicepack); - end -else if (Source = dsPoison) then - case random(2) of - 0: PlaySound(sndPoisonCough, Hedgehog^.Team^.voicepack); - 1: PlaySound(sndPoisonMoan, Hedgehog^.Team^.voicepack); - end -else - case random(4) of - 0: PlaySound(sndOw1, Hedgehog^.Team^.voicepack); - 1: PlaySound(sndOw2, Hedgehog^.Team^.voicepack); - 2: PlaySound(sndOw3, Hedgehog^.Team^.voicepack); - 3: PlaySound(sndOw4, Hedgehog^.Team^.voicepack); - end -end; - -// Shouldn't more of this ammo switching stuff be moved to uAmmos ? -function ChangeAmmo(HHGear: PGear): boolean; -var slot, i: Longword; - ammoidx: LongInt; -begin -ChangeAmmo:= false; -slot:= HHGear^.MsgParam; - -with HHGear^.Hedgehog^ do - begin - HHGear^.Message:= HHGear^.Message and not gmSlot; - ammoidx:= 0; - if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0) or - ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or - ((HHGear^.State and gstHHDriven) = 0) then exit; - ChangeAmmo:= true; - - while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do inc(ammoidx); - - if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then OnUsedAmmo(HHGear^.Hedgehog^); - - MultiShootAttacks:= 0; - HHGear^.Message:= HHGear^.Message and not (gmLJump or gmHJump); - - if Ammoz[CurAmmoType].Slot = slot then - begin - i:= 0; - repeat - inc(ammoidx); - if (ammoidx > cMaxSlotAmmoIndex) then - begin - inc(i); - CurAmmoType:= amNothing; - ammoidx:= -1; - //TryDo(i < 2, 'Engine bug: no ammo in current slot', true) - end; - until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) - end - else - begin - i:= 0; - // check whether there is ammo in slot - while (i <= cMaxSlotAmmoIndex) - and ((Ammo^[slot, i].Count = 0) - or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i); - - if i <= cMaxSlotAmmoIndex then ammoidx:= i - else ammoidx:= -1 - end; - if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; - end -end; - -procedure HHSetWeapon(HHGear: PGear); -var t: LongInt; - weap: TAmmoType; - Hedgehog: PHedgehog; - s: boolean; -begin -s:= false; - -weap:= TAmmoType(HHGear^.MsgParam); -Hedgehog:= HHGear^.Hedgehog; - -if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then exit; // weapon is not activated yet - -HHGear^.MsgParam:= Ammoz[weap].Slot; - -t:= cMaxSlotAmmoIndex; - -HHGear^.Message:= HHGear^.Message and not gmWeapon; - -with Hedgehog^ do - while (CurAmmoType <> weap) and (t >= 0) do - begin - s:= ChangeAmmo(HHGear); - dec(t) - end; - -if s then ApplyAmmoChanges(HHGear^.Hedgehog^) -end; - -procedure HHSetTimer(Gear: PGear); -var CurWeapon: PAmmo; - color: LongWord; -begin -Gear^.Message:= Gear^.Message and not gmTimer; -CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^); -with Gear^.Hedgehog^ do - if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then - begin - color:= Gear^.Hedgehog^.Team^.Clan^.Color; - case Gear^.MsgParam of - 1: begin - AddCaption(format(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate); - CurWeapon^.Bounciness:= 350; - end; - 2: begin - AddCaption(format(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate); - CurWeapon^.Bounciness:= 700; - end; - 3: begin - AddCaption(format(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate); - CurWeapon^.Bounciness:= 1000; - end; - 4: begin - AddCaption(format(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate); - CurWeapon^.Bounciness:= 2000; - end; - 5: begin - AddCaption(format(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate); - CurWeapon^.Bounciness:= 4000; - end - end - end - else if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then - begin - CurWeapon^.Timer:= 1000 * Gear^.MsgParam; - with CurrentTeam^ do - ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); - end; -end; - - -procedure Attack(Gear: PGear); -var xx, yy, newDx, newDy, lx, ly: hwFloat; - speech: PVisualGear; - newGear: PGear; - CurWeapon: PAmmo; - altUse: boolean; - elastic: hwFloat; -begin -newGear:= nil; -bShowFinger:= false; -CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^); -with Gear^, - Gear^.Hedgehog^ do - begin - if ((State and gstHHDriven) <> 0)and - ((State and (gstAttacked or gstHHChooseTarget)) = 0) and - (((State and gstMoving) = 0) or - (Power > 0) or - (CurAmmoType = amTeleport) or - // Allow attacks while moving on ammo with AltAttack - ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or - ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) and - ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then - begin - State:= State or gstAttacking; - if Power = cMaxPower then Message:= Message and not gmAttack - else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then Message:= Message and not gmAttack - else begin - if Power = 0 then - begin - AttackBar:= CurrentTeam^.AttackBar; - PlaySound(sndThrowPowerUp) - end; - inc(Power) - end; - if ((Message and gmAttack) <> 0) then exit; - - if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then - begin - StopSound(sndThrowPowerUp); - PlaySound(sndThrowRelease); - end; - - xx:= SignAs(AngleSin(Angle), dX); - yy:= -AngleCos(Angle); - - lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle))); - ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle))); - - if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then xx:= - xx; - if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then - AddVoice(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack); - -// Initiating alt attack - if (CurAmmoGear <> nil) and - ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and - ((Gear^.Message and gmLJump) <> 0) and - ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then - begin - newDx:= dX / _2; - newDy:= dY / _2; - altUse:= true; - end - else - begin - newDx:= xx*Power/cPowerDivisor; - newDy:= yy*Power/cPowerDivisor; - altUse:= false - end; - - case CurAmmoType of - amGrenade: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGrenade, 0, newDx, newDy, CurWeapon^.Timer); - amMolotov: newGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov, 0, newDx, newDy, 0); - amClusterBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, newDx, newDy, CurWeapon^.Timer); - amGasBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, newDx, newDy, CurWeapon^.Timer); - amBazooka: newGear:= AddGear(hwRound(lx), hwRound(ly), gtShell, 0, newDx, newDy, 0); - amSnowball: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball, 0, newDx, newDy, 0); - amBee: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBee, 0, newDx, newDy, 0); - amShotgun: begin - PlaySound(sndShotgunReload); - newGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0); - end; - amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0); - amSkip: ParseCommand('/skip', true); - amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0); - amMine: if altUse then - newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, newDx, newDy, 3000) - else - newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000); - amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); - amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); - amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); - amPortalGun: begin - newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, - // set selected color - CurWeapon^.Pos); - end; - amSniperRifle: begin - PlaySound(sndSniperReload); - newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0); - end; - amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); - amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0); - amWhip: begin - newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); - PlaySound(sndWhipCrack) - end; - amHammer: begin - newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0); - PlaySound(sndWhack) - end; - amBaseballBat: begin - newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); - PlaySound(sndBaseballBat) // TODO: Only play if something is hit? - end; - amParachute: begin - newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0); - PlaySound(sndParachute) - end; - // we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear. - amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0); - amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0); - amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer); - amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0); - amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); - amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0); - amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0); - amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0); - amMortar: begin - playSound(sndMortar); - newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); - end; - amRCPlane: begin - newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); - newGear^.SoundChannel:= LoopSound(sndRCPlane, nil) - end; - amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); - amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0); - amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0); - amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer); - amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0); - amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0); - amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); - amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0); - amBirdy: begin - PlaySound(sndWhistle); - newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0); - end; - amLowGravity: begin - PlaySound(sndLowGravity); - cGravity:= cMaxWindSpeed; - cGravityf:= 0.00025 - end; - amExtraDamage:begin - PlaySound(sndHellishImpact4); - cDamageModifier:= _1_5 - end; - amInvulnerable: Invulnerable:= true; - amExtraTime: begin - PlaySound(sndSwitchHog); - TurnTimeLeft:= TurnTimeLeft + 30000 - end; - amLaserSight: cLaserSighting:= true; - amVampiric: begin - PlaySound(sndOw1, Team^.voicepack); - cVampiric:= true; - end; - amPiano: begin - // Tuck the hedgehog away until the piano attack is completed - Unplaced:= true; - X:= _0; - Y:= _0; - newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0); - PauseMusic - end; - amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); - amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); - amResurrector: begin - newGear:= AddGear(hwRound(lx), hwRound(ly), - gtResurrector, 0, _0, _0, 0); - newGear^.SoundChannel := LoopSound(sndResurrector); - end; - //amMelonStrike: AddGear(CurWeapon^.Pos, 0, gtAirAttack, 4, _0, _0, 0); - amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); - amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000); - end; - case CurAmmoType of - amGrenade, amMolotov, - amClusterBomb, amGasBomb, - amBazooka, amSnowball, - amBee, amSMine, - amMortar, amWatermelon, - amHellishBomb, amDrill: FollowGear:= newGear; - - amShotgun, amPickHammer, - amRope, amDEagle, - amSineGun, amSniperRifle, - amFirePunch, amWhip, - amHammer, amBaseballBat, - amParachute, amBlowTorch, - amGirder, amTeleport, - amSwitch, amRCPlane, - amKamikaze, amCake, - amSeduction, amBallgun, - amJetpack, amBirdy, - amFlamethrower, amLandGun, - amResurrector, amStructure, - amTardis, amPiano: CurAmmoGear:= newGear; - end; - if (CurAmmoType = amMine) or (CurAmmoType = amSMine) and (GameFlags and gfInfAttack <> 0) then newGear^.FlightTime:= GameTicks + 1000; - if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then - begin - newGear^.Target.X:= TargetPoint.X; - newGear^.Target.Y:= TargetPoint.Y - end; - - // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement - if altUse then FollowGear:= nil; - - if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then - begin - elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; - - if elastic < _1 then newGear^.Elasticity:= newGear^.Elasticity * elastic - else if elastic > _1 then newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); -(* Experimented with friction modifier. Didn't seem helpful - fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; - if fric < _1 then newGear^.Friction:= newGear^.Friction * fric - else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) - end; - - - uStats.AmmoUsed(CurAmmoType); - - if not (SpeechText = '') then - begin - speech:= AddVisualGear(0, 0, vgtSpeechBubble); - if speech <> nil then - begin - speech^.Text:= SpeechText; - speech^.Hedgehog:= Gear^.Hedgehog; - speech^.FrameTicks:= SpeechType; - end; - SpeechText:= '' - end; - - Power:= 0; - if (CurAmmoGear <> nil) - and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then - begin - Message:= Message or gmAttack; - CurAmmoGear^.Message:= Message - end else begin - if not CurrentTeam^.ExtDriven and - ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then SendIPC('a'); - AfterAttack; - end - end else Message:= Message and not gmAttack; - end; - TargetPoint.X := NoPointX; - ScriptCall('onHogAttack'); -end; - -procedure AfterAttack; -var s: shortstring; - a: TAmmoType; -begin -with CurrentHedgehog^.Gear^, - CurrentHedgehog^ do - begin - a:= CurAmmoType; - State:= State and not gstAttacking; - if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then - begin - Inc(MultiShootAttacks); - - if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then - begin - s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); - AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); - end; - - if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) or - ((GameFlags and gfMultiWeapon) <> 0) then - begin - isInMultiShoot:= true - end - else - begin - OnUsedAmmo(CurrentHedgehog^); - if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then - begin - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; - TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; - end; - if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then State:= State or gstAttacked; - if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then ApplyAmmoChanges(CurrentHedgehog^) - end; - end - else - begin - OnUsedAmmo(CurrentHedgehog^); - ApplyAmmoChanges(CurrentHedgehog^); - end; - AttackBar:= 0 - end -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure doStepHedgehogDead(Gear: PGear); -const frametime = 200; - timertime = frametime * 6; -begin -if Gear^.Hedgehog^.Unplaced then exit; -if Gear^.Timer > 1 then - begin - AllInactive:= false; - dec(Gear^.Timer); - if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) - end -else if Gear^.Timer = 1 then - begin - Gear^.State:= Gear^.State or gstNoDamage; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; - DeleteGear(Gear); - SetAllToActive - end -else // Gear^.Timer = 0 - begin - AllInactive:= false; - Gear^.Z:= cCurrHHZ; - RemoveGearFromList(Gear); - InsertGearToList(Gear); - PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); - Gear^.Pos:= 0; - Gear^.Timer:= timertime - end -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure doStepHedgehogGone(Gear: PGear); -const frametime = 65; - timertime = frametime * 11; -begin -if Gear^.Hedgehog^.Unplaced then exit; -if Gear^.Timer > 1 then - begin - AllInactive:= false; - dec(Gear^.Timer); - if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) - end else -if Gear^.Timer = 1 then - begin - DeleteGear(Gear); - SetAllToActive - end else // Gear^.Timer = 0 - begin - AllInactive:= false; - Gear^.Z:= cCurrHHZ; - RemoveGearFromList(Gear); - InsertGearToList(Gear); - PlaySound(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); - PlaySound(sndWarp); - Gear^.Pos:= 0; - Gear^.Timer:= timertime - end -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure PickUp(HH, Gear: PGear); -var s: shortstring; - a: TAmmoType; - i: LongInt; - vga: PVisualGear; -begin -Gear^.Message:= gmDestroy; -PlaySound(sndShotgunReload); -if (Gear^.Pos and posCaseExplode) <> 0 then - if (Gear^.Pos and posCasePoison) <> 0 then - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) - else - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) -else if (Gear^.Pos and posCasePoison) <> 0 then - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) -else -case Gear^.Pos of - posCaseUtility, - posCaseAmmo: begin - if Gear^.AmmoType <> amNothing then a:= Gear^.AmmoType - else - begin - for i:= 0 to GameTicks and $7F do GetRandom(2); // Burn some random numbers - if Gear^.Pos = posCaseUtility then a:= GetUtility - else a:= GetAmmo - end; - AddAmmo(HH^.Hedgehog^, a); -// Possibly needs to check shared clan ammo game flag once added. -// On the other hand, no obvious reason that clan members shouldn't know what ammo another clan member picked up - if (not (HH^.Hedgehog^.Team^.ExtDriven - or (HH^.Hedgehog^.BotLevel > 0))) - or (HH^.Hedgehog^.Team^.Clan^.ClanIndex = LocalClan) - or (GameType = gmtDemo) then - begin - s:= trammo[Ammoz[a].NameId] + ' (+' + IntToStr(Ammoz[a].NumberInCase) + ')'; - AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); - - // show ammo icon - vga:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtAmmo); - if vga <> nil then - vga^.Frame:= Longword(a); - end; - - end; - posCaseHealth: begin - inc(HH^.Health, Gear^.Health); - HH^.Hedgehog^.Effects[hePoisoned] := false; - str(Gear^.Health, s); - s:= '+' + s; - AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); - RenderHealth(HH^.Hedgehog^); - RecountTeamHealth(HH^.Hedgehog^.Team); - - i:= 0; - while i < Gear^.Health do - begin - vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); - if vga <> nil then - with vga^ do - begin - Tint:= $00FF00FF; - State:= ord(sprHealth) - end; - inc(i, 5); - end; - end; - end -end; - -const StepTicks: LongWord = 0; - -procedure HedgehogStep(Gear: PGear); -var PrevdX: LongInt; - CurWeapon: PAmmo; -begin -CurWeapon:= GetAmmoEntry(Gear^.Hedgehog^); -if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then - begin - if isCursorVisible then - with Gear^.Hedgehog^ do - with CurWeapon^ do - begin - if (Gear^.Message and gmLeft ) <> 0 then - Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount - else - if (Gear^.Message and gmRight ) <> 0 then - Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount - else exit; - StepTicks:= 200; - exit - end; - - if ((Gear^.Message and gmAnimate) <> 0) then - begin - Gear^.Message:= 0; - Gear^.State:= Gear^.State or gstAnimation; - Gear^.Tag:= Gear^.MsgParam; - Gear^.Timer:= 0; - Gear^.Pos:= 0 - end; - - if ((Gear^.Message and gmLJump ) <> 0) then - begin - Gear^.Message:= Gear^.Message and not gmLJump; - DeleteCI(Gear); - if TestCollisionYwithGear(Gear, -1) = 0 then - if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else - if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then - begin - Gear^.dY:= -_0_15; - if not cArtillery then Gear^.dX:= SignAs(_0_15, Gear^.dX); - Gear^.State:= Gear^.State or gstMoving or gstHHJumping; - PlaySound(sndJump1, Gear^.Hedgehog^.Team^.voicepack); - exit - end; - end; - - if ((Gear^.Message and gmHJump ) <> 0) then - begin - DeleteCI(Gear); - Gear^.Message:= Gear^.Message and not gmHJump; - - Gear^.dY:= -_0_2; - SetLittle(Gear^.dX); - Gear^.State:= Gear^.State or gstMoving or gstHHJumping; - PlaySound(sndJump3, Gear^.Hedgehog^.Team^.voicepack); - exit - end; - - PrevdX:= hwSign(Gear^.dX); - if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else - if (Gear^.Message and gmRight )<>0 then Gear^.dX:= cLittle else exit; - - if (Gear^.Message and (gmLeft or gmRight)) <> 0 then - begin - StepSoundTimer:= cHHStepTicks; - end; - - StepTicks:= cHHStepTicks; - if PrevdX <> hwSign(Gear^.dX) then - begin - FollowGear:= Gear; - exit - end; - DeleteCI(Gear); // must be after exit!! (see previous line) - - Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7; - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - end; - - if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) and (not TestCollisionXwithGear(Gear, hwSign(Gear^.dX))) then - Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); - - SetAllHHToActive; - - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y - _6; - Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstMoving; - exit - end; - end - end - end - end - end - end; - AddGearCI(Gear) - end -end; - -procedure HedgehogChAngle(HHGear: PGear); -var da: LongWord; -begin -with HHGear^.Hedgehog^ do - if ((CurAmmoType = amRope) and - ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) or - ((CurAmmoType = amPortalGun) and - ((HHGear^.State and gstMoving) <> 0)) then da:= 2 - else da:= 1; - -if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then - if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then dec(HHGear^.Angle, da) - else - if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then inc(HHGear^.Angle, da) -end; - -procedure doStepHedgehog(Gear: PGear); forward; -//////////////////////////////////////////////////////////////////////////////// -procedure doStepHedgehogMoving(Gear: PGear); -var isFalling, isUnderwater: boolean; - land: Word; -begin -land:= 0; -isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; -if Gear^.dX.QWordValue > 8160437862 then Gear^.dX.QWordValue:= 8160437862; -if Gear^.dY.QWordValue > 8160437862 then Gear^.dY.QWordValue:= 8160437862; - -if Gear^.Hedgehog^.Unplaced then - begin - Gear^.dY:= _0; - Gear^.dX:= _0; - Gear^.State:= Gear^.State and not gstMoving; - while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; - exit - end; -isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1); -if isFalling then - begin - if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstMoving; - if (CurrentHedgehog^.Gear = Gear) - and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then - begin - FollowGear:= Gear; - end; - if isUnderwater then Gear^.dY:= Gear^.dY + cGravity / _2 - else - begin - Gear^.dY:= Gear^.dY + cGravity; -// this set of circumstances could be less complex if jumping was more clearly identified - if ((GameFlags and gfMoreWind) <> 0) and - (((Gear^.Damage <> 0) or - ((CurAmmoGear <> nil) and - ((CurAmmoGear^.AmmoType = amJetpack) or - (CurAmmoGear^.AmmoType = amBirdy))) or - ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) - then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density - end - end -else - begin - land:= TestCollisionYwithGear(Gear, 1); - if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) - and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX); - - if not Gear^.dY.isNegative then - begin - CheckHHDamage(Gear); - - if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) and - (Gear^.dX.QWordValue < _0_02.QWordValue) then Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump - - Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); - Gear^.dY:= _0; - end else Gear^.dY:= Gear^.dY + cGravity; - - if ((Gear^.State and gstMoving) <> 0) then - begin - if land and lfIce <> 0 then - begin - Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) - end - else Gear^.dX:= Gear^.dX * Gear^.Friction; - end - end; - -if (Gear^.State <> 0) then DeleteCI(Gear); - -if isUnderwater then - begin - Gear^.dY:= Gear^.dY * _0_999; - Gear^.dX:= Gear^.dX * _0_999; - end; - -if (Gear^.State and gstMoving) <> 0 then - if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then - if not isFalling then - if hwAbs(Gear^.dX) > _0_01 then - if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else - if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 end else - if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_9 ; Gear^.Y:= Gear^.Y - _3 end else - if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - _4 end else - if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - _5 end else - if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX - else begin - Gear^.State:= Gear^.State and not gstMoving; - while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; - SetLittle(Gear^.dX) - end - else begin - Gear^.State:= Gear^.State and not gstMoving; - while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; - SetLittle(Gear^.dX) - end - else if (hwAbs(Gear^.dX) > cLittle) - and ((Gear^.State and gstHHJumping) = 0) - then Gear^.dX:= -Gear^.Elasticity * Gear^.dX - else SetLittle(Gear^.dX); - -if (not isFalling) and - (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then - begin - Gear^.State:= Gear^.State and not gstWinner; - Gear^.State:= Gear^.State and not gstMoving; - while TestCollisionYWithGear(Gear,1) = 0 do Gear^.Y:= Gear^.Y+_1; - SetLittle(Gear^.dX); - Gear^.dY:= _0 - end else Gear^.State:= Gear^.State or gstMoving; - -if (Gear^.State and gstMoving) <> 0 then - begin - Gear^.State:= Gear^.State and not gstAnimation; -// ARTILLERY but not being moved by explosions - Gear^.X:= Gear^.X + Gear^.dX; - Gear^.Y:= Gear^.Y + Gear^.dY; - if (not Gear^.dY.isNegative) and - (not TestCollisionYKick(Gear, 1)) and - TestCollisionYwithXYShift(Gear, 0, 1, 1) then - begin - CheckHHDamage(Gear); - Gear^.dY:= _0; - Gear^.Y:= Gear^.Y + _1 - end; - CheckGearDrowning(Gear); - // hide target cursor if current hog is drowning - if (Gear^.State and gstDrowning) <> 0 then - if (CurrentHedgehog^.Gear = Gear) then - isCursorVisible:= false - end; - -if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then - begin - inc(Gear^.FlightTime); - if Gear^.FlightTime = 3000 then - begin - AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); - PlaySound(sndHomerun) - end; - end -else - begin - uStats.hedgehogFlight(Gear, Gear^.FlightTime); - Gear^.FlightTime:= 0; - end; - -end; - -procedure doStepHedgehogDriven(HHGear: PGear); -var t: PGear; - wasJumping: boolean; - Hedgehog: PHedgehog; -begin -Hedgehog:= HHGear^.Hedgehog; -if isInMultiShoot then - HHGear^.Message:= 0; - -if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then - AllInactive:= true -else if not isInMultiShoot then AllInactive:= false; - -if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then - begin - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; - TurnTimeLeft:= 0; - isCursorVisible:= false; - HHGear^.State:= HHGear^.State and not (gstHHDriven or gstAnimation or gstAttacking); - AttackBar:= 0; - if HHGear^.Damage > 0 then - HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); - exit - end; - -if (HHGear^.State and gstAnimation) <> 0 then - begin - HHGear^.Message:= 0; - if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then PlaySound(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); - inc(HHGear^.Timer); - if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then - begin - HHGear^.Timer:= 0; - inc(HHGear^.Pos); - if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then - HHGear^.State:= HHGear^.State and not gstAnimation - end; - exit - end; - -if ((HHGear^.State and gstMoving) <> 0) - or (StepTicks = cHHStepTicks) - or (CurAmmoGear <> nil) then // we are moving - begin - with Hedgehog^ do - if (CurAmmoGear = nil) - and (HHGear^.dY > _0_39) - and (CurAmmoType = amParachute) then HHGear^.Message:= HHGear^.Message or gmAttack; - // check for case with ammo - t:= CheckGearNear(HHGear, gtCase, 36, 36); - if t <> nil then - PickUp(HHGear, t) - end; - -if (CurAmmoGear = nil) then - if (((HHGear^.Message and gmAttack) <> 0) - or ((HHGear^.State and gstAttacking) <> 0)) then - Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs - else -else - with Hedgehog^ do - if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) - and ((HHGear^.Message and gmLJump) <> 0) - and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then - begin - Attack(HHGear); - HHGear^.Message:= HHGear^.Message and not gmLJump - end; - -if (CurAmmoGear = nil) - or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) - or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then - begin - if ((HHGear^.Message and gmSlot) <> 0) then - if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); - - if ((HHGear^.Message and gmWeapon) <> 0) then HHSetWeapon(HHGear); - - if ((HHGear^.Message and gmTimer) <> 0) then HHSetTimer(HHGear); - end; - -if CurAmmoGear <> nil then - begin - CurAmmoGear^.Message:= HHGear^.Message; - exit - end; - -if not isInMultiShoot then - HedgehogChAngle(HHGear); - -if (HHGear^.State and gstMoving) <> 0 then - begin - wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); - - if ((HHGear^.Message and gmHJump) <> 0) and - wasJumping and - ((HHGear^.State and gstHHHJump) = 0) then - if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then - begin - HHGear^.State:= HHGear^.State or gstHHHJump; - HHGear^.dY:= -_0_25; - if not cArtillery then HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); - PlaySound(sndJump2, Hedgehog^.Team^.voicepack) - end; - - HHGear^.Message:= HHGear^.Message and not (gmLJump or gmHJump); - - if (not cArtillery) and wasJumping and - TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); - - if Hedgehog^.Gear <> nil then doStepHedgehogMoving(HHGear); - - if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then - begin - AddGearCI(HHGear); - if wasJumping then - StepTicks:= 410 - else - StepTicks:= 95 - end; - exit - end; - - if not isInMultiShoot and (Hedgehog^.Gear <> nil) then - begin - if StepTicks > 0 then dec(StepTicks); - if (StepTicks = 0) then HedgehogStep(HHGear) - end -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure doStepHedgehogFree(Gear: PGear); -var prevState: Longword; -begin -prevState:= Gear^.State; - -doStepHedgehogMoving(Gear); - -if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then - begin - if Gear^.Damage > 0 then CalcRotationDirAngle(Gear); - AllInactive:= false; - exit - end; - -if (Gear^.Health = 0) then - begin - if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then - begin - Gear^.Timer:= 0; - FollowGear:= Gear; - PrvInactive:= false; - AllInactive:= false; - - if (Gear^.State and gstHHGone) = 0 then - begin - Gear^.Hedgehog^.Effects[hePoisoned] := false; - if Gear^.Hedgehog^.Effects[heResurrectable] then begin - ResurrectHedgehog(Gear); - end else - begin - Gear^.State:= (Gear^.State or gstHHDeath) and not gstAnimation; - Gear^.doStep:= @doStepHedgehogDead; - // Death message - AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); - end; - end - else - begin - Gear^.State:= Gear^.State and not gstAnimation; - Gear^.doStep:= @doStepHedgehogGone; - - // Gone message - AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); - end - end; - exit - end; - -if ((Gear^.State and gstWait) = 0) and - (prevState <> Gear^.State) then - begin - Gear^.State:= Gear^.State or gstWait; - Gear^.Timer:= 150 - end else - begin - if Gear^.Timer = 0 then - begin - Gear^.State:= Gear^.State and not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable); - Gear^.Active:= false; - AddGearCI(Gear); - exit - end else dec(Gear^.Timer) - end; - -AllInactive:= false -end; - -//////////////////////////////////////////////////////////////////////////////// -procedure doStepHedgehog(Gear: PGear); -(* -var x,y,tx,ty: LongInt; - tdX, tdY, slope: hwFloat; - land: Word; *) -var slope: hwFloat; -begin -if (Gear^.Message and gmDestroy) <> 0 then - begin - DeleteGear(Gear); - exit - end; - -if (Gear^.State and gstHHDriven) = 0 then - doStepHedgehogFree(Gear) -else - begin - with Gear^.Hedgehog^ do - if Team^.hasGone then - TeamGoneEffect(Team^) - else - doStepHedgehogDriven(Gear) - end; -if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) and - (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) and - not Gear^.dY.isNegative and - (GameTicks mod (100*hwRound(cMaxWindSpeed/(cGravity/2))) = 0) and - (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then - begin - slope:= CalcSlopeBelowGear(Gear); - Gear^.dX:=Gear^.dX+slope*_0_07; - if slope.QWordValue <> 0 then Gear^.State:= Gear^.State or gstMoving; -(* - x:= hwRound(Gear^.X); - y:= hwRound(Gear^.Y); - AddVisualGear(x, y, vgtSmokeTrace); - AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); - AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); - AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); - AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); - AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); - AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); - AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); - AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); - AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); - AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) - end -end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/LuaPas.pas --- a/hedgewars/LuaPas.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/LuaPas.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,4 +1,5 @@ {$HINTS OFF} +{$INCLUDE "options.inc"} unit LuaPas; @@ -10,20 +11,20 @@ *) interface - +uses uConsts; {.$DEFINE LUA_GETHOOK} -{$INCLUDE "config.inc"} type - size_t = type Cardinal; - Psize_t = ^size_t; - PPointer = ^Pointer; +{$IFNDEF PAS2C} + size_t = Cardinal; +{$ENDIF} + Psize_t = ^size_t; + PPointer = ^Pointer; - lua_State = record end; - Plua_State = ^lua_State; + lua_State = record end; + Plua_State = ^lua_State; -const - LuaLibName = cLuaLibrary; +{$DEFINE LuaLibName:= cLuaLibrary} (*****************************************************************************) @@ -45,8 +46,8 @@ ** =================================================================== *) type - LUA_NUMBER_ = type Double; // ending underscore is needed in Pascal - LUA_INTEGER_ = type PtrInt; + LUA_NUMBER_ = Double; // ending underscore is needed in Pascal + LUA_INTEGER_ = PtrInt; (* @@ LUA_IDSIZE gives the maximum size for the description of the source @@ -54,13 +55,13 @@ ** CHANGE it if you want a different size. *) const - LUA_IDSIZE = 60; + LUA_IDSIZE = 60; (* @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. *) const - LUAL_BUFFERSIZE = 1024; + LUAL_BUFFERSIZE = 1024; (* @@ LUA_PROMPT is the default prompt used by stand-alone Lua. @@ -69,8 +70,8 @@ ** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.) *) const - LUA_PROMPT = '> '; - LUA_PROMPT2 = '>> '; + LUA_PROMPT = '> '; + LUA_PROMPT2 = '>> '; (* @@ lua_readline defines how to show a prompt and then read a line from @@ -80,8 +81,11 @@ ** CHANGE them if you want to improve this functionality (e.g., by using ** GNU readline and history facilities). *) -function lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean; +{function lua_readline(L : Plua_State; +var b : PChar; p : PChar): Boolean;} + procedure lua_saveline(L : Plua_State; idx : LongInt); + procedure lua_freeline(L : Plua_State; b : PChar); (* @@ -95,7 +99,7 @@ #define lua_stdin_is_tty() _isatty(_fileno(stdin)) *) const - lua_stdin_is_tty = TRUE; + lua_stdin_is_tty = TRUE; (*****************************************************************************) (* lua.h *) @@ -109,283 +113,329 @@ *) const - LUA_VERSION = 'Lua 5.1'; - LUA_VERSION_NUM = 501; - LUA_COPYRIGHT = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio'; - LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes'; + LUA_VERSION = 'Lua 5.1'; + LUA_VERSION_NUM = 501; + LUA_COPYRIGHT = 'Copyright (C) 1994-2006 Tecgraf, PUC-Rio'; + LUA_AUTHORS = 'R. Ierusalimschy, L. H. de Figueiredo & W. Celes'; - (* mark for precompiled code (`Lua') *) - LUA_SIGNATURE = #27'Lua'; + (* mark for precompiled code (`Lua') *) + //LUA_SIGNATURE = #27'Lua'; - (* option for multiple returns in `lua_pcall' and `lua_call' *) - LUA_MULTRET = -1; + (* option for multiple returns in `lua_pcall' and `lua_call' *) + LUA_MULTRET = -1; - (* - ** pseudo-indices - *) - LUA_REGISTRYINDEX = -10000; - LUA_ENVIRONINDEX = -10001; - LUA_GLOBALSINDEX = -10002; + (* + ** pseudo-indices + *) + LUA_REGISTRYINDEX = -10000; + LUA_ENVIRONINDEX = -10001; + LUA_GLOBALSINDEX = -10002; function lua_upvalueindex(idx : LongInt) : LongInt; // a marco const - (* thread status; 0 is OK *) - LUA_YIELD_ = 1; // Note: the ending underscore is needed in Pascal - LUA_ERRRUN = 2; - LUA_ERRSYNTAX = 3; - LUA_ERRMEM = 4; - LUA_ERRERR = 5; + (* thread status; 0 is OK *) + LUA_YIELD_ = 1; // Note: the ending underscore is needed in Pascal + LUA_ERRRUN = 2; + LUA_ERRSYNTAX = 3; + LUA_ERRMEM = 4; + LUA_ERRERR = 5; type - lua_CFunction = function(L : Plua_State) : LongInt; cdecl; + lua_CFunction = function(L : Plua_State) : LongInt; cdecl; - (* - ** functions that read/write blocks when loading/dumping Lua chunks - *) - lua_Reader = function (L : Plua_State; ud : Pointer; - sz : Psize_t) : PChar; cdecl; - lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t; - ud : Pointer) : LongInt; cdecl; + (* + ** functions that read/write blocks when loading/dumping Lua chunks + *) + lua_Reader = function (L : Plua_State; ud : Pointer; sz : Psize_t) : PChar; cdecl; + lua_Writer = function (L : Plua_State; const p : Pointer; sz : size_t; ud : Pointer) : LongInt; cdecl; (* ** prototype for memory-allocation functions *) - lua_Alloc = function (ud, ptr : Pointer; - osize, nsize : size_t) : Pointer; cdecl; + lua_Alloc = function (ud, ptr : Pointer; osize, nsize : size_t) : Pointer; cdecl; const - (* - ** basic types - *) - LUA_TNONE = -1; + (* + ** basic types + *) + LUA_TNONE = -1; + LUA_TNIL = 0; + LUA_TBOOLEAN = 1; + LUA_TLIGHTUSERDATA = 2; + LUA_TNUMBER = 3; + LUA_TSTRING = 4; + LUA_TTABLE = 5; + LUA_TFUNCTION = 6; + LUA_TUSERDATA = 7; + LUA_TTHREAD = 8; - LUA_TNIL = 0; - LUA_TBOOLEAN = 1; - LUA_TLIGHTUSERDATA = 2; - LUA_TNUMBER = 3; - LUA_TSTRING = 4; - LUA_TTABLE = 5; - LUA_TFUNCTION = 6; - LUA_TUSERDATA = 7; - LUA_TTHREAD = 8; - - (* minimum Lua stack available to a C function *) - LUA_MINSTACK = 20; + (* minimum Lua stack available to a C function *) + LUA_MINSTACK = 20; type - (* type of numbers in Lua *) - lua_Number = LUA_NUMBER_; + (* type of numbers in Lua *) + lua_Number = LUA_NUMBER_; - (* type for integer functions *) - lua_Integer = LUA_INTEGER_; + (* type for integer functions *) + lua_Integer = LUA_INTEGER_; (* ** state manipulation *) function lua_newstate(f : lua_Alloc; ud : Pointer) : Plua_State; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_close(L: Plua_State); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function lua_newthread(L : Plua_State) : Plua_State; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function lua_atpanic(L : Plua_State; panicf : lua_CFunction) : lua_CFunction; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** basic stack manipulation *) function lua_gettop(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_settop(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushvalue(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_remove(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_insert(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_replace(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_checkstack(L : Plua_State; sz : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure lua_xmove(src, dest : Plua_State; n : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** access functions (stack -> C) *) function lua_isnumber(L : Plua_State; idx : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_isstring(L : Plua_State; idx : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_iscfunction(L : Plua_State; idx : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_isuserdata(L : Plua_State; idx : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_type(L : Plua_State; idx : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_typename(L : Plua_State; tp : LongInt) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_equal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_rawequal(L : Plua_State; idx1, idx2 : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_lessthan(L : Plua_State; idx1, idx2 : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function lua_tonumber(L : Plua_State; idx : LongInt) : lua_Number; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_tointeger(L : Plua_State; idx : LongInt) : lua_Integer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_toboolean(L : Plua_State; idx : LongInt) : LongBool; - cdecl; external LuaLibName; -function lua_tolstring(L : Plua_State; idx : LongInt; - len : Psize_t) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + + +function lua_tolstring(L : Plua_State; idx : LongInt; len : Psize_t) : PChar; + cdecl; external LuaLibName; + function lua_objlen(L : Plua_State; idx : LongInt) : size_t; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_tocfunction(L : Plua_State; idx : LongInt) : lua_CFunction; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_touserdata(L : Plua_State; idx : LongInt) : Pointer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_tothread(L : Plua_State; idx : LongInt) : Plua_State; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_topointer(L : Plua_State; idx : LongInt) : Pointer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** push functions (C -> stack) *) procedure lua_pushnil(L : Plua_State); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushnumber(L : Plua_State; n : lua_Number); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushinteger(L : Plua_State; n : lua_Integer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushlstring(L : Plua_State; const s : PChar; ls : size_t); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushstring(L : Plua_State; const s : PChar); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + + function lua_pushvfstring(L : Plua_State; - const fmt : PChar; argp : Pointer) : PChar; - cdecl; external LuaLibName; + const fmt : PChar; argp : Pointer) : PChar; + cdecl; external LuaLibName; + function lua_pushfstring(L : Plua_State; const fmt : PChar) : PChar; varargs; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushcclosure(L : Plua_State; fn : lua_CFunction; n : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushboolean(L : Plua_State; b : LongBool); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_pushlightuserdata(L : Plua_State; p : Pointer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_pushthread(L : Plua_state) : Cardinal; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** get functions (Lua -> stack) *) procedure lua_gettable(L : Plua_State ; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_getfield(L : Plua_State; idx : LongInt; k : PChar); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_rawget(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_rawgeti(L : Plua_State; idx, n : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_createtable(L : Plua_State; narr, nrec : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_newuserdata(L : Plua_State; sz : size_t) : Pointer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_getmetatable(L : Plua_State; objindex : LongInt) : LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_getfenv(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** set functions (stack -> Lua) *) procedure lua_settable(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_setfield(L : Plua_State; idx : LongInt; const k : PChar); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_rawset(L : Plua_State; idx : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_rawseti(L : Plua_State; idx , n: LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_setmetatable(L : Plua_State; objindex : LongInt): LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_setfenv(L : Plua_State; idx : LongInt): LongBool; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** `load' and `call' functions (load and run Lua code) *) procedure lua_call(L : Plua_State; nargs, nresults : LongInt); - cdecl; external LuaLibName; -function lua_pcall(L : Plua_State; - nargs, nresults, errfunc : LongInt) : LongInt; - cdecl; external LuaLibName; -function lua_cpcall(L : Plua_State; - func : lua_CFunction; ud : Pointer) : LongInt; - cdecl; external LuaLibName; -function lua_load(L : Plua_State; reader : lua_Reader; - dt : Pointer; const chunkname : PChar) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + +function lua_pcall(L : Plua_State; nargs, nresults, errfunc : LongInt) : LongInt; + cdecl; external LuaLibName; + +function lua_cpcall(L : Plua_State; func : lua_CFunction; ud : Pointer) : LongInt; + cdecl; external LuaLibName; + +function lua_load(L : Plua_State; reader : lua_Reader; dt : Pointer; const chunkname : PChar) : LongInt; + cdecl; external LuaLibName; + function lua_dump(L : Plua_State; writer : lua_Writer; data: Pointer) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** coroutine functions *) function lua_yield(L : Plua_State; nresults : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_resume(L : Plua_State; narg : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_status(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** garbage-collection functions and options *) const - LUA_GCSTOP = 0; - LUA_GCRESTART = 1; - LUA_GCCOLLECT = 2; - LUA_GCCOUNT = 3; - LUA_GCCOUNTB = 4; - LUA_GCSTEP = 5; - LUA_GCSETPAUSE = 6; - LUA_GCSETSTEPMUL = 7; + LUA_GCSTOP = 0; + LUA_GCRESTART = 1; + LUA_GCCOLLECT = 2; + LUA_GCCOUNT = 3; + LUA_GCCOUNTB = 4; + LUA_GCSTEP = 5; + LUA_GCSETPAUSE = 6; + LUA_GCSETSTEPMUL = 7; function lua_gc(L : Plua_State; what, data : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** miscellaneous functions *) function lua_error(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function lua_next(L : Plua_State; idx : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure lua_concat(L : Plua_State; n : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function lua_getallocf(L : Plua_State; ud : PPointer) : lua_Alloc; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + procedure lua_setallocf(L : Plua_State; f : lua_Alloc; ud : Pointer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ** =============================================================== @@ -429,8 +479,8 @@ function lua_getgccount(L : Plua_State) : LongInt; type - lua_Chuckreader = type lua_Reader; - lua_Chuckwriter = type lua_Writer; + lua_Chuckreader = lua_Reader; + lua_Chuckwriter = lua_Writer; (* ====================================================================== *) @@ -444,23 +494,23 @@ ** Event codes *) const - LUA_HOOKCALL = 0; - LUA_HOOKRET = 1; - LUA_HOOKLINE = 2; - LUA_HOOKCOUNT = 3; - LUA_HOOKTAILRET = 4; + LUA_HOOKCALL = 0; + LUA_HOOKRET = 1; + LUA_HOOKLINE = 2; + LUA_HOOKCOUNT = 3; + LUA_HOOKTAILRET = 4; (* ** Event masks *) - LUA_MASKCALL = 1 shl LUA_HOOKCALL; - LUA_MASKRET = 1 shl LUA_HOOKRET; - LUA_MASKLINE = 1 shl LUA_HOOKLINE; - LUA_MASKCOUNT = 1 shl LUA_HOOKCOUNT; + LUA_MASKCALL = 1 shl LUA_HOOKCALL; + LUA_MASKRET = 1 shl LUA_HOOKRET; + LUA_MASKLINE = 1 shl LUA_HOOKLINE; + LUA_MASKCOUNT = 1 shl LUA_HOOKCOUNT; type - lua_Debug = packed record + lua_Debug = packed record event : LongInt; name : PChar; (* (n) *) namewhat : PChar; (* (n) `global', `local', `field', `method' *) @@ -472,42 +522,44 @@ short_src : array [0..LUA_IDSIZE-1] of Char; (* (S) *) (* private part *) i_ci : LongInt; (* active function *) - end; - Plua_Debug = ^lua_Debug; + end; + Plua_Debug = ^lua_Debug; (* Functions to be called by the debuger in specific events *) lua_Hook = procedure (L : Plua_State; ar : Plua_Debug); cdecl; -function lua_getstack(L : Plua_State; level : LongInt; - ar : Plua_Debug) : LongInt; - cdecl; external LuaLibName; -function lua_getinfo(L : Plua_State; const what : PChar; - ar: Plua_Debug): LongInt; - cdecl; external LuaLibName; -function lua_getlocal(L : Plua_State; - ar : Plua_Debug; n : LongInt) : PChar; - cdecl; external LuaLibName; -function lua_setlocal(L : Plua_State; - ar : Plua_Debug; n : LongInt) : PChar; - cdecl; external LuaLibName; +function lua_getstack(L : Plua_State; level : LongInt; ar : Plua_Debug) : LongInt; + cdecl; external LuaLibName; + +function lua_getinfo(L : Plua_State; const what : PChar; ar: Plua_Debug): LongInt; + cdecl; external LuaLibName; + +function lua_getlocal(L : Plua_State; ar : Plua_Debug; n : LongInt) : PChar; + cdecl; external LuaLibName; + +function lua_setlocal(L : Plua_State; ar : Plua_Debug; n : LongInt) : PChar; + cdecl; external LuaLibName; + function lua_getupvalue(L : Plua_State; funcindex, n : LongInt) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_setupvalue(L : Plua_State; funcindex, n : LongInt) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; -function lua_sethook(L : Plua_State; func : lua_Hook; - mask, count: LongInt): LongInt; - cdecl; external LuaLibName; +function lua_sethook(L : Plua_State; func : lua_Hook; mask, count: LongInt): LongInt; + cdecl; external LuaLibName; + {$IFDEF LUA_GETHOOK} function lua_gethook(L : Plua_State) : lua_Hook; - cdecl; external LuaLibName; + cdecl; external LuaLibName; {$ENDIF} function lua_gethookmask(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; + function lua_gethookcount(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; (*****************************************************************************) @@ -521,44 +573,44 @@ *) const - (* Key to file-handle type *) - LUA_FILEHANDLE = 'FILE*'; + (* Key to file-handle type *) + LUA_FILEHANDLE = 'FILE*'; - LUA_COLIBNAME = 'coroutine'; - LUA_TABLIBNAME = 'table'; - LUA_IOLIBNAME = 'io'; - LUA_OSLIBNAME = 'os'; - LUA_STRLIBNAME = 'string'; - LUA_MATHLIBNAME = 'math'; - LUA_DBLIBNAME = 'debug'; - LUA_LOADLIBNAME = 'package'; + LUA_COLIBNAME = 'coroutine'; + LUA_TABLIBNAME = 'table'; + LUA_IOLIBNAME = 'io'; + LUA_OSLIBNAME = 'os'; + LUA_STRLIBNAME = 'string'; + LUA_MATHLIBNAME = 'math'; + LUA_DBLIBNAME = 'debug'; + LUA_LOADLIBNAME = 'package'; function luaopen_base(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_table(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_io(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_os(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_string(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_math(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_debug(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaopen_package(L : Plua_State) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_openlibs(L : Plua_State); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure lua_assert(x : Boolean); // a macro @@ -578,97 +630,83 @@ procedure luaL_setn(L : Plua_State; i, j : LongInt); const - LUA_ERRFILE = LUA_ERRERR + 1; + LUA_ERRFILE = LUA_ERRERR + 1; type - luaL_Reg = packed record + luaL_Reg = packed record name : PChar; func : lua_CFunction; - end; - PluaL_Reg = ^luaL_Reg; + end; + PluaL_Reg = ^luaL_Reg; -procedure luaL_openlib(L : Plua_State; const libname : PChar; - const lr : PluaL_Reg; nup : LongInt); - cdecl; external LuaLibName; -procedure luaL_register(L : Plua_State; const libname : PChar; - const lr : PluaL_Reg); - cdecl; external LuaLibName; -function luaL_getmetafield(L : Plua_State; obj : LongInt; - const e : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_callmeta(L : Plua_State; obj : LongInt; - const e : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_typerror(L : Plua_State; narg : LongInt; - const tname : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_argerror(L : Plua_State; numarg : LongInt; - const extramsg : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_checklstring(L : Plua_State; numArg : LongInt; - ls : Psize_t) : PChar; - cdecl; external LuaLibName; -function luaL_optlstring(L : Plua_State; numArg : LongInt; - const def: PChar; ls: Psize_t) : PChar; - cdecl; external LuaLibName; +procedure luaL_openlib(L : Plua_State; const libname : PChar; const lr : PluaL_Reg; nup : LongInt); + cdecl; external LuaLibName; +procedure luaL_register(L : Plua_State; const libname : PChar; const lr : PluaL_Reg); + cdecl; external LuaLibName; +function luaL_getmetafield(L : Plua_State; obj : LongInt; const e : PChar) : LongInt; + cdecl; external LuaLibName; +function luaL_callmeta(L : Plua_State; obj : LongInt; const e : PChar) : LongInt; + cdecl; external LuaLibName; +function luaL_typerror(L : Plua_State; narg : LongInt; const tname : PChar) : LongInt; + cdecl; external LuaLibName; +function luaL_argerror(L : Plua_State; numarg : LongInt; const extramsg : PChar) : LongInt; + cdecl; external LuaLibName; +function luaL_checklstring(L : Plua_State; numArg : LongInt; ls : Psize_t) : PChar; + cdecl; external LuaLibName; +function luaL_optlstring(L : Plua_State; numArg : LongInt; const def: PChar; ls: Psize_t) : PChar; + cdecl; external LuaLibName; function luaL_checknumber(L : Plua_State; numArg : LongInt) : lua_Number; - cdecl; external LuaLibName; -function luaL_optnumber(L : Plua_State; nArg : LongInt; - def : lua_Number) : lua_Number; - cdecl; external LuaLibName; + cdecl; external LuaLibName; +function luaL_optnumber(L : Plua_State; nArg : LongInt; def : lua_Number) : lua_Number; + cdecl; external LuaLibName; function luaL_checkinteger(L : Plua_State; numArg : LongInt) : lua_Integer; - cdecl; external LuaLibName; -function luaL_optinteger(L : Plua_State; nArg : LongInt; - def : lua_Integer) : lua_Integer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; +function luaL_optinteger(L : Plua_State; nArg : LongInt; def : lua_Integer) : lua_Integer; + cdecl; external LuaLibName; procedure luaL_checkstack(L : Plua_State; sz : LongInt; const msg : PChar); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_checktype(L : Plua_State; narg, t : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_checkany(L : Plua_State; narg : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_newmetatable(L : Plua_State; const tname : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_checkudata(L : Plua_State; ud : LongInt; - const tname : PChar) : Pointer; - cdecl; external LuaLibName; + cdecl; external LuaLibName; +function luaL_checkudata(L : Plua_State; ud : LongInt; const tname : PChar) : Pointer; + cdecl; external LuaLibName; procedure luaL_where(L : Plua_State; lvl : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_error(L : Plua_State; const fmt : PChar) : LongInt; varargs; - cdecl; external LuaLibName; + cdecl; external LuaLibName; -function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar; - const lst : array of PChar) : LongInt; - cdecl; external LuaLibName; +function luaL_checkoption(L : Plua_State; narg : LongInt; const def : PChar; const lst : array of PChar) : LongInt; + cdecl; external LuaLibName; function luaL_ref(L : Plua_State; t : LongInt) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_unref(L : Plua_State; t, ref : LongInt); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_loadfile(L : Plua_State; const filename : PChar) : LongInt; - cdecl; external LuaLibName; -function luaL_loadbuffer(L : Plua_State; const buff : PChar; - sz : size_t; const name: PChar) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; +function luaL_loadbuffer(L : Plua_State; const buff : PChar; sz : size_t; const name: PChar) : LongInt; + cdecl; external LuaLibName; function luaL_loadstring(L : Plua_State; const s : Pchar) : LongInt; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_newstate : Plua_State; - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_gsub(L : Plua_State; const s, p, r : PChar) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; -function luaL_findtable(L : Plua_State; idx : LongInt; - const fname : PChar; szhint : LongInt) : PChar; - cdecl; external LuaLibName; +function luaL_findtable(L : Plua_State; idx : LongInt; const fname : PChar; szhint : LongInt) : PChar; + cdecl; external LuaLibName; (* @@ -677,8 +715,7 @@ ** =============================================================== *) -function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; - extramsg : PChar): LongInt; +function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; extramsg : PChar): LongInt; function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; @@ -705,13 +742,13 @@ *) type - luaL_Buffer = packed record + luaL_Buffer = packed record p : PChar; (* current position in buffer *) lvl : LongInt; (* number of strings in the stack (level) *) L : Plua_State; buffer : array [0..LUAL_BUFFERSIZE-1] of Char; - end; - PluaL_Buffer = ^luaL_Buffer; + end; + PluaL_Buffer = ^luaL_Buffer; procedure luaL_addchar(B : PluaL_Buffer; c : Char); @@ -721,17 +758,17 @@ procedure luaL_addsize(B : PluaL_Buffer; n : LongInt); procedure luaL_buffinit(L : Plua_State; B : PluaL_Buffer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; function luaL_prepbuffer(B : PluaL_Buffer) : PChar; - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_addlstring(B : PluaL_Buffer; const s : PChar; ls : size_t); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_addstring(B : PluaL_Buffer; const s : PChar); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_addvalue(B : PluaL_Buffer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; procedure luaL_pushresult(B : PluaL_Buffer); - cdecl; external LuaLibName; + cdecl; external LuaLibName; (* ====================================================== *) @@ -740,8 +777,8 @@ (* pre-defined references *) const - LUA_NOREF = -2; - LUA_REFNIL = -1; + LUA_NOREF = -2; + LUA_REFNIL = -1; function lua_ref(L : Plua_State; lock : Boolean) : LongInt; @@ -762,17 +799,19 @@ (*****************************************************************************) (* luaconfig.h *) (*****************************************************************************) - -function lua_readline(L : Plua_State; var b : PChar; p : PChar): Boolean; +{ +function lua_readline(L : Plua_State; var - s : AnsiString; + b : PChar; p : PChar): Boolean; +var + s : AnsiString; begin - Write(p); // show prompt - ReadLn(s); // get line - b := PChar(s); // and return it - lua_readline := (b[0] <> #4); // test for ctrl-D + Write(p); // show prompt + ReadLn(s); // get line + b := PChar(s); // and return it + lua_readline := (b[0] <> #4); // test for ctrl-D end; - +} procedure lua_saveline(L : Plua_State; idx : LongInt); begin end; @@ -788,108 +827,108 @@ function lua_upvalueindex(idx : LongInt) : LongInt; begin - lua_upvalueindex := LUA_GLOBALSINDEX - idx; +lua_upvalueindex := LUA_GLOBALSINDEX - idx; end; procedure lua_pop(L : Plua_State; n : LongInt); begin - lua_settop(L, -n - 1); +lua_settop(L, -n - 1); end; procedure lua_newtable(L : Plua_State); begin - lua_createtable(L, 0, 0); +lua_createtable(L, 0, 0); end; procedure lua_register(L : Plua_State; n : PChar; f : lua_CFunction); begin - lua_pushcfunction(L, f); - lua_setglobal(L, n); +lua_pushcfunction(L, f); +lua_setglobal(L, n); end; procedure lua_pushcfunction(L : Plua_State; f : lua_CFunction); begin - lua_pushcclosure(L, f, 0); + lua_pushcclosure(L, f, 0); end; function lua_strlen(L : Plua_State; idx : LongInt) : LongInt; begin - lua_strlen := lua_objlen(L, idx); + lua_strlen := lua_objlen(L, idx); end; function lua_isfunction(L : Plua_State; n : LongInt) : Boolean; begin - lua_isfunction := lua_type(L, n) = LUA_TFUNCTION; + lua_isfunction := lua_type(L, n) = LUA_TFUNCTION; end; function lua_istable(L : Plua_State; n : LongInt) : Boolean; begin - lua_istable := lua_type(L, n) = LUA_TTABLE; + lua_istable := lua_type(L, n) = LUA_TTABLE; end; function lua_islightuserdata(L : Plua_State; n : LongInt) : Boolean; begin - lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA; + lua_islightuserdata := lua_type(L, n) = LUA_TLIGHTUSERDATA; end; function lua_isnil(L : Plua_State; n : LongInt) : Boolean; begin - lua_isnil := lua_type(L, n) = LUA_TNIL; + lua_isnil := lua_type(L, n) = LUA_TNIL; end; function lua_isboolean(L : Plua_State; n : LongInt) : Boolean; begin - lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN; + lua_isboolean := lua_type(L, n) = LUA_TBOOLEAN; end; function lua_isthread(L : Plua_State; n : LongInt) : Boolean; begin - lua_isthread := lua_type(L, n) = LUA_TTHREAD; + lua_isthread := lua_type(L, n) = LUA_TTHREAD; end; function lua_isnone(L : Plua_State; n : LongInt) : Boolean; begin - lua_isnone := lua_type(L, n) = LUA_TNONE; + lua_isnone := lua_type(L, n) = LUA_TNONE; end; function lua_isnoneornil(L : Plua_State; n : LongInt) : Boolean; begin - lua_isnoneornil := lua_type(L, n) <= 0; + lua_isnoneornil := lua_type(L, n) <= 0; end; procedure lua_pushliteral(L : Plua_State; s : PChar); begin - lua_pushlstring(L, s, StrLen(s)); + lua_pushlstring(L, s, StrLen(s)); end; procedure lua_setglobal(L : Plua_State; s : PChar); begin - lua_setfield(L, LUA_GLOBALSINDEX, s); + lua_setfield(L, LUA_GLOBALSINDEX, s); end; procedure lua_getglobal(L: Plua_State; s: PChar); begin - lua_getfield(L, LUA_GLOBALSINDEX, s); + lua_getfield(L, LUA_GLOBALSINDEX, s); end; function lua_tostring(L : Plua_State; idx : LongInt) : AnsiString; begin - lua_tostring := SysUtils.StrPas(lua_tolstring(L, idx, nil)); + lua_tostring := StrPas(lua_tolstring(L, idx, nil)); end; function lua_open : Plua_State; begin - lua_open := luaL_newstate; + lua_open := luaL_newstate; end; procedure lua_getregistry(L : Plua_State); begin - lua_pushvalue(L, LUA_REGISTRYINDEX); + lua_pushvalue(L, LUA_REGISTRYINDEX); end; function lua_getgccount(L : Plua_State) : LongInt; begin - lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0); + lua_getgccount := lua_gc(L, LUA_GCCOUNT, 0); end; @@ -908,88 +947,87 @@ function luaL_getn(L : Plua_State; idx : LongInt) : LongInt; begin - luaL_getn := lua_objlen(L, idx); + luaL_getn := lua_objlen(L, idx); end; procedure luaL_setn(L : plua_State; i, j : LongInt); begin - (* no op *) + (* no op *) end; -function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; - extramsg : PChar): LongInt; +function luaL_argcheck(L : Plua_State; cond : Boolean; numarg : LongInt; extramsg : PChar): LongInt; begin - if not cond then - luaL_argcheck := luaL_argerror(L, numarg, extramsg) - else - luaL_argcheck := 0; + if not cond then + luaL_argcheck := luaL_argerror(L, numarg, extramsg) + else + luaL_argcheck := 0; end; function luaL_checkstring(L : Plua_State; n : LongInt) : PChar; begin - luaL_checkstring := luaL_checklstring(L, n, nil); + luaL_checkstring := luaL_checklstring(L, n, nil); end; function luaL_optstring(L : Plua_State; n : LongInt; d : PChar) : PChar; begin - luaL_optstring := luaL_optlstring(L, n, d, nil); + luaL_optstring := luaL_optlstring(L, n, d, nil); end; function luaL_checkint(L : Plua_State; n : LongInt) : lua_Integer; begin - luaL_checkint := luaL_checkinteger(L, n); + luaL_checkint := luaL_checkinteger(L, n); end; function luaL_optint(L : Plua_State; n : LongInt; d : lua_Integer): lua_Integer; begin - luaL_optint := luaL_optinteger(L, n, d); + luaL_optint := luaL_optinteger(L, n, d); end; function luaL_checklong(L : Plua_State; n : LongInt) : lua_Integer; begin - luaL_checklong := luaL_checkinteger(L, n); + luaL_checklong := luaL_checkinteger(L, n); end; function luaL_optlong(L : Plua_State; n : LongInt; d : lua_Integer) : lua_Integer; begin - luaL_optlong := luaL_optinteger(L, n, d); + luaL_optlong := luaL_optinteger(L, n, d); end; function luaL_typename(L : Plua_State; idx : LongInt) : PChar; begin - luaL_typename := lua_typename( L, lua_type(L, idx) ); + luaL_typename := lua_typename( L, lua_type(L, idx) ); end; function luaL_dofile(L : Plua_State; fn : PChar) : LongInt; begin - luaL_dofile := luaL_loadfile(L, fn); - if luaL_dofile = 0 then - luaL_dofile := lua_pcall(L, 0, 0, 0); + luaL_dofile := luaL_loadfile(L, fn); + if luaL_dofile = 0 then + luaL_dofile := lua_pcall(L, 0, 0, 0); end; function luaL_dostring(L : Plua_State; s : PChar) : LongInt; begin - luaL_dostring := luaL_loadstring(L, s); - if luaL_dostring = 0 then - luaL_dostring := lua_pcall(L, 0, 0, 0); + luaL_dostring := luaL_loadstring(L, s); + if luaL_dostring = 0 then + luaL_dostring := lua_pcall(L, 0, 0, 0); end; procedure luaL_getmetatable(L : Plua_State; n : PChar); begin - lua_getfield(L, LUA_REGISTRYINDEX, n); + lua_getfield(L, LUA_REGISTRYINDEX, n); end; procedure luaL_addchar(B : PluaL_Buffer; c : Char); begin - if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then - luaL_prepbuffer(B); - B^.p^ := c; - Inc(B^.p); + if not(B^.p < B^.buffer + LUAL_BUFFERSIZE) then + luaL_prepbuffer(B); + (B^.p^) := c; + Inc(B^.p); end; procedure luaL_putchar(B : PluaL_Buffer; c : Char); begin - luaL_addchar(B, c); + luaL_addchar(B, c); end; procedure luaL_addsize(B : PluaL_Buffer; n : LongInt); @@ -999,23 +1037,24 @@ function lua_ref(L : Plua_State; lock : Boolean) : LongInt; begin - if lock then - lua_ref := luaL_ref(L, LUA_REGISTRYINDEX) - else begin - lua_pushstring(L, 'unlocked references are obsolete'); - lua_error(L); - lua_ref := 0; - end; + if lock then + lua_ref := luaL_ref(L, LUA_REGISTRYINDEX) + else + begin + lua_pushstring(L, _P'unlocked references are obsolete'); + lua_error(L); + lua_ref := 0; + end; end; procedure lua_unref(L : Plua_State; ref : LongInt); begin - luaL_unref(L, LUA_REGISTRYINDEX, ref); + luaL_unref(L, LUA_REGISTRYINDEX, ref); end; procedure lua_getref(L : Plua_State; ref : LongInt); begin - lua_rawgeti(L, LUA_REGISTRYINDEX, ref); + lua_rawgeti(L, LUA_REGISTRYINDEX, ref); end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/Math.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/Math.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,2 @@ +#pragma once + diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/PNGh.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/PNGh.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,90 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} + +unit PNGh; +interface + +uses png; + +{$IFDEF FPC} + {$PACKRECORDS C} +{$ELSE} + {$DEFINE cdecl attribute(cdecl)} +{$ENDIF} + +const + // Constants for libpng, they are not defined in png unit. + // We actually don't need all of them. + + // These describe the color_type field in png_info. + // color type masks + PNG_COLOR_MASK_PALETTE = 1; + PNG_COLOR_MASK_COLOR = 2; + PNG_COLOR_MASK_ALPHA = 4; + + // color types. Note that not all combinations are legal + PNG_COLOR_TYPE_GRAY = 0; + PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_PALETTE; + PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR; + PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR or PNG_COLOR_MASK_ALPHA; + PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA; + + // aliases + PNG_COLOR_TYPE_RGBA = PNG_COLOR_TYPE_RGB_ALPHA; + PNG_COLOR_TYPE_GA = PNG_COLOR_TYPE_GRAY_ALPHA; + + // This is for compression type. PNG 1.0-1.2 only define the single type. + PNG_COMPRESSION_TYPE_BASE = 0; // Deflate method 8, 32K window + PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE; + + // This is for filter type. PNG 1.0-1.2 only define the single type. + PNG_FILTER_TYPE_BASE = 0; // Single row per-byte filtering + PNG_INTRAPIXEL_DIFFERENCING = 64; // Used only in MNG datastreams + PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE; + + // These are for the interlacing type. These values should NOT be changed. + PNG_INTERLACE_NONE = 0; // Non-interlaced image + PNG_INTERLACE_ADAM7 = 1; // Adam7 interlacing + PNG_INTERLACE_LAST = 2; // Not a valid value + +type + // where is better place for this definition? + PFile = ^file; + +procedure png_init_pascal_io(png_ptr: png_structp; pf : PFile); + +implementation + +// We cannot get c-style FILE* pointer to pass it to libpng, so we implement our own writing functions +procedure PngWriteData(png_ptr: png_structp; p: PByte; len: png_size_t); cdecl; +begin + BlockWrite( PFile(png_get_io_ptr(png_ptr))^, p^, len); +end; + +procedure PngFlushData(png_ptr: png_structp); cdecl; +begin +end; + +procedure png_init_pascal_io(png_ptr: png_structp; pf : PFile); +begin + png_set_write_fn(png_ptr, pf, @PngWriteData, @PngFlushData); +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,365 +0,0 @@ -(* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - *) - -{$INCLUDE "options.inc"} - -unit PascalExports; -(* - * If the engine is compiled as library this unit will export functions - * as C declarations for convenient library usage in your application and - * language of choice. - * - * See also: C declarations on wikipedia - * http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl - *) -interface -uses uTypes, uConsts, uVariables, GLunit, uKeys, uSound, uAmmos, uUtils, uCommands; - -{$INCLUDE "config.inc"} -procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export; -function HW_getNumberOfWeapons:LongInt; cdecl; export; -function HW_getMaxNumberOfTeams:LongInt; cdecl; export; -function HW_getMaxNumberOfHogs:LongInt; cdecl; export; -procedure HW_terminate(closeFrontend: Boolean); cdecl; export; - -implementation -{$IFDEF HWLIBRARY} -var cZoomVal: GLfloat; - -// retrieve protocol information -procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export; -begin - netProto^:= cNetProtoVersion; - versionStr^:= cVersionString; -end; - -// emulate mouse/keyboard input -procedure HW_click; cdecl; export; -begin - leftClick:= true; -end; - -procedure HW_ammoMenu; cdecl; export; -begin - rightClick:= true; -end; - -procedure HW_zoomSet(value: GLfloat); cdecl; export; -begin - cZoomVal:= value; - ZoomValue:= value; -end; - -procedure HW_zoomIn; cdecl; export; -begin - if wheelDown = false then - wheelUp:= true; -end; - -procedure HW_zoomOut; cdecl; export; -begin - if wheelUp = false then - wheelDown:= true; -end; - -procedure HW_zoomReset; cdecl; export; -begin - ZoomValue:= cZoomVal; - // center the camera at current hog - if CurrentHedgehog <> nil then - followGear:= CurrentHedgehog^.Gear; -end; - -function HW_zoomFactor: GLfloat; cdecl; export; -begin - exit( ZoomValue / cDefaultZoomLevel ); -end; - -function HW_zoomLevel: LongInt; cdecl; export; -begin - exit( trunc((ZoomValue - cDefaultZoomLevel) / cZoomDelta) ); -end; - -procedure HW_walkingKeysUp; cdecl; export; -begin - leftKey:= false; - rightKey:= false; - upKey:= false; - downKey:= false; - preciseKey:= false; -end; - -procedure HW_otherKeysUp; cdecl; export; -begin - spaceKey:= false; - enterKey:= false; - backspaceKey:= false; -end; - -procedure HW_allKeysUp; cdecl; export; -begin - // set all keys to released - uKeys.initModule; -end; - -procedure HW_walkLeft; cdecl; export; -begin - leftKey:= true; -end; - -procedure HW_walkRight; cdecl; export; -begin - rightKey:= true; -end; - -procedure HW_preciseSet(status:boolean); cdecl; export; -begin - preciseKey:= status; -end; - -procedure HW_aimUp; cdecl; export; -begin - upKey:= true; -end; - -procedure HW_aimDown; cdecl; export; -begin - downKey:= true; -end; - -procedure HW_shoot; cdecl; export; -begin - spaceKey:= true; -end; - -procedure HW_jump; cdecl; export; -begin - enterKey:= true; -end; - -procedure HW_backjump; cdecl; export; -begin - backspaceKey:= true; -end; - -procedure HW_tab; cdecl; export; -begin - tabKey:= true; -end; - -procedure HW_chat; cdecl; export; -begin - chatAction:= true; -end; - -procedure HW_screenshot; cdecl; export; -begin - flagMakeCapture:= true; -end; - -procedure HW_pause; cdecl; export; -begin - if isPaused = false then - pauseAction:= true; -end; - -procedure HW_pauseToggle; cdecl; export; -begin - pauseAction:= true; -end; - -function HW_isPaused: boolean; cdecl; export; -begin - exit( isPaused ); -end; - -// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup -procedure HW_terminate(closeFrontend: boolean); cdecl; export; -begin - alsoShutdownFrontend:= closeFrontend; - ParseCommand('forcequit', true); -end; - -function HW_getSDLWindow: pointer; cdecl; export; -begin -{$IFDEF SDL13} - exit( SDLwindow ); -{$ELSE} - exit( nil ); -{$ENDIF} -end; - -// cursor handling -procedure HW_setCursor(x,y: LongInt); cdecl; export; -begin - CursorPoint.X:= x; - CursorPoint.Y:= y; -end; - -procedure HW_getCursor(x,y: PLongInt); cdecl; export; -begin - x^:= CursorPoint.X; - y^:= CursorPoint.Y; -end; - -// ammo menu related functions -function HW_isAmmoMenuOpen: boolean; cdecl; export; -begin - exit( bShowAmmoMenu ); -end; - -function HW_isAmmoMenuNotAllowed: boolean; cdecl; export; -begin; - exit( (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or - ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) ); -end; - -function HW_isWeaponRequiringClick: boolean; cdecl; export; -begin - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.BotLevel = 0) then - exit( (CurrentHedgehog^.Gear^.State and gstHHChooseTarget) <> 0 ) - else - exit(false); -end; - -function HW_isWeaponTimerable: boolean; cdecl; export; -begin - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then - exit( (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable) <> 0) - else - exit(false); -end; - -function HW_isWeaponSwitch: boolean cdecl; export; -begin - if (CurAmmoGear <> nil) and (CurrentHedgehog^.BotLevel = 0) then - exit(CurAmmoGear^.AmmoType = amSwitch) - else - exit(false) -end; - -function HW_isWeaponRope: boolean cdecl; export; -begin - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) then - exit(CurrentHedgehog^.CurAmmoType = amRope) - else - exit(false); -end; - -procedure HW_setGrenadeTime(time: LongInt); cdecl; export; -begin - ParseCommand('/timer ' + inttostr(time), true); -end; - -procedure HW_setPianoSound(snd: LongInt); cdecl; export; -begin - // this most likely won't work in network game - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Ammo <> nil) and (CurrentHedgehog^.BotLevel = 0) - and (CurrentHedgehog^.CurAmmoType = amPiano) then - case snd of - 0: PlaySound(sndPiano0); - 1: PlaySound(sndPiano1); - 2: PlaySound(sndPiano2); - 3: PlaySound(sndPiano3); - 4: PlaySound(sndPiano4); - 5: PlaySound(sndPiano5); - 6: PlaySound(sndPiano6); - 7: PlaySound(sndPiano7); - else PlaySound(sndPiano8); - end; -end; - -function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export; -begin - exit(str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); -end; - -function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export; -begin - exit(str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); -end; - -function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export; -begin - exit(str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); -end; - -function HW_getNumberOfWeapons:LongInt; cdecl; export; -begin - exit(ord(high(TAmmoType))); -end; - -procedure HW_setWeapon(whichone: LongInt); cdecl; export; -begin - if (CurrentTeam = nil) then exit; - if (not CurrentTeam^.ExtDriven) and (CurrentTeam^.Hedgehogs[0].BotLevel = 0) then - SetWeapon(TAmmoType(whichone+1)); -end; - -function HW_isWeaponAnEffect(whichone: LongInt): boolean; cdecl; export; -begin - exit(Ammoz[TAmmoType(whichone+1)].Ammo.Propz and ammoprop_Effect <> 0) -end; - -function HW_getAmmoCounts(counts: PLongInt): LongInt; cdecl; export; -var a : PHHAmmo; - slot, index: LongInt; -begin - // nil check - if (CurrentHedgehog = nil) or (CurrentHedgehog^.Ammo = nil) or (CurrentTeam = nil) then - exit(-1); - // hog controlled by opponent (net or ai) - if (CurrentTeam^.ExtDriven) or (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then - exit(1); - - a:= CurrentHedgehog^.Ammo; - for slot:= 0 to cMaxSlotIndex do - for index:= 0 to cMaxSlotAmmoIndex do - if a^[slot,index].Count <> 0 then // yes, ammomenu is hell - counts[ord(a^[slot,index].AmmoType)-1]:= a^[slot,index].Count; - exit(0); -end; - -procedure HW_getAmmoDelays (skipTurns: PByte); cdecl; export; -var a : TAmmoType; -begin - for a:= Low(TAmmoType) to High(TAmmoType) do - skipTurns[ord(a)-1]:= byte(Ammoz[a].SkipTurns); -end; - -function HW_getTurnsForCurrentTeam: LongInt; cdecl; export; -begin - if (CurrentTeam <> nil) and (CurrentTeam^.Clan <> nil) then - exit(CurrentTeam^.Clan^.TurnNumber) - else - exit(0); -end; - -function HW_getMaxNumberOfHogs: LongInt; cdecl; export; -begin - exit(cMaxHHIndex+1); -end; - -function HW_getMaxNumberOfTeams: LongInt; cdecl; export; -begin - exit(cMaxTeams); -end; -{$ENDIF} - -end. - diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/SDLh.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,48 +22,51 @@ interface {$IFDEF LINUX} - {$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF FREEBSD} - {$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF DARWIN} - {$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF HAIKU} - {$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF UNIX} - {$IFNDEF DARWIN} - {$linklib c} - {$ENDIF} - {$IFDEF HAIKU} - {$linklib root} - {$ELSE} - {$IFNDEF ANDROID} - {$linklib pthread} + {$IFNDEF DARWIN} + {$linklib c} {$ENDIF} - {$ENDIF} + {$IFDEF HAIKU} + {$linklib root} + {$ELSE} + {$IFNDEF ANDROID} + {$linklib pthread} + {$ENDIF} + {$ENDIF} {$ENDIF} {$IFDEF FPC} - {$PACKRECORDS C} + {$PACKRECORDS C} {$ELSE} - {$DEFINE cdecl attribute(cdecl)} + {$DEFINE cdecl attribute(cdecl)} + type PByte = ^Byte; + type PInteger = ^Integer; + type PLongInt = ^LongInt; {$ENDIF} {$IFDEF DARWIN} - {$IFNDEF IPHONEOS} - {$PASCALMAINNAME SDL_main} - {$linkframework Cocoa} - {$linkframework SDL} - {$linkframework SDL_net} - {$linkframework SDL_image} - {$linkframework SDL_ttf} - {$linkframework SDL_mixer} - {$linkframework OpenGL} - {$ENDIF} + {$IFNDEF IPHONEOS} + {$PASCALMAINNAME SDL_main} + {$linkframework Cocoa} + {$linkframework SDL} + {$linkframework SDL_net} + {$linkframework SDL_image} + {$linkframework SDL_ttf} + {$linkframework SDL_mixer} + {$linkframework OpenGL} + {$ENDIF} {$ENDIF} @@ -76,19 +79,19 @@ SDL_ImageLibName = 'SDL_image.dll'; SDL_NetLibName = 'SDL_net.dll'; {$ELSE} - {$IFDEF DARWIN} + {$IFDEF DARWIN} SDLLibName = 'SDL'; SDL_TTFLibName = 'SDL_ttf'; SDL_MixerLibName = 'SDL_mixer'; SDL_ImageLibName = 'SDL_image'; SDL_NetLibName = 'SDL_net'; - {$ELSE} + {$ELSE} SDLLibName = 'libSDL.so'; SDL_TTFLibName = 'libSDL_ttf.so'; SDL_MixerLibName = 'libSDL_mixer.so'; SDL_ImageLibName = 'libSDL_image.so'; SDL_NetLibName = 'libSDL_net.so'; - {$ENDIF} + {$ENDIF} {$ENDIF} ///////////////////////////////////////////////////////////////// @@ -111,6 +114,10 @@ SDL_ALLEVENTS = $FFFFFFFF; SDL_APPINPUTFOCUS = $02; + + SDL_BUTTON_LEFT = 1; + SDL_BUTTON_MIDDLE = 2; + SDL_BUTTON_RIGHT = 3; SDL_BUTTON_WHEELUP = 4; SDL_BUTTON_WHEELDOWN = 5; @@ -148,6 +155,7 @@ SDL_DOLLARRECORD = $801; SDL_MULTIGESTURE = $802; SDL_CLIPBOARDUPDATE = $900; + SDL_DROPFILE = $1000; SDL_USEREVENT = $8000; SDL_LASTEVENT = $FFFF; // no compatibility events $7000 @@ -262,6 +270,19 @@ AShift = 0; {$ENDIF} + KMOD_NONE = $0000; + KMOD_LSHIFT = $0001; + KMOD_RSHIFT = $0002; + KMOD_LCTRL = $0040; + KMOD_RCTRL = $0080; + KMOD_LALT = $0400; + KMOD_RALT = $0800; + KMOD_LMETA = $0400; + KMOD_RMETA = $0800; + KMOD_NUM = $1000; + KMOD_CAPS = $2000; + KMOD_MODE = $4000; + {* SDL_mixer *} MIX_MAX_VOLUME = 128; MIX_INIT_FLAC = $00000001; @@ -290,7 +311,6 @@ IMG_INIT_PNG = $00000002; IMG_INIT_TIF = $00000004; - {* SDL_EventMask type definition *} ///////////////////////////////////////////////////////////////// /////////////////////// TYPE DEFINITIONS /////////////////////// @@ -306,6 +326,8 @@ PSDL_Renderer = Pointer; PSDL_Texture = Pointer; PSDL_GLContext= Pointer; + TSDL_FingerId = Int64; + TSDL_TouchId = Int64; {$ENDIF} PSDL_Rect = ^TSDL_Rect; @@ -365,7 +387,7 @@ {$ENDIF} end; - SDL_eventaction = (SDL_ADDEVENT = 0, SDL_PEEPEVENT, SDL_GETEVENT); + TSDL_eventaction = (SDL_ADDEVENT, SDL_PEEPEVENT, SDL_GETEVENT); PSDL_Surface = ^TSDL_Surface; TSDL_Surface = record @@ -388,12 +410,10 @@ PSDL_Color = ^TSDL_Color; TSDL_Color = record - case Byte of - 0: ( r: Byte; - g: Byte; - b: Byte; - unused: Byte; ); - 1: ( value: LongWord; ); + r: Byte; + g: Byte; + b: Byte; + unused: Byte; end; @@ -436,13 +456,14 @@ {$IFDEF SDL13} TSDL_KeySym = record scancode: LongInt; - sym: LongInt; + sym: LongWord; modifier: Word; unicode: LongWord; end; TSDL_WindowEvent = record type_: LongWord; + timestamp: LongWord; windowID: LongWord; event: Byte; padding1, padding2, padding3: Byte; @@ -452,6 +473,7 @@ // available in sdl12 but not exposed TSDL_TextEditingEvent = record type_: LongWord; + timestamp: LongWord; windowID: LongWord; text: array[0..31] of Byte; start, lenght: LongInt; @@ -460,15 +482,17 @@ // available in sdl12 but not exposed TSDL_TextInputEvent = record type_: LongWord; + timestamp: LongWord; windowID: LongWord; text: array[0..31] of Byte; end; TSDL_TouchFingerEvent = record type_: LongWord; + timestamp: LongWord; windowId: LongWord; - touchId: Int64; - fingerId: Int64; + touchId: TSDL_TouchId; + fingerId: TSDL_FingerId; state, padding1, padding2, padding3: Byte; x, y: Word; dx, dy: SmallInt; @@ -477,21 +501,24 @@ TSDL_TouchButtonEvent = record type_: LongWord; + timestamp: LongWord; windowId: LongWord; - touchId: Int64; + touchId: TSDL_TouchId; state, button, padding1, padding2: Byte; end; TSDL_MultiGestureEvent = record type_: LongWord; + timestamp: LongWord; windowId: LongWord; - touchId: Int64; + touchId: TSDL_TouchId; dTheta, dDist, x, y: Single; numFingers, padding: Word; end; TSDL_DollarGestureEvent = record type_: LongWord; + timestamp: LongWord; windowId: LongWord; touchId: Int64; gesturedId: Int64; @@ -499,8 +526,15 @@ error: Single; end; + TSDL_DropEvent = record + type_: LongWord; + timestamp: LongWord; + filename: PChar; + end; + TSDL_SysWMEvent = record type_: LongWord; + timestamp: LongWord; msg: Pointer; end; {$ELSE} @@ -526,8 +560,9 @@ TSDL_KeyboardEvent = record {$IFDEF SDL13} type_: LongWord; +// timestamp: LongWord; windowID: LongWord; - state, repeat_, padding2, padding3: Byte; + state, repeat_ {*,padding2, padding3*}: Byte; {$ELSE} type_, which, state: Byte; {$ENDIF} @@ -537,6 +572,7 @@ TSDL_MouseMotionEvent = record {$IFDEF SDL13} type_: LongWord; + timestamp: LongWord; windowID: LongWord; state, padding1, padding2, padding3: Byte; x, y, z, xrel, yrel : LongInt; @@ -549,8 +585,9 @@ TSDL_MouseButtonEvent = record {$IFDEF SDL13} type_: LongWord; + timestamp: LongWord; windowID: LongWord; - buttonm, state, padding1, padding2: Byte; + button, state, padding1, padding2: Byte; x, y: LongInt; {$ELSE} type_, which, button, state: Byte; @@ -561,6 +598,7 @@ TSDL_MouseWheelEvent = record type_: LongWord; {$IFDEF SDL13} + timestamp: LongWord; windowID: LongWord; {$ELSE} which: Byte; @@ -569,7 +607,12 @@ end; TSDL_JoyAxisEvent = record - type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF}; +{$IFDEF SDL13} + type_: LongWord; + timestamp: LongWord; +{$ELSE} + type_: Byte; +{$ENDIF} which: Byte; axis: Byte; {$IFDEF SDL13} @@ -581,7 +624,12 @@ end; TSDL_JoyBallEvent = record - type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF}; +{$IFDEF SDL13} + type_: LongWord; + timestamp: LongWord; +{$ELSE} + type_: Byte; +{$ENDIF} which: Byte; ball: Byte; {$IFDEF SDL13} @@ -593,7 +641,12 @@ end; TSDL_JoyHatEvent = record - type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF}; +{$IFDEF SDL13} + type_: LongWord; + timestamp: LongWord; +{$ELSE} + type_: Byte; +{$ENDIF} which: Byte; hat: Byte; value: Byte; @@ -603,7 +656,12 @@ end; TSDL_JoyButtonEvent = record - type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF}; +{$IFDEF SDL13} + type_: LongWord; + timestamp: LongWord; +{$ELSE} + type_: Byte; +{$ENDIF} which: Byte; button: Byte; state: Byte; @@ -613,12 +671,18 @@ end; TSDL_QuitEvent = record - type_: {$IFDEF SDL13}LongWord{$ELSE}Byte{$ENDIF}; +{$IFDEF SDL13} + type_: LongWord; + timestamp: LongWord; +{$ELSE} + type_: Byte; +{$ENDIF} end; TSDL_UserEvent = record {$IFDEF SDL13} type_: LongWord; + timestamp: LongWord; windowID: LongWord; {$ELSE} type_: Byte; @@ -656,6 +720,7 @@ SDL_TOUCHBUTTONDOWN: (tbutton: TSDL_TouchButtonEvent); SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent); SDL_DOLLARGESTURE: (dgesture: TSDL_DollarGestureEvent); + SDL_DROPFILE: (drop: TSDL_DropEvent); SDL_ALLEVENTS: (foo: shortstring); {$ELSE} case Byte of @@ -680,10 +745,10 @@ TSDL_EventFilter = function( event : PSDL_Event ): Integer; cdecl; + TByteArray = array[0..65535] of Byte; PByteArray = ^TByteArray; - TByteArray = array[0..65535] of Byte; + TLongWordArray = array[0..16383] of LongWord; PLongWordArray = ^TLongWordArray; - TLongWordArray = array[0..16383] of LongWord; PSDL_Thread = Pointer; PSDL_mutex = Pointer; @@ -748,40 +813,42 @@ TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); TMidiSong = record - samples : LongInt; - events : Pointer; - end; + samples : LongInt; + events : Pointer; + end; TMusicUnion = record case Byte of - 0: ( midi : TMidiSong ); - 1: ( ogg : Pointer); - end; + 0: ( midi : TMidiSong ); + 1: ( ogg : Pointer); + end; PMixMusic = ^TMixMusic; TMixMusic = record - end; + end; + + TPostMix = procedure(udata: pointer; stream: PByte; len: LongInt); cdecl; {* SDL_net *} TIPAddress = record - host: LongWord; - port: Word; - end; + host: LongWord; + port: Word; + end; PTCPSocket = ^TTCPSocket; TTCPSocket = record - ready: LongInt; - channel: LongInt; - remoteAddress: TIPaddress; - localAddress: TIPaddress; - sflag: LongInt; - end; + ready: LongInt; + channel: LongInt; + remoteAddress: TIPaddress; + localAddress: TIPaddress; + sflag: LongInt; + end; PSDLNet_SocketSet = ^TSDLNet_SocketSet; TSDLNet_SocketSet = record - numsockets, - maxsockets: LongInt; - sockets: PTCPSocket; - end; + numsockets, + maxsockets: LongInt; + sockets: PTCPSocket; + end; ///////////////////////////////////////////////////////////////// @@ -859,15 +926,18 @@ function SDL_SetHint(name, value: PChar): Boolean; cdecl; external SDLLibName; procedure SDL_StartTextInput; cdecl; external SDLLibName; -function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName; +function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; minType, maxType: LongWord): LongInt; cdecl; external SDLLibName; function SDL_CreateThread(fn: Pointer; name: PChar; data: Pointer): PSDL_Thread; cdecl; external SDLLibName; {$ELSE} function SDL_CreateThread(fn: Pointer; data: Pointer): PSDL_Thread; cdecl; external SDLLibName; -function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: SDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName; +function SDL_PeepEvents(event: PSDL_Event; numevents: LongInt; action: TSDL_eventaction; mask: LongWord): LongInt; cdecl; external SDLLibName; {$ENDIF} function SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName; function SDL_GetKeyName(key: LongWord): PChar; cdecl; external SDLLibName; +function SDL_GetScancodeName(key: LongWord): PChar; cdecl; external SDLLibName; +function SDL_GetKeyFromScancode(key: LongWord): LongInt; cdecl; external SDLLibName; + procedure SDL_PumpEvents; cdecl; external SDLLibName; function SDL_PollEvent(event: PSDL_Event): LongInt; cdecl; external SDLLibName; @@ -887,7 +957,10 @@ function SDL_UnlockMutex(mutex: PSDL_mutex): LongInt; cdecl; external SDLLibName name 'SDL_mutexV'; function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: LongInt): LongInt; cdecl; external SDLLibName; -procedure SDL_GL_SwapBuffers(); cdecl; external SDLLibName; +procedure SDL_GL_SwapBuffers; cdecl; external SDLLibName; + +procedure SDL_LockAudio; cdecl; external SDLLibName; +procedure SDL_UnlockAudio; cdecl; external SDLLibName; function SDL_NumJoysticks: LongInt; cdecl; external SDLLibName; function SDL_JoystickName(idx: LongInt): PChar; cdecl; external SDLLibName; @@ -911,14 +984,15 @@ function SDL_getenv(const text: PChar): PChar; cdecl; external SDLLibName; {$ENDIF} + {* Compatibility between SDL-1.2 and SDL-1.3 *} -procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF} +procedure SDL_WarpMouse(x, y: Word); {$IFDEF SDL13}inline{$ELSE}cdecl; external SDLLibName{$ENDIF}; function SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF}; function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF} procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF} function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF} function SDL_EnableUNICODE(enable: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF} -function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF} +function SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt; {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF} (* SDL_ttf *) function TTF_Init: LongInt; cdecl; external SDL_TTFLibName; @@ -939,6 +1013,7 @@ function Mix_OpenAudio(frequency: LongInt; format: Word; channels: LongInt; chunksize: LongInt): LongInt; cdecl; external SDL_MixerLibName; procedure Mix_CloseAudio; cdecl; external SDL_MixerLibName; +function Mix_QuerySpec(frequency: PLongInt; format: PWord; channels: PLongInt): LongInt; cdecl; external SDL_MixerLibName; function Mix_Volume(channel: LongInt; volume: LongInt): LongInt; cdecl; external SDL_MixerLibName; function Mix_SetDistance(channel: LongInt; distance: Byte): LongInt; cdecl; external SDL_MixerLibName; @@ -961,10 +1036,13 @@ function Mix_PauseMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; function Mix_ResumeMusic(music: PMixMusic): LongInt; cdecl; external SDL_MixerLibName; function Mix_HaltChannel(channel: LongInt): LongInt; cdecl; external SDL_MixerLibName; +function Mix_HaltMusic: LongInt; cdecl; external SDL_MixerLibName; function Mix_FadeInChannelTimed(channel: LongInt; chunk: PMixChunk; loops: LongInt; fadems: LongInt; ticks: LongInt): LongInt; cdecl; external SDL_MixerLibName; function Mix_FadeOutChannel(channel: LongInt; fadems: LongInt): LongInt; cdecl; external SDL_MixerLibName; +procedure Mix_SetPostMix( mix_func: TPostMix; arg: pointer); cdecl; external SDL_MixerLibName; + (* SDL_image *) function IMG_Init(flags: LongInt): LongInt; {$IFDEF SDL_IMAGE_NEWER}cdecl; external SDL_ImageLibName;{$ENDIF} procedure IMG_Quit; {$IFDEF SDL_IMAGE_NEWER}cdecl; external SDL_ImageLibName;{$ENDIF} @@ -996,14 +1074,13 @@ function SDLNet_Read32(buf: Pointer): LongWord; implementation -uses strings, uVariables; +{$IFDEF SDL13} +uses strings, uVariables, uStore; -{$IFDEF SDL13} -// this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode -// compatible function, but we use SDL_CreateWindow, so the window would be NULL -procedure SDL_WarpMouse(x, y: Word); +// compatible functions +procedure SDL_WarpMouse(x, y: Word); inline; begin - SDL_WarpMouseInWindow(SDLwindow, x, y); + WarpMouse(x, y); end; function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar; @@ -1013,37 +1090,41 @@ if (name <> nil) and (namebuf <> nil) then begin strlcopy(namebuf, name, maxlen); - exit(namebuf) + SDL_VideoDriverName:= namebuf end; - exit(name); + SDL_VideoDriverName:= name; end; function SDL_EnableUNICODE(enable: LongInt): LongInt; begin + enable:= enable; // avoid hint SDL_StartTextInput(); - exit(0); + SDL_EnableUNICODE:= 0; end; -function SDL_EnableKeyRepeat(delay_, interval: LongInt): LongInt; +function SDL_EnableKeyRepeat(timedelay, interval: LongInt): LongInt; begin - exit(0); + timedelay:= timedelay; // avoid hint + interval:= interval; // avoid hint + SDL_EnableKeyRepeat:= 0; end; {$ELSE} -function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; const conversionFormat: TSDL_PixelFormat = ( palette: nil; BitsPerPixel: 32; BytesPerPixel: 4; Rloss: 0; Gloss: 0; Bloss: 0; Aloss: 0; Rshift: RShift; Gshift: GShift; Bshift: BShift; Ashift: AShift; RMask: RMask; GMask: GMask; BMask: BMask; AMask: AMask; colorkey: 0; alpha: 255); + +function SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; begin format:= format; - exit(@conversionFormat); + SDL_AllocFormat:= @conversionFormat; end; procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); begin - pixelformat:= pixelformat; + pixelformat:= pixelformat; // avoid hint end; {$ENDIF} @@ -1060,7 +1141,7 @@ {$IFNDEF SDL_MIXER_NEWER} function Mix_Init(flags: LongInt): LongInt; begin - exit(flags); + Mix_Init:= flags; end; procedure Mix_Quit; @@ -1071,7 +1152,7 @@ {$IFNDEF SDL_IMAGE_NEWER} function IMG_Init(flags: LongInt): LongInt; begin - exit(flags); + IMG_Init:= flags; end; procedure IMG_Quit; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/SysUtils.h diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/Types.h diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/VGSHandlers.inc --- a/hedgewars/VGSHandlers.inc Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/VGSHandlers.inc Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ procedure doStepFlake(Gear: PVisualGear; Steps: Longword); var sign: real; + moved: boolean; begin if vobCount = 0 then exit; @@ -38,19 +39,21 @@ begin dec(FrameTicks, vobFrameTicks); inc(Frame); - if Frame = vobFramesCount then Frame:= 0 + if Frame = vobFramesCount then + Frame:= 0 end else if SuddenDeathDmg and (FrameTicks > vobSDFrameTicks) then begin dec(FrameTicks, vobSDFrameTicks); inc(Frame); - if Frame = vobSDFramesCount then Frame:= 0 + if Frame = vobSDFramesCount then + Frame:= 0 end; - X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps; + X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps * Gear^.Scale; if SuddenDeathDmg then - Y:= Y + (dY + tdY + cGravityf * vobSDFallSpeed) * Steps + Y:= Y + (dY + tdY + cGravityf * vobSDFallSpeed) * Steps * Gear^.Scale else - Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps; + Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps * Gear^.Scale; Angle:= Angle + dAngle * Steps; if Angle > 360 then Angle:= Angle - 360 @@ -59,28 +62,61 @@ Angle:= Angle + 360; - if (round(X) >= cLeftScreenBorder) and - (round(X) <= cRightScreenBorder) and - (round(Y) - 75 <= LAND_HEIGHT) and - (Timer > 0) and (Timer-Steps > 0) then + if (round(X) >= cLeftScreenBorder) + and (round(X) <= cRightScreenBorder) + and (round(Y) - 75 <= LAND_HEIGHT) + and (Timer > 0) and (Timer-Steps > 0) then begin - if tdX > 0 then sign := 1 - else sign:= -1; + if tdX > 0 then + sign := 1 + else + sign:= -1; tdX:= tdX - 0.005*Steps*sign; - if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then tdX:= 0; - if tdX > 0 then sign := 1 - else sign:= -1; + if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then + tdX:= 0; + if tdX > 0 then + sign := 1 + else + sign:= -1; tdY:= tdY - 0.005*Steps*sign; - if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; + if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then + tdY:= 0; dec(Timer, Steps) end else begin - if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else - if round(X) > cRightScreenBorder then X:= X - cScreenSpace; - // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards? - if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range) - else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25); + moved:= false; + if round(X) < cLeftScreenBorder then + begin + X:= X + cScreenSpace; + moved:= true + end + else + if round(X) > cRightScreenBorder then + begin + X:= X - cScreenSpace; + moved:= true + end; + // if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards? + if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then + begin + X:= cLeftScreenBorder + random(cScreenSpace); + Y:= Y - (1024 + 250 + random(50)); // TODO - configure in theme (jellies for example could use limited range) + moved:= true + end + else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then + begin + X:= cLeftScreenBorder + random(cScreenSpace); + Y:= Y - (1024 + random(25)); + moved:= true + end; + if moved then + begin + Angle:= random(360); + dx:= 0.0000038654705 * random(10000); + dy:= 0.000003506096 * random(7000); + if random(2) = 0 then dx := -dx + end; Timer:= 0; tdX:= 0; tdY:= 0 @@ -103,29 +139,35 @@ var s: Longword; t: real; begin -Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX) * Steps; +Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX * Gear^.Scale) * Steps; // up-and-down-bounce magic s := (GameTicks + Gear^.Timer) mod 4096; -t := 8 * hwFloat2Float(AngleSin(s mod 2048)); +t := 8 * Gear^.Scale * hwFloat2Float(AngleSin(s mod 2048)); if (s < 2048) then t := -t; Gear^.Y := LAND_HEIGHT - 1184 + LongInt(Gear^.Timer mod 8) + t; -if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else -if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace +if round(Gear^.X) < cLeftScreenBorder then + Gear^.X:= Gear^.X + cScreenSpace +else + if round(Gear^.X) > cRightScreenBorder then + Gear^.X:= Gear^.X - cScreenSpace end; //////////////////////////////////////////////////////////////////////////////// procedure doStepExpl(Gear: PVisualGear; Steps: Longword); +var s: LongInt; begin -Gear^.X:= Gear^.X + Gear^.dX * Steps; +s:= min(Steps, cExplFrameTicks); -Gear^.Y:= Gear^.Y + Gear^.dY * Steps; +Gear^.X:= Gear^.X + Gear^.dX * s; +Gear^.Y:= Gear^.Y + Gear^.dY * s; //Gear^.dY:= Gear^.dY + cGravityf; if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) + if Gear^.Frame = 0 then + DeleteVisualGear(Gear) else begin dec(Gear^.Frame); @@ -243,102 +285,108 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepBubble(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + Gear^.dX * Steps; - Gear^.Y:= Gear^.Y + Gear^.dY * Steps; - Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; +Gear^.X:= Gear^.X + Gear^.dX * Steps; +Gear^.Y:= Gear^.Y + Gear^.dY * Steps; +Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; +Gear^.dX := Gear^.dX / (1.001 * Steps); +Gear^.dY := Gear^.dY / (1.001 * Steps); - Gear^.dX := Gear^.dX / (1.001 * Steps); - Gear^.dY := Gear^.dY / (1.001 * Steps); - - if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then - DeleteVisualGear(Gear) - else - dec(Gear^.FrameTicks, Steps) +if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then + DeleteVisualGear(Gear) +else + dec(Gear^.FrameTicks, Steps) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepSteam(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; +Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps; +Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - if Random(2) = 0 then dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) +if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then + DeleteVisualGear(Gear) + else + begin + if Random(2) = 0 then + dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end +else dec(Gear^.FrameTicks, Steps) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); begin - Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; +Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; - Gear^.scale:= Gear^.scale + 0.0025 * Steps; - Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; +Gear^.scale:= Gear^.scale + 0.0025 * Steps; +Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; - if Gear^.alpha < 0 then DeleteVisualGear(Gear) +if Gear^.alpha < 0 then + DeleteVisualGear(Gear) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; +Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps; +Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; - Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps); - //Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); +Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps); +//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - if Random(2) = 0 then dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) +if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then + DeleteVisualGear(Gear) + else + begin + if Random(2) = 0 then + dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepDust(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; +Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; +Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; - Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps); - Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); +Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps); +Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) +if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then + DeleteVisualGear(Gear) + else + begin + dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepSplash(Gear: PVisualGear; Steps: Longword); begin - if Gear^.FrameTicks <= Steps then - DeleteVisualGear(Gear) - else - dec(Gear^.FrameTicks, Steps); +if Gear^.FrameTicks <= Steps then + DeleteVisualGear(Gear) +else + dec(Gear^.FrameTicks, Steps); end; //////////////////////////////////////////////////////////////////////////////// procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + Gear^.dX * Steps; +Gear^.X:= Gear^.X + Gear^.dX * Steps; - Gear^.Y:= Gear^.Y + Gear^.dY * Steps; - Gear^.dY:= Gear^.dY + cGravityf * Steps; +Gear^.Y:= Gear^.Y + Gear^.dY * Steps; +Gear^.dY:= Gear^.dY + cGravityf * Steps; - if round(Gear^.Y) > cWaterLine then begin +if round(Gear^.Y) > cWaterLine then + begin DeleteVisualGear(Gear); PlaySound(TSound(ord(sndDroplet1) + Random(3))); end; @@ -348,12 +396,14 @@ procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); begin inc(Gear^.Timer, Steps); -if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) +if Gear^.Timer >= Gear^.FrameTicks then + DeleteVisualGear(Gear) else begin Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); - if Gear^.alpha < 0 then Gear^.alpha:= 0; + if Gear^.alpha < 0 then + Gear^.alpha:= 0; end; end; @@ -386,7 +436,7 @@ procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); var i, t: LongInt; begin -for t:= 1 to Steps do +for t:= 1 to min(Steps, Gear^.Timer) do begin dec(Gear^.Timer); if (Gear^.Timer and 15) = 0 then @@ -394,17 +444,18 @@ with thexchar[i] do begin {$WARNINGS OFF} - team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; + team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div cSorterWorkTime; team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; {$WARNINGS ON} end; + end; - if (Gear^.Timer = 0) or (currsorter <> Gear) then - begin - if currsorter = Gear then currsorter:= nil; - DeleteVisualGear(Gear); - exit - end +if (Gear^.Timer = 0) or (currsorter <> Gear) then + begin + if currsorter = Gear then + currsorter:= nil; + DeleteVisualGear(Gear); + exit end end; @@ -414,15 +465,21 @@ t: LongInt; begin Steps:= Steps; // avoid compiler hint + for t:= 0 to Pred(TeamsCount) do with thexchar[t] do begin - dy:= TeamsArray[t]^.DrawHealthY; - dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; team:= TeamsArray[t]; - SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; - SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; - SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; + dy:= team^.DrawHealthY; + dw:= team^.TeamHealthBarWidth - team^.NewTeamHealthBarWidth; + if team^.TeamHealth > 0 then + begin + SortFactor:= team^.Clan^.ClanHealth; + SortFactor:= (SortFactor shl 3) + team^.Clan^.ClanIndex; + SortFactor:= (SortFactor shl 30) + team^.TeamHealth; + end + else + SortFactor:= 0; end; if TeamsCount > 1 then @@ -440,12 +497,13 @@ t:= - 4; for i:= 0 to Pred(TeamsCount) do - with thexchar[i] do - begin - dec(t, team^.HealthTex^.h + 2); - ny:= t; - dy:= dy - ny - end; + with thexchar[i] do + if team^.TeamHealth > 0 then + begin + dec(t, team^.HealthTex^.h + 2); + ny:= t; + dy:= dy - ny + end; Gear^.Timer:= cSorterWorkTime; Gear^.doStep:= @doStepTeamHealthSorterWork; @@ -477,7 +535,8 @@ Steps:= Steps; // avoid compiler hint with Gear^.Hedgehog^ do - if SpeechGear <> nil then SpeechGear^.Timer:= 0; + if SpeechGear <> nil then + SpeechGear^.Timer:= 0; Gear^.Hedgehog^.SpeechGear:= Gear; @@ -536,7 +595,8 @@ Gear^.Y:= Gear^.Y - Gear^.Tex^.h; -if Steps > 1 then Gear^.doStep(Gear, Steps-1); +if Steps > 1 then + Gear^.doStep(Gear, Steps-1); end; //////////////////////////////////////////////////////////////////////////////// @@ -546,10 +606,10 @@ if Gear^.Timer > 64 then begin if Gear^.State = 0 then - begin - DeleteVisualGear(Gear); - exit; - end; + begin + DeleteVisualGear(Gear); + exit; + end; dec(Gear^.State, Gear^.Timer div 65); Gear^.Timer:= Gear^.Timer mod 65; end; @@ -565,7 +625,8 @@ begin inc(Gear^.State, Gear^.Timer div 76); Gear^.Timer:= Gear^.Timer mod 76; - if Gear^.State > 5 then DeleteVisualGear(Gear); + if Gear^.State > 5 then + DeleteVisualGear(Gear); end; end; @@ -588,7 +649,8 @@ for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); Gear^.doStep:= @doStepExplosionWork; -if Steps > 1 then Gear^.doStep(Gear, Steps-1); +if Steps > 1 then + Gear^.doStep(Gear, Steps-1); end; @@ -604,7 +666,8 @@ ShakeCamera(maxMovement); end; -if Gear^.Timer > 250 then DeleteVisualGear(Gear); +if Gear^.Timer > 250 then + DeleteVisualGear(Gear); end; procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); @@ -627,10 +690,13 @@ inc(vg^.FrameTicks, vg^.FrameTicks) end end; -for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); -for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); +for i:= 0 to 15 do + AddVisualGear(gX, gY, vgtExplPart); +for i:= 0 to 15 do + AddVisualGear(gX, gY, vgtExplPart2); Gear^.doStep:= @doStepBigExplosionWork; -if Steps > 1 then Gear^.doStep(Gear, Steps-1); +if Steps > 1 then + Gear^.doStep(Gear, Steps-1); performRumble(); end; @@ -653,10 +719,10 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepBulletHit(Gear: PVisualGear; Steps: Longword); begin - if Gear^.FrameTicks <= Steps then - DeleteVisualGear(Gear) - else - dec(Gear^.FrameTicks, Steps); +if Gear^.FrameTicks <= Steps then + DeleteVisualGear(Gear) +else + dec(Gear^.FrameTicks, Steps); end; //////////////////////////////////////////////////////////////////////////////// @@ -672,12 +738,18 @@ if (FrameTicks mod Frame) = 0 then begin tmp:= Gear^.Tint and $FF; - if tdY >= 0 then inc(tmp) - else dec(tmp); - if tmp < round(dX) then tdY:= 1; - if tmp > round(dY) then tdY:= -1; - if tmp > 255 then tmp := 255; - if tmp < 0 then tmp := 0; + if tdY >= 0 then + inc(tmp) + else + dec(tmp); + if tmp < round(dX) then + tdY:= 1; + if tmp > round(dY) then + tdY:= -1; + if tmp > 255 then + tmp := 255; + if tmp < 0 then + tmp := 0; Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Longword(tmp) end end @@ -686,16 +758,28 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword); begin - inc(Gear^.Timer, Steps); +inc(Gear^.Timer, Steps); - while Gear^.Timer >= 10 do - begin - dec(Gear^.Timer, 10); - if WindBarWidth < Gear^.Tag then inc(WindBarWidth) - else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); - end; +while Gear^.Timer >= 10 do + begin + dec(Gear^.Timer, 10); + if WindBarWidth < Gear^.Tag then + inc(WindBarWidth) + else if WindBarWidth > Gear^.Tag then + dec(WindBarWidth); + end; +if cWindspeedf > Gear^.dAngle then + begin + cWindspeedf := cWindspeedf - Gear^.Angle*Steps; + if cWindspeedf < Gear^.dAngle then cWindspeedf:= Gear^.dAngle; + end +else if cWindspeedf < Gear^.dAngle then + begin + cWindspeedf := cWindspeedf + Gear^.Angle*Steps; + if cWindspeedf > Gear^.dAngle then cWindspeedf:= Gear^.dAngle; + end; -if WindBarWidth = Gear^.Tag then +if (WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle) then DeleteVisualGear(Gear) end; //////////////////////////////////////////////////////////////////////////////// diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/adler32.pas --- a/hedgewars/adler32.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/adler32.pas Sun Oct 28 13:28:23 2012 +0100 @@ -63,9 +63,10 @@ (* As per the license above, noting that this implementation of adler32 was stripped of everything we didn't need. That means no btypes, file loading, and the assembly version disabled. +Also, the structure was removed to simplify C conversion *) -procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint); +function Adler32Update ( var adler :longint; Msg :pointer; Len :longint ) : longint; implementation @@ -73,29 +74,33 @@ $ifdef BASM16 procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint); - //-update Adler32 with Msg data + //-update Adler32 with Msg data const - BASE = 65521; // max. prime < 65536 - NMAX = 5552; // max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^32 + BASE = 65521; // max. prime < 65536 + NMAX = 5552; // max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^32 type - LH = packed record + LH = packed record L,H: word; - end; + end; var - s1,s2: longint; - n: integer; + s1,s2: longint; + n: integer; begin - s1 := LH(adler).L; - s2 := LH(adler).H; - while Len > 0 do begin - if Len 0 do + begin + if Len 0 do begin - if Len0 do + begin + if Len + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include "libavformat/avformat.h" + +#ifndef AVIO_FLAG_WRITE +#define AVIO_FLAG_WRITE AVIO_WRONLY +#endif + +static AVFormatContext* g_pContainer; +static AVOutputFormat* g_pFormat; +static AVStream* g_pAStream; +static AVStream* g_pVStream; +static AVFrame* g_pAFrame; +static AVFrame* g_pVFrame; +static AVCodec* g_pACodec; +static AVCodec* g_pVCodec; +static AVCodecContext* g_pAudio; +static AVCodecContext* g_pVideo; + +static int g_Width, g_Height; +static uint32_t g_Frequency, g_Channels; +static int g_VQuality; +static AVRational g_Framerate; + +static FILE* g_pSoundFile; +static int16_t* g_pSamples; +static int g_NumSamples; + +/* +Initially I wrote code for latest ffmpeg, but on Linux (Ubuntu) +only older version is available from repository. That's why you see here +all of this #if LIBAVCODEC_VERSION_MAJOR < 54. +Actually, it may be possible to remove code for newer version +and use only code for older version. +*/ + +#if LIBAVCODEC_VERSION_MAJOR < 54 +#define OUTBUFFER_SIZE 200000 +static uint8_t g_OutBuffer[OUTBUFFER_SIZE]; +#endif + +// pointer to function from hwengine (uUtils.pas) +static void (*AddFileLogRaw)(const char* pString); + +static void FatalError(const char* pFmt, ...) +{ + const char Buffer[1024]; + va_list VaArgs; + + va_start(VaArgs, pFmt); + vsnprintf(Buffer, 1024, pFmt, VaArgs); + va_end(VaArgs); + + AddFileLogRaw("Error in av-wrapper: "); + AddFileLogRaw(Buffer); + AddFileLogRaw("\n"); + exit(1); +} + +// Function to be called from libav for logging. +// Note: libav can call LogCallback from different threads +// (there is mutex in AddFileLogRaw). +static void LogCallback(void* p, int Level, const char* pFmt, va_list VaArgs) +{ + const char Buffer[1024]; + + vsnprintf(Buffer, 1024, pFmt, VaArgs); + AddFileLogRaw(Buffer); +} + +static void Log(const char* pFmt, ...) +{ + const char Buffer[1024]; + va_list VaArgs; + + va_start(VaArgs, pFmt); + vsnprintf(Buffer, 1024, pFmt, VaArgs); + va_end(VaArgs); + + AddFileLogRaw(Buffer); +} + +static void AddAudioStream() +{ +#if LIBAVFORMAT_VERSION_MAJOR >= 54 + g_pAStream = avformat_new_stream(g_pContainer, g_pACodec); +#else + g_pAStream = av_new_stream(g_pContainer, 1); +#endif + if(!g_pAStream) + { + Log("Could not allocate audio stream\n"); + return; + } + g_pAStream->id = 1; + + g_pAudio = g_pAStream->codec; + + avcodec_get_context_defaults3(g_pAudio, g_pACodec); + g_pAudio->codec_id = g_pACodec->id; + + // put parameters + g_pAudio->sample_fmt = AV_SAMPLE_FMT_S16; + g_pAudio->sample_rate = g_Frequency; + g_pAudio->channels = g_Channels; + + // set quality + g_pAudio->bit_rate = 160000; + + // for codecs that support variable bitrate use it, it should be better + g_pAudio->flags |= CODEC_FLAG_QSCALE; + g_pAudio->global_quality = 1*FF_QP2LAMBDA; + + // some formats want stream headers to be separate + if (g_pFormat->flags & AVFMT_GLOBALHEADER) + g_pAudio->flags |= CODEC_FLAG_GLOBAL_HEADER; + + // open it +#if LIBAVCODEC_VERSION_MAJOR >= 53 + if (avcodec_open2(g_pAudio, g_pACodec, NULL) < 0) +#else + if (avcodec_open(g_pAudio, g_pACodec) < 0) +#endif + { + Log("Could not open audio codec %s\n", g_pACodec->long_name); + return; + } + +#if LIBAVCODEC_VERSION_MAJOR >= 54 + if (g_pACodec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) +#else + if (g_pAudio->frame_size == 0) +#endif + g_NumSamples = 4096; + else + g_NumSamples = g_pAudio->frame_size; + g_pSamples = (int16_t*)av_malloc(g_NumSamples*g_Channels*sizeof(int16_t)); + g_pAFrame = avcodec_alloc_frame(); + if (!g_pAFrame) + { + Log("Could not allocate frame\n"); + return; + } +} + +// returns non-zero if there is more sound +static int WriteAudioFrame() +{ + if (!g_pAStream) + return 0; + + AVPacket Packet = { 0 }; + av_init_packet(&Packet); + + int NumSamples = fread(g_pSamples, 2*g_Channels, g_NumSamples, g_pSoundFile); + +#if LIBAVCODEC_VERSION_MAJOR >= 54 + AVFrame* pFrame = NULL; + if (NumSamples > 0) + { + g_pAFrame->nb_samples = NumSamples; + avcodec_fill_audio_frame(g_pAFrame, g_Channels, AV_SAMPLE_FMT_S16, + (uint8_t*)g_pSamples, NumSamples*2*g_Channels, 1); + pFrame = g_pAFrame; + } + // when NumSamples == 0 we still need to call encode_audio2 to flush + int got_packet; + if (avcodec_encode_audio2(g_pAudio, &Packet, pFrame, &got_packet) != 0) + FatalError("avcodec_encode_audio2 failed"); + if (!got_packet) + return 0; +#else + if (NumSamples == 0) + return 0; + int BufferSize = OUTBUFFER_SIZE; + if (g_pAudio->frame_size == 0) + BufferSize = NumSamples*g_Channels*2; + Packet.size = avcodec_encode_audio(g_pAudio, g_OutBuffer, BufferSize, g_pSamples); + if (Packet.size == 0) + return 1; + if (g_pAudio->coded_frame && g_pAudio->coded_frame->pts != AV_NOPTS_VALUE) + Packet.pts = av_rescale_q(g_pAudio->coded_frame->pts, g_pAudio->time_base, g_pAStream->time_base); + Packet.flags |= AV_PKT_FLAG_KEY; + Packet.data = g_OutBuffer; +#endif + + // Write the compressed frame to the media file. + Packet.stream_index = g_pAStream->index; + if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) + FatalError("Error while writing audio frame"); + return 1; +} + +// add a video output stream +static void AddVideoStream() +{ +#if LIBAVFORMAT_VERSION_MAJOR >= 54 + g_pVStream = avformat_new_stream(g_pContainer, g_pVCodec); +#else + g_pVStream = av_new_stream(g_pContainer, 0); +#endif + if (!g_pVStream) + FatalError("Could not allocate video stream"); + + g_pVideo = g_pVStream->codec; + + avcodec_get_context_defaults3(g_pVideo, g_pVCodec); + g_pVideo->codec_id = g_pVCodec->id; + + // put parameters + // resolution must be a multiple of two + g_pVideo->width = g_Width & ~1; // make even (dimensions should be even) + g_pVideo->height = g_Height & ~1; // make even + /* time base: this is the fundamental unit of time (in seconds) in terms + of which frame timestamps are represented. for fixed-fps content, + timebase should be 1/framerate and timestamp increments should be + identically 1. */ + g_pVideo->time_base.den = g_Framerate.num; + g_pVideo->time_base.num = g_Framerate.den; + //g_pVideo->gop_size = 12; /* emit one intra frame every twelve frames at most */ + g_pVideo->pix_fmt = PIX_FMT_YUV420P; + + // set quality + if (g_VQuality > 100) + g_pVideo->bit_rate = g_VQuality; + else + { + g_pVideo->flags |= CODEC_FLAG_QSCALE; + g_pVideo->global_quality = g_VQuality*FF_QP2LAMBDA; + } + + // some formats want stream headers to be separate + if (g_pFormat->flags & AVFMT_GLOBALHEADER) + g_pVideo->flags |= CODEC_FLAG_GLOBAL_HEADER; + +#if LIBAVCODEC_VERSION_MAJOR < 54 + // for some versions of ffmpeg x264 options must be set explicitly + if (strcmp(g_pVCodec->name, "libx264") == 0) + { + g_pVideo->coder_type = FF_CODER_TYPE_AC; + g_pVideo->flags |= CODEC_FLAG_LOOP_FILTER; + g_pVideo->crf = 23; + g_pVideo->thread_count = 3; + g_pVideo->me_cmp = FF_CMP_CHROMA; + g_pVideo->partitions = X264_PART_I8X8 | X264_PART_I4X4 | X264_PART_P8X8 | X264_PART_B8X8; + g_pVideo->me_method = ME_HEX; + g_pVideo->me_subpel_quality = 7; + g_pVideo->me_range = 16; + g_pVideo->gop_size = 250; + g_pVideo->keyint_min = 25; + g_pVideo->scenechange_threshold = 40; + g_pVideo->i_quant_factor = 0.71; + g_pVideo->b_frame_strategy = 1; + g_pVideo->qcompress = 0.6; + g_pVideo->qmin = 10; + g_pVideo->qmax = 51; + g_pVideo->max_qdiff = 4; + g_pVideo->max_b_frames = 3; + g_pVideo->refs = 3; + g_pVideo->directpred = 1; + g_pVideo->trellis = 1; + g_pVideo->flags2 = CODEC_FLAG2_BPYRAMID | CODEC_FLAG2_MIXED_REFS | CODEC_FLAG2_WPRED | CODEC_FLAG2_8X8DCT | CODEC_FLAG2_FASTPSKIP; + g_pVideo->weighted_p_pred = 2; + } +#endif + + // open the codec +#if LIBAVCODEC_VERSION_MAJOR >= 53 + AVDictionary* pDict = NULL; + if (strcmp(g_pVCodec->name, "libx264") == 0) + av_dict_set(&pDict, "preset", "medium", 0); + + if (avcodec_open2(g_pVideo, g_pVCodec, &pDict) < 0) +#else + if (avcodec_open(g_pVideo, g_pVCodec) < 0) +#endif + FatalError("Could not open video codec %s", g_pVCodec->long_name); + + g_pVFrame = avcodec_alloc_frame(); + if (!g_pVFrame) + FatalError("Could not allocate frame"); + + g_pVFrame->linesize[0] = g_Width; + g_pVFrame->linesize[1] = g_Width/2; + g_pVFrame->linesize[2] = g_Width/2; + g_pVFrame->linesize[3] = 0; +} + +static int WriteFrame(AVFrame* pFrame) +{ + double AudioTime, VideoTime; + + // write interleaved audio frame + if (g_pAStream) + { + VideoTime = (double)g_pVStream->pts.val*g_pVStream->time_base.num/g_pVStream->time_base.den; + do + AudioTime = (double)g_pAStream->pts.val*g_pAStream->time_base.num/g_pAStream->time_base.den; + while (AudioTime < VideoTime && WriteAudioFrame()); + } + + if (!g_pVStream) + return 0; + + AVPacket Packet; + av_init_packet(&Packet); + Packet.data = NULL; + Packet.size = 0; + + g_pVFrame->pts++; + if (g_pFormat->flags & AVFMT_RAWPICTURE) + { + /* raw video case. The API will change slightly in the near + future for that. */ + Packet.flags |= AV_PKT_FLAG_KEY; + Packet.stream_index = g_pVStream->index; + Packet.data = (uint8_t*)pFrame; + Packet.size = sizeof(AVPicture); + + if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) + FatalError("Error while writing video frame"); + return 0; + } + else + { +#if LIBAVCODEC_VERSION_MAJOR >= 54 + int got_packet; + if (avcodec_encode_video2(g_pVideo, &Packet, pFrame, &got_packet) < 0) + FatalError("avcodec_encode_video2 failed"); + if (!got_packet) + return 0; + + if (Packet.pts != AV_NOPTS_VALUE) + Packet.pts = av_rescale_q(Packet.pts, g_pVideo->time_base, g_pVStream->time_base); + if (Packet.dts != AV_NOPTS_VALUE) + Packet.dts = av_rescale_q(Packet.dts, g_pVideo->time_base, g_pVStream->time_base); +#else + Packet.size = avcodec_encode_video(g_pVideo, g_OutBuffer, OUTBUFFER_SIZE, pFrame); + if (Packet.size < 0) + FatalError("avcodec_encode_video failed"); + if (Packet.size == 0) + return 0; + + if( g_pVideo->coded_frame->pts != AV_NOPTS_VALUE) + Packet.pts = av_rescale_q(g_pVideo->coded_frame->pts, g_pVideo->time_base, g_pVStream->time_base); + if( g_pVideo->coded_frame->key_frame ) + Packet.flags |= AV_PKT_FLAG_KEY; + Packet.data = g_OutBuffer; +#endif + // write the compressed frame in the media file + Packet.stream_index = g_pVStream->index; + if (av_interleaved_write_frame(g_pContainer, &Packet) != 0) + FatalError("Error while writing video frame"); + + return 1; + } +} + +void AVWrapper_WriteFrame(uint8_t* pY, uint8_t* pCb, uint8_t* pCr) +{ + g_pVFrame->data[0] = pY; + g_pVFrame->data[1] = pCb; + g_pVFrame->data[2] = pCr; + WriteFrame(g_pVFrame); +} + +void AVWrapper_Init( + void (*pAddFileLogRaw)(const char*), + const char* pFilename, + const char* pDesc, + const char* pSoundFile, + const char* pFormatName, + const char* pVCodecName, + const char* pACodecName, + int Width, int Height, + int FramerateNum, int FramerateDen, + int VQuality) +{ + AddFileLogRaw = pAddFileLogRaw; + av_log_set_callback( &LogCallback ); + + g_Width = Width; + g_Height = Height; + g_Framerate.num = FramerateNum; + g_Framerate.den = FramerateDen; + g_VQuality = VQuality; + + // initialize libav and register all codecs and formats + av_register_all(); + + // find format + g_pFormat = av_guess_format(pFormatName, NULL, NULL); + if (!g_pFormat) + FatalError("Format \"%s\" was not found", pFormatName); + + // allocate the output media context + g_pContainer = avformat_alloc_context(); + if (!g_pContainer) + FatalError("Could not allocate output context"); + + g_pContainer->oformat = g_pFormat; + + // store description of file + av_dict_set(&g_pContainer->metadata, "comment", pDesc, 0); + + // append extesnion to filename + char ext[16]; + strncpy(ext, g_pFormat->extensions, 16); + ext[15] = 0; + ext[strcspn(ext,",")] = 0; + snprintf(g_pContainer->filename, sizeof(g_pContainer->filename), "%s.%s", pFilename, ext); + + // find codecs + g_pVCodec = avcodec_find_encoder_by_name(pVCodecName); + g_pACodec = avcodec_find_encoder_by_name(pACodecName); + + // add audio and video stream to container + g_pVStream = NULL; + g_pAStream = NULL; + + if (g_pVCodec) + AddVideoStream(); + else + Log("Video codec \"%s\" was not found; video will be ignored.\n", pVCodecName); + + if (g_pACodec) + { + g_pSoundFile = fopen(pSoundFile, "rb"); + if (g_pSoundFile) + { + fread(&g_Frequency, 4, 1, g_pSoundFile); + fread(&g_Channels, 4, 1, g_pSoundFile); + AddAudioStream(); + } + else + Log("Could not open %s\n", pSoundFile); + } + else + Log("Audio codec \"%s\" was not found; audio will be ignored.\n", pACodecName); + + if (!g_pAStream && !g_pVStream) + FatalError("No video, no audio, aborting..."); + + // write format info to log + av_dump_format(g_pContainer, 0, g_pContainer->filename, 1); + + // open the output file, if needed + if (!(g_pFormat->flags & AVFMT_NOFILE)) + { + if (avio_open(&g_pContainer->pb, g_pContainer->filename, AVIO_FLAG_WRITE) < 0) + FatalError("Could not open output file (%s)", g_pContainer->filename); + } + + // write the stream header, if any + avformat_write_header(g_pContainer, NULL); + + g_pVFrame->pts = -1; +} + +void AVWrapper_Close() +{ + // output buffered frames + if (g_pVCodec->capabilities & CODEC_CAP_DELAY) + while( WriteFrame(NULL) ); + // output any remaining audio + while( WriteAudioFrame() ); + + // write the trailer, if any. + av_write_trailer(g_pContainer); + + // close the output file + if (!(g_pFormat->flags & AVFMT_NOFILE)) + avio_close(g_pContainer->pb); + + // free everything + if (g_pVStream) + { + avcodec_close(g_pVideo); + av_free(g_pVideo); + av_free(g_pVStream); + av_free(g_pVFrame); + } + if (g_pAStream) + { + avcodec_close(g_pAudio); + av_free(g_pAudio); + av_free(g_pAStream); + av_free(g_pAFrame); + av_free(g_pSamples); + fclose(g_pSoundFile); + } + + av_free(g_pContainer); +} diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/config.inc.in --- a/hedgewars/config.inc.in Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/config.inc.in Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/hwLibrary.pas --- a/hedgewars/hwLibrary.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/hwLibrary.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,17 +16,72 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) -Library hwLibrary; {$INCLUDE "options.inc"} -// Add all your Pascal units to the 'uses' clause below to add them to the program. -// Mark all Pascal procedures/functions that you wish to call from C/C++/Objective-C code using -// 'cdecl; export;' (see the fpclogo.pas unit for an example), and then add C-declarations for -// these procedures/functions to the PascalImports.h file (also in the 'Pascal Sources' group) -// to make these functions available in the C/C++/Objective-C source files -// (add '#include PascalImports.h' near the top of these files if it is not there yet) -uses PascalExports, hwengine{$IFDEF ANDROID}, jni{$ENDIF}; -exports Game, HW_versionInfo; +(* + * When engine is compiled as library this unit will export functions + * as C declarations for convenient library usage in your application + * and language of choice. + * + * See also: C declarations on Wikipedia + * http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl + *) + +Library hwLibrary; + +uses hwengine, uTypes, uConsts, uVariables, uSound, uCommands, uUtils, + uLocale{$IFDEF ANDROID}, jni{$ENDIF}; + +{$INCLUDE "config.inc"} + +// retrieve protocol information +procedure HW_versionInfo(netProto: PLongInt; versionStr: PPChar); cdecl; export; +begin + netProto^:= cNetProtoVersion; + versionStr^:= cVersionString; +end; + +// equivalent to esc+y; when closeFrontend = true the game exits after memory cleanup +procedure HW_terminate(closeFrontend: boolean); cdecl; export; +begin + closeFrontend:= closeFrontend; // avoid hint + ParseCommand('forcequit', true); +end; + +function HW_getWeaponNameByIndex(whichone: LongInt): PChar; cdecl; export; +begin + HW_getWeaponNameByIndex:= (str2pchar(trammo[Ammoz[TAmmoType(whichone+1)].NameId])); +end; + +(*function HW_getWeaponCaptionByIndex(whichone: LongInt): PChar; cdecl; export; +begin + HW_getWeaponCaptionByIndex:= (str2pchar(trammoc[Ammoz[TAmmoType(whichone+1)].NameId])); +end; + +function HW_getWeaponDescriptionByIndex(whichone: LongInt): PChar; cdecl; export; +begin + HW_getWeaponDescriptionByIndex:= (str2pchar(trammod[Ammoz[TAmmoType(whichone+1)].NameId])); +end;*) + +function HW_getNumberOfWeapons: LongInt; cdecl; export; +begin + HW_getNumberOfWeapons:= ord(high(TAmmoType)); +end; + +function HW_getMaxNumberOfHogs: LongInt; cdecl; export; +begin + HW_getMaxNumberOfHogs:= cMaxHHIndex + 1; +end; + +function HW_getMaxNumberOfTeams: LongInt; cdecl; export; +begin + HW_getMaxNumberOfTeams:= cMaxTeams; +end; + +procedure HW_memoryWarningCallback; cdecl; export; +begin + ReleaseSound(false); +end; {$IFDEF ANDROID} function JNI_HW_versionInfoNet(env: PJNIEnv; obj: JObject):JInt;cdecl; @@ -51,10 +106,21 @@ HW_getNumberOfweapons name Java_Prefix + 'HWgetNumberOfWeapons', HW_getMaxNumberOfHogs name Java_Prefix + 'HWgetMaxNumberOfHogs', HW_getMaxNumberOfTeams name Java_Prefix + 'HWgetMaxNumberOfTeams', - HW_terminate name Java_Prefix + 'HWterminate'; + HW_terminate name Java_Prefix + 'HWterminate', + Game; +{$ELSE} +exports + Game, + GenLandPreview, + LoadLocaleWrapper, + HW_versionInfo, + HW_terminate, + HW_getNumberOfWeapons, + HW_getMaxNumberOfHogs, + HW_getMaxNumberOfTeams, + HW_getWeaponNameByIndex, + HW_memoryWarningCallback; {$ENDIF} begin - end. - diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/hwengine.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,20 +1,20 @@ (* -* Hedgewars, a free turn based strategy game -* Copyright (c) 2004-2011 Andrey Korotaev -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; version 2 of the License -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -*) + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) {$INCLUDE "options.inc"} @@ -29,10 +29,14 @@ program hwengine; {$ENDIF} -uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound, - uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions, - sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted - {$IFDEF SDL13}, uTouch{$ENDIF}{$IFDEF ANDROID}, GLUnit{$ENDIF}; +uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler, + uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uAILandMarks, uLandTexture, uCollisions, + SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, uLandPainted + {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF} + {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF} + {$IFDEF ANDROID}, GLUnit{$ENDIF} + ; + {$IFDEF HWLIBRARY} procedure initEverything(complete:boolean); @@ -42,170 +46,190 @@ implementation {$ELSE} -procedure OnDestroy; forward; procedure initEverything(complete:boolean); forward; procedure freeEverything(complete:boolean); forward; {$ENDIF} -//////////////////////////////// -procedure DoTimer(Lag: LongInt); +//////////////////////////////////////////////////////////////////////////////// +function DoTimer(Lag: LongInt): boolean; var s: shortstring; begin - if isPaused = false then - inc(RealTicks, Lag); + DoTimer:= false; + inc(RealTicks, Lag); case GameState of - gsLandGen: begin - GenMap; - ParseCommand('sendlanddigest', true); - GameState:= gsStart; - end; - gsStart: begin - if HasBorder then DisableSomeWeapons; - AddClouds; - AddFlakes; - AssignHHCoords; - AddMiscGears; - StoreLoad; - InitWorld; - ResetKbd; - SoundLoad; - if GameType = gmtSave then - begin - isSEBackup:= isSoundEnabled; - isSoundEnabled:= false - end; - FinishProgress; - PlayMusic; - SetScale(zoom); - ScriptCall('onGameStart'); - GameState:= gsGame; - end; - gsConfirm, - gsGame: begin - DrawWorld(Lag); // never place between ProcessKbd and DoGameTick - bugs due to /put cmd and isCursorVisible - ProcessKbd; - if not isPaused then - begin - DoGameTick(Lag); - ProcessVisualGears(Lag); - end; - end; - gsChat: begin - DrawWorld(Lag); - if not isPaused then - begin - DoGameTick(Lag); - ProcessVisualGears(Lag); - end; - end; - gsExit: begin - isTerminated:= true; - end; - gsSuspend: exit; - end; + gsLandGen: + begin + GenMap; + SetLandTexture; + UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false); + setAILandMarks; + ParseCommand('sendlanddigest', true); + GameState:= gsStart; + end; + gsStart: + begin + if HasBorder then + DisableSomeWeapons; + AddClouds; + AddFlakes; + AssignHHCoords; + AddMiscGears; + StoreLoad(false); + InitWorld; + ResetKbd; + if GameType = gmtSave then + SetSound(false); + FinishProgress; + PlayMusic; + SetScale(zoom); + ScriptCall('onGameStart'); + GameState:= gsGame; + end; + gsConfirm, gsGame: + begin + DrawWorld(Lag); + DoGameTick(Lag); + ProcessVisualGears(Lag); + end; + gsChat: + begin + DrawWorld(Lag); + DoGameTick(Lag); + ProcessVisualGears(Lag); + end; + gsExit: + begin + DoTimer:= true; + end; + gsSuspend: + exit(false); + end; -{$IFDEF SDL13} - SDL_GL_SwapWindow(SDLwindow); -{$ELSE} - SDL_GL_SwapBuffers(); + SwapBuffers; + +{$IFDEF USE_VIDEO_RECORDING} + if flagPrerecording then + SaveCameraPosition; {$ENDIF} if flagMakeCapture then - begin + begin flagMakeCapture:= false; - s:= 'hw_' + FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now()) + inttostr(GameTicks); + {$IFDEF PAS2C} + s:= '/Screenshots/hw'; + {$ELSE} + s:= '/Screenshots/hw_' + FormatDateTime('YYYY-MM-DD_HH-mm-ss', Now()) + inttostr(GameTicks); + {$ENDIF} + // flash playSound(sndShutter); - if MakeScreenshot(s) then WriteLnToConsole('Screenshot saved: ' + s) - else begin + ScreenFade:= sfFromWhite; + ScreenFadeValue:= sfMax; + ScreenFadeSpeed:= 5; + + if MakeScreenshot(s, 1) then + WriteLnToConsole('Screenshot saved: ' + s) + else + begin WriteLnToConsole('Screenshot failed.'); AddChatString(#5 + 'screen capture failed (lack of memory or write permissions)'); end - end; + end; end; -//////////////////// -procedure OnDestroy; -begin - WriteLnToConsole('Freeing resources...'); - FreeActionsList(); - StoreRelease(); - ControllerClose(); - CloseIPC(); - TTF_Quit(); -{$IFDEF SDL13} - SDL_GL_DeleteContext(SDLGLcontext); - SDL_DestroyWindow(SDLwindow); - SDLGLcontext:= nil; - SDLwindow:= nil; -{$ENDIF} - SDL_Quit(); - isTerminated:= false; -end; - -/////////////////// +//////////////////////////////////////////////////////////////////////////////// procedure MainLoop; var event: TSDL_Event; PrevTime, CurrTime: Longword; + isTerminated: boolean; {$IFDEF SDL13} previousGameState: TGameState; {$ELSE} prevFocusState: boolean; {$ENDIF} begin + isTerminated:= false; PrevTime:= SDL_GetTicks; while isTerminated = false do begin SDL_PumpEvents(); + while SDL_PeepEvents(@event, 1, SDL_GETEVENT, {$IFDEF SDL13}SDL_FIRSTEVENT, SDL_LASTEVENT{$ELSE}SDL_ALLEVENTS{$ENDIF}) > 0 do begin case event.type_ of {$IFDEF SDL13} - SDL_KEYDOWN: if GameState = gsChat then + SDL_KEYDOWN: + if GameState = gsChat then // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3 - KeyPressChat(event.key.keysym.sym); + KeyPressChat(SDL_GetKeyFromScancode(event.key.keysym.sym))//TODO correct for keymodifiers + else + ProcessKey(event.key); + SDL_KEYUP: + if GameState <> gsChat then + ProcessKey(event.key); + SDL_WINDOWEVENT: if event.window.event = SDL_WINDOWEVENT_SHOWN then - begin + begin cHasFocus:= true; onFocusStateChanged() - end + end else if event.window.event = SDL_WINDOWEVENT_MINIMIZED then - begin + begin previousGameState:= GameState; GameState:= gsSuspend; - end + end else if event.window.event = SDL_WINDOWEVENT_RESTORED then - begin + begin GameState:= previousGameState; - end +{$IFDEF ANDROID} + //This call is used to reinitialize the glcontext and reload the textures + ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true); +{$ENDIF} + end else if event.window.event = SDL_WINDOWEVENT_RESIZED then - begin - // way too broken right now - (* + begin cNewScreenWidth:= max(2 * (event.window.data1 div 2), cMinScreenWidth); cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight); - cScreenResizeDelay:= RealTicks+500; - *) - end; - SDL_FINGERMOTION: onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId); - SDL_FINGERDOWN: onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); - SDL_FINGERUP: onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); + cScreenResizeDelay:= RealTicks + 500{$IFDEF IPHONEOS}div 2{$ENDIF}; + end; + + SDL_FINGERMOTION: + onTouchMotion(event.tfinger.x, event.tfinger.y,event.tfinger.dx, event.tfinger.dy, event.tfinger.fingerId); + + SDL_FINGERDOWN: + onTouchDown(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); + + SDL_FINGERUP: + onTouchUp(event.tfinger.x, event.tfinger.y, event.tfinger.fingerId); {$ELSE} - SDL_KEYDOWN: if GameState = gsChat then - KeyPressChat(event.key.keysym.unicode); - SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true; - SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true; + SDL_KEYDOWN: + if GameState = gsChat then + KeyPressChat(event.key.keysym.unicode) + else + ProcessKey(event.key); + SDL_KEYUP: + if GameState <> gsChat then + ProcessKey(event.key); + + SDL_MOUSEBUTTONDOWN: + ProcessMouse(event.button, true); + + SDL_MOUSEBUTTONUP: + ProcessMouse(event.button, false); + SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then - begin + begin prevFocusState:= cHasFocus; cHasFocus:= event.active.gain = 1; if prevFocusState xor cHasFocus then onFocusStateChanged() - end; - SDL_VIDEORESIZE: begin + end; + + SDL_VIDEORESIZE: + begin // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts // Change by sheepluva: // Let's only use even numbers for custom width/height since I ran into scaling issues with odd width values. @@ -213,18 +237,24 @@ cNewScreenWidth:= max(2 * (event.resize.w div 2), cMinScreenWidth); cNewScreenHeight:= max(2 * (event.resize.h div 2), cMinScreenHeight); cScreenResizeDelay:= RealTicks+500; - end; + end; {$ENDIF} - SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); - SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); - SDL_JOYBUTTONDOWN: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); - SDL_JOYBUTTONUP: ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); - SDL_QUITEV: isTerminated:= true + SDL_JOYAXISMOTION: + ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value); + SDL_JOYHATMOTION: + ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value); + SDL_JOYBUTTONDOWN: + ControllerButtonEvent(event.jbutton.which, event.jbutton.button, true); + SDL_JOYBUTTONUP: + ControllerButtonEvent(event.jbutton.which, event.jbutton.button, false); + SDL_QUITEV: + isTerminated:= true end; //end case event.type_ of end; //end while SDL_PollEvent(@event) <> 0 do - if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks) and ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then - begin + if (cScreenResizeDelay <> 0) and (cScreenResizeDelay < RealTicks) and + ((cNewScreenWidth <> cScreenWidth) or (cNewScreenHeight <> cScreenHeight)) then + begin cScreenResizeDelay:= 0; cScreenWidth:= cNewScreenWidth; cScreenHeight:= cNewScreenHeight; @@ -232,44 +262,79 @@ ParseCommand('fullscr '+intToStr(LongInt(cFullScreen)), true); WriteLnToConsole('window resize: ' + IntToStr(cScreenWidth) + ' x ' + IntToStr(cScreenHeight)); ScriptOnScreenResize(); - InitCameraBorders() - end; + InitCameraBorders(); + InitTouchInterface(); + end; - if isTerminated = false then - begin - CurrTime:= SDL_GetTicks; - if PrevTime + longword(cTimerInterval) <= CurrTime then - begin - DoTimer(CurrTime - PrevTime); - PrevTime:= CurrTime - end - else SDL_Delay(1); - IPCCheckSock(); - end; + CurrTime:= SDL_GetTicks(); + if PrevTime + longword(cTimerInterval) <= CurrTime then + begin + isTerminated:= DoTimer(CurrTime - PrevTime); + PrevTime:= CurrTime + end + else SDL_Delay(1); + IPCCheckSock(); end; end; -/////////////// +{$IFDEF USE_VIDEO_RECORDING} +procedure RecorderMainLoop; +var oldGameTicks, oldRealTicks, newGameTicks, newRealTicks: LongInt; +begin + if not BeginVideoRecording() then + exit; + DoTimer(0); // gsLandGen -> gsStart + DoTimer(0); // gsStart -> gsGame + + if not LoadNextCameraPosition(newRealTicks, newGameTicks) then + exit; + fastScrolling:= true; + DoGameTick(newGameTicks); + fastScrolling:= false; + oldRealTicks:= 0; + oldGameTicks:= newGameTicks; + + while LoadNextCameraPosition(newRealTicks, newGameTicks) do + begin + IPCCheckSock(); + DoGameTick(newGameTicks - oldGameTicks); + if GameState = gsExit then + break; + ProcessVisualGears(newRealTicks - oldRealTicks); + DrawWorld(newRealTicks - oldRealTicks); + EncodeFrame(); + oldRealTicks:= newRealTicks; + oldGameTicks:= newGameTicks; + end; + StopVideoRecording(); +end; +{$ENDIF} + +//////////////////////////////////////////////////////////////////////////////// procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF}; var p: TPathType; s: shortstring; i: LongInt; begin {$IFDEF HWLIBRARY} - cBits:= 32; - cFullScreen:= false; - cTimerInterval:= 8; + initEverything(true); cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF}; - val(gameArgs[0], ipcPort); - val(gameArgs[1], cScreenWidth); - val(gameArgs[2], cScreenHeight); - val(gameArgs[3], cReducedQuality); + ipcPort:= StrToInt(gameArgs[0]); + cScreenWidth:= StrToInt(gameArgs[1]); + cScreenHeight:= StrToInt(gameArgs[2]); + cReducedQuality:= StrToInt(gameArgs[3]); cLocaleFName:= gameArgs[4]; - if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5) - else cLocale := Copy(cLocaleFName,1,2); + // cFullScreen functionality is platform dependent, ifdef it if you need to modify it + cFullScreen:= false; + + if (Length(cLocaleFName) > 6) then + cLocale := Copy(cLocaleFName,1,5) + else + cLocale := Copy(cLocaleFName,1,2); + UserNick:= gameArgs[5]; - isSoundEnabled:= gameArgs[6] = '1'; - isMusicEnabled:= gameArgs[7] = '1'; + SetSound(gameArgs[6] = '1'); + SetMusic(gameArgs[7] = '1'); cAltDamage:= gameArgs[8] = '1'; PathPrefix:= gameArgs[9]; UserPathPrefix:= '../Documents'; @@ -281,20 +346,22 @@ cOrigScreenWidth:= cScreenWidth; cOrigScreenHeight:= cScreenHeight; - initEverything(true); WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); AddFileLog('Prefix: "' + PathPrefix +'"'); AddFileLog('UserPrefix: "' + UserPathPrefix +'"'); + for i:= 0 to ParamCount do AddFileLog(inttostr(i) + ': ' + ParamStr(i)); for p:= Succ(Low(TPathType)) to High(TPathType) do - if (p <> ptMapCurrent) and (p <> ptData) then UserPathz[p]:= UserPathPrefix + '/Data/' + Pathz[p]; + if (p <> ptMapCurrent) and (p <> ptData) then + UserPathz[p]:= UserPathPrefix + '/Data/' + Pathz[p]; UserPathz[ptData]:= UserPathPrefix + '/Data'; for p:= Succ(Low(TPathType)) to High(TPathType) do - if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p]; + if p <> ptMapCurrent then + Pathz[p]:= PathPrefix + '/' + Pathz[p]; WriteToConsole('Init SDL... '); SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true); @@ -307,9 +374,18 @@ SDLTry(TTF_Init() <> -1, true); WriteLnToConsole(msgOK); - // show main window - if cFullScreen then ParseCommand('fullscr 1', true) - else ParseCommand('fullscr 0', true); +{$IFDEF USE_VIDEO_RECORDING} + if GameType = gmtRecord then + InitOffscreenOpenGL() + else +{$ENDIF} + begin + // show main window + if cFullScreen then + ParseCommand('fullscr 1', true) + else + ParseCommand('fullscr 0', true); + end; ControllerInit(); // has to happen before InitKbdKeyTable to map keys InitKbdKeyTable(); @@ -335,77 +411,74 @@ if recordFileName = '' then begin InitIPC; - SendIPCAndWaitReply('C'); // ask for game config + SendIPCAndWaitReply(_S'C'); // ask for game config end else LoadRecordFromFile(recordFileName); ScriptOnGameInit; - s:= 'eproto ' + inttostr(cNetProtoVersion); SendIPCRaw(@s[0], Length(s) + 1); // send proto version InitTeams(); AssignStores(); - if isSoundEnabled then - InitSound(); + if GameType = gmtRecord then + SetSound(false); + + InitSound(); isDeveloperMode:= false; - TryDo(InitStepsFlags = cifAllInited, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); - ParseCommand('rotmask', true); - MainLoop(); - // clean up SDL and GL context - OnDestroy(); - // clean up all the other memory allocated +{$IFDEF USE_VIDEO_RECORDING} + if GameType = gmtRecord then + RecorderMainLoop() + else +{$ENDIF} + MainLoop(); + + // clean up all the memory allocated freeEverything(true); - if alsoShutdownFrontend then halt; end; +//////////////////////////////////////////////////////////////////////////////// +// As a rule of thumb, every module that is listed in either initEverything or +// freeEverything should come in pair, even if they are stubs. Only use this +// section for inialising variables and remeber that game args overwrite these, +// so handle this section with care. Pay attention to the init/free order too! procedure initEverything (complete:boolean); begin Randomize(); - if complete then cLogfileBase:= 'game' - else cLogfileBase:= 'preview'; + uUtils.initModule(complete); // opens the debug file, must be the first + uVariables.initModule; // inits all global variables + uConsole.initModule; // opens stdout + uCommands.initModule; // helps below + uCommandHandlers.initModule; // registers all messages from frontend - // uConsts does not need initialization as they are all consts - uUtils.initModule; - uMisc.initModule; - uVariables.initModule; - uConsole.initModule; // MUST happen after uMisc - uCommands.initModule; - uCommandHandlers.initModule; - - uLand.initModule; - uLandPainted.initModule; - - uIO.initModule; + uLand.initModule; // computes land + uLandPainted.initModule; // computes drawn land + uIO.initModule; // sets up sockets if complete then begin -{$IFDEF ANDROID}GLUnit.init;{$ENDIF} -{$IFDEF SDL13}uTouch.initModule;{$ENDIF} - uAI.initModule; - //uAIActions does not need initialization - //uAIAmmoTests does not need initialization +{$IFDEF ANDROID}GLUnit.initModule;{$ENDIF} +{$IFDEF USE_TOUCH_INTERFACE}uTouch.initModule;{$ENDIF} +{$IFDEF USE_VIDEO_RECORDING}uVideoRec.initModule;{$ENDIF} //stub + uAI.initModule; uAIMisc.initModule; + uAILandMarks.initModule; //stub uAmmos.initModule; + uCaptions.initModule; + uChat.initModule; uCollisions.initModule; - //uFloat does not need initialization - //uGame does not need initialization uGears.initModule; - uKeys.initModule; - //uLandGraphics does not need initialization - //uLandObjects does not need initialization - //uLandTemplates does not need initialization - uLandTexture.initModule; - //uLocale does not need initialization - uRandom.initModule; + uInputHandler.initModule; //stub + uMisc.initModule; + uLandTexture.initModule; //stub uScript.initModule; uSound.initModule; uStats.initModule; @@ -413,7 +486,6 @@ uTeams.initModule; uVisualGears.initModule; uWorld.initModule; - uCaptions.initModule; end; end; @@ -421,93 +493,91 @@ begin if complete then begin + WriteLnToConsole('Freeing resources...'); + uAI.freeModule; // AI things need to be freed first + uAIMisc.freeModule; //stub + uAILandMarks.freeModule; uCaptions.freeModule; uWorld.freeModule; uVisualGears.freeModule; uTeams.freeModule; - uStore.freeModule; //stub + uInputHandler.freeModule; uStats.freeModule; //stub uSound.freeModule; uScript.freeModule; - uRandom.freeModule; //stub - //uLocale does not need to be freed - //uLandTemplates does not need to be freed + uMisc.freeModule; uLandTexture.freeModule; - //uLandObjects does not need to be freed - //uLandGraphics does not need to be freed - uKeys.freeModule; //stub uGears.freeModule; - //uGame does not need to be freed - //uFloat does not need to be freed uCollisions.freeModule; //stub uChat.freeModule; uAmmos.freeModule; - uAIMisc.freeModule; //stub - //uAIAmmoTests does not need to be freed - //uAIActions does not need to be freed - uAI.freeModule; //stub + uStore.freeModule; // closes SDL +{$IFDEF USE_VIDEO_RECORDING}uVideoRec.freeModule;{$ENDIF} +{$IFDEF USE_TOUCH_INTERFACE}uTouch.freeModule;{$ENDIF} //stub +{$IFDEF ANDROID}GLUnit.freeModule;{$ENDIF} end; - uIO.freeModule; //stub + uIO.freeModule; uLand.freeModule; uLandPainted.freeModule; uCommandHandlers.freeModule; uCommands.freeModule; - uConsole.freeModule; + uConsole.freeModule; // closes stdout uVariables.freeModule; - uUtils.freeModule; - uMisc.freeModule; // uMisc closes the debug log. + uUtils.freeModule; // closes debug file end; -///////////////////////// +//////////////////////////////////////////////////////////////////////////////// procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF}; var Preview: TPreview; begin +{$IFDEF HWLIBRARY} initEverything(false); -{$IFDEF HWLIBRARY} WriteLnToConsole('Preview connecting on port ' + inttostr(port)); ipcPort:= port; + InitStepsFlags:= cifRandomize; {$ENDIF} InitIPC; IPCWaitPongEvent; TryDo(InitStepsFlags = cifRandomize, 'Some parameters not set (flags = ' + inttostr(InitStepsFlags) + ')', true); - Preview:= GenPreview(); + GenPreview(Preview); WriteLnToConsole('Sending preview...'); SendIPCRaw(@Preview, sizeof(Preview)); SendIPCRaw(@MaxHedgehogs, sizeof(byte)); WriteLnToConsole('Preview sent, disconnect'); - CloseIPC(); freeEverything(false); end; {$IFNDEF HWLIBRARY} -///////////////////// +//////////////////////////////////////////////////////////////////////////////// procedure DisplayUsage; var i: LongInt; begin - WriteLn('Wrong argument format: correct configurations is'); - WriteLn(); - WriteLn(' hwengine [options]'); - WriteLn(); - WriteLn('where [options] must be specified either as:'); - WriteLn(' --set-video [screen width] [screen height] [color dept]'); - WriteLn(' --set-audio [volume] [enable music] [enable sounds]'); - WriteLn(' --set-other [language file] [full screen] [show FPS]'); - WriteLn(' --set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]'); - WriteLn(' --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]'); - WriteLn(' --stats-only'); - WriteLn(); - WriteLn('Read documentation online at http://code.google.com/p/hedgewars/wiki/CommandLineOptions for more information'); - WriteLn(); - Write('PARSED COMMAND: '); + WriteLn(stdout, 'Wrong argument format: correct configurations is'); + WriteLn(stdout, ''); + WriteLn(stdout, ' hwengine [options]'); + WriteLn(stdout, ''); + WriteLn(stdout, 'where [options] must be specified either as:'); + WriteLn(stdout, ' --set-video [screen width] [screen height] [color dept]'); + WriteLn(stdout, ' --set-audio [volume] [enable music] [enable sounds]'); + WriteLn(stdout, ' --set-other [language file] [full screen] [show FPS]'); + WriteLn(stdout, ' --set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen]'); + WriteLn(stdout, ' --set-everything [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] [show FPS] [alternate damage] [timer value] [reduced quality]'); + WriteLn(stdout, ' --stats-only'); + WriteLn(stdout, ''); + WriteLn(stdout, 'Read documentation online at http://code.google.com/p/hedgewars/wiki/CommandLineOptions for more information'); + WriteLn(stdout, ''); + Write(stdout, 'PARSED COMMAND: '); + for i:=0 to ParamCount do - Write(ParamStr(i) + ' '); - WriteLn(); + Write(stdout, ParamStr(i) + ' '); + + WriteLn(stdout, ''); end; -//////////////////// +//////////////////////////////////////////////////////////////////////////////// {$INCLUDE "ArgParsers.inc"} procedure GetParams; @@ -515,13 +585,28 @@ if (ParamCount < 3) then GameType:= gmtSyntax else - if (ParamCount = 3) and ((ParamStr(3) = '--stats-only') or (ParamStr(3) = 'landpreview')) then - internalSetGameTypeLandPreviewFromParameters() + if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then + begin + initEverything(false); + ipcPort:= StrToInt(ParamStr(2)); + GameType:= gmtLandPreview; + exit; + end else - if (ParamCount = cDefaultParamNum) then - internalStartGameWithParameters() + begin + initEverything(true); + if (ParamCount = 3) and (ParamStr(3) = '--stats-only') then + playReplayFileWithParameters() else - playReplayFileWithParameters(); + if ParamCount = cDefaultParamNum then + internalStartGameWithParameters() +{$IFDEF USE_VIDEO_RECORDING} + else if ParamCount = cVideorecParamNum then + internalStartVideoRecordingWithParameters() +{$ENDIF} + else + playReplayFileWithParameters(); + end end; //////////////////////////////////////////////////////////////////////////////// @@ -529,14 +614,18 @@ //////////////////////////////////////////////////////////////////////////////// begin GetParams(); - if (Length(cLocaleFName) > 6) then cLocale := Copy(cLocaleFName,1,5) - else cLocale := Copy(cLocaleFName,1,2); + if (Length(cLocaleFName) > 6) then + cLocale := Copy(cLocaleFName,1,5) + else + cLocale := Copy(cLocaleFName,1,2); - if GameType = gmtLandPreview then GenLandPreview() - else if GameType = gmtSyntax then DisplayUsage() + if GameType = gmtLandPreview then + GenLandPreview() + else if GameType = gmtSyntax then + DisplayUsage() else Game(); // return 1 when engine is not called correctly - ExitCode:= LongInt(GameType = gmtSyntax); + halt(LongInt(GameType = gmtSyntax)); {$ENDIF} end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/options.inc --- a/hedgewars/options.inc Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/options.inc Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004, 2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,39 +16,64 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) -{$IFDEF FPC} - {$J+} -{$ELSE} - {$ERROR Only Free Pascal supported!} +{$IFNDEF FPC} + {$ERROR Only FreePascal Compiler is supported!} {$ENDIF} +{$MACRO ON} {$MODE OBJFPC} -{$MACRO ON} +{$DEFINE GLunit:=GL} +{$WRITEABLECONST OFF} +{$IMPLICITEXCEPTIONS OFF} +{$VARSTRINGCHECKS ON} -{$DEFINE GLunit:=GL} +{$DEFINE USE_LUA_SCRIPT} + {$IFDEF ANDROID} - {$DEFINE SDL13} - {$DEFINE HWLIBRARY} - {$DEFINE S3D_DISABLED} - {$DEFINE GLunit:=gles11} - {$DEFINE MOBILE} - {$DEFINE Java_Prefix := 'Java_org_hedgewars_hedgeroid_EngineProtocol_PascalExports_'} + {$DEFINE MOBILE} + {$DEFINE USE_SDLTHREADS} + {$DEFINE USE_CONTEXT_RESTORE} + {$DEFINE Java_Prefix:= 'Java_org_hedgewars_hedgeroid_EngineProtocol_PascalExports_'} {$ENDIF} {$IFDEF IPHONEOS} - {$DEFINE SDL13} - {$DEFINE HWLIBRARY} - {$DEFINE S3D_DISABLED} - {$DEFINE GLunit:=gles11} - {$DEFINE MOBILE} + {$DEFINE MOBILE} +{$ENDIF} + +{$IFDEF MOBILE} + {$DEFINE HWLIBRARY} + {$DEFINE S3D_DISABLED} + {$DEFINE GLunit:=gles11} + {$DEFINE USE_LANDSCAPE_AMMOMENU} + {$DEFINE USE_TOUCH_INTERFACE} +{$ELSE} + {$DEFINE USE_AM_NUMCOLUMN} +{$ENDIF} + + +{$IFDEF WIN32} + {$DEFINE USE_CONTEXT_RESTORE} {$ENDIF} -{$IFNDEF IPHONEOS} - // not needed on ios because it is switched from the compiler command line arguments - {$DEFINE DEBUGFILE} - //{$DEFINE TRACEAIACTIONS} - //{$DEFINE COUNTTICKS} +{$IFDEF DARWIN} + {$IFNDEF IPHONEOS} + {$DEFINE USE_CONTEXT_RESTORE} + {$ENDIF} +{$ENDIF} + +{$IFDEF USE_TOUCH_INTERFACE} + {$DEFINE SDL13} {$ENDIF} -//also available LUA_DISABLED +{$IFDEF PAS2C} + {$DEFINE NOCONSOLE} + {$DEFINE USE_SDLTHREADS} +{$ENDIF} + +{$DEFINE _S:=} +{$DEFINE _P:=} + +//{$DEFINE TRACEAIACTIONS} +//{$DEFINE COUNTTICKS} + diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/pas2c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/pas2c.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,144 @@ +#pragma once + +#include +#include +#include +#include + +typedef union string255_ + { + struct { + char s[256]; + }; + struct { + char len; + char str[255]; + }; + } string255; +typedef struct string192_ + { + char s[193]; + } string192; +typedef struct string31_ + { + char s[32]; + } string31; +typedef struct string15_ + { + char s[16]; + } string15; + +typedef string255 shortstring; +typedef string255 ansistring; + +typedef uint8_t Byte; +typedef int8_t ShortInt; +typedef uint16_t Word; +typedef int16_t SmallInt; +typedef uint32_t LongWord; +typedef int32_t LongInt; +typedef uint64_t QWord; +typedef int64_t Int64; +typedef LongWord Cardinal; + +typedef LongInt Integer; +typedef float extended; +typedef float real; +typedef float single; + +typedef bool boolean; +typedef int LongBool; + +typedef void * pointer; +typedef Byte * PByte; +typedef char * PChar; +typedef LongInt * PLongInt; +typedef LongWord * PLongWord; +typedef Integer * PInteger; +typedef int PtrInt; +typedef wchar_t widechar; + +#define new(a) __new((void **)&a, sizeof(*(a))) +void __new(void ** p, int size); +#define dispose(a) __dispose(a, sizeof(*(a))) +void __dispose(pointer p, int size); + +void * GetMem(int size); +void FreeMem(void * p, int size); + +#define FillChar(a, b, c) __FillChar(&(a), b, c) + +void __FillChar(pointer p, int size, char fill); +string255 _strconcat(string255 a, string255 b); +string255 _strappend(string255 s, char c); +string255 _strprepend(char c, string255 s); +string255 _chrconcat(char a, char b); +bool _strcompare(string255 a, string255 b); +bool _strcomparec(string255 a, char b); +bool _strncompare(string255 a, string255 b); +char * _pchar(string255 s); +string255 pchar2str(char * s); + +int Length(string255 a); +string255 copy(string255 a, int s, int l); +string255 delete(string255 a, int s, int l); +string255 trim(string255 a); + +#define STRINIT(a) {.len = sizeof(a) - 1, .str = a} + + +int length_ar(void * a); + +typedef int file; +typedef int TextFile; +extern int FileMode; +extern int IOResult; +extern int stdout; +extern int stderr; + +#define assign(a, b) assign_(&(a), b) +void assign_(int * f, string255 fileName); +void reset_1(int f, int size); +void reset_2(int f, int size); +#define BlockRead(a, b, c, d) BlockRead_(a, &(b), c, &(d)) +void BlockRead_(int f, void * p, int size, int * sizeRead); +#define BlockWrite(a, b, c) BlockWrite_(a, &(b), c) +void BlockWrite_(int f, void * p, int size); +void close(int f); + +void write(int f, string255 s); +void writeLn(int f, string255 s); + +bool DirectoryExists(string255 dir); +bool FileExists(string255 filename); + +bool odd(int i); + + +typedef int TThreadId; +void ThreadSwitch(); +#define InterlockedIncrement(a) __InterlockedIncrement(&(a)) +#define InterlockedDecrement(a) __InterlockedDecrement(&(a)) +void __InterlockedIncrement(int * a); +void __InterlockedDecrement(int * a); + +bool Assigned(void * a); + +void randomize(); +int random(int max); +int abs(int i); +double sqr(double n); +double sqrt(double n); +int trunc(double n); +int round(double n); + +string255 ParamStr(int n); +int ParamCount(); + +#define val(a, b, c) _val(a, (LongInt*)&(b), (LongInt*)&(c)) +void _val(string255 str, LongInt * a, LongInt * c); + +extern double pi; + +string255 EnumToStr(int a); +string255 ExtractFileName(string255 f); diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/pas2cSystem.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/pas2cSystem.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,148 @@ +system; + +type + Integer = integer; + LongInt = integer; + LongWord = integer; + Cardinal = integer; + PtrInt = integer; + Word = integer; + Byte = integer; + SmallInt = integer; + ShortInt = integer; + QWord = integer; + GLint = integer; + GLuint = integer; + int = integer; + size_t = integer; + + pointer = pointer; + + float = float; + single = float; + double = float; + real = float; + extended = float; + GLfloat = float; + + boolean = boolean; + LongBool = boolean; + + string = string; + shortstring = string; + ansistring = string; + widechar = string; + + char = char; + PChar = ^char; + PPChar = ^Pchar; + + PByte = ^Byte; + PWord = ^Word; + PLongInt = ^LongInt; + PLongWord = ^LongWord; + PInteger = ^Integer; + + Handle = integer; + + png_structp = pointer; + png_size_t = integer; + +var + false, true: boolean; + + write, writeLn, read, readLn: procedure; + + StrLen, ord, Succ, Pred : function : integer; + inc, dec, Low, High, Lo, Hi : function : integer; + odd, even : function : boolean; + + Now : function : integer; + + new, dispose, FillChar, Move : procedure; + + trunc, round : function : integer; + abs, sqr : function : integer; + + StrPas, FormatDateTime, copy, delete, str, pos, trim, LowerCase : function : shortstring; + Length, StrToInt : function : integer; + SetLength, val : procedure; + _pchar : function : PChar; + pchar2str : function : string; + memcpy : procedure; + + assign, rewrite, reset, flush, BlockWrite, BlockRead, close : procedure; + IOResult : integer; + exit, break, halt, continue : procedure; + TextFile, file : Handle; + FileMode : integer; + FileExists, DirectoryExists, eof : function : boolean; + ExtractFileName : function : string; + exitcode : integer; + stdout, stderr : Handle; + + ParamCount : function : integer; + ParamStr : function : string; + + sqrt, arctan2, cos, sin, power : function : float; + pi : float; + + TypeInfo, GetEnumName : function : shortstring; + + UTF8ToUnicode, WrapText: function : shortstring; + + sizeof : function : integer; + + GetMem : function : pointer; + FreeMem : procedure; + + glGetString : function : pchar; + + glBegin, glBindTexture, glBlendFunc, glClear, glClearColor, + glColor4ub, glColorMask, glColorPointer, glDeleteTextures, + glDisable, glDisableClientState, glDrawArrays, glEnable, + glEnableClientState, glEnd, glGenTextures, glGetIntegerv, + glHint, glLineWidth, glLoadIdentity, glMatrixMode, glPopMatrix, + glPushMatrix, glReadPixels, glRotatef, glScalef, glTexCoord2f, + glTexCoordPointer, glTexImage2D, glTexParameterf, + glTexParameteri, glTranslatef, glVertex2d, glVertexPointer, + glViewport, glext_LoadExtension, glDeleteRenderbuffersEXT, + glDeleteFramebuffersEXT, glGenFramebuffersEXT, + glGenRenderbuffersEXT, glBindFramebufferEXT, + glBindRenderbufferEXT, glRenderbufferStorageEXT, + glFramebufferRenderbufferEXT, glFramebufferTexture2DEXT : procedure; + + GL_BGRA, GL_BLEND, GL_CLAMP_TO_EDGE, GL_COLOR_ARRAY, + GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_DEPTH_COMPONENT, + GL_DITHER, GL_EXTENSIONS, GL_FALSE, GL_FASTEST, GL_LINEAR, + GL_LINE_LOOP, GL_LINES, GL_LINE_SMOOTH, GL_LINE_STRIP, + GL_MAX_TEXTURE_SIZE, GL_MODELVIEW, GL_ONE_MINUS_SRC_ALPHA, + GL_PERSPECTIVE_CORRECTION_HINT, GL_PROJECTION, GL_QUADS, + GL_RENDERER, GL_RGBA, GL_RGBA8, GL_SRC_ALPHA, GL_TEXTURE_2D, + GL_TEXTURE_COORD_ARRAY, GL_TEXTURE_MAG_FILTER, + GL_TEXTURE_MIN_FILTER, GL_TEXTURE_PRIORITY, GL_TEXTURE_WRAP_S, + GL_TEXTURE_WRAP_T, GL_TRIANGLE_FAN, GL_TRUE, GL_VENDOR, + GL_VERSION, GL_VERTEX_ARRAY, GLenum, GL_FRAMEBUFFER_EXT, + GL_RENDERBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_COLOR_ATTACHMENT0_EXT, GL_FLOAT, GL_UNSIGNED_BYTE : integer; + + TThreadId : function : integer; + BeginThread, ThreadSwitch : procedure; + InterlockedIncrement, InterlockedDecrement : procedure; + + random : function : integer; + randomize : procedure; + + Assigned : function : boolean; + + _strconcat, _strappend, _strprepend, _chrconcat : function : string; + _strcompare, _strncompare, _strcomparec : function : boolean; + + png_structp, png_set_write_fn, png_get_io_ptr, + png_get_libpng_ver, png_create_write_struct, + png_create_info_struct, png_destroy_write_struct, + png_write_row, png_set_ihdr, png_write_info, + png_write_end : procedure; + + EnumToStr : function : string; + diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAI.pas --- a/hedgewars/uAI.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uAI.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,108 +30,44 @@ implementation uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions, - uAmmos, SysUtils{$IFDEF UNIX}{$IFNDEF ANDROID}, cthreads{$ENDIF}{$ENDIF}, uTypes, - uVariables, uCommands, uUtils, uDebug; + uAmmos, SysUtils{$IFNDEF USE_SDLTHREADS} {$IFDEF UNIX}, cthreads{$ENDIF} {$ENDIF}, uTypes, + uVariables, uCommands, uUtils, uDebug, uAILandMarks; var BestActions: TActions; CanUseAmmo: array [TAmmoType] of boolean; StopThinking: boolean; +{$IFDEF USE_SDLTHREADS} ThinkThread: PSDL_Thread = nil; +{$ELSE} + ThinkThread: TThreadID; +{$ENDIF} hasThread: LongInt; + StartTicks: Longword; procedure FreeActionsList; begin -AddFileLog('FreeActionsList called'); -if hasThread <> 0 then - begin - AddFileLog('Waiting AI thread to finish'); - StopThinking:= true; - repeat - SDL_Delay(10) - until hasThread = 0 - end; + AddFileLog('FreeActionsList called'); + if hasThread <> 0 then + begin + AddFileLog('Waiting AI thread to finish'); + StopThinking:= true; + repeat + SDL_Delay(10) + until hasThread = 0 + end; -with CurrentHedgehog^ do - if Gear <> nil then - if BotLevel <> 0 then - StopMessages(Gear^.Message); + with CurrentHedgehog^ do + if Gear <> nil then + if BotLevel <> 0 then + StopMessages(Gear^.Message); -BestActions.Count:= 0; -BestActions.Pos:= 0 + BestActions.Count:= 0; + BestActions.Pos:= 0 end; -procedure TestAmmos(var Actions: TActions; Me: PGear; isMoved: boolean); -var BotLevel: Byte; - ap: TAttackParams; - Score, i: LongInt; - a, aa: TAmmoType; -begin -BotLevel:= Me^.Hedgehog^.BotLevel; -for i:= 0 to Pred(Targets.Count) do - if (Targets.ar[i].Score >= 0) and (not StopThinking) then - begin - with CurrentHedgehog^ do - a:= CurAmmoType; - aa:= a; - SDL_delay(0); //ThreadSwitch was only a hint - - repeat - if (CanUseAmmo[a]) and - ((not isMoved) or ((AmmoTests[a].flags and amtest_OnTurn) = 0)) then - begin -{$HINTS OFF} - Score:= AmmoTests[a].proc(Me, Targets.ar[i].Point, BotLevel, ap); -{$HINTS ON} - if Actions.Score + Score > BestActions.Score then - if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then - begin - BestActions:= Actions; - inc(BestActions.Score, Score); - - if (ap.Angle > 0) then AddAction(BestActions, aia_LookRight, 0, 200, 0, 0) - else if (ap.Angle < 0) then AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0); - AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0); - if (ap.Time <> 0) then AddAction(BestActions, aia_Timer, ap.Time div 1000, 400, 0, 0); - if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then - begin - ap.Angle:= LongInt(Me^.Angle) - Abs(ap.Angle); - if ap.Angle > 0 then - begin - AddAction(BestActions, aia_Up, aim_push, 300 + random(250), 0, 0); - AddAction(BestActions, aia_Up, aim_release, ap.Angle, 0, 0) - end else if ap.Angle < 0 then - begin - AddAction(BestActions, aia_Down, aim_push, 300 + random(250), 0, 0); - AddAction(BestActions, aia_Down, aim_release, -ap.Angle, 0, 0) - end - end; - if (Ammoz[a].Ammo.Propz and ammoprop_NeedTarget) <> 0 then - begin - AddAction(BestActions, aia_Put, 0, 1, ap.AttackPutX, ap.AttackPutY) - end; - if (Ammoz[a].Ammo.Propz and ammoprop_AttackingPut) = 0 then - begin - AddAction(BestActions, aia_attack, aim_push, 650 + random(300), 0, 0); - AddAction(BestActions, aia_attack, aim_release, ap.Power, 0, 0); - end; - if ap.ExplR > 0 then - AddAction(BestActions, aia_AwareExpl, ap.ExplR, 10, ap.ExplX, ap.ExplY); - end - end; - if a = High(TAmmoType) then a:= Low(TAmmoType) - else inc(a) - until (a = aa) or - (CurrentHedgehog^.MultiShootAttacks > 0) or // shooting same weapon - StopThinking - end -end; - -procedure Walk(Me: PGear); -const FallPixForBranching = cHHRadius * 2 + 8; - cBranchStackSize = 12; - +const cBranchStackSize = 12; type TStackEntry = record WastedTicks: Longword; MadeActions: TActions; @@ -143,12 +79,12 @@ States: array[0..Pred(cBranchStackSize)] of TStackEntry; end; - function Push(Ticks: Longword; const Actions: TActions; const Me: TGear; Dir: integer): boolean; - var bRes: boolean; - begin +function Push(Ticks: Longword; const Actions: TActions; const Me: TGear; Dir: integer): boolean; +var bRes: boolean; +begin bRes:= (Stack.Count < cBranchStackSize) and (Actions.Count < MAXACTIONS - 5); if bRes then - with Stack.States[Stack.Count] do + with Stack.States[Stack.Count] do begin WastedTicks:= Ticks; MadeActions:= Actions; @@ -157,209 +93,455 @@ inc(Stack.Count) end; Push:= bRes - end; +end; - procedure Pop(var Ticks: Longword; var Actions: TActions; var Me: TGear); - begin +procedure Pop(var Ticks: Longword; var Actions: TActions; var Me: TGear); +begin dec(Stack.Count); with Stack.States[Stack.Count] do - begin - Ticks:= WastedTicks; - Actions:= MadeActions; - Me:= Hedgehog - end - end; + begin + Ticks:= WastedTicks; + Actions:= MadeActions; + Me:= Hedgehog + end +end; + + + +procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean); +var BotLevel: Byte; + ap: TAttackParams; + Score, i, dAngle: LongInt; + a, aa: TAmmoType; +begin +BotLevel:= Me^.Hedgehog^.BotLevel; +windSpeed:= hwFloat2Float(cWindSpeed); + +for i:= 0 to Pred(Targets.Count) do + if (Targets.ar[i].Score >= 0) and (not StopThinking) then + begin + with Me^.Hedgehog^ do + a:= CurAmmoType; + aa:= a; +{$IFDEF USE_SDLTHREADS} + SDL_delay(0); //ThreadSwitch was only a hint +{$ELSE} + ThreadSwitch(); +{$ENDIF} + repeat + if (CanUseAmmo[a]) + and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0)) + and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0)) + then + begin +{$HINTS OFF} + Score:= AmmoTests[a].proc(Me, Targets.ar[i].Point, BotLevel, ap); +{$HINTS ON} + if Actions.Score + Score > BestActions.Score then + if (BestActions.Score < 0) or (Actions.Score + Score > BestActions.Score + Byte(BotLevel) * 2048) then + begin + BestActions:= Actions; + inc(BestActions.Score, Score); + BestActions.isWalkingToABetterPlace:= false; + + AddAction(BestActions, aia_Weapon, Longword(a), 300 + random(400), 0, 0); -var Actions: TActions; - ticks, maxticks, steps, tmp: Longword; + if (ap.Angle > 0) then + AddAction(BestActions, aia_LookRight, 0, 200, 0, 0) + else if (ap.Angle < 0) then + AddAction(BestActions, aia_LookLeft, 0, 200, 0, 0); + + if (Ammoz[a].Ammo.Propz and ammoprop_Timerable) <> 0 then + AddAction(BestActions, aia_Timer, ap.Time div 1000, 400, 0, 0); + + if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then + begin + dAngle:= LongInt(Me^.Angle) - Abs(ap.Angle); + if dAngle > 0 then + begin + AddAction(BestActions, aia_Up, aim_push, 300 + random(250), 0, 0); + AddAction(BestActions, aia_Up, aim_release, dAngle, 0, 0) + end + else if dAngle < 0 then + begin + AddAction(BestActions, aia_Down, aim_push, 300 + random(250), 0, 0); + AddAction(BestActions, aia_Down, aim_release, -dAngle, 0, 0) + end + end; + + if (Ammoz[a].Ammo.Propz and ammoprop_NeedTarget) <> 0 then + begin + AddAction(BestActions, aia_Put, 0, 1, ap.AttackPutX, ap.AttackPutY) + end; + + if (Ammoz[a].Ammo.Propz and ammoprop_OscAim) <> 0 then + begin + AddAction(BestActions, aia_attack, aim_push, 350 + random(200), 0, 0); + AddAction(BestActions, aia_attack, aim_release, 1, 0, 0); + + if abs(ap.Angle) > 32 then + begin + AddAction(BestActions, aia_Down, aim_push, 100 + random(150), 0, 0); + AddAction(BestActions, aia_Down, aim_release, 32, 0, 0); + end; + + AddAction(BestActions, aia_waitAngle, ap.Angle, 250, 0, 0); + AddAction(BestActions, aia_attack, aim_push, 1, 0, 0); + AddAction(BestActions, aia_attack, aim_release, 1, 0, 0); + end else + if (Ammoz[a].Ammo.Propz and ammoprop_AttackingPut) = 0 then + begin + AddAction(BestActions, aia_attack, aim_push, 650 + random(300), 0, 0); + AddAction(BestActions, aia_attack, aim_release, ap.Power, 0, 0); + end; + + if (Ammoz[a].Ammo.Propz and ammoprop_Track) <> 0 then + begin + AddAction(BestActions, aia_waitAmmoXY, 0, 12, ap.ExplX, ap.ExplY); + AddAction(BestActions, aia_attack, aim_push, 1, 0, 0); + AddAction(BestActions, aia_attack, aim_release, 7, 0, 0); + end; + + if ap.ExplR > 0 then + AddAction(BestActions, aia_AwareExpl, ap.ExplR, 10, ap.ExplX, ap.ExplY); + end + end; + if a = High(TAmmoType) then + a:= Low(TAmmoType) + else inc(a) + until (a = aa) or (CurrentHedgehog^.MultiShootAttacks > 0) {shooting same weapon} + or StopThinking + end +end; + +procedure Walk(Me: PGear; var Actions: TActions); +const FallPixForBranching = cHHRadius; +var + ticks, maxticks, oldticks, steps, tmp: Longword; BaseRate, BestRate, Rate: integer; GoInfo: TGoInfo; CanGo: boolean; AltMe: TGear; BotLevel: Byte; + a: TAmmoType; begin -ticks:= 0; // avoid compiler hint -Actions.Count:= 0; -Actions.Pos:= 0; -Actions.Score:= 0; +ticks:= 0; +oldticks:= 0; // avoid compiler hint Stack.Count:= 0; + +clearAllMarks; + +for a:= Low(TAmmoType) to High(TAmmoType) do + CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and (HHHasAmmo(Me^.Hedgehog^, a) > 0); + BotLevel:= Me^.Hedgehog^.BotLevel; -tmp:= random(2) + 1; -Push(0, Actions, Me^, tmp); -Push(0, Actions, Me^, tmp xor 3); +if (Me^.State and gstAttacked) = 0 then + maxticks:= Max(0, TurnTimeLeft - 5000 - LongWord(4000 * BotLevel)) +else + maxticks:= TurnTimeLeft; -if (Me^.State and gstAttacked) = 0 then maxticks:= Max(0, TurnTimeLeft - 5000 - LongWord(4000 * BotLevel)) - else maxticks:= TurnTimeLeft; - -if (Me^.State and gstAttacked) = 0 then TestAmmos(Actions, Me, false); +if (Me^.State and gstAttacked) = 0 then + TestAmmos(Actions, Me, false); + BestRate:= RatePlace(Me); BaseRate:= Max(BestRate, 0); +// switch to 'skip' if we can't move because of mouse cursor being shown if (Ammoz[Me^.Hedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then - AddAction(Actions, aia_Weapon, Longword(amNothing), 100 + random(200), 0, 0); - -while (Stack.Count > 0) and (not StopThinking) and (GameFlags and gfArtillery = 0) do + AddAction(Actions, aia_Weapon, Longword(amSkip), 100 + random(200), 0, 0); + +if ((CurrentHedgehog^.MultiShootAttacks = 0) or ((Ammoz[Me^.Hedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoMoveAfter) = 0)) + and (GameFlags and gfArtillery = 0) then begin - Pop(ticks, Actions, Me^); + tmp:= random(2) + 1; + Push(0, Actions, Me^, tmp); + Push(0, Actions, Me^, tmp xor 3); + + while (Stack.Count > 0) and (not StopThinking) do + begin + Pop(ticks, Actions, Me^); - AddAction(Actions, Me^.Message, aim_push, 250, 0, 0); - if (Me^.Message and gmLeft) <> 0 then AddAction(Actions, aia_WaitXL, hwRound(Me^.X), 0, 0, 0) - else AddAction(Actions, aia_WaitXR, hwRound(Me^.X), 0, 0, 0); - steps:= 0; + AddAction(Actions, Me^.Message, aim_push, 250, 0, 0); + if (Me^.Message and gmLeft) <> 0 then + AddAction(Actions, aia_WaitXL, hwRound(Me^.X), 0, 0, 0) + else + AddAction(Actions, aia_WaitXR, hwRound(Me^.X), 0, 0, 0); + + steps:= 0; - while (not StopThinking) do - begin -{$HINTS OFF} - CanGo:= HHGo(Me, @AltMe, GoInfo); -{$HINTS ON} - inc(ticks, GoInfo.Ticks); - if ticks > maxticks then break; + while (not StopThinking) do + begin + {$HINTS OFF} + CanGo:= HHGo(Me, @AltMe, GoInfo); + {$HINTS ON} + oldticks:= ticks; + inc(ticks, GoInfo.Ticks); + if ticks > maxticks then + break; - if (BotLevel < 5) and (GoInfo.JumpType = jmpHJump) then // hjump support - if Push(ticks, Actions, AltMe, Me^.Message) then - with Stack.States[Pred(Stack.Count)] do - begin - if Me^.dX.isNegative then AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0) - else AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0); - AddAction(MadeActions, aia_HJump, 0, 305 + random(50), 0, 0); - AddAction(MadeActions, aia_HJump, 0, 350, 0, 0); - if Me^.dX.isNegative then AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0) - else AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0); - end; - if (BotLevel < 3) and (GoInfo.JumpType = jmpLJump) then // ljump support - if Push(ticks, Actions, AltMe, Me^.Message) then - with Stack.States[Pred(Stack.Count)] do - AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0); + if (BotLevel < 5) + and (GoInfo.JumpType = jmpHJump) + and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped)) + then // hjump support + begin + // check if we could go backwards and maybe ljump over a gap after this hjump + addMark(hwRound(Me^.X), hwRound(Me^.Y), markHJumped); + if Push(ticks, Actions, AltMe, Me^.Message xor 3) then + begin + with Stack.States[Pred(Stack.Count)] do + begin + if Me^.dX.isNegative then + AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0) + else + AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0); + + AddAction(MadeActions, aia_HJump, 0, 305 + random(50), 0, 0); + AddAction(MadeActions, aia_HJump, 0, 350, 0, 0); + + if Me^.dX.isNegative then + AddAction(MadeActions, aia_LookLeft, 0, 200, 0, 0) + else + AddAction(MadeActions, aia_LookRight, 0, 200, 0, 0); + end; + // but first check walking forward + Push(ticks, Stack.States[Pred(Stack.Count)].MadeActions, AltMe, Me^.Message) + end; + end; + if (BotLevel < 3) + and (GoInfo.JumpType = jmpLJump) + and (not checkMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped)) + then // ljump support + begin + addMark(hwRound(Me^.X), hwRound(Me^.Y), markLJumped); + // at final check where we go after jump walking backward + if Push(ticks, Actions, AltMe, Me^.Message xor 3) then + with Stack.States[Pred(Stack.Count)] do + AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0); - if not CanGo then break; - inc(steps); - Actions.actions[Pred(Actions.Count)].Param:= hwRound(Me^.X); - Rate:= RatePlace(Me); - if Rate > BestRate then - begin - BestActions:= Actions; - BestRate:= Rate; - Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo - end - else if Rate < BestRate then break; - if ((Me^.State and gstAttacked) = 0) - and ((steps mod 4) = 0) then TestAmmos(Actions, Me, true); - if GoInfo.FallPix >= FallPixForBranching then - Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right - end; + // push current position so we proceed from it after checking jump+forward walk opportunities + if CanGo then Push(ticks, Actions, Me^, Me^.Message); + + // first check where we go after jump walking forward + if Push(ticks, Actions, AltMe, Me^.Message) then + with Stack.States[Pred(Stack.Count)] do + AddAction(MadeActions, aia_LJump, 0, 305 + random(50), 0, 0); + break + end; - if BestRate > BaseRate then exit - end + // 'not CanGO' means we can't go straight, possible jumps are checked above + if not CanGo then + break; + + inc(steps); + Actions.actions[Pred(Actions.Count)].Param:= hwRound(Me^.X); + Rate:= RatePlace(Me); + if Rate > BestRate then + begin + BestActions:= Actions; + BestActions.isWalkingToABetterPlace:= true; + BestRate:= Rate; + Me^.State:= Me^.State or gstAttacked // we have better place, go there and do not use ammo + end + else if Rate < BestRate then + break; + + if ((Me^.State and gstAttacked) = 0) and ((steps mod 4) = 0) then + begin + if (steps > 4) and checkMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere) then + break; + addMark(hwRound(Me^.X), hwRound(Me^.Y), markWalkedHere); + + TestAmmos(Actions, Me, ticks shr 12 = oldticks shr 12); + end; + + if GoInfo.FallPix >= FallPixForBranching then + Push(ticks, Actions, Me^, Me^.Message xor 3); // aia_Left xor 3 = aia_Right + end {while}; + + if BestRate > BaseRate then + exit + end {while} + end {if} end; function Think(Me: Pointer): ptrint; var BackMe, WalkMe: TGear; - StartTicks: Longword; + switchCount: LongInt; + StartTicks, currHedgehogIndex, itHedgehog, switchesNum, i: Longword; + switchImmediatelyAvailable: boolean; + Actions: TActions; begin InterlockedIncrement(hasThread); StartTicks:= GameTicks; -BackMe:= PGear(Me)^; +currHedgehogIndex:= CurrentTeam^.CurrHedgehog; +itHedgehog:= currHedgehogIndex; +switchesNum:= 0; + +switchImmediatelyAvailable:= (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtSwitcher); +if PGear(Me)^.Hedgehog^.BotLevel <> 5 then + switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch) +else switchCount:= 0; if (PGear(Me)^.State and gstAttacked) = 0 then - if Targets.Count > 0 then - begin + if Targets.Count > 0 then + begin + // iterate over current team hedgehogs + repeat + WalkMe:= CurrentTeam^.Hedgehogs[itHedgehog].Gear^; + + Actions.Count:= 0; + Actions.Pos:= 0; + Actions.Score:= 0; + if switchesNum > 0 then + begin + if not switchImmediatelyAvailable then + begin + // when AI has to use switcher, make it cost smth unless they have a lot of switches + if (switchCount < 10) then Actions.Score:= (-27+switchCount*3)*4000; + AddAction(Actions, aia_Weapon, Longword(amSwitch), 300 + random(200), 0, 0); + AddAction(Actions, aia_attack, aim_push, 300 + random(300), 0, 0); + AddAction(Actions, aia_attack, aim_release, 1, 0, 0); + end; + for i:= 1 to switchesNum do + AddAction(Actions, aia_Switch, 0, 300 + random(200), 0, 0); + end; + Walk(@WalkMe, Actions); + + // find another hog in team + repeat + itHedgehog:= Succ(itHedgehog) mod CurrentTeam^.HedgehogsNumber; + until (itHedgehog = currHedgehogIndex) or (CurrentTeam^.Hedgehogs[itHedgehog].Gear <> nil); + - WalkMe:= BackMe; - Walk(@WalkMe); - if (StartTicks > GameTicks - 1500) and (not StopThinking) then SDL_Delay(1000); - if BestActions.Score < -1023 then - begin - BestActions.Count:= 0; - AddAction(BestActions, aia_Skip, 0, 250, 0, 0); - end; - end else -else begin - while (not StopThinking) and (BestActions.Count = 0) do + inc(switchesNum); + until (not (switchImmediatelyAvailable or (switchCount > 0))) + or StopThinking + or (itHedgehog = currHedgehogIndex) + or BestActions.isWalkingToABetterPlace; + + if (StartTicks > GameTicks - 1500) and (not StopThinking) then + SDL_Delay(1000); + + if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then begin - FillBonuses(true); - WalkMe:= BackMe; - Walk(@WalkMe); - if not StopThinking then SDL_Delay(100) - end - end; -PGear(Me)^.State:= PGear(Me)^.State and not gstHHThinking; + BestActions.Count:= 0; + AddAction(BestActions, aia_Skip, 0, 250, 0, 0); + end; + + end else +else + begin + BackMe:= PGear(Me)^; + while (not StopThinking) and (BestActions.Count = 0) do + begin +(* + // Maybe this would get a bit of movement out of them? Hopefully not *toward* water. Need to check how often he'd choose that strategy + if SuddenDeathDmg and ((hwRound(BackMe.Y)+cWaterRise*2) > cWaterLine) then + AddBonus(hwRound(BackMe.X), hwRound(BackMe.Y), 250, -40); +*) + FillBonuses(true); + WalkMe:= BackMe; + Actions.Count:= 0; + Actions.Pos:= 0; + Actions.Score:= 0; + Walk(@WalkMe, Actions); + if not StopThinking then + SDL_Delay(100) + end + end; + +PGear(Me)^.State:= PGear(Me)^.State and (not gstHHThinking); Think:= 0; InterlockedDecrement(hasThread) end; procedure StartThink(Me: PGear); -var a: TAmmoType; begin if ((Me^.State and (gstAttacking or gstHHJumping or gstMoving)) <> 0) - or isInMultiShoot then exit; +or isInMultiShoot then + exit; -//DeleteCI(Me); // this might break demo +//DeleteCI(Me); // this will break demo/netplay + Me^.State:= Me^.State or gstHHThinking; Me^.Message:= 0; BestActions.Count:= 0; BestActions.Pos:= 0; BestActions.Score:= Low(LongInt); +BestActions.isWalkingToABetterPlace:= false; StopThinking:= false; ThinkingHH:= Me; FillTargets; if Targets.Count = 0 then - begin - OutError('AI: no targets!?', false); - exit - end; + begin + OutError('AI: no targets!?', false); + exit + end; FillBonuses((Me^.State and gstAttacked) <> 0); -for a:= Low(TAmmoType) to High(TAmmoType) do - CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(Me^.Hedgehog^, a); AddFileLog('Enter Think Thread'); -{$IFDEF IPHONEOS} -//TODO: sdl_thread works on device but crashes in simulator, most likely because of outdated toolchain +{$IFDEF USE_SDLTHREADS} +ThinkThread := SDL_CreateThread(@Think{$IFDEF SDL13}, nil{$ENDIF}, Me); +{$ELSE} BeginThread(@Think, Me, ThinkThread); -{$ELSE} -ThinkThread := SDL_CreateThread(@Think{$IFDEF SDL13}, nil{$ENDIF}, Me); -{$ENDIF} {$ENDIF} AddFileLog('Thread started'); end; +//var scoreShown: boolean = false; + procedure ProcessBot; -const StartTicks: Longword = 0; - cStopThinkTime = 40; +const cStopThinkTime = 40; begin with CurrentHedgehog^ do - if (Gear <> nil) - and ((Gear^.State and gstHHDriven) <> 0) - and (TurnTimeLeft < cHedgehogTurnTime - 50) then + if (Gear <> nil) + and ((Gear^.State and gstHHDriven) <> 0) + and (TurnTimeLeft < cHedgehogTurnTime - 50) then if ((Gear^.State and gstHHThinking) = 0) then - if (BestActions.Pos >= BestActions.Count) - and (TurnTimeLeft > cStopThinkTime) then - begin - if Gear^.Message <> 0 then - begin - StopMessages(Gear^.Message); - TryDo((Gear^.Message and gmAllStoppable) = 0, 'Engine bug: AI may break demos playing', true); - end; - if Gear^.Message <> 0 then exit; - StartThink(Gear); - StartTicks:= GameTicks - end else ProcessAction(BestActions, Gear) + if (BestActions.Pos >= BestActions.Count) + and (TurnTimeLeft > cStopThinkTime) then + begin + if Gear^.Message <> 0 then + begin + StopMessages(Gear^.Message); + TryDo((Gear^.Message and gmAllStoppable) = 0, 'Engine bug: AI may break demos playing', true); + end; + + if Gear^.Message <> 0 then + exit; + + //scoreShown:= false; + StartThink(Gear); + StartTicks:= GameTicks + + end else + begin + {if not scoreShown then + begin + if BestActions.Score > 0 then ParseCommand('/say Expected score = ' + inttostr(BestActions.Score div 1024), true); + scoreShown:= true + end;} + ProcessAction(BestActions, Gear) + end else if ((GameTicks - StartTicks) > cMaxAIThinkTime) - or (TurnTimeLeft <= cStopThinkTime) then StopThinking:= true + or (TurnTimeLeft <= cStopThinkTime) then + StopThinking:= true end; procedure initModule; begin hasThread:= 0; + StartTicks:= 0; ThinkThread:= ThinkThread; end; procedure freeModule; begin - + FreeActionsList(); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAIActions.pas --- a/hedgewars/uAIActions.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uAIActions.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,55 +23,65 @@ uses uFloat, uTypes; const MAXACTIONS = 96; - aia_none = 0; - aia_Left = 1; - aia_Right = 2; - aia_Timer = 3; - aia_attack = 4; - aia_Up = 5; - aia_Down = 6; + aia_none = 0; + aia_Left = 1; + aia_Right = 2; + aia_Timer = 3; + aia_attack = 4; + aia_Up = 5; + aia_Down = 6; + aia_Switch = 7; - aia_Weapon = $8000; - aia_WaitXL = $8001; - aia_WaitXR = $8002; - aia_LookLeft = $8003; - aia_LookRight = $8004; - aia_AwareExpl = $8005; - aia_HJump = $8006; - aia_LJump = $8007; - aia_Skip = $8008; - aia_Wait = $8009; - aia_Put = $800A; - - aim_push = $8000; - aim_release = $8001; - ai_specmask = $8000; + aia_Weapon = $8000; + aia_WaitXL = $8001; + aia_WaitXR = $8002; + aia_LookLeft = $8003; + aia_LookRight = $8004; + aia_AwareExpl = $8005; + aia_HJump = $8006; + aia_LJump = $8007; + aia_Skip = $8008; + aia_Wait = $8009; + aia_Put = $800A; + aia_waitAngle = $800B; + aia_waitAmmoXY = $800C; + + aim_push = $8000; + aim_release = $8001; + ai_specmask = $8000; type TAction = record - Action: Longword; - X, Y, Param: LongInt; - Time: Longword; - end; - TActions = record - Count, Pos: Longword; - actions: array[0..Pred(MAXACTIONS)] of TAction; - Score: LongInt; - end; + Action: Longword; + X, Y, Param: LongInt; + Time: Longword; + end; + + TActions = record + Count, Pos: Longword; + actions: array[0..Pred(MAXACTIONS)] of TAction; + Score: LongInt; + isWalkingToABetterPlace: boolean; + end; procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt); procedure ProcessAction(var Actions: TActions; Me: PGear); implementation -uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug, uIO; +uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uIO{$IFDEF TRACEAIACTIONS}, uConsole{$ENDIF}; -const ActionIdToStr: array[0..6] of string[16] = ( +var PrevX: LongInt = 0; + timedelta: Longword = 0; + +const ActionIdToStr: array[0..8] of string[16] = ( {aia_none} '', {aia_Left} 'left', {aia_Right} 'right', {aia_Timer} 'timer', {aia_attack} 'attack', {aia_Up} 'up', -{aia_Down} 'down' +{aia_Down} 'down', +{aia_Switch} 'switch', +{aia_waitAngle} 'waitAngle' ); {$IFDEF TRACEAIACTIONS} @@ -91,121 +101,164 @@ procedure DumpAction(Action: TAction; Me: PGear); begin if (Action.Action and ai_specmask) = 0 then - WriteLnToConsole('AI action: '+ActionIdToStr[Action.Action]) -else begin - WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); - if (Action.Action = aia_WaitXL) or (Action.Action = aia_WaitXR) then - WriteLnToConsole('AI action Wait X = '+IntToStr(Action.Param)+', current X = '+IntToStr(hwRound(Me^.X))) - else if (Action.Action = aia_AwareExpl) then WriteLnToConsole('Aware X = ' + IntToStr(Action.X) + ', Y = ' + IntToStr(Action.Y)); - end + WriteLnToConsole('AI action: '+ActionIdToStr[Action.Action]) +else + begin + WriteLnToConsole('AI action: '+SpecActionIdToStr[Action.Action]); + if (Action.Action = aia_WaitXL) or (Action.Action = aia_WaitXR) then + WriteLnToConsole('AI action Wait X = '+IntToStr(Action.Param)+', current X = '+IntToStr(hwRound(Me^.X))) + + else if (Action.Action = aia_AwareExpl) then + WriteLnToConsole('Aware X = ' + IntToStr(Action.X) + ', Y = ' + IntToStr(Action.Y)); + end end; {$ENDIF} procedure AddAction(var Actions: TActions; Action: Longword; Param: LongInt; TimeDelta: Longword; X, Y: LongInt); begin -with Actions do - begin - actions[Count].Action:= Action; - actions[Count].Param:= Param; - actions[Count].X:= X; - actions[Count].Y:= Y; - if Count > 0 then actions[Count].Time:= TimeDelta - else actions[Count].Time:= GameTicks + TimeDelta; - inc(Count); - TryDo(Count < MAXACTIONS, 'AI: actions overflow', true); - end +if Actions.Count < MAXACTIONS then + with Actions do + begin + actions[Count].Action:= Action; + actions[Count].Param:= Param; + actions[Count].X:= X; + actions[Count].Y:= Y; + if Count > 0 then + actions[Count].Time:= TimeDelta + else + actions[Count].Time:= GameTicks + TimeDelta; + inc(Count); + end +end; + +procedure CheckHang(Me: PGear); +begin +if hwRound(Me^.X) <> PrevX then + begin + PrevX:= hwRound(Me^.X); + timedelta:= 0 + end else + begin + inc(timedelta); + if timedelta > 1700 then + begin + timedelta:= 0; + FreeActionsList + end + end end; procedure ProcessAction(var Actions: TActions; Me: PGear); var s: shortstring; - - procedure CheckHang; - const PrevX: LongInt = 0; - timedelta: Longword = 0; - begin - if hwRound(Me^.X) <> PrevX then - begin - PrevX:= hwRound(Me^.X); - timedelta:= 0 - end else - begin - inc(timedelta); - if timedelta > 1700 then - begin - timedelta:= 0; - FreeActionsList - end - end - end; - begin repeat if Actions.Pos >= Actions.Count then exit; + with Actions.actions[Actions.Pos] do - begin - if Time > GameTicks then exit; - {$IFDEF TRACEAIACTIONS} - DumpAction(Actions.actions[Actions.Pos], Me); - {$ENDIF} - if (Action and ai_specmask) <> 0 then + begin + if Time > GameTicks then + exit; + {$IFDEF TRACEAIACTIONS} + DumpAction(Actions.actions[Actions.Pos], Me); + {$ENDIF} + if (Action and ai_specmask) <> 0 then case Action of - aia_Weapon: SetWeapon(TAmmoType(Param)); - aia_WaitXL: if hwRound(Me^.X) = Param then - begin - Action:= aia_LookLeft; - Time:= GameTicks; - exit - end - else if hwRound(Me^.X) < Param then - begin - //OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); - FreeActionsList; - exit - end - else begin CheckHang; exit end; - aia_WaitXR: if hwRound(Me^.X) = Param then - begin - Action:= aia_LookRight; - Time:= GameTicks; - exit - end - else if hwRound(Me^.X) > Param then - begin - //OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); - FreeActionsList; - exit - end - else begin CheckHang; exit end; - aia_LookLeft: if not Me^.dX.isNegative then - begin - ParseCommand('+left', true); - exit - end else ParseCommand('-left', true); - aia_LookRight: if Me^.dX.isNegative then - begin - ParseCommand('+right', true); - exit - end else ParseCommand('-right', true); - aia_AwareExpl: AwareOfExplosion(X, Y, Param); - aia_HJump: ParseCommand('hjump', true); - aia_LJump: ParseCommand('ljump', true); - aia_Skip: ParseCommand('skip', true); - aia_Put: doPut(X, Y, true); - end else - begin - s:= ActionIdToStr[Action]; - if (Param and ai_specmask) <> 0 then - case Param of - aim_push: s:= '+' + s; - aim_release: s:= '-' + s; - end - else if Param <> 0 then s:= s + ' ' + IntToStr(Param); + aia_Weapon: + SetWeapon(TAmmoType(Param)); + + aia_WaitXL: + if hwRound(Me^.X) = Param then + begin + Action:= aia_LookLeft; + Time:= GameTicks; + exit + end + else if hwRound(Me^.X) < Param then + begin + //OutError('AI: WaitXL assert (' + IntToStr(hwRound(Me^.X)) + ' < ' + IntToStr(Param) + ')', false); + FreeActionsList; + exit + end + else + begin + CheckHang(Me); + exit + end; + + aia_WaitXR: + if hwRound(Me^.X) = Param then + begin + Action:= aia_LookRight; + Time:= GameTicks; + exit + end + else if hwRound(Me^.X) > Param then + begin + //OutError('AI: WaitXR assert (' + IntToStr(hwRound(Me^.X)) + ' > ' + IntToStr(Param) + ')', false); + FreeActionsList; + exit + end + else + begin + CheckHang(Me); + exit + end; + aia_LookLeft: + if not Me^.dX.isNegative then + begin + ParseCommand('+left', true); + exit + end + else + ParseCommand('-left', true); + aia_LookRight: + if Me^.dX.isNegative then + begin + ParseCommand('+right', true); + exit + end + else ParseCommand('-right', true); + aia_AwareExpl: + AwareOfExplosion(X, Y, Param); + + aia_HJump: + ParseCommand('hjump', true); + + aia_LJump: + ParseCommand('ljump', true); + + aia_Skip: + ParseCommand('skip', true); + + aia_Put: + doPut(X, Y, true); + + aia_waitAngle: + if LongInt(Me^.Angle) <> Abs(Param) then exit; + + aia_waitAmmoXY: + if (CurAmmoGear <> nil) and ((hwRound(CurAmmoGear^.X) <> X) or (hwRound(CurAmmoGear^.Y) <> Y)) then exit; + + end + else + begin + s:= ActionIdToStr[Action]; + if (Param and ai_specmask) <> 0 then + case Param of + aim_push: + s:= '+' + s; + + aim_release: + s:= '-' + s; + end + else if Param <> 0 then + s:= s + ' ' + IntToStr(Param); ParseCommand(s, true) end - end; + end; inc(Actions.Pos); if Actions.Pos <= Actions.Count then - inc(Actions.actions[Actions.Pos].Time, GameTicks); + inc(Actions.actions[Actions.Pos].Time, GameTicks); until false end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uAIAmmoTests.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,14 +21,18 @@ unit uAIAmmoTests; interface uses SDLh, uConsts, uFloat, uTypes; -const amtest_OnTurn = $00000001; +const + amtest_Rare = $00000001; // check only several positions + amtest_NoTarget = $00000002; // each pos, but no targetting + +var windSpeed: real; type TAttackParams = record - Time: Longword; - Angle, Power: LongInt; - ExplX, ExplY, ExplR: LongInt; - AttackPutX, AttackPutY: LongInt; - end; + Time: Longword; + Angle, Power: LongInt; + ExplX, ExplY, ExplR: LongInt; + AttackPutX, AttackPutY: LongInt; + end; function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; @@ -39,11 +43,15 @@ function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; TAmmoTest = record @@ -65,11 +73,11 @@ (proc: nil; flags: 0), // amMine (proc: @TestDesertEagle; flags: 0), // amDEagle (proc: nil; flags: 0), // amDynamite - (proc: @TestFirePunch; flags: 0), // amFirePunch - (proc: @TestFirePunch; flags: 0), // amWhip - (proc: @TestBaseballBat; flags: 0), // amBaseballBat + (proc: @TestFirePunch; flags: amtest_NoTarget), // amFirePunch + (proc: @TestWhip; flags: amtest_NoTarget), // amWhip + (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat (proc: nil; flags: 0), // amParachute - (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack + (proc: @TestAirAttack; flags: amtest_Rare), // amAirAttack (proc: nil; flags: 0), // amMineStrike (proc: nil; flags: 0), // amBlowTorch (proc: nil; flags: 0), // amGirder @@ -77,8 +85,8 @@ //(proc: @TestTeleport; flags: amtest_OnTurn), // amTeleport (proc: nil; flags: 0), // amSwitch (proc: @TestMortar; flags: 0), // amMortar - (proc: nil; flags: 0), // amKamikaze - (proc: nil; flags: 0), // amCake + (proc: @TestKamikaze; flags: 0), // amKamikaze + (proc: @TestCake; flags: amtest_Rare or amtest_NoTarget), // amCake (proc: nil; flags: 0), // amSeduction (proc: @TestWatermelon; flags: 0), // amWatermelon (proc: nil; flags: 0), // amHellishBomb @@ -92,7 +100,7 @@ (proc: nil; flags: 0), // amExtraTime (proc: nil; flags: 0), // amLaserSight (proc: nil; flags: 0), // amVampiric - (proc: nil; flags: 0), // amSniperRifle + (proc: @TestSniperRifle; flags: 0), // amSniperRifle (proc: nil; flags: 0), // amJetpack (proc: @TestMolotov; flags: 0), // amMolotov (proc: nil; flags: 0), // amBirdy @@ -102,19 +110,21 @@ (proc: @TestShotgun; flags: 0), // amSineGun (proc: nil; flags: 0), // amFlamethrower (proc: @TestGrenade; flags: 0), // amSMine - (proc: @TestHammer; flags: 0), // amHammer + (proc: @TestHammer; flags: amtest_NoTarget), // amHammer (proc: nil; flags: 0), // amResurrector (proc: nil; flags: 0), // amDrillStrike (proc: nil; flags: 0), // amSnowball (proc: nil; flags: 0), // amTardis (proc: nil; flags: 0), // amStructure - (proc: nil; flags: 0) // amLandGun + (proc: nil; flags: 0), // amLandGun + (proc: nil; flags: 0), // amIceGun + (proc: nil; flags: 0) // amKnife ); const BadTurn = Low(LongInt) div 4; implementation -uses uAIMisc, uVariables, uUtils; +uses uAIMisc, uVariables, uUtils, uGearsHandlers; function Metric(x1, y1, x2, y2: LongInt): LongInt; inline; begin @@ -124,33 +134,11 @@ function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; var Vx, Vy, r, mX, mY: real; rTime: LongInt; - Score, EX, EY: LongInt; + EX, EY: LongInt; valueResult: LongInt; - - function CheckTrace: LongInt; - var x, y, dX, dY: real; - t: LongInt; - value: LongInt; - begin - x:= mX; - y:= mY; - dX:= Vx; - dY:= -Vy; - t:= rTime; - repeat - x:= x + dX; - y:= y + dY; - dX:= dX + cWindSpeedf; - dY:= dY + cGravityf; - dec(t) - until TestCollExcludingMe(Me, trunc(x), trunc(y), 5) or (t <= 0); - EX:= trunc(x); - EY:= trunc(y); - value:= RateExplosion(Me, EX, EY, 101); - if value = 0 then value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; - CheckTrace:= value; - end; - + x, y, dX, dY: real; + t: LongInt; + value: LongInt; begin mX:= hwFloat2Float(Me^.X); mY:= hwFloat2Float(Me^.Y); @@ -159,533 +147,825 @@ ap.ExplR:= 0; valueResult:= BadTurn; repeat - rTime:= rTime + 300 + Level * 50 + random(300); - Vx:= - cWindSpeedf * rTime * 0.5 + (Targ.X + AIrndSign(2) - mX) / rTime; - Vy:= cGravityf * rTime * 0.5 - (Targ.Y - mY) / rTime; - r:= sqrt(sqr(Vx) + sqr(Vy)); - if not (r > 1) then - begin - Score:= CheckTrace; - if valueResult <= Score then + rTime:= rTime + 300 + Level * 50 + random(300); + Vx:= - windSpeed * rTime * 0.5 + (Targ.X + AIrndSign(2) - mX) / rTime; + Vy:= cGravityf * rTime * 0.5 - (Targ.Y - mY) / rTime; + r:= sqr(Vx) + sqr(Vy); + if not (r > 1) then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); - ap.Power:= trunc(r * cMaxPower) - random((Level - 1) * 17 + 1); - ap.ExplR:= 100; - ap.ExplX:= EX; - ap.ExplY:= EY; - valueResult:= Score - end; - end -until (rTime > 4250); + x:= mX; + y:= mY; + dX:= Vx; + dY:= -Vy; + t:= rTime; + repeat + x:= x + dX; + y:= y + dY; + dX:= dX + windSpeed; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); + + EX:= trunc(x); + EY:= trunc(y); + if Level = 1 then + value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) + else value:= RateExplosion(Me, EX, EY, 101); + if value = 0 then + value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; + if valueResult <= value then + begin + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); + ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); + ap.ExplR:= 100; + ap.ExplX:= EX; + ap.ExplY:= EY; + valueResult:= value + end; + end +//until (value > 204800) or (rTime > 4250); not so useful since adding score to the drowning +until rTime > 4250; TestBazooka:= valueResult end; function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; -var Vx, Vy, r: hwFloat; +var Vx, Vy, r: real; rTime: LongInt; - Score, EX, EY: LongInt; + EX, EY: LongInt; valueResult: LongInt; - - function CheckTrace: LongInt; - var x, y, dX, dY: hwFloat; - t: LongInt; - value: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dX:= Vx; - dY:= -Vy; - t:= rTime; - repeat - x:= x + dX; - y:= y + dY; - dX:= dX + cWindSpeed; - dY:= dY + cGravity; - dec(t) - until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t <= 0); - EX:= hwRound(x); - EY:= hwRound(y); - value:= RateExplosion(Me, EX, EY, 5); - if value = 0 then value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; - CheckTrace:= value; - end; + x, y, dX, dY, meX, meY: real; + t: LongInt; + value: LongInt; begin +meX:= hwFloat2Float(Me^.X); +meY:= hwFloat2Float(Me^.Y); ap.Time:= 0; rTime:= 350; ap.ExplR:= 0; valueResult:= BadTurn; repeat - rTime:= rTime + 300 + Level * 50 + random(300); - Vx:= - cWindSpeed * rTime * _0_5 + (int2hwFloat(Targ.X + AIrndSign(2)) - Me^.X) / int2hwFloat(rTime); - Vy:= cGravity * rTime * _0_5 - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(rTime); - r:= Distance(Vx, Vy); - if not (r > _1) then - begin - Score:= CheckTrace; - if valueResult <= Score then + rTime:= rTime + 300 + Level * 50 + random(1000); + Vx:= - windSpeed * rTime * 0.5 + ((Targ.X + AIrndSign(2)) - meX) / rTime; + Vy:= cGravityf * rTime * 0.5 - (Targ.Y - meY) / rTime; + r:= sqr(Vx) + sqr(Vy); + if not (r > 1) then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); - ap.Power:= hwRound(r * cMaxPower) - random((Level - 1) * 17 + 1); - ap.ExplR:= 100; - ap.ExplX:= EX; - ap.ExplY:= EY; - valueResult:= Score - end; + x:= meX; + y:= meY; + dX:= Vx; + dY:= -Vy; + t:= rTime; + repeat + x:= x + dX; + y:= y + dY; + dX:= dX + windSpeed; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); + EX:= trunc(x); + EY:= trunc(y); + + value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall); + if value = 0 then + value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; + + if valueResult <= value then + begin + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9)); + ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1); + ap.ExplR:= 0; + ap.ExplX:= EX; + ap.ExplY:= EY; + valueResult:= value + end; end until (rTime > 4250); TestSnowball:= valueResult end; function TestMolotov(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; -var Vx, Vy, r: hwFloat; +var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; TestTime: Longword; - - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - t: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; - t:= TestTime; - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - dec(t) - until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 7) or (t = 0); - EX:= hwRound(x); - EY:= hwRound(y); - if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 97) // average of 17 attempts, most good, but some failing spectacularly - else CheckTrace:= BadTurn - end; + x, y, dY, meX, meY: real; + t: LongInt; begin +meX:= hwFloat2Float(Me^.X); +meY:= hwFloat2Float(Me^.Y); valueResult:= BadTurn; TestTime:= 0; ap.ExplR:= 0; repeat - inc(TestTime, 300); - Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime); - Vy:= cGravity * (TestTime div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime); - r:= Distance(Vx, Vy); - if not (r > _1) then - begin - Score:= CheckTrace; - if valueResult < Score then + inc(TestTime, 300); + Vx:= (Targ.X - meX) / TestTime; + Vy:= cGravityf * (TestTime div 2) - Targ.Y - meY / TestTime; + r:= sqr(Vx) + sqr(Vy); + if not (r > 1) then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); - ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15); - ap.Time:= TestTime; - ap.ExplR:= 100; - ap.ExplX:= EX; - ap.ExplY:= EY; - valueResult:= Score - end; - end + x:= meX; + y:= meY; + dY:= -Vy; + t:= TestTime; + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0); + EX:= trunc(x); + EY:= trunc(y); + if t < 50 then + Score:= RateExplosion(Me, EX, EY, 97) // average of 17 attempts, most good, but some failing spectacularly + else + Score:= BadTurn; + + if valueResult < Score then + begin + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); + ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); + ap.ExplR:= 100; + ap.ExplX:= EX; + ap.ExplY:= EY; + valueResult:= Score + end; + end until (TestTime > 4250); TestMolotov:= valueResult end; function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; const tDelta = 24; -var Vx, Vy, r: hwFloat; +var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; TestTime: Longword; - - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - t: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; - t:= TestTime; - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - dec(t) - until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); - EX:= hwRound(x); - EY:= hwRound(y); - if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 101) - else CheckTrace:= BadTurn - end; + x, y, meX, meY, dY: real; + t: LongInt; begin valueResult:= BadTurn; TestTime:= 0; ap.ExplR:= 0; +meX:= hwFloat2Float(Me^.X); +meY:= hwFloat2Float(Me^.Y); repeat - inc(TestTime, 1000); - Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); - Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta); - r:= Distance(Vx, Vy); - if not (r > _1) then - begin - Score:= CheckTrace; - if valueResult < Score then + inc(TestTime, 1000); + Vx:= (Targ.X - meX) / (TestTime + tDelta); + Vy:= cGravityf * ((TestTime + tDelta) div 2) - (Targ.Y - meY) / (TestTime + tDelta); + r:= sqr(Vx) + sqr(Vy); + if not (r > 1) then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); - ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15); + x:= meX; + y:= meY; + dY:= -Vy; + t:= TestTime; + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0); + EX:= trunc(x); + EY:= trunc(y); + if t < 50 then + if Level = 1 then + Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) + else Score:= RateExplosion(Me, EX, EY, 101) + else + Score:= BadTurn; + + if valueResult < Score then + begin + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); + ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); ap.Time:= TestTime; ap.ExplR:= 100; ap.ExplX:= EX; ap.ExplY:= EY; valueResult:= Score end; - end -until (TestTime = 4000); + end +//until (Score > 204800) or (TestTime > 4000); +until TestTime > 4000; TestGrenade:= valueResult end; function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; const tDelta = 24; -var Vx, Vy, r: hwFloat; +var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; TestTime: Longword; - - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - t: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; - t:= TestTime; - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - dec(t) - until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); - EX:= hwRound(x); - EY:= hwRound(y); - if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 41) - else CheckTrace:= BadTurn - end; + x, y, dY, meX, meY: real; + t: LongInt; begin valueResult:= BadTurn; -TestTime:= 0; +TestTime:= 500; ap.ExplR:= 0; +meX:= hwFloat2Float(Me^.X); +meY:= hwFloat2Float(Me^.Y); repeat - inc(TestTime, 1000); - // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster - if Me^.X _1) then - begin - Score:= CheckTrace; + inc(TestTime, 900); + // Try to overshoot slightly, seems to pay slightly better dividends in terms of hitting cluster + if meX 1) then + begin + x:= meX; + y:= meY; + dY:= -Vy; + t:= TestTime; + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t = 0); + EX:= trunc(x); + EY:= trunc(y); + if t < 50 then + Score:= RateExplosion(Me, EX, EY, 41) + else + Score:= BadTurn; + if valueResult < Score then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); - ap.Power:= hwRound(r * cMaxPower * _0_9) + AIrndSign(random(Level) * 15); - ap.Time:= TestTime; + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); + ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); + ap.Time:= TestTime div 1000 * 1000; ap.ExplR:= 90; ap.ExplX:= EX; ap.ExplY:= EY; valueResult:= Score end; end -until (TestTime = 4000); +until (TestTime = 4100); TestClusterBomb:= valueResult end; function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; const tDelta = 24; -var Vx, Vy, r: hwFloat; +var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; TestTime: Longword; - - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - t: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; - t:= TestTime; - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - dec(t) - until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0); - EX:= hwRound(x); - EY:= hwRound(y); - if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 381) - else CheckTrace:= BadTurn - end; + x, y, dY, meX, meY: real; + t: LongInt; begin valueResult:= BadTurn; -TestTime:= 0; +TestTime:= 500; ap.ExplR:= 0; +meX:= hwFloat2Float(Me^.X); +meY:= hwFloat2Float(Me^.Y); repeat - inc(TestTime, 1000); - Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta); - Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y-200) - Me^.Y) / int2hwFloat(TestTime + tDelta); - r:= Distance(Vx, Vy); - if not (r > _1) then - begin - Score:= CheckTrace; - if valueResult < Score then + inc(TestTime, 900); + Vx:= (Targ.X - meX) / (TestTime + tDelta); + Vy:= cGravityf * ((TestTime + tDelta) div 2) - ((Targ.Y-50) - meY) / (TestTime + tDelta); + r:= sqr(Vx)+sqr(Vy); + if not (r > 1) then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); - ap.Power:= hwRound(r * cMaxPower * _0_9) + AIrndSign(random(Level) * 15); - ap.Time:= TestTime; - ap.ExplR:= 300; - ap.ExplX:= EX; - ap.ExplY:= EY; - valueResult:= Score - end; - end -until (TestTime = 4000); + x:= meX; + y:= meY; + dY:= -Vy; + t:= TestTime; + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravityf; + dec(t) + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 6))) or (t = 0); + + EX:= trunc(x); + EY:= trunc(y); + if t < 50 then + Score:= RateExplosion(Me, EX, EY, 200) + RateExplosion(Me, EX, EY + 120, 200) + else + Score:= BadTurn; + + if valueResult < Score then + begin + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); + ap.Power:= trunc(sqrt(r) * cMaxPower) + AIrndSign(random(Level) * 15); + ap.Time:= TestTime div 1000 * 1000; + ap.ExplR:= 300; + ap.ExplX:= EX; + ap.ExplY:= EY; + valueResult:= Score + end; + end +until (TestTime = 4100); TestWatermelon:= valueResult end; + + function Solve(TX, TY, MX, MY: LongInt): LongWord; + var A, B, D, T: real; + C: LongInt; + begin + A:= sqr(cGravityf); + B:= - cGravityf * (TY - MY) - 1; + C:= sqr(TY - MY) + sqr(TX - MX); + D:= sqr(B) - A * C; + if D >= 0 then + begin + D:= sqrt(D) - B; + if D >= 0 then + T:= sqrt(D * 2 / A) + else + T:= 0; + Solve:= trunc(T) + end + else + Solve:= 0 + end; + function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; //const tDelta = 24; -var Vx, Vy: hwFloat; - Score, EX, EY, valueResult: LongInt; +var Vx, Vy: real; + Score, EX, EY: LongInt; TestTime: Longword; + x, y, dY, meX, meY: real; +begin + TestMortar:= BadTurn; + ap.ExplR:= 0; - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - value: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; + meX:= hwFloat2Float(Me^.X); + meY:= hwFloat2Float(Me^.Y); - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - EX:= hwRound(x); - EY:= hwRound(y); - until TestCollExcludingMe(Me, EX, EY, 5) or (EY > cWaterLine); + if (Level > 2) then + exit(BadTurn); + + TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY)); - if (EY < cWaterLine) and not dY.isNegative then - begin - value:= RateExplosion(Me, EX, EY, 91); - if (value = 0) then - if (dY > _0_15) then - value:= - abs(Targ.Y - EY) div 32 - else - value:= BadTurn - else if (value < 0) then value:= BadTurn - end - else - value:= BadTurn; + if TestTime = 0 then + exit(BadTurn); - CheckTrace:= value; - end; + Vx:= (Targ.X - meX) / TestTime; + Vy:= cGravityf * (TestTime div 2) - (Targ.Y - meY) / TestTime; + + x:= meX; + y:= meY; + dY:= -Vy; - function Solve: LongWord; - var A, B, D, T: hwFloat; - C: LongInt; - begin - A:= hwSqr(cGravity) * _0_25; - B:= - cGravity * (Targ.Y - hwRound(Me^.Y)) - _1; - C:= sqr(Targ.Y - hwRound(Me^.Y)) + sqr(Targ.X - hwRound(Me^.X)); - D:= hwSqr(B) - (A * C * 4); - if D.isNegative = false then - begin - D:= ( - B + hwSqrt(D)) * _0_5 / A; - if D.isNegative = false then - T:= hwSqrt(D) + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravityf; + EX:= trunc(x); + EY:= trunc(y); + until (((Me = CurrentHedgehog^.Gear) and TestColl(EX, EY, 4)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, EX, EY, 4))) or (EY > cWaterLine); + + if (EY < cWaterLine) and (dY >= 0) then + begin + Score:= RateExplosion(Me, EX, EY, 91); + if (Score = 0) then + if (dY > 0.15) then + Score:= - abs(Targ.Y - EY) div 32 else - T:= _0; - Solve:= hwRound(T) - end else Solve:= 0 - end; - -begin -valueResult:= BadTurn; -ap.ExplR:= 0; - -if (Level > 2) then exit(BadTurn); + Score:= BadTurn + else if (Score < 0) then + Score:= BadTurn + end + else + Score:= BadTurn; -TestTime:= Solve; - -if TestTime = 0 then exit(BadTurn); - - Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime); - Vy:= cGravity * (TestTime div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime); - - Score:= CheckTrace; - if valueResult < Score then + if BadTurn < Score then begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); + ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); ap.Power:= 1; ap.ExplR:= 100; ap.ExplX:= EX; ap.ExplY:= EY; - valueResult:= Score + TestMortar:= Score end; - -TestMortar:= valueResult; end; function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; const - MIN_RANGE = 80; - MAX_RANGE = 400; -var Vx, Vy, x, y: hwFloat; + MIN_RANGE = 80; + MAX_RANGE = 400; +var Vx, Vy, x, y: real; rx, ry, valueResult: LongInt; range: integer; begin +TestShotgun:= BadTurn; ap.ExplR:= 0; ap.Time:= 0; ap.Power:= 1; -x:= Me^.X; -y:= Me^.Y; -range:= Metric(hwRound(x), hwRound(y), Targ.X, Targ.Y); -if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then exit(BadTurn); -Vx:= (int2hwFloat(Targ.X) - x) * _1div1024; -Vy:= (int2hwFloat(Targ.Y) - y) * _1div1024; -ap.Angle:= DxDy2AttackAngle(Vx, -Vy); +x:= hwFloat2Float(Me^.X); +y:= hwFloat2Float(Me^.Y); +range:= Metric(trunc(x), trunc(y), Targ.X, Targ.Y); +if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then + exit(BadTurn); + +Vx:= (Targ.X - x) * 1 / 1024; +Vy:= (Targ.Y - y) * 1 / 1024; +ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); repeat - x:= x + vX; - y:= y + vY; - rx:= hwRound(x); - ry:= hwRound(y); - if TestCollExcludingMe(Me, rx, ry, 2) then - begin - x:= x + vX * 8; - y:= y + vY * 8; - valueResult:= RateShotgun(Me, rx, ry); + x:= x + vX; + y:= y + vY; + rx:= trunc(x); + ry:= trunc(y); + if ((Me = CurrentHedgehog^.Gear) and TestColl(rx, ry, 2)) or + ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, rx, ry, 2)) then + begin + x:= x + vX * 8; + y:= y + vY * 8; + valueResult:= RateShotgun(Me, vX, vY, rx, ry); - if valueResult = 0 then - valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 + if valueResult = 0 then + valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 else - dec(valueResult, Level * 4000); - exit(valueResult * 27 div 20) // 27/20 is reuse bonus - end -until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) - or (x.isNegative) - or (y.isNegative) - or (x.Round > LongWord(LAND_WIDTH)) - or (y.Round > LongWord(LAND_HEIGHT)); + dec(valueResult, Level * 4000); + // 27/20 is reuse bonus + exit(valueResult * 27 div 20) + end +until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4) + or (x < 0) + or (y < 0) + or (trunc(x) > LAND_WIDTH) + or (trunc(y) > LAND_HEIGHT); TestShotgun:= BadTurn end; function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; -var Vx, Vy, x, y, t: hwFloat; +var Vx, Vy, x, y, t, dmgMod: real; d: Longword; - valueResult: LongInt; + fallDmg, valueResult: LongInt; begin +if Level > 4 then exit(BadTurn); +dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; +Level:= Level; // avoid compiler hint +ap.ExplR:= 0; +ap.Time:= 0; +ap.Power:= 1; + +x:= hwFloat2Float(Me^.X); +y:= hwFloat2Float(Me^.Y); + +if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 20 then + exit(BadTurn); + +t:= 2 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y)); +Vx:= (Targ.X - x) * t; +Vy:= (Targ.Y - y) * t; +ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); +d:= 0; + +repeat + x:= x + vX; + y:= y + vY; + if ((trunc(x) and LAND_WIDTH_MASK) = 0)and((trunc(y) and LAND_HEIGHT_MASK) = 0) + and (Land[trunc(y), trunc(x)] <> 0) then + inc(d); +until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5) + or (x < 0) + or (y < 0) + or (trunc(x) > LAND_WIDTH) + or (trunc(y) > LAND_HEIGHT) + or (d > 48); + +if Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 5 then + begin + fallDmg:= TraceShoveFall(Targ.X, Targ.Y, vX * 0.00125 * 20, vY * 0.00125 * 20); + if fallDmg < 0 then + valueResult:= 204800 + else valueResult:= Max(0, (4 - d div 12) * trunc((7 + fallDmg) * dmgMod) * 1024) + end +else + valueResult:= BadTurn; +TestDesertEagle:= valueResult +end; + + +function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +var Vx, Vy, x, y, t, dmg, dmgMod: real; + d: Longword; + fallDmg: LongInt; +begin +if Level > 3 then exit(BadTurn); +dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; Level:= Level; // avoid compiler hint ap.ExplR:= 0; ap.Time:= 0; ap.Power:= 1; -x:= Me^.X; -y:= Me^.Y; -if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then - exit(BadTurn); -t:= _0_5 / Distance(int2hwFloat(Targ.X) - x, int2hwFloat(Targ.Y) - y); -Vx:= (int2hwFloat(Targ.X) - x) * t; -Vy:= (int2hwFloat(Targ.Y) - y) * t; -ap.Angle:= DxDy2AttackAngle(Vx, -Vy); +x:= hwFloat2Float(Me^.X); +y:= hwFloat2Float(Me^.Y); +if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then + exit(BadTurn); + +dmg:= sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y)); +t:= 1.5 / dmg; +dmg:= dmg * 0.025; // div 40 +Vx:= (Targ.X - x) * t; +Vy:= (Targ.Y - y) * t; +ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); d:= 0; repeat - x:= x + vX; - y:= y + vY; - if ((hwRound(x) and LAND_WIDTH_MASK) = 0)and((hwRound(y) and LAND_HEIGHT_MASK) = 0) - and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d); -until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) - or (x.isNegative) - or (y.isNegative) - or (x.Round > LongWord(LAND_WIDTH)) - or (y.Round > LongWord(LAND_HEIGHT)) - or (d > 200); + x:= x + vX; + y:= y + vY; + if ((trunc(x) and LAND_WIDTH_MASK) = 0)and((trunc(y) and LAND_HEIGHT_MASK) = 0) + and (Land[trunc(y), trunc(x)] <> 0) then + inc(d); +until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4) + or (x < 0) + or (y < 0) + or (trunc(x) > LAND_WIDTH) + or (trunc(y) > LAND_HEIGHT) + or (d > 23); -if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then valueResult:= Max(0, (4 - d div 50) * 7 * 1024) - else valueResult:= BadTurn; -TestDesertEagle:= valueResult +if Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4 then + begin + fallDmg:= TraceShoveFall(Targ.X, Targ.Y, vX * 0.00166 * dmg, vY * 0.00166 * dmg); + if fallDmg < 0 then + TestSniperRifle:= BadTurn + else + TestSniperRifle:= Max(0, trunc((dmg + fallDmg) * dmgMod) * 1024) + end +else + TestSniperRifle:= BadTurn end; + function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; -var valueResult: LongInt; - x, y: hwFloat; +var valueResult, a, v1, v2: LongInt; + x, y, trackFall: LongInt; + dx, dy: real; begin -Level:= Level; // avoid compiler hint -ap.ExplR:= 0; -if (Level > 2) or (Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 25) then - exit(BadTurn); + Targ:= Targ; // avoid compiler hint + + if Level < 3 then trackFall:= afTrackFall + else trackFall:= 0; + + ap.ExplR:= 0; + ap.Time:= 0; + ap.Power:= 1; + x:= hwRound(Me^.X); + y:= hwRound(Me^.Y); + + a:= cMaxAngle div 2; + valueResult:= 0; + + while a >= 0 do + begin + dx:= sin(a / cMaxAngle * pi) * 0.5; + dy:= cos(a / cMaxAngle * pi) * 0.5; -ap.Time:= 0; -ap.Power:= 1; -x:= Me^.X; -y:= Me^.Y; -if (Targ.X) - hwRound(x) >= 0 then ap.Angle:= cMaxAngle div 4 - else ap.Angle:= - cMaxAngle div 4; -valueResult:= RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x), hwRound(y), 15, 30); -if valueResult <= 0 then valueResult:= BadTurn else inc(valueResult); -TestBaseballBat:= valueResult; + v1:= RateShove(x - 10, y + 2 + , 32, 30, 115 + , -dx, -dy, trackFall); + v2:= RateShove(x + 10, y + 2 + , 32, 30, 115 + , dx, -dy, trackFall); + if (v1 > valueResult) or (v2 > valueResult) then + if (v2 > v1) + or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then + begin + ap.Angle:= a; + valueResult:= v2 + end + else + begin + ap.Angle:= -a; + valueResult:= v1 + end; + + a:= a - 15 - random(cMaxAngle div 16) + end; + + if valueResult <= 0 then + valueResult:= BadTurn; + + TestBaseballBat:= valueResult; end; function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; -var i, valueResult: LongInt; - x, y: hwFloat; +var valueResult, v1, v2, i: LongInt; + x, y, trackFall: LongInt; +begin + Targ:= Targ; // avoid compiler hint + + if Level = 1 then trackFall:= afTrackFall + else trackFall:= 0; + + ap.ExplR:= 0; + ap.Time:= 0; + ap.Power:= 1; + x:= hwRound(Me^.X); + y:= hwRound(Me^.Y) + 4; + + v1:= 0; + for i:= 0 to 8 do + begin + v1:= v1 + RateShove(x - 5, y - 10 * i + , 19, 30, 40 + , -0.45, -0.9, trackFall or afSetSkip); + end; + v1:= v1 + RateShove(x - 5, y - 90 + , 19, 30, 40 + , -0.45, -0.9, trackFall); + + + // now try opposite direction + v2:= 0; + for i:= 0 to 8 do + begin + v2:= v2 + RateShove(x + 5, y - 10 * i + , 19, 30, 40 + , 0.45, -0.9, trackFall or afSetSkip); + end; + v2:= v2 + RateShove(x + 5, y - 90 + , 19, 30, 40 + , 0.45, -0.9, trackFall); + + if (v2 > v1) + or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then + begin + ap.Angle:= 1; + valueResult:= v2 + end + else + begin + ap.Angle:= -1; + valueResult:= v1 + end; + + if valueResult <= 0 then + valueResult:= BadTurn; + + TestFirePunch:= valueResult; +end; + + +function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +var valueResult, v1, v2: LongInt; + x, y, trackFall: LongInt; begin -Level:= Level; // avoid compiler hint -ap.ExplR:= 0; -ap.Time:= 0; -ap.Power:= 1; -ap.Angle:= 0; -x:= Me^.X; -y:= Me^.Y; -if (Abs(hwRound(x) - Targ.X) > 25) -or (Abs(hwRound(y) - 50 - Targ.Y) > 50) then - begin - if TestColl(hwRound(x), hwRound(y) - 16, 6) - and (RateShove(Me, hwRound(x) + 10 * hwSign(Me^.dX), hwRound(y) - 40, 30, 30) = 0) then - valueResult:= Succ(BadTurn) + Targ:= Targ; // avoid compiler hint + + if Level = 1 then trackFall:= afTrackFall + else trackFall:= 0; + + ap.ExplR:= 0; + ap.Time:= 0; + ap.Power:= 1; + x:= hwRound(Me^.X); + y:= hwRound(Me^.Y); + + // check left direction + {first RateShove checks farthermost of two whip's AmmoShove attacks + to encourage distant attacks (damaged hog is excluded from view of second + RateShove call)} + v1:= RateShove(x - 13, y + , 30, 30, 25 + , -1, -0.8, trackFall or afSetSkip); + v1:= v1 + + RateShove(x - 2, y + , 30, 30, 25 + , -1, -0.8, trackFall); + // now try opposite direction + v2:= RateShove(x + 13, y + , 30, 30, 25 + , 1, -0.8, trackFall or afSetSkip); + v2:= v2 + + RateShove(x + 2, y + , 30, 30, 25 + , 1, -0.8, trackFall); + + if (v2 > v1) + or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then + begin + ap.Angle:= 1; + valueResult:= v2 + end + else + begin + ap.Angle:= -1; + valueResult:= v1 + end; + + if valueResult <= 0 then + valueResult:= BadTurn + else + inc(valueResult); + + TestWhip:= valueResult; +end; + +function TestKamikaze(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +const step = 8; +var valueResult, i, v, tx: LongInt; + trackFall: LongInt; + t, d, x, y, dx, dy, cx: real; +begin + ap.ExplR:= 0; + ap.Time:= 0; + ap.Power:= 1; + + if Level = 1 then + trackFall:= afTrackFall + else if Level = 2 then + trackFall:= 0 else - valueResult:= BadTurn; - exit(valueResult) - end; + exit(BadTurn); + + valueResult:= 0; + v:= 0; + + x:= hwFloat2Float(Me^.X); + y:= hwFloat2Float(Me^.Y); + d:= sqrt(sqr(Targ.X - x) + sqr(Targ.Y - y)); + if d < 10 then + begin + dx:= 0; + dy:= 8; + ap.Angle:= 2048 + end + else + begin + t:= step / d; + dx:= (Targ.X - x) * t; + dy:= (Targ.Y - y) * t; + + ap.Angle:= DxDy2AttackAnglef(dx, -dy) + end; + + if dx >= 0 then cx:= 0.45 else cx:= -0.45; -valueResult:= 0; -for i:= 0 to 4 do - valueResult:= valueResult + RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x), - hwRound(y) - 20 * i - 5, 10, 30); -if valueResult <= 0 then - valueResult:= BadTurn -else - inc(valueResult); + for i:= 0 to 512 div step - 2 do + begin + valueResult:= valueResult + + RateShove(trunc(x), trunc(y) + , 30, 30, 25 + , cx, -0.9, trackFall or afSetSkip); + + x:= x + dx; + y:= y + dy; + end; + if dx = 0 then + begin + x:= hwFloat2Float(Me^.X); + y:= hwFloat2Float(Me^.Y); + tx:= trunc(x); + v:= RateShove(tx, trunc(y) + , 30, 30, 25 + , -cx, -0.9, trackFall); + for i:= 1 to 512 div step - 2 do + begin + y:= y + dy; + v:= v + + RateShove(tx, trunc(y) + , 30, 30, 25 + , -cx, -0.9, trackFall or afSetSkip); + end + end; + if v > valueResult then + begin + ap.Angle:= -2048; + valueResult:= v + end; -TestFirePunch:= valueResult; + v:= RateShove(trunc(x), trunc(y) + , 30, 30, 25 + , cx, -0.9, trackFall); + valueResult:= valueResult + v - KillScore * friendlyfactor div 100 * 1024; + + if v < 65536 then + inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30)); + + TestKamikaze:= valueResult; end; function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; var rate: LongInt; begin Level:= Level; // avoid compiler hint +Targ:= Targ; + ap.ExplR:= 0; ap.Time:= 0; ap.Power:= 1; ap.Angle:= 0; -if (Abs(hwRound(Me^.X) + hwSign(Me^.dX) * 10 - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 20) then - rate:= 0 - else - rate:= RateHammer(Me); -if rate = 0 then rate:= BadTurn; +rate:= RateHammer(Me); +if rate = 0 then + rate:= BadTurn; TestHammer:= rate; end; function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; const cShift = 4; -var X, Y, dY: hwFloat; +var bombsSpeed, X, Y, dY: real; b: array[0..9] of boolean; dmg: array[0..9] of LongInt; fexit: boolean; @@ -693,15 +973,18 @@ begin ap.ExplR:= 0; ap.Time:= 0; -if (Level > 3) then exit(BadTurn); +if (Level > 3) then + exit(BadTurn); +ap.Angle:= 0; ap.AttackPutX:= Targ.X; ap.AttackPutY:= Targ.Y; -X:= int2hwFloat(Targ.X - 135 - cShift); // hh center - cShift -X:= X - cBombsSpeed * hwSqrt(int2hwFloat((Targ.Y + 128) * 2) / cGravity); -Y:= -_128; -dY:= _0; +bombsSpeed:= hwFloat2Float(cBombsSpeed); +X:= Targ.X - 135 - cShift; // hh center - cShift +X:= X - bombsSpeed * sqrt(((Targ.Y + 128) * 2) / cGravityf); +Y:= -128; +dY:= 0; for i:= 0 to 9 do begin @@ -711,23 +994,23 @@ valueResult:= 0; repeat - X:= X + cBombsSpeed; - Y:= Y + dY; - dY:= dY + cGravity; - fexit:= true; + X:= X + bombsSpeed; + Y:= Y + dY; + dY:= dY + cGravityf; + fexit:= true; - for i:= 0 to 9 do - if b[i] then - begin - fexit:= false; - if TestColl(hwRound(X) + i * 30, hwRound(Y), 4) then - begin - b[i]:= false; - dmg[i]:= RateExplosion(Me, hwRound(X) + i * 30, hwRound(Y), 58) - // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets) - end - end; -until fexit or (Y.Round > cWaterLine); + for i:= 0 to 9 do + if b[i] then + begin + fexit:= false; + if TestColl(trunc(X) + LongWord(i * 30), trunc(Y), 4) then + begin + b[i]:= false; + dmg[i]:= RateExplosion(Me, trunc(X) + LongWord(i * 30), trunc(Y), 58) + // 58 (instead of 60) for better prediction (hh moves after explosion of one of the rockets) + end + end; +until fexit or (Y > cWaterLine); for i:= 0 to 5 do inc(valueResult, dmg[i]); t:= valueResult; @@ -738,13 +1021,14 @@ dec(t, dmg[i]); inc(t, dmg[i + 6]); if t > valueResult then - begin - valueResult:= t; - ap.AttackPutX:= Targ.X - 30 - cShift + i * 30 - end + begin + valueResult:= t; + ap.AttackPutX:= Targ.X - 30 - cShift + i * 30 + end end; -if valueResult <= 0 then valueResult:= BadTurn; +if valueResult <= 0 then + valueResult:= BadTurn; TestAirAttack:= valueResult; end; @@ -755,32 +1039,115 @@ maxTop: longword; begin TestTeleport := BadTurn; + exit(BadTurn); Level:= Level; // avoid compiler hint - FillBonuses(true, [gtCase]); - if bonuses.Count = 0 then begin - if Me^.Health <= 100 then begin + //FillBonuses(true, [gtCase]); + if bonuses.Count = 0 then + begin + if Me^.Health <= 100 then + begin maxTop := Targ.Y - cHHRadius * 2; + while not TestColl(Targ.X, maxTop, cHHRadius) and (maxTop > topY + cHHRadius * 2 + 1) do - dec(maxTop, cHHRadius*2); - if not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius) then begin + dec(maxTop, cHHRadius*2); + if not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius) then + begin ap.AttackPutX := Targ.X; ap.AttackPutY := maxTop + cHHRadius; TestTeleport := Targ.Y - maxTop; + end; end; - end; - end - else begin + end + else + begin failNum := 0; repeat i := random(bonuses.Count); inc(failNum); - until not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) or (failNum = bonuses.Count*2); - if failNum < bonuses.Count*2 then begin + until not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) + or (failNum = bonuses.Count*2); + + if failNum < bonuses.Count*2 then + begin ap.AttackPutX := bonuses.ar[i].X; ap.AttackPutY := bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius; TestTeleport := 0; + end; end; +end; + + +procedure checkCakeWalk(Me, Gear: PGear; var ap: TAttackParams); +var i: Longword; + v: LongInt; +begin +while (not TestColl(hwRound(Gear^.X), hwRound(Gear^.Y), 6)) and (Gear^.Y.Round < LAND_HEIGHT) do + Gear^.Y:= Gear^.Y + _1; + +for i:= 0 to 2040 do + begin + cakeStep(Gear); + v:= RateExplosion(Me, hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg * 2, afTrackFall); + if v > ap.Power then + begin + ap.ExplX:= hwRound(Gear^.X); + ap.ExplY:= hwRound(Gear^.Y); + ap.Power:= v + end end; end; +function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +var valueResult, v1, v2: LongInt; + cake: TGear; +begin + Targ:= Targ; // avoid compiler hint + + if (Level > 2) then + exit(BadTurn); + + ap.ExplR:= 0; + ap.Time:= 0; + ap.Power:= BadTurn; // use it as max score value in checkCakeWalk + + //FillChar(cake, sizeof(cake), 0); + cake.Radius:= 7; + cake.CollisionMask:= $FF7F; + cake.Hedgehog:= Me^.Hedgehog; + + // check left direction + cake.Angle:= 3; + cake.dX.isNegative:= true; + cake.X:= Me^.X - _3; + cake.Y:= Me^.Y; + checkCakeWalk(Me, @cake, ap); + v1:= ap.Power; + + // now try opposite direction + cake.Angle:= 1; + cake.dX.isNegative:= false; + cake.X:= Me^.X + _3; + cake.Y:= Me^.Y; + checkCakeWalk(Me, @cake, ap); + v2:= ap.Power; + + ap.Power:= 1; + + if (v2 > v1) then + begin + ap.Angle:= 1; + valueResult:= v2 + end + else + begin + ap.Angle:= -1; + valueResult:= v1 + end; + + if valueResult <= 0 then + valueResult:= BadTurn; + + TestCake:= valueResult; +end; + end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAILandMarks.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uAILandMarks.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,78 @@ +unit uAILandMarks; + +interface +const + markWalkedHere = $01; + markHJumped = $02; + markLJumped = $04; + +procedure addMark(X, Y: LongInt; mark: byte); +function checkMark(X, Y: LongInt; mark: byte) : boolean; +procedure clearAllMarks; +procedure clearMarks(mark: byte); +procedure setAILandMarks; + +procedure initModule; +procedure freeModule; + +implementation +uses uVariables; + +const gr = 2; + +var marks: array of array of byte; + WIDTH, HEIGHT: Longword; + +procedure addMark(X, Y: LongInt; mark: byte); +begin + if((X and LAND_WIDTH_MASK) = 0) and ((Y and LAND_HEIGHT_MASK) = 0) then + begin + X:= X shr gr; + Y:= Y shr gr; + marks[Y, X]:= marks[Y, X] or mark + end +end; + +function checkMark(X, Y: LongInt; mark: byte) : boolean; +begin + checkMark:= ((X and LAND_WIDTH_MASK) = 0) + and ((Y and LAND_HEIGHT_MASK) = 0) + and ((marks[Y shr gr, X shr gr] and mark) <> 0) +end; + +procedure clearAllMarks; +var + Y, X: Longword; +begin + for Y:= 0 to Pred(HEIGHT) do + for X:= 0 to Pred(WIDTH) do + marks[Y, X]:= 0 +end; + +procedure clearMarks(mark: byte); +var + Y, X: Longword; +begin + for Y:= 0 to Pred(HEIGHT) do + for X:= 0 to Pred(WIDTH) do + marks[Y, X]:= marks[Y, X] and (not mark) +end; + +procedure setAILandMarks; +begin + WIDTH:= LAND_WIDTH shr gr; + HEIGHT:= LAND_HEIGHT shr gr; + + SetLength(marks, HEIGHT, WIDTH); +end; + +procedure initModule; +begin +end; + +procedure freeModule; +begin + SetLength(marks, 0, 0); +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uAIMisc.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2005-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,59 +24,78 @@ const MAXBONUS = 1024; + afTrackFall = $00000001; + afErasesLand = $00000002; + afSetSkip = $00000004; + + type TTarget = record - Point: TPoint; - Score: LongInt; - end; - TTargets = record - Count: Longword; - ar: array[0..Pred(cMaxHHs)] of TTarget; - end; - TJumpType = (jmpNone, jmpHJump, jmpLJump); - TGoInfo = record - Ticks: Longword; - FallPix: Longword; - JumpType: TJumpType; - end; - TBonus = record - X, Y: LongInt; - Radius: LongInt; - Score: LongInt; - end; + Point: TPoint; + Score: LongInt; + skip: boolean; + end; +TTargets = record + Count: Longword; + ar: array[0..Pred(cMaxHHs)] of TTarget; + end; +TJumpType = (jmpNone, jmpHJump, jmpLJump); +TGoInfo = record + Ticks: Longword; + FallPix: Longword; + JumpType: TJumpType; + end; +TBonus = record + X, Y: LongInt; + Radius: LongInt; + Score: LongInt; + end; procedure initModule; procedure freeModule; procedure FillTargets; -procedure FillBonuses(isAfterAttack: boolean; filter: TGearsType = []); -procedure AwareOfExplosion(x, y, r: LongInt); -function RatePlace(Gear: PGear): LongInt; -function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; -function TestColl(x, y, r: LongInt): boolean; -function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; -function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt; -function RateShotgun(Me: PGear; x, y: LongInt): LongInt; -function RateHammer(Me: PGear): LongInt; -function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean; -function AIrndSign(num: LongInt): LongInt; +procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); inline; +procedure FillBonuses(isAfterAttack: boolean); +procedure AwareOfExplosion(x, y, r: LongInt); inline; + +function RatePlace(Gear: PGear): LongInt; +function TestColl(x, y, r: LongInt): boolean; inline; +function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; +function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; +function TraceShoveFall(x, y, dX, dY: Real): LongInt; + +function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; inline; +function RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt; +function RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt; +function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt; +function RateHammer(Me: PGear): LongInt; + +function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean; +function AIrndSign(num: LongInt): LongInt; var ThinkingHH: PGear; Targets: TTargets; bonuses: record - Count: Longword; - ar: array[0..Pred(MAXBONUS)] of TBonus; - end; + Count: Longword; + ar: array[0..Pred(MAXBONUS)] of TBonus; + end; + + walkbonuses: record + Count: Longword; + ar: array[0..Pred(MAXBONUS div 8)] of TBonus; // don't use too many + end; + +const KillScore = 200; +var friendlyfactor: LongInt = 300; implementation -uses uCollisions, uVariables, uUtils, uDebug; - -const KillScore = 200; +uses uCollisions, uVariables, uUtils, uLandTexture, uGearsUtils; -var friendlyfactor: LongInt = 300; +var KnownExplosion: record - X, Y, Radius: LongInt - end = (X: 0; Y: 0; Radius: 0); + X, Y, Radius: LongInt + end = (X: 0; Y: 0; Radius: 0); procedure FillTargets; var i, t: Longword; @@ -91,19 +110,22 @@ begin for i:= 0 to cMaxHHIndex do if (Hedgehogs[i].Gear <> nil) - and (Hedgehogs[i].Gear <> ThinkingHH) then + and (Hedgehogs[i].Gear <> ThinkingHH) + and (Hedgehogs[i].Gear^.Health > Hedgehogs[i].Gear^.Damage) + then begin with Targets.ar[Targets.Count], Hedgehogs[i] do begin + skip:= false; Point.X:= hwRound(Gear^.X); Point.Y:= hwRound(Gear^.Y); if Clan <> CurrentTeam^.Clan then begin - Score:= Gear^.Health; + Score:= Gear^.Health - Gear^.Damage; inc(e) end else begin - Score:= -Gear^.Health; + Score:= Gear^.Damage - Gear^.Health; inc(f) end end; @@ -115,186 +137,427 @@ else friendlyfactor:= max(30, 300 - f * 80 div max(1,e)) end; -procedure FillBonuses(isAfterAttack: boolean; filter: TGearsType); -var Gear: PGear; - MyClan: PClan; - - procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); +procedure AddBonus(x, y: LongInt; r: Longword; s: LongInt); inline; +begin +if(bonuses.Count < MAXBONUS) then begin bonuses.ar[bonuses.Count].x:= x; bonuses.ar[bonuses.Count].y:= y; bonuses.ar[bonuses.Count].Radius:= r; bonuses.ar[bonuses.Count].Score:= s; inc(bonuses.Count); - TryDo(bonuses.Count <= MAXBONUS, 'Bonuses overflow', true) end; +end; +procedure AddWalkBonus(x, y: LongInt; r: Longword; s: LongInt); inline; +begin +if(walkbonuses.Count < MAXBONUS div 8) then + begin + walkbonuses.ar[walkbonuses.Count].x:= x; + walkbonuses.ar[walkbonuses.Count].y:= y; + walkbonuses.ar[walkbonuses.Count].Radius:= r; + walkbonuses.ar[walkbonuses.Count].Score:= s; + inc(walkbonuses.Count); + end; +end; + +procedure FillBonuses(isAfterAttack: boolean); +var Gear: PGear; + MyClan: PClan; + i: Longint; begin bonuses.Count:= 0; MyClan:= ThinkingHH^.Hedgehog^.Team^.Clan; Gear:= GearsList; while Gear <> nil do begin - if (filter = []) or (Gear^.Kind in filter) then - case Gear^.Kind of - gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25); - gtFlame: if (Gear^.State and gsttmpFlag) <> 0 then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50); + case Gear^.Kind of + gtCase: + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y) + 3, 37, 25); + gtFlame: + if (Gear^.State and gsttmpFlag) <> 0 then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50); // avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow - gtMine: if ((Gear^.State and gstAttacking) = 0) and - (((cMineDudPercent < 90) and (Gear^.Health <> 0)) or - ((Gear^.Health = 0) and (Gear^.Damage > 30))) then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) - else if (Gear^.State and gstAttacking) <> 0 then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on - gtSMine: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30); - gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); - gtHedgehog: begin - if Gear^.Damage >= Gear^.Health then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) - else - if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then - if (ClansCount > 2) or (MyClan = Gear^.Hedgehog^.Team^.Clan) then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend - else - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) - end; - end; + gtMine: + if ((Gear^.State and gstAttacking) = 0) and (((cMineDudPercent < 90) and (Gear^.Health <> 0)) + or (isAfterAttack and (Gear^.Health = 0) and (Gear^.Damage > 30))) then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) + else if (Gear^.State and gstAttacking) <> 0 then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on + + gtExplosives: + if isAfterAttack then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 75, -60 + Gear^.Health); + + gtSMine: + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30); + + gtDynamite: + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); + + gtHedgehog: + begin + if Gear^.Damage >= Gear^.Health then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) + else + if isAfterAttack + and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) + and ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_1) then + if (ClansCount > 2) or (MyClan = Gear^.Hedgehog^.Team^.Clan) then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend + else + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) + end; + end; Gear:= Gear^.NextGear end; if isAfterAttack and (KnownExplosion.Radius > 0) then - with KnownExplosion do + with KnownExplosion do AddBonus(X, Y, Radius + 10, -Radius); +if isAfterAttack then + begin + for i:= 0 to Pred(walkbonuses.Count) do + with walkbonuses.ar[i] do + AddBonus(X, Y, Radius, Score); + walkbonuses.Count:= 0 + end; end; -procedure AwareOfExplosion(x, y, r: LongInt); +procedure AwareOfExplosion(x, y, r: LongInt); inline; begin -KnownExplosion.X:= x; -KnownExplosion.Y:= y; -KnownExplosion.Radius:= r + KnownExplosion.X:= x; + KnownExplosion.Y:= y; + KnownExplosion.Radius:= r end; function RatePlace(Gear: PGear): LongInt; var i, r: LongInt; rate: LongInt; + gX, gY: real; begin +gX:= hwFloat2Float(Gear^.X); +gY:= hwFloat2Float(Gear^.Y); rate:= 0; for i:= 0 to Pred(bonuses.Count) do with bonuses.ar[i] do begin - r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); - if r < Radius then - inc(rate, Score * (Radius - r)) + r:= Radius; + if abs(gX-X)+abs(gY-Y) < Radius then + r:= trunc(sqrt(sqr(gX - X)+sqr(gY - Y))); + if r < 20 then + inc(rate, Score * Radius) + else if r < Radius then + inc(rate, Score * (Radius - r)) end; RatePlace:= rate; end; // Wrapper to test various approaches. If it works reasonably, will just replace. // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with... -function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; +function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; inline; var MeX, MeY: LongInt; begin if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then - begin + begin MeX:= hwRound(Me^.X); MeY:= hwRound(Me^.Y); // We are still inside the hog. Skip radius test - if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and - ((Land[y, x] and $FF00) = 0) then exit(false); - end; - exit(TestColl(x, y, r)) + if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and ((Land[y, x] and $FF00) = 0) then + exit(false); + end; + TestCollExcludingMe:= TestColl(x, y, r) +end; + +function TestCollExcludingObjects(x, y, r: LongInt): boolean; inline; +var b: boolean; +begin + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and $FF00 <> 0); + if b then + exit(true); + + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and $FF00 <> 0); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and $FF00 <> 0); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and $FF00 <> 0); + if b then + exit(true); + + TestCollExcludingObjects:= false; +end; + +function TestColl(x, y, r: LongInt): boolean; inline; +var b: boolean; +begin + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] and $FF7F <> 0); + if b then + exit(true); + + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] and $FF7F <> 0); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] and $FF7F <> 0); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] and $FF7F <> 0); + if b then + exit(true); + + TestColl:= false; end; -function TestColl(x, y, r: LongInt): boolean; +function TestCollWithLand(x, y, r: LongInt): boolean; inline; var b: boolean; begin -b:= (((x-r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] <> 0); -if b then exit(true); -b:=(((x-r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] <> 0); -if b then exit(true); -b:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] <> 0); -if b then exit(true); -TestColl:=(((x+r) and LAND_WIDTH_MASK) = 0)and(((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] <> 0) + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x-r] > 255); + if b then + exit(true); + + b:= (((x-r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x-r] > 255); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y-r) and LAND_HEIGHT_MASK) = 0) and (Land[y-r, x+r] > 255); + if b then + exit(true); + + b:= (((x+r) and LAND_WIDTH_MASK) = 0) and (((y+r) and LAND_HEIGHT_MASK) = 0) and (Land[y+r, x+r] > 255); + if b then + exit(true); + + TestCollWithLand:= false; +end; + +function TraceFall(eX, eY: LongInt; x, y, dX, dY: Real; r: LongWord): LongInt; +var skipLandCheck: boolean; + rCorner: real; + dmg: LongInt; +begin + skipLandCheck:= true; + if x - eX < 0 then dX:= -dX; + if y - eY < 0 then dY:= -dY; + // ok. attempt approximate search for an unbroken trajectory into water. if it continues far enough, assume out of map + rCorner:= r * 0.75; + while true do + begin + x:= x + dX; + y:= y + dY; + dY:= dY + cGravityf; + skipLandCheck:= skipLandCheck and (r <> 0) and (abs(eX-x) + abs(eY-y) < r) and ((abs(eX-x) < rCorner) or (abs(eY-y) < rCorner)); + if not skipLandCheck and TestCollWithLand(trunc(x), trunc(y), cHHRadius) then + begin + if 0.4 < dY then + begin + dmg := 1 + trunc((abs(dY) - 0.4) * 70); + if dmg >= 1 then + exit(dmg); + end; + exit(0) + end; + if (y > cWaterLine) or (x > 4096) or (x < 0) then + exit(-1); + end; +end; + +function TraceShoveFall(x, y, dX, dY: Real): LongInt; +var dmg: LongInt; +begin +//v:= random($FFFFFFFF); + while true do + begin + x:= x + dX; + y:= y + dY; + dY:= dY + cGravityf; + +{ if ((trunc(y) and LAND_HEIGHT_MASK) = 0) and ((trunc(x) and LAND_WIDTH_MASK) = 0) then + begin + LandPixels[trunc(y), trunc(x)]:= v; + UpdateLandTexture(trunc(X), 1, trunc(Y), 1, true); + end;} + + + // consider adding dX/dY calc here for fall damage + if TestCollExcludingObjects(trunc(x), trunc(y), cHHRadius) then + begin + if 0.4 < dY then + begin + dmg := 1 + trunc((abs(dY) - 0.4) * 70); + if dmg >= 1 then + exit(dmg); + end; + exit(0) + end; + if (y > cWaterLine) or (x > 4096) or (x < 0) then + // returning -1 for drowning so it can be considered in the Rate routine + exit(-1) + end; end; function RateExplosion(Me: PGear; x, y, r: LongInt): LongInt; -var i, dmg, rate: LongInt; begin + RateExplosion:= RateExplosion(Me, x, y, r, 0); +end; + +function RateExplosion(Me: PGear; x, y, r: LongInt; Flags: LongWord): LongInt; +var i, fallDmg, dmg, dmgBase, rate, erasure: LongInt; + dX, dY, dmgMod: real; +begin +fallDmg:= 0; +dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; rate:= 0; // add our virtual position with Targets.ar[Targets.Count] do - begin - Point.x:= hwRound(Me^.X); - Point.y:= hwRound(Me^.Y); - Score:= - ThinkingHH^.Health - end; + begin + Point.x:= hwRound(Me^.X); + Point.y:= hwRound(Me^.Y); + Score:= - ThinkingHH^.Health + end; // rate explosion +dmgBase:= r + cHHRadius div 2; +if (Flags and afErasesLand <> 0) and (GameFlags and gfSolidLand = 0) then erasure:= r +else erasure:= 0; for i:= 0 to Targets.Count do with Targets.ar[i] do - begin - dmg:= hwRound(_0_01 * cDamageModifier - * min((r + cHHRadius div 2 - LongInt(DistanceI(Point.x - x, Point.y - y).Round)) div 2, r) * cDamagePercent); + begin + dmg:= 0; + if abs(Point.x - x) + abs(Point.y - y) < dmgBase then + dmg:= trunc(dmgMod * min((dmgBase - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y)))) div 2, r)); - if dmg > 0 then + if dmg > 0 then begin - if dmg >= abs(Score) then - if Score > 0 then inc(rate, KillScore) - else dec(rate, KillScore * friendlyfactor div 100) + if (Flags and afTrackFall <> 0) and (dmg < abs(Score)) then + begin + dX:= 0.005 * dmg + 0.01; + dY:= dX; + if (x and LAND_WIDTH_MASK = 0) and ((y+cHHRadius+2) and LAND_HEIGHT_MASK = 0) and + (Land[y+cHHRadius+2, x] and lfIndestructible <> 0) then + fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, 0) * dmgMod) + else fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod) + end; + if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI + if Score > 0 then + inc(rate, (KillScore + Score div 10) * 1024) // Add a bit of a bonus for bigger hog drownings + else + dec(rate, (KillScore * friendlyfactor div 100 - Score div 10) * 1024) // and more of a punishment for drowning bigger friendly hogs + else if (dmg+fallDmg) >= abs(Score) then + if Score > 0 then + inc(rate, KillScore * 1024 + (dmg + fallDmg)) // tiny bonus for dealing more damage than needed to kill + else + dec(rate, KillScore * friendlyfactor div 100 * 1024) else - if Score > 0 then inc(rate, dmg) - else dec(rate, dmg * friendlyfactor div 100) + if Score > 0 then + inc(rate, (dmg + fallDmg) * 1024) + else dec(rate, (dmg + fallDmg) * friendlyfactor div 100 * 1024) end; - end; -RateExplosion:= rate * 1024; + end; +RateExplosion:= rate; end; -function RateShove(Me: PGear; x, y, r, power: LongInt): LongInt; -var i, dmg, rate: LongInt; +function RateShove(x, y, r, power, kick: LongInt; gdX, gdY: real; Flags: LongWord): LongInt; +var i, fallDmg, dmg, rate: LongInt; + dX, dY, dmgMod: real; begin -Me:= Me; // avoid compiler hint +fallDmg:= 0; +dX:= gdX * 0.01 * kick; +dY:= gdY * 0.01 * kick; +dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; rate:= 0; for i:= 0 to Pred(Targets.Count) do with Targets.ar[i] do - begin - dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y)); - dmg:= hwRound(_0_01 * cDamageModifier * dmg * cDamagePercent); - if dmg > 0 then + if skip then + if (Flags and afSetSkip = 0) then skip:= false else {still skip} + else + begin + dmg:= 0; + if abs(Point.x - x) + abs(Point.y - y) < r then + dmg:= r - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); + + if dmg > 0 then begin - if power >= abs(Score) then - if Score > 0 then inc(rate, KillScore) - else dec(rate, KillScore * friendlyfactor div 100) + if (Flags and afSetSkip <> 0) then skip:= true; + if (Flags and afTrackFall <> 0) and (Score > 0) then + fallDmg:= trunc(TraceShoveFall(Point.x, Point.y - 2, dX, dY) * dmgMod); + if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI + if Score > 0 then + inc(rate, KillScore + Score div 10) // Add a bit of a bonus for bigger hog drownings + else + dec(rate, KillScore * friendlyfactor div 100 - Score div 10) // and more of a punishment for drowning bigger friendly hogs + else if power+fallDmg >= abs(Score) then + if Score > 0 then + inc(rate, KillScore) + else + dec(rate, KillScore * friendlyfactor div 100) else - if Score > 0 then inc(rate, power) - else dec(rate, power * friendlyfactor div 100) + if Score > 0 then + inc(rate, power+fallDmg) + else + dec(rate, (power+fallDmg) * friendlyfactor div 100) end; - end; + end; RateShove:= rate * 1024 end; -function RateShotgun(Me: PGear; x, y: LongInt): LongInt; -var i, dmg, rate: LongInt; +function RateShotgun(Me: PGear; gdX, gdY: real; x, y: LongInt): LongInt; +var i, dmg, fallDmg, baseDmg, rate, erasure: LongInt; + dX, dY, dmgMod: real; begin +dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; rate:= 0; +gdX:= gdX * 0.01; +gdY:= gdX * 0.01; // add our virtual position with Targets.ar[Targets.Count] do - begin - Point.x:= hwRound(Me^.X); - Point.y:= hwRound(Me^.Y); - Score:= - ThinkingHH^.Health - end; + begin + Point.x:= hwRound(Me^.X); + Point.y:= hwRound(Me^.Y); + Score:= - ThinkingHH^.Health + end; // rate shot +baseDmg:= cHHRadius + cShotgunRadius + 4; +if GameFlags and gfSolidLand = 0 then erasure:= cShotgunRadius +else erasure:= 0; for i:= 0 to Targets.Count do with Targets.ar[i] do - begin - dmg:= min(cHHRadius + cShotgunRadius + 4 - hwRound(DistanceI(Point.x - x, Point.y - y)), 25); - dmg:= hwRound(_0_01 * cDamageModifier * dmg * cDamagePercent); - if dmg > 0 then + begin + dmg:= 0; + if abs(Point.x - x) + abs(Point.y - y) < baseDmg then + begin + dmg:= min(baseDmg - trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))), 25); + dmg:= trunc(dmg * dmgMod); + end; + if dmg > 0 then begin - if dmg >= abs(Score) then dmg := KillScore; - if Score > 0 then inc(rate, dmg) - else dec(rate, dmg * friendlyfactor div 100); + dX:= gdX * dmg; + dY:= gdY * dmg; + if dX < 0 then dX:= dX - 0.01 + else dX:= dX + 0.01; + if (x and LAND_WIDTH_MASK = 0) and ((y+cHHRadius+2) and LAND_HEIGHT_MASK = 0) and + (Land[y+cHHRadius+2, x] and lfIndestructible <> 0) then + fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, 0) * dmgMod) + else fallDmg:= trunc(TraceFall(x, y, Point.x, Point.y, dX, dY, erasure) * dmgMod); + if fallDmg < 0 then // drowning. score healthier hogs higher, since their death is more likely to benefit the AI + if Score > 0 then + inc(rate, KillScore + Score div 10) // Add a bit of a bonus for bigger hog drownings + else + dec(rate, KillScore * friendlyfactor div 100 - Score div 10) // and more of a punishment for drowning bigger friendly hogs + else if (dmg+fallDmg) >= abs(Score) then + if Score > 0 then + inc(rate, KillScore) + else + dec(rate, KillScore * friendlyfactor div 100) + else + if Score > 0 then + inc(rate, dmg+fallDmg) + else + dec(rate, (dmg+fallDmg) * friendlyfactor div 100) end; - end; + end; RateShotgun:= rate * 1024; end; @@ -308,189 +571,195 @@ for i:= 0 to Pred(Targets.Count) do with Targets.ar[i] do - begin // hammer hit radius is 8, shift is 10 - r:= hwRound(DistanceI(Point.x - x, Point.y - y)); + if abs(Point.x - x) + abs(Point.y - y) < 18 then + begin + r:= trunc(sqrt(sqr(Point.x - x)+sqr(Point.y - y))); - if r <= 18 then - if Score > 0 then - inc(rate, Score div 3) - else - inc(rate, Score div 3 * friendlyfactor div 100) - end; + if r <= 18 then + if Score > 0 then + inc(rate, Score div 3) + else + inc(rate, Score div 3 * friendlyfactor div 100) + end; RateHammer:= rate * 1024; end; function HHJump(Gear: PGear; JumpType: TJumpType; var GoInfo: TGoInfo): boolean; var bX, bY: LongInt; - bRes: boolean; begin -bRes:= false; +HHJump:= false; GoInfo.Ticks:= 0; GoInfo.JumpType:= jmpNone; bX:= hwRound(Gear^.X); bY:= hwRound(Gear^.Y); case JumpType of - jmpNone: exit(bRes); - jmpHJump: if TestCollisionYwithGear(Gear, -1) = 0 then - begin - Gear^.dY:= -_0_2; - SetLittle(Gear^.dX); - Gear^.State:= Gear^.State or gstMoving or gstHHJumping; - end else exit(bRes); - jmpLJump: begin - if TestCollisionYwithGear(Gear, -1) <> 0 then - if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - int2hwFloat(2) else - if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then - begin - Gear^.dY:= -_0_15; - Gear^.dX:= SignAs(_0_15, Gear^.dX); - Gear^.State:= Gear^.State or gstMoving or gstHHJumping - end else exit(bRes) - end - end; + jmpNone: exit(false); + + jmpHJump: + if TestCollisionYwithGear(Gear, -1) = 0 then + begin + Gear^.dY:= -_0_2; + SetLittle(Gear^.dX); + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; + end + else + exit(false); + + jmpLJump: + begin + if TestCollisionYwithGear(Gear, -1) <> 0 then + if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then + Gear^.Y:= Gear^.Y - int2hwFloat(2) + else + if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then + Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) or + (TestCollisionYwithGear(Gear, -1) <> 0)) then + begin + Gear^.dY:= -_0_15; + Gear^.dX:= SignAs(_0_15, Gear^.dX); + Gear^.State:= Gear^.State or gstMoving or gstHHJumping + end + else + exit(false) + end +end; repeat -if not (hwRound(Gear^.Y) + cHHRadius < cWaterLine) then exit(bRes); -if (Gear^.State and gstMoving) <> 0 then - begin - if (GoInfo.Ticks = 350) then - if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then - begin - Gear^.dY:= -_0_25; - Gear^.dX:= SignAs(_0_02, Gear^.dX) - end; - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); - Gear^.X:= Gear^.X + Gear^.dX; - inc(GoInfo.Ticks); - Gear^.dY:= Gear^.dY + cGravity; - if Gear^.dY > _0_4 then exit(bRes); - if (Gear^.dY.isNegative)and (TestCollisionYwithGear(Gear, -1) <> 0) then Gear^.dY:= _0; - Gear^.Y:= Gear^.Y + Gear^.dY; - if (not Gear^.dY.isNegative)and (TestCollisionYwithGear(Gear, 1) <> 0) then - begin - Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping); - Gear^.dY:= _0; - case JumpType of - jmpHJump: if bY - hwRound(Gear^.Y) > 5 then + {if ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) then + begin + LandPixels[hwRound(Gear^.Y), hwRound(Gear^.X)]:= Gear^.Hedgehog^.Team^.Clan^.Color; + UpdateLandTexture(hwRound(Gear^.X), 1, hwRound(Gear^.Y), 1, true); + end;} + + if not (hwRound(Gear^.Y) + cHHRadius < cWaterLine) then + exit(false); + if (Gear^.State and gstMoving) <> 0 then + begin + if (GoInfo.Ticks = 350) then + if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then + begin + Gear^.dY:= -_0_25; + Gear^.dX:= SignAs(_0_02, Gear^.dX) + end; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); + Gear^.X:= Gear^.X + Gear^.dX; + inc(GoInfo.Ticks); + Gear^.dY:= Gear^.dY + cGravity; + if Gear^.dY > _0_4 then + exit(false); + if (Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, -1) <> 0) then + Gear^.dY:= _0; + Gear^.Y:= Gear^.Y + Gear^.dY; + if (not Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, 1) <> 0) then + begin + Gear^.State:= Gear^.State and (not (gstMoving or gstHHJumping)); + Gear^.dY:= _0; + case JumpType of + jmpHJump: + if bY - hwRound(Gear^.Y) > 5 then begin - bRes:= true; GoInfo.JumpType:= jmpHJump; - inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after + inc(GoInfo.Ticks, 300 + 300); // 300 before jump, 300 after + exit(true) end; - jmpLJump: if abs(bX - hwRound(Gear^.X)) > 30 then + jmpLJump: + if abs(bX - hwRound(Gear^.X)) > 30 then begin - bRes:= true; GoInfo.JumpType:= jmpLJump; - inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after - end; - end; - exit(bRes) - end; - end; + inc(GoInfo.Ticks, 300 + 300); // 300 before jump, 300 after + exit(true) + end + end; + exit(false) + end; + end; until false end; function HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean; -var pX, pY: LongInt; +var pX, pY, tY: LongInt; begin +HHGo:= false; +Gear^.CollisionMask:= $FF7F; AltGear^:= Gear^; GoInfo.Ticks:= 0; GoInfo.FallPix:= 0; GoInfo.JumpType:= jmpNone; +tY:= hwRound(Gear^.Y); repeat -pX:= hwRound(Gear^.X); -pY:= hwRound(Gear^.Y); -if pY + cHHRadius >= cWaterLine then exit(false); -if (Gear^.State and gstMoving) <> 0 then - begin - inc(GoInfo.Ticks); - Gear^.dY:= Gear^.dY + cGravity; - if Gear^.dY > _0_4 then - begin - Goinfo.FallPix:= 0; - HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall with damage - exit(false) - end; - Gear^.Y:= Gear^.Y + Gear^.dY; - if hwRound(Gear^.Y) > pY then inc(GoInfo.FallPix); - if TestCollisionYwithGear(Gear, 1) <> 0 then - begin - inc(GoInfo.Ticks, 410); - Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping); - Gear^.dY:= _0; - HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall - exit(true) - end; - continue - end; - if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else - if (Gear^.Message and gmRight )<>0 then Gear^.dX:= cLittle else exit(false); - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - end; + {if ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) then + begin + LandPixels[hwRound(Gear^.Y), hwRound(Gear^.X)]:= random($FFFFFFFF);//Gear^.Hedgehog^.Team^.Clan^.Color; + UpdateLandTexture(hwRound(Gear^.X), 1, hwRound(Gear^.Y), 1, true); + end;} - if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - Gear^.X:= Gear^.X + int2hwFloat(hwSign(Gear^.dX)); - inc(GoInfo.Ticks, cHHStepTicks) - end; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y + _1; - if TestCollisionYwithGear(Gear, 1) = 0 then - begin - Gear^.Y:= Gear^.Y - _6; - Gear^.dY:= _0; - Gear^.State:= Gear^.State or gstMoving - end - end - end - end - end - end - end; -if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then - exit(true); + pX:= hwRound(Gear^.X); + pY:= hwRound(Gear^.Y); + if pY + cHHRadius >= cWaterLine then + begin + if AltGear^.Hedgehog^.BotLevel < 4 then + AddWalkBonus(pX, tY, 250, -40); + exit(false) + end; + + // hog is falling + if (Gear^.State and gstMoving) <> 0 then + begin + inc(GoInfo.Ticks); + Gear^.dY:= Gear^.dY + cGravity; + if Gear^.dY > _0_4 then + begin + GoInfo.FallPix:= 0; + // try ljump instead of fall with damage + HHJump(AltGear, jmpLJump, GoInfo); + if AltGear^.Hedgehog^.BotLevel < 4 then + AddWalkBonus(pX, tY, 175, -20); + exit(false) + end; + Gear^.Y:= Gear^.Y + Gear^.dY; + if hwRound(Gear^.Y) > pY then + inc(GoInfo.FallPix); + if TestCollisionYwithGear(Gear, 1) <> 0 then + begin + inc(GoInfo.Ticks, 410); + Gear^.State:= Gear^.State and (not (gstMoving or gstHHJumping)); + Gear^.dY:= _0; + // try ljump instead of fall + HHJump(AltGear, jmpLJump, GoInfo); + exit(true) + end; + continue + end; + + // usual walk + if (Gear^.Message and gmLeft) <> 0 then + Gear^.dX:= -cLittle + else + if (Gear^.Message and gmRight) <> 0 then + Gear^.dX:= cLittle + else + exit(false); + + if MakeHedgehogsStep(Gear) then + inc(GoInfo.Ticks, cHHStepTicks); + + // we have moved for 1 px + if (pX <> hwRound(Gear^.X)) and ((Gear^.State and gstMoving) = 0) then + exit(true) until (pX = hwRound(Gear^.X)) and (pY = hwRound(Gear^.Y)) and ((Gear^.State and gstMoving) = 0); + HHJump(AltGear, jmpHJump, GoInfo); -HHGo:= false; end; function AIrndSign(num: LongInt): LongInt; begin -if random(2) = 0 then AIrndSign:= num - else AIrndSign:= - num +if random(2) = 0 then + AIrndSign:= num +else + AIrndSign:= - num end; procedure initModule; @@ -503,7 +772,6 @@ procedure freeModule; begin - end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uAmmos.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,20 +20,21 @@ unit uAmmos; interface -uses uConsts, uTypes; +uses uConsts, uTypes, uStore; procedure initModule; procedure freeModule; procedure AddAmmoStore; -procedure SetAmmoLoadout(s: shortstring); -procedure SetAmmoProbability(s: shortstring); -procedure SetAmmoDelay(s: shortstring); -procedure SetAmmoReinforcement(s: shortstring); +procedure SetAmmoLoadout(var s: shortstring); +procedure SetAmmoProbability(var s: shortstring); +procedure SetAmmoDelay(var s: shortstring); +procedure SetAmmoReinforcement(var s: shortstring); procedure AssignStores; procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType); -procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord); -function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean; +procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord); +procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord); +function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord; procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt); procedure OnUsedAmmo(var Hedgehog: THedgehog); procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType); @@ -43,13 +44,13 @@ procedure DisableSomeWeapons; procedure ResetWeapons; function GetAmmoByNum(num: Longword): PHHAmmo; -function GetAmmoEntry(var Hedgehog: THedgehog): PAmmo; +function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo; function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo; var StoreCnt: Longword; implementation -uses uLocale, uMobile, uVariables, uCommands, uUtils, uCaptions, uDebug; +uses uLocale, uVariables, uCommands, uUtils, uCaptions, uDebug; type TAmmoCounts = array[TAmmoType] of Longword; var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo; @@ -67,13 +68,15 @@ for a:= Low(TAmmoType) to High(TAmmoType) do begin if cnts[a] > 0 then - begin - TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); - Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; - with Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]] do Count:= cnts[a]; - inc(mi[Ammoz[a].Slot]) - end - end + begin + TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true); + Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo; + with Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]] do + Count:= cnts[a]; + inc(mi[Ammoz[a].Slot]) + end + end; +AmmoMenuInvalidated:= true; end; procedure AddAmmoStore; @@ -103,31 +106,36 @@ cnt:= AMMO_INFINITE; Ammoz[a].Probability:= 0 end; - if Ammoz[a].NumberInCase = 0 then Ammoz[a].Probability:= 0; + if Ammoz[a].NumberInCase = 0 then + Ammoz[a].Probability:= 0; // avoid things we already have by scheme // merge this into DisableSomeWeapons ? - if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or - ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or - ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or - ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) or - ((a = amExtraTime) and (cHedgehogTurnTime >= 1000000)) or - (a = amStructure) then + if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) + or ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) + or ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) + or ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) + or ((a = amExtraTime) and (cHedgehogTurnTime >= 1000000)) then begin cnt:= 0; Ammoz[a].Probability:= 0 end; ammos[a]:= cnt; - if ((GameFlags and gfKing) <> 0) and ((GameFlags and gfPlaceHog) = 0) and (Ammoz[a].SkipTurns = 0) and (a <> amTeleport) and (a <> amSkip) then + if ((GameFlags and gfKing) <> 0) and ((GameFlags and gfPlaceHog) = 0) + and (Ammoz[a].SkipTurns = 0) and (a <> amTeleport) and (a <> amSkip) then Ammoz[a].SkipTurns:= 1; - if ((GameFlags and gfPlaceHog) <> 0) and - (a <> amTeleport) and (a <> amSkip) and - (Ammoz[a].SkipTurns < 10000) then inc(Ammoz[a].SkipTurns,10000); - if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then ammos[a]:= AMMO_INFINITE + if ((GameFlags and gfPlaceHog) <> 0) + and (a <> amTeleport) and (a <> amSkip) + and (Ammoz[a].SkipTurns < 10000) then + inc(Ammoz[a].SkipTurns,10000); + if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then + ammos[a]:= AMMO_INFINITE end - else ammos[a]:= AMMO_INFINITE; + + else + ammos[a]:= AMMO_INFINITE; if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then InitialCounts[Pred(StoreCnt)][a]:= cnt else @@ -138,13 +146,13 @@ function GetAmmoByNum(num: Longword): PHHAmmo; begin -TryDo(num < StoreCnt, 'Invalid store number', true); -exit(StoresList[num]) + TryDo(num < StoreCnt, 'Invalid store number', true); + GetAmmoByNum:= StoresList[num] end; -function GetAmmoEntry(var Hedgehog: THedgehog): PAmmo; +function GetCurAmmoEntry(var Hedgehog: THedgehog): PAmmo; begin -GetAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType) + GetCurAmmoEntry:= GetAmmoEntry(Hedgehog, Hedgehog.CurAmmoType) end; function GetAmmoEntry(var Hedgehog: THedgehog; am: TAmmoType): PAmmo; @@ -154,9 +162,11 @@ begin slot:= Ammoz[am].Slot; ammoidx:= 0; - while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> am) do inc(ammoidx); + while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> am) do + inc(ammoidx); GetAmmoEntry:= @Ammo^[slot, ammoidx]; - if (Ammo^[slot, ammoidx].AmmoType <> am) then GetAmmoEntry:= GetAmmoEntry(Hedgehog, amNothing) + if (Ammo^[slot, ammoidx].AmmoType <> am) then + GetAmmoEntry:= GetAmmoEntry(Hedgehog, amNothing) end; end; @@ -165,35 +175,42 @@ i: Longword; begin for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - for i:= 0 to cMaxHHIndex do - if Hedgehogs[i].Gear <> nil then - begin - Hedgehogs[i].Ammo:= GetAmmoByNum(Hedgehogs[i].AmmoStore); - if (GameFlags and gfPlaceHog) <> 0 then - Hedgehogs[i].CurAmmoType:= amTeleport - else - Hedgehogs[i].CurAmmoType:= amNothing - end - end + with TeamsArray[t]^ do + begin + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + begin + Hedgehogs[i].Ammo:= GetAmmoByNum(Hedgehogs[i].AmmoStore); + if (GameFlags and gfPlaceHog) <> 0 then + Hedgehogs[i].CurAmmoType:= amTeleport + else + Hedgehogs[i].CurAmmoType:= amNothing + end + end end; -procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType); +procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; amt: LongWord); var cnt: LongWord; a: PAmmo; begin a:= GetAmmoEntry(Hedgehog, ammo); -if (a^.AmmoType <> amNothing) then cnt:= a^.Count -else cnt:= 0; +if (a^.AmmoType <> amNothing) then + cnt:= a^.Count +else + cnt:= 0; if (cnt <> AMMO_INFINITE) then begin - inc(cnt, Ammoz[ammo].NumberInCase); - AddAmmo(Hedgehog, ammo, cnt) + inc(cnt, amt); + SetAmmo(Hedgehog, ammo, cnt) end end; -procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord); +procedure AddAmmo(var Hedgehog: THedgehog; ammo: TAmmoType); +begin + AddAmmo(Hedgehog, ammo, Ammoz[ammo].NumberInCase); +end; + +procedure SetAmmo(var Hedgehog: THedgehog; ammo: TAmmoType; cnt: LongWord); var ammos: TAmmoCounts; slot, ami: LongInt; hhammo: PHHAmmo; @@ -207,19 +224,19 @@ for slot:= 0 to cMaxSlotIndex do for ami:= 0 to cMaxSlotAmmoIndex do if hhammo^[slot, ami].Count > 0 then - ammos[hhammo^[slot, ami].AmmoType]:= hhammo^[slot, ami].Count; + ammos[hhammo^[slot, ami].AmmoType]:= hhammo^[slot, ami].Count; ammos[ammo]:= cnt; if ammos[ammo] > AMMO_INFINITE then ammos[ammo]:= AMMO_INFINITE; FillAmmoStore(hhammo, ammos); -CurWeapon:= GetAmmoEntry(Hedgehog); +CurWeapon:= GetCurAmmoEntry(Hedgehog); with Hedgehog, CurWeapon^ do - if (Count = 0) or (AmmoType = amNothing) then - begin - PackAmmo(Ammo, Ammoz[AmmoType].Slot); - CurAmmoType:= amNothing - end + if (Count = 0) or (AmmoType = amNothing) then + begin + PackAmmo(Ammo, Ammoz[AmmoType].Slot); + CurAmmoType:= amNothing + end end; procedure PackAmmo(Ammo: PHHAmmo; Slot: LongInt); @@ -227,24 +244,27 @@ b: boolean; begin repeat - b:= false; - ami:= 0; - while (not b) and (ami < cMaxSlotAmmoIndex) do - if (Ammo^[Slot, ami].Count = 0) - and (Ammo^[Slot, ami + 1].Count > 0) then b:= true - else inc(ami); - if b then // there is a free item in ammo stack - begin - Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1]; - Ammo^[Slot, ami + 1].Count:= 0 - end; + b:= false; + ami:= 0; + while (not b) and (ami < cMaxSlotAmmoIndex) do + if (Ammo^[Slot, ami].Count = 0) + and (Ammo^[Slot, ami + 1].Count > 0) then + b:= true + else + inc(ami); + if b then // there is a free item in ammo stack + begin + Ammo^[Slot, ami]:= Ammo^[Slot, ami + 1]; + Ammo^[Slot, ami + 1].Count:= 0 + end; until not b; +AmmoMenuInvalidated:= true; end; procedure OnUsedAmmo(var Hedgehog: THedgehog); var CurWeapon: PAmmo; begin -CurWeapon:= GetAmmoEntry(Hedgehog); +CurWeapon:= GetCurAmmoEntry(Hedgehog); with Hedgehog do begin @@ -257,44 +277,50 @@ begin PackAmmo(Ammo, Ammoz[AmmoType].Slot); //SwitchNotHeldAmmo(Hedgehog); + if CurAmmoType = amKnife then LoadHedgehogHat(Hedgehog, Hedgehog.Hat); CurAmmoType:= amNothing end end end; -uMobile.AmmoUpdate; end; -function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean; +function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): LongWord; var slot, ami: LongInt; begin -Slot:= Ammoz[Ammo].Slot; -ami:= 0; -while (ami <= cMaxSlotAmmoIndex) do - begin - with Hedgehog.Ammo^[Slot, ami] do + HHHasAmmo:= 0; + Slot:= Ammoz[Ammo].Slot; + ami:= 0; + while (ami <= cMaxSlotAmmoIndex) do + begin + with Hedgehog.Ammo^[Slot, ami] do if (AmmoType = Ammo) then - exit((Count > 0) and (Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns)); - inc(ami) - end; -HHHasAmmo:= false + if Hedgehog.Team^.Clan^.TurnNumber > Ammoz[AmmoType].SkipTurns then + exit(Count) + else + exit(0); + inc(ami) + end; end; procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType); begin -with Hedgehog do - begin - CurMinAngle:= Ammoz[AmmoType].minAngle; - if Ammoz[AmmoType].maxAngle <> 0 then - CurMaxAngle:= Ammoz[AmmoType].maxAngle - else - CurMaxAngle:= cMaxAngle; +if Hedgehog.Gear <> nil then + with Hedgehog do + begin + CurMinAngle:= Ammoz[AmmoType].minAngle; + if Ammoz[AmmoType].maxAngle <> 0 then + CurMaxAngle:= Ammoz[AmmoType].maxAngle + else + CurMaxAngle:= cMaxAngle; - with Hedgehog.Gear^ do - begin - if Angle < CurMinAngle then Angle:= CurMinAngle; - if Angle > CurMaxAngle then Angle:= CurMaxAngle; + with Hedgehog.Gear^ do + begin + if Angle < CurMinAngle then + Angle:= CurMinAngle; + if Angle > CurMaxAngle then + Angle:= CurMaxAngle; + end end - end end; procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog); @@ -309,11 +335,10 @@ ((Ammo^[slot, ammoidx].Count = 0) or (Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) do - begin - while (ammoidx <= cMaxSlotAmmoIndex) and - ((Ammo^[slot, ammoidx].Count = 0) or - (Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) - do inc(ammoidx); + begin + while (ammoidx <= cMaxSlotAmmoIndex) + and ((Ammo^[slot, ammoidx].Count = 0) or (Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) + do inc(ammoidx); if (ammoidx > cMaxSlotAmmoIndex) then begin @@ -323,6 +348,7 @@ end; TryDo(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true); CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; + if CurAmmoType = amKnife then LoadHedgehogHat(Hedgehog, 'Reserved/chef') end end; @@ -336,30 +362,33 @@ begin Timer:= 10; - CurWeapon:= GetAmmoEntry(Hedgehog); + CurWeapon:= GetCurAmmoEntry(Hedgehog); if (CurWeapon^.Count = 0) then SwitchToFirstLegalAmmo(Hedgehog) - else if CurWeapon^.AmmoType = amNothing then Hedgehog.CurAmmoType:= amNothing; + else if CurWeapon^.AmmoType = amNothing then + Hedgehog.CurAmmoType:= amNothing; - CurWeapon:= GetAmmoEntry(Hedgehog); + CurWeapon:= GetCurAmmoEntry(Hedgehog); ApplyAngleBounds(Hedgehog, CurWeapon^.AmmoType); with CurWeapon^ do begin s:= trammo[Ammoz[AmmoType].NameId]; - if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then + if (Count <> AMMO_INFINITE) and (not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0))) then s:= s + ' (' + IntToStr(Count) + ')'; if (Propz and ammoprop_Timerable) <> 0 then s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds]; AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); - if (Propz and ammoprop_NeedTarget) <> 0 - then begin - Gear^.State:= Gear^.State or gstHHChooseTarget; + if (Propz and ammoprop_NeedTarget) <> 0 then + begin + if Gear <> nil then Gear^.State:= Gear^.State or gstHHChooseTarget; isCursorVisible:= true - end else begin - Gear^.State:= Gear^.State and not gstHHChooseTarget; + end + else + begin + if Gear <> nil then Gear^.State:= Gear^.State and (not gstHHChooseTarget); isCursorVisible:= false end; end @@ -369,8 +398,8 @@ procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); begin with Hedgehog do - if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_DontHold) <> 0) or - (Ammoz[CurAmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then + if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_DontHold) <> 0) + or (Ammoz[CurAmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then SwitchToFirstLegalAmmo(Hedgehog); end; @@ -398,25 +427,26 @@ end; for t:= Low(TAmmoType) to High(TAmmoType) do - if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0 + if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then + Ammoz[t].Probability:= 0 end; -procedure SetAmmoLoadout(s: shortstring); +procedure SetAmmoLoadout(var s: shortstring); begin ammoLoadout:= s; end; -procedure SetAmmoProbability(s: shortstring); +procedure SetAmmoProbability(var s: shortstring); begin ammoProbability:= s; end; -procedure SetAmmoDelay(s: shortstring); +procedure SetAmmoDelay(var s: shortstring); begin ammoDelay:= s; end; -procedure SetAmmoReinforcement(s: shortstring); +procedure SetAmmoReinforcement(var s: shortstring); begin ammoReinforcement:= s; end; @@ -427,16 +457,16 @@ a: TAmmoType; begin for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - for i:= 0 to cMaxHHIndex do - if Hedgehogs[i].Gear <> nil then - begin - FillAmmoStore(Hedgehogs[i].Ammo, InitialCounts[Hedgehogs[i].AmmoStore]); - Hedgehogs[i].CurAmmoType:= amNothing - end; + with TeamsArray[t]^ do + for i:= 0 to cMaxHHIndex do + Hedgehogs[i].CurAmmoType:= amNothing; + +for i:= 0 to Pred(StoreCnt) do + FillAmmoStore(StoresList[i], InitialCounts[i]); for a:= Low(TAmmoType) to High(TAmmoType) do - if Ammoz[a].SkipTurns >= 10000 then dec(Ammoz[a].SkipTurns,10000) + if Ammoz[a].SkipTurns >= 10000 then + dec(Ammoz[a].SkipTurns,10000) end; @@ -448,18 +478,26 @@ end; procedure initModule; +var i: Longword; begin - RegisterVariable('ammloadt', vtCommand, @SetAmmoLoadout, false); - RegisterVariable('ammdelay', vtCommand, @SetAmmoDelay, false); - RegisterVariable('ammprob', vtCommand, @SetAmmoProbability, false); - RegisterVariable('ammreinf', vtCommand, @SetAmmoReinforcement, false); - RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false); + RegisterVariable('ammloadt', @SetAmmoLoadout, false); + RegisterVariable('ammdelay', @SetAmmoDelay, false); + RegisterVariable('ammprob', @SetAmmoProbability, false); + RegisterVariable('ammreinf', @SetAmmoReinforcement, false); + RegisterVariable('ammstore', @chAddAmmoStore , false); StoreCnt:= 0; ammoLoadout:= ''; ammoProbability:= ''; ammoDelay:= ''; ammoReinforcement:= ''; + for i:=1 to ord(High(TAmmoType)) do + begin + ammoLoadout:= ammoLoadout + '0'; + ammoProbability:= ammoProbability + '0'; + ammoDelay:= ammoDelay + '0'; + ammoReinforcement:= ammoReinforcement + '0' + end; FillChar(InitialCounts, sizeof(InitialCounts), 0) end; @@ -467,7 +505,8 @@ var i: LongWord; begin if StoreCnt > 0 then - for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]) + for i:= 0 to Pred(StoreCnt) do + Dispose(StoresList[i]) end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uCaptions.pas --- a/hedgewars/uCaptions.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uCaptions.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); procedure DrawCaptions; +procedure ReloadCaptions(unload: boolean); procedure initModule; procedure freeModule; @@ -33,19 +34,28 @@ uses uTextures, uRenderUtils, uVariables, uRender; type TCaptionStr = record - Tex: PTexture; - EndTime: LongWord; - end; + Tex: PTexture; + EndTime: LongWord; + Text: shortstring; + Color: Longword + end; var Captions: array[TCapGroup] of TCaptionStr; procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup); begin - if Captions[Group].Tex <> nil then + if Captions[Group].Text <> s then + begin FreeTexture(Captions[Group].Tex); - Captions[Group].Tex:= nil; - - Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); + Captions[Group].Tex:= nil + end; + + if Captions[Group].Tex = nil then + begin + Captions[Group].Color:= Color; + Captions[Group].Text:= s; + Captions[Group].Tex:= RenderStringTex(s, Color, fntBig) + end; case Group of capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 @@ -54,12 +64,23 @@ end; end; +// For uStore texture recreation +procedure ReloadCaptions(unload: boolean); +var Group: TCapGroup; +begin +for Group:= Low(TCapGroup) to High(TCapGroup) do + if unload then + FreeTexture(Captions[Group].Tex) + else if Captions[Group].Text <> '' then + Captions[Group].Tex:= RenderStringTex(Captions[Group].Text, Captions[Group].Color, fntBig) +end; + procedure DrawCaptions; var grp: TCapGroup; offset: LongInt; begin -{$IFDEF MOBILE} +{$IFDEF USE_TOUCH_INTERFACE} offset:= 48; {$ELSE} offset:= 8; @@ -68,16 +89,17 @@ for grp:= Low(TCapGroup) to High(TCapGroup) do with Captions[grp] do if Tex <> nil then - begin - DrawCentered(0, offset, Tex); + begin + DrawTextureCentered(0, offset, Tex); inc(offset, Tex^.h + 2); if EndTime <= RealTicks then - begin + begin FreeTexture(Tex); Tex:= nil; + Text:= ''; EndTime:= 0 + end; end; - end; end; procedure initModule; @@ -86,13 +108,13 @@ end; procedure freeModule; -var - group: TCapGroup; +var group: TCapGroup; begin for group:= Low(TCapGroup) to High(TCapGroup) do - begin + begin FreeTexture(Captions[group].Tex); - end; + Captions[group].Tex:= nil + end end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uChat.pas --- a/hedgewars/uChat.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uChat.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,22 +24,23 @@ procedure initModule; procedure freeModule; +procedure ReloadLines; procedure AddChatString(s: shortstring); procedure DrawChat; procedure KeyPressChat(Key: Longword); implementation -uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; +uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; const MaxStrIndex = 27; type TChatLine = record - Tex: PTexture; - Time: Longword; - Width: LongInt; - s: shortstring; - end; + Tex: PTexture; + Time: Longword; + Width: LongInt; + s: shortstring; + end; var Strs: array[0 .. MaxStrIndex] of TChatLine; MStrs: array[0 .. MaxStrIndex] of shortstring; @@ -51,7 +52,8 @@ ChatReady: boolean; showAll: boolean; -const colors: array[#1..#6] of TSDL_Color = ( +const colors: array[#0..#6] of TSDL_Color = ( + (r:$FF; g:$FF; b:$FF; unused:$FF), // unused, feel free to take it for anything (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White] (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple] (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime] @@ -72,15 +74,15 @@ cl.s:= str; if isInput then -begin + begin color:= colors[#6]; str:= UserNick + '> ' + str + '_' -end + end else -begin + begin color:= colors[str[1]]; delete(str, 1, 1) -end; + end; font:= CheckCJKFont(str, fnt16); w:= 0; h:= 0; // avoid compiler hints @@ -99,6 +101,21 @@ SDL_FreeSurface(resSurface) end; +// For uStore texture recreation +procedure ReloadLines; +var i, t: LongWord; +begin + if InputStr.s <> '' then + SetLine(InputStr, InputStr.s, true); + for i:= 0 to MaxStrIndex do + if Strs[i].s <> '' then + begin + t:= Strs[i].Time; + SetLine(Strs[i], Strs[i].s, false); + Strs[i].Time:= t + end; +end; + procedure AddChatString(s: shortstring); begin if not ChatReady then @@ -137,8 +154,7 @@ r.y:= (visibleCount - t) * 16 + 10; r.h:= 16; -if (GameState = gsChat) - and (InputStr.Tex <> nil) then +if (GameState = gsChat) and (InputStr.Tex <> nil) then begin r.w:= InputStr.Width; DrawFillRect(r); @@ -150,9 +166,8 @@ dec(r.y, 16); -while (((t < 7) and (Strs[i].Time > RealTicks)) or - ((t < MaxStrIndex) and showAll)) and - (Strs[i].Tex <> nil) do +while (((t < 7) and (Strs[i].Time > RealTicks)) or ((t < MaxStrIndex) and showAll)) +and (Strs[i].Tex <> nil) do begin r.w:= Strs[i].Width; DrawFillRect(r); @@ -162,7 +177,11 @@ DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex); dec(r.y, 16); - if i = 0 then i:= MaxStrIndex else dec(i); + if i = 0 then + i:= MaxStrIndex + else + dec(i); + inc(cnt); inc(t) end; @@ -183,12 +202,19 @@ begin t:= LocalTeam; x:= 0; -if (s[1] = '"') and (s[Length(s)] = '"') then x:= 1 -else if (s[1] = '''') and (s[Length(s)] = '''') then x:= 2 -else if (s[1] = '-') and (s[Length(s)] = '-') then x:= 3; +if (s[1] = '"') and (s[Length(s)] = '"') + then x:= 1 + +else if (s[1] = '''') and (s[Length(s)] = '''') then + x:= 2 + +else if (s[1] = '-') and (s[Length(s)] = '-') then + x:= 3; + if not CurrentTeam^.ExtDriven and (x <> 0) then for c:= 0 to Pred(TeamsCount) do - if (TeamsArray[c] = CurrentTeam) then t:= c; + if (TeamsArray[c] = CurrentTeam) then + t:= c; if x <> 0 then begin @@ -247,11 +273,10 @@ end; procedure KeyPressChat(Key: Longword); -const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0); +const firstByteMark: array[0..3] of byte = (0, $C0, $E0, $F0); var i, btw: integer; utf8: shortstring; begin - if Key <> 0 then case Key of {Backspace} @@ -267,6 +292,7 @@ FreezeEnterKey; SDL_EnableKeyRepeat(0,0); GameState:= gsGame; + ResetKbd; end; {Return} 3, 13, 271: begin @@ -278,12 +304,17 @@ FreezeEnterKey; SDL_EnableKeyRepeat(0,0); GameState:= gsGame; + ResetKbd; end; else - if (Key < $80) then btw:= 1 - else if (Key < $800) then btw:= 2 - else if (Key < $10000) then btw:= 3 - else btw:= 4; + if (Key < $80) then + btw:= 1 + else if (Key < $800) then + btw:= 2 + else if (Key < $10000) then + btw:= 3 + else + btw:= 4; utf8:= ''; @@ -293,9 +324,10 @@ Key:= Key shr 6 end; - utf8:= char(Key or firstByteMark[btw]) + utf8; + utf8:= char(Key or firstByteMark[Pred(btw)]) + utf8; - if byte(InputStr.s[0]) + btw > 240 then exit; + if byte(InputStr.s[0]) + btw > 240 then + exit; InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; SetLine(InputStr, InputStr.s + utf8, true) @@ -312,7 +344,7 @@ SendIPC('s' + s); if copy(s, 1, 4) = '/me ' then - s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) + s:= #2 + '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) else s:= #1 + UserNick + ': ' + s; @@ -331,7 +363,7 @@ procedure chHistory(var s: shortstring); begin s:= s; // avoid compiler hint - uChat.showAll:= not uChat.showAll + showAll:= not showAll end; procedure chChat(var s: shortstring); @@ -344,6 +376,7 @@ else begin // err, does anyone have any documentation on this sequence? + // ^^ isn't it obvious? 27 is esc, 32 is space, inbetween is "/team" KeyPressChat(27); KeyPressChat(47); KeyPressChat(116); @@ -357,11 +390,11 @@ procedure initModule; var i: ShortInt; begin - RegisterVariable('chatmsg', vtCommand, @chChatMessage, true); - RegisterVariable('say', vtCommand, @chSay, true); - RegisterVariable('team', vtCommand, @chTeamSay, true); - RegisterVariable('history', vtCommand, @chHistory, true ); - RegisterVariable('chat', vtCommand, @chChat, true ); + RegisterVariable('chatmsg', @chChatMessage, true); + RegisterVariable('say', @chSay, true); + RegisterVariable('team', @chTeamSay, true); + RegisterVariable('history', @chHistory, true ); + RegisterVariable('chat', @chChat, true ); lastStr:= 0; visibleCount:= 0; @@ -371,9 +404,7 @@ inputStr.Tex := nil; for i:= 0 to MaxStrIndex do - begin Strs[i].Tex := nil; - end; end; procedure freeModule; @@ -381,9 +412,7 @@ begin FreeTexture(InputStr.Tex); for i:= 0 to MaxStrIndex do - begin FreeTexture(Strs[i].Tex); - end; end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uCollisions.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,9 +26,9 @@ type PGearArray = ^TGearArray; TGearArray = record - ar: array[0..cMaxGearArrayInd] of PGear; - Count: Longword - end; + ar: array[0..cMaxGearArrayInd] of PGear; + Count: Longword + end; procedure initModule; procedure freeModule; @@ -47,22 +47,25 @@ function TestCollisionX(Gear: PGear; Dir: LongInt): boolean; function TestCollisionY(Gear: PGear; Dir: LongInt): boolean; -function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean; -function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean; +function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline; +function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean; +function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline; +function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean; function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5) function CalcSlopeBelowGear(Gear: PGear): hwFloat; +function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean; implementation -uses uConsts, uLandGraphics, uVariables, uDebug, uGears; +uses uConsts, uLandGraphics, uVariables, uDebug, uGearsList; type TCollisionEntry = record - X, Y, Radius: LongInt; - cGear: PGear; - end; + X, Y, Radius: LongInt; + cGear: PGear; + end; const MAXRECTSINDEX = 1023; var Count: Longword; @@ -72,14 +75,15 @@ procedure AddGearCI(Gear: PGear); var t: PGear; begin -if Gear^.CollisionIndex >= 0 then exit; +if Gear^.CollisionIndex >= 0 then + exit; TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); with cinfos[Count] do begin X:= hwRound(Gear^.X); Y:= hwRound(Gear^.Y); Radius:= Gear^.Radius; - ChangeRoundInLand(X, Y, Radius - 1, true); + ChangeRoundInLand(X, Y, Radius - 1, true, (Gear = CurrentHedgehog^.Gear) or (Gear^.Kind = gtCase)); cGear:= Gear end; Gear^.CollisionIndex:= Count; @@ -90,7 +94,8 @@ t:= GearsList; while (t <> nil) and (t^.Kind <> gtMine) do t:= t^.NextGear; - if (t <> nil) then DeleteGear(t) + if (t <> nil) then + DeleteGear(t) end; end; @@ -99,7 +104,7 @@ if Gear^.CollisionIndex >= 0 then begin with cinfos[Gear^.CollisionIndex] do - ChangeRoundInLand(X, Y, Radius - 1, false); + ChangeRoundInLand(X, Y, Radius - 1, false, (Gear = CurrentHedgehog^.Gear) or (Gear^.Kind = gtCase)); cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)]; cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex; Gear^.CollisionIndex:= -1; @@ -113,7 +118,8 @@ begin CheckGearsCollision:= @ga; ga.Count:= 0; -if Count = 0 then exit; +if Count = 0 then + exit; mx:= hwRound(Gear^.X); my:= hwRound(Gear^.Y); @@ -131,63 +137,63 @@ function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean; var x, y, i: LongInt; - TestWord: LongWord; begin -if Gear^.IntersectGear <> nil then - with Gear^ do - if (hwRound(IntersectGear^.X) + IntersectGear^.Radius < hwRound(X) - Radius) or - (hwRound(IntersectGear^.X) - IntersectGear^.Radius > hwRound(X) + Radius) then - begin - IntersectGear:= nil; - TestWord:= 0 - end else - TestWord:= 255 - else TestWord:= 0; +// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap +if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and + ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.X) - Gear^.Radius) or + (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.X) + Gear^.Radius)) then + Gear^.CollisionMask:= $FFFF; x:= hwRound(Gear^.X); -if Dir < 0 then x:= x - Gear^.Radius - else x:= x + Gear^.Radius; +if Dir < 0 then + x:= x - Gear^.Radius +else + x:= x + Gear^.Radius; + +TestCollisionXwithGear:= true; if (x and LAND_WIDTH_MASK) = 0 then - begin - y:= hwRound(Gear^.Y) - Gear^.Radius + 1; - i:= y + Gear^.Radius * 2 - 2; - repeat - if (y and LAND_HEIGHT_MASK) = 0 then - if Land[y, x] > TestWord then exit(true); - inc(y) - until (y > i); - end; + begin + y:= hwRound(Gear^.Y) - Gear^.Radius + 1; + i:= y + Gear^.Radius * 2 - 2; + repeat + if (y and LAND_HEIGHT_MASK) = 0 then + if Land[y, x] and Gear^.CollisionMask <> 0 then + exit; + inc(y) + until (y > i); + end; TestCollisionXwithGear:= false end; function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): Word; var x, y, i: LongInt; - TestWord: LongWord; begin -if Gear^.IntersectGear <> nil then - with Gear^ do - if (hwRound(IntersectGear^.Y) + IntersectGear^.Radius < hwRound(Y) - Radius) or - (hwRound(IntersectGear^.Y) - IntersectGear^.Radius > hwRound(Y) + Radius) then - begin - IntersectGear:= nil; - TestWord:= 0 - end else - TestWord:= 255 - else TestWord:= 0; +// Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap +if (Gear^.CollisionMask = $FF7F) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and + ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.Y) - Gear^.Radius) or + (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.Y) + Gear^.Radius)) then + Gear^.CollisionMask:= $FFFF; y:= hwRound(Gear^.Y); -if Dir < 0 then y:= y - Gear^.Radius - else y:= y + Gear^.Radius; +if Dir < 0 then + y:= y - Gear^.Radius +else + y:= y + Gear^.Radius; + if (y and LAND_HEIGHT_MASK) = 0 then - begin - x:= hwRound(Gear^.X) - Gear^.Radius + 1; - i:= x + Gear^.Radius * 2 - 2; - repeat - if (x and LAND_WIDTH_MASK) = 0 then - if Land[y, x] > TestWord then exit(Land[y, x]); - inc(x) - until (x > i); - end; + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and LAND_WIDTH_MASK) = 0 then + if Land[y, x] and Gear^.CollisionMask <> 0 then + begin + TestCollisionYwithGear:= Land[y, x]; + exit; + end; + inc(x) + until (x > i); + end; TestCollisionYwithGear:= 0 end; @@ -197,105 +203,131 @@ begin flag:= false; x:= hwRound(Gear^.X); -if Dir < 0 then x:= x - Gear^.Radius - else x:= x + Gear^.Radius; +if Dir < 0 then + x:= x - Gear^.Radius +else + x:= x + Gear^.Radius; + +TestCollisionXKick:= true; if (x and LAND_WIDTH_MASK) = 0 then - begin - y:= hwRound(Gear^.Y) - Gear^.Radius + 1; - i:= y + Gear^.Radius * 2 - 2; - repeat - if (y and LAND_HEIGHT_MASK) = 0 then - if Land[y, x] > 255 then exit(true) - else if Land[y, x] <> 0 then flag:= true; - inc(y) - until (y > i); - end; + begin + y:= hwRound(Gear^.Y) - Gear^.Radius + 1; + i:= y + Gear^.Radius * 2 - 2; + repeat + if (y and LAND_HEIGHT_MASK) = 0 then + if Land[y, x] > 255 then + exit + else if Land[y, x] <> 0 then + flag:= true; + inc(y) + until (y > i); + end; TestCollisionXKick:= flag; if flag then - begin - if hwAbs(Gear^.dX) < cHHKick then exit; - if (Gear^.State and gstHHJumping <> 0) - and (hwAbs(Gear^.dX) < _0_4) then exit; + begin + if hwAbs(Gear^.dX) < cHHKick then + exit; + if (Gear^.State and gstHHJumping <> 0) + and (hwAbs(Gear^.dX) < _0_4) then + exit; - mx:= hwRound(Gear^.X); - my:= hwRound(Gear^.Y); + mx:= hwRound(Gear^.X); + my:= hwRound(Gear^.Y); - for i:= 0 to Pred(Count) do - with cinfos[i] do - if (Gear <> cGear) and - (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and - ((mx > x) xor (Dir > 0)) then - if ((cGear^.Kind in [gtHedgehog, gtMine]) and ((Gear^.State and gstNotKickable) = 0)) or - // only apply X kick if the barrel is knocked over - ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) then - begin - with cGear^ do - begin - dX:= Gear^.dX; - dY:= Gear^.dY * _0_5; - State:= State or gstMoving; - Active:= true - end; - DeleteCI(cGear); - exit(false) - end - end + for i:= 0 to Pred(Count) do + with cinfos[i] do + if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) + and ((mx > x) xor (Dir > 0)) and + ( + ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or + // only apply X kick if the barrel is knocked over + ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0))) then + begin + with cGear^ do + begin + dX:= Gear^.dX; + dY:= Gear^.dY * _0_5; + State:= State or gstMoving; + if Kind = gtKnife then State:= State and (not gstCollision); + Active:= true + end; + DeleteCI(cGear); + TestCollisionXKick:= false; + exit; + end + end end; function TestCollisionYKick(Gear: PGear; Dir: LongInt): boolean; -var x, y, mx, my, i: LongInt; +var x, y, mx, my, myr, i: LongInt; flag: boolean; begin flag:= false; y:= hwRound(Gear^.Y); -if Dir < 0 then y:= y - Gear^.Radius - else y:= y + Gear^.Radius; +if Dir < 0 then + y:= y - Gear^.Radius +else + y:= y + Gear^.Radius; + +TestCollisionYKick:= true; if (y and LAND_HEIGHT_MASK) = 0 then - begin - x:= hwRound(Gear^.X) - Gear^.Radius + 1; - i:= x + Gear^.Radius * 2 - 2; - repeat - if (x and LAND_WIDTH_MASK) = 0 then + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and LAND_WIDTH_MASK) = 0 then if Land[y, x] > 0 then - if Land[y, x] > 255 then exit(true) - else if Land[y, x] <> 0 then flag:= true; - inc(x) - until (x > i); - end; + if Land[y, x] > 255 then + exit + else if Land[y, x] <> 0 then + flag:= true; + inc(x) + until (x > i); + end; TestCollisionYKick:= flag; if flag then - begin - if hwAbs(Gear^.dY) < cHHKick then exit(true); - if (Gear^.State and gstHHJumping <> 0) - and (not Gear^.dY.isNegative) - and (Gear^.dY < _0_4) then exit; + begin + if hwAbs(Gear^.dY) < cHHKick then + exit; + if (Gear^.State and gstHHJumping <> 0) and (not Gear^.dY.isNegative) and (Gear^.dY < _0_4) then + exit; - mx:= hwRound(Gear^.X); - my:= hwRound(Gear^.Y); + mx:= hwRound(Gear^.X); + my:= hwRound(Gear^.Y); + myr:= my+Gear^.Radius; - for i:= 0 to Pred(Count) do - with cinfos[i] do - if (Gear <> cGear) and - (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) and - ((my > y) xor (Dir > 0)) then - if (cGear^.Kind in [gtHedgehog, gtMine, gtExplosives]) and ((Gear^.State and gstNotKickable) = 0) then - begin - with cGear^ do - begin - if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then dX:= Gear^.dX * _0_5; - dY:= Gear^.dY; - State:= State or gstMoving; - Active:= true - end; - DeleteCI(cGear); - exit(false) - end - end + for i:= 0 to Pred(Count) do + with cinfos[i] do + if (Gear <> cGear) and (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) + and ((myr > y) xor (Dir > 0)) and + ( + (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and + ((Gear^.State and gstNotKickable) = 0)) then + begin + with cGear^ do + begin + if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then + dX:= Gear^.dX * _0_5; + dY:= Gear^.dY; + State:= State or gstMoving; + if Kind = gtKnife then State:= State and (not gstCollision); + Active:= true + end; + DeleteCI(cGear); + TestCollisionYKick:= false; + exit + end + end end; -function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean; +function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean; inline; +begin + TestCollisionXwithXYShift:= TestCollisionXwithXYShift(Gear, ShiftX, ShiftY, Dir, true); +end; + +function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean; begin Gear^.X:= Gear^.X + ShiftX; Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); @@ -305,22 +337,28 @@ Gear^.X:= Gear^.X - ShiftX; Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) end; + function TestCollisionX(Gear: PGear; Dir: LongInt): boolean; var x, y, i: LongInt; begin x:= hwRound(Gear^.X); -if Dir < 0 then x:= x - Gear^.Radius - else x:= x + Gear^.Radius; +if Dir < 0 then + x:= x - Gear^.Radius +else + x:= x + Gear^.Radius; + +TestCollisionX:= true; if (x and LAND_WIDTH_MASK) = 0 then - begin - y:= hwRound(Gear^.Y) - Gear^.Radius + 1; - i:= y + Gear^.Radius * 2 - 2; - repeat - if (y and LAND_HEIGHT_MASK) = 0 then - if Land[y, x] > 255 then exit(true); - inc(y) - until (y > i); - end; + begin + y:= hwRound(Gear^.Y) - Gear^.Radius + 1; + i:= y + Gear^.Radius * 2 - 2; + repeat + if (y and LAND_HEIGHT_MASK) = 0 then + if Land[y, x] > 255 then + exit; + inc(y) + until (y > i); + end; TestCollisionX:= false end; @@ -328,27 +366,41 @@ var x, y, i: LongInt; begin y:= hwRound(Gear^.Y); -if Dir < 0 then y:= y - Gear^.Radius - else y:= y + Gear^.Radius; +if Dir < 0 then + y:= y - Gear^.Radius +else + y:= y + Gear^.Radius; + +TestCollisionY:= true; if (y and LAND_HEIGHT_MASK) = 0 then - begin - x:= hwRound(Gear^.X) - Gear^.Radius + 1; - i:= x + Gear^.Radius * 2 - 2; - repeat - if (x and LAND_WIDTH_MASK) = 0 then - if Land[y, x] > 255 then exit(true); - inc(x) - until (x > i); - end; + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and LAND_WIDTH_MASK) = 0 then + if Land[y, x] > 255 then + exit; + inc(x) + until (x > i); + end; TestCollisionY:= false end; -function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean = true): boolean; +function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean; inline; +begin + TestCollisionYwithXYShift:= TestCollisionYwithXYShift(Gear, ShiftX, ShiftY, Dir, true); +end; + +function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): boolean; begin Gear^.X:= Gear^.X + int2hwFloat(ShiftX); Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); -if withGear then TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) <> 0 -else TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir); + +if withGear then + TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) <> 0 +else + TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir); + Gear^.X:= Gear^.X - int2hwFloat(ShiftX); Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) end; @@ -357,6 +409,8 @@ var x, y: LongInt; TestWord: LongWord; begin +TestRectancleForObstacle:= true; + if landOnly then TestWord:= 255 else @@ -377,13 +431,12 @@ end; if (hasBorder and ((y1 < 0) or (x1 < 0) or (x2 > LAND_WIDTH))) then - exit(true); + exit; for y := y1 to y2 do for x := x1 to x2 do - if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) - and (Land[y, x] > TestWord) then - exit(true); + if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > TestWord) then + exit; TestRectancleForObstacle:= false end; @@ -393,10 +446,12 @@ i, j, k, mx, my, li, ri, jfr, jto, tmpo : ShortInt; tmpx, tmpy: LongWord; dx, dy, s: hwFloat; - offset: Array[0..7,0..1] of ShortInt; + offset: array[0..7,0..1] of ShortInt; isColl: Boolean; begin + CalcSlopeTangent:= false; + dx:= Gear^.dX; dy:= Gear^.dY; @@ -442,13 +497,18 @@ end; end; - if i = 7 then break; + if i = 7 then + break; // prepare offset for next check (clockwise) - if (mx = -1) and (my <> -1) then my:= my - 1 - else if (my = -1) and (mx <> 1) then mx:= mx + 1 - else if (mx = 1) and (my <> 1) then my:= my + 1 - else mx:= mx - 1; + if (mx = -1) and (my <> -1) then + my:= my - 1 + else if (my = -1) and (mx <> 1) then + mx:= mx + 1 + else if (mx = 1) and (my <> 1) then + my:= my + 1 + else + mx:= mx - 1; end; @@ -475,15 +535,16 @@ tmpx:= ldx + k * offset[tmpo,0]; tmpy:= ldy + k * offset[tmpo,1]; if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) - and (Land[tmpy,tmpx] > TestWord) then - begin - ldx:= tmpx; - ldy:= tmpy; - isColl:= true; - break; - end; + and (Land[tmpy,tmpx] > TestWord) then + begin + ldx:= tmpx; + ldy:= tmpy; + isColl:= true; + break; + end; end; - if isColl then break; + if isColl then + break; end; jfr:= 8+ri-1; @@ -498,32 +559,127 @@ tmpx:= rdx + k * offset[tmpo,0]; tmpy:= rdy + k * offset[tmpo,1]; if (((tmpy) and LAND_HEIGHT_MASK) = 0) and (((tmpx) and LAND_WIDTH_MASK) = 0) - and (Land[tmpy,tmpx] > TestWord) then - begin - rdx:= tmpx; - rdy:= tmpy; - isColl:= true; - break; - end; + and (Land[tmpy,tmpx] > TestWord) then + begin + rdx:= tmpx; + rdy:= tmpy; + isColl:= true; + break; + end; end; - if isColl then break; + if isColl then + break; end; end; ldx:= rdx - ldx; ldy:= rdy - ldy; - if ((ldx = 0) and (ldy = 0)) then EXIT(false); + if ((ldx = 0) and (ldy = 0)) then + exit; outDeltaX:= ldx; outDeltaY:= ldy; -exit(true); +CalcSlopeTangent:= true; +end; + +function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; +var dx, dy: hwFloat; + collX, collY, i, y, x, gx, gy, sdx, sdy: LongInt; + isColl, bSucc: Boolean; +begin + +if dirY <> 0 then + begin + y:= hwRound(Gear^.Y) + Gear^.Radius * dirY; + gx:= hwRound(Gear^.X); + collX := gx; + isColl:= false; + + if (y and LAND_HEIGHT_MASK) = 0 then + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and LAND_WIDTH_MASK) = 0 then + if Land[y, x] <> 0 then + if (not isColl) or (abs(x-gx) < abs(collX-gx)) then + begin + isColl:= true; + collX := x; + end; + inc(x) + until (x > i); + end; + end +else + begin + x:= hwRound(Gear^.X) + Gear^.Radius * dirX; + gy:= hwRound(Gear^.Y); + collY := gy; + isColl:= false; + + if (x and LAND_WIDTH_MASK) = 0 then + begin + y:= hwRound(Gear^.Y) - Gear^.Radius + 1; + i:= y + Gear^.Radius * 2 - 2; + repeat + if (y and LAND_HEIGHT_MASK) = 0 then + if Land[y, x] <> 0 then + if (not isColl) or (abs(y-gy) < abs(collY-gy)) then + begin + isColl:= true; + collY := y; + end; + inc(y) + until (y > i); + end; + end; + +if isColl then + begin + // save original dx/dy + dx := Gear^.dX; + dy := Gear^.dY; + + if dirY <> 0 then + begin + Gear^.dX.QWordValue:= 0; + Gear^.dX.isNegative:= (collX >= gx); + Gear^.dY:= _1*dirY + end + else + begin + Gear^.dY.QWordValue:= 0; + Gear^.dY.isNegative:= (collY >= gy); + Gear^.dX:= _1*dirX + end; + + sdx:= 0; + sdy:= 0; + if dirY <> 0 then + bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 0) + else bSucc := CalcSlopeTangent(Gear, x, collY, sdx, sdy, 0); + + // restore original dx/dy + Gear^.dX := dx; + Gear^.dY := dy; + + if bSucc and ((sdx <> 0) or (sdy <> 0)) then + begin + dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy)); + dx.isNegative := (sdx * sdy) < 0; + exit (dx); + end + end; + +CalcSlopeNearGear := _0; end; function CalcSlopeBelowGear(Gear: PGear): hwFloat; var dx, dy: hwFloat; collX, i, y, x, gx, sdx, sdy: LongInt; - isColl, succ: Boolean; + isColl, bSucc: Boolean; begin @@ -533,20 +689,20 @@ isColl:= false; if (y and LAND_HEIGHT_MASK) = 0 then - begin - x:= hwRound(Gear^.X) - Gear^.Radius + 1; - i:= x + Gear^.Radius * 2 - 2; - repeat - if (x and LAND_WIDTH_MASK) = 0 then + begin + x:= hwRound(Gear^.X) - Gear^.Radius + 1; + i:= x + Gear^.Radius * 2 - 2; + repeat + if (x and LAND_WIDTH_MASK) = 0 then if Land[y, x] > 255 then - if not isColl or (abs(x-gx) < abs(collX-gx)) then + if (not isColl) or (abs(x-gx) < abs(collX-gx)) then begin isColl:= true; collX := x; end; - inc(x) - until (x > i); - end; + inc(x) + until (x > i); + end; if isColl then begin @@ -560,13 +716,13 @@ sdx:= 0; sdy:= 0; - succ := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 255); + bSucc := CalcSlopeTangent(Gear, collX, y, sdx, sdy, 255); // restore original dx/dy Gear^.dX := dx; Gear^.dY := dy; - if succ and (sdx <> 0) and (sdy <> 0) then + if bSucc and (sdx <> 0) and (sdy <> 0) then begin dx := int2hwFloat(sdy) / (abs(sdx) + abs(sdy)); dx.isNegative := (sdx * sdy) < 0; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uCommandHandlers.pas --- a/hedgewars/uCommandHandlers.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uCommandHandlers.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,21 +26,24 @@ procedure freeModule; implementation -uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions; +uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions + {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}; + +var prevGState: TGameState = gsConfirm; procedure chGenCmd(var s: shortstring); begin case s[1] of - 'R': if ReadyTimeLeft > 1 then - begin - ReadyTimeLeft:= 1; - if not CurrentTeam^.ExtDriven then SendIPC('c'+s); - end + 'R': if ReadyTimeLeft > 1 then + begin + ReadyTimeLeft:= 1; + if not isExternalSource then + SendIPC('c'+s); + end end end; procedure chQuit(var s: shortstring); -const prevGState: TGameState = gsConfirm; begin s:= s; // avoid compiler hint if (GameState = gsGame) or (GameState = gsChat) then @@ -48,7 +51,8 @@ prevGState:= GameState; GameState:= gsConfirm; SDL_ShowCursor(1) - end else + end + else if GameState = gsConfirm then begin GameState:= prevGState; @@ -67,18 +71,18 @@ begin s:= s; // avoid compiler hint if GameState = gsConfirm then - begin - SendIPC('Q'); + begin + SendIPC(_S'Q'); GameState:= gsExit - end -else - ParseCommand('chat team', true); + end + else + ParseCommand('chat team', true); end; procedure chHalt (var s: shortstring); begin s:= s; // avoid compiler hint - SendIPC('H'); + SendIPC(_S'H'); GameState:= gsExit end; @@ -88,48 +92,60 @@ if isDeveloperMode then begin val(s, i, c); - if (c <> 0) or (i = 0) then exit; TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true); - end + end end; procedure chTeamLocal(var s: shortstring); begin s:= s; // avoid compiler hint -if not isDeveloperMode then exit; -if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/rdriven"', true); +if not isDeveloperMode then + exit; +if CurrentTeam = nil then + OutError(errmsgIncorrectUse + ' "/rdriven"', true); CurrentTeam^.ExtDriven:= true end; procedure chGrave(var s: shortstring); begin -if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true); -if s[1]='"' then Delete(s, 1, 1); -if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); +if CurrentTeam = nil then + OutError(errmsgIncorrectUse + ' "/grave"', true); +if s[1]='"' then + Delete(s, 1, 1); +if s[byte(s[0])]='"' then + Delete(s, byte(s[0]), 1); CurrentTeam^.GraveName:= s end; procedure chFort(var s: shortstring); begin -if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/fort"', true); -if s[1]='"' then Delete(s, 1, 1); -if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); +if CurrentTeam = nil then + OutError(errmsgIncorrectUse + ' "/fort"', true); +if s[1]='"' then + Delete(s, 1, 1); +if s[byte(s[0])]='"' then + Delete(s, byte(s[0]), 1); CurrentTeam^.FortName:= s end; procedure chFlag(var s: shortstring); begin -if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/flag"', true); -if s[1]='"' then Delete(s, 1, 1); -if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); +if CurrentTeam = nil then + OutError(errmsgIncorrectUse + ' "/flag"', true); +if s[1]='"' then + Delete(s, 1, 1); +if s[byte(s[0])]='"' then + Delete(s, byte(s[0]), 1); CurrentTeam^.flag:= s end; procedure chScript(var s: shortstring); begin -if s[1]='"' then Delete(s, 1, 1); -if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); +if s[1]='"' then + Delete(s, 1, 1); +if s[byte(s[0])]='"' then + Delete(s, byte(s[0]), 1); cScriptName:= s; ScriptLoad(s) end; @@ -140,9 +156,9 @@ with CurrentTeam^ do begin if not CurrentHedgehog^.King then - if (s = '') or - (((GameFlags and gfKing) <> 0) and (s = 'crown')) or - ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then + if (s = '') + or (((GameFlags and gfKing) <> 0) and (s = 'crown')) + or ((Length(s) > 39) and (Copy(s,1,8) = 'Reserved') and (Copy(s,9,32) <> PlayerHash)) then CurrentHedgehog^.Hat:= 'NoHat' else CurrentHedgehog^.Hat:= s @@ -200,8 +216,10 @@ procedure chLeft_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('L'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'L'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmLeft and InputMask); @@ -211,18 +229,22 @@ procedure chLeft_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; -if not CurrentTeam^.ExtDriven then SendIPC('l'); +if CheckNoTeamOrHH then + exit; +if not isExternalSource then + SendIPC(_S'l'); with CurrentHedgehog^.Gear^ do - Message:= Message and not (gmLeft and InputMask); + Message:= Message and (not (gmLeft and InputMask)); ScriptCall('onLeftUp'); end; procedure chRight_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('R'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'R'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmRight and InputMask); @@ -232,18 +254,22 @@ procedure chRight_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; -if not CurrentTeam^.ExtDriven then SendIPC('r'); +if CheckNoTeamOrHH then + exit; +if not isExternalSource then + SendIPC(_S'r'); with CurrentHedgehog^.Gear^ do - Message:= Message and not (gmRight and InputMask); + Message:= Message and (not (gmRight and InputMask)); ScriptCall('onRightUp'); end; procedure chUp_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('U'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'U'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmUp and InputMask); @@ -253,18 +279,22 @@ procedure chUp_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; -if not CurrentTeam^.ExtDriven then SendIPC('u'); +if CheckNoTeamOrHH then + exit; +if not isExternalSource then + SendIPC(_S'u'); with CurrentHedgehog^.Gear^ do - Message:= Message and not (gmUp and InputMask); + Message:= Message and (not (gmUp and InputMask)); ScriptCall('onUpUp'); end; procedure chDown_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('D'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'D'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmDown and InputMask); @@ -274,18 +304,22 @@ procedure chDown_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; -if not CurrentTeam^.ExtDriven then SendIPC('d'); +if CheckNoTeamOrHH then + exit; +if not isExternalSource then + SendIPC(_S'd'); with CurrentHedgehog^.Gear^ do - Message:= Message and not (gmDown and InputMask); + Message:= Message and (not (gmDown and InputMask)); ScriptCall('onDownUp'); end; procedure chPrecise_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('Z'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'Z'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmPrecise and InputMask); @@ -295,18 +329,22 @@ procedure chPrecise_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; -if not CurrentTeam^.ExtDriven then SendIPC('z'); +if CheckNoTeamOrHH then + exit; +if not isExternalSource then + SendIPC(_S'z'); with CurrentHedgehog^.Gear^ do - Message:= Message and not (gmPrecise and InputMask); + Message:= Message and (not (gmPrecise and InputMask)); ScriptCall('onPreciseUp'); end; procedure chLJump(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('j'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'j'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmLJump and InputMask); @@ -316,8 +354,10 @@ procedure chHJump(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('J'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'J'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmHJump and InputMask); @@ -327,7 +367,8 @@ procedure chAttack_p(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused then + exit; bShowFinger:= false; with CurrentHedgehog^.Gear^ do begin @@ -335,7 +376,8 @@ if ((State and gstHHDriven) <> 0) then begin FollowGear:= CurrentHedgehog^.Gear; - if not CurrentTeam^.ExtDriven then SendIPC('A'); + if not isExternalSource then + SendIPC(_S'A'); Message:= Message or (gmAttack and InputMask); ScriptCall('onAttack'); end @@ -345,12 +387,14 @@ procedure chAttack_m(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH then exit; +if CheckNoTeamOrHH then + exit; with CurrentHedgehog^.Gear^ do begin - if not CurrentTeam^.ExtDriven and - ((Message and gmAttack) <> 0) then SendIPC('a'); - Message:= Message and not (gmAttack and InputMask); + if not isExternalSource and + ((Message and gmAttack) <> 0) then + SendIPC(_S'a'); + Message:= Message and (not (gmAttack and InputMask)); ScriptCall('onAttackUp'); end end; @@ -358,8 +402,10 @@ procedure chSwitch(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; -if not CurrentTeam^.ExtDriven then SendIPC('S'); +if CheckNoTeamOrHH or isPaused then + exit; +if not isExternalSource then + SendIPC(_S'S'); bShowFinger:= false; with CurrentHedgehog^.Gear^ do Message:= Message or (gmSwitch and InputMask); @@ -367,73 +413,110 @@ end; procedure chNextTurn(var s: shortstring); +var gi: PGear; begin s:= s; // avoid compiler hint + TryDo(AllInactive, '/nextturn called when not all gears are inactive', true); - if not CurrentTeam^.ExtDriven then SendIPC('N'); - AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks)); + CheckSum:= CheckSum xor GameTicks; + gi := GearsList; + while gi <> nil do + begin + with gi^ do CheckSum:= CheckSum xor X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac; + AddRandomness(CheckSum); + gi := gi^.NextGear + end; + + if not isExternalSource then + begin + s[0]:= #5; + s[1]:= 'N'; + SDLNet_Write32(CheckSum, @s[2]); + SendIPC(s) + end + else + TryDo(CurrentTeam^.hasGone or (CheckSum = lastTurnChecksum), 'Desync detected', true); + + AddFileLog('Next turn: time '+inttostr(GameTicks)); end; procedure chTimer(var s: shortstring); begin -if (s[0] <> #1) or (s[1] < '1') or (s[1] > '5') or CheckNoTeamOrHH then exit; +if CheckNoTeamOrHH then + exit; -if not CurrentTeam^.ExtDriven then SendIPC(s); +TryDo((s[0] = #1) and (s[1] >= '1') and (s[1] <= '5'), 'Malformed /timer', true); + +if not isExternalSource then + SendIPC(s); bShowFinger:= false; with CurrentHedgehog^.Gear^ do begin Message:= Message or (gmTimer and InputMask); MsgParam:= byte(s[1]) - ord('0'); - ScriptCall('onTimer'); + ScriptCall('onTimer', MsgParam); end end; procedure chSlot(var s: shortstring); var slot: LongWord; + ss: shortstring; begin -if (s[0] <> #1) or CheckNoTeamOrHH then exit; +if (s[0] <> #1) or CheckNoTeamOrHH then + exit; slot:= byte(s[1]) - 49; -if slot > cMaxSlotIndex then exit; -if not CurrentTeam^.ExtDriven then SendIPC(char(byte(s[1]) + 79)); +if slot > cMaxSlotIndex then + exit; +if not isExternalSource then + begin + ss[0]:= #1; + ss[1]:= char(byte(s[1]) + 79); + SendIPC(ss); + end; bShowFinger:= false; with CurrentHedgehog^.Gear^ do begin Message:= Message or (gmSlot and InputMask); MsgParam:= slot; - ScriptCall('onSlot'); + ScriptCall('onSlot', MsgParam); end end; procedure chSetWeapon(var s: shortstring); begin - if (s[0] <> #1) or CheckNoTeamOrHH then exit; + if CheckNoTeamOrHH then + exit; - if TAmmoType(s[1]) > High(TAmmoType) then exit; + TryDo((s[0] = #1) and (s[1] <= char(High(TAmmoType))), 'Malformed /setweap', true); - if not CurrentTeam^.ExtDriven then SendIPC('w' + s); + if not isExternalSource then + SendIPC('w' + s); with CurrentHedgehog^.Gear^ do - begin + begin Message:= Message or (gmWeapon and InputMask); MsgParam:= byte(s[1]); - ScriptCall('onSetWeapon'); - end; + ScriptCall('onSetWeapon', MsgParam); + end; end; procedure chTaunt(var s: shortstring); begin -if (s[0] <> #1) or CheckNoTeamOrHH then exit; +if (s[0] <> #1) or CheckNoTeamOrHH then + exit; -if TWave(s[1]) > High(TWave) then exit; +if TWave(s[1]) > High(TWave) then + exit; -if not CurrentTeam^.ExtDriven then SendIPC('t' + s); +if not isExternalSource then + SendIPC('t' + s); with CurrentHedgehog^.Gear^ do begin Message:= Message or (gmAnimate and InputMask); MsgParam:= byte(s[1]) ; - ScriptCall('onTaunt'); + ScriptCall('onTaunt', MsgParam); end end; @@ -449,38 +532,57 @@ flagMakeCapture:= true end; +procedure chRecord(var s: shortstring); +begin +s:= s; // avoid compiler hint +{$IFDEF USE_VIDEO_RECORDING} +if flagPrerecording then + StopPreRecording() +else + BeginPreRecording(); +{$ENDIF} +end; + procedure chSetMap(var s: shortstring); begin if isDeveloperMode then begin - UserPathz[ptMapCurrent]:= UserPathz[ptMaps] + '/' + s; - Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; + if s = '' then + begin + UserPathz[ptMapCurrent]:= s; + Pathz[ptMapCurrent]:= s; + end + else + begin + UserPathz[ptMapCurrent]:= UserPathz[ptMaps] + '/' + s; + Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s; + end; InitStepsFlags:= InitStepsFlags or cifMap end; - +cMapName:= s; ScriptLoad('Maps/' + s + '/map.lua') end; procedure chSetTheme(var s: shortstring); begin if isDeveloperMode then -begin -UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s; -Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; -Theme:= s; -InitStepsFlags:= InitStepsFlags or cifTheme -end + begin + UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s; + Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s; + Theme:= s; + InitStepsFlags:= InitStepsFlags or cifTheme + end end; procedure chSetSeed(var s: shortstring); begin if isDeveloperMode then -begin -SetRandomSeed(s); -cSeed:= s; -InitStepsFlags:= InitStepsFlags or cifRandomize -end -end; + begin + SetRandomSeed(s); + cSeed:= s; + InitStepsFlags:= InitStepsFlags or cifRandomize + end + end; procedure chAmmoMenu(var s: shortstring); begin @@ -494,10 +596,15 @@ begin bSelected:= false; - if bShowAmmoMenu then bShowAmmoMenu:= false - else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) or - ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) or - ((Gear^.State and gstHHDriven) = 0) then else bShowAmmoMenu:= true + if bShowAmmoMenu then + bShowAmmoMenu:= false + else if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) + or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) + or ((Gear^.State and gstHHDriven) = 0) then + begin + end + else + bShowAmmoMenu:= true end; end end; @@ -517,17 +624,21 @@ procedure chFindhh(var s: shortstring); begin s:= s; // avoid compiler hint -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused then + exit; -if FollowGear <> nil then +if autoCameraOn then begin + FollowGear:= nil; AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume); autoCameraOn:= false end - else begin +else + begin AddCaption('Auto Camera On', $CCCCCC, capgrpVolume); bShowFinger:= true; - if not CurrentHedgehog^.Unplaced then FollowGear:= CurrentHedgehog^.Gear; + if not CurrentHedgehog^.Unplaced then + FollowGear:= CurrentHedgehog^.Gear; autoCameraOn:= true end end; @@ -547,12 +658,16 @@ procedure chRotateMask(var s: shortstring); begin s:= s; // avoid compiler hint -if ((GameFlags and gfInvulnerable) = 0) then cTagsMask:= cTagsMasks[cTagsMask] else cTagsMask:= cTagsMasksNoHealth[cTagsMask]; +if ((GameFlags and gfInvulnerable) = 0) then + cTagsMask:= cTagsMasks[cTagsMask] +else + cTagsMask:= cTagsMasksNoHealth[cTagsMask]; end; procedure chSpeedup_p(var s: shortstring); begin s:= s; // avoid compiler hint +SpeedStart:= RealTicks; isSpeed:= true end; @@ -582,90 +697,197 @@ ZoomValue:= cDefaultZoomLevel; end; +procedure chMapGen(var s: shortstring); +begin +cMapGen:= StrToInt(s) +end; + +procedure chTemplateFilter(var s: shortstring); +begin +cTemplateFilter:= StrToInt(s) +end; + +procedure chInactDelay(var s: shortstring); +begin +cInactDelay:= StrToInt(s) +end; + +procedure chReadyDelay(var s: shortstring); +begin +cReadyDelay:= StrToInt(s) +end; + +procedure chCaseFactor(var s: shortstring); +begin +cCaseFactor:= StrToInt(s) +end; + +procedure chHealthCaseProb(var s: shortstring); +begin +cHealthCaseProb:= StrToInt(s) +end; + +procedure chHealthCaseAmount(var s: shortstring); +begin +cHealthCaseAmount:= StrToInt(s) +end; + +procedure chSuddenDTurns(var s: shortstring); +begin +cSuddenDTurns:= StrToInt(s) +end; + +procedure chWaterRise(var s: shortstring); +begin +cWaterRise:= StrToInt(s) +end; + +procedure chHealthDecrease(var s: shortstring); +begin +cHealthDecrease:= StrToInt(s) +end; + +procedure chDamagePercent(var s: shortstring); +begin +cDamagePercent:= StrToInt(s) +end; + +procedure chRopePercent(var s: shortstring); +begin +cRopePercent:= StrToInt(s) +end; + +procedure chGetAwayTime(var s: shortstring); +begin +cGetAwayTime:= StrToInt(s) +end; + +procedure chMineDudPercent(var s: shortstring); +begin +cMineDudPercent:= StrToInt(s) +end; + +procedure chLandMines(var s: shortstring); +begin +cLandMines:= StrToInt(s) +end; + +procedure chExplosives(var s: shortstring); +begin +cExplosives:= StrToInt(s) +end; + +procedure chGameFlags(var s: shortstring); +begin +GameFlags:= StrToInt(s); +if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo) +end; + +procedure chHedgehogTurnTime(var s: shortstring); +begin +cHedgehogTurnTime:= StrToInt(s) +end; + +procedure chMinesTime(var s: shortstring); +begin +cMinesTime:= StrToInt(s) +end; + +procedure chFastUntilLag(var s: shortstring); +begin +fastUntilLag:= StrToInt(s) <> 0 +end; + +procedure chCampVar(var s:shortstring); +begin + CampaignVariable := s; +end; procedure initModule; begin //////// Begin top sorted by freq analysis not including chatmsg - RegisterVariable('+right' , vtCommand, @chRight_p , false); - RegisterVariable('-right' , vtCommand, @chRight_m , false); - RegisterVariable('+up' , vtCommand, @chUp_p , false); - RegisterVariable('-up' , vtCommand, @chUp_m , false); - RegisterVariable('+left' , vtCommand, @chLeft_p , false); - RegisterVariable('-left' , vtCommand, @chLeft_m , false); - RegisterVariable('+attack' , vtCommand, @chAttack_p , false); - RegisterVariable('+down' , vtCommand, @chDown_p , false); - RegisterVariable('-down' , vtCommand, @chDown_m , false); - RegisterVariable('hjump' , vtCommand, @chHJump , false); - RegisterVariable('ljump' , vtCommand, @chLJump , false); - RegisterVariable('nextturn', vtCommand, @chNextTurn , false); - RegisterVariable('-attack' , vtCommand, @chAttack_m , false); - RegisterVariable('slot' , vtCommand, @chSlot , false); - RegisterVariable('setweap' , vtCommand, @chSetWeapon , false); + RegisterVariable('+right' , @chRight_p , false, true); + RegisterVariable('-right' , @chRight_m , false, true); + RegisterVariable('+up' , @chUp_p , false, true); + RegisterVariable('-up' , @chUp_m , false, true); + RegisterVariable('+left' , @chLeft_p , false, true); + RegisterVariable('-left' , @chLeft_m , false, true); + RegisterVariable('+attack' , @chAttack_p , false); + RegisterVariable('+down' , @chDown_p , false, true); + RegisterVariable('-down' , @chDown_m , false, true); + RegisterVariable('hjump' , @chHJump , false, true); + RegisterVariable('ljump' , @chLJump , false, true); + RegisterVariable('nextturn', @chNextTurn , false); + RegisterVariable('-attack' , @chAttack_m , false); + RegisterVariable('slot' , @chSlot , false); + RegisterVariable('setweap' , @chSetWeapon , false, true); //////// End top by freq analysis - RegisterVariable('gencmd' , vtCommand, @chGenCmd , false); - RegisterVariable('flag' , vtCommand, @chFlag , false); - RegisterVariable('script' , vtCommand, @chScript , false); - RegisterVariable('proto' , vtCommand, @chCheckProto , true ); - RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); - RegisterVariable('capture' , vtCommand, @chCapture , true ); - RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); - RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); - RegisterVariable('map' , vtCommand, @chSetMap , false); - RegisterVariable('theme' , vtCommand, @chSetTheme , false); - RegisterVariable('seed' , vtCommand, @chSetSeed , false); - RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); - RegisterVariable('mapgen' , vtLongInt, @cMapGen , false); - RegisterVariable('maze_size',vtLongInt, @cTemplateFilter, false); - RegisterVariable('delay' , vtLongInt, @cInactDelay , false); - RegisterVariable('ready' , vtLongInt, @cReadyDelay , false); - RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); - RegisterVariable('healthprob', vtLongInt, @cHealthCaseProb, false); - RegisterVariable('hcaseamount', vtLongInt, @cHealthCaseAmount, false); - RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); - RegisterVariable('waterrise', vtLongInt, @cWaterRise , false); - RegisterVariable('healthdec', vtLongInt, @cHealthDecrease, false); - RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); - RegisterVariable('ropepct' , vtLongInt, @cRopePercent , false); - RegisterVariable('getawaytime' , vtLongInt, @cGetAwayTime , false); - RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); - RegisterVariable('minesnum', vtLongInt, @cLandMines , false); - RegisterVariable('explosives',vtLongInt,@cExplosives , false); - RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); - RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); - RegisterVariable('minestime',vtLongInt, @cMinesTime , false); - RegisterVariable('fort' , vtCommand, @chFort , false); - RegisterVariable('grave' , vtCommand, @chGrave , false); - RegisterVariable('hat' , vtCommand, @chSetHat , false); - RegisterVariable('quit' , vtCommand, @chQuit , true ); - RegisterVariable('forcequit', vtCommand, @chForceQuit , true ); - RegisterVariable('confirm' , vtCommand, @chConfirm , true ); - RegisterVariable('halt', vtCommand, @chHalt , true ); - RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); - RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); - RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); - RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); - RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); - RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); - RegisterVariable('+precise', vtCommand, @chPrecise_p , false); - RegisterVariable('-precise', vtCommand, @chPrecise_m , false); - RegisterVariable('switch' , vtCommand, @chSwitch , false); - RegisterVariable('timer' , vtCommand, @chTimer , false); - RegisterVariable('taunt' , vtCommand, @chTaunt , false); - RegisterVariable('put' , vtCommand, @chPut , false); - RegisterVariable('+volup' , vtCommand, @chVol_p , true ); - RegisterVariable('-volup' , vtCommand, @chVol_m , true ); - RegisterVariable('+voldown', vtCommand, @chVol_m , true ); - RegisterVariable('-voldown', vtCommand, @chVol_p , true ); - RegisterVariable('findhh' , vtCommand, @chFindhh , true ); - RegisterVariable('pause' , vtCommand, @chPause , true ); - RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); - RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); - RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); - RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); - RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); - RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); - RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); - RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); + RegisterVariable('gencmd' , @chGenCmd , false); + RegisterVariable('flag' , @chFlag , false); + RegisterVariable('script' , @chScript , false); + RegisterVariable('proto' , @chCheckProto , true ); + RegisterVariable('spectate', @chFastUntilLag , false); + RegisterVariable('capture' , @chCapture , true ); + RegisterVariable('rotmask' , @chRotateMask , true ); + RegisterVariable('rdriven' , @chTeamLocal , false); + RegisterVariable('map' , @chSetMap , false); + RegisterVariable('theme' , @chSetTheme , false); + RegisterVariable('seed' , @chSetSeed , false); + RegisterVariable('template_filter', @chTemplateFilter, false); + RegisterVariable('mapgen' , @chMapGen , false); + RegisterVariable('maze_size',@chTemplateFilter, false); + RegisterVariable('delay' , @chInactDelay , false); + RegisterVariable('ready' , @chReadyDelay , false); + RegisterVariable('casefreq', @chCaseFactor , false); + RegisterVariable('healthprob', @chHealthCaseProb, false); + RegisterVariable('hcaseamount', @chHealthCaseAmount, false); + RegisterVariable('sd_turns', @chSuddenDTurns , false); + RegisterVariable('waterrise', @chWaterRise , false); + RegisterVariable('healthdec', @chHealthDecrease, false); + RegisterVariable('damagepct',@chDamagePercent , false); + RegisterVariable('ropepct' , @chRopePercent , false); + RegisterVariable('getawaytime' , @chGetAwayTime , false); + RegisterVariable('minedudpct',@chMineDudPercent, false); + RegisterVariable('minesnum', @chLandMines , false); + RegisterVariable('explosives',@chExplosives , false); + RegisterVariable('gmflags' , @chGameFlags , false); + RegisterVariable('turntime', @chHedgehogTurnTime, false); + RegisterVariable('minestime',@chMinesTime , false); + RegisterVariable('fort' , @chFort , false); + RegisterVariable('grave' , @chGrave , false); + RegisterVariable('hat' , @chSetHat , false); + RegisterVariable('quit' , @chQuit , true ); + RegisterVariable('forcequit', @chForceQuit , true ); + RegisterVariable('confirm' , @chConfirm , true ); + RegisterVariable('halt', @chHalt , true ); + RegisterVariable('+speedup', @chSpeedup_p , true ); + RegisterVariable('-speedup', @chSpeedup_m , true ); + RegisterVariable('zoomin' , @chZoomIn , true ); + RegisterVariable('zoomout' , @chZoomOut , true ); + RegisterVariable('zoomreset',@chZoomReset , true ); + RegisterVariable('ammomenu', @chAmmoMenu , true); + RegisterVariable('+precise', @chPrecise_p , false, true); + RegisterVariable('-precise', @chPrecise_m , false, true); + RegisterVariable('switch' , @chSwitch , false); + RegisterVariable('timer' , @chTimer , false, true); + RegisterVariable('taunt' , @chTaunt , false); + RegisterVariable('put' , @chPut , false); + RegisterVariable('+volup' , @chVol_p , true ); + RegisterVariable('-volup' , @chVol_m , true ); + RegisterVariable('+voldown', @chVol_m , true ); + RegisterVariable('-voldown', @chVol_p , true ); + RegisterVariable('findhh' , @chFindhh , true ); + RegisterVariable('pause' , @chPause , true ); + RegisterVariable('+cur_u' , @chCurU_p , true ); + RegisterVariable('-cur_u' , @chCurU_m , true ); + RegisterVariable('+cur_d' , @chCurD_p , true ); + RegisterVariable('-cur_d' , @chCurD_m , true ); + RegisterVariable('+cur_l' , @chCurL_p , true ); + RegisterVariable('-cur_l' , @chCurL_m , true ); + RegisterVariable('+cur_r' , @chCurR_p , true ); + RegisterVariable('-cur_r' , @chCurR_m , true ); + RegisterVariable('campvar' , @chCampVar , true ); + RegisterVariable('record' , @chRecord , true ); end; procedure freeModule; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uCommands.pas --- a/hedgewars/uCommands.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uCommands.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,112 +23,125 @@ interface var isDeveloperMode: boolean; -type TVariableType = (vtCommand, vtLongInt, vthwFloat, vtBoolean); - TCommandHandler = procedure (var params: shortstring); +var isExternalSource: boolean; +type TCommandHandler = procedure (var params: shortstring); procedure initModule; procedure freeModule; -procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean); -procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); +procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean); +procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean); +procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); inline; +procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean); +procedure ParseTeamCommand(s: shortstring); procedure StopMessages(Message: Longword); implementation -uses Types, uConsts, uVariables, uConsole, uUtils, uDebug; +uses uConsts, uVariables, uConsole, uUtils, uDebug, SDLh; type PVariable = ^TVariable; - TVariable = record - Next: PVariable; - Name: string[15]; - VType: TVariableType; - Handler: pointer; - Trusted: boolean; - end; + TVariable = record + Next: PVariable; + Name: string[15]; + Handler: TCommandHandler; + Trusted, Rand: boolean; + end; -var - Variables: PVariable; +var Variables: PVariable; -procedure RegisterVariable(Name: shortstring; VType: TVariableType; p: pointer; Trusted: boolean); -var value: PVariable; +procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean); +begin +RegisterVariable(Name, p, Trusted, false); +end; +procedure RegisterVariable(Name: shortstring; p: TCommandHandler; Trusted: boolean; Rand: boolean); +var + value: PVariable; begin New(value); TryDo(value <> nil, 'RegisterVariable: value = nil', true); FillChar(value^, sizeof(TVariable), 0); value^.Name:= Name; -value^.VType:= VType; value^.Handler:= p; value^.Trusted:= Trusted; +value^.Rand:= Rand; -if Variables = nil then Variables:= value - else begin - value^.Next:= Variables; - Variables:= value - end; +if Variables = nil then + Variables:= value +else + begin + value^.Next:= Variables; + Variables:= value + end; end; -procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); -var ii: LongInt; - s: shortstring; +procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); inline; +begin + ParseCommand(CmdStr, TrustedSource, false) +end; + +procedure ParseCommand(CmdStr: shortstring; TrustedSource, ExternalSource: boolean); +var s: shortstring; t: PVariable; c: char; begin +isExternalSource:= ExternalSource or ((CurrentTeam <> nil) and CurrentTeam^.ExtDriven); //WriteLnToConsole(CmdStr); -if CmdStr[0]=#0 then exit; +if CmdStr[0]=#0 then + exit; c:= CmdStr[1]; -if c in ['/', '$'] then Delete(CmdStr, 1, 1) else c:= '/'; +if (c = '/') or (c = '$') then + Delete(CmdStr, 1, 1); s:= ''; SplitBySpace(CmdStr, s); -AddFileLog('[Cmd] ' + c + CmdStr + ' (' + inttostr(length(s)) + ')'); +AddFileLog('[Cmd] ' + CmdStr + ' (' + inttostr(length(s)) + ')'); + t:= Variables; while t <> nil do - begin - if t^.Name = CmdStr then - begin - if TrustedSource or t^.Trusted then - case t^.VType of - vtCommand: if c='/' then - begin - TCommandHandler(t^.Handler)(s); - end; - vtLongInt: if c='$' then - if s[0]=#0 then - begin - str(PLongInt(t^.Handler)^, s); - WriteLnToConsole('$' + CmdStr + ' is "' + s + '"'); - end else val(s, PLongInt(t^.Handler)^); - vthwFloat: if c='$' then - if s[0]=#0 then - begin - //str(PhwFloat(t^.Handler)^:4:6, s); - WriteLnToConsole('$' + CmdStr + ' is "' + s + '"'); - end else; //val(s, PhwFloat(t^.Handler)^, i); - vtBoolean: if c='$' then - if s[0]=#0 then - begin - str(ord(boolean(t^.Handler^)), s); - WriteLnToConsole('$' + CmdStr + ' is "' + s + '"'); - end else - begin - val(s, ii); - boolean(t^.Handler^):= not (ii = 0) - end; - end; - exit - end else t:= t^.Next - end; + begin + if t^.Name = CmdStr then + begin + if TrustedSource or t^.Trusted then + begin + if t^.Rand and (not CheckNoTeamOrHH) then + CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks; + t^.Handler(s); + end; + exit + end + else + t:= t^.Next + end; case c of - '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"') - else WriteLnToConsole(errmsgUnknownCommand + ': "/' + CmdStr + '"') end + '$': WriteLnToConsole(errmsgUnknownVariable + ': "$' + CmdStr + '"') + else + WriteLnToConsole(errmsgUnknownCommand + ': "/' + CmdStr + '"') end end; +procedure ParseTeamCommand(s: shortstring); +var Trusted: boolean; +begin +Trusted:= (CurrentTeam <> nil) + and (not CurrentTeam^.ExtDriven) + and (CurrentHedgehog^.BotLevel = 0); +ParseCommand(s, Trusted); +if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then + ParseCommand('gencmd R', true) +end; + + procedure StopMessages(Message: Longword); begin -if (Message and gmLeft) <> 0 then ParseCommand('/-left', true) else -if (Message and gmRight) <> 0 then ParseCommand('/-right', true) else -if (Message and gmUp) <> 0 then ParseCommand('/-up', true) else -if (Message and gmDown) <> 0 then ParseCommand('/-down', true) else -if (Message and gmAttack) <> 0 then ParseCommand('/-attack', true) +if (Message and gmLeft) <> 0 then + ParseCommand('/-left', true) +else if (Message and gmRight) <> 0 then + ParseCommand('/-right', true) +else if (Message and gmUp) <> 0 then + ParseCommand('/-up', true) +else if (Message and gmDown) <> 0 then + ParseCommand('/-down', true) +else if (Message and gmAttack) <> 0 then + ParseCommand('/-attack', true) end; procedure initModule; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uConsole.pas --- a/hedgewars/uConsole.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uConsole.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,18 +26,18 @@ procedure WriteToConsole(s: shortstring); procedure WriteLnToConsole(s: shortstring); function GetLastConsoleLine: shortstring; -function ShortStringAsPChar(s: shortstring): PChar; +function ShortStringAsPChar(s: shortstring): PChar; implementation uses Types, uVariables, uUtils {$IFDEF ANDROID}, log in 'log.pas'{$ENDIF}; -const cLineWidth: LongInt = 0; - cLinesCount = 8; +const cLinesCount = 8; +var cLineWidth: LongInt; type - TTextLine = record - s: shortstring; - end; + TTextLine = record + s: shortstring + end; var ConsoleLines: array[byte] of TTextLine; CurrLine: LongInt; @@ -45,17 +45,19 @@ procedure SetLine(var tl: TTextLine; str: shortstring); begin with tl do - s:= str; + s:= str; end; procedure WriteToConsole(s: shortstring); +{$IFNDEF NOCONSOLE} var Len: LongInt; done: boolean; +{$ENDIF} begin {$IFNDEF NOCONSOLE} AddFileLog('[Con] ' + s); {$IFDEF ANDROID} - Log.__android_log_write(Log.Android_LOG_DEBUG, 'HW_Engine', ShortStringAsPChar('[Con]' + s)); + Log.__android_log_write(Log.Android_LOG_DEBUG, 'HW_Engine', ShortStringAsPChar('[Con]' + s)); {$ELSE} Write(stderr, s); done:= false; @@ -68,7 +70,8 @@ if byte(ConsoleLines[CurrLine].s[0]) = cLineWidth then begin inc(CurrLine); - if CurrLine = cLinesCount then CurrLine:= 0; + if CurrLine = cLinesCount then + CurrLine:= 0; PByte(@ConsoleLines[CurrLine].s)^:= 0 end; done:= (Length(s) = 0); @@ -82,7 +85,7 @@ {$IFNDEF NOCONSOLE} WriteToConsole(s); {$IFNDEF ANDROID} -WriteLn(stderr); +WriteLn(stderr, ''); inc(CurrLine); if CurrLine = cLinesCount then CurrLine:= 0; @@ -91,11 +94,12 @@ {$ENDIF} end; -function ShortStringAsPChar(s: ShortString) : PChar; +function ShortStringAsPChar(s: shortstring) : PChar; begin - if Length(s) = High(s) then Dec(s[0]); + if Length(s) = High(s) then + Dec(s[0]); s[Ord(Length(s))+1] := #0; - exit(@s[1]); + ShortStringAsPChar:= @s[1]; end; function GetLastConsoleLine: shortstring; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uConsts.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ const sfMax = 1000; cDefaultParamNum = 17; + cVideorecParamNum = cDefaultParamNum + 7; // message constants errmsgCreateSurface = 'Error creating SDL surface'; @@ -51,7 +52,6 @@ cWhiteColor : Longword = $FFFFFFFF; cYellowColor : Longword = $FFFFFF00; cNearBlackColor : Longword = $FF000010; - cExplosionBorderColor : LongWord = $FF808080; {$WARNINGS OFF} cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 3006477107); // 1.4 @@ -95,6 +95,7 @@ lfObject = $2000; lfDamaged = $1000; // lfIce = $0800; // blue + lfBouncy = $0400; // green cMaxPower = 1500; cMaxAngle = 2048; @@ -103,18 +104,18 @@ MAXNAMELEN = 192; MAXROPEPOINTS = 3840; + {$IFNDEF PAS2C} // some opengl headers do not have these macros GL_BGR = $80E0; GL_BGRA = $80E1; GL_CLAMP_TO_EDGE = $812F; GL_TEXTURE_PRIORITY = $8066; + {$ENDIF} cSendCursorPosTime : LongWord = 50; cVisibleWater : LongInt = 128; cCursorEdgesDist : LongInt = 100; cTeamHealthWidth : LongInt = 128; - cWaterOpacity : byte = $80; - cSDWaterOpacity : byte = $80; cifRandomize = $00000001; cifTheme = $00000002; @@ -122,16 +123,10 @@ cifAllInited = cifRandomize or cifTheme or cifMap; cTransparentColor: Longword = $00000000; - cGrayScale: Boolean = false; RGB_LUMINANCE_RED = 0.212671; RGB_LUMINANCE_GREEN = 0.715160; RGB_LUMINANCE_BLUE = 0.072169; -(* - RGB_LUMINANCE_RED = 0.3333333333; - RGB_LUMINANCE_GREEN = 0.3333333333; - RGB_LUMINANCE_BLUE = 0.3333333333; -*) cMaxTeams = 8; cMaxHHIndex = 7; @@ -152,8 +147,16 @@ cBarrelHealth = 60; cShotgunRadius = 22; cBlowTorchC = 6; + cakeDmg = 75; cKeyMaxIndex = 1023; + cKbdMaxIndex = 65536;//need more room for the modifier keys + + cHHFileName = 'Hedgehog'; + cCHFileName = 'Crosshair'; + cThemeCFGFilename = 'theme.cfg'; + + cFontBorder = 2; // do not change this value cDefaultZoomLevel = 2.0; @@ -226,20 +229,24 @@ gstHHGone = $00100000; gstInvisible = $00200000; - gmLeft = $00000001; - gmRight = $00000002; - gmUp = $00000004; - gmDown = $00000008; - gmSwitch = $00000010; - gmAttack = $00000020; - gmLJump = $00000040; - gmHJump = $00000080; - gmDestroy= $00000100; - gmSlot = $00000200; // with param - gmWeapon = $00000400; // with param - gmTimer = $00000800; // with param - gmAnimate= $00001000; // with param - gmPrecise= $00002000; + gmLeft = $00000001; + gmRight = $00000002; + gmUp = $00000004; + gmDown = $00000008; + gmSwitch = $00000010; + gmAttack = $00000020; + gmLJump = $00000040; + gmHJump = $00000080; + gmDestroy = $00000100; + gmSlot = $00000200; // with param + gmWeapon = $00000400; // with param + gmTimer = $00000800; // with param + gmAnimate = $00001000; // with param + gmPrecise = $00002000; + + gmRemoveFromList = $00004000; + gmAddToList = $00008000; + gmDelete = $00010000; gmAllStoppable = gmLeft or gmRight or gmUp or gmDown or gmAttack or gmPrecise; cMaxSlotIndex = 9; @@ -259,11 +266,15 @@ ammoprop_Utility = $00001000; ammoprop_Effect = $00002000; ammoprop_SetBounce = $00004000; + ammoprop_NeedUpDown = $00008000;//Used by TouchInterface to show or hide up/down widgets + ammoprop_OscAim = $00010000; + ammoprop_NoMoveAfter = $00020000; + ammoprop_Track = $00040000; ammoprop_NoRoundEnd = $10000000; AMMO_INFINITE = 100; - EXPLAllDamageInRadius = $00000001; + //EXPLAllDamageInRadius = $00000001; Completely unused for ages EXPLAutoSound = $00000002; EXPLNoDamage = $00000004; EXPLDoNotTouchHH = $00000008; @@ -289,8 +300,33 @@ htHealth = $04; htTransparent = $08; + AMAnimDuration = 200; + AMHidden = 0;//AMState values + AMShowingUp = 1; + AMShowing = 2; + AMHiding = 3; + AMTypeMaskX = $00000001; + AMTypeMaskY = $00000002; + AMTypeMaskAlpha = $00000004; + AMTypeMaskSlide = $00000008; +{$IFDEF MOBILE} + AMSlotSize = 48; + AMTITLE = 30; +{$ELSE} + AMSlotSize = 32; +{$ENDIF} + AMSlotPadding = (AMSlotSize - 32) shr 1; + +{$IFDEF USE_TOUCH_INTERFACE} + FADE_ANIM_TIME = 500; + MOVE_ANIM_TIME = 500; +{$ENDIF} + + cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13); + cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0); + implementation end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uCursor.pas --- a/hedgewars/uCursor.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uCursor.pas Sun Oct 28 13:28:23 2012 +0100 @@ -24,7 +24,8 @@ CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2; CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2; - if cHasFocus then SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); + if cHasFocus then + SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); end end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uDebug.pas --- a/hedgewars/uDebug.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uDebug.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,12 +42,18 @@ procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); begin -if not Assert then OutError(Msg, isFatal) +if not Assert then + OutError(Msg, isFatal) end; procedure SDLTry(Assert: boolean; isFatal: boolean); +var s: shortstring; begin -if not Assert then OutError(SDL_GetError, isFatal) +if not Assert then + begin + s:= SDL_GetError(); + OutError(s, isFatal) + end end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uFloat.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,18 +42,18 @@ {$IFDEF FPC} {$IFDEF ENDIAN_LITTLE} type hwFloat = record - isNegative: boolean; - case byte of - 0: (Frac, Round: Longword); - 1: (QWordValue : QWord); - end; + isNegative: boolean; + case byte of + 0: (Frac, Round: Longword); + 1: (QWordValue : QWord); + end; {$ELSE} type hwFloat = record - isNegative: boolean; - case byte of - 0: (Round, Frac: Longword); - 1: (QWordValue : QWord); - end; + isNegative: boolean; + case byte of + 0: (Round, Frac: Longword); + 1: (QWordValue : QWord); + end; {$ENDIF} // Returns an hwFloat that represents the value of integer parameter i @@ -62,7 +62,10 @@ // The implemented operators -operator = (const z1, z2: hwFloat) z:boolean; inline; +operator = (const z1, z2: hwFloat) z : boolean; inline; +{$IFDEF PAS2C} +operator <> (const z1, z2: hwFloat) z : boolean; inline; +{$ENDIF} operator + (const z1, z2: hwFloat) z : hwFloat; inline; operator - (const z1, z2: hwFloat) z : hwFloat; inline; operator - (const z1: hwFloat) z : hwFloat; inline; @@ -82,13 +85,16 @@ function hwRound(const t: hwFloat): LongInt; inline; // Does NOT really round but returns the integer representation of the hwFloat without fractional digits. (-_0_9 -> -0, _1_5 -> _1) function hwAbs(const t: hwFloat): hwFloat; inline; // Returns the value of t with positive sign. function hwSqr(const t: hwFloat): hwFloat; inline; // Returns the square value of parameter t. +function hwPow(const t: hwFloat; p: LongWord): hwFloat; inline; // Returns the power of the value function hwSqrt(const t: hwFloat): hwFloat; inline; // Returns the the positive square root of parameter t. function Distance(const dx, dy: hwFloat): hwFloat; // Returns the distance between two points in 2-dimensional space, of which the parameters are the horizontal and vertical distance. function DistanceI(const dx, dy: LongInt): hwFloat; // Same as above for integer parameters. function AngleSin(const Angle: Longword): hwFloat; function AngleCos(const Angle: Longword): hwFloat; +function vector2Angle(const x, y: hwFloat): LongInt; function SignAs(const num, signum: hwFloat): hwFloat; inline; // Returns an hwFloat with the value of parameter num and the sign of signum. function hwSign(r: hwFloat): LongInt; inline; // Returns an integer with value 1 and sign of parameter r. +function hwSignf(r: real): LongInt; inline; // Returns an integer with value 1 and sign of parameter r. function isZero(const z: hwFloat): boolean; inline; {$IFDEF FPC} {$J-} @@ -110,10 +116,12 @@ _0_0005: hwFloat = (isNegative: false; QWordValue: 2147484); _0_001: hwFloat = (isNegative: false; QWordValue: 4294967); _0_003: hwFloat = (isNegative: false; QWordValue: 12884902); + _0_0032: hwFloat = (isNegative: false; QWordValue: 13743895); _0_004: hwFloat = (isNegative: false; QWordValue: 17179869); _0_005: hwFloat = (isNegative: false; QWordValue: 21474836); _0_008: hwFloat = (isNegative: false; QWordValue: 34359738); _0_01: hwFloat = (isNegative: false; QWordValue: 42949673); + _0_0128: hwFloat = (isNegative: false; QWordValue: 54975581); _0_02: hwFloat = (isNegative: false; QWordValue: 85899345); _0_03: hwFloat = (isNegative: false; QWordValue: 128849018); _0_07: hwFloat = (isNegative: false; QWordValue: 300647710); @@ -143,13 +151,21 @@ _0_999: hwFloat = (isNegative: false; QWordValue: 4290672328); _0: hwFloat = (isNegative: false; QWordValue: 0); _1: hwFloat = (isNegative: false; QWordValue: 4294967296); + _1_2: hwFloat = (isNegative: false; QWordValue: 1288490189*4); _1_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3 div 2); + _1_6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 8 div 5); _1_9: hwFloat = (isNegative: false; QWordValue: 8160437862); _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2); + _2_4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 12 div 5); _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3); + _3_2: hwFloat = (isNegative: false; QWordValue: 3435973837*4); + _PI: hwFloat = (isNegative: false; QWordValue: 13493037704); _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4); + _4_5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 9 div 2); _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5); _6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 6); + _6_4: hwFloat = (isNegative: false; QWordValue: 3435973837 * 8); + _7: hwFloat = (isNegative: false; QWordValue: 4294967296 * 7); _10: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10); _12: hwFloat = (isNegative: false; QWordValue: 4294967296 * 12); _16: hwFloat = (isNegative: false; QWordValue: 4294967296 * 16); @@ -158,6 +174,8 @@ _25: hwFloat = (isNegative: false; QWordValue: 4294967296 * 25); _30: hwFloat = (isNegative: false; QWordValue: 4294967296 * 30); _40: hwFloat = (isNegative: false; QWordValue: 4294967296 * 40); + _41: hwFloat = (isNegative: false; QWordValue: 4294967296 * 41); + _49: hwFloat = (isNegative: false; QWordValue: 4294967296 * 49); _50: hwFloat = (isNegative: false; QWordValue: 4294967296 * 50); _70: hwFloat = (isNegative: false; QWordValue: 4294967296 * 70); _90: hwFloat = (isNegative: false; QWordValue: 4294967296 * 90); @@ -189,150 +207,264 @@ {$IFDEF FPC} -function int2hwFloat (const i: LongInt) : hwFloat; +function int2hwFloat (const i: LongInt) : hwFloat; inline; begin int2hwFloat.isNegative:= i < 0; int2hwFloat.Round:= abs(i); int2hwFloat.Frac:= 0 end; -function hwFloat2Float (const i: hwFloat) : extended; +function hwFloat2Float (const i: hwFloat) : extended; inline; begin -hwFloat2Float:= i.QWordValue / $100000000; -if i.isNegative then hwFloat2Float:= -hwFloat2Float; +hwFloat2Float:= i.Frac / $100000000 + i.Round; +if i.isNegative then + hwFloat2Float:= -hwFloat2Float; end; -operator = (const z1, z2: hwFloat) z:boolean; inline; +{$IFNDEF WEB} +operator = (const z1, z2: hwFloat) z : boolean; inline; begin z:= (z1.isNegative = z2.isNegative) and (z1.QWordValue = z2.QWordValue); end; +{$IFDEF PAS2C} +operator <> (const z1, z2: hwFloat) z : boolean; inline; +begin + z:= (z1.isNegative <> z2.isNegative) or (z1.QWordValue <> z2.QWordValue); +end; +{$ENDIF} -operator + (const z1, z2: hwFloat) z : hwFloat; +operator + (const z1, z2: hwFloat) z : hwFloat; inline; +begin +if z1.isNegative = z2.isNegative then + begin + z.isNegative:= z1.isNegative; + z.QWordValue:= z1.QWordValue + z2.QWordValue + end +else + if z1.QWordValue > z2.QWordValue then + begin + z.isNegative:= z1.isNegative; + z.QWordValue:= z1.QWordValue - z2.QWordValue + end + else + begin + z.isNegative:= z2.isNegative; + z.QWordValue:= z2.QWordValue - z1.QWordValue + end +end; + +operator - (const z1, z2: hwFloat) z : hwFloat; inline; begin if z1.isNegative = z2.isNegative then - begin - z.isNegative:= z1.isNegative; - z.QWordValue:= z1.QWordValue + z2.QWordValue - end + if z1.QWordValue > z2.QWordValue then + begin + z.isNegative:= z1.isNegative; + z.QWordValue:= z1.QWordValue - z2.QWordValue + end + else + begin + z.isNegative:= not z2.isNegative; + z.QWordValue:= z2.QWordValue - z1.QWordValue + end else - if z1.QWordValue > z2.QWordValue then - begin - z.isNegative:= z1.isNegative; - z.QWordValue:= z1.QWordValue - z2.QWordValue - end else - begin - z.isNegative:= z2.isNegative; - z.QWordValue:= z2.QWordValue - z1.QWordValue - end + begin + z.isNegative:= z1.isNegative; + z.QWordValue:= z1.QWordValue + z2.QWordValue + end +end; + +function isZero(const z: hwFloat): boolean; inline; +begin +isZero := z.QWordValue = 0; +end; + +operator < (const z1, z2: hwFloat) b : boolean; inline; +begin +if z1.isNegative xor z2.isNegative then + b:= z1.isNegative +else + if z1.QWordValue = z2.QWordValue then + b:= false + else + b:= not((z1.QWordValue = z2.QWordValue) or ((z2.QWordValue < z1.QWordValue) <> z1.isNegative)) +end; + +operator > (const z1, z2: hwFloat) b : boolean; inline; +begin +if z1.isNegative xor z2.isNegative then + b:= z2.isNegative +else + if z1.QWordValue = z2.QWordValue then + b:= false + else + b:= (z1.QWordValue > z2.QWordValue) <> z2.isNegative +end; +{$ENDIF} +{$IFDEF WEB} +(* + Mostly to be kind to JS as of 2012-08-27 where there is no int64/uint64. This may change though. +*) +operator = (const z1, z2: hwFloat) z : boolean; inline; +begin + z:= (z1.isNegative = z2.isNegative) and (z1.Frac = z2.Frac) and (z1.Round = z2.Round); end; -operator - (const z1, z2: hwFloat) z : hwFloat; +operator <> (const z1, z2: hwFloat) z : boolean; inline; +begin + z:= (z1.isNegative <> z2.isNegative) or (z1.Frac <> z2.Frac) or (z1.Round <> z2.Round); +end; + +operator + (const z1, z2: hwFloat) z : hwFloat; inline; +begin +if z1.isNegative = z2.isNegative then + begin + z:= z1; + z.Frac:= z.Frac + z2.Frac; + z.Round:= z.Round + z2.Round; + if z.Frac z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac)) then + begin + z.isNegative:= z1.isNegative; + z.Round:= z1.Round - z2.Round; + z.Frac:= z1.Frac - z2.Frac; + if z2.Frac > z1.Frac then dec(z.Round) + end + else + begin + z.isNegative:= z2.isNegative; + z.Round:= z2.Round - z1.Round; + z.Frac:= z2.Frac-z1.Frac; + if z2.Frac < z1.Frac then dec(z.Round) + end +end; + +operator - (const z1, z2: hwFloat) z : hwFloat; inline; begin if z1.isNegative = z2.isNegative then - if z1.QWordValue > z2.QWordValue then - begin - z.isNegative:= z1.isNegative; - z.QWordValue:= z1.QWordValue - z2.QWordValue - end else - begin - z.isNegative:= not z2.isNegative; - z.QWordValue:= z2.QWordValue - z1.QWordValue - end -else begin - z.isNegative:= z1.isNegative; - z.QWordValue:= z1.QWordValue + z2.QWordValue - end + if (z1.Round > z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac)) then + begin + z.isNegative:= z1.isNegative; + z.Round:= z1.Round - z2.Round; + z.Frac:= z1.Frac-z2.Frac; + if z2.Frac > z1.Frac then dec(z.Round) + end + else + begin + z.isNegative:= not z2.isNegative; + z.Round:= z2.Round - z1.Round; + z.Frac:= z2.Frac-z1.Frac; + if z2.Frac < z1.Frac then dec(z.Round) + end +else + begin + z:= z1; + z.Frac:= z.Frac + z2.Frac; + z.Round:= z.Round + z2.Round; + if z.Frac z1.isNegative +end; + +operator > (const z1, z2: hwFloat) b : boolean; inline; +begin +if z1.isNegative xor z2.isNegative then + b:= z2.isNegative +else +(* + if z1.QWordValue = z2.QWordValue then + b:= false + else*) + b:= ((z1.Round > z2.Round) or ((z1.Round = z2.Round) and (z1.Frac > z2.Frac))) <> z1.isNegative +end; + +function isZero(const z: hwFloat): boolean; inline; +begin +isZero := (z.Round = 0) and (z.Frac = 0); +end; +{$ENDIF} + +operator - (const z1: hwFloat) z : hwFloat; inline; begin z:= z1; z.isNegative:= not z.isNegative end; -operator * (const z1, z2: hwFloat) z : hwFloat; +operator * (const z1, z2: hwFloat) z : hwFloat; inline; begin z.isNegative:= z1.isNegative xor z2.isNegative; -z.QWordValue:= QWord(z1.Round) * z2.Frac + - QWord(z1.Frac) * z2.Round + - ((QWord(z1.Frac) * z2.Frac) shr 32); +z.QWordValue:= QWord(z1.Round) * z2.Frac + QWord(z1.Frac) * z2.Round + ((QWord(z1.Frac) * z2.Frac) shr 32); z.Round:= z.Round + QWord(z1.Round) * z2.Round; end; -operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; +operator * (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; begin z.isNegative:= z1.isNegative xor (z2 < 0); z.QWordValue:= z1.QWordValue * abs(z2) end; -operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; +operator / (const z1: hwFloat; z2: hwFloat) z : hwFloat; inline; var t: hwFloat; begin z.isNegative:= z1.isNegative xor z2.isNegative; z.Round:= z1.QWordValue div z2.QWordValue; t:= z1 - z2 * z.Round; if t.QWordValue = 0 then - z.Frac:= 0 + z.Frac:= 0 else - begin - while ((t.QWordValue and $8000000000000000) = 0) and - ((z2.QWordValue and $8000000000000000) = 0) do - begin - t.QWordValue:= t.QWordValue shl 1; - z2.QWordValue:= z2.QWordValue shl 1 - end; - if z2.Round > 0 then z.Frac:= (t.QWordValue) div (z2.Round) - else z.Frac:= 0 - end + begin + while ((t.QWordValue and $8000000000000000) = 0) and ((z2.QWordValue and $8000000000000000) = 0) do + begin + t.QWordValue:= t.QWordValue shl 1; + z2.QWordValue:= z2.QWordValue shl 1 + end; + if z2.Round > 0 then + z.Frac:= (t.QWordValue) div (z2.Round) + else + z.Frac:= 0 + end end; -operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; +operator / (const z1: hwFloat; const z2: LongInt) z : hwFloat; inline; begin z.isNegative:= z1.isNegative xor (z2 < 0); z.QWordValue:= z1.QWordValue div abs(z2) end; -operator < (const z1, z2: hwFloat) b : boolean; -begin -if z1.isNegative xor z2.isNegative then - b:= z1.isNegative -else - if z1.QWordValue = z2.QWordValue then - b:= false - else - b:= (z1.QWordValue < z2.QWordValue) xor z1.isNegative -end; - -operator > (const z1, z2: hwFloat) b : boolean; -begin -if z1.isNegative xor z2.isNegative then - b:= z2.isNegative -else - if z1.QWordValue = z2.QWordValue then - b:= false - else - b:= (z1.QWordValue > z2.QWordValue) xor z2.isNegative -end; - function cstr(const z: hwFloat): shortstring; var tmpstr: shortstring; begin str(z.Round, cstr); if z.Frac <> 0 then - begin - str(z.Frac / $100000000:1:10, tmpstr); - delete(tmpstr, 1, 2); - cstr:= cstr + '.' + tmpstr - end; -if z.isNegative then cstr:= '-' + cstr + begin + str(z.Frac / $100000000, tmpstr); + delete(tmpstr, 1, 2); + cstr:= cstr + '.' + copy(tmpstr, 1, 10) + end; +if z.isNegative then + cstr:= '-' + cstr end; function hwRound(const t: hwFloat): LongInt; begin -if t.isNegative then hwRound:= -(t.Round and $7FFFFFFF) - else hwRound:= t.Round and $7FFFFFFF +if t.isNegative then + hwRound:= -(t.Round and $7FFFFFFF) +else + hwRound:= t.Round and $7FFFFFFF end; function hwAbs(const t: hwFloat): hwFloat; @@ -341,35 +473,62 @@ hwAbs.isNegative:= false end; -function hwSqr(const t: hwFloat): hwFloat; +function hwSqr(const t: hwFloat): hwFloat; inline; begin hwSqr.isNegative:= false; -hwSqr.QWordValue:= - ((QWord(t.Round) * t.Round) shl 32) - + QWord(t.Round) * t.Frac * 2 - + ((QWord(t.Frac) * t.Frac) shr 32); +hwSqr.QWordValue:= ((QWord(t.Round) * t.Round) shl 32) + QWord(t.Round) * t.Frac * 2 + ((QWord(t.Frac) * t.Frac) shr 32); +end; + +function hwPow(const t: hwFloat;p: LongWord): hwFloat; +begin +hwPow:= t; +if p mod 2 = 0 then hwPow.isNegative:= false; + +while p > 0 do + begin + hwPow.QWordValue:= QWord(hwPow.Round) * t.Frac + QWord(hwPow.Frac) * t.Round + ((QWord(hwPow.Frac) * t.Frac) shr 32); + dec(p) + end end; function hwSqrt(const t: hwFloat): hwFloat; +const pwr = 8; // even value, feel free to adjust + rThreshold = 1 shl (pwr + 32); + lThreshold = 1 shl (pwr div 2 + 32); var l, r: QWord; c: hwFloat; begin hwSqrt.isNegative:= false; if t.Round = 0 then - begin - l:= t.QWordValue; - r:= $100000000 - end else - begin - l:= $100000000; - r:= t.QWordValue div 2 + $80000000; // r:= t / 2 + 0.5 - if r > $FFFFFFFFFFFF then r:= $FFFFFFFFFFFF - end; + begin + l:= t.QWordValue; + r:= $100000000 + end +else + begin + if t.QWordValue > $FFFFFFFFFFFF then // t.Round > 65535.9999 + begin + l:= $10000000000; // 256 + r:= $FFFFFFFFFFFF; // 65535.9999 + end else + if t.QWordValue >= rThreshold then + begin + l:= lThreshold; + r:= $10000000000; // 256 + end else + begin + l:= $100000000; + r:= lThreshold; + end; + end; repeat - c.QWordValue:= (l + r) div 2; - if hwSqr(c).QWordValue > t.QWordValue then r:= c.QWordValue else l:= c.QWordValue + c.QWordValue:= (l + r) shr 1; + if hwSqr(c).QWordValue > t.QWordValue then + r:= c.QWordValue + else + l:= c.QWordValue until r - l <= 1; hwSqrt.QWordValue:= l @@ -394,7 +553,18 @@ function hwSign(r: hwFloat): LongInt; begin // yes, we have negative zero for a reason -if r.isNegative then hwSign:= -1 else hwSign:= 1 +if r.isNegative then + hwSign:= -1 +else + hwSign:= 1 +end; + +function hwSignf(r: real): LongInt; +begin +if r < 0 then + hwSignf:= -1 +else + hwSignf:= 1 end; @@ -402,22 +572,54 @@ begin //TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true); AngleSin.isNegative:= false; -if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle] - else AngleSin.QWordValue:= SinTable[2048 - Angle] +if Angle < 1024 then + AngleSin.QWordValue:= SinTable[Angle] +else + AngleSin.QWordValue:= SinTable[2048 - Angle] end; function AngleCos(const Angle: Longword): hwFloat; begin //TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true); AngleCos.isNegative:= Angle > 1024; -if Angle < 1024 then AngleCos.QWordValue:= SinTable[1024 - Angle] - else AngleCos.QWordValue:= SinTable[Angle - 1024] +if Angle < 1024 then + AngleCos.QWordValue:= SinTable[1024 - Angle] +else + AngleCos.QWordValue:= SinTable[Angle - 1024] end; -function isZero(const z: hwFloat): boolean; inline; +function vector2Angle(const x, y: hwFloat): LongInt; +var d, nf: hwFloat; + l, r, c, oc: Longword; + n: QWord; begin - isZero := z.QWordValue = 0; + d:= _1 / Distance(x, y); + + nf:= y * d; + n:= nf.QWordValue; + + l:= 0; + r:= 1024; + c:= 0; + + repeat + oc:= c; + + c:= (l + r) shr 1; + + if n >= SinTable[c] then + l:= c + else + r:= c; + + until (oc = c); + + if x.isNegative then c:= 2048 - c; + if y.isNegative then c:= - c; + + vector2Angle:= c end; + {$ENDIF} end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGame.pas --- a/hedgewars/uGame.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uGame.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,55 +24,74 @@ procedure DoGameTick(Lag: LongInt); //////////////////// - implementation + implementation //////////////////// -uses uKeys, uTeams, uIO, uAI, uGears, uSound, uMobile, uVisualGears, uTypes, uVariables{$IFDEF SDL13}, uTouch{$ENDIF}; +uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uMobile, + uVisualGears, uTypes, uVariables, uCommands, uConsts + {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}; procedure DoGameTick(Lag: LongInt); var i: LongInt; begin -if isPaused then exit; +if isPaused then + exit; if (not CurrentTeam^.ExtDriven) then begin NetGetNextCmd; // its for the case of receiving "/say" message isInLag:= false; SendKeepAliveMessage(Lag) end; -if Lag > 100 then Lag:= 100 -else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; +if GameType <> gmtRecord then + begin + if Lag > 100 then + Lag:= 100 + else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then + Lag:= 2500; -if (GameType = gmtDemo) then - if isSpeed then Lag:= Lag * 10 - else - if cOnlyStats then Lag:= High(LongInt); + if (GameType = gmtDemo) then + if isSpeed then + begin + i:= RealTicks-SpeedStart; + if i < 2000 then Lag:= Lag*5 + else if i < 4000 then Lag:= Lag*10 + else if i < 6000 then Lag:= Lag*20 + else if i < 8000 then Lag:= Lag*40 + else Lag:= Lag*80; + end + else + if cOnlyStats then + Lag:= High(LongInt); + end; PlayNextVoice; i:= 1; while (GameState <> gsExit) and (i <= Lag) do begin if not CurrentTeam^.ExtDriven then - begin - if CurrentHedgehog^.BotLevel <> 0 then ProcessBot; - ProcessGears; - {$IFDEF SDL13}ProcessTouch;{$ENDIF} - end else - begin - NetGetNextCmd; - if isInLag then - case GameType of + begin + if CurrentHedgehog^.BotLevel <> 0 then + ProcessBot; + ProcessGears; + {$IFDEF SDL13}ProcessTouch;{$ENDIF} + end + else + begin + NetGetNextCmd; + if isInLag then + case GameType of gmtNet: begin // just update the health bars AddVisualGear(0, 0, vgtTeamHealthSorter); break; end; - gmtDemo: begin + gmtDemo, gmtRecord: begin GameState:= gsExit; exit end; - gmtSave: begin + gmtSave: begin RestoreTeamsFromSave; SetBinds(CurrentTeam^.Binds); - //CurrentHedgehog^.Gear^.Message:= 0; <- produces bugs with further save restoring and demos - isSoundEnabled:= isSEBackup; + StopMessages(gmLeft or gmRight or gmUp or gmDown); + ResetSound; // restore previous sound state PlayMusic; GameType:= gmtLocal; AddVisualGear(0, 0, vgtTeamHealthSorter); @@ -80,9 +99,9 @@ {$IFDEF IPHONEOS}InitIPC;{$ENDIF} uMobile.SaveLoadingEnded(); end; - end - else ProcessGears - end; + end + else ProcessGears + end; inc(i) end end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGears.pas --- a/hedgewars/uGears.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uGears.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,17 +37,14 @@ procedure initModule; procedure freeModule; -function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; -function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear; +function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear; function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear; -function GetAmmo: TAmmoType; -function GetUtility: TAmmoType; -procedure ResurrectHedgehog(gear: PGear); +function GetAmmo(Hedgehog: PHedgehog): TAmmoType; +function GetUtility(Hedgehog: PHedgehog): TAmmoType; procedure HideHog(HH: PHedgehog); procedure RestoreHog(HH: PHedgehog); procedure ProcessGears; procedure EndTurnCleanup; -procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); procedure SetAllToActive; procedure SetAllHHToActive; procedure DrawGears; @@ -55,624 +52,39 @@ procedure AddMiscGears; procedure AssignHHCoords; function GearByUID(uid : Longword) : PGear; -procedure InsertGearToList(Gear: PGear); -procedure RemoveGearFromList(Gear: PGear); -function ModifyDamage(dmg: Longword; Gear: PGear): Longword; -procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false); -procedure DeleteGear(Gear: PGear); +procedure doStepDrowningGear(Gear: PGear); implementation uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, - uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, - uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture; + uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, + uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, + uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope; +var skipFlag: boolean; -procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord = $FFFFFFFF); forward; procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward; //procedure AmmoFlameWork(Ammo: PGear); forward; -function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; forward; -function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; forward; +function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; forward; procedure SpawnBoxOfSmth; forward; -procedure AfterAttack; forward; -procedure HedgehogStep(Gear: PGear); forward; -procedure doStepHedgehogMoving(Gear: PGear); forward; -procedure HedgehogChAngle(HHGear: PGear); forward; procedure ShotgunShot(Gear: PGear); forward; -procedure PickUp(HH, Gear: PGear); forward; -procedure HHSetWeapon(HHGear: PGear); forward; procedure doStepCase(Gear: PGear); forward; + +var delay: LongWord; + delay2: LongWord; + step: (stDelay, stChDmg, stSweep, stTurnReact, + stAfterDelay, stChWin, stWater, stChWin2, stHealth, + stSpawn, stNTurn); + upd: Longword; + snowLeft,snowRight: LongInt; + //SDMusic: shortstring; + // For better maintainability the step handlers of gears are stored in // separate files. // Note: step handlers of gears that are hedgehogs are in a different file // than the handlers for all other gears. {$INCLUDE "GSHandlers.inc"} -{$INCLUDE "HHHandlers.inc"} - -const doStepHandlers: array[TGearType] of TGearStepProcedure = ( - @doStepBomb, - @doStepHedgehog, - @doStepShell, - @doStepGrave, - @doStepBee, - @doStepShotgunShot, - @doStepPickHammer, - @doStepRope, - @doStepMine, - @doStepCase, - @doStepDEagleShot, - @doStepDynamite, - @doStepBomb, - @doStepCluster, - @doStepShover, - @doStepFlame, - @doStepFirePunch, - @doStepActionTimer, - @doStepActionTimer, - @doStepParachute, - @doStepAirAttack, - @doStepAirBomb, - @doStepBlowTorch, - @doStepGirder, - @doStepTeleport, - @doStepSwitcher, - @doStepTarget, - @doStepMortar, - @doStepWhip, - @doStepKamikaze, - @doStepCake, - @doStepSeduction, - @doStepBomb, - @doStepCluster, - @doStepBomb, - @doStepWaterUp, - @doStepDrill, - @doStepBallgun, - @doStepBomb, - @doStepRCPlane, - @doStepSniperRifleShot, - @doStepJetpack, - @doStepMolotov, - @doStepCase, - @doStepBirdy, - @doStepEggWork, - @doStepPortalShot, - @doStepPiano, - @doStepBomb, - @doStepSineGunShot, - @doStepFlamethrower, - @doStepSMine, - @doStepPoisonCloud, - @doStepHammer, - @doStepHammerHit, - @doStepResurrector, - @doStepNapalmBomb, - @doStepSnowball, - @doStepSnowflake, - @doStepStructure, - @doStepLandGun, - @doStepTardis); - -procedure InsertGearToList(Gear: PGear); -var tmp, ptmp: PGear; -begin - tmp:= GearsList; - ptmp:= GearsList; - while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do - begin - ptmp:= tmp; - tmp:= tmp^.NextGear - end; - - if ptmp <> tmp then - begin - Gear^.NextGear:= ptmp^.NextGear; - Gear^.PrevGear:= ptmp; - if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; - ptmp^.NextGear:= Gear - end - else - begin - Gear^.NextGear:= GearsList; - if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear; - GearsList:= Gear; - end; -end; - -procedure RemoveGearFromList(Gear: PGear); -begin -if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; -if Gear^.PrevGear <> nil then - Gear^.PrevGear^.NextGear:= Gear^.NextGear -else - GearsList:= Gear^.NextGear -end; - -procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); -var tag: PVisualGear; -begin -tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); -if (tag <> nil) then - tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color -AllInactive:= false; -HHGear^.Active:= true; -end; - -function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; -const Counter: Longword = 0; -var gear: PGear; -begin -inc(Counter); -AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); - -New(gear); -FillChar(gear^, sizeof(TGear), 0); -gear^.X:= int2hwFloat(X); -gear^.Y:= int2hwFloat(Y); -gear^.Target.X:= NoPointX; -gear^.Kind := Kind; -gear^.State:= State; -gear^.Active:= true; -gear^.dX:= dX; -gear^.dY:= dY; -gear^.doStep:= doStepHandlers[Kind]; -gear^.CollisionIndex:= -1; -gear^.Timer:= Timer; -gear^.FlightTime:= 0; -gear^.uid:= Counter; -gear^.SoundChannel:= -1; -gear^.ImpactSound:= sndNone; -gear^.nImpactSounds:= 0; -gear^.Density:= _1; -// Define ammo association, if any. -gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; -if Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then gear^.Z:= cHHZ+1 -else gear^.Z:= cUsualZ; - -if CurrentHedgehog <> nil then - begin - gear^.Hedgehog:= CurrentHedgehog; - gear^.IntersectGear:= CurrentHedgehog^.Gear - end; - -case Kind of - gtGrenade, - gtClusterBomb, - gtGasBomb: begin - gear^.ImpactSound:= sndGrenadeImpact; - gear^.nImpactSounds:= 1; - gear^.AdvBounce:= 1; - gear^.Radius:= 5; - gear^.Elasticity:= _0_8; - gear^.Friction:= _0_8; - gear^.Density:= _1_5; - gear^.RenderTimer:= true; - if gear^.Timer = 0 then gear^.Timer:= 3000 - end; - gtWatermelon: begin - gear^.ImpactSound:= sndMelonImpact; - gear^.nImpactSounds:= 1; - gear^.AdvBounce:= 1; - gear^.Radius:= 6; - gear^.Elasticity:= _0_8; - gear^.Friction:= _0_995; - gear^.Density:= _2; - gear^.RenderTimer:= true; - if gear^.Timer = 0 then gear^.Timer:= 3000 - end; - gtMelonPiece: begin - gear^.Density:= _2; - end; - gtHedgehog: begin - gear^.AdvBounce:= 1; - gear^.Radius:= cHHRadius; - gear^.Elasticity:= _0_35; - gear^.Friction:= _0_999; - gear^.Angle:= cMaxAngle div 2; - gear^.Density:= _3; - gear^.Z:= cHHZ; - if (GameFlags and gfAISurvival) <> 0 then - if gear^.Hedgehog^.BotLevel > 0 then - gear^.Hedgehog^.Effects[heResurrectable] := true; - end; - gtShell: begin - gear^.Radius:= 4; - gear^.Density:= _1; - end; - gtSnowball: begin - gear^.ImpactSound:= sndMudballImpact; - gear^.nImpactSounds:= 1; - gear^.Radius:= 4; - gear^.Elasticity:= _1; - gear^.Friction:= _1; - gear^.Density:= _0_5; - end; - - gtFlake: begin - with Gear^ do - begin - Pos:= 0; - Radius:= 1; - DirAngle:= random * 360; - if State and gstTmpFlag = 0 then - begin - dx.isNegative:= GetRandom(2) = 0; - dx.QWordValue:= GetRandom(100000000); - dy.isNegative:= false; - dy.QWordValue:= GetRandom(70000000); - if GetRandom(2) = 0 then dx := -dx - end; - State:= State or gstInvisible; - Health:= random(vobFrameTicks); - Timer:= random(vobFramesCount); - Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity - end - end; - gtGrave: begin - gear^.ImpactSound:= sndGraveImpact; - gear^.nImpactSounds:= 1; - gear^.Radius:= 10; - gear^.Elasticity:= _0_6; - end; - gtBee: begin - gear^.Radius:= 5; - gear^.Timer:= 500; - gear^.RenderTimer:= true; - gear^.Elasticity:= _0_9; - gear^.Tag:= 0; - end; - gtSeduction: begin - gear^.Radius:= 250; - end; - gtShotgunShot: begin - gear^.Timer:= 900; - gear^.Radius:= 2 - end; - gtPickHammer: begin - gear^.Radius:= 10; - gear^.Timer:= 4000 - end; - gtHammerHit: begin - gear^.Radius:= 8; - gear^.Timer:= 125 - end; - gtRope: begin - gear^.Radius:= 3; - gear^.Friction:= _450 * _0_01 * cRopePercent; - RopePoints.Count:= 0; - end; - gtMine: begin - gear^.ImpactSound:= sndMineImpact; - gear^.nImpactSounds:= 1; - gear^.Health:= 10; - gear^.State:= gear^.State or gstMoving; - gear^.Radius:= 2; - gear^.Elasticity:= _0_55; - gear^.Friction:= _0_995; - gear^.Density:= _0_9; - if cMinesTime < 0 then - gear^.Timer:= getrandom(51)*100 - else - gear^.Timer:= cMinesTime; - end; - gtSMine: begin - gear^.Health:= 10; - gear^.State:= gear^.State or gstMoving; - gear^.Radius:= 2; - gear^.Elasticity:= _0_55; - gear^.Friction:= _0_995; - gear^.Density:= _0_9; - gear^.Timer:= 500; - end; - gtCase: begin - gear^.ImpactSound:= sndGraveImpact; - gear^.nImpactSounds:= 1; - gear^.Radius:= 16; - gear^.Elasticity:= _0_3 - end; - gtExplosives: begin - gear^.ImpactSound:= sndGrenadeImpact; - gear^.nImpactSounds:= 1; - gear^.Radius:= 16; - gear^.Elasticity:= _0_4; - gear^.Friction:= _0_995; - gear^.Density:= _6; - gear^.Health:= cBarrelHealth; - gear^.Z:= cHHZ-1 - end; - gtDEagleShot: begin - gear^.Radius:= 1; - gear^.Health:= 50 - end; - gtSniperRifleShot: begin - gear^.Radius:= 1; - gear^.Health:= 50 - end; - gtDynamite: begin - gear^.Radius:= 3; - gear^.Elasticity:= _0_55; - gear^.Friction:= _0_03; - gear^.Density:= _2; - gear^.Timer:= 5000; - end; - gtCluster: begin - gear^.Radius:= 2; - gear^.Density:= _1_5; - gear^.RenderTimer:= true - end; - gtShover: gear^.Radius:= 20; - gtFlame: begin - gear^.Tag:= GetRandom(32); - gear^.Radius:= 1; - gear^.Health:= 5; - gear^.Density:= _1; - if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then - begin - gear^.dY:= (getrandom - _0_8) * _0_03; - gear^.dX:= (getrandom - _0_5) * _0_4 - end - end; - gtFirePunch: begin - gear^.Radius:= 15; - gear^.Tag:= Y - end; - gtAirBomb: begin - gear^.Radius:= 5; - gear^.Density:= _2; - end; - gtBlowTorch: begin - gear^.Radius:= cHHRadius + cBlowTorchC; - gear^.Timer:= 7500 - end; - gtSwitcher: begin - gear^.Z:= cCurrHHZ - end; - gtTarget: begin - gear^.ImpactSound:= sndGrenadeImpact; - gear^.nImpactSounds:= 1; - gear^.Radius:= 10; - gear^.Elasticity:= _0_3; - gear^.Timer:= 0 - end; - gtTardis: begin - gear^.Timer:= 0; - gear^.Pos:= 1; - gear^.Z:= cCurrHHZ+1; - end; - gtMortar: begin - gear^.Radius:= 4; - gear^.Elasticity:= _0_2; - gear^.Friction:= _0_08; - gear^.Density:= _1; - end; - gtWhip: gear^.Radius:= 20; - gtHammer: gear^.Radius:= 20; - gtKamikaze: begin - gear^.Health:= 2048; - gear^.Radius:= 20 - end; - gtCake: begin - gear^.Health:= 2048; - gear^.Radius:= 7; - gear^.Z:= cOnHHZ; - gear^.RenderTimer:= true; - gear^.DirAngle:= -90 * hwSign(Gear^.dX); - if not dX.isNegative then gear^.Angle:= 1 else gear^.Angle:= 3 - end; - gtHellishBomb: begin - gear^.ImpactSound:= sndHellishImpact1; - gear^.nImpactSounds:= 4; - gear^.AdvBounce:= 1; - gear^.Radius:= 4; - gear^.Elasticity:= _0_5; - gear^.Friction:= _0_96; - gear^.Density:= _1_5; - gear^.RenderTimer:= true; - gear^.Timer:= 5000 - end; - gtDrill: begin - if gear^.Timer = 0 then gear^.Timer:= 5000; - // Tag for drill strike. if 1 then first impact occured already - gear^.Tag := 0; - gear^.Radius:= 4; - gear^.Density:= _1; - end; - gtBall: begin - gear^.ImpactSound:= sndGrenadeImpact; - gear^.nImpactSounds:= 1; - gear^.AdvBounce:= 1; - gear^.Radius:= 5; - gear^.Tag:= random(8); - gear^.Timer:= 5000; - gear^.Elasticity:= _0_7; - gear^.Friction:= _0_995; - gear^.Density:= _1_5; - end; - gtBallgun: begin - gear^.Timer:= 5001; - end; - gtRCPlane: begin - gear^.Timer:= 15000; - gear^.Health:= 3; - gear^.Radius:= 8 - end; - gtJetpack: begin - gear^.Health:= 2000; - gear^.Damage:= 100 - end; - gtMolotov: begin - gear^.Radius:= 6; - gear^.Density:= _2; - end; - gtBirdy: begin - gear^.Radius:= 16; // todo: check - gear^.Timer:= 0; - gear^.Health := 2000; - gear^.FlightTime := 2; - end; - gtEgg: begin - gear^.Radius:= 4; - gear^.Elasticity:= _0_6; - gear^.Friction:= _0_96; - gear^.Density:= _1; - if gear^.Timer = 0 then gear^.Timer:= 3000 - end; - gtPortal: begin - gear^.ImpactSound:= sndMelonImpact; - gear^.nImpactSounds:= 1; - gear^.AdvBounce:= 0; - gear^.Radius:= 17; - // set color - gear^.Tag:= 2 * gear^.Timer; - gear^.Timer:= 15000; - gear^.RenderTimer:= false; - gear^.Health:= 100; - end; - gtPiano: begin - gear^.Radius:= 32; - gear^.Density:= _50; - end; - gtSineGunShot: begin - gear^.Radius:= 5; - gear^.Health:= 6000; - end; -gtFlamethrower: begin - gear^.Tag:= 10; - gear^.Timer:= 10; - gear^.Health:= 500; - gear^.Damage:= 100; - end; - gtLandGun: begin - gear^.Tag:= 10; - gear^.Timer:= 10; - gear^.Health:= 1000; - gear^.Damage:= 100; - end; - gtPoisonCloud: begin - gear^.Timer:= 5000; - gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; - end; - gtResurrector: begin - gear^.Radius := 100; - gear^.Tag := 0 - end; - gtWaterUp: begin - gear^.Tag := 47; - end; - gtNapalmBomb: begin - gear^.Timer:= 1000; - gear^.Radius:= 5; - gear^.Density:= _1_5; - end; - gtStructure: begin - gear^.Elasticity:= _0_55; - gear^.Friction:= _0_995; - gear^.Density:= _0_9; - gear^.Radius:= 13; - gear^.Health:= 200; - gear^.Tag:= 3; - end; - end; - -InsertGearToList(gear); -AddGear:= gear; - -ScriptCall('onGearAdd', gear^.uid); -end; - -procedure DeleteGear(Gear: PGear); -var team: PTeam; - t,i: Longword; - k: boolean; -begin - -ScriptCall('onGearDelete', gear^.uid); - -DeleteCI(Gear); - -if Gear^.Tex <> nil then - begin - FreeTexture(Gear^.Tex); - Gear^.Tex:= nil - end; - -// make sure that portals have their link removed before deletion -if (Gear^.Kind = gtPortal) then - begin - if (Gear^.IntersectGear <> nil) then - if (Gear^.IntersectGear^.IntersectGear = Gear) then - Gear^.IntersectGear^.IntersectGear:= nil; - end -else if Gear^.Kind = gtHedgehog then - (* - This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS. I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves. I believe it should be removed - if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then - begin - AttackBar:= 0; - Gear^.Message:= gmDestroy; - CurAmmoGear^.Message:= gmDestroy; - exit - end - else*) - begin - if (hwRound(Gear^.Y) >= cWaterLine) then - begin - t:= max(Gear^.Damage, Gear^.Health); - Gear^.Damage:= t; - if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cWaterOpacity < $FF))) and (hwRound(Gear^.Y) < cWaterLine + 256) then - spawnHealthTagForHH(Gear, t); - end; - - team:= Gear^.Hedgehog^.Team; - if CurrentHedgehog^.Gear = Gear then - begin - AttackBar:= 0; - FreeActionsList; // to avoid ThinkThread on drawned gear - if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (CurrentHedgehog^.MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^); - end; - - Gear^.Hedgehog^.Gear:= nil; - if Gear^.Hedgehog^.King then - begin - // are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough - k:= false; - for i:= 0 to Pred(team^.Clan^.TeamsNumber) do - if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then k:= true; - if not k then - for i:= 0 to Pred(team^.Clan^.TeamsNumber) do - begin - team^.Clan^.Teams[i]^.hasGone:= true; - TeamGoneEffect(team^.Clan^.Teams[i]^) - end - end; - - // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog - // same stand for CheckHHDamage - if (Gear^.LastDamage <> nil) then - uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) - else - uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); - - inc(KilledHHs); - RecountTeamHealth(team); - if (CurrentHedgehog <> nil) and CurrentHedgehog^.Effects[heResurrectable] and not Gear^.Hedgehog^.Effects[heResurrectable] then - with CurrentHedgehog^ do - begin - inc(Team^.stats.AIKills); - if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex); - Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); - end - end; -with Gear^ do - AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); - -if CurAmmoGear = Gear then CurAmmoGear:= nil; -if FollowGear = Gear then FollowGear:= nil; -if lastGearByUID = Gear then lastGearByUID := nil; -RemoveGearFromList(Gear); -Dispose(Gear) -end; function CheckNoDamage: boolean; // returns TRUE in case of no damaged hhs var Gear: PGear; @@ -682,11 +94,12 @@ Gear:= GearsList; while Gear <> nil do begin - if (Gear^.Kind = gtHedgehog) and (((GameFlags and gfInfAttack) = 0) or ((Gear^.dX.QWordValue < _0_000004.QWordValue) and (Gear^.dY.QWordValue < _0_000004.QWordValue))) then + if (Gear^.Kind = gtHedgehog) and (((GameFlags and gfInfAttack) = 0) or ((Gear^.dX.QWordValue < _0_000004.QWordValue) + and (Gear^.dY.QWordValue < _0_000004.QWordValue))) then begin - if (not isInMultiShoot) then inc(Gear^.Damage, Gear^.Karma); - if (Gear^.Damage <> 0) and - (not Gear^.Invulnerable) then + if (not isInMultiShoot) then + inc(Gear^.Damage, Gear^.Karma); + if (Gear^.Damage <> 0) and (not Gear^.Invulnerable) then begin CheckNoDamage:= false; @@ -699,11 +112,8 @@ else dec(Gear^.Health, dmg); - if (Gear^.Hedgehog^.Team = CurrentTeam) and - (Gear^.Damage <> Gear^.Karma) and - not Gear^.Hedgehog^.King and - not Gear^.Hedgehog^.Effects[hePoisoned] and - not SuddenDeathDmg then + if (Gear^.Hedgehog^.Team = CurrentTeam) and (Gear^.Damage <> Gear^.Karma) + and (not Gear^.Hedgehog^.King) and (Gear^.Hedgehog^.Effects[hePoisoned] = 0) and (not SuddenDeathDmg) then Gear^.State:= Gear^.State or gstLoser; spawnHealthTagForHH(Gear, dmg); @@ -712,7 +122,8 @@ RecountTeamHealth(Gear^.Hedgehog^.Team); end; - if (not isInMultiShoot) then Gear^.Karma:= 0; + if (not isInMultiShoot) then + Gear^.Karma:= 0; Gear^.Damage:= 0 end; Gear:= Gear^.NextGear @@ -722,9 +133,9 @@ procedure HealthMachine; var Gear: PGear; team: PTeam; - i: LongWord; + i: LongWord; flag: Boolean; - tmp: LongWord; + tmp: LongWord; begin Gear:= GearsList; @@ -733,29 +144,31 @@ if Gear^.Kind = gtHedgehog then begin tmp:= 0; - if Gear^.Hedgehog^.Effects[hePoisoned] then + if Gear^.Hedgehog^.Effects[hePoisoned] <> 0 then begin inc(tmp, ModifyDamage(5, Gear)); - if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth) // does not need a minimum check since <= 1 basically disables it + if (GameFlags and gfResetHealth) <> 0 then + dec(Gear^.Hedgehog^.InitialHealth) // does not need a minimum check since <= 1 basically disables it end; if (TotalRounds > cSuddenDTurns - 1) then begin inc(tmp, cHealthDecrease); - if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease) + if (GameFlags and gfResetHealth) <> 0 then + dec(Gear^.Hedgehog^.InitialHealth, cHealthDecrease) end; if Gear^.Hedgehog^.King then begin flag:= false; team:= Gear^.Hedgehog^.Team; for i:= 0 to Pred(team^.HedgehogsNumber) do - if (team^.Hedgehogs[i].Gear <> nil) and - (not team^.Hedgehogs[i].King) and - (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) - then flag:= true; + if (team^.Hedgehogs[i].Gear <> nil) and (not team^.Hedgehogs[i].King) + and (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) then + flag:= true; if not flag then begin inc(tmp, 5); - if (GameFlags and gfResetHealth) <> 0 then dec(Gear^.Hedgehog^.InitialHealth, 5) + if (GameFlags and gfResetHealth) <> 0 then + dec(Gear^.Hedgehog^.InitialHealth, 5) end end; if tmp > 0 then @@ -770,12 +183,7 @@ end; procedure ProcessGears; -const delay: LongWord = 0; - delay2: LongWord = 0; - step: (stDelay, stChDmg, stSweep, stTurnReact, - stAfterDelay, stChWin, stWater, stChWin2, stHealth, - stSpawn, stNTurn) = stDelay; -var Gear, t: PGear; +var t: PGear; i, AliveCount: LongInt; s: shortstring; begin @@ -786,7 +194,7 @@ StepSoundChannel:= LoopSound(sndSteps) else if (StepSoundTimer = 0) and (StepSoundChannel > -1) then begin - StopSound(StepSoundChannel); + StopSoundChan(StepSoundChannel); StepSoundChannel:= -1 end; @@ -796,25 +204,39 @@ t:= GearsList; while t <> nil do begin - Gear:= t; - t:= Gear^.NextGear; + curHandledGear:= t; + t:= curHandledGear^.NextGear; - if Gear^.Active then + if curHandledGear^.Message and gmDelete <> 0 then + DeleteGear(curHandledGear) + else begin - if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then + if curHandledGear^.Message and gmRemoveFromList <> 0 then begin - if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); - Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), cWhiteColor, fntSmall); + RemoveGearFromList(curHandledGear); + // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block + if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear); + curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList)) end; - Gear^.doStep(Gear); - // might be useful later - //ScriptCall('onGearStep', Gear^.uid); + if curHandledGear^.Active then + begin + if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then + begin + FreeTexture(curHandledGear^.Tex); + curHandledGear^.Tex:= RenderStringTex(inttostr(curHandledGear^.Timer div 1000), cWhiteColor, fntSmall); + end; + curHandledGear^.doStep(curHandledGear); + // might be useful later + //ScriptCall('onGearStep', Gear^.uid); + end end end; +curHandledGear:= nil; if AllInactive then case step of - stDelay: begin + stDelay: + begin if delay = 0 then delay:= cInactDelay else @@ -823,104 +245,133 @@ if delay = 0 then inc(step) end; - stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; - stSweep: if SweepDirty then - begin - SetAllToActive; - step:= stChDmg - end else inc(step); - stTurnReact: begin + + stChDmg: + if CheckNoDamage then + inc(step) + else + step:= stDelay; + + stSweep: + if SweepDirty then + begin + SetAllToActive; + step:= stChDmg + end + else + inc(step); + + stTurnReact: + begin if (not bBetweenTurns) and (not isInMultiShoot) then begin uStats.TurnReaction; inc(step) - end else + end + else inc(step, 2); end; - stAfterDelay: begin + + stAfterDelay: + begin if delay = 0 then delay:= cInactDelay else dec(delay); if delay = 0 then - inc(step) - end; - stChWin: begin - CheckForWin; - inc(step) - end; - stWater: if (not bBetweenTurns) and (not isInMultiShoot) then - begin - if TotalRounds = cSuddenDTurns + 1 then bWaterRising:= true; - - if bWaterRising and (cWaterRise > 0) then - AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise; - - inc(step) - end else inc(step); - stChWin2: begin - CheckForWin; inc(step) end; - stHealth: begin - if (cWaterRise <> 0) or (cHealthDecrease <> 0) then + stChWin: + begin + CheckForWin(); + inc(step) + end; + stWater: + if (not bBetweenTurns) and (not isInMultiShoot) then + begin + if TotalRounds = cSuddenDTurns + 1 then + bWaterRising:= true; + if bWaterRising and (cWaterRise > 0) then + AddGear(0, 0, gtWaterUp, 0, _0, _0, 0)^.Tag:= cWaterRise; + inc(step) + end + else // since we are not raising the water, a second win-check isn't needed + inc(step,2); + stChWin2: + begin + CheckForWin; + inc(step) + end; + + stHealth: + begin + if (cWaterRise <> 0) or (cHealthDecrease <> 0) then + begin + if (TotalRounds = cSuddenDTurns) and (not SuddenDeath) and (not isInMultiShoot) then begin - if (TotalRounds = cSuddenDTurns) and not SuddenDeath and not isInMultiShoot then + SuddenDeath:= true; + if cHealthDecrease <> 0 then begin - SuddenDeath:= true; - if cHealthDecrease <> 0 then - begin - SuddenDeathDmg:= true; + SuddenDeathDmg:= true; - // flash - ScreenFade:= sfFromWhite; - ScreenFadeValue:= sfMax; - ScreenFadeSpeed:= 1; - - ChangeToSDClouds; - ChangeToSDFlakes; - glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99); - end; - AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); - playSound(sndSuddenDeath); - MusicFN:= SDMusic; - ChangeMusic + // flash + ScreenFade:= sfFromWhite; + ScreenFadeValue:= sfMax; + ScreenFadeSpeed:= 1; + + ChangeToSDClouds; + ChangeToSDFlakes; + glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99); + Ammoz[amTardis].SkipTurns:= 9999; + Ammoz[amTardis].Probability:= 0; + end; + AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); + playSound(sndSuddenDeath); + StopMusic //No SDMusic for now + //ChangeMusic(SDMusic) end - else if (TotalRounds < cSuddenDTurns) and not isInMultiShoot then + else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then begin i:= cSuddenDTurns - TotalRounds; s:= inttostr(i); if i = 1 then AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState) - else if i in [2, 5, 10, 15, 20, 25, 50, 100] then + else if (i = 2) or ((i > 0) and ((i mod 50 = 0) or ((i <= 25) and (i mod 5 = 0)))) then AddCaption(Format(trmsg[sidRoundsSD], s), cWhiteColor, capgrpGameState); end; end; if bBetweenTurns - or isInMultiShoot - or (TotalRounds = -1) then inc(step) - else begin + or isInMultiShoot + or (TotalRounds = -1) then + inc(step) + else + begin bBetweenTurns:= true; HealthMachine; step:= stChDmg end end; - stSpawn: begin - if not isInMultiShoot then SpawnBoxOfSmth; - inc(step) - end; - stNTurn: begin - if isInMultiShoot then - isInMultiShoot:= false - else begin - // delayed till after 0.9.12 - // reset to default zoom - //ZoomValue:= ZoomDefault; - with CurrentHedgehog^ do - if (Gear <> nil) - and ((Gear^.State and gstAttacked) = 0) - and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^); + stSpawn: + begin + if not isInMultiShoot then + SpawnBoxOfSmth; + inc(step) + end; + stNTurn: + begin + if isInMultiShoot then + isInMultiShoot:= false + else + begin + // delayed till after 0.9.12 + // reset to default zoom + //ZoomValue:= ZoomDefault; + with CurrentHedgehog^ do + if (Gear <> nil) + and ((Gear^.State and gstAttacked) = 0) + and (MultiShootAttacks > 0) then + OnUsedAmmo(CurrentHedgehog^); EndTurnCleanup; @@ -943,26 +394,32 @@ begin dec(delay2); - if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and not CurrentHedgehog^.Unplaced then + if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) + and (not CurrentHedgehog^.Unplaced) then begin - if (CurrentHedgehog^.Gear^.State and gstAttacked <> 0) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then + if (CurrentHedgehog^.Gear^.State and gstAttacked <> 0) + and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then begin CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstHHChooseTarget; isCursorVisible := true end; - CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstAttacked; + CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacked); end; if delay2 = 0 then begin - if (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.State and gstAttacked = 0) and (CurAmmoGear = nil) then SweepDirty; + if (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.State and gstAttacked = 0) + and (CurAmmoGear = nil) then + SweepDirty; CheckNoDamage; AliveCount:= 0; // shorter version of check for win to allow typical step activity to proceed for i:= 0 to Pred(ClansCount) do - if ClansArray[i]^.ClanHealth > 0 then inc(AliveCount); + if ClansArray[i]^.ClanHealth > 0 then + inc(AliveCount); if (AliveCount <= 1) and ((GameFlags and gfOneClanMode) = 0) then begin step:= stChDmg; - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:= 0 end end @@ -970,29 +427,30 @@ end; if TurnTimeLeft > 0 then - if CurrentHedgehog^.Gear <> nil then - if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) - and not isInMultiShoot then + if CurrentHedgehog^.Gear <> nil then + if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) + and (not isInMultiShoot) then begin if (TurnTimeLeft = 5000) - and (cHedgehogTurnTime >= 10000) - and (not PlacingHogs) - and (CurrentHedgehog^.Gear <> nil) - and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then - AddVoice(sndHurry, CurrentTeam^.voicepack); - if ReadyTimeLeft > 0 then - begin - if ReadyTimeLeft = 2000 then - AddVoice(sndComeonthen, CurrentTeam^.voicepack); - dec(ReadyTimeLeft) - end - else - dec(TurnTimeLeft) - end; + and (cHedgehogTurnTime >= 10000) + and (not PlacingHogs) + and (CurrentHedgehog^.Gear <> nil) + and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then + PlaySoundV(sndHurry, CurrentTeam^.voicepack); + if ReadyTimeLeft > 0 then + begin + if (ReadyTimeLeft = 2000) and (LastVoice.snd = sndNone) then + AddVoice(sndComeonthen, CurrentTeam^.voicepack); + dec(ReadyTimeLeft) + end + else + dec(TurnTimeLeft) + end; if skipFlag then begin - if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:= 0; skipFlag:= false; inc(CurrentHedgehog^.Team^.stats.TurnSkips); @@ -1002,15 +460,16 @@ begin if (not CurrentTeam^.ExtDriven) then begin - SendIPC('#'); + SendIPC(_S'#'); AddFileLog('hiTicks increment message sent') end; if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then inc(hiTicks) // we do not recieve a message for this end; - +AddRandomness(CheckSum); ScriptCall('onGameTick'); +if GameTicks mod 20 = 0 then ScriptCall('onGameTick20'); inc(GameTicks) end; @@ -1070,7 +529,7 @@ t:= t^.NextGear end; - if ((GameFlags and gfResetWeps) <> 0) and not PlacingHogs then + if ((GameFlags and gfResetWeps) <> 0) and (not PlacingHogs) then ResetWeapons; if (GameFlags and gfResetHealth) <> 0 then @@ -1078,69 +537,6 @@ RecountTeamHealth(TeamsArray[i]) end; -procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); -var s: shortstring; - vampDmg, tmpDmg, i: Longword; - vg: PVisualGear; -begin - if Damage = 0 then exit; // nothing to apply - - if (Gear^.Kind = gtHedgehog) then - begin - Gear^.LastDamage := AttackerHog; - - Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; - HHHurt(Gear^.Hedgehog, Source); - AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); - tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); - if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then - begin - if cVampiric then - begin - vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); - if vampDmg >= 1 then - begin - // was considering pulsing on attack, Tiy thinks it should be permanent while in play - //CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; - inc(CurrentHedgehog^.Gear^.Health,vampDmg); - str(vampDmg, s); - s:= '+' + s; - AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); - RenderHealth(CurrentHedgehog^); - RecountTeamHealth(CurrentHedgehog^.Team); - i:= 0; - while i < vampDmg do - begin - vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); - if vg <> nil then - with vg^ do - begin - Tint:= $FF0000FF; - State:= ord(sprHealth) - end; - inc(i, 5); - end; - end - end; - if ((GameFlags and gfKarma) <> 0) and - ((GameFlags and gfInvulnerable) = 0) and - not CurrentHedgehog^.Gear^.Invulnerable then - begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid - inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); - CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; - spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); - end; - uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); - end; - end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure - begin - Gear^.Hedgehog:= AttackerHog; - end; - inc(Gear^.Damage, Damage); - - ScriptCall('onGearDamage', Gear^.UID, Damage); -end; - procedure SetAllToActive; var t: PGear; begin @@ -1160,7 +556,8 @@ t:= GearsList; while t <> nil do begin - if (t^.Kind = gtHedgehog) or (t^.Kind = gtExplosives) then t^.Active:= true; + if (t^.Kind = gtHedgehog) or (t^.Kind = gtExplosives) then + t^.Active:= true; t:= t^.NextGear end end; @@ -1173,7 +570,7 @@ Gear:= GearsList; while Gear <> nil do begin - if Gear^.State and gstInvisible = 0 then + if (Gear^.State and gstInvisible = 0) and (Gear^.Message and gmRemoveFromList = 0) then begin x:= hwRound(Gear^.X) + WorldDx; y:= hwRound(Gear^.Y) + WorldDy; @@ -1197,7 +594,8 @@ end; procedure AddMiscGears; -var i: Longword; +var i,rx, ry: Longword; + rdx, rdy: hwFloat; Gear: PGear; begin AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); @@ -1231,138 +629,34 @@ Gear:= GearsList; if (GameFlags and gfInvulnerable) <> 0 then - while Gear <> nil do - begin - Gear^.Invulnerable:= true; // this is only checked on hogs right now, so no need for gear type check - Gear:= Gear^.NextGear - end; + while Gear <> nil do + begin + Gear^.Invulnerable:= true; // this is only checked on hogs right now, so no need for gear type check + Gear:= Gear^.NextGear + end; if (GameFlags and gfLaserSight) <> 0 then cLaserSighting:= true; if (GameFlags and gfArtillery) <> 0 then cArtillery:= true; +for i:= GetRandom(10)+30 downto 0 do + begin + rx:= GetRandom(rightX-leftX)+leftX; + ry:= GetRandom(LAND_HEIGHT-topY)+topY; + rdx:= _90-(GetRandomf*_360); + rdy:= _90-(GetRandomf*_360); + AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF); + end; -if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then - for i:= 0 to Pred(vobCount*2) do - AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0); +snowRight:= max(LAND_WIDTH,4096)+512; +snowLeft:= -(snowRight-LAND_WIDTH); + +if (not hasBorder) and ((Theme = 'Snow') or (Theme = 'Christmas')) then + for i:= vobCount * Longword(max(LAND_WIDTH,4096)) div 2048 downto 1 do + AddGear(LongInt(GetRandom(snowRight - snowLeft)) + snowLeft, LongInt(LAND_HEIGHT + GetRandom(750)) - 1300, gtFlake, 0, _0, _0, 0); end; -procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); -var Gear: PGear; - dmg, dmgRadius, dmgBase: LongInt; - fX, fY: hwFloat; - vg: PVisualGear; - i, cnt: LongInt; -begin -if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); -if Radius > 25 then KickFlakes(Radius, X, Y); - -if ((Mask and EXPLNoGfx) = 0) then - begin - vg:= nil; - if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) - else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); - if vg <> nil then - vg^.Tint:= Tint; - end; -if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); - -if (Mask and EXPLAllDamageInRadius) = 0 then - dmgRadius:= Radius shl 1 -else - dmgRadius:= Radius; -dmgBase:= dmgRadius + cHHRadius div 2; -fX:= int2hwFloat(X); -fY:= int2hwFloat(Y); -Gear:= GearsList; -while Gear <> nil do - begin - dmg:= 0; - //dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); - //if (dmg > 1) and - if (Gear^.State and gstNoDamage) = 0 then - begin - case Gear^.Kind of - gtHedgehog, - gtMine, - gtBall, - gtMelonPiece, - gtGrenade, - gtClusterBomb, - // gtCluster, too game breaking I think - gtSMine, - gtCase, - gtTarget, - gtFlame, - gtExplosives, - gtStructure: begin -// Run the calcs only once we know we have a type that will need damage - if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then - dmg:= dmgBase - max(hwRound(Distance(Gear^.X - fX, Gear^.Y - fY)),Gear^.Radius); - if dmg > 1 then - begin - dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); - //AddFileLog('Damage: ' + inttostr(dmg)); - if (Mask and EXPLNoDamage) = 0 then - begin - if not Gear^.Invulnerable then - ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) - else - Gear^.State:= Gear^.State or gstWinner; - end; - if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then - begin - DeleteCI(Gear); - if Gear^.Kind <> gtHedgehog then - begin - Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - fX)/Gear^.Density; - Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - fY)/Gear^.Density; - end - else - begin - Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - fX); - Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - fY); - end; - - Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); - if not Gear^.Invulnerable then - Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); - Gear^.Active:= true; - if Gear^.Kind <> gtFlame then FollowGear:= Gear - end; - if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and not Gear^.Invulnerable then - Gear^.Hedgehog^.Effects[hePoisoned] := true; - end; - - end; - gtGrave: begin -// Run the calcs only once we know we have a type that will need damage - if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then - dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY)); - if dmg > 1 then - begin - dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); - Gear^.dY:= - _0_004 * dmg; - Gear^.Active:= true - end - end; - end; - end; - Gear:= Gear^.NextGear - end; - -if (Mask and EXPLDontDraw) = 0 then - if (GameFlags and gfSolidLand) = 0 then - begin - cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk - if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then - for i:= 0 to cnt do - AddVisualGear(X, Y, vgtChunk) - end; - -uAIMisc.AwareOfExplosion(0, 0, 0) -end; procedure ShotgunShot(Gear: PGear); var t: PGear; @@ -1377,6 +671,7 @@ gtHedgehog, gtMine, gtSMine, + gtKnife, gtCase, gtTarget, gtExplosives, @@ -1404,6 +699,7 @@ t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; t^.State:= t^.State or gstMoving; + if t^.Kind = gtKnife then t^.State:= t^.State and (not gstCollision); t^.Active:= true; FollowGear:= t end @@ -1429,20 +725,21 @@ end; t:= t^.NextGear end; -if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) +if (GameFlags and gfSolidLand) = 0 then + DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) end; procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); var t: PGearArray; Gear: PGear; - i, tmpDmg: LongInt; + i, j, tmpDmg: LongInt; VGear: PVisualGear; begin t:= CheckGearsCollision(Ammo); // Just to avoid hogs on rope dodging fire. -if (CurAmmoGear <> nil) and ((CurAmmoGear^.Kind = gtRope) or (CurAmmoGear^.Kind = gtJetpack) or (CurAmmoGear^.Kind = gtBirdy)) and - (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) and - (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then +if (CurAmmoGear <> nil) and ((CurAmmoGear^.Kind = gtRope) or (CurAmmoGear^.Kind = gtJetpack) or (CurAmmoGear^.Kind = gtBirdy)) +and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) +and (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then begin t^.ar[t^.Count]:= CurrentHedgehog^.Gear; inc(t^.Count) @@ -1450,7 +747,8 @@ i:= t^.Count; -if (Ammo^.Kind = gtFlame) and (i > 0) then Ammo^.Health:= 0; +if (Ammo^.Kind = gtFlame) and (i > 0) then + Ammo^.Health:= 0; while i > 0 do begin dec(i); @@ -1462,61 +760,101 @@ if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then begin VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); - if VGear <> nil then VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); + if VGear <> nil then + VGear^.Angle := DxDy2Angle(-Ammo^.dX, Ammo^.dY); end; - if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then Gear^.FlightTime:= 1; + if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then + Gear^.FlightTime:= 1; case Gear^.Kind of gtHedgehog, gtMine, gtSMine, + gtKnife, gtTarget, gtCase, gtExplosives, - gtStructure: begin - if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; - if (not Gear^.Invulnerable) then - ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) - else - Gear^.State:= Gear^.State or gstWinner; - if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then - begin - if (Ammo^.Hedgehog^.Gear <> nil) then Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and not gstNotKickable; - ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch - end; - - DeleteCI(Gear); - if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then - begin - Gear^.dX:= Ammo^.dX * Power * _0_005; - Gear^.dY:= Ammo^.dY * Power * _0_005 - end - else + gtStructure: + begin + if (Ammo^.Kind = gtDrill) then + begin + Ammo^.Timer:= 0; + exit; + end; + if (not Gear^.Invulnerable) then + begin + if (Ammo^.Kind = gtKnife) and (tmpDmg > 0) then + for j:= 1 to max(1,min(3,tmpDmg div 5)) do begin - Gear^.dX:= Ammo^.dX * Power * _0_01; - Gear^.dY:= Ammo^.dY * Power * _0_01 + VGear:= AddVisualGear(hwRound(Ammo^.X-((Ammo^.X-Gear^.X)/_2)), hwRound(Ammo^.Y-((Ammo^.Y-Gear^.Y)/_2)), vgtStraightShot); + if VGear <> nil then + with VGear^ do + begin + Tint:= $FFCC00FF; + Angle:= random(360); + dx:= 0.0005 * (random(100)); + dy:= 0.0005 * (random(100)); + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; + FrameTicks:= 600+random(200); + State:= ord(sprStar) + end end; - - Gear^.Active:= true; - Gear^.State:= Gear^.State or gstMoving; + ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove) + end + else + Gear^.State:= Gear^.State or gstWinner; + if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then + begin + if (Ammo^.Hedgehog^.Gear <> nil) then + Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable); + ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch + end; - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) - or (TestCollisionYwithGear(Gear, -1) <> 0)) then Gear^.Y:= Gear^.Y - _1; - end; + if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then + begin + Gear^.dX:= Ammo^.dX * Power * _0_005; + Gear^.dY:= Ammo^.dY * Power * _0_005 + end + else if ((Ammo^.Kind <> gtFlame) or (Gear^.Kind = gtHedgehog)) and (Power <> 0) then + begin + Gear^.dX:= Ammo^.dX * Power * _0_01; + Gear^.dY:= Ammo^.dY * Power * _0_01 + end; - if (Ammo^.Kind <> gtFlame) or ((Ammo^.State and gsttmpFlag) = 0) then FollowGear:= Gear - end; + if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then + begin + Gear^.Active:= true; + DeleteCI(Gear); + Gear^.State:= Gear^.State or gstMoving; + if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); + // move the gear upwards a bit to throw it over tiny obstacles at start + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then + begin + if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) + or (TestCollisionYwithGear(Gear, -1) <> 0)) then + Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) + or (TestCollisionYwithGear(Gear, -1) <> 0)) then + Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) + or (TestCollisionYwithGear(Gear, -1) <> 0)) then + Gear^.Y:= Gear^.Y - _1; + end + end; + + + if (Ammo^.Kind <> gtFlame) or ((Ammo^.State and gsttmpFlag) = 0) then + FollowGear:= Gear + end; end end; end; -if i <> 0 then SetAllToActive +if i <> 0 then + SetAllToActive end; procedure AssignHHCoords; @@ -1524,7 +862,8 @@ ar: array[0..Pred(cMaxHHs)] of PHedgehog; Count: Longword; begin -if (GameFlags and gfPlaceHog) <> 0 then PlacingHogs:= true; +if (GameFlags and gfPlaceHog) <> 0 then + PlacingHogs:= true; if (GameFlags and gfDivideTeams) <> 0 then begin t:= 0; @@ -1538,8 +877,10 @@ with Hedgehogs[i] do if (Gear <> nil) and (Gear^.X.QWordValue = 0) then begin - if PlacingHogs then Unplaced:= true - else FindPlace(Gear, false, t, t + LAND_WIDTH div 2);// could make Gear == nil; + if PlacingHogs then + Unplaced:= true + else + FindPlace(Gear, false, t, t + LAND_WIDTH div 2, true);// could make Gear == nil; if Gear <> nil then begin Gear^.Pos:= GetRandom(49); @@ -1569,8 +910,10 @@ while (Count > 0) do begin i:= GetRandom(Count); - if PlacingHogs then ar[i]^.Unplaced:= true - else FindPlace(ar[i]^.Gear, false, 0, LAND_WIDTH); + if PlacingHogs then + ar[i]^.Unplaced:= true + else + FindPlace(ar[i]^.Gear, false, 0, LAND_WIDTH, true); if ar[i]^.Gear <> nil then begin ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > LAND_WIDTH div 2; @@ -1582,43 +925,30 @@ end end; -function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): TPGearArray; +var GearsNearArray : TPGearArray; +function GearsNear(X, Y: hwFloat; Kind: TGearType; r: LongInt): PGearArrayS; var t: PGear; - l: Longword; + s: Longword; begin r:= r*r; - GearsNear := nil; + s:= 0; + SetLength(GearsNearArray, s); t := GearsList; while t <> nil do begin if (t^.Kind = Kind) and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then begin - l:= Length(GearsNear); - SetLength(GearsNear, l + 1); - GearsNear[l] := t; + inc(s); + SetLength(GearsNearArray, s); + GearsNearArray[s - 1] := t; end; t := t^.NextGear; end; -end; -function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; -var t: PGear; -begin -t:= GearsList; -rX:= sqr(rX); -rY:= sqr(rY); - -while t <> nil do - begin - if (t <> Gear) and (t^.Kind = Kind) then - if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then - exit(t); - t:= t^.NextGear - end; - -CheckGearNear:= nil + GearsNear.size:= s; + GearsNear.ar:= @GearsNearArray end; {procedure AmmoFlameWork(Ammo: PGear); @@ -1641,21 +971,6 @@ end; end;} -function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; -var t: PGear; -begin -t:= GearsList; -rX:= sqr(rX); -rY:= sqr(rY); -while t <> nil do - begin - if t^.Kind in Kind then - if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then - exit(t); - t:= t^.NextGear - end; -CheckGearsNear:= nil -end; function CountGears(Kind: TGearType): Longword; var t: PGear; @@ -1665,65 +980,46 @@ t:= GearsList; while t <> nil do begin - if t^.Kind = Kind then inc(count); + if t^.Kind = Kind then + inc(count); t:= t^.NextGear end; CountGears:= count; end; -procedure ResurrectHedgehog(gear: PGear); -var tempTeam : PTeam; -begin - AttackBar:= 0; - gear^.dX := _0; - gear^.dY := _0; - gear^.Damage := 0; - gear^.Health := gear^.Hedgehog^.InitialHealth; - gear^.Hedgehog^.Effects[hePoisoned] := false; - if not CurrentHedgehog^.Effects[heResurrectable] then - with CurrentHedgehog^ do - begin - inc(Team^.stats.AIKills); - if Team^.AIKillsTex <> nil then FreeTexture(Team^.AIKillsTex); - Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); - end; - tempTeam := gear^.Hedgehog^.Team; - DeleteCI(gear); - FindPlace(gear, false, 0, LAND_WIDTH, true); - if gear <> nil then begin - RenderHealth(gear^.Hedgehog^); - ScriptCall('onGearResurrect', gear^.uid); - gear^.State := gstWait; - end; - RecountTeamHealth(tempTeam); -end; - -function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword): PGear; +function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear; begin FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); cCaseFactor := 0; - if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then content := ord(High(TAmmoType)); + if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then + content := ord(High(TAmmoType)); + + FollowGear^.Power:= cnt; case crate of - HealthCrate: begin + HealthCrate: + begin FollowGear^.Pos := posCaseHealth; FollowGear^.Health := content; AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo); end; - AmmoCrate: begin + AmmoCrate: + begin FollowGear^.Pos := posCaseAmmo; FollowGear^.AmmoType := TAmmoType(content); AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo); end; - UtilityCrate: begin + UtilityCrate: + begin FollowGear^.Pos := posCaseUtility; FollowGear^.AmmoType := TAmmoType(content); AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo); end; end; - if ( (x = 0) and (y = 0) ) then FindPlace(FollowGear, true, 0, LAND_WIDTH); + if ( (x = 0) and (y = 0) ) then + FindPlace(FollowGear, true, 0, LAND_WIDTH); SpawnCustomCrateAt := FollowGear; end; @@ -1734,33 +1030,40 @@ cCaseFactor := 0; FollowGear^.Pos := posCaseDummy; - if explode then FollowGear^.Pos := FollowGear^.Pos + posCaseExplode; - if poison then FollowGear^.Pos := FollowGear^.Pos + posCasePoison; + if explode then + FollowGear^.Pos := FollowGear^.Pos + posCaseExplode; + if poison then + FollowGear^.Pos := FollowGear^.Pos + posCasePoison; case crate of - HealthCrate: begin + HealthCrate: + begin FollowGear^.Pos := FollowGear^.Pos + posCaseHealth; AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpAmmoInfo); end; - AmmoCrate: begin + AmmoCrate: + begin FollowGear^.Pos := FollowGear^.Pos + posCaseAmmo; AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpAmmoInfo); end; - UtilityCrate: begin + UtilityCrate: + begin FollowGear^.Pos := FollowGear^.Pos + posCaseUtility; AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpAmmoInfo); end; end; - if ( (x = 0) and (y = 0) ) then FindPlace(FollowGear, true, 0, LAND_WIDTH); + if ( (x = 0) and (y = 0) ) then + FindPlace(FollowGear, true, 0, LAND_WIDTH); SpawnFakeCrateAt := FollowGear; end; -function GetAmmo: TAmmoType; +function GetAmmo(Hedgehog: PHedgehog): TAmmoType; var t, aTot: LongInt; i: TAmmoType; begin +Hedgehog:= Hedgehog; // avoid hint aTot:= 0; for i:= Low(TAmmoType) to High(TAmmoType) do @@ -1773,23 +1076,24 @@ begin t:= GetRandom(t); while t >= 0 do - begin - inc(i); - if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then - dec(t, Ammoz[i].Probability) - end + begin + inc(i); + if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then + dec(t, Ammoz[i].Probability) + end end; GetAmmo:= i end; -function GetUtility: TAmmoType; +function GetUtility(Hedgehog: PHedgehog): TAmmoType; var t, uTot: LongInt; i: TAmmoType; begin uTot:= 0; for i:= Low(TAmmoType) to High(TAmmoType) do - if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then + if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) + and ((Hedgehog^.Team^.HedgehogsNumber > 1) or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then inc(uTot, Ammoz[i].Probability); t:= uTot; @@ -1798,11 +1102,12 @@ begin t:= GetRandom(t); while t >= 0 do - begin - inc(i); - if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then - dec(t, Ammoz[i].Probability) - end + begin + inc(i); + if ((Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0) and ((Hedgehog^.Team^.HedgehogsNumber > 1) + or (Ammoz[i].Ammo.AmmoType <> amSwitch)) then + dec(t, Ammoz[i].Probability) + end end; GetUtility:= i end; @@ -1814,9 +1119,10 @@ i: TAmmoType; begin if (PlacingHogs) or - (cCaseFactor = 0) or - (CountGears(gtCase) >= 5) or - (GetRandom(cCaseFactor) <> 0) then exit; + (cCaseFactor = 0) + or (CountGears(gtCase) >= 5) + or (GetRandom(cCaseFactor) <> 0) then + exit; FollowGear:= nil; aTot:= 0; @@ -1889,119 +1195,6 @@ end end; -procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean = false); - - function CountNonZeroz(x, y, r, c: LongInt): LongInt; - var i: LongInt; - count: LongInt = 0; - begin - if (y and LAND_HEIGHT_MASK) = 0 then - for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do - if Land[y, i] <> 0 then - begin - inc(count); - if count = c then exit(count) - end; - CountNonZeroz:= count; - end; - -var x: LongInt; - y, sy: LongInt; - ar: array[0..511] of TPoint; - ar2: array[0..1023] of TPoint; - cnt, cnt2: Longword; - delta: LongInt; - reallySkip, tryAgain: boolean; -begin -reallySkip:= false; // try not skipping proximity at first -tryAgain:= true; -while tryAgain do - begin - delta:= 250; - cnt2:= 0; - repeat - x:= Left + LongInt(GetRandom(Delta)); - repeat - inc(x, Delta); - cnt:= 0; - y:= min(1024, topY) - 2 * Gear^.Radius; - while y < cWaterLine do - begin - repeat - inc(y, 2); - until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0); - - sy:= y; - - repeat - inc(y); - until (y >= cWaterLine) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0); - - if (y - sy > Gear^.Radius * 2) and - (((Gear^.Kind = gtExplosives) - and (y < cWaterLine) - and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil)) - and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius)) - or - ((Gear^.Kind <> gtExplosives) - and (y < cWaterLine) - and (reallySkip or (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil)))) then - begin - ar[cnt].X:= x; - if withFall then ar[cnt].Y:= sy + Gear^.Radius - else ar[cnt].Y:= y - Gear^.Radius; - inc(cnt) - end; - - inc(y, 45) - end; - - if cnt > 0 then - with ar[GetRandom(cnt)] do - begin - ar2[cnt2].x:= x; - ar2[cnt2].y:= y; - inc(cnt2) - end - until (x + Delta > Right); - - dec(Delta, 60) - until (cnt2 > 0) or (Delta < 70); - if (cnt2 = 0) and skipProximity and not reallySkip then tryAgain:= true - else tryAgain:= false; - reallySkip:= true; - end; - -if cnt2 > 0 then - with ar2[GetRandom(cnt2)] do - begin - Gear^.X:= int2hwFloat(x); - Gear^.Y:= int2hwFloat(y); - AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); - end - else - begin - OutError('Can''t find place for Gear', false); - if Gear^.Kind = gtHedgehog then Gear^.Hedgehog^.Effects[heResurrectable] := false; - DeleteGear(Gear); - Gear:= nil - end -end; - -function ModifyDamage(dmg: Longword; Gear: PGear): Longword; -var i: hwFloat; -begin -(* Invulnerability cannot be placed in here due to still needing kicks - Not without a new damage machine. - King check should be in here instead of ApplyDamage since Tiy wants them kicked less -*) -i:= _1; -if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then i:= _1_5; -if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then - ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) -else - ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) -end; function GearByUID(uid : Longword) : PGear; var gear: PGear; @@ -2030,7 +1223,8 @@ procedure chSkip(var s: shortstring); begin s:= s; // avoid compiler hint -if not CurrentTeam^.ExtDriven then SendIPC(','); +if not isExternalSource then + SendIPC(_S','); uStats.Skipped; skipFlag:= true end; @@ -2049,12 +1243,16 @@ if x < 4 then begin t:= byte(s[2]); // team - if Length(s) > 2 then h:= byte(s[3]) // target hog + if Length(s) > 2 then + h:= byte(s[3]) // target hog end; // allow targetting a hog by specifying a number as the first portion of the text - if (x < 4) and (h > byte('0')) and (h < byte('9')) then i:= h - 48; - if i <> 0 then text:= copy(s, 4, Length(s) - 1) - else if x < 4 then text:= copy(s, 3, Length(s) - 1) + if (x < 4) and (h > byte('0')) and (h < byte('9')) then + i:= h - 48; + if i <> 0 then + text:= copy(s, 4, Length(s) - 1) + else if x < 4 then + text:= copy(s, 3, Length(s) - 1) else text:= copy(s, 2, Length(s) - 1); (* @@ -2068,7 +1266,8 @@ if (x < 4) and (TeamsArray[t] <> nil) then begin // if team matches current hedgehog team, default to current hedgehog - if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then hh:= CurrentHedgehog + if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then + hh:= CurrentHedgehog else begin // otherwise use the first living hog or the hog amongs the remaining ones indicated by i @@ -2105,12 +1304,83 @@ end; procedure initModule; +const handlers: array[TGearType] of TGearStepProcedure = ( + @doStepFlame, + @doStepHedgehog, + @doStepMine, + @doStepCase, + @doStepCase, + @doStepBomb, + @doStepShell, + @doStepGrave, + @doStepBee, + @doStepShotgunShot, + @doStepPickHammer, + @doStepRope, + @doStepDEagleShot, + @doStepDynamite, + @doStepBomb, + @doStepCluster, + @doStepShover, + @doStepFirePunch, + @doStepActionTimer, + @doStepActionTimer, + @doStepParachute, + @doStepAirAttack, + @doStepAirBomb, + @doStepBlowTorch, + @doStepGirder, + @doStepTeleport, + @doStepSwitcher, + @doStepTarget, + @doStepMortar, + @doStepWhip, + @doStepKamikaze, + @doStepCake, + @doStepSeduction, + @doStepBomb, + @doStepCluster, + @doStepBomb, + @doStepWaterUp, + @doStepDrill, + @doStepBallgun, + @doStepBomb, + @doStepRCPlane, + @doStepSniperRifleShot, + @doStepJetpack, + @doStepMolotov, + @doStepBirdy, + @doStepEggWork, + @doStepPortalShot, + @doStepPiano, + @doStepBomb, + @doStepSineGunShot, + @doStepFlamethrower, + @doStepSMine, + @doStepPoisonCloud, + @doStepHammer, + @doStepHammerHit, + @doStepResurrector, + @doStepNapalmBomb, + @doStepSnowball, + @doStepSnowflake, + @doStepStructure, + @doStepLandGun, + @doStepTardis, + @doStepIceGun, + @doStepAddAmmo, + @doStepGenericFaller, + @doStepKnife); begin - RegisterVariable('skip', vtCommand, @chSkip, false); - RegisterVariable('hogsay', vtCommand, @chHogSay, true ); + doStepHandlers:= handlers; + + RegisterVariable('skip', @chSkip, false); + RegisterVariable('hogsay', @chHogSay, true ); CurAmmoGear:= nil; GearsList:= nil; + curHandledGear:= nil; + KilledHHs:= 0; SuddenDeath:= false; SuddenDeathDmg:= false; @@ -2119,6 +1389,14 @@ AllInactive:= false; PrvInactive:= false; + + //typed const + delay:= 0; + delay2:= 0; + step:= stDelay; + upd:= 0; + + //SDMusic:= 'hell.ogg'; end; procedure freeModule; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsHandlers.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uGearsHandlers.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,86 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} + +unit uGearsHandlers; +interface + +uses uTypes; + +procedure cakeStep(Gear: PGear); + +implementation + +uses SDLh, uFloat, uCollisions; + + + +const dirs: array[0..3] of TPoint = ((X: 0; Y: -1), (X: 1; Y: 0),(X: 0; Y: 1),(X: -1; Y: 0)); + +procedure PrevAngle(Gear: PGear; dA: LongInt); inline; +begin + Gear^.Angle := (LongInt(Gear^.Angle) - dA) and 3 +end; + +procedure NextAngle(Gear: PGear; dA: LongInt); inline; +begin + Gear^.Angle := (LongInt(Gear^.Angle) + dA) and 3 +end; + +procedure cakeStep(Gear: PGear); +var + xx, yy, xxn, yyn: LongInt; + dA: LongInt; +begin + dA := hwSign(Gear^.dX); + xx := dirs[Gear^.Angle].x; + yy := dirs[Gear^.Angle].y; + xxn := dirs[(LongInt(Gear^.Angle) + dA) and 3].x; + yyn := dirs[(LongInt(Gear^.Angle) + dA) and 3].y; + + if (xx = 0) then + if TestCollisionYwithGear(Gear, yy) <> 0 then + PrevAngle(Gear, dA) + else + begin + Gear^.Tag := 0; + Gear^.Y := Gear^.Y + int2hwFloat(yy); + if not TestCollisionXwithGear(Gear, xxn) then + begin + Gear^.X := Gear^.X + int2hwFloat(xxn); + NextAngle(Gear, dA) + end; + end; + + if (yy = 0) then + if TestCollisionXwithGear(Gear, xx) then + PrevAngle(Gear, dA) + else + begin + Gear^.Tag := 0; + Gear^.X := Gear^.X + int2hwFloat(xx); + if TestCollisionYwithGear(Gear, yyn) = 0 then + begin + Gear^.Y := Gear^.Y + int2hwFloat(yyn); + NextAngle(Gear, dA) + end; + end; +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsHandlersRope.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uGearsHandlersRope.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,463 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} +unit uGearsHandlersRope; +interface + +uses uTypes; + +procedure doStepRope(Gear: PGear); + +implementation +uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils, + uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender; + +procedure doStepRopeAfterAttack(Gear: PGear); +var + HHGear: PGear; +begin + HHGear := Gear^.Hedgehog^.Gear; + if ((HHGear^.State and gstHHDriven) = 0) + or (CheckGearDrowning(HHGear)) + or (TestCollisionYwithGear(HHGear, 1) <> 0) then + begin + DeleteGear(Gear); + isCursorVisible := false; + ApplyAmmoChanges(HHGear^.Hedgehog^); + exit + end; + + HedgehogChAngle(HHGear); + + if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then + SetLittle(HHGear^.dX); + + if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then + HHGear^.dY := _0; + HHGear^.X := HHGear^.X + HHGear^.dX; + HHGear^.Y := HHGear^.Y + HHGear^.dY; + HHGear^.dY := HHGear^.dY + cGravity; + + if (GameFlags and gfMoreWind) <> 0 then + HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density; + + if (Gear^.Message and gmAttack) <> 0 then + begin + Gear^.X := HHGear^.X; + Gear^.Y := HHGear^.Y; + + ApplyAngleBounds(Gear^.Hedgehog^, amRope); + + Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); + Gear^.dY := -AngleCos(HHGear^.Angle); + Gear^.Friction := _4_5 * cRopePercent; + Gear^.Elasticity := _0; + Gear^.State := Gear^.State and (not gsttmpflag); + Gear^.doStep := @doStepRope; + end +end; + +procedure RopeDeleteMe(Gear, HHGear: PGear); +begin + with HHGear^ do + begin + Message := Message and (not gmAttack); + State := (State or gstMoving) and (not gstWinner); + end; + DeleteGear(Gear) +end; + +procedure RopeWaitCollision(Gear, HHGear: PGear); +begin + with HHGear^ do + begin + Message := Message and (not gmAttack); + State := State or gstMoving; + end; + RopePoints.Count := 0; + Gear^.Elasticity := _0; + Gear^.doStep := @doStepRopeAfterAttack +end; + +procedure doStepRopeWork(Gear: PGear); +var + HHGear: PGear; + len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; + lx, ly, cd: LongInt; + haveCollision, + haveDivided: boolean; + +begin + if GameTicks mod 4 <> 0 then exit; + + HHGear := Gear^.Hedgehog^.Gear; + + if ((HHGear^.State and gstHHDriven) = 0) + or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then + begin + PlaySound(sndRopeRelease); + RopeDeleteMe(Gear, HHGear); + exit + end; + + HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shl 2; + HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shl 2; + if (Gear^.Message and gmLeft <> 0) and (not TestCollisionXwithGear(HHGear, -1)) then + HHGear^.dX := HHGear^.dX - _0_0032; + + if (Gear^.Message and gmRight <> 0) and (not TestCollisionXwithGear(HHGear, 1)) then + HHGear^.dX := HHGear^.dX + _0_0032; + + // vector between hedgehog and rope attaching point + ropeDx := HHGear^.X - Gear^.X; + ropeDy := HHGear^.Y - Gear^.Y; + + if TestCollisionYwithGear(HHGear, 1) = 0 then + begin + + // depending on the rope vector we know which X-side to check for collision + // in order to find out if the hog can still be moved by gravity + if ropeDx.isNegative = RopeDy.IsNegative then + cd:= -1 + else + cd:= 1; + + // apply gravity if there is no obstacle + if not TestCollisionXwithGear(HHGear, cd) then + HHGear^.dY := HHGear^.dY + cGravity * 16; + + if (GameFlags and gfMoreWind) <> 0 then + // apply wind if there's no obstacle + if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then + HHGear^.dX := HHGear^.dX + cWindSpeed * 16 / HHGear^.Density; + end; + + mdX := ropeDx + HHGear^.dX; + mdY := ropeDy + HHGear^.dY; + len := _1 / Distance(mdX, mdY); + // rope vector plus hedgehog direction vector normalized + mdX := mdX * len; + mdY := mdY * len; + + // for visual purposes only + Gear^.dX := mdX; + Gear^.dY := mdY; + + ///// + tx := HHGear^.X; + ty := HHGear^.Y; + + if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then + if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) + or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then + Gear^.Elasticity := Gear^.Elasticity + _1_2; + + if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then + if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) + or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then + Gear^.Elasticity := Gear^.Elasticity - _1_2; + + HHGear^.X := Gear^.X + mdX * Gear^.Elasticity; + HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity; + + HHGear^.dX := HHGear^.X - tx; + HHGear^.dY := HHGear^.Y - ty; + //// + + + haveDivided := false; + // check whether rope needs dividing + + len := Gear^.Elasticity - _5; + nx := Gear^.X + mdX * len; + ny := Gear^.Y + mdY * len; + tx := mdX * _1_2; // should be the same as increase step + ty := mdY * _1_2; + + while len > _3 do + begin + lx := hwRound(nx); + ly := hwRound(ny); + if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then + begin + ny := _1 / Distance(ropeDx, ropeDy); + // old rope pos + nx := ropeDx * ny; + ny := ropeDy * ny; + + with RopePoints.ar[RopePoints.Count] do + begin + X := Gear^.X; + Y := Gear^.Y; + if RopePoints.Count = 0 then + RopePoints.HookAngle := DxDy2Angle(Gear^.dY, Gear^.dX); + b := (nx * HHGear^.dY) > (ny * HHGear^.dX); + dLen := len + end; + + with RopePoints.rounded[RopePoints.Count] do + begin + X := hwRound(Gear^.X); + Y := hwRound(Gear^.Y); + end; + + Gear^.X := Gear^.X + nx * len; + Gear^.Y := Gear^.Y + ny * len; + inc(RopePoints.Count); + TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); + Gear^.Elasticity := Gear^.Elasticity - len; + Gear^.Friction := Gear^.Friction - len; + haveDivided := true; + break + end; + nx := nx - tx; + ny := ny - ty; + + // len := len - _1_2 // should be the same as increase step + len.QWordValue := len.QWordValue - _1_2.QWordValue; + end; + + if not haveDivided then + if RopePoints.Count > 0 then // check whether the last dividing point could be removed + begin + tx := RopePoints.ar[Pred(RopePoints.Count)].X; + ty := RopePoints.ar[Pred(RopePoints.Count)].Y; + mdX := tx - Gear^.X; + mdY := ty - Gear^.Y; + if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then + begin + dec(RopePoints.Count); + Gear^.X := RopePoints.ar[RopePoints.Count].X; + Gear^.Y := RopePoints.ar[RopePoints.Count].Y; + Gear^.Elasticity := Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; + Gear^.Friction := Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen; + + // restore hog position + len := _1 / Distance(mdX, mdY); + mdX := mdX * len; + mdY := mdY * len; + + HHGear^.X := Gear^.X - mdX * Gear^.Elasticity; + HHGear^.Y := Gear^.Y - mdY * Gear^.Elasticity; + end + end; + + haveCollision := false; + if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then + begin + HHGear^.dX := -_0_6 * HHGear^.dX; + haveCollision := true + end; + if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then + begin + HHGear^.dY := -_0_6 * HHGear^.dY; + haveCollision := true + end; + + if haveCollision and (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.Message and (gmUp or gmDown) <> 0) then + begin + HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _0_8, HHGear^.dX); + HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _0_8, HHGear^.dY) + end; + + len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY); + if len > _10 then + begin + len := _3_2 / hwSqrt(len); + HHGear^.dX := HHGear^.dX * len; + HHGear^.dY := HHGear^.dY * len; + end; + + haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)]) <> 0); + + if not haveCollision then + begin + // backup gear location + tx:= Gear^.X; + ty:= Gear^.Y; + + if RopePoints.Count > 0 then + begin + // set gear location to the remote end of the rope, the attachment point + Gear^.X:= RopePoints.ar[0].X; + Gear^.Y:= RopePoints.ar[0].Y; + end; + + CheckCollision(Gear); + // if we haven't found any collision yet then check the other side too + if (Gear^.State and gstCollision) = 0 then + begin + Gear^.dX.isNegative:= not Gear^.dX.isNegative; + Gear^.dY.isNegative:= not Gear^.dY.isNegative; + CheckCollision(Gear); + Gear^.dX.isNegative:= not Gear^.dX.isNegative; + Gear^.dY.isNegative:= not Gear^.dY.isNegative; + end; + + haveCollision:= (Gear^.State and gstCollision) <> 0; + + // restore gear location + Gear^.X:= tx; + Gear^.Y:= ty; + end; + + // if the attack key is pressed, lose rope contact as well + if (Gear^.Message and gmAttack) <> 0 then + haveCollision:= false; + + HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 2; + HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 2; + if (not haveCollision) and ((Gear^.State and gsttmpFlag) <> 0) then + begin + begin + PlaySound(sndRopeRelease); + if Gear^.Hedgehog^.CurAmmoType <> amParachute then + RopeWaitCollision(Gear, HHGear) + else + RopeDeleteMe(Gear, HHGear) + end + end + else + if (Gear^.State and gsttmpFlag) = 0 then + Gear^.State := Gear^.State or gsttmpFlag; +end; + +procedure RopeRemoveFromAmmo(Gear, HHGear: PGear); +begin + if (Gear^.State and gstAttacked) = 0 then + begin + OnUsedAmmo(HHGear^.Hedgehog^); + Gear^.State := Gear^.State or gstAttacked + end; + ApplyAmmoChanges(HHGear^.Hedgehog^) +end; + +procedure doStepRopeAttach(Gear: PGear); +var + HHGear: PGear; + tx, ty, tt: hwFloat; +begin + Gear^.X := Gear^.X - Gear^.dX; + Gear^.Y := Gear^.Y - Gear^.dY; + Gear^.Elasticity := Gear^.Elasticity + _1; + + HHGear := Gear^.Hedgehog^.Gear; + DeleteCI(HHGear); + + if (HHGear^.State and gstMoving) <> 0 then + begin + if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then + SetLittle(HHGear^.dX); + if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then + HHGear^.dY := _0; + + HHGear^.X := HHGear^.X + HHGear^.dX; + Gear^.X := Gear^.X + HHGear^.dX; + + if TestCollisionYwithGear(HHGear, 1) <> 0 then + begin + CheckHHDamage(HHGear); + HHGear^.dY := _0 + //HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); + end + else + begin + HHGear^.Y := HHGear^.Y + HHGear^.dY; + Gear^.Y := Gear^.Y + HHGear^.dY; + HHGear^.dY := HHGear^.dY + cGravity; + if (GameFlags and gfMoreWind) <> 0 then + HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density + end; + + tt := Gear^.Elasticity; + tx := _0; + ty := _0; + while tt > _20 do + begin + if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)] and $FF00) <> 0) then + begin + Gear^.X := Gear^.X + tx; + Gear^.Y := Gear^.Y + ty; + Gear^.Elasticity := tt; + Gear^.doStep := @doStepRopeWork; + PlaySound(sndRopeAttach); + with HHGear^ do + begin + State := State and (not (gstAttacking or gstHHJumping or gstHHHJump)); + Message := Message and (not gmAttack) + end; + + RopeRemoveFromAmmo(Gear, HHGear); + + tt := _0; + exit + end; + tx := tx + Gear^.dX + Gear^.dX; + ty := ty + Gear^.dY + Gear^.dY; + tt := tt - _2; + end; + end; + + if Gear^.Elasticity < _20 then Gear^.CollisionMask:= $FF00 + else Gear^.CollisionMask:= $FF7F; + CheckCollision(Gear); + + if (Gear^.State and gstCollision) <> 0 then + if Gear^.Elasticity < _10 then + Gear^.Elasticity := _10000 + else + begin + Gear^.doStep := @doStepRopeWork; + PlaySound(sndRopeAttach); + with HHGear^ do + begin + State := State and (not (gstAttacking or gstHHJumping or gstHHHJump)); + Message := Message and (not gmAttack) + end; + + RopeRemoveFromAmmo(Gear, HHGear); + + exit + end; + + if (Gear^.Elasticity > Gear^.Friction) + or ((Gear^.Message and gmAttack) = 0) + or ((HHGear^.State and gstHHDriven) = 0) + or (HHGear^.Damage > 0) then + begin + with Gear^.Hedgehog^.Gear^ do + begin + State := State and (not gstAttacking); + Message := Message and (not gmAttack) + end; + DeleteGear(Gear); + exit; + end; + if CheckGearDrowning(HHGear) then DeleteGear(Gear) +end; + +procedure doStepRope(Gear: PGear); +begin + Gear^.dX := - Gear^.dX; + Gear^.dY := - Gear^.dY; + Gear^.doStep := @doStepRopeAttach; + PlaySound(sndRopeShot) +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsHedgehog.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uGearsHedgehog.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1251 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} + +unit uGearsHedgehog; +interface +uses uTypes; + +procedure doStepHedgehog(Gear: PGear); +procedure AfterAttack; +procedure HedgehogStep(Gear: PGear); +procedure doStepHedgehogMoving(Gear: PGear); +procedure HedgehogChAngle(HHGear: PGear); +procedure PickUp(HH, Gear: PGear); +procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); + +implementation +uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, + uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript, + uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, + uGearsUtils; + +var GHStepTicks: LongWord = 0; + +// Shouldn't more of this ammo switching stuff be moved to uAmmos ? +function ChangeAmmo(HHGear: PGear): boolean; +var slot, i: Longword; + ammoidx: LongInt; + prevAmmo: TAmmoType; +begin +ChangeAmmo:= false; +slot:= HHGear^.MsgParam; + +with HHGear^.Hedgehog^ do + begin + HHGear^.Message:= HHGear^.Message and (not gmSlot); + prevAmmo:= CurAmmoType; + ammoidx:= 0; + if ((HHGear^.State and (gstAttacking or gstAttacked)) <> 0) + or ((MultiShootAttacks > 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) = 0)) + or ((HHGear^.State and gstHHDriven) = 0) then + exit; + ChangeAmmo:= true; + + while (ammoidx < cMaxSlotAmmoIndex) and (Ammo^[slot, ammoidx].AmmoType <> CurAmmoType) do + inc(ammoidx); + + if ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) and (MultiShootAttacks > 0) then + OnUsedAmmo(HHGear^.Hedgehog^); + + MultiShootAttacks:= 0; + HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); + + if Ammoz[CurAmmoType].Slot = slot then + begin + i:= 0; + repeat + inc(ammoidx); + if (ammoidx > cMaxSlotAmmoIndex) then + begin + inc(i); + CurAmmoType:= amNothing; + ammoidx:= -1; + //TryDo(i < 2, 'Engine bug: no ammo in current slot', true) + end; + until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) + and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) + + end + else + begin + i:= 0; + // check whether there is ammo in slot + while (i <= cMaxSlotAmmoIndex) and ((Ammo^[slot, i].Count = 0) + or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) + do inc(i); + + if i <= cMaxSlotAmmoIndex then + ammoidx:= i + else ammoidx:= -1 + end; + if ammoidx >= 0 then + CurAmmoType:= Ammo^[slot, ammoidx].AmmoType; + if (prevAmmo <> CurAmmoType) then + begin + if CurAmmoType = amKnife then + LoadHedgehogHat(HHGear^.Hedgehog^, 'Reserved/chef') + else if prevAmmo = amKnife then + LoadHedgehogHat(HHGear^.Hedgehog^, Hat); + end + end +end; + +procedure HHSetWeapon(HHGear: PGear); +var t: LongInt; + weap: TAmmoType; + Hedgehog: PHedgehog; + s: boolean; +begin +s:= false; + +weap:= TAmmoType(HHGear^.MsgParam); +Hedgehog:= HHGear^.Hedgehog; + +if Hedgehog^.Team^.Clan^.TurnNumber <= Ammoz[weap].SkipTurns then + exit; // weapon is not activated yet + +HHGear^.MsgParam:= Ammoz[weap].Slot; + +t:= cMaxSlotAmmoIndex; + +HHGear^.Message:= HHGear^.Message and (not gmWeapon); + +with Hedgehog^ do + while (CurAmmoType <> weap) and (t >= 0) do + begin + s:= ChangeAmmo(HHGear); + dec(t) + end; + +if s then + ApplyAmmoChanges(HHGear^.Hedgehog^) +end; + +procedure HHSetTimer(Gear: PGear); +var CurWeapon: PAmmo; + color: LongWord; +begin +Gear^.Message:= Gear^.Message and (not gmTimer); +CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); +with Gear^.Hedgehog^ do + if ((Gear^.Message and gmPrecise) <> 0) and ((CurWeapon^.Propz and ammoprop_SetBounce) <> 0) then + begin + color:= Gear^.Hedgehog^.Team^.Clan^.Color; + case Gear^.MsgParam of + 1: begin + AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce1]), color, capgrpAmmostate); + CurWeapon^.Bounciness:= 350; + end; + 2: begin + AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce2]), color, capgrpAmmostate); + CurWeapon^.Bounciness:= 700; + end; + 3: begin + AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce3]), color, capgrpAmmostate); + CurWeapon^.Bounciness:= 1000; + end; + 4: begin + AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce4]), color, capgrpAmmostate); + CurWeapon^.Bounciness:= 2000; + end; + 5: begin + AddCaption(FormatA(trmsg[sidBounce], trmsg[sidBounce5]), color, capgrpAmmostate); + CurWeapon^.Bounciness:= 4000; + end + end + end + else if (CurWeapon^.Propz and ammoprop_Timerable) <> 0 then + begin + CurWeapon^.Timer:= 1000 * Gear^.MsgParam; + with CurrentTeam^ do + ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); + end; +end; + + +procedure Attack(Gear: PGear); +var xx, yy, newDx, newDy, lx, ly: hwFloat; + speech: PVisualGear; + newGear: PGear; + CurWeapon: PAmmo; + altUse: boolean; + elastic: hwFloat; +begin +newGear:= nil; +bShowFinger:= false; +CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); +with Gear^, + Gear^.Hedgehog^ do + begin + if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0) + or (Power > 0) + or (CurAmmoType = amTeleport) + or + // Allow attacks while moving on ammo with AltAttack + ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) + or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) + and ((TargetPoint.X <> NoPointX) or ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget) = 0)) then + begin + State:= State or gstAttacking; + if Power = cMaxPower then + Message:= Message and (not gmAttack) + else if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) = 0 then + Message:= Message and (not gmAttack) + else + begin + if Power = 0 then + begin + AttackBar:= CurrentTeam^.AttackBar; + PlaySound(sndThrowPowerUp) + end; + inc(Power) + end; + if ((Message and gmAttack) <> 0) then + exit; + + if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0 then + begin + StopSound(sndThrowPowerUp); + PlaySound(sndThrowRelease); + end; + + xx:= SignAs(AngleSin(Angle), dX); + yy:= -AngleCos(Angle); + + lx:= X + int2hwfloat(round(GetLaunchX(CurAmmoType, hwSign(dX), Angle))); + ly:= Y + int2hwfloat(round(GetLaunchY(CurAmmoType, Angle))); + + if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then + xx:= - xx; + if Ammoz[CurAmmoType].Ammo.AttackVoice <> sndNone then + AddVoice(Ammoz[CurAmmoType].Ammo.AttackVoice, CurrentTeam^.voicepack); + +// Initiating alt attack + if (CurAmmoGear <> nil) + and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) + and ((Gear^.Message and gmLJump) <> 0) + and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then + begin + newDx:= dX; + newDy:= dY; + altUse:= true + end + else + begin + newDx:= xx*Power/cPowerDivisor; + newDy:= yy*Power/cPowerDivisor; + altUse:= false + end; + + case CurAmmoType of + amGrenade: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGrenade, 0, newDx, newDy, CurWeapon^.Timer); + amMolotov: newGear:= AddGear(hwRound(lx), hwRound(ly), gtMolotov, 0, newDx, newDy, 0); + amClusterBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtClusterBomb, 0, newDx, newDy, CurWeapon^.Timer); + amGasBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtGasBomb, 0, newDx, newDy, CurWeapon^.Timer); + amBazooka: newGear:= AddGear(hwRound(lx), hwRound(ly), gtShell, 0, newDx, newDy, 0); + amSnowball: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSnowball, 0, newDx, newDy, 0); + amBee: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBee, 0, newDx, newDy, 0); + amShotgun: begin + PlaySound(sndShotgunReload); + newGear:= AddGear(hwRound(lx), hwRound(ly), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0); + end; + amPickHammer: newGear:= AddGear(hwRound(lx), hwRound(ly) + cHHRadius, gtPickHammer, 0, _0, _0, 0); + amSkip: ParseCommand('/skip', true); + amRope: newGear:= AddGear(hwRound(lx), hwRound(ly), gtRope, 0, xx, yy, 0); + amMine: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtMine, gstWait, SignAs(_0_02, dX), _0, 3000); + amSMine: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSMine, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); + amKnife: begin + newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); + newGear^.State:= newGear^.State or gstMoving; + newGear^.Radius:= 6 // temporarily shrink so it doesn't instantly embed in the ground + end; + amDEagle: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0); + amSineGun: newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSineGunShot, 0, xx * _0_5, yy * _0_5, 0); + amPortalGun: begin + newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, + // set selected color + CurWeapon^.Pos); + end; + amSniperRifle: begin + PlaySound(sndSniperReload); + newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtSniperRifleShot, 0, xx * _0_5, yy * _0_5, 0); + end; + amDynamite: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000); + amFirePunch: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtFirePunch, 0, xx, _0, 0); + amWhip: begin + newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtWhip, 0, SignAs(_1, dX), - _0_8, 0); + PlaySound(sndWhipCrack) + end; + amHammer: begin + newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtHammer, 0, SignAs(_1, dX), - _0_8, 0); + PlaySound(sndWhack) + end; + amBaseballBat: begin + newGear:= AddGear(hwRound(lx) + hwSign(dX) * 10, hwRound(ly), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); + PlaySound(sndBaseballBat) // TODO: Only play if something is hit? + end; + amParachute: begin + newGear:= AddGear(hwRound(lx), hwRound(ly), gtParachute, 0, _0, _0, 0); + PlaySound(sndParachute) + end; + // we save CurWeapon^.Pos (in this case: cursor direction) by using it as (otherwise irrelevant) X value of the new gear. + amAirAttack: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 0, _0, _0, 0); + amMineStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 1, _0, _0, 0); + amDrillStrike: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 3, _0, _0, CurWeapon^.Timer); + amNapalm: newGear:= AddGear(CurWeapon^.Pos, 0, gtAirAttack, 2, _0, _0, 0); + amBlowTorch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0); + amGirder: newGear:= AddGear(0, 0, gtGirder, CurWeapon^.Pos, _0, _0, 0); + amTeleport: newGear:= AddGear(CurWeapon^.Pos, 0, gtTeleport, 0, _0, _0, 0); + amSwitch: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSwitcher, 0, _0, _0, 0); + amMortar: begin + playSound(sndMortar); + newGear:= AddGear(hwRound(lx), hwRound(ly), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); + end; + amRCPlane: begin + newGear:= AddGear(hwRound(lx), hwRound(ly), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); + newGear^.SoundChannel:= LoopSound(sndRCPlane) + end; + amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0); + amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, SignAs(cLittle, xx), _0, 0); + amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0); + amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon, 0, newDx, newDy, CurWeapon^.Timer); + amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb, 0, newDx, newDy, 0); + amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0); + amBallgun: newGear:= AddGear(hwRound(X), hwRound(Y), gtBallgun, 0, xx * _0_5, yy * _0_5, 0); + amJetpack: newGear:= AddGear(hwRound(lx), hwRound(ly), gtJetpack, 0, _0, _0, 0); + amBirdy: begin + PlaySound(sndWhistle); + newGear:= AddGear(hwRound(lx), hwRound(ly) - 32, gtBirdy, 0, _0, _0, 0); + end; + amLowGravity: begin + PlaySound(sndLowGravity); + cGravity:= cMaxWindSpeed; + cGravityf:= 0.00025 + end; + amExtraDamage: begin + PlaySound(sndHellishImpact4); + cDamageModifier:= _1_5 + end; + amInvulnerable: Invulnerable:= true; + amExtraTime: begin + PlaySound(sndSwitchHog); + TurnTimeLeft:= TurnTimeLeft + 30000 + end; + amLaserSight: cLaserSighting:= true; + amVampiric: begin + PlaySoundV(sndOw1, Team^.voicepack); + cVampiric:= true; + end; + amPiano: begin + // Tuck the hedgehog away until the piano attack is completed + Unplaced:= true; + X:= _0; + Y:= _0; + newGear:= AddGear(TargetPoint.X, 0, gtPiano, 0, _0, _0, 0); + PauseMusic + end; + amFlamethrower: newGear:= AddGear(hwRound(X), hwRound(Y), gtFlamethrower, 0, xx * _0_5, yy * _0_5, 0); + amLandGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtLandGun, 0, xx * _0_5, yy * _0_5, 0); + amResurrector: begin + newGear:= AddGear(hwRound(lx), hwRound(ly), gtResurrector, 0, _0, _0, 0); + newGear^.SoundChannel := LoopSound(sndResurrector); + end; + amStructure: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 7, hwRound(ly), gtStructure, gstWait, SignAs(_0_02, dX), _0, 3000); + amTardis: newGear:= AddGear(hwRound(X), hwRound(Y), gtTardis, 0, _0, _0, 5000); + amIceGun: newGear:= AddGear(hwRound(X), hwRound(Y), gtIceGun, 0, _0, _0, 0); + end; + if altUse and (newGear <> nil) then + begin + newGear^.dX:= newDx / newGear^.Density; + newGear^.dY:= newDY / newGear^.Density + end; + + case CurAmmoType of + amGrenade, amMolotov, + amClusterBomb, amGasBomb, + amBazooka, amSnowball, + amBee, amSMine, + amMortar, amWatermelon, + amHellishBomb, amDrill: FollowGear:= newGear; + + amShotgun, amPickHammer, + amRope, amDEagle, + amSineGun, amSniperRifle, + amFirePunch, amWhip, + amHammer, amBaseballBat, + amParachute, amBlowTorch, + amGirder, amTeleport, + amSwitch, amRCPlane, + amKamikaze, amCake, + amSeduction, amBallgun, + amJetpack, amBirdy, + amFlamethrower, amLandGun, + amResurrector, amStructure, + amTardis, amPiano, + amIceGun: CurAmmoGear:= newGear; + end; + + if ((CurAmmoType = amMine) or (CurAmmoType = amSMine)) and (GameFlags and gfInfAttack <> 0) then + newGear^.FlightTime:= GameTicks + 1000 + else if CurAmmoType = amDrill then + newGear^.FlightTime:= GameTicks + 250; + if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then + begin + newGear^.Target.X:= TargetPoint.X; + newGear^.Target.Y:= TargetPoint.Y + end; + if (newGear <> nil) and (newGear^.CollisionMask and $80 <> 0) then newGear^.CollisionMask:= newGear^.CollisionMask and (not $80); + + // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement + if altUse then + FollowGear:= nil; + + if (newGear <> nil) and ((Ammoz[newGear^.AmmoType].Ammo.Propz and ammoprop_SetBounce) <> 0) then + begin + elastic:= int2hwfloat(CurWeapon^.Bounciness) / _1000; + + if elastic < _1 then + newGear^.Elasticity:= newGear^.Elasticity * elastic + else if elastic > _1 then + newGear^.Elasticity:= _1 - ((_1-newGear^.Elasticity) / elastic); +(* Experimented with friction modifier. Didn't seem helpful + fric:= int2hwfloat(CurWeapon^.Bounciness) / _250; + if fric < _1 then newGear^.Friction:= newGear^.Friction * fric + else if fric > _1 then newGear^.Friction:= _1 - ((_1-newGear^.Friction) / fric)*) + end; + + + uStats.AmmoUsed(CurAmmoType); + + if not (SpeechText = '') then + begin + speech:= AddVisualGear(0, 0, vgtSpeechBubble); + if speech <> nil then + begin + speech^.Text:= SpeechText; + speech^.Hedgehog:= Gear^.Hedgehog; + speech^.FrameTicks:= SpeechType; + end; + SpeechText:= '' + end; + + Power:= 0; + if (CurAmmoGear <> nil) + and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) = 0){check for dropping ammo from rope} then + begin + Message:= Message or gmAttack; + CurAmmoGear^.Message:= Message + end + else + begin + if not CurrentTeam^.ExtDriven + and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_Power) <> 0) then + SendIPC(_S'a'); + AfterAttack; + end + end + else + Message:= Message and (not gmAttack); + end; + TargetPoint.X := NoPointX; + ScriptCall('onHogAttack'); +end; + +procedure AfterAttack; +var s: shortstring; + a: TAmmoType; + HHGear: PGear; +begin +with CurrentHedgehog^ do + begin + HHGear:= Gear; + a:= CurAmmoType; + if HHGear <> nil then HHGear^.State:= HHGear^.State and (not gstAttacking); + if (Ammoz[a].Ammo.Propz and ammoprop_Effect) = 0 then + begin + Inc(MultiShootAttacks); + + if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) then + begin + s:= inttostr(Ammoz[a].Ammo.NumPerTurn - MultiShootAttacks + 1); + AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); + end; + + if (Ammoz[a].Ammo.NumPerTurn >= MultiShootAttacks) + or ((GameFlags and gfMultiWeapon) <> 0) then + begin + isInMultiShoot:= true + end + else + begin + OnUsedAmmo(CurrentHedgehog^); + if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (((GameFlags and gfInfAttack) = 0) or PlacingHogs) then + begin + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; + TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; + end; + if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then + HHGear^.State:= HHGear^.State or gstAttacked; + if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then + ApplyAmmoChanges(CurrentHedgehog^) + end; + end + else + begin + OnUsedAmmo(CurrentHedgehog^); + ApplyAmmoChanges(CurrentHedgehog^); + end; + AttackBar:= 0 + end +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepHedgehogDead(Gear: PGear); +const frametime = 200; + timertime = frametime * 6; +begin +if Gear^.Hedgehog^.Unplaced then + exit; +if Gear^.Timer > 1 then + begin + AllInactive:= false; + dec(Gear^.Timer); + if (Gear^.Timer mod frametime) = 0 then + inc(Gear^.Pos) + end +else if Gear^.Timer = 1 then + begin + Gear^.State:= Gear^.State or gstNoDamage; + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, CurrentHedgehog, EXPLAutoSound); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; + DeleteGear(Gear); + SetAllToActive + end +else // Gear^.Timer = 0 + begin + AllInactive:= false; + Gear^.Z:= cCurrHHZ; + RemoveGearFromList(Gear); + InsertGearToList(Gear); + PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); + Gear^.Pos:= 0; + Gear^.Timer:= timertime + end +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepHedgehogGone(Gear: PGear); +const frametime = 65; + timertime = frametime * 11; +begin +if Gear^.Hedgehog^.Unplaced then + exit; +if Gear^.Timer > 1 then + begin + AllInactive:= false; + dec(Gear^.Timer); + if (Gear^.Timer mod frametime) = 0 then + inc(Gear^.Pos) + end +else +if Gear^.Timer = 1 then + begin + DeleteGear(Gear); + SetAllToActive + end +else // Gear^.Timer = 0 + begin + AllInactive:= false; + Gear^.Z:= cCurrHHZ; + RemoveGearFromList(Gear); + InsertGearToList(Gear); + PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack); + PlaySound(sndWarp); + Gear^.Pos:= 0; + Gear^.Timer:= timertime + end +end; + +procedure AddPickup(HH: THedgehog; ammo: TAmmoType; cnt, X, Y: LongWord); +var s: shortstring; + vga: PVisualGear; +begin + if cnt <> 0 then AddAmmo(HH, ammo, cnt) + else AddAmmo(HH, ammo); + + if (not (HH.Team^.ExtDriven + or (HH.BotLevel > 0))) + or (HH.Team^.Clan^.ClanIndex = LocalClan) + or (GameType = gmtDemo) then + begin + if cnt <> 0 then + s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(cnt) + ')' + else + s:= trammo[Ammoz[ammo].NameId] + ' (+' + IntToStr(Ammoz[ammo].NumberInCase) + ')'; + AddCaption(s, HH.Team^.Clan^.Color, capgrpAmmoinfo); + + // show ammo icon + vga:= AddVisualGear(X, Y, vgtAmmo); + if vga <> nil then + vga^.Frame:= Longword(ammo); + end; +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure PickUp(HH, Gear: PGear); +var s: shortstring; + i: LongInt; + vga: PVisualGear; + ag, gi: PGear; +begin +Gear^.Message:= gmDestroy; +if (Gear^.Pos and posCaseExplode) <> 0 then + if (Gear^.Pos and posCasePoison) <> 0 then + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned) + else + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound) +else if (Gear^.Pos and posCasePoison) <> 0 then + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, HH^.Hedgehog, EXPLAutoSound + EXPLPoisoned + EXPLNoDamage) +else +case Gear^.Pos of + posCaseUtility, + posCaseAmmo: begin + PlaySound(sndShotgunReload); + if Gear^.AmmoType <> amNothing then + begin + AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); + end + else + begin +// Add spawning here... + AddRandomness(GameTicks); + + gi := GearsList; + while gi <> nil do + begin + if gi^.Kind = gtGenericFaller then + begin + gi^.Active:= true; + gi^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); + gi^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); + gi^.dX:= _90-(GetRandomf*_360); + gi^.dY:= _90-(GetRandomf*_360) + end; + gi := gi^.NextGear + end; + ag:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAddAmmo, gstInvisible, _0, _0, GetRandom(125)+25); + ag^.Pos:= Gear^.Pos; + ag^.Power:= Gear^.Power + end; + end; + posCaseHealth: begin + PlaySound(sndShotgunReload); + inc(HH^.Health, Gear^.Health); + HH^.Hedgehog^.Effects[hePoisoned] := 0; + str(Gear^.Health, s); + s:= '+' + s; + AddCaption(s, HH^.Hedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); + RenderHealth(HH^.Hedgehog^); + RecountTeamHealth(HH^.Hedgehog^.Team); + + i:= 0; + while i < Gear^.Health do + begin + vga:= AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtStraightShot); + if vga <> nil then + with vga^ do + begin + Tint:= $00FF00FF; + State:= ord(sprHealth) + end; + inc(i, 5); + end; + end; + end +end; + +procedure HedgehogStep(Gear: PGear); +var PrevdX: LongInt; + CurWeapon: PAmmo; +begin +CurWeapon:= GetCurAmmoEntry(Gear^.Hedgehog^); +if ((Gear^.State and (gstAttacking or gstMoving)) = 0) then + begin + if isCursorVisible then + with Gear^.Hedgehog^ do + with CurWeapon^ do + begin + if (Gear^.Message and gmLeft ) <> 0 then + Pos:= (Pos - 1 + Ammoz[AmmoType].PosCount) mod Ammoz[AmmoType].PosCount + else + if (Gear^.Message and gmRight ) <> 0 then + Pos:= (Pos + 1) mod Ammoz[AmmoType].PosCount + else + exit; + GHStepTicks:= 200; + exit + end; + + if ((Gear^.Message and gmAnimate) <> 0) then + begin + Gear^.Message:= 0; + Gear^.State:= Gear^.State or gstAnimation; + Gear^.Tag:= Gear^.MsgParam; + Gear^.Timer:= 0; + Gear^.Pos:= 0 + end; + + if ((Gear^.Message and gmLJump ) <> 0) then + begin + Gear^.Message:= Gear^.Message and (not gmLJump); + DeleteCI(Gear); + if TestCollisionYwithGear(Gear, -1) = 0 then + if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then + Gear^.Y:= Gear^.Y - _2 + else + if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then + Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) + or (TestCollisionYwithGear(Gear, -1) <> 0)) then + begin + Gear^.dY:= -_0_15; + if not cArtillery then + Gear^.dX:= SignAs(_0_15, Gear^.dX); + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; + PlaySoundV(sndJump1, Gear^.Hedgehog^.Team^.voicepack); + exit + end; + end; + + if ((Gear^.Message and gmHJump ) <> 0) then + begin + DeleteCI(Gear); + Gear^.Message:= Gear^.Message and (not gmHJump); + + Gear^.dY:= -_0_2; + SetLittle(Gear^.dX); + Gear^.State:= Gear^.State or gstMoving or gstHHJumping; + PlaySoundV(sndJump3, Gear^.Hedgehog^.Team^.voicepack); + exit + end; + + PrevdX:= hwSign(Gear^.dX); + if (Gear^.Message and gmLeft )<>0 then + Gear^.dX:= -cLittle else + if (Gear^.Message and gmRight )<>0 then + Gear^.dX:= cLittle + else exit; + + StepSoundTimer:= cHHStepTicks; + + GHStepTicks:= cHHStepTicks; + if PrevdX <> hwSign(Gear^.dX) then + begin + FollowGear:= Gear; + exit + end; + DeleteCI(Gear); // must be after exit!! (see previous line) + + Gear^.Hedgehog^.visStepPos:= (Gear^.Hedgehog^.visStepPos + 1) and 7; + + if (not cArtillery) and ((Gear^.Message and gmPrecise) = 0) then + MakeHedgehogsStep(Gear); + + SetAllHHToActive; + AddGearCI(Gear) + end +end; + +procedure HedgehogChAngle(HHGear: PGear); +var da: LongWord; +begin +with HHGear^.Hedgehog^ do + if ((CurAmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) + or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then + da:= 2 + else da:= 1; + +if (((HHGear^.Message and gmPrecise) = 0) or ((GameTicks mod 5) = 1)) then + if ((HHGear^.Message and gmUp) <> 0) and (HHGear^.Angle >= CurMinAngle + da) then + dec(HHGear^.Angle, da) + else + if ((HHGear^.Message and gmDown) <> 0) and (HHGear^.Angle + da <= CurMaxAngle) then + inc(HHGear^.Angle, da) +end; + + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepHedgehogMoving(Gear: PGear); +var isFalling, isUnderwater: boolean; + land: Word; +begin +land:= 0; +isUnderwater:= cWaterLine < hwRound(Gear^.Y) + Gear^.Radius; +if Gear^.dX.QWordValue > 8160437862 then + Gear^.dX.QWordValue:= 8160437862; +if Gear^.dY.QWordValue > 8160437862 then + Gear^.dY.QWordValue:= 8160437862; + +if Gear^.Hedgehog^.Unplaced then + begin + Gear^.dY:= _0; + Gear^.dX:= _0; + Gear^.State:= Gear^.State and (not gstMoving); + exit + end; +isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1)); +if isFalling then + begin + if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then + Gear^.dY:= _0; + Gear^.State:= Gear^.State or gstMoving; + if (CurrentHedgehog^.Gear = Gear) + and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then + begin + // TODO: why so aggressive at setting FollowGear when falling? + FollowGear:= Gear; + end; + if isUnderwater then + Gear^.dY:= Gear^.dY + cGravity / _2 + else + begin + Gear^.dY:= Gear^.dY + cGravity; +// this set of circumstances could be less complex if jumping was more clearly identified + if ((GameFlags and gfMoreWind) <> 0) and (((Gear^.Damage <> 0) + or ((CurAmmoGear <> nil) and ((CurAmmoGear^.AmmoType = amJetpack) or (CurAmmoGear^.AmmoType = amBirdy))) + or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then + Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density + end + end +else + begin + land:= TestCollisionYwithGear(Gear, 1); + if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_55.QWordValue) and ((land and lfIce) = 0) + and ((Gear^.State and gstHHJumping) <> 0) then + SetLittle(Gear^.dX); + + if not Gear^.dY.isNegative then + begin + CheckHHDamage(Gear); + + if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) + and (Gear^.dX.QWordValue < _0_02.QWordValue) then + Gear^.dX.isNegative:= not Gear^.dX.isNegative; // landing after high jump + Gear^.State:= Gear^.State and (not (gstHHJumping or gstHHHJump)); + Gear^.dY:= _0; + end + else + Gear^.dY:= Gear^.dY + cGravity; + + if ((Gear^.State and gstMoving) <> 0) then + begin + if land and lfIce <> 0 then + begin + Gear^.dX:= Gear^.dX * (_1 - (_1 - Gear^.Friction) / _2) + end + else + Gear^.dX:= Gear^.dX * Gear^.Friction; + end + end; + +if (Gear^.State <> 0) then + DeleteCI(Gear); + +if isUnderwater then + begin + Gear^.dY:= Gear^.dY * _0_999; + Gear^.dX:= Gear^.dX * _0_999; + end; + +if (Gear^.State and gstMoving) <> 0 then + if TestCollisionXKick(Gear, hwSign(Gear^.dX)) then + if not isFalling then + if hwAbs(Gear^.dX) > _0_01 then + if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.dX:= Gear^.dX * _0_96; + Gear^.Y:= Gear^.Y - _1 + end + else + if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.dX:= Gear^.dX * _0_93; + Gear^.Y:= Gear^.Y - _2 + end + else + if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.dX:= Gear^.dX * _0_9 ; + Gear^.Y:= Gear^.Y - _3 + end + else + if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.dX:= Gear^.dX * _0_87; + Gear^.Y:= Gear^.Y - _4 + end + else + if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.dX:= Gear^.dX * _0_84; + Gear^.Y:= Gear^.Y - _5 + end + else + if hwAbs(Gear^.dX) > _0_02 then + Gear^.dX:= -Gear^.Elasticity * Gear^.dX + else + begin + Gear^.State:= Gear^.State and (not gstMoving); + while TestCollisionYWithGear(Gear,1) = 0 do + Gear^.Y:= Gear^.Y+_1; + SetLittle(Gear^.dX) + end + else + begin + Gear^.State:= Gear^.State and (not gstMoving); + while TestCollisionYWithGear(Gear,1) = 0 do + Gear^.Y:= Gear^.Y+_1; + SetLittle(Gear^.dX) + end + else if (hwAbs(Gear^.dX) > cLittle) + and ((Gear^.State and gstHHJumping) = 0) then + Gear^.dX:= -Gear^.Elasticity * Gear^.dX + else + SetLittle(Gear^.dX); + +if (not isFalling) + and (hwAbs(Gear^.dX) + hwAbs(Gear^.dY) < _0_03) then + begin + Gear^.State:= Gear^.State and (not gstWinner); + Gear^.State:= Gear^.State and (not gstMoving); + while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) do + Gear^.Y:= Gear^.Y+_1; + SetLittle(Gear^.dX); + Gear^.dY:= _0 + end +else + Gear^.State:= Gear^.State or gstMoving; + +if (Gear^.State and gstMoving) <> 0 then + begin + Gear^.State:= Gear^.State and (not gstAnimation); +// ARTILLERY but not being moved by explosions + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.Y:= Gear^.Y + Gear^.dY; + if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) + and TestCollisionYwithXYShift(Gear, 0, 1, 1) then + begin + CheckHHDamage(Gear); + Gear^.dY:= _0; + Gear^.Y:= Gear^.Y + _1 + end; + CheckGearDrowning(Gear); + // hide target cursor if current hog is drowning + if (Gear^.State and gstDrowning) <> 0 then + if (CurrentHedgehog^.Gear = Gear) then + isCursorVisible:= false + end; +if (not isZero(Gear^.dY)) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then + begin + inc(Gear^.FlightTime); + if (Gear^.FlightTime > 1500) and ((hwRound(Gear^.X) < leftX-250) or (hwRound(Gear^.X) > rightX+250)) then + begin + Gear^.FlightTime:= 0; + AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); + PlaySound(sndHomerun) + end; + end +else + begin + uStats.hedgehogFlight(Gear, Gear^.FlightTime); + Gear^.FlightTime:= 0; + end; + +end; + +procedure doStepHedgehogDriven(HHGear: PGear); +var t: PGear; + wasJumping: boolean; + Hedgehog: PHedgehog; +begin +Hedgehog:= HHGear^.Hedgehog; +if isInMultiShoot then + HHGear^.Message:= 0; + +if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then + AllInactive:= true +else if not isInMultiShoot then + AllInactive:= false; + +if (TurnTimeLeft = 0) or (HHGear^.Damage > 0) then + begin + if TagTurnTimeLeft = 0 then + TagTurnTimeLeft:= TurnTimeLeft; + TurnTimeLeft:= 0; + isCursorVisible:= false; + HHGear^.State:= HHGear^.State and (not (gstHHDriven or gstAnimation or gstAttacking)); + AttackBar:= 0; + if HHGear^.Damage > 0 then + HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); + exit + end; + +if (HHGear^.State and gstAnimation) <> 0 then + begin + HHGear^.Message:= 0; + if (HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].VoiceDelay) and (HHGear^.Timer = 0) then + PlaySoundV(Wavez[TWave(HHGear^.Tag)].Voice, Hedgehog^.Team^.voicepack); + inc(HHGear^.Timer); + if HHGear^.Timer = Wavez[TWave(HHGear^.Tag)].Interval then + begin + HHGear^.Timer:= 0; + inc(HHGear^.Pos); + if HHGear^.Pos = Wavez[TWave(HHGear^.Tag)].FramesCount then + HHGear^.State:= HHGear^.State and (not gstAnimation) + end; + exit + end; + +if ((HHGear^.State and gstMoving) <> 0) +or (GHStepTicks = cHHStepTicks) +or (CurAmmoGear <> nil) then // we are moving + begin + with Hedgehog^ do + if (CurAmmoGear = nil) + and (HHGear^.dY > _0_39) + and (CurAmmoType = amParachute) then + HHGear^.Message:= HHGear^.Message or gmAttack; + // check for case with ammo + t:= CheckGearNear(HHGear, gtCase, 36, 36); + if t <> nil then + PickUp(HHGear, t) + end; + +if (CurAmmoGear = nil) then + if (((HHGear^.Message and gmAttack) <> 0) + or ((HHGear^.State and gstAttacking) <> 0)) then + Attack(HHGear) // should be before others to avoid desync with '/put' msg and changing weapon msgs + else +else + with Hedgehog^ do + if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) + and ((HHGear^.Message and gmLJump) <> 0) + and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then + begin + Attack(HHGear); + HHGear^.Message:= HHGear^.Message and (not gmLJump) + end; + +if (CurAmmoGear = nil) +or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) +or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) then + begin + if ((HHGear^.Message and gmSlot) <> 0) then + if ChangeAmmo(HHGear) then ApplyAmmoChanges(Hedgehog^); + + if ((HHGear^.Message and gmWeapon) <> 0) then + HHSetWeapon(HHGear); + + if ((HHGear^.Message and gmTimer) <> 0) then + HHSetTimer(HHGear); + end; + +if CurAmmoGear <> nil then + begin + CurAmmoGear^.Message:= HHGear^.Message; + exit + end; + +if not isInMultiShoot then + HedgehogChAngle(HHGear); + +if (HHGear^.State and gstMoving) <> 0 then + begin + wasJumping:= ((HHGear^.State and gstHHJumping) <> 0); + + if ((HHGear^.Message and gmHJump) <> 0) and wasJumping and ((HHGear^.State and gstHHHJump) = 0) then + if (not (hwAbs(HHGear^.dX) > cLittle)) and (HHGear^.dY < -_0_02) then + begin + HHGear^.State:= HHGear^.State or gstHHHJump; + HHGear^.dY:= -_0_25; + if not cArtillery then + HHGear^.dX:= -SignAs(_0_02, HHGear^.dX); + PlaySoundV(sndJump2, Hedgehog^.Team^.voicepack) + end; + + HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); + + if (not cArtillery) and wasJumping and TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then + SetLittle(HHGear^.dX); + + if Hedgehog^.Gear <> nil then + doStepHedgehogMoving(HHGear); + + if ((HHGear^.State and (gstMoving or gstDrowning)) = 0) then + begin + AddGearCI(HHGear); + if wasJumping then + GHStepTicks:= 410 + else + GHStepTicks:= 95 + end; + exit + end; + + if not isInMultiShoot and (Hedgehog^.Gear <> nil) then + begin + if GHStepTicks > 0 then + dec(GHStepTicks); + if (GHStepTicks = 0) then + HedgehogStep(HHGear) + end +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepHedgehogFree(Gear: PGear); +var prevState: Longword; +begin +prevState:= Gear^.State; + +doStepHedgehogMoving(Gear); + +if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then + begin + if Gear^.Damage > 0 then + CalcRotationDirAngle(Gear); + AllInactive:= false; + exit + end; + +if (Gear^.Health = 0) then + begin + if PrvInactive or ((GameFlags and gfInfAttack) <> 0) then + begin + Gear^.Timer:= 0; + FollowGear:= Gear; + PrvInactive:= false; + AllInactive:= false; + + if (Gear^.State and gstHHGone) = 0 then + begin + Gear^.Hedgehog^.Effects[hePoisoned] := 0; + if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then + begin + ResurrectHedgehog(Gear); + end + else + begin + Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); + Gear^.doStep:= @doStepHedgehogDead; + // Death message + AddCaption(Format(GetEventString(eidDied), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); + end; + end + else + begin + Gear^.State:= Gear^.State and (not gstAnimation); + Gear^.doStep:= @doStepHedgehogGone; + + // Gone message + AddCaption(Format(GetEventString(eidGone), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); + end + end; + exit + end; + +if ((Gear^.State and gstWait) = 0) and + (prevState <> Gear^.State) then + begin + Gear^.State:= Gear^.State or gstWait; + Gear^.Timer:= 150 + end +else + begin + if Gear^.Timer = 0 then + begin + Gear^.State:= Gear^.State and (not (gstWait or gstLoser or gstWinner or gstAttacked or gstNotKickable or gstHHChooseTarget)); + Gear^.Active:= false; + AddGearCI(Gear); + exit + end + else dec(Gear^.Timer) + end; + +AllInactive:= false +end; + +//////////////////////////////////////////////////////////////////////////////// +procedure doStepHedgehog(Gear: PGear); +(* +var x,y,tx,ty: LongInt; + tdX, tdY, slope: hwFloat; + land: Word; *) +var slope: hwFloat; +begin +CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; +if (Gear^.Message and gmDestroy) <> 0 then + begin + DeleteGear(Gear); + exit + end; + +if (Gear^.State and gstHHDriven) = 0 then + doStepHedgehogFree(Gear) +else + begin + with Gear^.Hedgehog^ do + if Team^.hasGone then + TeamGoneEffect(Team^) + else + doStepHedgehogDriven(Gear) + end; +if (Gear^.Message and (gmAllStoppable or gmLJump or gmHJump) = 0) +and (Gear^.State and (gstHHJumping or gstHHHJump or gstAttacking) = 0) +and (not Gear^.dY.isNegative) and (GameTicks mod (100*LongWOrd(hwRound(cMaxWindSpeed*2/cGravity))) = 0) +and (TestCollisionYwithGear(Gear, 1) and lfIce <> 0) then + begin + slope:= CalcSlopeBelowGear(Gear); + Gear^.dX:=Gear^.dX+slope*_0_07; + if slope.QWordValue <> 0 then + Gear^.State:= Gear^.State or gstMoving; +(* + x:= hwRound(Gear^.X); + y:= hwRound(Gear^.Y); + AddVisualGear(x, y, vgtSmokeTrace); + AddVisualGear(x - hwRound(_5*slope), y + hwRound(_5*slope), vgtSmokeTrace); + AddVisualGear(x + hwRound(_5*slope), y - hwRound(_5*slope), vgtSmokeTrace); + AddVisualGear(x - hwRound(_20 * slope), y + hwRound(_20 * slope), vgtSmokeTrace); + AddVisualGear(x + hwRound(_20 * slope), y - hwRound(_20 * slope), vgtSmokeTrace); + AddVisualGear(x - hwRound(_30 * slope), y + hwRound(_30 * slope), vgtSmokeTrace); + AddVisualGear(x + hwRound(_30 * slope), y - hwRound(_30 * slope), vgtSmokeTrace); + AddVisualGear(x - hwRound(_40 * slope), y + hwRound(_40 * slope), vgtSmokeTrace); + AddVisualGear(x + hwRound(_40 * slope), y - hwRound(_40 * slope), vgtSmokeTrace); + AddVisualGear(x - hwRound(_50 * slope), y + hwRound(_50 * slope), vgtSmokeTrace); + AddVisualGear(x + hwRound(_50 * slope), y - hwRound(_50 * slope), vgtSmokeTrace); *) + end +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsList.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uGearsList.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,593 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} +unit uGearsList; + +interface +uses uFloat, uTypes; + +function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; +procedure DeleteGear(Gear: PGear); +procedure InsertGearToList(Gear: PGear); +procedure RemoveGearFromList(Gear: PGear); + +var curHandledGear: PGear; + +implementation + +uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats, + uTextures, uScript, uRenderUtils, uAI, uCollisions, + uGearsRender, uGearsUtils, uDebug; + +var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless + +procedure InsertGearToList(Gear: PGear); +var tmp, ptmp: PGear; +begin + tmp:= GearsList; + ptmp:= GearsList; + while (tmp <> nil) and (tmp^.Z < Gear^.Z) do + begin + ptmp:= tmp; + tmp:= tmp^.NextGear + end; + + if ptmp <> tmp then + begin + Gear^.NextGear:= ptmp^.NextGear; + Gear^.PrevGear:= ptmp; + if ptmp^.NextGear <> nil then + ptmp^.NextGear^.PrevGear:= Gear; + ptmp^.NextGear:= Gear + end + else + begin + Gear^.NextGear:= GearsList; + if Gear^.NextGear <> nil then + Gear^.NextGear^.PrevGear:= Gear; + GearsList:= Gear; + end; +end; + + +procedure RemoveGearFromList(Gear: PGear); +begin +TryDo((curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true); + +if Gear^.NextGear <> nil then + Gear^.NextGear^.PrevGear:= Gear^.PrevGear; +if Gear^.PrevGear <> nil then + Gear^.PrevGear^.NextGear:= Gear^.NextGear +else + GearsList:= Gear^.NextGear +end; + + +function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; +var gear: PGear; +begin +inc(GCounter); +AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); + +New(gear); +FillChar(gear^, sizeof(TGear), 0); +gear^.X:= int2hwFloat(X); +gear^.Y:= int2hwFloat(Y); +gear^.Target.X:= NoPointX; +gear^.Kind := Kind; +gear^.State:= State; +gear^.Active:= true; +gear^.dX:= dX; +gear^.dY:= dY; +gear^.doStep:= doStepHandlers[Kind]; +gear^.CollisionIndex:= -1; +gear^.Timer:= Timer; +gear^.uid:= GCounter; +gear^.SoundChannel:= -1; +gear^.ImpactSound:= sndNone; +gear^.Density:= _1; +// Define ammo association, if any. +gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; +gear^.CollisionMask:= $FFFF; + +if CurrentHedgehog <> nil then + begin + gear^.Hedgehog:= CurrentHedgehog; + if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then + gear^.CollisionMask:= $FF7F + end; + +if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then + gear^.Z:= cHHZ+1 +else gear^.Z:= cUsualZ; + + +case Kind of + gtGrenade, + gtClusterBomb, + gtGasBomb: begin + gear^.ImpactSound:= sndGrenadeImpact; + gear^.nImpactSounds:= 1; + gear^.AdvBounce:= 1; + gear^.Radius:= 5; + gear^.Elasticity:= _0_8; + gear^.Friction:= _0_8; + gear^.Density:= _1_5; + gear^.RenderTimer:= true; + if gear^.Timer = 0 then + gear^.Timer:= 3000 + end; + gtWatermelon: begin + gear^.ImpactSound:= sndMelonImpact; + gear^.nImpactSounds:= 1; + gear^.AdvBounce:= 1; + gear^.Radius:= 6; + gear^.Elasticity:= _0_8; + gear^.Friction:= _0_995; + gear^.Density:= _2; + gear^.RenderTimer:= true; + if gear^.Timer = 0 then + gear^.Timer:= 3000 + end; + gtMelonPiece: begin + gear^.Density:= _2; + end; + gtHedgehog: begin + gear^.AdvBounce:= 1; + gear^.Radius:= cHHRadius; + gear^.Elasticity:= _0_35; + gear^.Friction:= _0_999; + gear^.Angle:= cMaxAngle div 2; + gear^.Density:= _3; + gear^.Z:= cHHZ; + if (GameFlags and gfAISurvival) <> 0 then + if gear^.Hedgehog^.BotLevel > 0 then + gear^.Hedgehog^.Effects[heResurrectable] := 1; + end; + gtShell: begin + gear^.Radius:= 4; + gear^.Density:= _1; + end; + gtSnowball: begin + gear^.ImpactSound:= sndMudballImpact; + gear^.nImpactSounds:= 1; + gear^.Radius:= 4; + gear^.Elasticity:= _1; + gear^.Friction:= _1; + gear^.Density:= _0_5; + end; + + gtFlake: begin + with Gear^ do + begin + Pos:= 0; + Radius:= 1; + DirAngle:= random(360); + if State and gstTmpFlag = 0 then + begin + dx.isNegative:= GetRandom(2) = 0; + dx.QWordValue:= $40DA * GetRandom(10000) * 8; + dy.isNegative:= false; + dy.QWordValue:= $3AD3 * GetRandom(7000) * 8; + if GetRandom(2) = 0 then + dx := -dx + end; + State:= State or gstInvisible; + Health:= random(vobFrameTicks); + Timer:= random(vobFramesCount); + Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8; + end + end; + gtGrave: begin + gear^.ImpactSound:= sndGraveImpact; + gear^.nImpactSounds:= 1; + gear^.Radius:= 10; + gear^.Elasticity:= _0_6; + end; + gtBee: begin + gear^.Radius:= 5; + gear^.Timer:= 500; + gear^.RenderTimer:= true; + gear^.Elasticity:= _0_9; + gear^.Tag:= 0; + end; + gtSeduction: begin + gear^.Radius:= 250; + end; + gtShotgunShot: begin + gear^.Timer:= 900; + gear^.Radius:= 2 + end; + gtPickHammer: begin + gear^.Radius:= 10; + gear^.Timer:= 4000 + end; + gtHammerHit: begin + gear^.Radius:= 8; + gear^.Timer:= 125 + end; + gtRope: begin + gear^.Radius:= 3; + gear^.Friction:= _450 * _0_01 * cRopePercent; + RopePoints.Count:= 0; + end; + gtMine: begin + gear^.ImpactSound:= sndMineImpact; + gear^.nImpactSounds:= 1; + gear^.Health:= 10; + gear^.State:= gear^.State or gstMoving; + gear^.Radius:= 2; + gear^.Elasticity:= _0_55; + gear^.Friction:= _0_995; + gear^.Density:= _1; + if cMinesTime < 0 then + gear^.Timer:= getrandom(51)*100 + else + gear^.Timer:= cMinesTime; + end; + gtSMine: begin + gear^.Health:= 10; + gear^.State:= gear^.State or gstMoving; + gear^.Radius:= 2; + gear^.Elasticity:= _0_55; + gear^.Friction:= _0_995; + gear^.Density:= _1_6; + gear^.Timer:= 500; + end; + gtKnife: begin + gear^.Density:= _4; + gear^.Radius:= 16 + end; + gtCase: begin + gear^.ImpactSound:= sndGraveImpact; + gear^.nImpactSounds:= 1; + gear^.Radius:= 16; + gear^.Elasticity:= _0_3; + gear^.Timer:= 500 + end; + gtExplosives: begin + gear^.ImpactSound:= sndGrenadeImpact; + gear^.nImpactSounds:= 1; + gear^.Radius:= 16; + gear^.Elasticity:= _0_4; + gear^.Friction:= _0_995; + gear^.Density:= _6; + gear^.Health:= cBarrelHealth; + gear^.Z:= cHHZ-1 + end; + gtDEagleShot: begin + gear^.Radius:= 1; + gear^.Health:= 50 + end; + gtSniperRifleShot: begin + gear^.Radius:= 1; + gear^.Health:= 50 + end; + gtDynamite: begin + gear^.Radius:= 3; + gear^.Elasticity:= _0_55; + gear^.Friction:= _0_03; + gear^.Density:= _2; + gear^.Timer:= 5000; + end; + gtCluster: begin + gear^.Radius:= 2; + gear^.Density:= _1_5; + gear^.RenderTimer:= true + end; + gtShover: gear^.Radius:= 20; + gtFlame: begin + gear^.Tag:= GetRandom(32); + gear^.Radius:= 1; + gear^.Health:= 5; + gear^.Density:= _1; + if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then + begin + gear^.dY:= (getrandomf - _0_8) * _0_03; + gear^.dX:= (getrandomf - _0_5) * _0_4 + end + end; + gtFirePunch: begin + gear^.Radius:= 15; + gear^.Tag:= Y + end; + gtAirAttack: gear^.Z:= cHHZ+2; + gtAirBomb: begin + gear^.Radius:= 5; + gear^.Density:= _2; + end; + gtBlowTorch: begin + gear^.Radius:= cHHRadius + cBlowTorchC; + gear^.Timer:= 7500 + end; + gtSwitcher: begin + gear^.Z:= cCurrHHZ + end; + gtTarget: begin + gear^.ImpactSound:= sndGrenadeImpact; + gear^.nImpactSounds:= 1; + gear^.Radius:= 10; + gear^.Elasticity:= _0_3; + gear^.Timer:= 0 + end; + gtTardis: begin + gear^.Timer:= 0; + gear^.Pos:= 1; + gear^.Z:= cCurrHHZ+1; + end; + gtMortar: begin + gear^.Radius:= 4; + gear^.Elasticity:= _0_2; + gear^.Friction:= _0_08; + gear^.Density:= _1; + end; + gtWhip: gear^.Radius:= 20; + gtHammer: gear^.Radius:= 20; + gtKamikaze: begin + gear^.Health:= 2048; + gear^.Radius:= 20 + end; + gtCake: begin + gear^.Health:= 2048; + gear^.Radius:= 7; + gear^.Z:= cOnHHZ; + gear^.RenderTimer:= true; + gear^.DirAngle:= -90 * hwSign(Gear^.dX); + if not dX.isNegative then + gear^.Angle:= 1 + else + gear^.Angle:= 3 + end; + gtHellishBomb: begin + gear^.ImpactSound:= sndHellishImpact1; + gear^.nImpactSounds:= 4; + gear^.AdvBounce:= 1; + gear^.Radius:= 4; + gear^.Elasticity:= _0_5; + gear^.Friction:= _0_96; + gear^.Density:= _1_5; + gear^.RenderTimer:= true; + gear^.Timer:= 5000 + end; + gtDrill: begin + if gear^.Timer = 0 then + gear^.Timer:= 5000; + // Tag for drill strike. if 1 then first impact occured already + gear^.Tag := 0; + gear^.Radius:= 4; + gear^.Density:= _1; + end; + gtBall: begin + gear^.ImpactSound:= sndGrenadeImpact; + gear^.nImpactSounds:= 1; + gear^.AdvBounce:= 1; + gear^.Radius:= 5; + gear^.Tag:= random(8); + gear^.Timer:= 5000; + gear^.Elasticity:= _0_7; + gear^.Friction:= _0_995; + gear^.Density:= _1_5; + end; + gtBallgun: begin + gear^.Timer:= 5001; + end; + gtRCPlane: begin + gear^.Timer:= 15000; + gear^.Health:= 3; + gear^.Radius:= 8 + end; + gtJetpack: begin + gear^.Health:= 2000; + gear^.Damage:= 100 + end; + gtMolotov: begin + gear^.Radius:= 6; + gear^.Density:= _2; + end; + gtBirdy: begin + gear^.Radius:= 16; // todo: check + gear^.Timer:= 0; + gear^.Health := 2000; + gear^.FlightTime := 2; + end; + gtEgg: begin + gear^.Radius:= 4; + gear^.Elasticity:= _0_6; + gear^.Friction:= _0_96; + gear^.Density:= _1; + if gear^.Timer = 0 then + gear^.Timer:= 3000 + end; + gtPortal: begin + gear^.ImpactSound:= sndMelonImpact; + gear^.nImpactSounds:= 1; + gear^.AdvBounce:= 0; + gear^.Radius:= 17; + // set color + gear^.Tag:= 2 * gear^.Timer; + gear^.Timer:= 15000; + gear^.RenderTimer:= false; + gear^.Health:= 100; + end; + gtPiano: begin + gear^.Radius:= 32; + gear^.Density:= _50; + end; + gtSineGunShot: begin + gear^.Radius:= 5; + gear^.Health:= 6000; + end; +gtFlamethrower: begin + gear^.Tag:= 10; + gear^.Timer:= 10; + gear^.Health:= 500; + gear^.Damage:= 100; + end; + gtLandGun: begin + gear^.Tag:= 10; + gear^.Timer:= 10; + gear^.Health:= 1000; + gear^.Damage:= 100; + end; + gtPoisonCloud: begin + gear^.Timer:= 5000; + gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000; + end; + gtResurrector: begin + gear^.Radius := 100; + gear^.Tag := 0 + end; + gtWaterUp: begin + gear^.Tag := 47; + end; + gtNapalmBomb: begin + gear^.Timer:= 1000; + gear^.Radius:= 5; + gear^.Density:= _1_5; + end; + gtStructure: begin + gear^.Elasticity:= _0_55; + gear^.Friction:= _0_995; + gear^.Density:= _0_9; + gear^.Radius:= 13; + gear^.Health:= 200; + gear^.Timer:= 0; + gear^.Tag:= TotalRounds + 3; + gear^.Pos:= 1; + end; + gtIceGun: gear^.Health:= 1000; +gtGenericFaller:begin + gear^.AdvBounce:= 1; + gear^.Radius:= 1; + gear^.Elasticity:= _0_9; + gear^.Friction:= _0_995; + gear^.Density:= _1; + end; + end; + +InsertGearToList(gear); +AddGear:= gear; + +ScriptCall('onGearAdd', gear^.uid); +end; + +procedure DeleteGear(Gear: PGear); +var team: PTeam; + t,i: Longword; + k: boolean; +begin + +ScriptCall('onGearDelete', gear^.uid); + +DeleteCI(Gear); + +FreeTexture(Gear^.Tex); +Gear^.Tex:= nil; + +// make sure that portals have their link removed before deletion +if (Gear^.Kind = gtPortal) then + begin + if (Gear^.LinkedGear <> nil) then + if (Gear^.LinkedGear^.LinkedGear = Gear) then + Gear^.LinkedGear^.LinkedGear:= nil; + end +else if Gear^.Kind = gtHedgehog then + (* + This behaviour dates back to revision 4, and I accidentally encountered it with TARDIS. I don't think it must apply to any modern weapon, since if it was actually hit, the best the gear could do would be to destroy itself immediately, and you'd still end up with two graves. I believe it should be removed + if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then + begin + AttackBar:= 0; + Gear^.Message:= gmDestroy; + CurAmmoGear^.Message:= gmDestroy; + exit + end + else*) + begin + if (Gear <> CurrentHedgehog^.Gear) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then + Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; + if (hwRound(Gear^.Y) >= cWaterLine) then + begin + t:= max(Gear^.Damage, Gear^.Health); + Gear^.Damage:= t; + if ((not SuddenDeathDmg and (WaterOpacity < $FF)) or (SuddenDeathDmg and (WaterOpacity < $FF))) + and (hwRound(Gear^.Y) < cWaterLine + 256) then + spawnHealthTagForHH(Gear, t); + end; + + team:= Gear^.Hedgehog^.Team; + if CurrentHedgehog^.Gear = Gear then + begin + AttackBar:= 0; + FreeActionsList; // to avoid ThinkThread on drawned gear + if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoRoundEnd) <> 0) + and (CurrentHedgehog^.MultiShootAttacks > 0) then + OnUsedAmmo(CurrentHedgehog^); + end; + + Gear^.Hedgehog^.Gear:= nil; + if Gear^.Hedgehog^.King then + begin + // are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough + k:= false; + for i:= 0 to Pred(team^.Clan^.TeamsNumber) do + if (team^.Clan^.Teams[i]^.Hedgehogs[0].Gear <> nil) then + k:= true; + if not k then + for i:= 0 to Pred(team^.Clan^.TeamsNumber) do + begin + team^.Clan^.Teams[i]^.hasGone:= true; + TeamGoneEffect(team^.Clan^.Teams[i]^) + end + end; + + // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog + // same stand for CheckHHDamage + if (Gear^.LastDamage <> nil) then + uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) + else + uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); + + inc(KilledHHs); + RecountTeamHealth(team); + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and + //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then + (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then + with CurrentHedgehog^ do + begin + inc(Team^.stats.AIKills); + FreeTexture(Team^.AIKillsTex); + Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); + end + end; +with Gear^ do + begin + AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind)); + AddRandomness(X.round xor X.frac xor dX.round xor dX.frac xor Y.round xor Y.frac xor dY.round xor dY.frac) + end; +if CurAmmoGear = Gear then + CurAmmoGear:= nil; +if FollowGear = Gear then + FollowGear:= nil; +if lastGearByUID = Gear then + lastGearByUID := nil; +RemoveGearFromList(Gear); +Dispose(Gear) +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uGearsRender.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,15 +29,15 @@ Count: Longword; HookAngle: GLfloat; ar: array[0..MAXROPEPOINTS] of record - X, Y: hwFloat; - dLen: hwFloat; - b: boolean; - end; + X, Y: hwFloat; + dLen: hwFloat; + b: boolean; + end; rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f; end; implementation -uses uRender, uUtils, uVariables, uAmmos, Math; +uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGears; procedure DrawRopeLinesRQ(Gear: PGear); begin @@ -74,71 +74,80 @@ end; -procedure DrawRope(Gear: PGear); -var roplen: LongInt; - i: Longword; - - procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); - var eX, eY, dX, dY: LongInt; - i, sX, sY, x, y, d: LongInt; - b: boolean; - begin +function DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt): LongInt; +var eX, eY, dX, dY: LongInt; + i, sX, sY, x, y, d: LongInt; + b: boolean; +begin if (X1 = X2) and (Y1 = Y2) then - begin - //OutError('WARNING: zero length rope line!', false); - exit - end; + begin + //OutError('WARNING: zero length rope line!', false); + exit + end; eX:= 0; eY:= 0; dX:= X2 - X1; dY:= Y2 - Y1; - if (dX > 0) then sX:= 1 + if (dX > 0) then + sX:= 1 else - if (dX < 0) then - begin - sX:= -1; - dX:= -dX - end else sX:= dX; + if (dX < 0) then + begin + sX:= -1; + dX:= -dX + end + else sX:= dX; - if (dY > 0) then sY:= 1 + if (dY > 0) then + sY:= 1 else - if (dY < 0) then - begin - sY:= -1; - dY:= -dY - end else sY:= dY; + if (dY < 0) then + begin + sY:= -1; + dY:= -dY + end + else + sY:= dY; - if (dX > dY) then d:= dX - else d:= dY; + if (dX > dY) then + d:= dX + else + d:= dY; - x:= X1; - y:= Y1; + x:= X1; + y:= Y1; - for i:= 0 to d do + for i:= 0 to d do + begin + inc(eX, dX); + inc(eY, dY); + b:= false; + if (eX > d) then + begin + dec(eX, d); + inc(x, sX); + b:= true + end; + if (eY > d) then begin - inc(eX, dX); - inc(eY, dY); - b:= false; - if (eX > d) then - begin - dec(eX, d); - inc(x, sX); - b:= true - end; - if (eY > d) then - begin - dec(eY, d); - inc(y, sY); - b:= true - end; - if b then - begin - inc(roplen); - if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) - end - end + dec(eY, d); + inc(y, sY); + b:= true + end; + if b then + begin + inc(roplen); + if (roplen mod 4) = 0 then + DrawSprite(sprRopeNode, x - 2, y - 2, 0) + end end; +DrawRopeLine:= roplen; +end; + +procedure DrawRope(Gear: PGear); +var roplen: LongInt; + i: Longword; begin if (cReducedQuality and rqSimpleRope) <> 0 then DrawRopeLinesRQ(Gear) @@ -150,26 +159,27 @@ i:= 0; while i < Pred(RopePoints.Count) do begin - DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, - hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); + roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, + hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy, roplen); inc(i) end; - DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, - hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); - DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, - hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy); - end else + roplen:= DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, + hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, roplen); + roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, + hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen); + end + else if Gear^.Elasticity.QWordValue > 0 then - DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, - hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy); + roplen:= DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, + hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen); end; if RopePoints.Count > 0 then - DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) - else + DrawSpriteRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) +else if Gear^.Elasticity.QWordValue > 0 then - DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + DrawSpriteRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); end; @@ -195,9 +205,11 @@ CurWeapon: PAmmo; begin HH:= Gear^.Hedgehog; - if HH^.Unplaced then exit; + if HH^.Unplaced then + exit; m:= 1; - if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1; + if ((Gear^.State and gstHHHJump) <> 0) and (not cArtillery) then + m:= -1; sx:= ox + 1; // this offset is very common sy:= oy - 3; sign:= hwSign(Gear^.dX); @@ -212,7 +224,7 @@ end else if (Gear^.State and gstHHGone) <> 0 then begin - DrawRotatedF(sprTeleport, sx, sy, Gear^.Pos, sign, 0); + DrawSpriteRotatedF(sprTeleport, sx, sy, Gear^.Pos, sign, 0); exit end; @@ -220,10 +232,10 @@ HatVisible:= false; - if HH^.Effects[hePoisoned] then + if HH^.Effects[hePoisoned] <> 0 then begin Tint($00, $FF, $40, $40); - DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360); + DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360); Tint($FF, $FF, $FF, $FF) end; @@ -260,10 +272,10 @@ begin if ((Gear^.State and (gstHHThinking or gstAnimation)) = 0) and /// If current ammo is active, and current ammo has alt attack and uses a crosshair (rope, basically, right now, with no crosshair for parachute/saucer - (((CurAmmoGear <> nil) and //((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and + (((CurAmmoGear <> nil) and //((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or /// If no current ammo is active, and the selected ammo uses a crosshair - ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then + ((CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0) and ((Gear^.State and gstAttacked) = 0))) then begin (* These calculations are a little complex for a few reasons: 1: I need to draw the laser from weapon origin to nearest land @@ -309,8 +321,8 @@ // reached edge of land. assume infinite beam. Extend it way out past camera if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then begin - tx:= round(lx + ax * (LAND_WIDTH div 4)); - ty:= round(ly + ay * (LAND_WIDTH div 4)); + tx:= round(lx + ax * (max(LAND_WIDTH,4096) div 2)); + ty:= round(ly + ay * (max(LAND_WIDTH,4096) div 2)); end; //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then @@ -323,7 +335,7 @@ CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle)); - DrawRotatedTex(HH^.Team^.CrosshairTex, + DrawTextureRotated(HH^.Team^.CrosshairTex, 12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0, sign * (Gear^.Angle * 180.0) / cMaxAngle); end; @@ -335,20 +347,20 @@ case CurAmmoGear^.Kind of gtShotgunShot: begin if (CurAmmoGear^.State and gstAnimation <> 0) then - DrawRotated(sprShotgun, hx, hy, sign, aangle) + DrawSpriteRotated(sprShotgun, hx, hy, sign, aangle) else - DrawRotated(sprHandShotgun, hx, hy, sign, aangle); + DrawSpriteRotated(sprHandShotgun, hx, hy, sign, aangle); end; - gtDEagleShot: DrawRotated(sprDEagle, hx, hy, sign, aangle); + gtDEagleShot: DrawSpriteRotated(sprDEagle, hx, hy, sign, aangle); gtSniperRifleShot: begin if (CurAmmoGear^.State and gstAnimation <> 0) then - DrawRotatedF(sprSniperRifle, hx, hy, 1, sign, aangle) + DrawSpriteRotatedF(sprSniperRifle, hx, hy, 1, sign, aangle) else - DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle) + DrawSpriteRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle) end; - gtBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle); + gtBallgun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); gtRCPlane: begin - DrawRotated(sprHandPlane, hx, hy, sign, 0); + DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0); defaultPos:= false end; gtRope: begin @@ -357,38 +369,40 @@ dAngle:= 0; hAngle:= 180; i:= 1 - end else + end + else begin dAngle:= 180; hAngle:= 0; i:= -1 end; - if ((Gear^.State and gstWinner) = 0) then - begin - DrawHedgehog(ox, oy, - i, - 1, - 0, - DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); - with HH^ do - if (HatTex <> nil) then - begin - DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32, - i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle); - if HatTex^.w > 64 then + if ((Gear^.State and gstWinner) = 0) then + begin + DrawHedgehog(ox, oy, + i, + 1, + 0, + DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle); + with HH^ do + if (HatTex <> nil) then begin - Tint(HH^.Team^.Clan^.Color shl 8 or $FF); - DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32, + DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 0, i, 32, 32, i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle); - Tint($FF, $FF, $FF, $FF) + if HatTex^.w > 64 then + begin + Tint(HH^.Team^.Clan^.Color shl 8 or $FF); + DrawTextureRotatedF(HatTex, 1.0, -1.0, -6.0, ox, oy, 32, i, 32, 32, + i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle); + Tint($FF, $FF, $FF, $FF) + end end - end end; DrawAltWeapon(Gear, ox, oy); defaultPos:= false end; - gtBlowTorch: begin - DrawRotated(sprBlowTorch, hx, hy, sign, aangle); + gtBlowTorch: + begin + DrawSpriteRotated(sprBlowTorch, hx, hy, sign, aangle); DrawHedgehog(sx, sy, sign, 3, @@ -421,8 +435,9 @@ end; defaultPos:= false end; - gtShover: DrawRotated(sprHandBaseball, hx, hy, sign, aangle + 180); - gtFirePunch: begin + gtShover: DrawSpriteRotated(sprHandBaseball, hx, hy, sign, aangle + 180); + gtFirePunch: + begin DrawHedgehog(sx, sy, sign, 1, @@ -430,13 +445,15 @@ 0); defaultPos:= false end; - gtPickHammer: begin + gtPickHammer: + begin defaultPos:= false; dec(sy,20); end; gtTeleport: defaultPos:= false; - gtWhip: begin - DrawRotatedF(sprWhip, + gtWhip: + begin + DrawSpriteRotatedF(sprWhip, sx, sy, 1, @@ -444,8 +461,9 @@ 0); defaultPos:= false end; - gtHammer: begin - DrawRotatedF(sprHammer, + gtHammer: + begin + DrawSpriteRotatedF(sprHammer, sx, sy, 1, @@ -453,11 +471,13 @@ 0); defaultPos:= false end; - gtResurrector: begin - DrawRotated(sprHandResurrector, sx, sy, 0, 0); + gtResurrector: + begin + DrawSpriteRotated(sprHandResurrector, sx, sy, 0, 0); defaultPos:= false end; - gtKamikaze: begin + gtKamikaze: + begin if CurAmmoGear^.Pos = 0 then DrawHedgehog(sx, sy, sign, @@ -465,14 +485,15 @@ 6, 0) else - DrawRotatedF(sprKamikaze, + DrawSpriteRotatedF(sprKamikaze, ox, oy, CurAmmoGear^.Pos - 1, sign, aangle); defaultPos:= false end; - gtSeduction: begin + gtSeduction: + begin if CurAmmoGear^.Pos >= 6 then DrawHedgehog(sx, sy, sign, @@ -481,7 +502,7 @@ 0) else begin - DrawRotatedF(sprDress, + DrawSpriteRotatedF(sprDress, ox, oy, CurAmmoGear^.Pos, sign, @@ -490,12 +511,21 @@ end; defaultPos:= false end; - gtFlamethrower: begin - DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); - if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex) + gtFlamethrower: + begin + DrawSpriteRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); + if CurAmmoGear^.Tex <> nil then + DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex) end; - gtLandGun: begin DrawRotated(sprHandBallgun, hx, hy, sign, aangle); - if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex) + gtLandGun: + begin DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); + if CurAmmoGear^.Tex <> nil then + DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex) + end; + gtIceGun: + begin DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); + if CurAmmoGear^.Tex <> nil then + DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex) end; end; @@ -503,12 +533,9 @@ gtShotgunShot, gtDEagleShot, gtSniperRifleShot, - gtShover: begin - DrawHedgehog(sx, sy, - sign, - 0, - 4, - 0); + gtShover: + begin + DrawHedgehog(sx, sy, sign, 0, 4, 0); defaultPos:= false; HatVisible:= true end @@ -542,11 +569,11 @@ begin if (TWave(Gear^.Tag) < Low(TWave)) or (TWave(Gear^.Tag) > High(TWave)) then begin - Gear^.State:= Gear^.State and not gstAnimation; + Gear^.State:= Gear^.State and (not gstAnimation); end else begin - DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, + DrawSpriteRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, sx, sy, Gear^.Pos, @@ -561,54 +588,61 @@ if HH^.Timer > 0 then begin // There must be a tidier way to do this. Anyone? - if aangle <= 90 then aangle:= aangle+360; - if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10) - else aangle:= aangle+((240-aangle)*HH^.Timer/10); + if aangle <= 90 then + aangle:= aangle+360; + if Gear^.dX > _0 then + aangle:= aangle-((aangle-240)*HH^.Timer/10) + else + aangle:= aangle+((240-aangle)*HH^.Timer/10); dec(HH^.Timer) end; amt:= CurrentHedgehog^.CurAmmoType; - CurWeapon:= GetAmmoEntry(HH^); + CurWeapon:= GetCurAmmoEntry(HH^); case amt of - amBazooka: DrawRotated(sprHandBazooka, hx, hy, sign, aangle); - amSnowball: DrawRotated(sprHandSnowball, hx, hy, sign, aangle); - amMortar: DrawRotated(sprHandMortar, hx, hy, sign, aangle); - amMolotov: DrawRotated(sprHandMolotov, hx, hy, sign, aangle); - amBallgun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle); - amDrill: DrawRotated(sprHandDrill, hx, hy, sign, aangle); - amRope: DrawRotated(sprHandRope, hx, hy, sign, aangle); - amShotgun: DrawRotated(sprHandShotgun, hx, hy, sign, aangle); - amDEagle: DrawRotated(sprHandDEagle, hx, hy, sign, aangle); - amSineGun: DrawRotatedF(sprHandSinegun, hx, hy, 73 + (sign * LongInt(RealTicks div 73)) mod 8, sign, aangle); - amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer? - DrawRotatedF(sprPortalGun, hx, hy, 0, sign, aangle) - else - DrawRotatedF(sprPortalGun, hx, hy, 1+CurWeapon^.Pos, sign, aangle); - amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle); - amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, sign, aangle); - amCake: DrawRotated(sprHandCake, hx, hy, sign, aangle); - amGrenade: DrawRotated(sprHandGrenade, hx, hy, sign, aangle); - amWatermelon: DrawRotated(sprHandMelon, hx, hy, sign, aangle); - amSkip: DrawRotated(sprHandSkip, hx, hy, sign, aangle); - amClusterBomb: DrawRotated(sprHandCluster, hx, hy, sign, aangle); - amDynamite: DrawRotated(sprHandDynamite, hx, hy, sign, aangle); - amHellishBomb: DrawRotated(sprHandHellish, hx, hy, sign, aangle); - amGasBomb: DrawRotated(sprHandCheese, hx, hy, sign, aangle); - amMine: DrawRotated(sprHandMine, hx, hy, sign, aangle); - amSMine: DrawRotated(sprHandSMine, hx, hy, sign, aangle); + amBazooka: DrawSpriteRotated(sprHandBazooka, hx, hy, sign, aangle); + amSnowball: DrawSpriteRotated(sprHandSnowball, hx, hy, sign, aangle); + amMortar: DrawSpriteRotated(sprHandMortar, hx, hy, sign, aangle); + amMolotov: DrawSpriteRotated(sprHandMolotov, hx, hy, sign, aangle); + amBallgun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); + amDrill: DrawSpriteRotated(sprHandDrill, hx, hy, sign, aangle); + amRope: DrawSpriteRotated(sprHandRope, hx, hy, sign, aangle); + amShotgun: DrawSpriteRotated(sprHandShotgun, hx, hy, sign, aangle); + amDEagle: DrawSpriteRotated(sprHandDEagle, hx, hy, sign, aangle); + amSineGun: DrawSpriteRotatedF(sprHandSinegun, hx, hy, 73 + (sign * LongInt(RealTicks div 73)) mod 8, sign, aangle); + + amPortalGun: + if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer? + DrawSpriteRotatedF(sprPortalGun, hx, hy, 0, sign, aangle) + else + DrawSpriteRotatedF(sprPortalGun, hx, hy, 1+CurWeapon^.Pos, sign, aangle); + + amSniperRifle: DrawSpriteRotatedF(sprSniperRifle, hx, hy, 0, sign, aangle); + amBlowTorch: DrawSpriteRotated(sprHandBlowTorch, hx, hy, sign, aangle); + amCake: DrawSpriteRotated(sprHandCake, hx, hy, sign, aangle); + amGrenade: DrawSpriteRotated(sprHandGrenade, hx, hy, sign, aangle); + amWatermelon: DrawSpriteRotated(sprHandMelon, hx, hy, sign, aangle); + amSkip: DrawSpriteRotated(sprHandSkip, hx, hy, sign, aangle); + amClusterBomb: DrawSpriteRotated(sprHandCluster, hx, hy, sign, aangle); + amDynamite: DrawSpriteRotated(sprHandDynamite, hx, hy, sign, aangle); + amHellishBomb: DrawSpriteRotated(sprHandHellish, hx, hy, sign, aangle); + amGasBomb: DrawSpriteRotated(sprHandCheese, hx, hy, sign, aangle); + amMine: DrawSpriteRotated(sprHandMine, hx, hy, sign, aangle); + amSMine: DrawSpriteRotated(sprHandSMine, hx, hy, sign, aangle); + amKnife: DrawSpriteRotatedF(sprHandKnife, hx, hy, 0, sign, aangle); amSeduction: begin - DrawRotated(sprHandSeduction, hx, hy, sign, aangle); + DrawSpriteRotated(sprHandSeduction, hx, hy, sign, aangle); DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA); //Tint($FF, $0, $0, $AA); //DrawTexture(ox - 240, oy - 240, SpritesData[sprVampiric].Texture, 10); //Tint($FF, $FF, $FF, $FF); end; - amVampiric: DrawRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle); + amVampiric: DrawSpriteRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle); amRCPlane: begin - DrawRotated(sprHandPlane, hx, hy, sign, 0); + DrawSpriteRotated(sprHandPlane, hx, hy, sign, 0); defaultPos:= false end; amGirder: begin - DrawRotated(sprHandConstruction, hx, hy, sign, aangle); + DrawSpriteRotated(sprHandConstruction, hx, hy, sign, aangle); DrawSpriteClipped(sprGirder, ox-256, oy-256, @@ -617,34 +651,35 @@ cWaterLine+WorldDy, LongInt(leftX)+WorldDx) end; - amBee: DrawRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle); - amFlamethrower: DrawRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); - amLandGun: DrawRotated(sprHandBallgun, hx, hy, sign, aangle); + amBee: DrawSpriteRotatedF(sprHandBee, hx, hy, (RealTicks div 125) mod 4, sign, aangle); + amFlamethrower: DrawSpriteRotatedF(sprHandFlamethrower, hx, hy, (RealTicks div 125) mod 4, sign, aangle); + amLandGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); + amIceGun: DrawSpriteRotated(sprHandBallgun, hx, hy, sign, aangle); amResurrector: DrawCircle(ox, oy, 98, 4, $F5, $DB, $35, $AA); // I'd rather not like to hardcode 100 here end; case amt of amAirAttack, amMineStrike, - amDrillStrike: DrawRotated(sprHandAirAttack, sx, oy, sign, 0); + amDrillStrike: DrawSpriteRotated(sprHandAirAttack, sx, oy, sign, 0); amPickHammer: DrawHedgehog(sx, sy, sign, 1, 2, 0); - amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, sign, 0); + amTeleport: DrawSpriteRotatedF(sprTeleport, sx, sy, 0, sign, 0); amKamikaze: DrawHedgehog(sx, sy, sign, 1, 5, 0); - amWhip: DrawRotatedF(sprWhip, + amWhip: DrawSpriteRotatedF(sprWhip, sx, sy, 0, sign, 0); - amHammer: DrawRotatedF(sprHammer, + amHammer: DrawSpriteRotatedF(sprHammer, sx, sy, 0, @@ -672,7 +707,7 @@ end; case amt of - amBaseballBat: DrawRotated(sprHandBaseball, + amBaseballBat: DrawSpriteRotated(sprHandBaseball, sx - 4 * sign, sy + 9, sign, aangle); end; @@ -708,7 +743,7 @@ begin if defaultPos then begin - DrawRotatedF(sprHHIdle, + DrawSpriteRotatedF(sprHHIdle, sx, sy, (RealTicks div 128 + Gear^.Pos) mod 19, @@ -792,11 +827,15 @@ DrawSprite(sprJetpack, sx-32, sy-32, 0); if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then begin - if (CurAmmoGear^.MsgParam and gmUp) <> 0 then DrawSprite(sprJetpack, sx-32, sy-28, 1); - if (CurAmmoGear^.MsgParam and gmLeft) <> 0 then DrawSprite(sprJetpack, sx-28, sy-28, 2); - if (CurAmmoGear^.MsgParam and gmRight) <> 0 then DrawSprite(sprJetpack, sx-36, sy-28, 3) + if (CurAmmoGear^.MsgParam and gmUp) <> 0 then + DrawSprite(sprJetpack, sx-32, sy-28, 1); + if (CurAmmoGear^.MsgParam and gmLeft) <> 0 then + DrawSprite(sprJetpack, sx-28, sy-28, 2); + if (CurAmmoGear^.MsgParam and gmRight) <> 0 then + DrawSprite(sprJetpack, sx-36, sy-28, 3) end; - if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex); + if CurAmmoGear^.Tex <> nil then + DrawTextureCentered(sx, sy - 40, CurAmmoGear^.Tex); DrawAltWeapon(Gear, sx, sy) end; end; @@ -805,7 +844,7 @@ with HH^ do begin - if ((Gear^.State and not gstWinner) = 0) + if ((Gear^.State and (not gstWinner)) = 0) or ((Gear^.State = gstWait) and (Gear^.dY.QWordValue = 0)) or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then begin @@ -815,17 +854,17 @@ if ((cTagsMask and htHealth) <> 0) then begin dec(t, HealthTagTex^.h + 2); - DrawCentered(ox, t, HealthTagTex) + DrawTextureCentered(ox, t, HealthTagTex) end; if (cTagsMask and htName) <> 0 then begin dec(t, NameTagTex^.h + 2); - DrawCentered(ox, t, NameTagTex) + DrawTextureCentered(ox, t, NameTagTex) end; if (cTagsMask and htTeamName) <> 0 then begin dec(t, Team^.NameTagTex^.h + 2); - DrawCentered(ox, t, Team^.NameTagTex) + DrawTextureCentered(ox, t, Team^.NameTagTex) end; if (cTagsMask and htTransparent) <> 0 then Tint($FF, $FF, $FF, $FF) @@ -833,7 +872,7 @@ if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog begin if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtResurrector) then - DrawCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex); + DrawTextureCentered(ox, sy - cHHRadius - 7 - HealthTagTex^.h, HealthTagTex); if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then DrawSprite(sprFinger, ox - 16, oy - 64, @@ -845,12 +884,12 @@ end end; - if HH^.Effects[hePoisoned] then + if HH^.Effects[hePoisoned] <> 0 then begin Tint($00, $FF, $40, $80); - DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360); + DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360); end; - if HH^.Effects[heResurrected] then + if HH^.Effects[heResurrected] <> 0 then begin Tint($f5, $db, $35, $20); DrawSprite(sprVampiric, sx - 24, sy - 24, 0); @@ -875,55 +914,54 @@ procedure RenderGear(Gear: PGear; x, y: LongInt); var HHGear: PGear; + vg: PVisualGear; i: Longword; + aAngle: real; startX, endX, startY, endY: LongInt; begin if Gear^.Target.X <> NoPointX then if Gear^.AmmoType = amBee then - DrawRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) - else - DrawRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); + DrawSpriteRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) + else if Gear^.AmmoType = amIceGun then + //DrawSprite(sprSnowDust, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8) + //DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360) + DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1/(1+(RealTicks shr 8) mod 5), 0, 0, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, (RealTicks shr 2) mod 8, 1, 22, 22, (RealTicks shr 3) mod 360) + else + DrawSpriteRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); case Gear^.Kind of - gtGrenade: DrawRotated(sprBomb, x, y, 0, Gear^.DirAngle); - gtSnowball: DrawRotated(sprSnowball, x, y, 0, Gear^.DirAngle); - gtGasBomb: DrawRotated(sprCheese, x, y, 0, Gear^.DirAngle); + gtGrenade: DrawSpriteRotated(sprBomb, x, y, 0, Gear^.DirAngle); + gtSnowball: DrawSpriteRotated(sprSnowball, x, y, 0, Gear^.DirAngle); + gtGasBomb: DrawSpriteRotated(sprCheese, x, y, 0, Gear^.DirAngle); gtMolotov: if (Gear^.State and gstDrowning) = 0 then - DrawRotatedF(sprMolotov, x, y, (RealTicks div 125) mod 8, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX)) + DrawSpriteRotatedF(sprMolotov, x, y, (RealTicks div 125) mod 8, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX)) else DrawSprite(sprMolotov, x, y, 8); gtRCPlane: begin + aangle:= Gear^.Angle * 360 / 4096; + if Gear^.Tag < 0 then aangle:= 360-aangle; Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF); - if Gear^.Tag = -1 then - begin - DrawRotatedF(sprPlane, x, y, 0, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90); - Tint($FF, $FF, $FF, $FF); - DrawRotatedF(sprPlane, x, y, 1, -1, DxDy2Angle(Gear^.dX, Gear^.dY) + 90) - end - else - begin - DrawRotatedF(sprPlane, x, y, 0, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); - Tint($FF, $FF, $FF, $FF); - DrawRotatedF(sprPlane, x, y, 1, 0, DxDy2Angle(Gear^.dY, Gear^.dX)) - end + DrawSpriteRotatedF(sprPlane, x, y, 0, Gear^.Tag, aangle - 90); + Tint($FF, $FF, $FF, $FF); + DrawSpriteRotatedF(sprPlane, x, y, 1, Gear^.Tag, aangle - 90) end; - gtBall: DrawRotatedf(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle); + gtBall: DrawSpriteRotatedF(sprBalls, x, y, Gear^.Tag,0, Gear^.DirAngle); gtPortal: if ((Gear^.Tag and 1) = 0) // still moving? - or (Gear^.IntersectGear = nil) or (Gear^.IntersectGear^.IntersectGear <> Gear) // not linked&backlinked? - or ((Gear^.IntersectGear^.Tag and 1) = 0) then // linked portal still moving? - DrawRotatedf(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle) - else DrawRotatedf(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle); + or (Gear^.LinkedGear = nil) or (Gear^.LinkedGear^.LinkedGear <> Gear) // not linked&backlinked? + or ((Gear^.LinkedGear^.Tag and 1) = 0) then // linked portal still moving? + DrawSpriteRotatedF(sprPortal, x, y, Gear^.Tag, hwSign(Gear^.dX), Gear^.DirAngle) + else DrawSpriteRotatedF(sprPortal, x, y, 4 + Gear^.Tag div 2, hwSign(Gear^.dX), Gear^.DirAngle); gtDrill: if (Gear^.State and gsttmpFlag) <> 0 then - DrawRotated(sprAirDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)) + DrawSpriteRotated(sprAirDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)) else - DrawRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + DrawSpriteRotated(sprDrill, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtHedgehog: DrawHH(Gear, x, y); - gtShell: DrawRotated(sprBazookaShell, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtShell: DrawSpriteRotated(sprBazookaShell, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtGrave: begin DrawTextureF(Gear^.Hedgehog^.Team^.GraveTex, 1, x, y, (GameTicks shr 7+Gear^.uid) and 7, 1, 32, 32); @@ -936,52 +974,72 @@ Tint($FF, $FF, $FF, $FF) end end; - gtBee: DrawRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtBee: DrawSpriteRotatedF(sprBee, x, y, (GameTicks shr 5) mod 2, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtPickHammer: DrawSprite(sprPHammer, x - 16, y - 50 + LongInt(((GameTicks shr 5) and 1) * 2), 0); gtRope: DrawRope(Gear); + gtMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then - DrawRotated(sprMineOff, x, y, 0, Gear^.DirAngle) - else if Gear^.Health <> 0 then DrawRotated(sprMineOn, x, y, 0, Gear^.DirAngle) - else DrawRotated(sprMineDead, x, y, 0, Gear^.DirAngle); + DrawSpriteRotated(sprMineOff, x, y, 0, Gear^.DirAngle) + else if Gear^.Health <> 0 then + DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle) + else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle); + gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then - DrawRotated(sprSMineOff, x, y, 0, Gear^.DirAngle) - else if Gear^.Health <> 0 then DrawRotated(sprSMineOn, x, y, 0, Gear^.DirAngle) - else DrawRotated(sprMineDead, x, y, 0, Gear^.DirAngle); - gtCase: if ((Gear^.Pos and posCaseAmmo) <> 0) then + DrawSpriteRotated(sprSMineOff, x, y, 0, Gear^.DirAngle) + else if Gear^.Health <> 0 then + DrawSpriteRotated(sprSMineOn, x, y, 0, Gear^.DirAngle) + else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle); + gtKnife: DrawSpriteRotatedF(sprKnife, x, y, 0, hwSign(Gear^.dX), Gear^.DirAngle); + + gtCase: begin + if Gear^.Timer > 1000 then begin - i:= (GameTicks shr 6) mod 64; - if i > 18 then i:= 0; - DrawSprite(sprCase, x - 24, y - 24, i); + if ((Gear^.Pos and posCaseAmmo) <> 0) then + begin + i:= (GameTicks shr 6) mod 64; + if i > 18 then + i:= 0; + DrawSprite(sprCase, x - 24, y - 24, i); + end + else if ((Gear^.Pos and posCaseHealth) <> 0) then + begin + i:= ((GameTicks shr 6) + 38) mod 64; + if i > 13 then + i:= 0; + DrawSprite(sprFAid, x - 24, y - 24, i); + end + else if ((Gear^.Pos and posCaseUtility) <> 0) then + begin + i:= (GameTicks shr 6) mod 70; + if i > 23 then + i:= 0; + i:= i mod 12; + DrawSprite(sprUtility, x - 24, y - 24, i); + end; + end; + if Gear^.Timer < 1833 then + begin + DrawTextureRotatedF(SpritesData[sprPortal].texture, min(abs(1.25 - (Gear^.Timer mod 1333) / 400), 1.25), 0, 0, + x, LongInt(Gear^.Angle) + WorldDy - 16, 4 + Gear^.Tag, 1, 32, 32, 270); end - else if ((Gear^.Pos and posCaseHealth) <> 0) then - begin - i:= ((GameTicks shr 6) + 38) mod 64; - if i > 13 then i:= 0; - DrawSprite(sprFAid, x - 24, y - 24, i); - end - else if ((Gear^.Pos and posCaseUtility) <> 0) then - begin - i:= (GameTicks shr 6) mod 70; - if i > 23 then i:= 0; - i:= i mod 12; - DrawSprite(sprUtility, x - 24, y - 24, i); - end; + end; gtExplosives: begin if ((Gear^.State and gstDrowning) <> 0) then DrawSprite(sprExplosivesRoll, x - 24, y - 24, 0) else if Gear^.State and gstAnimation = 0 then begin i:= (GameTicks shr 6 + Gear^.uid*3) mod 64; - if i > 18 then i:= 0; + if i > 18 then + i:= 0; DrawSprite(sprExplosives, x - 24, y - 24, i) end else if Gear^.State and gsttmpFlag = 0 then - DrawRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle) + DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 0, 0, Gear^.DirAngle) else - DrawRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle); + DrawSpriteRotatedF(sprExplosivesRoll, x, y + 4, 1, 0, Gear^.DirAngle); end; - gtDynamite: DrawSprite2(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1); - gtClusterBomb: DrawRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle); + gtDynamite: DrawSprite(sprDynamite, x - 16, y - 25, Gear^.Tag and 1, Gear^.Tag shr 1); + gtClusterBomb: DrawSpriteRotated(sprClusterBomb, x, y, 0, Gear^.DirAngle); gtCluster: DrawSprite(sprClusterParticle, x - 8, y - 8, 0); gtFlame: if Gear^.Tag and 1 = 0 then DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), x, y, (GameTicks shr 7 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16) @@ -992,15 +1050,16 @@ end; gtAirAttack: begin Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF); - DrawRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0); + DrawSpriteRotatedF(sprAirplane, x, y, 0, Gear^.Tag, 0); Tint($FF, $FF, $FF, $FF); - DrawRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0); + DrawSpriteRotatedF(sprAirplane, x, y, 1, Gear^.Tag, 0); end; - gtAirBomb: DrawRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtAirBomb: DrawSpriteRotated(sprAirBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtTeleport: begin HHGear:= Gear^.Hedgehog^.Gear; - if not Gear^.Hedgehog^.Unplaced then DrawRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0); - DrawRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); + if not Gear^.Hedgehog^.Unplaced then + DrawSpriteRotatedF(sprTeleport, x + 1, y - 3, Gear^.Pos, hwSign(Gear^.dX), 0); + DrawSpriteRotatedF(sprTeleport, hwRound(HHGear^.X) + 1 + WorldDx, hwRound(HHGear^.Y) - 3 + WorldDy, 11 - Gear^.Pos, hwSign(HHGear^.dX), 0); end; gtSwitcher: DrawSprite(sprSwitch, x - 16, y - 56, (GameTicks shr 6) mod 12); gtTarget: begin @@ -1008,15 +1067,17 @@ DrawSprite(sprTarget, x - 16, y - 16, 0); Tint($FF, $FF, $FF, $FF); end; - gtMortar: DrawRotated(sprMortar, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtMortar: DrawSpriteRotated(sprMortar, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtCake: if Gear^.Pos = 6 then - DrawRotatedf(sprCakeWalk, x, y, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90) + DrawSpriteRotatedF(sprCakeWalk, x, y, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90) else - DrawRotatedf(sprCakeDown, x, y, 5 - Gear^.Pos, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90); - gtSeduction: if Gear^.Pos >= 14 then DrawSprite(sprSeduction, x - 16, y - 16, 0); - gtWatermelon: DrawRotatedf(sprWatermelon, x, y, 0, 0, Gear^.DirAngle); - gtMelonPiece: DrawRotatedf(sprWatermelon, x, y, 1, 0, Gear^.DirAngle); - gtHellishBomb: DrawRotated(sprHellishBomb, x, y, 0, Gear^.DirAngle); + DrawSpriteRotatedF(sprCakeDown, x, y, 5 - Gear^.Pos, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90); + gtSeduction: if Gear^.Pos >= 14 then + DrawSprite(sprSeduction, x - 16, y - 16, 0); + + gtWatermelon: DrawSpriteRotatedF(sprWatermelon, x, y, 0, 0, Gear^.DirAngle); + gtMelonPiece: DrawSpriteRotatedF(sprWatermelon, x, y, 1, 0, Gear^.DirAngle); + gtHellishBomb: DrawSpriteRotated(sprHellishBomb, x, y, 0, Gear^.DirAngle); gtBirdy: begin if Gear^.State and gstAnimation = gstAnimation then begin @@ -1025,9 +1086,9 @@ endX:= x - WorldDx; endY:= y - WorldDy; if Gear^.Tag < 0 then - startX:= max(LAND_WIDTH + 1024, endX + 2048) + startX:= max(max(LAND_WIDTH,4096) + 1024, endX + 2048) else - startX:= max(-LAND_WIDTH - 1024, endX - 2048); + startX:= max(-max(LAND_WIDTH,4096) - 1024, endX - 2048); startY:= endY - 256; DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2)))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75); end @@ -1036,9 +1097,9 @@ startX:= x - WorldDx; startY:= y - WorldDy; if Gear^.Tag > 0 then - endX:= max(LAND_WIDTH + 1024, startX + 2048) + endX:= max(max(LAND_WIDTH,4096) + 1024, startX + 2048) else - endX:= max(-LAND_WIDTH - 1024, startX - 2048); + endX:= max(-max(LAND_WIDTH,4096) - 1024, startX - 2048); endY:= startY + 256; DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY))) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75); end; @@ -1051,7 +1112,7 @@ DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75); end; end; - gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, x, y, 0, 1, 16, 16, Gear^.DirAngle); + gtEgg: DrawTextureRotatedF(SpritesData[sprEgg].Texture, 1, 0, 0, x, y, 0, 1, 16, 16, Gear^.DirAngle); gtPiano: begin if (Gear^.State and gstDrowning) = 0 then begin @@ -1069,61 +1130,96 @@ Tint($C0, $C0, $00, (5000 - Gear^.Timer) div 8) else Tint($C0, $C0, $00, $C0); - DrawRotatedTextureF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360); + DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360); Tint($FF, $FF, $FF, $FF) end; gtResurrector: begin - DrawRotated(sprCross, x, y, 0, 0); + DrawSpriteRotated(sprCross, x, y, 0, 0); Tint($f5, $db, $35, max($00, round($C0 * abs(1 - (GameTicks mod 6000) / 3000)))); DrawTexture(x - 108, y - 108, SpritesData[sprVampiric].Texture, 4.5); Tint($FF, $FF, $FF, $FF); end; - gtNapalmBomb: DrawRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + gtNapalmBomb: DrawSpriteRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0 then begin - Tint((cExplosionBorderColor shr RShift) and $FF, - (cExplosionBorderColor shr GShift) and $FF, - (cExplosionBorderColor shr BShift) and $FF, + Tint((ExplosionBorderColor shr RShift) and $FF, + (ExplosionBorderColor shr GShift) and $FF, + (ExplosionBorderColor shr BShift) and $FF, $FF); // Needs a nicer white texture to tint - DrawRotatedTextureF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle); - //DrawRotated(sprSnowDust, x, y, 0, Gear^.DirAngle); + DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle); + //DrawSpriteRotated(sprSnowDust, x, y, 0, Gear^.DirAngle); //DrawTexture(x, y, SpritesData[sprVampiric].Texture, 0.1); Tint($FF, $FF, $FF, $FF); end else //if not isInLag then begin - if isInLag and (Gear^.FlightTime < 256) then inc(Gear^.FlightTime, 8) - else if not isInLag and (Gear^.FlightTime > 0) then dec(Gear^.FlightTime, 8); - if Gear^.FlightTime > 0 then Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime)); + if isInLag and (Gear^.FlightTime < 256) then + inc(Gear^.FlightTime, 8) + else if not isInLag and (Gear^.FlightTime > 0) then + dec(Gear^.FlightTime, 8); + if Gear^.FlightTime > 0 then + Tint($FF, $FF, $FF, $FF-min(255,Gear^.FlightTime)); if vobVelocity = 0 then DrawSprite(sprFlake, x, y, Gear^.Timer) else - DrawRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle); + DrawSpriteRotatedF(sprFlake, x, y, Gear^.Timer, 1, Gear^.DirAngle); //DrawSprite(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer) -//DrawRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle); - if Gear^.FlightTime > 0 then Tint($FF, $FF, $FF, $FF); +//DrawSpriteRotatedF(sprFlake, x-SpritesData[sprFlake].Width div 2, y-SpritesData[sprFlake].Height div 2, Gear^.Timer, 1, Gear^.DirAngle); + if Gear^.FlightTime > 0 then + Tint($FF, $FF, $FF, $FF); end; gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0); gtTardis: if Gear^.Pos <> 4 then begin - if Gear^.Pos = 2 then Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF) - else Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000))))); + if Gear^.Pos = 2 then + Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF) + else + Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000))))); DrawSprite(sprTardis, x-24, y-63,0); - if Gear^.Pos = 2 then Tint($FF, $FF, $FF, $FF) - else Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000))))); + if Gear^.Pos = 2 then + Tint($FF, $FF, $FF, $FF) + else + Tint($FF,$FF,$FF,max($00, round(Gear^.Power * (1-abs(0.5 - (GameTicks mod 2000) / 2000))))); DrawSprite(sprTardis, x-24, y-63,1); - if Gear^.Pos <> 2 then Tint($FF, $FF, $FF, $FF) + if Gear^.Pos <> 2 then + Tint($FF, $FF, $FF, $FF) (* Tint(Gear^.Hedgehog^.Team^.Clan^.Color shl 8 or max($00, round(Gear^.Power * abs(1 - (RealTicks mod 500) / 250)))); DrawTexture(x-6, y-70, SpritesData[sprVampiric].Texture, 0.25); Tint($FF, $FF, $FF, $FF) *) end; - - + gtIceGun: begin + HHGear := Gear^.Hedgehog^.Gear; + if HHGear <> nil then + begin + i:= hwRound(hwSqr(Gear^.X - HHGear^.X) + hwSqr(Gear^.Y - HHGear^.Y)); + if RealTicks mod max(1,50 - (round(sqrt(i)) div 4)) = 0 then // experiment in "intensifying" might not get used + begin + vg:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtDust, 1); + if vg <> nil then + begin + i:= random(100) + 155; + vg^.Tint:= i shl 24 or i shl 16 or $FF shl 8 or Longword(random(200) + 55); + vg^.Angle:= random(360); + vg^.dx:= 0.001 * random(80); + vg^.dy:= 0.001 * random(80) + end + end; + if RealTicks mod 2 = 0 then + begin + i:= random(100)+100; + if Gear^.Target.X <> NoPointX then + DrawLine(Gear^.Target.X, Gear^.Target.Y, hwRound(HHGear^.X), hwRound(HHGear^.Y), 4.0, i, i, $FF, $40) + else DrawLine(hwRound(HHGear^.X), hwRound(HHGear^.Y), hwRound(Gear^.X), hwRound(Gear^.Y), 4.0, i, i, $FF, $40); + end + end + end; + gtGenericFaller: DrawCircle(x, y, 3, 3, $FF, $00, $00, $FF); // debug end; - if Gear^.RenderTimer and (Gear^.Tex <> nil) then DrawCentered(x + 8, y + 8, Gear^.Tex); + if Gear^.RenderTimer and (Gear^.Tex <> nil) then + DrawTextureCentered(x + 8, y + 8, Gear^.Tex); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uGearsUtils.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uGearsUtils.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,759 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} + +unit uGearsUtils; +interface +uses uTypes; + +procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; +procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); + +function ModifyDamage(dmg: Longword; Gear: PGear): Longword; +procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); +procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); +procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); +procedure CheckHHDamage(Gear: PGear); +procedure CalcRotationDirAngle(Gear: PGear); +procedure ResurrectHedgehog(gear: PGear); + +procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; +procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); + +function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; +function CheckGearDrowning(Gear: PGear): boolean; +procedure CheckCollision(Gear: PGear); inline; +procedure CheckCollisionWithLand(Gear: PGear); inline; + +function MakeHedgehogsStep(Gear: PGear) : boolean; + +var doStepHandlers: array[TGearType] of TGearStepProcedure; + + +implementation +uses uFloat, uSound, uCollisions, uUtils, uConsts, uVisualGears, uAIMisc, + uVariables, uLandGraphics, uScript, uStats, uCaptions, uTeams, uStore, + uLocale, uTextures, uRenderUtils, uRandom, SDLh, uDebug, uGears, + uGearsList, Math; + +procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; +begin + doMakeExplosion(X, Y, Radius, AttackingHog, Mask, $FFFFFFFF); +end; + +procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); +var Gear: PGear; + dmg, dmgBase: LongInt; + fX, fY, tdX, tdY: hwFloat; + vg: PVisualGear; + i, cnt: LongInt; +begin +if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')'); +if Radius > 25 then KickFlakes(Radius, X, Y); + +if ((Mask and EXPLNoGfx) = 0) then + begin + vg:= nil; + if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion) + else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion); + if vg <> nil then + vg^.Tint:= Tint; + end; +if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); + +(*if (Mask and EXPLAllDamageInRadius) = 0 then + dmgRadius:= Radius shl 1 +else + dmgRadius:= Radius; +dmgBase:= dmgRadius + cHHRadius div 2;*) +dmgBase:= Radius shl 1 + cHHRadius div 2; +fX:= int2hwFloat(X); +fY:= int2hwFloat(Y); +Gear:= GearsList; +while Gear <> nil do + begin + dmg:= 0; + //dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); + //if (dmg > 1) and + if (Gear^.State and gstNoDamage) = 0 then + begin + case Gear^.Kind of + gtHedgehog, + gtMine, + gtBall, + gtMelonPiece, + gtGrenade, + gtClusterBomb, + // gtCluster, too game breaking I think + gtSMine, + gtCase, + gtTarget, + gtFlame, + gtKnife, + gtExplosives, + gtStructure: begin +// Run the calcs only once we know we have a type that will need damage + tdX:= Gear^.X-fX; + tdY:= Gear^.Y-fY; + if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then + dmg:= dmgBase - hwRound(Distance(tdX, tdY)); + if dmg > 1 then + begin + dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); + //AddFileLog('Damage: ' + inttostr(dmg)); + if (Mask and EXPLNoDamage) = 0 then + begin + if not Gear^.Invulnerable then + ApplyDamage(Gear, AttackingHog, dmg, dsExplosion) + else + Gear^.State:= Gear^.State or gstWinner; + end; + if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then + begin + DeleteCI(Gear); + Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, tdX)/(Gear^.Density/_3); + Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, tdY)/(Gear^.Density/_3); + + Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); + if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision); + if not Gear^.Invulnerable then + Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); + Gear^.Active:= true; + if Gear^.Kind <> gtFlame then FollowGear:= Gear + end; + if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) then + Gear^.Hedgehog^.Effects[hePoisoned] := 1; + end; + + end; + gtGrave: begin +// Run the calcs only once we know we have a type that will need damage + tdX:= Gear^.X-fX; + tdY:= Gear^.Y-fY; + if LongInt(tdX.Round + tdY.Round + 2) < dmgBase then + dmg:= dmgBase - hwRound(Distance(tdX, tdY)); + if dmg > 1 then + begin + dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); + Gear^.dY:= - _0_004 * dmg; + Gear^.Active:= true + end + end; + end; + end; + Gear:= Gear^.NextGear + end; + +if (Mask and EXPLDontDraw) = 0 then + if (GameFlags and gfSolidLand) = 0 then + begin + cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk + if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then + for i:= 0 to cnt do + AddVisualGear(X, Y, vgtChunk) + end; + +uAIMisc.AwareOfExplosion(0, 0, 0) +end; + +function ModifyDamage(dmg: Longword; Gear: PGear): Longword; +var i: hwFloat; +begin +(* Invulnerability cannot be placed in here due to still needing kicks + Not without a new damage machine. + King check should be in here instead of ApplyDamage since Tiy wants them kicked less +*) +i:= _1; +if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then + i:= _1_5; +if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King) then + ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) +else + ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) +end; + +procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); +var s: shortstring; + vampDmg, tmpDmg, i: Longword; + vg: PVisualGear; +begin + if Damage = 0 then + exit; // nothing to apply + + if (Gear^.Kind = gtHedgehog) then + begin + Gear^.LastDamage := AttackerHog; + + Gear^.Hedgehog^.Team^.Clan^.Flawless:= false; + HHHurt(Gear^.Hedgehog, Source); + AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, Gear^.Hedgehog^.Team^.Clan^.Color); + tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); + if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then + begin + if cVampiric then + begin + vampDmg:= hwRound(int2hwFloat(tmpDmg)*_0_8); + if vampDmg >= 1 then + begin + // was considering pulsing on attack, Tiy thinks it should be permanent while in play + //CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstVampiric; + inc(CurrentHedgehog^.Gear^.Health,vampDmg); + str(vampDmg, s); + s:= '+' + s; + AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); + RenderHealth(CurrentHedgehog^); + RecountTeamHealth(CurrentHedgehog^.Team); + i:= 0; + while i < vampDmg do + begin + vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtStraightShot); + if vg <> nil then + with vg^ do + begin + Tint:= $FF0000FF; + State:= ord(sprHealth) + end; + inc(i, 5); + end; + end + end; + if ((GameFlags and gfKarma) <> 0) and + ((GameFlags and gfInvulnerable) = 0) + and (not CurrentHedgehog^.Gear^.Invulnerable) then + begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid + inc(CurrentHedgehog^.Gear^.Karma, tmpDmg); + CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; + spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); + end; + uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); + end; + end + else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure + Gear^.Hedgehog:= AttackerHog; + inc(Gear^.Damage, Damage); + + ScriptCall('onGearDamage', Gear^.UID, Damage); +end; + +procedure spawnHealthTagForHH(HHGear: PGear; dmg: Longword); +var tag: PVisualGear; +begin +tag:= AddVisualGear(hwRound(HHGear^.X), hwRound(HHGear^.Y), vgtHealthTag, dmg); +if (tag <> nil) then + tag^.Hedgehog:= HHGear^.Hedgehog; // the tag needs the tag to determine the text color +AllInactive:= false; +HHGear^.Active:= true; +end; + +procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); +begin +if (Source = dsFall) or (Source = dsExplosion) then + case random(3) of + 0: PlaySoundV(sndOoff1, Hedgehog^.Team^.voicepack); + 1: PlaySoundV(sndOoff2, Hedgehog^.Team^.voicepack); + 2: PlaySoundV(sndOoff3, Hedgehog^.Team^.voicepack); + end +else if (Source = dsPoison) then + case random(2) of + 0: PlaySoundV(sndPoisonCough, Hedgehog^.Team^.voicepack); + 1: PlaySoundV(sndPoisonMoan, Hedgehog^.Team^.voicepack); + end +else + case random(4) of + 0: PlaySoundV(sndOw1, Hedgehog^.Team^.voicepack); + 1: PlaySoundV(sndOw2, Hedgehog^.Team^.voicepack); + 2: PlaySoundV(sndOw3, Hedgehog^.Team^.voicepack); + 3: PlaySoundV(sndOw4, Hedgehog^.Team^.voicepack); + end +end; + +procedure CheckHHDamage(Gear: PGear); +var + dmg: Longword; + i: LongInt; + particle: PVisualGear; +begin + if _0_4 < Gear^.dY then + begin + dmg := ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); + PlaySound(sndBump); + if dmg < 1 then + exit; + + for i:= min(12, (3 + dmg div 10)) downto 0 do + begin + particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); + if particle <> nil then + particle^.dX := particle^.dX + (Gear^.dX.QWordValue / 21474836480); + end; + + if (Gear^.Invulnerable) then + exit; + + //if _0_6 < Gear^.dY then + // PlaySound(sndOw4, Gear^.Hedgehog^.Team^.voicepack) + //else + // PlaySound(sndOw1, Gear^.Hedgehog^.Team^.voicepack); + + if Gear^.LastDamage <> nil then + ApplyDamage(Gear, Gear^.LastDamage, dmg, dsFall) + else + ApplyDamage(Gear, CurrentHedgehog, dmg, dsFall); + end +end; + + +procedure CalcRotationDirAngle(Gear: PGear); +var + dAngle: real; +begin + // Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 + //dAngle := (Gear^.dX.QWordValue + Gear^.dY.QWordValue) / $80000000; + dAngle := (Gear^.dX.Round + Gear^.dY.Round) / 2 + (Gear^.dX.Frac/$100000000+Gear^.dY.Frac/$100000000); + if not Gear^.dX.isNegative then + Gear^.DirAngle := Gear^.DirAngle + dAngle + else + Gear^.DirAngle := Gear^.DirAngle - dAngle; + + if Gear^.DirAngle < 0 then + Gear^.DirAngle := Gear^.DirAngle + 360 + else if 360 < Gear^.DirAngle then + Gear^.DirAngle := Gear^.DirAngle - 360 +end; + +function CheckGearDrowning(Gear: PGear): boolean; +var + skipSpeed, skipAngle, skipDecay: hwFloat; + i, maxDrops, X, Y: LongInt; + vdX, vdY: real; + particle, splash: PVisualGear; + isSubmersible: boolean; +begin + // probably needs tweaking. might need to be in a case statement based upon gear type + Y:= hwRound(Gear^.Y); + if cWaterLine < Y + Gear^.Radius then + begin + if Gear^.State and gstInvisible <> 0 then + begin + if Gear^.Kind = gtGenericFaller then + begin + Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX); + Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY); + Gear^.dX:= _90-(GetRandomf*_360); + Gear^.dY:= _90-(GetRandomf*_360) + end + else DeleteGear(Gear); + exit + end; + isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); + skipSpeed := _0_25; + skipAngle := _1_9; + skipDecay := _0_87; + X:= hwRound(Gear^.X); + vdX:= hwFloat2Float(Gear^.dX); + vdY:= hwFloat2Float(Gear^.dY); + // this could perhaps be a tiny bit higher. + if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) + and (hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then + begin + Gear^.dY.isNegative := true; + Gear^.dY := Gear^.dY * skipDecay; + Gear^.dX := Gear^.dX * skipDecay; + CheckGearDrowning := false; + PlaySound(sndSkip) + end + else + begin + if not isSubmersible then + begin + CheckGearDrowning := true; + Gear^.State := gstDrowning; + Gear^.RenderTimer := false; + if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) + and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then + if Gear^.Kind = gtHedgehog then + begin + if Gear^.Hedgehog^.Effects[heResurrectable] <> 0 then + ResurrectHedgehog(Gear) + else + begin + Gear^.doStep := @doStepDrowningGear; + Gear^.State := Gear^.State and (not gstHHDriven); + AddCaption(Format(GetEventString(eidDrowned), Gear^.Hedgehog^.Name), cWhiteColor, capgrpMessage); + end + end + else + Gear^.doStep := @doStepDrowningGear; + if Gear^.Kind = gtFlake then + exit // skip splashes + end; + if ((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) + or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) + and (CurAmmoGear^.dY < _0_01))) then + if Gear^.Density * Gear^.dY > _1 then + PlaySound(sndSplash) + else if Gear^.Density * Gear^.dY > _0_5 then + PlaySound(sndSkip) + else + PlaySound(sndDroplet2); + end; + + if ((cReducedQuality and rqPlainSplash) = 0) + and (((not isSubmersible) and (Y < cWaterLine + 64 + Gear^.Radius)) + or (isSubmersible and (Y < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) + and (CurAmmoGear^.dY < _0_01)))) then + begin + splash:= AddVisualGear(X, cWaterLine, vgtSplash); + if splash <> nil then + with splash^ do + begin + Scale:= hwFloat2Float(Gear^.Density / _3 * Gear^.dY); + if Scale > 1 then Scale:= power(Scale,0.3333) + else Scale:= Scale + ((1-Scale) / 2); + if Scale > 1 then Timer:= round(min(Scale*0.0005/cGravityf,4)) + else Timer:= 1; + // Low Gravity + FrameTicks:= FrameTicks*Timer; + end; + + maxDrops := (hwRound(Gear^.Density) * 3) div 2 + round(vdX * hwRound(Gear^.Density) * 6) + round(vdY * hwRound(Gear^.Density) * 6); + for i:= max(maxDrops div 3, min(32, Random(maxDrops))) downto 0 do + begin + particle := AddVisualGear(X - 3 + Random(7), cWaterLine, vgtDroplet); + if particle <> nil then + with particle^ do + begin + dX := dX - vdX / 10; + dY := dY - vdY / 5; + if splash <> nil then + begin + if splash^.Scale > 1 then + begin + dX:= dX * power(splash^.Scale,0.3333); // tone down the droplet height further + dY:= dY * power(splash^.Scale, 0.3333) + end + else + begin + dX:= dX * splash^.Scale; + dY:= dY * splash^.Scale + end + end + end + end + end; + if isSubmersible and (CurAmmoGear^.Pos = 0) then + CurAmmoGear^.Pos := 1000 + end + else + CheckGearDrowning := false; +end; + + +procedure ResurrectHedgehog(gear: PGear); +var tempTeam : PTeam; + sparkles: PVisualGear; + gX, gY: LongInt; +begin + if (Gear^.LastDamage <> nil) then + uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true) + else + uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true); + AttackBar:= 0; + gear^.dX := _0; + gear^.dY := _0; + gear^.Damage := 0; + gear^.Health := gear^.Hedgehog^.InitialHealth; + gear^.Hedgehog^.Effects[hePoisoned] := 0; + if (CurrentHedgehog^.Effects[heResurrectable] = 0) or ((CurrentHedgehog^.Effects[heResurrectable] <> 0) + and (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan)) then + with CurrentHedgehog^ do + begin + inc(Team^.stats.AIKills); + FreeTexture(Team^.AIKillsTex); + Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16); + end; + tempTeam := gear^.Hedgehog^.Team; + DeleteCI(gear); + gX := hwRound(gear^.X); + gY := hwRound(gear^.Y); + // might need more sparkles for a column + sparkles:= AddVisualGear(gX, gY, vgtDust, 1); + if sparkles <> nil then + begin + sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF; + //sparkles^.Angle:= random(360); + end; + FindPlace(gear, false, 0, LAND_WIDTH, true); + if gear <> nil then + begin + AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion); + PlaySound(sndWarp); + RenderHealth(gear^.Hedgehog^); + ScriptCall('onGearResurrect', gear^.uid); + gear^.State := gstWait; + end; + RecountTeamHealth(tempTeam); +end; + +function CountNonZeroz(x, y, r, c: LongInt; mask: LongWord): LongInt; +var i: LongInt; + count: LongInt = 0; +begin + if (y and LAND_HEIGHT_MASK) = 0 then + for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do + if Land[y, i] and mask <> 0 then + begin + inc(count); + if count = c then + begin + CountNonZeroz:= count; + exit + end; + end; + CountNonZeroz:= count; +end; + + +function NoGearsToAvoid(mX, mY: LongInt; rX, rY: LongInt): boolean; +var t: PGear; +begin +NoGearsToAvoid:= false; +t:= GearsList; +rX:= sqr(rX); +rY:= sqr(rY); +while t <> nil do + begin + if t^.Kind <= gtExplosives then + if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then + exit; + t:= t^.NextGear + end; +NoGearsToAvoid:= true +end; + +procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); inline; +begin + FindPlace(Gear, withFall, Left, Right, false); +end; + +procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt; skipProximity: boolean); +var x: LongInt; + y, sy: LongInt; + ar: array[0..511] of TPoint; + ar2: array[0..1023] of TPoint; + cnt, cnt2: Longword; + delta: LongInt; + ignoreNearObjects, ignoreOverlap, tryAgain: boolean; +begin +ignoreNearObjects:= false; // try not skipping proximity at first +ignoreOverlap:= false; // this not only skips proximity, but allows overlapping objects (barrels, mines, hogs, crates). Saving it for a 3rd pass. With this active, winning AI Survival goes back to virtual impossibility +tryAgain:= true; +while tryAgain do + begin + delta:= 250; + cnt2:= 0; + repeat + x:= Left + LongInt(GetRandom(Delta)); + repeat + inc(x, Delta); + cnt:= 0; + y:= min(1024, topY) - 2 * Gear^.Radius; + while y < cWaterLine do + begin + repeat + inc(y, 2); + until (y >= cWaterLine) or + (not ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) or + (ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) = 0)); + + sy:= y; + + repeat + inc(y); + until (y >= cWaterLine) or + (not ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) <> 0)) or + (ignoreOverlap and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FF00) <> 0)); + + if (y - sy > Gear^.Radius * 2) + and (((Gear^.Kind = gtExplosives) + and (y < cWaterLine) + and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 60, 60)) + and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1, $FFFF) > Gear^.Radius)) + or + ((Gear^.Kind <> gtExplosives) + and (y < cWaterLine) + and (ignoreNearObjects or NoGearsToAvoid(x, y - Gear^.Radius, 110, 110)) + )) then + begin + ar[cnt].X:= x; + if withFall then + ar[cnt].Y:= sy + Gear^.Radius + else + ar[cnt].Y:= y - Gear^.Radius; + inc(cnt) + end; + + inc(y, 10) + end; + + if cnt > 0 then + with ar[GetRandom(cnt)] do + begin + ar2[cnt2].x:= x; + ar2[cnt2].y:= y; + inc(cnt2) + end + until (x + Delta > Right); + + dec(Delta, 60) + until (cnt2 > 0) or (Delta < 70); + // if either of these has not been tried, do another pass + if (cnt2 = 0) and skipProximity and (not ignoreOverlap) then + tryAgain:= true + else tryAgain:= false; + if ignoreNearObjects then ignoreOverlap:= true; + ignoreNearObjects:= true; + end; + +if cnt2 > 0 then + with ar2[GetRandom(cnt2)] do + begin + Gear^.X:= int2hwFloat(x); + Gear^.Y:= int2hwFloat(y); + AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); + end + else + begin + OutError('Can''t find place for Gear', false); + if Gear^.Kind = gtHedgehog then + Gear^.Hedgehog^.Effects[heResurrectable] := 0; + DeleteGear(Gear); + Gear:= nil + end +end; + +function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; +var t: PGear; +begin +t:= GearsList; +rX:= sqr(rX); +rY:= sqr(rY); + +while t <> nil do + begin + if (t <> Gear) and (t^.Kind = Kind) then + if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then + begin + CheckGearNear:= t; + exit; + end; + t:= t^.NextGear + end; + +CheckGearNear:= nil +end; + +procedure CheckCollision(Gear: PGear); inline; +begin + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) + or (TestCollisionYwithGear(Gear, hwSign(Gear^.dY)) <> 0) then + Gear^.State := Gear^.State or gstCollision + else + Gear^.State := Gear^.State and (not gstCollision) +end; + +procedure CheckCollisionWithLand(Gear: PGear); inline; +begin + if TestCollisionX(Gear, hwSign(Gear^.dX)) + or TestCollisionY(Gear, hwSign(Gear^.dY)) then + Gear^.State := Gear^.State or gstCollision + else + Gear^.State := Gear^.State and (not gstCollision) +end; + +function MakeHedgehogsStep(Gear: PGear) : boolean; +begin + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then if (TestCollisionYwithGear(Gear, -1) = 0) then + begin + Gear^.Y:= Gear^.Y - _1; + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then + Gear^.Y:= Gear^.Y + _6 + end else Gear^.Y:= Gear^.Y + _5 else + end else Gear^.Y:= Gear^.Y + _4 else + end else Gear^.Y:= Gear^.Y + _3 else + end else Gear^.Y:= Gear^.Y + _2 else + end else Gear^.Y:= Gear^.Y + _1 + end; + + if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then + begin + Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX); + MakeHedgehogsStep:= true + end else + MakeHedgehogsStep:= false; + + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y + _1; + if TestCollisionYwithGear(Gear, 1) = 0 then + begin + Gear^.Y:= Gear^.Y - _6; + Gear^.dY:= _0; + Gear^.State:= Gear^.State or gstMoving; + exit + end; + end + end + end + end + end + end; +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uIO.pas --- a/hedgewars/uIO.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uIO.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ procedure initModule; procedure freeModule; +procedure InitIPC; procedure SendIPC(s: shortstring); procedure SendIPCXY(cmd: char; X, Y: SmallInt); procedure SendIPCRaw(p: pointer; len: Longword); @@ -34,8 +35,6 @@ procedure SendStat(sit: TStatInfoType; s: shortstring); procedure IPCWaitPongEvent; procedure IPCCheckSock; -procedure InitIPC; -procedure CloseIPC; procedure NetGetNextCmd; procedure doPut(putX, putY: LongInt; fromAI: boolean); @@ -56,6 +55,7 @@ var IPCSock: PTCPSocket; fds: PSDLNet_SocketSet; isPonged: boolean; + SocketString: shortstring; headcmd: PCmd; lastcmd: PCmd; @@ -71,14 +71,15 @@ command^.str:= str; if command^.cmd <> 'F' then dec(command^.len, 2); // cut timestamp if headcmd = nil then - begin - headcmd:= command; - lastcmd:= command - end else - begin - lastcmd^.Next:= command; - lastcmd:= command - end; + begin + headcmd:= command; + lastcmd:= command + end +else + begin + lastcmd^.Next:= command; + lastcmd:= command + end; AddCmd:= command; end; @@ -88,7 +89,8 @@ TryDo(headcmd <> nil, 'Engine bug: headcmd = nil', true); tmp:= headcmd; headcmd:= headcmd^.Next; -if headcmd = nil then lastcmd:= nil; +if headcmd = nil then + lastcmd:= nil; dispose(tmp) end; @@ -102,26 +104,19 @@ WriteLnToConsole(msgOK); WriteToConsole('Establishing IPC connection to tcp 127.0.0.1:' + IntToStr(ipcPort) + ' '); {$HINTS OFF} - SDLTry(SDLNet_ResolveHost(ipaddr, '127.0.0.1', ipcPort) = 0, true); + SDLTry(SDLNet_ResolveHost(ipaddr, PChar('127.0.0.1'), ipcPort) = 0, true); {$HINTS ON} IPCSock:= SDLNet_TCP_Open(ipaddr); SDLTry(IPCSock <> nil, true); WriteLnToConsole(msgOK) end; -procedure CloseIPC; -begin - SDLNet_FreeSocketSet(fds); - SDLNet_TCP_Close(IPCSock); - SDLNet_Quit(); -end; - procedure ParseIPCCommand(s: shortstring); var loTicks: Word; begin case s[1] of '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end; - '?': SendIPC('!'); + '?': SendIPC(_S'!'); 'e': ParseCommand(copy(s, 2, Length(s) - 1), true); 'E': OutError(copy(s, 2, Length(s) - 1), true); 'W': OutError(copy(s, 2, Length(s) - 1), false); @@ -131,7 +126,12 @@ 'D': GameType:= gmtDemo; 'N': GameType:= gmtNet; 'S': GameType:= gmtSave; + 'V': GameType:= gmtRecord; else OutError(errmsgIncorrectUse + ' IPC "T" :' + s[2], true) end; + 'V': begin + if s[2] = '.' then + ParseCommand('campvar ' + copy(s, 3, length(s) - 2), true); + end else loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]); AddCmd(loTicks, s); @@ -140,30 +140,30 @@ end; procedure IPCCheckSock; -const ss: shortstring = ''; var i: LongInt; - buf: array[0..255] of byte; - s: shortstring absolute buf; + s: shortstring; begin -if IPCSock = nil then - exit; + if IPCSock = nil then + exit; -fds^.numsockets:= 0; -SDLNet_AddSocket(fds, IPCSock); + fds^.numsockets:= 0; + SDLNet_AddSocket(fds, IPCSock); -while SDLNet_CheckSockets(fds, 0) > 0 do + while SDLNet_CheckSockets(fds, 0) > 0 do begin - i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); - if i > 0 then + i:= SDLNet_TCP_Recv(IPCSock, @s[1], 255 - Length(SocketString)); + if i > 0 then begin - buf[0]:= i; - ss:= ss + s; - while (Length(ss) > 1) and (Length(ss) > byte(ss[1])) do + s[0]:= char(i); + SocketString:= SocketString + s; + while (Length(SocketString) > 1) and (Length(SocketString) > byte(SocketString[1])) do begin - ParseIPCCommand(copy(ss, 2, byte(ss[1]))); - Delete(ss, 1, Succ(byte(ss[1]))) + ParseIPCCommand(copy(SocketString, 2, byte(SocketString[1]))); + Delete(SocketString, 1, Succ(byte(SocketString[1]))) end - end else OutError('IPC connection lost', true) + end + else + OutError('IPC connection lost', true) end; end; @@ -171,8 +171,7 @@ var f: file; ss: shortstring = ''; i: LongInt; - buf: array[0..255] of byte; - s: shortstring absolute buf; + s: shortstring; begin // set RDNLY on file open @@ -184,12 +183,12 @@ tryDo(IOResult = 0, 'Error opening file ' + fileName, true); i:= 0; // avoid compiler hints -buf[0]:= 0; +s[0]:= #0; repeat - BlockRead(f, buf[1], 255 - Length(ss), i); + BlockRead(f, s[1], 255 - Length(ss), i); if i > 0 then begin - buf[0]:= i; + s[0]:= char(i); ss:= ss + s; while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do begin @@ -204,7 +203,7 @@ end; procedure SendStat(sit: TStatInfoType; s: shortstring); -const stc: array [TStatInfoType] of char = 'rDkKHTPsSB'; +const stc: array [TStatInfoType] of char = ('r', 'D', 'k', 'K', 'H', 'T', 'P', 's', 'S', 'B'); var buf: shortstring; begin buf:= 'i' + stc[sit] + s; @@ -217,7 +216,9 @@ if IPCSock <> nil then begin SendEmptyPacketTicks:= 0; - if s[0]>#251 then s[0]:= #251; + if s[0]>#251 then + s[0]:= #251; + SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); AddFileLog('[IPC out] '+ s[1]); inc(s[0], 2); @@ -228,9 +229,9 @@ procedure SendIPCRaw(p: pointer; len: Longword); begin if IPCSock <> nil then - begin - SDLNet_TCP_Send(IPCSock, p, len) - end + begin + SDLNet_TCP_Send(IPCSock, p, len) + end end; procedure SendIPCXY(cmd: char; X, Y: SmallInt); @@ -247,15 +248,15 @@ begin isPonged:= false; repeat - IPCCheckSock; - SDL_Delay(1) + IPCCheckSock; + SDL_Delay(1) until isPonged end; procedure SendIPCAndWaitReply(s: shortstring); begin SendIPC(s); -SendIPC('?'); +SendIPC(_S'?'); IPCWaitPongEvent end; @@ -263,7 +264,7 @@ begin inc(SendEmptyPacketTicks, Lag); if (SendEmptyPacketTicks >= cSendEmptyPacketTime) then - SendIPC('+') + SendIPC(_S'+') end; procedure NetGetNextCmd; @@ -307,28 +308,29 @@ 'c': begin s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); ParseCommand('gencmd ' + s, true); - end; + end; 's': begin s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); ParseCommand('chatmsg ' + s, true); WriteLnToConsole(s) - end; + end; 'b': begin s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); - ParseCommand('chatmsg '#4 + s, true); + ParseCommand('chatmsg ' + #4 + s, true); WriteLnToConsole(s) - end; + end; // TODO: deprecate 'F' 'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); 'N': begin tmpflag:= false; + lastTurnChecksum:= SDLNet_Read32(@headcmd^.str[2]); AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime)) - end; + end; 'p': begin x16:= SDLNet_Read16(@(headcmd^.X)); y16:= SDLNet_Read16(@(headcmd^.Y)); doPut(x16, y16, false) - end; + end; 'P': begin // these are equations solved for CursorPoint // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx; @@ -338,14 +340,16 @@ CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx; CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy end - end; + end; 'w': ParseCommand('setweap ' + headcmd^.str[2], true); 't': ParseCommand('taunt ' + headcmd^.str[2], true); 'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true); - #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) else - OutError('Unexpected protocol command: ' + headcmd^.cmd, True) + if (headcmd^.cmd >= #128) and (headcmd^.cmd <= char(128 + cMaxSlotIndex)) then + ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) + else + OutError('Unexpected protocol command: ' + headcmd^.cmd, True) end; RemoveCmd end; @@ -369,7 +373,8 @@ procedure doPut(putX, putY: LongInt; fromAI: boolean); begin -if CheckNoTeamOrHH or isPaused then exit; +if CheckNoTeamOrHH or isPaused then + exit; bShowFinger:= false; if not CurrentTeam^.ExtDriven and bShowAmmoMenu then begin @@ -388,7 +393,8 @@ begin TargetPoint.X:= putX; TargetPoint.Y:= putY - end else + end + else begin TargetPoint.X:= CursorPoint.X - WorldDx; TargetPoint.Y:= cScreenHeight - CursorPoint.Y - WorldDy; @@ -401,7 +407,7 @@ TargetPoint.Y:= putY end; AddFileLog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y)); - State:= State and not gstHHChooseTarget; + State:= State and (not gstHHChooseTarget); if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then Message:= Message or (gmAttack and InputMask); end @@ -412,21 +418,25 @@ procedure initModule; begin - RegisterVariable('fatal', vtCommand, @chFatalError, true ); + RegisterVariable('fatal', @chFatalError, true ); IPCSock:= nil; headcmd:= nil; lastcmd:= nil; - isPonged:= false; // was const - + isPonged:= false; + SocketString:= ''; + hiTicks:= 0; SendEmptyPacketTicks:= 0; end; procedure freeModule; begin -while headcmd <> nil do RemoveCmd + while headcmd <> nil do RemoveCmd; + SDLNet_FreeSocketSet(fds); + SDLNet_TCP_Close(IPCSock); + SDLNet_Quit(); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uInputHandler.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uInputHandler.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,440 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + +{$INCLUDE "options.inc"} + +unit uInputHandler; +interface +uses SDLh, uTypes; + +procedure initModule; +procedure freeModule; + +function KeyNameToCode(name: shortstring): LongInt; inline; +function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; +//procedure MaskModifier(var code: LongInt; modifier: LongWord); +procedure MaskModifier(Modifier: shortstring; var code: LongInt); +procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); +procedure ProcessKey(event: TSDL_KeyboardEvent); inline; +procedure ProcessKey(code: LongInt; KeyDown: boolean); + +procedure ResetKbd; +procedure FreezeEnterKey; +procedure InitKbdKeyTable; + +procedure SetBinds(var binds: TBinds); +procedure SetDefaultBinds; + +procedure ControllerInit; +procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); +procedure ControllerHatEvent(joy, hat, value: Byte); +procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); + +implementation +uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; + +const + LSHIFT = $0200; + RSHIFT = $0400; + LALT = $0800; + RALT = $1000; + LCTRL = $2000; + RCTRL = $4000; + +var tkbd: array[0..cKbdMaxIndex] of boolean; + quitKeyCode: Byte; + KeyNames: array [0..cKeyMaxIndex] of string[15]; + CurrentBinds: TBinds; + +function KeyNameToCode(name: shortstring): LongInt; inline; +begin + KeyNameToCode:= KeyNameToCode(name, ''); +end; + +function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt; +var code: LongInt; +begin + name:= LowerCase(name); + code:= cKeyMaxIndex; + while (code > 0) and (KeyNames[code] <> name) do dec(code); + + MaskModifier(Modifier, code); + KeyNameToCode:= code; +end; +(* +procedure MaskModifier(var code: LongInt; Modifier: LongWord); +begin + if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT; + if(Modifier and KMOD_RSHIFT) <> 0 then code:= code or LSHIFT; + if(Modifier and KMOD_LALT) <> 0 then code:= code or LALT; + if(Modifier and KMOD_RALT) <> 0 then code:= code or LALT; + if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL; + if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL; +end; +*) +procedure MaskModifier(Modifier: shortstring; var code: LongInt); +var mod_ : shortstring; + ModifierCount, i: LongInt; +begin +if Modifier = '' then exit; +ModifierCount:= 0; + +for i:= 1 to Length(Modifier) do + if(Modifier[i] = ':') then inc(ModifierCount); + +SplitByChar(Modifier, mod_, ':');//remove the first mod: part +Modifier:= mod_; +for i:= 0 to ModifierCount do + begin + mod_:= ''; + SplitByChar(Modifier, mod_, ':'); + if (Modifier = 'lshift') then code:= code or LSHIFT; + if (Modifier = 'rshift') then code:= code or RSHIFT; + if (Modifier = 'lalt') then code:= code or LALT; + if (Modifier = 'ralt') then code:= code or RALT; + if (Modifier = 'lctrl') or (mod_ = 'lmeta') then code:= code or LCTRL; + if (Modifier = 'rctrl') or (mod_ = 'rmeta') then code:= code or RCTRL; + Modifier:= mod_; + end; +end; + +procedure ProcessKey(code: LongInt; KeyDown: boolean); +var + Trusted: boolean; + s : string; +begin +if not(tkbd[code] xor KeyDown) then exit; +tkbd[code]:= KeyDown; + +hideAmmoMenu:= false; +Trusted:= (CurrentTeam <> nil) + and (not CurrentTeam^.ExtDriven) + and (CurrentHedgehog^.BotLevel = 0); + +// ctrl/cmd + q to close engine and frontend +if(KeyDown and (code = quitKeyCode)) then + begin +{$IFDEF DARWIN} + if tkbd[KeyNameToCode('left_meta')] or tkbd[KeyNameToCode('right_meta')] then +{$ELSE} + if tkbd[KeyNameToCode('left_ctrl')] or tkbd[KeyNameToCode('right_ctrl')] then +{$ENDIF} + ParseCommand('halt', true); + end; + +if CurrentBinds[code][0] <> #0 then + begin + if (code > 3) and KeyDown and (not ((CurrentBinds[code] = 'put')) or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true; + + if KeyDown then + begin + ParseCommand(CurrentBinds[code], Trusted); + if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then + ParseCommand('gencmd R', true) + end + else if (CurrentBinds[code][1] = '+') then + begin + s:= CurrentBinds[code]; + s[1]:= '-'; + ParseCommand(s, Trusted); + if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then + ParseCommand('gencmd R', true) + end; + end +end; + +procedure ProcessKey(event: TSDL_KeyboardEvent); inline; +var code: LongInt; +begin + code:= event.keysym.sym; + //MaskModifier(code, event.keysym.modifier); + ProcessKey(code, event.type_ = SDL_KEYDOWN); +end; + +procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean); +begin +case event.button of + SDL_BUTTON_LEFT: + ProcessKey(KeyNameToCode('mousel'), ButtonDown); + SDL_BUTTON_MIDDLE: + ProcessKey(KeyNameToCode('mousem'), ButtonDown); + SDL_BUTTON_RIGHT: + ProcessKey(KeyNameToCode('mouser'), ButtonDown); + SDL_BUTTON_WHEELDOWN: + ProcessKey(KeyNameToCode('wheeldown'), ButtonDown); + SDL_BUTTON_WHEELUP: + ProcessKey(KeyNameToCode('wheelup'), ButtonDown); + end; +end; + +procedure ResetKbd; +var t: LongInt; +begin +for t:= 0 to cKbdMaxIndex do + if tkbd[t] then + ProcessKey(t, False); +end; + +procedure InitKbdKeyTable; +var i, j, k, t: LongInt; + s: string[15]; +begin +//TODO in sdl13 this overrides some values (A and B) change indices to some other values at the back perhaps? +KeyNames[1]:= 'mousel'; +KeyNames[2]:= 'mousem'; +KeyNames[3]:= 'mouser'; +KeyNames[4]:= 'wheelup'; +KeyNames[5]:= 'wheeldown'; + +for i:= 6 to cKeyMaxIndex do + begin + s:= shortstring(sdl_getkeyname(i)); + //WriteLnToConsole(IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex)); + if s = 'unknown key' then KeyNames[i]:= '' + else + begin + for t:= 1 to Length(s) do + if s[t] = ' ' then + s[t]:= '_'; + KeyNames[i]:= LowerCase(s) + end; + end; + +quitKeyCode:= KeyNameToCode(_S'q'); + +// get the size of keyboard array +SDL_GetKeyState(@k); + +// Controller(s) +for j:= 0 to Pred(ControllerNumControllers) do + begin + for i:= 0 to Pred(ControllerNumAxes[j]) do + begin + keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u'; + keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd'; + inc(k, 2); + end; + for i:= 0 to Pred(ControllerNumHats[j]) do + begin + keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u'; + keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r'; + keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd'; + keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l'; + inc(k, 4); + end; + for i:= 0 to Pred(ControllerNumButtons[j]) do + begin + keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i); + inc(k, 1); + end; + end; + +DefaultBinds[KeyNameToCode('escape')]:= 'quit'; +DefaultBinds[KeyNameToCode('grave')]:= 'history'; +DefaultBinds[KeyNameToCode('delete')]:= 'rotmask'; + +//numpad +//DefaultBinds[265]:= '+volup'; +//DefaultBinds[256]:= '+voldown'; + +DefaultBinds[KeyNameToCode(_S'0')]:= '+volup'; +DefaultBinds[KeyNameToCode(_S'9')]:= '+voldown'; +DefaultBinds[KeyNameToCode(_S'8')]:= 'mute'; +DefaultBinds[KeyNameToCode(_S'c')]:= 'capture'; +DefaultBinds[KeyNameToCode(_S'r')]:= 'record'; +DefaultBinds[KeyNameToCode(_S'h')]:= 'findhh'; +DefaultBinds[KeyNameToCode(_S'p')]:= 'pause'; +DefaultBinds[KeyNameToCode(_S's')]:= '+speedup'; +DefaultBinds[KeyNameToCode(_S't')]:= 'chat'; +DefaultBinds[KeyNameToCode(_S'y')]:= 'confirm'; + +DefaultBinds[KeyNameToCode('mousem')]:= 'zoomreset'; +DefaultBinds[KeyNameToCode('wheelup')]:= 'zoomin'; +DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomout'; + +DefaultBinds[KeyNameToCode('f12')]:= 'fullscr'; + + +DefaultBinds[KeyNameToCode('mousel')]:= '/put'; +DefaultBinds[KeyNameToCode('mouser')]:= 'ammomenu'; +DefaultBinds[KeyNameToCode('backspace')]:= 'hjump'; +DefaultBinds[KeyNameToCode('tab')]:= 'switch'; +DefaultBinds[KeyNameToCode('return')]:= 'ljump'; +DefaultBinds[KeyNameToCode('space')]:= '+attack'; +DefaultBinds[KeyNameToCode('up')]:= '+up'; +DefaultBinds[KeyNameToCode('down')]:= '+down'; +DefaultBinds[KeyNameToCode('left')]:= '+left'; +DefaultBinds[KeyNameToCode('right')]:= '+right'; +DefaultBinds[KeyNameToCode('left_shift')]:= '+precise'; + + +DefaultBinds[KeyNameToCode('j0a0u')]:= '+left'; +DefaultBinds[KeyNameToCode('j0a0d')]:= '+right'; +DefaultBinds[KeyNameToCode('j0a1u')]:= '+up'; +DefaultBinds[KeyNameToCode('j0a1d')]:= '+down'; +for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i); +for i:= 1 to 5 do DefaultBinds[KeyNameToCode(IntToStr(i))]:= 'timer '+IntToStr(i); + +SetDefaultBinds(); +end; + +procedure SetBinds(var binds: TBinds); +{$IFNDEF MOBILE} +var + t: LongInt; +{$ENDIF} +begin +{$IFDEF MOBILE} + binds:= binds; // avoid hint + CurrentBinds:= DefaultBinds; +{$ELSE} +for t:= 0 to cKbdMaxIndex do + if (CurrentBinds[t] <> binds[t]) and tkbd[t] then + ProcessKey(t, False); + + CurrentBinds:= binds; +{$ENDIF} +end; + +procedure SetDefaultBinds; +begin + CurrentBinds:= DefaultBinds; +end; + +procedure FreezeEnterKey; +begin + tkbd[3]:= True; + tkbd[13]:= True; + tkbd[27]:= True; + tkbd[271]:= True; +end; + +var Controller: array [0..5] of PSDL_Joystick; + +procedure ControllerInit; +var i, j: Integer; +begin +ControllerEnabled:= 0; +{$IFDEF IPHONE} +exit; // joystick subsystem disabled on iPhone +{$ENDIF} + +SDL_InitSubSystem(SDL_INIT_JOYSTICK); +ControllerNumControllers:= SDL_NumJoysticks(); + +if ControllerNumControllers > 6 then + ControllerNumControllers:= 6; + +WriteLnToConsole('Number of game controllers: ' + IntToStr(ControllerNumControllers)); + +if ControllerNumControllers > 0 then + begin + for j:= 0 to pred(ControllerNumControllers) do + begin + WriteLnToConsole('Using game controller: ' + shortstring(SDL_JoystickName(j))); + Controller[j]:= SDL_JoystickOpen(j); + if Controller[j] = nil then + WriteLnToConsole('* Failed to open game controller!') + else + begin + ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]); + //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]); + ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]); + ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]); + WriteLnToConsole('* Number of axes: ' + IntToStr(ControllerNumAxes[j])); + //WriteLnToConsole('* Number of balls: ' + IntToStr(ControllerNumBalls[j])); + WriteLnToConsole('* Number of hats: ' + IntToStr(ControllerNumHats[j])); + WriteLnToConsole('* Number of buttons: ' + IntToStr(ControllerNumButtons[j])); + ControllerEnabled:= 1; + + if ControllerNumAxes[j] > 20 then + ControllerNumAxes[j]:= 20; + //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; + + if ControllerNumHats[j] > 20 then + ControllerNumHats[j]:= 20; + + if ControllerNumButtons[j] > 20 then + ControllerNumButtons[j]:= 20; + + // reset all buttons/axes + for i:= 0 to pred(ControllerNumAxes[j]) do + ControllerAxes[j][i]:= 0; + (*for i:= 0 to pred(ControllerNumBalls[j]) do + begin + ControllerBalls[j][i][0]:= 0; + ControllerBalls[j][i][1]:= 0; + end;*) + for i:= 0 to pred(ControllerNumHats[j]) do + ControllerHats[j][i]:= SDL_HAT_CENTERED; + for i:= 0 to pred(ControllerNumButtons[j]) do + ControllerButtons[j][i]:= 0; + end; + end; + // enable event generation/controller updating + SDL_JoystickEventState(1); + end +else + WriteLnToConsole('Not using any game controller'); +end; + +procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); +var + k: LongInt; +begin + SDL_GetKeyState(@k); + k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); + ProcessKey(k + axis*2, value > 20000); + ProcessKey(k + (axis*2)+1, value < -20000); +end; + +procedure ControllerHatEvent(joy, hat, value: Byte); +var + k: LongInt; +begin + SDL_GetKeyState(@k); + k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); + ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 0, (value and SDL_HAT_UP) <> 0); + ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 1, (value and SDL_HAT_RIGHT)<> 0); + ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 2, (value and SDL_HAT_DOWN) <> 0); + ProcessKey(k + ControllerNumAxes[joy]*2 + hat*4 + 3, (value and SDL_HAT_LEFT) <> 0); +end; + +procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); +var + k: LongInt; +begin + SDL_GetKeyState(@k); + k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2); + ProcessKey(k + ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + button, pressed); +end; + +procedure initModule; +begin +end; + +procedure freeModule; +var j: LongInt; +begin + // close gamepad controllers + if ControllerEnabled > 0 then + for j:= 0 to pred(ControllerNumControllers) do + SDL_JoystickClose(Controller[j]); +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,516 +0,0 @@ -(* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - *) - -{$INCLUDE "options.inc"} - -unit uKeys; -interface -uses SDLh, uTypes; - -procedure initModule; -procedure freeModule; - -function KeyNameToCode(name: shortstring): word; -procedure ProcessKbd; -procedure ResetKbd; -procedure FreezeEnterKey; -procedure InitKbdKeyTable; - -procedure SetBinds(var binds: TBinds); -procedure SetDefaultBinds; - -procedure ControllerInit; -procedure ControllerClose; -procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); -procedure ControllerHatEvent(joy, hat, value: Byte); -procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); - -{$IFDEF IPHONEOS} -procedure setiPhoneBinds; -{$ENDIF} - -implementation -uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug; - -var tkbd, tkbdn: TKeyboardState; - KeyNames: array [0..cKeyMaxIndex] of string[15]; - -function KeyNameToCode(name: shortstring): word; -var code: Word; -begin - code:= cKeyMaxIndex; - while (code > 0) and (KeyNames[code] <> name) do dec(code); - KeyNameToCode:= code; -end; - - -procedure ProcessKbd; -var i, j, k: LongInt; - s: shortstring; - Trusted: boolean; -{$IFNDEF IPHONEOS}pkbd: PByteArray;{$ENDIF} -begin -hideAmmoMenu:= false; -Trusted:= (CurrentTeam <> nil) - and (not CurrentTeam^.ExtDriven) - and (CurrentHedgehog^.BotLevel = 0); - -// move cursor/camera -// TODO: Scale on screen dimensions and/or axis value (game controller)? -movecursor(5 * CursorMovementX, 5 * CursorMovementY); - -k:= SDL_GetMouseState(nil, nil); - -{$IFDEF IPHONEOS} -SDL_GetKeyState(@j); -{$ELSE} -pkbd:= SDL_GetKeyState(@j); -for i:= 6 to pred(j) do // first 6 will be overwritten - tkbdn[i]:= pkbd^[i]; -{$ENDIF} - -// mouse buttons -{$IFDEF DARWIN} -tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305])); -tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4); -{$ELSE} -tkbdn[1]:= (k and 1); -tkbdn[3]:= ((k shr 2) and 1); -{$ENDIF} -tkbdn[2]:= ((k shr 1) and 1); - -// mouse wheels -tkbdn[4]:= ord(wheelDown); -tkbdn[5]:= ord(wheelUp); -wheelUp:= false; -wheelDown:= false; - -{$IFDEF IPHONEOS} -setiPhoneBinds(); -{$ELSE} -// Controller(s) -k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it -for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; - if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; - tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; - tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; - tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - tkbdn[k]:= ControllerButtons[j][i]; - inc(k, 1); - end; - end; -{$ENDIF} - -// ctrl/cmd + q to close engine and frontend -{$IFDEF DARWIN} - if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then -{$ELSE} - if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then -{$ENDIF} - begin - if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true) - end; - -// now process strokes -for i:= 0 to cKeyMaxIndex do -if CurrentBinds[i][0] <> #0 then - begin - if (i > 3) and (tkbdn[i] <> 0) and not ((CurrentBinds[i] = 'put') or (CurrentBinds[i] = 'ammomenu') or (CurrentBinds[i] = '+cur_u') or (CurrentBinds[i] = '+cur_d') or (CurrentBinds[i] = '+cur_l') or (CurrentBinds[i] = '+cur_r')) then hideAmmoMenu:= true; - if (tkbd[i] = 0) and (tkbdn[i] <> 0) then - begin - ParseCommand(CurrentBinds[i], Trusted); - if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true) - end - else if (CurrentBinds[i][1] = '+') - and (tkbdn[i] = 0) - and (tkbd[i] <> 0) then - begin - s:= CurrentBinds[i]; - s[1]:= '-'; - ParseCommand(s, Trusted); - if (CurrentTeam <> nil) and not CurrentTeam^.ExtDriven and (ReadyTimeLeft > 1) then ParseCommand('gencmd R', true) - end; - tkbd[i]:= tkbdn[i] - end -end; - -procedure ResetKbd; -var j, k, t: LongInt; -{$IFNDEF IPHONEOS} - i: LongInt; - pkbd: PByteArray; -{$ENDIF} -begin - -k:= SDL_GetMouseState(nil, nil); -{$IFNDEF IPHONEOS}pkbd:={$ENDIF}SDL_GetKeyState(@j); - -TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + IntToStr(j) + ')', true); - -{$IFNDEF IPHONEOS} -for i:= 1 to pred(j) do - tkbdn[i]:= pkbd^[i]; -{$ENDIF} - -// mouse buttons -{$IFDEF DARWIN} -tkbdn[1]:= ((k and 1) and not (tkbdn[306] or tkbdn[305])); -tkbdn[3]:= ((k and 1) and (tkbdn[306] or tkbdn[305])) or (k and 4); -{$ELSE} -tkbdn[1]:= (k and 1); -tkbdn[3]:= ((k shr 2) and 1); -{$ENDIF} -tkbdn[2]:= ((k shr 1) and 1); - -// mouse wheels -tkbdn[4]:= ord(wheelDown); -tkbdn[5]:= ord(wheelUp); -wheelUp:= false; -wheelDown:= false; - -{$IFDEF IPHONEOS} -setiPhoneBinds(); -{$ELSE} -// Controller(s) -k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it -for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; - if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; - tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; - tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; - tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - tkbdn[k]:= ControllerButtons[j][i]; - inc(k, 1); - end; - end; -{$ENDIF} - -// what is this final loop for? -for t:= 0 to cKeyMaxIndex do - tkbd[t]:= tkbdn[t] -end; - -procedure InitKbdKeyTable; -var i, j, k, t: LongInt; - s: string[15]; -begin -KeyNames[1]:= 'mousel'; -KeyNames[2]:= 'mousem'; -KeyNames[3]:= 'mouser'; -KeyNames[4]:= 'wheelup'; -KeyNames[5]:= 'wheeldown'; - -for i:= 6 to cKeyMaxIndex do - begin - s:= shortstring(sdl_getkeyname(i)); - //writeln(stdout,IntToStr(i) + ': ' + s); - if s = 'unknown key' then KeyNames[i]:= '' - else - begin - for t:= 1 to Length(s) do - if s[t] = ' ' then s[t]:= '_'; - KeyNames[i]:= s - end; - end; - -//for i:= 0 to cKeyMaxIndex do writeln(stdout,IntToStr(i) + ': ' + KeyNames[i]); - -// get the size of keyboard array -SDL_GetKeyState(@k); - -// Controller(s) -for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - keynames[k + 0]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'u'; - keynames[k + 1]:= 'j' + IntToStr(j) + 'a' + IntToStr(i) + 'd'; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - keynames[k + 0]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'u'; - keynames[k + 1]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'r'; - keynames[k + 2]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'd'; - keynames[k + 3]:= 'j' + IntToStr(j) + 'h' + IntToStr(i) + 'l'; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - keynames[k]:= 'j' + IntToStr(j) + 'b' + IntToStr(i); - inc(k, 1); - end; - end; - -DefaultBinds[ 27]:= 'quit'; -DefaultBinds[ 96]:= 'history'; -DefaultBinds[127]:= 'rotmask'; - -//numpad -//DefaultBinds[265]:= '+volup'; -//DefaultBinds[256]:= '+voldown'; - -DefaultBinds[KeyNameToCode('0')]:= '+volup'; -DefaultBinds[KeyNameToCode('9')]:= '+voldown'; -DefaultBinds[KeyNameToCode('c')]:= 'capture'; -DefaultBinds[KeyNameToCode('h')]:= 'findhh'; -DefaultBinds[KeyNameToCode('p')]:= 'pause'; -DefaultBinds[KeyNameToCode('s')]:= '+speedup'; -DefaultBinds[KeyNameToCode('t')]:= 'chat'; -DefaultBinds[KeyNameToCode('y')]:= 'confirm'; - -DefaultBinds[KeyNameToCode('mousem')]:= 'zoomreset'; -DefaultBinds[KeyNameToCode('wheelup')]:= 'zoomout'; -DefaultBinds[KeyNameToCode('wheeldown')]:= 'zoomin'; - -DefaultBinds[KeyNameToCode('f12')]:= 'fullscr'; - - -DefaultBinds[ 1]:= '/put'; -DefaultBinds[ 3]:= 'ammomenu'; -DefaultBinds[ 8]:= 'hjump'; -DefaultBinds[ 9]:= 'switch'; -DefaultBinds[13]:= 'ljump'; -DefaultBinds[32]:= '+attack'; -{$IFDEF IPHONEOS} -DefaultBinds[23]:= '+up'; -DefaultBinds[24]:= '+down'; -DefaultBinds[25]:= '+left'; -DefaultBinds[26]:= '+right'; -DefaultBinds[27]:= '+precise'; -DefaultBinds[44]:= 'chat'; -DefaultBinds[55]:= 'pause'; -{$ELSE} -DefaultBinds[KeyNameToCode('up')]:= '+up'; -DefaultBinds[KeyNameToCode('down')]:= '+down'; -DefaultBinds[KeyNameToCode('left')]:= '+left'; -DefaultBinds[KeyNameToCode('right')]:= '+right'; -DefaultBinds[KeyNameToCode('left_shift')]:= '+precise'; -{$ENDIF} - -for i:= 1 to 10 do DefaultBinds[KeyNameToCode('f'+IntToStr(i))]:= 'slot '+IntToStr(i); - -SetDefaultBinds(); -end; - -procedure SetBinds(var binds: TBinds); -begin -{$IFDEF IPHONEOS} - binds:= binds; // avoid hint - CurrentBinds:= DefaultBinds; -{$ELSE} - CurrentBinds:= binds; -{$ENDIF} -end; - -procedure SetDefaultBinds; -begin - CurrentBinds:= DefaultBinds; -end; - -{$IFDEF IPHONEOS} -procedure setiPhoneBinds; -begin - tkbdn[ 1]:= ord(leftClick); - tkbdn[ 2]:= ord(middleClick); - tkbdn[ 3]:= ord(rightClick); - - tkbdn[23]:= ord(upKey); - tkbdn[24]:= ord(downKey); - tkbdn[25]:= ord(leftKey); - tkbdn[26]:= ord(rightKey); - tkbdn[27]:= ord(preciseKey); - - tkbdn[ 8]:= ord(backspaceKey); - tkbdn[ 9]:= ord(tabKey); - tkbdn[13]:= ord(enterKey); - tkbdn[32]:= ord(spaceKey); - - tkbdn[44]:= ord(chatAction); - tkbdn[55]:= ord(pauseAction); - - // set to false the keys that only need one stoke - leftClick:= false; - middleClick:= false; - rightClick:= false; - - tabKey:= false; - enterKey:= false; - backspaceKey:= false; - - chatAction:= false; - pauseAction:= false; -end; -{$ENDIF} - -procedure FreezeEnterKey; -begin - tkbd[3]:= 1; - tkbd[13]:= 1; - tkbd[27]:= 1; - tkbd[271]:= 1; -end; - -var Controller: array [0..5] of PSDL_Joystick; - -procedure ControllerInit; -var i, j: Integer; -begin -ControllerEnabled:= 0; -{$IFDEF IPHONEOS} -exit; // joystick subsystem disabled on iPhone -{$ENDIF} - -SDL_InitSubSystem(SDL_INIT_JOYSTICK); -ControllerNumControllers:= SDL_NumJoysticks(); -if ControllerNumControllers > 6 then ControllerNumControllers:= 6; - -WriteLnToConsole('Number of game controllers: ' + IntToStr(ControllerNumControllers)); - -if ControllerNumControllers > 0 then - begin - for j:= 0 to pred(ControllerNumControllers) do - begin - WriteLnToConsole('Using game controller: ' + SDL_JoystickName(j)); - Controller[j]:= SDL_JoystickOpen(j); - if Controller[j] = nil then - WriteLnToConsole('* Failed to open game controller!') - else - begin - ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]); - //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]); - ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]); - ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]); - WriteLnToConsole('* Number of axes: ' + IntToStr(ControllerNumAxes[j])); - //WriteLnToConsole('* Number of balls: ' + IntToStr(ControllerNumBalls[j])); - WriteLnToConsole('* Number of hats: ' + IntToStr(ControllerNumHats[j])); - WriteLnToConsole('* Number of buttons: ' + IntToStr(ControllerNumButtons[j])); - ControllerEnabled:= 1; - - if ControllerNumAxes[j] > 20 then ControllerNumAxes[j]:= 20; - //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; - if ControllerNumHats[j] > 20 then ControllerNumHats[j]:= 20; - if ControllerNumButtons[j] > 20 then ControllerNumButtons[j]:= 20; - - // reset all buttons/axes - for i:= 0 to pred(ControllerNumAxes[j]) do - ControllerAxes[j][i]:= 0; - (*for i:= 0 to pred(ControllerNumBalls[j]) do - begin - ControllerBalls[j][i][0]:= 0; - ControllerBalls[j][i][1]:= 0; - end;*) - for i:= 0 to pred(ControllerNumHats[j]) do - ControllerHats[j][i]:= SDL_HAT_CENTERED; - for i:= 0 to pred(ControllerNumButtons[j]) do - ControllerButtons[j][i]:= 0; - end; - end; - // enable event generation/controller updating - SDL_JoystickEventState(1); - end -else - WriteLnToConsole('Not using any game controller'); -end; - -procedure ControllerClose; -var j: Integer; -begin - if ControllerEnabled > 0 then - for j:= 0 to pred(ControllerNumControllers) do - SDL_JoystickClose(Controller[j]); -end; - -procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); -begin - ControllerAxes[joy][axis]:= value; -end; - -procedure ControllerHatEvent(joy, hat, value: Byte); -begin - ControllerHats[joy][hat]:= value; -end; - -procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); -begin - if pressed then ControllerButtons[joy][button]:= 1 - else ControllerButtons[joy][button]:= 0; -end; - -procedure initModule; -begin - wheelUp:= false; - wheelDown:= false; -{$IFDEF HWLIBRARY} - // this function is called by HW_allKeysUp so be careful - - // mouse emulation - leftClick:= false; - middleClick:= false; - rightClick:= false; - - // arrow key emulation - upKey:= false; - downKey:= false; - rightKey:= false; - leftKey:= false; - preciseKey:= false; - - // action key emulation - backspaceKey:= false; - spaceKey:= false; - enterKey:= false; - tabKey:= false; - - // other key emulation - chatAction:= false; - pauseAction:= false; -{$ENDIF} -end; - -procedure freeModule; -begin - -end; - -end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLand.pas --- a/hedgewars/uLand.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLand.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,263 +20,41 @@ unit uLand; interface -uses SDLh, uLandTemplates, uFloat, uConsts, GLunit, uTypes; - -type direction = record x, y: LongInt; end; -const DIR_N: direction = (x: 0; y: -1); - DIR_E: direction = (x: 1; y: 0); - DIR_S: direction = (x: 0; y: 1); - DIR_W: direction = (x: -1; y: 0); +uses SDLh, uLandTemplates, uFloat, uConsts, GLunit, uTypes, uAILandMarks; procedure initModule; procedure freeModule; procedure DrawBottomBorder; procedure GenMap; -function GenPreview: TPreview; +procedure GenPreview(out Preview: TPreview); implementation -uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils, - uVariables, uUtils, uCommands, Adler32, uDebug, uLandPainted, uTextures; - -operator=(const a, b: direction) c: Boolean; -begin - c := (a.x = b.x) and (a.y = b.y); -end; - -type TPixAr = record - Count: Longword; - ar: array[0..Pred(cMaxEdgePoints)] of TPoint; - end; - -procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); -var - eX, eY, dX, dY: LongInt; - i, sX, sY, x, y, d: LongInt; -begin -eX:= 0; -eY:= 0; -dX:= X2 - X1; -dY:= Y2 - Y1; - -if (dX > 0) then sX:= 1 -else - if (dX < 0) then - begin - sX:= -1; - dX:= -dX - end else sX:= dX; - -if (dY > 0) then sY:= 1 - else - if (dY < 0) then - begin - sY:= -1; - dY:= -dY - end else sY:= dY; - -if (dX > dY) then d:= dX - else d:= dY; - -x:= X1; -y:= Y1; +uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, SysUtils, + uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures, + uLandGenMaze, uLandOutline; -for i:= 0 to d do - begin - inc(eX, dX); - inc(eY, dY); - if (eX > d) then - begin - dec(eX, d); - inc(x, sX); - end; - if (eY > d) then - begin - dec(eY, d); - inc(y, sY); - end; - - if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then - Land[y, x]:= Color; - end -end; - -procedure DrawEdge(var pa: TPixAr; Color: Longword); -var i: LongInt; -begin -i:= 0; -with pa do -while i < LongInt(Count) - 1 do - if (ar[i + 1].X = NTPX) then inc(i, 2) - else begin - DrawLine(ar[i].x, ar[i].y, ar[i + 1].x, ar[i + 1].y, Color); - inc(i) - end -end; - -procedure Vector(p1, p2, p3: TPoint; var Vx, Vy: hwFloat); -var d1, d2, d: hwFloat; -begin -Vx:= int2hwFloat(p1.X - p3.X); -Vy:= int2hwFloat(p1.Y - p3.Y); -d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y); -d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y); -d2:= Distance(Vx, Vy); -if d1 < d then d:= d1; -if d2 < d then d:= d2; -d:= d * _1div3; -if d2.QWordValue = 0 then - begin - Vx:= _0; - Vy:= _0 - end else - begin - d2:= _1 / d2; - Vx:= Vx * d2; - Vy:= Vy * d2; - - Vx:= Vx * d; - Vy:= Vy * d - end -end; +var digest: shortstring; -procedure AddLoopPoints(var pa, opa: TPixAr; StartI, EndI: LongInt; Delta: hwFloat); -var i, pi, ni: LongInt; - NVx, NVy, PVx, PVy: hwFloat; - x1, x2, y1, y2: LongInt; - tsq, tcb, t, r1, r2, r3, cx1, cx2, cy1, cy2: hwFloat; - X, Y: LongInt; -begin -pi:= EndI; -i:= StartI; -ni:= Succ(StartI); -{$HINTS OFF} -Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); -{$HINTS ON} -repeat - inc(pi); - if pi > EndI then pi:= StartI; - inc(i); - if i > EndI then i:= StartI; - inc(ni); - if ni > EndI then ni:= StartI; - PVx:= NVx; - PVy:= NVy; - Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); - - x1:= opa.ar[pi].x; - y1:= opa.ar[pi].y; - x2:= opa.ar[i].x; - y2:= opa.ar[i].y; - cx1:= int2hwFloat(x1) - PVx; - cy1:= int2hwFloat(y1) - PVy; - cx2:= int2hwFloat(x2) + NVx; - cy2:= int2hwFloat(y2) + NVy; - t:= _0; - while t.Round = 0 do - begin - tsq:= t * t; - tcb:= tsq * t; - r1:= (_1 - t*3 + tsq*3 - tcb); - r2:= ( t*3 - tsq*6 + tcb*3); - r3:= ( tsq*3 - tcb*3); - X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2); - Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2); - t:= t + Delta; - pa.ar[pa.Count].x:= X; - pa.ar[pa.Count].y:= Y; - inc(pa.Count); - TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true) - end; -until i = StartI; -pa.ar[pa.Count].x:= opa.ar[StartI].X; -pa.ar[pa.Count].y:= opa.ar[StartI].Y; -inc(pa.Count) -end; +procedure ResizeLand(width, height: LongWord); +var potW, potH: LongWord; +begin +potW:= toPowerOf2(width); +potH:= toPowerOf2(height); +if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then + begin + LAND_WIDTH:= potW; + LAND_HEIGHT:= potH; + LAND_WIDTH_MASK:= not(LAND_WIDTH-1); + LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); + cWaterLine:= LAND_HEIGHT; + if (cReducedQuality and rqBlurryLand) = 0 then + SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) + else + SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); -procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat); -var i, StartLoop: LongInt; - opa: TPixAr; -begin -opa:= pa; -pa.Count:= 0; -i:= 0; -StartLoop:= 0; -while i < LongInt(opa.Count) do - if (opa.ar[i + 1].X = NTPX) then - begin - AddLoopPoints(pa, opa, StartLoop, i, Delta); - inc(i, 2); - StartLoop:= i; - pa.ar[pa.Count].X:= NTPX; - pa.ar[pa.Count].Y:= 0; - inc(pa.Count); - end else inc(i) -end; - -procedure FillLand(x, y: LongInt); -var Stack: record - Count: Longword; - points: array[0..8192] of record - xl, xr, y, dir: LongInt; - end - end; - - procedure Push(_xl, _xr, _y, _dir: LongInt); - begin - TryDo(Stack.Count <= 8192, 'FillLand: stack overflow', true); - _y:= _y + _dir; - if (_y < 0) or (_y >= LAND_HEIGHT) then exit; - with Stack.points[Stack.Count] do - begin - xl:= _xl; - xr:= _xr; - y:= _y; - dir:= _dir - end; - inc(Stack.Count) + SetLength(Land, LAND_HEIGHT, LAND_WIDTH); + SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); end; - - procedure Pop(var _xl, _xr, _y, _dir: LongInt); - begin - dec(Stack.Count); - with Stack.points[Stack.Count] do - begin - _xl:= xl; - _xr:= xr; - _y:= y; - _dir:= dir - end - end; - -var xl, xr, dir: LongInt; -begin -Stack.Count:= 0; -xl:= x - 1; -xr:= x; -Push(xl, xr, y, -1); -Push(xl, xr, y, 1); -dir:= 0; -while Stack.Count > 0 do - begin - Pop(xl, xr, y, dir); - while (xl > 0) and (Land[y, xl] <> 0) do dec(xl); - while (xr < LAND_WIDTH - 1) and (Land[y, xr] <> 0) do inc(xr); - while (xl < xr) do - begin - while (xl <= xr) and (Land[y, xl] = 0) do inc(xl); - x:= xl; - while (xl <= xr) and (Land[y, xl] <> 0) do - begin - Land[y, xl]:= 0; - inc(xl) - end; - if x < xl then - begin - Push(x, Pred(xl), y, dir); - Push(x, Pred(xl), y,-dir); - end; - end; - end; end; procedure ColorizeLand(Surface: PSDL_Surface); @@ -284,8 +62,7 @@ r, rr: TSDL_Rect; x, yd, yu: LongInt; begin - tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/LandTex', ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps); + tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps); r.y:= 0; while r.y < LAND_HEIGHT do begin @@ -300,21 +77,21 @@ SDL_FreeSurface(tmpsurf); // freed in freeModule() below - LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); - if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); - if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface); + LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); + if (LandBackSurface <> nil) and GrayScale then Surface2GrayScale(LandBackSurface); - tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Border', ifIgnoreCaps or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent); + tmpsurf:= LoadDataImage(ptCurrTheme, 'Border', ifCritical or ifIgnoreCaps or ifTransparent); for x:= 0 to LAND_WIDTH - 1 do begin yd:= LAND_HEIGHT - 1; repeat while (yd > 0) and (Land[yd, x] = 0) do dec(yd); - if (yd < 0) then yd:= 0; + if (yd < 0) then + yd:= 0; - while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); + while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do + inc(yd); dec(yd); yu:= yd; @@ -322,7 +99,7 @@ while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then - begin + begin rr.x:= x; rr.y:= yd - 15; r.x:= x mod tmpsurf^.w; @@ -330,9 +107,9 @@ r.w:= 1; r.h:= 16; SDL_UpperBlit(tmpsurf, @r, Surface, @rr); - end; + end; if (yu > 0) then - begin + begin rr.x:= x; rr.y:= yu; r.x:= x mod tmpsurf^.w; @@ -340,7 +117,7 @@ r.w:= 1; r.h:= Min(16, yd - yu + 1); SDL_UpperBlit(tmpsurf, @r, Surface, @rr); - end; + end; yd:= yu - 1; until yd < 0; end; @@ -351,25 +128,25 @@ var i: LongInt; begin with Template do - begin - pa.Count:= BasePointsCount; - for i:= 0 to pred(pa.Count) do - begin - pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w)); - if pa.ar[i].x <> NTPX then - pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2); - pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight) - end; + begin + pa.Count:= BasePointsCount; + for i:= 0 to pred(pa.Count) do + begin + pa.ar[i].x:= BasePoints^[i].x + LongInt(GetRandom(BasePoints^[i].w)); + if pa.ar[i].x <> NTPX then + pa.ar[i].x:= pa.ar[i].x + ((LAND_WIDTH - Template.TemplateWidth) div 2); + pa.ar[i].y:= BasePoints^[i].y + LongInt(GetRandom(BasePoints^[i].h)) + LAND_HEIGHT - LongInt(Template.TemplateHeight) + end; - if canMirror then + if canMirror then if getrandom(2) = 0 then - begin - for i:= 0 to pred(BasePointsCount) do - if pa.ar[i].x <> NTPX then - pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x; - for i:= 0 to pred(FillPointsCount) do - FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; - end; + begin + for i:= 0 to pred(BasePointsCount) do + if pa.ar[i].x <> NTPX then + pa.ar[i].x:= LAND_WIDTH - 1 - pa.ar[i].x; + for i:= 0 to pred(FillPointsCount) do + FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; + end; (* Experiment in making this option more useful if ((not isNegative) and (cTemplateFilter = 4)) or @@ -391,108 +168,30 @@ end *) // template recycling. Pull these off the floor a bit - if (not isNegative) and (cTemplateFilter = 4) then - begin - for i:= 0 to pred(BasePointsCount) do - begin - dec(pa.ar[i].y, 100); - if pa.ar[i].y < 0 then - pa.ar[i].y:= 0; - end; - for i:= 0 to pred(FillPointsCount) do - begin - dec(FillPoints^[i].y, 100); - if FillPoints^[i].y < 0 then - FillPoints^[i].y:= 0; - end; - end; - - if (canFlip and (getrandom(2) = 0)) then - begin - for i:= 0 to pred(BasePointsCount) do - pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y; - for i:= 0 to pred(FillPointsCount) do - FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y; - end; - end -end; - -function CheckIntersect(V1, V2, V3, V4: TPoint): boolean; -var c1, c2, dm: LongInt; -begin -dm:= (V4.y - V3.y) * (V2.x - V1.x) - (V4.x - V3.x) * (V2.y - V1.y); -c1:= (V4.x - V3.x) * (V1.y - V3.y) - (V4.y - V3.y) * (V1.x - V3.x); -if dm = 0 then exit(false); - -c2:= (V2.x - V3.x) * (V1.y - V3.y) - (V2.y - V3.y) * (V1.x - V3.x); -if dm > 0 then - begin - if (c1 < 0) or (c1 > dm) then exit(false); - if (c2 < 0) or (c2 > dm) then exit(false) - end else - begin - if (c1 > 0) or (c1 < dm) then exit(false); - if (c2 > 0) or (c2 < dm) then exit(false) - end; - -//AddFileLog('1 (' + inttostr(V1.x) + ',' + inttostr(V1.y) + ')x(' + inttostr(V2.x) + ',' + inttostr(V2.y) + ')'); -//AddFileLog('2 (' + inttostr(V3.x) + ',' + inttostr(V3.y) + ')x(' + inttostr(V4.x) + ',' + inttostr(V4.y) + ')'); -CheckIntersect:= true -end; + if (not isNegative) and (cTemplateFilter = 4) then + begin + for i:= 0 to pred(BasePointsCount) do + begin + dec(pa.ar[i].y, 100); + if pa.ar[i].y < 0 then + pa.ar[i].y:= 0; + end; + for i:= 0 to pred(FillPointsCount) do + begin + dec(FillPoints^[i].y, 100); + if FillPoints^[i].y < 0 then + FillPoints^[i].y:= 0; + end; + end; -function CheckSelfIntersect(var pa: TPixAr; ind: Longword): boolean; -var i: Longword; -begin -if (ind <= 0) or (ind >= Pred(pa.Count)) then exit(false); -for i:= 1 to pa.Count - 3 do - if (i <= ind - 1) or (i >= ind + 2) then - begin - if (i <> ind - 1) and - CheckIntersect(pa.ar[ind], pa.ar[ind - 1], pa.ar[i], pa.ar[i - 1]) then exit(true); - if (i <> ind + 2) and - CheckIntersect(pa.ar[ind], pa.ar[ind + 1], pa.ar[i], pa.ar[i - 1]) then exit(true); - end; -CheckSelfIntersect:= false -end; - -procedure RandomizePoints(var pa: TPixAr); -const cEdge = 55; - cMinDist = 8; -var radz: array[0..Pred(cMaxEdgePoints)] of LongInt; - i, k, dist, px, py: LongInt; -begin -for i:= 0 to Pred(pa.Count) do - begin - radz[i]:= 0; - with pa.ar[i] do - if x <> NTPX then - begin - radz[i]:= Min(Max(x - cEdge, 0), Max(LAND_WIDTH - cEdge - x, 0)); - radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(LAND_HEIGHT - cEdge - y, 0))); - if radz[i] > 0 then - for k:= 0 to Pred(i) do - begin - dist:= Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y)); - radz[k]:= Max(0, Min((dist - cMinDist) div 2, radz[k])); - radz[i]:= Max(0, Min(dist - radz[k] - cMinDist, radz[i])) - end - end; - end; - -for i:= 0 to Pred(pa.Count) do - with pa.ar[i] do - if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then - begin - px:= x; - py:= y; - x:= x + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; - y:= y + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; - if CheckSelfIntersect(pa, i) then - begin - x:= px; - y:= py - end; - end + if (canFlip and (getrandom(2) = 0)) then + begin + for i:= 0 to pred(BasePointsCount) do + pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y; + for i:= 0 to pred(FillPointsCount) do + FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y; + end; + end end; @@ -501,6 +200,7 @@ i: Longword; y, x: Longword; begin + ResizeLand(Template.TemplateWidth, Template.TemplateHeight); for y:= 0 to LAND_HEIGHT - 1 do for x:= 0 to LAND_WIDTH - 1 do Land[y, x]:= lfBasic; @@ -513,7 +213,8 @@ RandomizePoints(pa); RandomizePoints(pa) end; - for i:= 1 to Template.RandPassesCount do RandomizePoints(pa); + for i:= 1 to Template.RandPassesCount do + RandomizePoints(pa); BezierizeEdge(pa, _0_1); @@ -535,9 +236,9 @@ topY:= LAND_HEIGHT - playHeight; // HACK: force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? - if (cTemplateFilter = 4) or - (Template.canInvert and (getrandom(2) = 0)) or - (not Template.canInvert and Template.isNegative) then + if (cTemplateFilter = 4) + or (Template.canInvert and (getrandom(2) = 0)) + or (not Template.canInvert and Template.isNegative) then begin hasBorder:= true; for y:= 0 to LAND_HEIGHT - 1 do @@ -545,17 +246,18 @@ if (y < topY) or (x < leftX) or (x > rightX) then Land[y, x]:= 0 else - begin - if Land[y, x] = 0 then - Land[y, x]:= lfBasic - else if Land[y, x] = lfBasic then - Land[y, x]:= 0; - end; + begin + if Land[y, x] = 0 then + Land[y, x]:= lfBasic + else if Land[y, x] = lfBasic then + Land[y, x]:= 0; + end; end; end; procedure GenDrawnMap; begin + ResizeLand(4096, 2048); uLandPainted.Draw; MaxHedgehogs:= 48; @@ -579,6 +281,11 @@ 3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))]; 4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))]; 5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))]; +// For lua only! + 6: begin + SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates)); + GetRandom(2) // burn 1 + end; end; WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); @@ -599,9 +306,9 @@ for x:= 0 to LAND_WIDTH - 1 do if Land[y, x] <> 0 then if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[y, x]:= p^[x] or AMask + LandPixels[y, x]:= p^[x] or AMask else - LandPixels[y div 2, x div 2]:= p^[x] or AMask; + LandPixels[y div 2, x div 2]:= p^[x] or AMask; p:= @(p^[Surface^.pitch div 4]); end; @@ -610,437 +317,6 @@ SDL_UnlockSurface(Surface); end; -procedure GenMaze; -const small_cell_size = 128; - medium_cell_size = 192; - large_cell_size = 256; - braidness = 10; - -var x, y: LongInt; - cellsize: LongInt; //selected by the user in the gui - seen_cells_x, seen_cells_y: LongInt; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another - num_edges_x, num_edges_y: LongInt; //number of resulting edges that need to be vertexificated - num_cells_x, num_cells_y: LongInt; //actual number of cells, depending on cell size - seen_list: array of array of LongInt; - xwalls: array of array of Boolean; - ywalls: array of array of Boolean; - x_edge_list: array of array of Boolean; - y_edge_list: array of array of Boolean; - maze: array of array of Boolean; - pa: TPixAr; - num_vertices: LongInt; - off_y: LongInt; - num_steps: LongInt; - current_step: LongInt; - step_done: array of Boolean; - done: Boolean; - last_cell: array of record x, y: LongInt; end; - came_from: array of array of record x, y: LongInt; end; - came_from_pos: array of LongInt; - maze_inverted: Boolean; - -function when_seen(x: LongInt; y: LongInt): LongInt; -begin -if (x < 0) or (x >= seen_cells_x) or (y < 0) or (y >= seen_cells_y) then - when_seen := current_step -else - when_seen := seen_list[x, y]; -end; - -function is_x_edge(x, y: LongInt): Boolean; -begin -if (x < 0) or (x > num_edges_x) or (y < 0) or (y > num_cells_y) then - is_x_edge := false -else - is_x_edge := x_edge_list[x, y]; -end; - -function is_y_edge(x, y: LongInt): Boolean; -begin -if (x < 0) or (x > num_cells_x) or (y < 0) or (y > num_edges_y) then - is_y_edge := false -else - is_y_edge := y_edge_list[x, y]; -end; - -procedure see_cell; -var dir: direction; - tries: LongInt; - x, y: LongInt; - found_cell: Boolean; - next_dir_clockwise: Boolean; - -begin -x := last_cell[current_step].x; -y := last_cell[current_step].y; -seen_list[x, y] := current_step; -case GetRandom(4) of - 0: dir := DIR_N; - 1: dir := DIR_E; - 2: dir := DIR_S; - 3: dir := DIR_W; -end; -tries := 0; -found_cell := false; -if getrandom(2) = 1 then next_dir_clockwise := true -else next_dir_clockwise := false; - -while (tries < 5) and not found_cell do -begin - if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction - begin - //we have already seen the target cell, decide if we should remove the wall anyway - //(or put a wall there if maze_inverted, but we are not doing that right now) - if not maze_inverted and (GetRandom(braidness) = 0) then - //or just warn that inverted+braid+indestructible terrain != good idea - begin - case dir.x of - -1: if x > 0 then ywalls[x-1, y] := false; - 1: if x < seen_cells_x - 1 then ywalls[x, y] := false; - end; - case dir.y of - -1: if y > 0 then xwalls[x, y-1] := false; - 1: if y < seen_cells_y - 1 then xwalls[x, y] := false; - end; - end; - if next_dir_clockwise then - begin - if dir = DIR_N then - dir := DIR_E - else if dir = DIR_E then - dir := DIR_S - else if dir = DIR_S then - dir := DIR_W - else - dir := DIR_N; - end - else - begin - if dir = DIR_N then - dir := DIR_W - else if dir = DIR_E then - dir := DIR_N - else if dir = DIR_S then - dir := DIR_E - else - dir := DIR_S; - end - end - else if when_seen(x + dir.x, y + dir.y) = -1 then //cell was not seen yet, go there - begin - case dir.y of - -1: xwalls[x, y-1] := false; - 1: xwalls[x, y] := false; - end; - case dir.x of - -1: ywalls[x-1, y] := false; - 1: ywalls[x, y] := false; - end; - last_cell[current_step].x := x+dir.x; - last_cell[current_step].y := y+dir.y; - came_from_pos[current_step] := came_from_pos[current_step] + 1; - came_from[current_step, came_from_pos[current_step]].x := x; - came_from[current_step, came_from_pos[current_step]].y := y; - found_cell := true; - end - else //we are seeing someone else, quit - begin - step_done[current_step] := true; - found_cell := true; - end; - - tries := tries + 1; -end; -if not found_cell then -begin - last_cell[current_step].x := came_from[current_step, came_from_pos[current_step]].x; - last_cell[current_step].y := came_from[current_step, came_from_pos[current_step]].y; - came_from_pos[current_step] := came_from_pos[current_step] - 1; - if came_from_pos[current_step] >= 0 then see_cell - else step_done[current_step] := true; -end; -end; - -procedure add_vertex(x, y: LongInt); -var tmp_x, tmp_y: LongInt; -begin -if x = NTPX then -begin - if pa.ar[num_vertices - 6].x = NTPX then - begin - num_vertices := num_vertices - 6; - end - else - begin - pa.ar[num_vertices].x := NTPX; - pa.ar[num_vertices].y := 0; - end -end -else -begin - if maze_inverted or (x mod 2 = 0) then tmp_x := cellsize - else tmp_x := cellsize * 2 div 3; - if maze_inverted or (y mod 2 = 0) then tmp_y := cellsize - else tmp_y := cellsize * 2 div 3; - - pa.ar[num_vertices].x := (x-1)*cellsize + tmp_x; - pa.ar[num_vertices].y := (y-1)*cellsize + tmp_y + off_y; -end; -num_vertices := num_vertices + 1; -end; - -procedure add_edge(x, y: LongInt; dir: direction); -var i: LongInt; -begin -if dir = DIR_N then -begin - dir := DIR_W -end -else if dir = DIR_E then -begin - dir := DIR_N -end -else if dir = DIR_S then -begin - dir := DIR_E -end -else -begin - dir := DIR_S; -end; - -for i := 0 to 3 do -begin - if dir = DIR_N then - dir := DIR_E - else if dir = DIR_E then - dir := DIR_S - else if dir = DIR_S then - dir := DIR_W - else - dir := DIR_N; - - if (dir = DIR_N) and is_x_edge(x, y) then - begin - x_edge_list[x, y] := false; - add_vertex(x+1, y); - add_edge(x, y-1, DIR_N); - break; - end; - - if (dir = DIR_E) and is_y_edge(x+1, y) then - begin - y_edge_list[x+1, y] := false; - add_vertex(x+2, y+1); - add_edge(x+1, y, DIR_E); - break; - end; - - if (dir = DIR_S) and is_x_edge(x, y+1) then - begin - x_edge_list[x, y+1] := false; - add_vertex(x+1, y+2); - add_edge(x, y+1, DIR_S); - break; - end; - - if (dir = DIR_W) and is_y_edge(x, y) then - begin - y_edge_list[x, y] := false; - add_vertex(x, y+1); - add_edge(x-1, y, DIR_W); - break; - end; -end; - -end; - -begin -case cTemplateFilter of - 0: begin - cellsize := small_cell_size; - maze_inverted := false; - end; - 1: begin - cellsize := medium_cell_size; - maze_inverted := false; - end; - 2: begin - cellsize := large_cell_size; - maze_inverted := false; - end; - 3: begin - cellsize := small_cell_size; - maze_inverted := true; - end; - 4: begin - cellsize := medium_cell_size; - maze_inverted := true; - end; - 5: begin - cellsize := large_cell_size; - maze_inverted := true; - end; -end; - -num_cells_x := LAND_WIDTH div cellsize; -if not odd(num_cells_x) then num_cells_x := num_cells_x - 1; //needs to be odd -num_cells_y := LAND_HEIGHT div cellsize; -if not odd(num_cells_y) then num_cells_y := num_cells_y - 1; -num_edges_x := num_cells_x - 1; -num_edges_y := num_cells_y - 1; -seen_cells_x := num_cells_x div 2; -seen_cells_y := num_cells_y div 2; - -if maze_inverted then - num_steps := 3 //TODO randomize, between 3 and 5? -else - num_steps := 1; -SetLength(step_done, num_steps); -SetLength(last_cell, num_steps); -SetLength(came_from_pos, num_steps); -SetLength(came_from, num_steps, num_cells_x*num_cells_y); -done := false; -for current_step := 0 to num_steps - 1 do - step_done[current_step] := false; - came_from_pos[current_step] := 0; -current_step := 0; - -SetLength(seen_list, seen_cells_x, seen_cells_y); -SetLength(xwalls, seen_cells_x, seen_cells_y - 1); -SetLength(ywalls, seen_cells_x - 1, seen_cells_y); -SetLength(x_edge_list, num_edges_x, num_cells_y); -SetLength(y_edge_list, num_cells_x, num_edges_y); -SetLength(maze, num_cells_x, num_cells_y); - -num_vertices := 0; - -playHeight := num_cells_y * cellsize; -playWidth := num_cells_x * cellsize; -off_y := LAND_HEIGHT - playHeight; - -for x := 0 to playWidth do - for y := 0 to off_y - 1 do - Land[y, x] := 0; - -for x := 0 to playWidth do - for y := off_y to LAND_HEIGHT - 1 do - Land[y, x] := lfBasic; - -for y := 0 to num_cells_y - 1 do - for x := 0 to num_cells_x - 1 do - maze[x, y] := false; - -for x := 0 to seen_cells_x - 1 do - for y := 0 to seen_cells_y - 2 do - xwalls[x, y] := true; - -for x := 0 to seen_cells_x - 2 do - for y := 0 to seen_cells_y - 1 do - ywalls[x, y] := true; - -for x := 0 to seen_cells_x - 1 do - for y := 0 to seen_cells_y - 1 do - seen_list[x, y] := -1; - -for x := 0 to num_edges_x - 1 do - for y := 0 to num_cells_y - 1 do - x_edge_list[x, y] := false; - -for x := 0 to num_cells_x - 1 do - for y := 0 to num_edges_y - 1 do - y_edge_list[x, y] := false; - -for current_step := 0 to num_steps-1 do -begin - x := GetRandom(seen_cells_x - 1) div LongWord(num_steps); - last_cell[current_step].x := x + current_step * seen_cells_x div num_steps; - last_cell[current_step].y := GetRandom(seen_cells_y); -end; - -while not done do -begin - done := true; - for current_step := 0 to num_steps-1 do - begin - if not step_done[current_step] then - begin - see_cell; - done := false; - end; - end; -end; - -for x := 0 to seen_cells_x - 1 do - for y := 0 to seen_cells_y - 1 do - if seen_list[x, y] > -1 then - maze[(x+1)*2-1, (y+1)*2-1] := true; - -for x := 0 to seen_cells_x - 1 do - for y := 0 to seen_cells_y - 2 do - if not xwalls[x, y] then - maze[x*2 + 1, y*2 + 2] := true; - - -for x := 0 to seen_cells_x - 2 do - for y := 0 to seen_cells_y - 1 do - if not ywalls[x, y] then - maze[x*2 + 2, y*2 + 1] := true; - -for x := 0 to num_edges_x - 1 do - for y := 0 to num_cells_y - 1 do - if maze[x, y] xor maze[x+1, y] then - x_edge_list[x, y] := true - else - x_edge_list[x, y] := false; - -for x := 0 to num_cells_x - 1 do - for y := 0 to num_edges_y - 1 do - if maze[x, y] xor maze[x, y+1] then - y_edge_list[x, y] := true - else - y_edge_list[x, y] := false; - -for x := 0 to num_edges_x - 1 do - for y := 0 to num_cells_y - 1 do - if x_edge_list[x, y] then - begin - x_edge_list[x, y] := false; - add_vertex(x+1, y+1); - add_vertex(x+1, y); - add_edge(x, y-1, DIR_N); - add_vertex(NTPX, 0); - end; - -pa.count := num_vertices; - -RandomizePoints(pa); -BezierizeEdge(pa, _0_25); -RandomizePoints(pa); -BezierizeEdge(pa, _0_25); - -DrawEdge(pa, 0); - -if maze_inverted then - FillLand(1, 1+off_y) -else -begin - x := 0; - while Land[cellsize div 2 + cellsize + off_y, x] = lfBasic do - x := x + 1; - while Land[cellsize div 2 + cellsize + off_y, x] = 0 do - x := x + 1; - FillLand(x+1, cellsize div 2 + cellsize + off_y); -end; - -MaxHedgehogs:= 32; -if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false -else hasGirders := true; -leftX:= 0; -rightX:= playWidth; -topY:= off_y; -hasBorder := false; -end; procedure GenLandSurface; var tmpsurf: PSDL_Surface; @@ -1049,7 +325,7 @@ WriteLnToConsole('Generating land...'); case cMapGen of 0: GenBlank(EdgeTemplates[SelectTemplate]); - 1: GenMaze; + 1: begin ResizeLand(4096,2048); GenMaze; end; 2: GenDrawnMap; else OutError('Unknown mapgen', true); @@ -1072,11 +348,20 @@ begin if (cReducedQuality and rqBlurryLand) = 0 then begin - if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] - else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] - else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x] - else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x]; - if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (128 shl AShift) + if (Land[y, x-1] = lfBasic) and (LandPixels[y, x-1] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y, x-1] + + else if (Land[y, x+1] = lfBasic) and (LandPixels[y, x+1] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y, x+1] + + else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1, x] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y-1, x] + + else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1, x] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y+1, x]; + + if (((LandPixels[y,x] and AMask) shr AShift) > 10) then + LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (128 shl AShift) end; Land[y,x]:= lfObject end @@ -1089,14 +374,27 @@ ((Land[y-1, x] = lfBasic) and (Land[y-1,x+1] = lfBasic) and (Land[y,x+2] = lfBasic)) or ((Land[y+1, x] = lfBasic) and (Land[y+1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic)) or ((Land[y-1, x] = lfBasic) and (Land[y-1,x-1] = lfBasic) and (Land[y,x-2] = lfBasic))) then - begin + + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin - if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x-1] - else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y, x+1] - else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y+1, x] - else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then LandPixels[y, x]:= LandPixels[y-1, x]; - if (((LandPixels[y,x] and AMask) shr AShift) > 10) then LandPixels[y,x]:= (LandPixels[y,x] and not AMask) or (64 shl AShift) + + if (Land[y, x-1] = lfBasic) and (LandPixels[y,x-1] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y, x-1] + + else if (Land[y, x+1] = lfBasic) and (LandPixels[y,x+1] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y, x+1] + + else if (Land[y+1, x] = lfBasic) and (LandPixels[y+1,x] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y+1, x] + + else if (Land[y-1, x] = lfBasic) and (LandPixels[y-1,x] and AMask <> 0) then + LandPixels[y, x]:= LandPixels[y-1, x]; + + if (((LandPixels[y,x] and AMask) shr AShift) > 10) then + LandPixels[y,x]:= (LandPixels[y,x] and (not AMask)) or (64 shl AShift) end; Land[y,x]:= lfObject end; @@ -1117,13 +415,11 @@ WriteLnToConsole('Generating forts land...'); -tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifTransparent or ifIgnoreCaps); -if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); +tmpsurf:= LoadDataImage(ptForts, ClansArray[0]^.Teams[0]^.FortName + 'L', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); BlitImageAndGenerateCollisionInfo(leftX+150, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); SDL_FreeSurface(tmpsurf); -tmpsurf:= LoadImage(UserPathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifTransparent or ifIgnoreCaps); -if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptForts] + '/' + ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); +tmpsurf:= LoadDataImage(ptForts, ClansArray[1]^.Teams[0]^.FortName + 'R', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); BlitImageAndGenerateCollisionInfo(rightX - 150 - tmpsurf^.w, LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); SDL_FreeSurface(tmpsurf); end; @@ -1134,18 +430,16 @@ p: PLongwordArray; x, y, cpX, cpY: Longword; begin -tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); -if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); +tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifTransparent or ifIgnoreCaps); if tmpsurf = nil then begin mapName:= ExtractFileName(Pathz[ptMapCurrent]); - tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); + tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); end; if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then -begin + begin disableLandBack:= true; cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; @@ -1158,19 +452,22 @@ begin for x:= 0 to Pred(tmpsurf^.w) do begin - if ((AMask and p^[x]) = 0) then + // this an if instead of masking colours to avoid confusing map creators + if ((AMask and p^[x]) = 0) then Land[cpY + y, cpX + x]:= 0 - else if p^[x] = $FFFFFFFF then + else if p^[x] = $FFFFFFFF then // white Land[cpY + y, cpX + x]:= lfObject - else if p^[x] = (AMask or RMask) then - Land[cpY + y, cpX + x]:= lfIndestructible - else if p^[x] = AMask then + else if p^[x] = AMask then // black begin Land[cpY + y, cpX + x]:= lfBasic; disableLandBack:= false end - else if p^[x] = (AMask or BMask) then + else if p^[x] = (AMask or RMask) then // red + Land[cpY + y, cpX + x]:= lfIndestructible + else if p^[x] = (AMask or BMask) then // blue Land[cpY + y, cpX + x]:= lfObject or lfIce + else if p^[x] = (AMask or GMask) then // green + Land[cpY + y, cpX + x]:= lfObject or lfBouncy end; p:= @(p^[tmpsurf^.pitch div 4]); end; @@ -1180,9 +477,9 @@ if not disableLandBack then begin // freed in freeModule() below - LandBackSurface:= LoadImage(UserPathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); - if LandBackSurface = nil then LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); - if (LandBackSurface <> nil) and cGrayScale then Surface2GrayScale(LandBackSurface) + LandBackSurface:= LoadDataImage(ptCurrTheme, 'LandBackTex', ifIgnoreCaps or ifTransparent); + if (LandBackSurface <> nil) and GrayScale then + Surface2GrayScale(LandBackSurface) end; end; if (tmpsurf <> nil) then @@ -1196,37 +493,40 @@ f: textfile; mapName: shortstring = ''; begin -isMap:= true; WriteLnToConsole('Loading land from file...'); AddProgress; -tmpsurf:= LoadImage(UserPathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); -if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); +tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifTransparent or ifIgnoreCaps); if tmpsurf = nil then begin mapName:= ExtractFileName(Pathz[ptMapCurrent]); - tmpsurf:= LoadImage(UserPathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptMissionMaps] + '/' + mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); + tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps); end; -TryDo((tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT), 'Map dimensions too big!', true); +// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take +TryDo((tmpsurf^.w < $40000000) and (tmpsurf^.h < $40000000) and (tmpsurf^.w * tmpsurf^.h < 6*1024*1024*1024), 'Map dimensions too big!', true); + +ResizeLand(tmpsurf^.w, tmpsurf^.h); // unC0Rr - should this be passed from the GUI? I am not sure which layer does what s:= UserPathz[ptMapCurrent] + '/map.cfg'; -if not FileExists(s) then s:= Pathz[ptMapCurrent] + '/map.cfg'; +if not FileExists(s) then + s:= Pathz[ptMapCurrent] + '/map.cfg'; WriteLnToConsole('Fetching map HH limit'); {$I-} Assign(f, s); filemode:= 0; // readonly Reset(f); if IOResult <> 0 then -begin + begin s:= Pathz[ptMissionMaps] + '/' + mapName + '/map.cfg'; Assign(f, s); Reset(f); -end; + end; Readln(f); -if not eof(f) then Readln(f, MaxHedgehogs); +if not eof(f) then + Readln(f, MaxHedgehogs); {$I+} -if (MaxHedgehogs = 0) then MaxHedgehogs:= 18; +if (MaxHedgehogs = 0) then + MaxHedgehogs:= 18; playHeight:= tmpsurf^.h; playWidth:= tmpsurf^.w; @@ -1271,7 +571,6 @@ hasBorder:= false; LoadThemeConfig; - isMap:= false; // is this not needed any more? lets hope setlength sets also 0s //if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then @@ -1297,7 +596,7 @@ if Land[y, x] <> 0 then begin inc(c); - if c > 200 then // avoid accidental triggering + if c > 1000 then // avoid accidental triggering begin hasBorder:= true; break; @@ -1351,18 +650,21 @@ end; end; -if (GameFlags and gfBottomBorder) <> 0 then DrawBottomBorder; +if (GameFlags and gfBottomBorder) <> 0 then + DrawBottomBorder; -if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false; +if (GameFlags and gfDisableGirders) <> 0 then + hasGirders:= false; -if ((GameFlags and gfForts) = 0) - and (Pathz[ptMapCurrent] = '') - then AddObjects -else AddProgress(); +if ((GameFlags and gfForts) = 0) and (Pathz[ptMapCurrent] = '') then + AddObjects + +else + AddProgress(); FreeLandObjects; -if cGrayScale then +if GrayScale then begin if (cReducedQuality and rqBlurryLand) = 0 then for x:= leftX to rightX do @@ -1372,7 +674,8 @@ w:= round(((w shr RShift and $FF) * RGB_LUMINANCE_RED + (w shr BShift and $FF) * RGB_LUMINANCE_GREEN + (w shr GShift and $FF) * RGB_LUMINANCE_BLUE)); - if w > 255 then w:= 255; + if w > 255 then + w:= 255; w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y,x] and AMask); LandPixels[y,x]:= w or (LandPixels[y, x] and AMask) end @@ -1382,30 +685,41 @@ begin w:= LandPixels[y div 2,x div 2]; w:= ((w shr RShift and $FF) + (w shr BShift and $FF) + (w shr GShift and $FF)) div 3; - if w > 255 then w:= 255; - w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask); + if w > 255 then + w:= 255; + w:= (w and $FF shl RShift) or (w and $FF shl BShift) or (w and $FF shl GShift) or (LandPixels[y div 2,x div 2] and AMask); LandPixels[y,x]:= w or (LandPixels[y div 2, x div 2] and AMask) end end; - -UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT); end; -function GenPreview: TPreview; -var x, y, xx, yy, t, bit, cbit, lh, lw: LongInt; - Preview: TPreview; +procedure GenPreview(out Preview: TPreview); +var rh, rw, ox, oy, x, y, xx, yy, t, bit, cbit, lh, lw: LongInt; begin WriteLnToConsole('Generating preview...'); case cMapGen of 0: GenBlank(EdgeTemplates[SelectTemplate]); - 1: GenMaze; + 1: begin ResizeLand(4096,2048); GenMaze; end; 2: GenDrawnMap; else OutError('Unknown mapgen', true); end; - lh:= LAND_HEIGHT div 128; - lw:= LAND_WIDTH div 32; + // strict scaling needed here since preview assumes a rectangle + rh:= max(LAND_HEIGHT,2048); + rw:= max(LAND_WIDTH,4096); + ox:= 0; + if rw < rh*2 then + begin + rw:= rh*2; + end; + if rh < rw div 2 then rh:= rw * 2; + + ox:= (rw-LAND_WIDTH) div 2; + oy:= rh-LAND_HEIGHT; + + lh:= rh div 128; + lw:= rw div 32; for y:= 0 to 127 do for x:= 0 to 31 do begin @@ -1416,13 +730,13 @@ cbit:= bit * 8; for yy:= y * lh to y * lh + 7 do for xx:= x * lw + cbit to x * lw + cbit + 7 do - if Land[yy, xx] <> 0 then inc(t); + if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0) + and (Land[yy-oy, xx-ox] <> 0) then + inc(t); if t > 8 then Preview[y, x]:= Preview[y, x] or ($80 shr bit); end; end; - - GenPreview:= Preview end; @@ -1440,7 +754,7 @@ begin adler:= 1; for i:= 0 to LAND_HEIGHT-1 do - Adler32Update(adler, @Land[i,0], LAND_WIDTH); + adler:= Adler32Update(adler, @Land[i,0], LAND_WIDTH); s:= 'M' + IntToStr(adler) + cScriptName; chLandCheck(s); @@ -1449,12 +763,14 @@ procedure initModule; begin - RegisterVariable('landcheck', vtCommand, @chLandCheck, false); - RegisterVariable('sendlanddigest', vtCommand, @chSendLandDigest, false); + RegisterVariable('landcheck', @chLandCheck, false); + RegisterVariable('sendlanddigest', @chSendLandDigest, false); LandBackSurface:= nil; digest:= ''; - + LAND_WIDTH:= 0; + LAND_HEIGHT:= 0; +(* if (cReducedQuality and rqBlurryLand) = 0 then SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) else @@ -1462,13 +778,14 @@ SetLength(Land, LAND_HEIGHT, LAND_WIDTH); SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); +*) end; procedure freeModule; begin - Land:= nil; - LandPixels:= nil; - LandDirty:= nil; + SetLength(Land, 0, 0); + SetLength(LandPixels, 0, 0); + SetLength(LandDirty, 0, 0); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandGenMaze.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uLandGenMaze.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,485 @@ +unit uLandGenMaze; + +interface + +procedure GenMaze; + +implementation + +uses uRandom, uLandOutline, uLandTemplates, uVariables, uFloat, uConsts; + +type direction = record x, y: LongInt; end; +const DIR_N: direction = (x: 0; y: -1); + DIR_E: direction = (x: 1; y: 0); + DIR_S: direction = (x: 0; y: 1); + DIR_W: direction = (x: -1; y: 0); + + +operator = (const a, b: direction) c: Boolean; +begin + c := (a.x = b.x) and (a.y = b.y); +end; + +const small_cell_size = 128; + medium_cell_size = 192; + large_cell_size = 256; + braidness = 10; + +var x, y: LongInt; + cellsize: LongInt; //selected by the user in the gui + seen_cells_x, seen_cells_y: LongInt; //number of cells that can be visited by the generator, that is every second cell in x and y direction. the cells between there are walls that will be removed when we move from one cell to another + num_edges_x, num_edges_y: LongInt; //number of resulting edges that need to be vertexificated + num_cells_x, num_cells_y: LongInt; //actual number of cells, depending on cell size + seen_list: array of array of LongInt; + xwalls: array of array of Boolean; + ywalls: array of array of Boolean; + x_edge_list: array of array of Boolean; + y_edge_list: array of array of Boolean; + maze: array of array of Boolean; + pa: TPixAr; + num_vertices: LongInt; + off_y: LongInt; + num_steps: LongInt; + current_step: LongInt; + step_done: array of Boolean; + done: Boolean; + last_cell: array of record x, y: LongInt; end; + came_from: array of array of record x, y: LongInt; end; + came_from_pos: array of LongInt; + maze_inverted: Boolean; + +function when_seen(x: LongInt; y: LongInt): LongInt; +begin +if (x < 0) or (x >= seen_cells_x) or (y < 0) or (y >= seen_cells_y) then + when_seen := current_step +else + when_seen := seen_list[x, y]; +end; + +function is_x_edge(x, y: LongInt): Boolean; +begin +if (x < 0) or (x > num_edges_x) or (y < 0) or (y > num_cells_y) then + is_x_edge := false +else + is_x_edge := x_edge_list[x, y]; +end; + +function is_y_edge(x, y: LongInt): Boolean; +begin +if (x < 0) or (x > num_cells_x) or (y < 0) or (y > num_edges_y) then + is_y_edge := false +else + is_y_edge := y_edge_list[x, y]; +end; + +procedure see_cell; +var dir: direction; + tries: LongInt; + x, y: LongInt; + found_cell: Boolean; + next_dir_clockwise: Boolean; + +begin +x := last_cell[current_step].x; +y := last_cell[current_step].y; +seen_list[x, y] := current_step; +case GetRandom(4) of + 0: dir := DIR_N; + 1: dir := DIR_E; + 2: dir := DIR_S; + 3: dir := DIR_W; +end; +tries := 0; +found_cell := false; +if getrandom(2) = 1 then + next_dir_clockwise := true +else + next_dir_clockwise := false; + +while (tries < 5) and (not found_cell) do +begin + if when_seen(x + dir.x, y + dir.y) = current_step then //we are seeing ourselves, try another direction + begin + //we have already seen the target cell, decide if we should remove the wall anyway + //(or put a wall there if maze_inverted, but we are not doing that right now) + if not maze_inverted and (GetRandom(braidness) = 0) then + //or just warn that inverted+braid+indestructible terrain != good idea + begin + case dir.x of + + -1: + if x > 0 then + ywalls[x-1, y] := false; + 1: + if x < seen_cells_x - 1 then + ywalls[x, y] := false; + end; + case dir.y of + -1: + if y > 0 then + xwalls[x, y-1] := false; + 1: + if y < seen_cells_y - 1 then + xwalls[x, y] := false; + end; + end; + if next_dir_clockwise then + begin + if dir = DIR_N then + dir := DIR_E + else if dir = DIR_E then + dir := DIR_S + else if dir = DIR_S then + dir := DIR_W + else + dir := DIR_N; + end + else + begin + if dir = DIR_N then + dir := DIR_W + else if dir = DIR_E then + dir := DIR_N + else if dir = DIR_S then + dir := DIR_E + else + dir := DIR_S; + end + end + else if when_seen(x + dir.x, y + dir.y) = -1 then //cell was not seen yet, go there + begin + case dir.y of + -1: xwalls[x, y-1] := false; + 1: xwalls[x, y] := false; + end; + case dir.x of + -1: ywalls[x-1, y] := false; + 1: ywalls[x, y] := false; + end; + last_cell[current_step].x := x+dir.x; + last_cell[current_step].y := y+dir.y; + came_from_pos[current_step] := came_from_pos[current_step] + 1; + came_from[current_step, came_from_pos[current_step]].x := x; + came_from[current_step, came_from_pos[current_step]].y := y; + found_cell := true; + end + else //we are seeing someone else, quit + begin + step_done[current_step] := true; + found_cell := true; + end; + + tries := tries + 1; +end; +if not found_cell then + begin + last_cell[current_step].x := came_from[current_step, came_from_pos[current_step]].x; + last_cell[current_step].y := came_from[current_step, came_from_pos[current_step]].y; + came_from_pos[current_step] := came_from_pos[current_step] - 1; + + if came_from_pos[current_step] >= 0 then + see_cell + + else + step_done[current_step] := true; + end; +end; + +procedure add_vertex(x, y: LongInt); +var tmp_x, tmp_y: LongInt; +begin +if x = NTPX then +begin + if pa.ar[num_vertices - 6].x = NTPX then + begin + num_vertices := num_vertices - 6; + end + else + begin + pa.ar[num_vertices].x := NTPX; + pa.ar[num_vertices].y := 0; + end +end +else +begin + if maze_inverted or (x mod 2 = 0) then + tmp_x := cellsize + else + tmp_x := cellsize * 2 div 3; + + if maze_inverted or (y mod 2 = 0) then + tmp_y := cellsize + else + tmp_y := cellsize * 2 div 3; + + pa.ar[num_vertices].x := (x-1)*cellsize + tmp_x; + pa.ar[num_vertices].y := (y-1)*cellsize + tmp_y + off_y; +end; +num_vertices := num_vertices + 1; +end; + +procedure add_edge(x, y: LongInt; dir: direction); +var i: LongInt; +begin +if dir = DIR_N then + begin + dir := DIR_W + end +else if dir = DIR_E then + begin + dir := DIR_N + end +else if dir = DIR_S then + begin + dir := DIR_E + end +else + begin + dir := DIR_S; + end; + +for i := 0 to 3 do + begin + if dir = DIR_N then + dir := DIR_E + else if dir = DIR_E then + dir := DIR_S + else if dir = DIR_S then + dir := DIR_W + else + dir := DIR_N; + +if (dir = DIR_N) and is_x_edge(x, y) then + begin + x_edge_list[x, y] := false; + add_vertex(x+1, y); + add_edge(x, y-1, DIR_N); + break; + end; + +if (dir = DIR_E) and is_y_edge(x+1, y) then + begin + y_edge_list[x+1, y] := false; + add_vertex(x+2, y+1); + add_edge(x+1, y, DIR_E); + break; + end; + +if (dir = DIR_S) and is_x_edge(x, y+1) then + begin + x_edge_list[x, y+1] := false; + add_vertex(x+1, y+2); + add_edge(x, y+1, DIR_S); + break; + end; + +if (dir = DIR_W) and is_y_edge(x, y) then + begin + y_edge_list[x, y] := false; + add_vertex(x, y+1); + add_edge(x-1, y, DIR_W); + break; + end; +end; + +end; + +procedure GenMaze; +begin +case cTemplateFilter of + 0: begin + cellsize := small_cell_size; + maze_inverted := false; + end; + 1: begin + cellsize := medium_cell_size; + maze_inverted := false; + end; + 2: begin + cellsize := large_cell_size; + maze_inverted := false; + end; + 3: begin + cellsize := small_cell_size; + maze_inverted := true; + end; + 4: begin + cellsize := medium_cell_size; + maze_inverted := true; + end; + 5: begin + cellsize := large_cell_size; + maze_inverted := true; + end; +end; + +num_cells_x := LAND_WIDTH div cellsize; +if not odd(num_cells_x) then + num_cells_x := num_cells_x - 1; //needs to be odd + +num_cells_y := LAND_HEIGHT div cellsize; +if not odd(num_cells_y) then + num_cells_y := num_cells_y - 1; + +num_edges_x := num_cells_x - 1; +num_edges_y := num_cells_y - 1; + +seen_cells_x := num_cells_x div 2; +seen_cells_y := num_cells_y div 2; + +if maze_inverted then + num_steps := 3 //TODO randomize, between 3 and 5? +else + num_steps := 1; + +SetLength(step_done, num_steps); +SetLength(last_cell, num_steps); +SetLength(came_from_pos, num_steps); +SetLength(came_from, num_steps, num_cells_x*num_cells_y); +done := false; + +for current_step := 0 to num_steps - 1 do + step_done[current_step] := false; + came_from_pos[current_step] := 0; + +current_step := 0; + +SetLength(seen_list, seen_cells_x, seen_cells_y); +SetLength(xwalls, seen_cells_x, seen_cells_y - 1); +SetLength(ywalls, seen_cells_x - 1, seen_cells_y); +SetLength(x_edge_list, num_edges_x, num_cells_y); +SetLength(y_edge_list, num_cells_x, num_edges_y); +SetLength(maze, num_cells_x, num_cells_y); + +num_vertices := 0; + +playHeight := num_cells_y * cellsize; +playWidth := num_cells_x * cellsize; +off_y := LAND_HEIGHT - playHeight; + +for x := 0 to playWidth do + for y := 0 to off_y - 1 do + Land[y, x] := 0; + +for x := 0 to playWidth do + for y := off_y to LAND_HEIGHT - 1 do + Land[y, x] := lfBasic; + +for y := 0 to num_cells_y - 1 do + for x := 0 to num_cells_x - 1 do + maze[x, y] := false; + +for x := 0 to seen_cells_x - 1 do + for y := 0 to seen_cells_y - 2 do + xwalls[x, y] := true; + +for x := 0 to seen_cells_x - 2 do + for y := 0 to seen_cells_y - 1 do + ywalls[x, y] := true; + +for x := 0 to seen_cells_x - 1 do + for y := 0 to seen_cells_y - 1 do + seen_list[x, y] := -1; + +for x := 0 to num_edges_x - 1 do + for y := 0 to num_cells_y - 1 do + x_edge_list[x, y] := false; + +for x := 0 to num_cells_x - 1 do + for y := 0 to num_edges_y - 1 do + y_edge_list[x, y] := false; + +for current_step := 0 to num_steps-1 do + begin + x := GetRandom(seen_cells_x - 1) div LongWord(num_steps); + last_cell[current_step].x := x + current_step * seen_cells_x div num_steps; + last_cell[current_step].y := GetRandom(seen_cells_y); +end; + +while not done do + begin + done := true; + for current_step := 0 to num_steps-1 do + begin + if not step_done[current_step] then + begin + see_cell; + done := false; + end; + end; +end; + +for x := 0 to seen_cells_x - 1 do + for y := 0 to seen_cells_y - 1 do + if seen_list[x, y] > -1 then + maze[(x+1)*2-1, (y+1)*2-1] := true; + +for x := 0 to seen_cells_x - 1 do + for y := 0 to seen_cells_y - 2 do + if not xwalls[x, y] then + maze[x*2 + 1, y*2 + 2] := true; + + +for x := 0 to seen_cells_x - 2 do + for y := 0 to seen_cells_y - 1 do + if not ywalls[x, y] then + maze[x*2 + 2, y*2 + 1] := true; + +for x := 0 to num_edges_x - 1 do + for y := 0 to num_cells_y - 1 do + if maze[x, y] xor maze[x+1, y] then + x_edge_list[x, y] := true + else + x_edge_list[x, y] := false; + +for x := 0 to num_cells_x - 1 do + for y := 0 to num_edges_y - 1 do + if maze[x, y] xor maze[x, y+1] then + y_edge_list[x, y] := true + else + y_edge_list[x, y] := false; + +for x := 0 to num_edges_x - 1 do + for y := 0 to num_cells_y - 1 do + if x_edge_list[x, y] then + begin + x_edge_list[x, y] := false; + add_vertex(x+1, y+1); + add_vertex(x+1, y); + add_edge(x, y-1, DIR_N); + add_vertex(NTPX, 0); + end; + +pa.count := num_vertices; + +RandomizePoints(pa); +BezierizeEdge(pa, _0_25); +RandomizePoints(pa); +BezierizeEdge(pa, _0_25); + +DrawEdge(pa, 0); + +if maze_inverted then + FillLand(1, 1+off_y) +else + begin + x := 0; + while Land[cellsize div 2 + cellsize + off_y, x] = lfBasic do + x := x + 1; + while Land[cellsize div 2 + cellsize + off_y, x] = 0 do + x := x + 1; + FillLand(x+1, cellsize div 2 + cellsize + off_y); + end; + +MaxHedgehogs:= 32; +if (GameFlags and gfDisableGirders) <> 0 then + hasGirders:= false +else + hasGirders := true; +leftX:= 0; +rightX:= playWidth; +topY:= off_y; +hasBorder := false; +end; + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLandGraphics.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,10 @@ interface uses uFloat, uConsts, uTypes; -type PRangeArray = ^TRangeArray; - TRangeArray = array[0..31] of record +type TRangeArray = array[0..31] of record Left, Right: LongInt; end; + PRangeArray = ^TRangeArray; function addBgColor(OldColor, NewColor: LongWord): LongWord; function SweepDirty: boolean; @@ -36,8 +36,11 @@ procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte); procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt); procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); -procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); +procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean); function LandBackPixel(x, y: LongInt): LongWord; +procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); +procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword); +procedure DumpLandToLog(x, y, r: LongInt); function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean; @@ -56,7 +59,7 @@ begin addBgColor:= NewColor; exit - end; + end; // Get colors oRed := (OldColor shr RShift); oGreen := (OldColor shr GShift); @@ -69,7 +72,7 @@ // Mix colors nRed := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*byte(255-nAlpha)) div 65025)); nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*byte(255-nAlpha)) div 65025)); - nBlue := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*byte(255-nAlpha)) div 65025)); + nBlue := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*byte(255-nAlpha)) div 65025)); nAlpha := min(255, oAlpha + nAlpha); addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift); @@ -83,7 +86,7 @@ if (Land[y + dy, i] and lfIndestructible) = 0 then Land[y + dy, i]:= Value; if ((y - dy) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do if (Land[y - dy, i] and lfIndestructible) = 0 then Land[y - dy, i]:= Value; if ((y + dx) and LAND_HEIGHT_MASK) = 0 then @@ -96,82 +99,107 @@ Land[y - dx, i]:= Value; end; -procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet: boolean); +procedure ChangeCircleLines(x, y, dx, dy: LongInt; doSet, isCurrent: boolean); var i: LongInt; begin if not doSet then - begin - if ((y + dy) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[y + dy, i] > 0) and (Land[y + dy, i] < 256) then dec(Land[y + dy, i]); // check > 0 because explosion can erase collision data - if ((y - dy) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[y - dy, i] > 0) and (Land[y - dy, i] < 256) then dec(Land[y - dy, i]); - if ((y + dx) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[y + dx, i] > 0) and (Land[y + dx, i] < 256) then dec(Land[y + dx, i]); - if ((y - dx) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[y - dx, i] > 0) and (Land[y - dx, i] < 256) then dec(Land[y - dx, i]); - end else - begin - if ((y + dy) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[y + dy, i] < 256) then - inc(Land[y + dy, i]); - if ((y - dy) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[y - dy, i] < 256) then - inc(Land[y - dy, i]); - if ((y + dx) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[y + dx, i] < 256) then - inc(Land[y + dx, i]); - if ((y - dx) and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[y - dx, i] < 256) then - inc(Land[y - dx, i]); - end + begin + if ((y + dy) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if isCurrent then + Land[y + dy, i]:= Land[y + dy, i] and $FF7F + else if Land[y + dy, i] and $007F > 0 then + Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) - 1); + if ((y - dy) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if isCurrent then + Land[y - dy, i]:= Land[y - dy, i] and $FF7F + else if Land[y - dy, i] and $007F > 0 then + Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) - 1); + if ((y + dx) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if isCurrent then + Land[y + dx, i]:= Land[y + dx, i] and $FF7F + else if Land[y + dx, i] and $007F > 0 then + Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) - 1); + if ((y - dx) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if isCurrent then + Land[y - dx, i]:= Land[y - dx, i] and $FF7F + else if Land[y - dx, i] and $007F > 0 then + Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) - 1) + end +else + begin + if ((y + dy) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if isCurrent then + Land[y + dy, i]:= Land[y + dy, i] or $80 + else if Land[y + dy, i] and $007F < 127 then + Land[y + dy, i]:= (Land[y + dy, i] and $FF80) or ((Land[y + dy, i] and $7F) + 1); + if ((y - dy) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if isCurrent then + Land[y - dy, i]:= Land[y - dy, i] or $80 + else if Land[y - dy, i] and $007F < 127 then + Land[y - dy, i]:= (Land[y - dy, i] and $FF80) or ((Land[y - dy, i] and $7F) + 1); + if ((y + dx) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if isCurrent then + Land[y + dx, i]:= Land[y + dx, i] or $80 + else if Land[y + dx, i] and $007F < 127 then + Land[y + dx, i]:= (Land[y + dx, i] and $FF80) or ((Land[y + dx, i] and $7F) + 1); + if ((y - dx) and LAND_HEIGHT_MASK) = 0 then + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if isCurrent then + Land[y - dx, i]:= Land[y - dx, i] or $80 + else if Land[y - dx, i] and $007F < 127 then + Land[y - dx, i]:= (Land[y - dx, i] and $FF80) or ((Land[y - dx, i] and $7F) + 1) + end end; procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword); var dx, dy, d: LongInt; begin - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillCircleLines(x, y, dx, dy, Value); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillCircleLines(x, y, dx, dy, Value); +dx:= 0; +dy:= Radius; +d:= 3 - 2 * Radius; +while (dx < dy) do + begin + FillCircleLines(x, y, dx, dy, Value); + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; +if (dx = dy) then + FillCircleLines(x, y, dx, dy, Value); end; -procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean); +procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet, isCurrent: boolean); var dx, dy, d: LongInt; begin - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - ChangeCircleLines(x, y, dx, dy, doSet); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then ChangeCircleLines(x, y, dx, dy, doSet) +dx:= 0; +dy:= Radius; +d:= 3 - 2 * Radius; +while (dx < dy) do + begin + ChangeCircleLines(x, y, dx, dy, doSet, isCurrent); + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; +if (dx = dy) then + ChangeCircleLines(x, y, dx, dy, doSet, isCurrent) end; procedure FillLandCircleLines0(x, y, dx, dy: LongInt); @@ -222,90 +250,90 @@ cnt:= 0; t:= y + dy; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[t, i] and lfIndestructible) = 0 then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - begin - by:= t; bx:= i; - end - else - begin - by:= t div 2; bx:= i div 2; - end; - if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then - begin - inc(cnt); - LandPixels[by, bx]:= LandBackPixel(i, t) - end - else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then - LandPixels[by, bx]:= 0 - end; + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if (Land[t, i] and lfIndestructible) = 0 then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + by:= t; bx:= i; + end + else + begin + by:= t div 2; bx:= i div 2; + end; + if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then + begin + inc(cnt); + LandPixels[by, bx]:= LandBackPixel(i, t) + end + else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then + LandPixels[by, bx]:= 0 + end; t:= y - dy; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if (Land[t, i] and lfIndestructible) = 0 then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - begin - by:= t; bx:= i; - end - else - begin - by:= t div 2; bx:= i div 2; - end; - if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then - begin - inc(cnt); - LandPixels[by, bx]:= LandBackPixel(i, t) - end - else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then - LandPixels[by, bx]:= 0 - end; + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if (Land[t, i] and lfIndestructible) = 0 then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + by:= t; bx:= i; + end + else + begin + by:= t div 2; bx:= i div 2; + end; + if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then + begin + inc(cnt); + LandPixels[by, bx]:= LandBackPixel(i, t) + end + else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then + LandPixels[by, bx]:= 0 + end; t:= y + dx; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[t, i] and lfIndestructible) = 0 then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - begin - by:= t; bx:= i; - end - else - begin - by:= t div 2; bx:= i div 2; - end; - if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then - begin - inc(cnt); - LandPixels[by, bx]:= LandBackPixel(i, t) - end - else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then - LandPixels[by, bx]:= 0 - end; + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if (Land[t, i] and lfIndestructible) = 0 then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + by:= t; bx:= i; + end + else + begin + by:= t div 2; bx:= i div 2; + end; + if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then + begin + inc(cnt); + LandPixels[by, bx]:= LandBackPixel(i, t) + end + else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then + LandPixels[by, bx]:= 0 + end; t:= y - dx; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if (Land[t, i] and lfIndestructible) = 0 then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - begin - by:= t; bx:= i; - end - else - begin - by:= t div 2; bx:= i div 2; - end; - if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then - begin - inc(cnt); - LandPixels[by, bx]:= LandBackPixel(i, t) - end - else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then - LandPixels[by, bx]:= 0 - end; + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if (Land[t, i] and lfIndestructible) = 0 then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + by:= t; bx:= i; + end + else + begin + by:= t div 2; bx:= i div 2; + end; + if ((Land[t, i] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then + begin + inc(cnt); + LandPixels[by, bx]:= LandBackPixel(i, t) + end + else if ((Land[t, i] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then + LandPixels[by, bx]:= 0 + end; FillLandCircleLinesBG:= cnt; end; @@ -314,62 +342,62 @@ begin t:= y + dy; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[t, i]:= cExplosionBorderColor - else - LandPixels[t div 2, i div 2]:= cExplosionBorderColor; + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[t, i]:= ExplosionBorderColor + else + LandPixels[t div 2, i div 2]:= ExplosionBorderColor; - Land[t, i]:= Land[t, i] or lfDamaged; - //Despeckle(i, t); - LandDirty[t div 32, i div 32]:= 1; - end; + Land[t, i]:= Land[t, i] or lfDamaged; + //Despeckle(i, t); + LandDirty[t div 32, i div 32]:= 1; + end; t:= y - dy; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do - if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[t, i]:= cExplosionBorderColor + for i:= Max(x - dx, 0) to Min(x + dx, LAND_WIDTH - 1) do + if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[t, i]:= ExplosionBorderColor else - LandPixels[t div 2, i div 2]:= cExplosionBorderColor; - Land[t, i]:= Land[t, i] or lfDamaged; - //Despeckle(i, t); - LandDirty[t div 32, i div 32]:= 1; - end; + LandPixels[t div 2, i div 2]:= ExplosionBorderColor; + Land[t, i]:= Land[t, i] or lfDamaged; + //Despeckle(i, t); + LandDirty[t div 32, i div 32]:= 1; + end; t:= y + dx; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[t, i]:= cExplosionBorderColor + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[t, i]:= ExplosionBorderColor else - LandPixels[t div 2, i div 2]:= cExplosionBorderColor; + LandPixels[t div 2, i div 2]:= ExplosionBorderColor; - Land[t, i]:= Land[t, i] or lfDamaged; - //Despeckle(i, t); - LandDirty[t div 32, i div 32]:= 1; - end; + Land[t, i]:= Land[t, i] or lfDamaged; + //Despeckle(i, t); + LandDirty[t div 32, i div 32]:= 1; + end; t:= y - dx; if (t and LAND_HEIGHT_MASK) = 0 then - for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do - if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then - begin - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[t, i]:= cExplosionBorderColor + for i:= Max(x - dy, 0) to Min(x + dy, LAND_WIDTH - 1) do + if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then + begin + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[t, i]:= ExplosionBorderColor else - LandPixels[t div 2, i div 2]:= cExplosionBorderColor; + LandPixels[t div 2, i div 2]:= ExplosionBorderColor; - Land[t, i]:= Land[t, i] or lfDamaged; - //Despeckle(i, y - dy); - LandDirty[t div 32, i div 32]:= 1; - end; + Land[t, i]:= Land[t, i] or lfDamaged; + //Despeckle(i, y - dy); + LandDirty[t div 32, i div 32]:= 1; + end; end; function DrawExplosion(X, Y, Radius: LongInt): Longword; @@ -387,15 +415,17 @@ while (dx < dy) do begin inc(cnt, FillLandCircleLinesBG(x, y, dx, dy)); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin d:= d + 4 * (dx - dy) + 10; dec(dy) end; inc(dx) end; - if (dx = dy) then inc(cnt, FillLandCircleLinesBG(x, y, dx, dy)); + if (dx = dy) then + inc(cnt, FillLandCircleLinesBG(x, y, dx, dy)); end; // draw a hole in land @@ -408,15 +438,17 @@ while (dx < dy) do begin FillLandCircleLines0(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin d:= d + 4 * (dx - dy) + 10; dec(dy) end; inc(dx) end; - if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); + if (dx = dy) then + FillLandCircleLines0(x, y, dx, dy); end; // FillRoundInLand after erasing land pixels to allow Land 0 check for mask.png to function @@ -431,22 +463,24 @@ while (dx < dy) do begin FillLandCircleLinesEBC(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin d:= d + 4 * (dx - dy) + 10; dec(dy) end; inc(dx) end; - if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); + if (dx = dy) then + FillLandCircleLinesEBC(x, y, dx, dy); end; tx:= Max(X - Radius - 1, 0); dx:= Min(X + Radius + 1, LAND_WIDTH) - tx; ty:= Max(Y - Radius - 1, 0); dy:= Min(Y + Radius + 1, LAND_HEIGHT) - ty; -UpdateLandTexture(tx, dx, ty, dy); +UpdateLandTexture(tx, dx, ty, dy, false); DrawExplosion:= cnt end; @@ -468,9 +502,9 @@ begin by:= ty div 2; bx:= tx div 2; end; - if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then + if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then LandPixels[by, bx]:= LandBackPixel(tx, ty) - else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then + else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then LandPixels[by, bx]:= 0 end end; @@ -486,10 +520,10 @@ for tx:= Max(0, ar^[i].Left - Radius) to Min(LAND_WIDTH, ar^[i].Right + Radius) do if ((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0) then begin - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[ty, tx]:= cExplosionBorderColor - else - LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor; + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[ty, tx]:= ExplosionBorderColor + else + LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor; Land[ty, tx]:= Land[ty, tx] or lfDamaged; LandDirty[ty div 32, tx div 32]:= 1; @@ -498,7 +532,7 @@ end; -UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT) +UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false) end; // @@ -529,19 +563,19 @@ Y:= Y + dY; tx:= hwRound(X); ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - (((Land[ty, tx] and lfBasic) <> 0) or - ((Land[ty, tx] and lfObject) <> 0)) then + if ((ty and LAND_HEIGHT_MASK) = 0) + and ((tx and LAND_WIDTH_MASK) = 0) + and (((Land[ty, tx] and lfBasic) <> 0) or ((Land[ty, tx] and lfObject) <> 0)) then begin - if despeckle then + if despeckle then begin Land[ty, tx]:= Land[ty, tx] or lfDamaged; LandDirty[ty div 32, tx div 32]:= 1 end; if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[ty, tx]:= cExplosionBorderColor - else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor + LandPixels[ty, tx]:= ExplosionBorderColor + else + LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor end end; nx:= nx - dY; @@ -553,23 +587,23 @@ X:= nx - dX8; Y:= ny - dY8; for t:= 0 to 7 do - begin - X:= X + dX; - Y:= Y + dY; - tx:= hwRound(X); - ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - (((Land[ty, tx] and lfBasic) <> 0) or - ((Land[ty, tx] and lfObject) <> 0)) then begin - Land[ty, tx]:= Land[ty, tx] or lfDamaged; - if despeckle then LandDirty[ty div 32, tx div 32]:= 1; - if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[ty, tx]:= cExplosionBorderColor - else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor - end - end; + X:= X + dX; + Y:= Y + dY; + tx:= hwRound(X); + ty:= hwRound(Y); + if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0) + or ((Land[ty, tx] and lfObject) <> 0)) then + begin + Land[ty, tx]:= Land[ty, tx] or lfDamaged; + if despeckle then + LandDirty[ty div 32, tx div 32]:= 1; + if (cReducedQuality and rqBlurryLand) = 0 then + LandPixels[ty, tx]:= ExplosionBorderColor + else + LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor + end + end; X:= nx; Y:= ny; for t:= 0 to ticks do @@ -588,7 +622,7 @@ begin by:= ty div 2; bx:= tx div 2; end; - if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and not disableLandBack then + if ((Land[ty, tx] and lfBasic) <> 0) and (((LandPixels[by,bx] and AMask) shr AShift) = 255) and (not disableLandBack) then LandPixels[by, bx]:= LandBackPixel(tx, ty) else if ((Land[ty, tx] and lfObject) <> 0) or (((LandPixels[by,bx] and AMask) shr AShift) < 255) then LandPixels[by, bx]:= 0; @@ -601,18 +635,18 @@ Y:= Y + dY; tx:= hwRound(X); ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - (((Land[ty, tx] and lfBasic) <> 0) or - ((Land[ty, tx] and lfObject) <> 0)) then + if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0) + or ((Land[ty, tx] and lfObject) <> 0)) then begin Land[ty, tx]:= Land[ty, tx] or lfDamaged; - if despeckle then LandDirty[ty div 32, tx div 32]:= 1; + if despeckle then + LandDirty[ty div 32, tx div 32]:= 1; if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[ty, tx]:= cExplosionBorderColor - else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor + LandPixels[ty, tx]:= ExplosionBorderColor + else + LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor end - end; + end; nx:= nx - dY; ny:= ny + dX; end; @@ -627,16 +661,16 @@ Y:= Y + dY; tx:= hwRound(X); ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - (((Land[ty, tx] and lfBasic) <> 0) or - ((Land[ty, tx] and lfObject) <> 0)) then + if ((ty and LAND_HEIGHT_MASK) = 0) and ((tx and LAND_WIDTH_MASK) = 0) and (((Land[ty, tx] and lfBasic) <> 0) + or ((Land[ty, tx] and lfObject) <> 0)) then begin Land[ty, tx]:= Land[ty, tx] or lfDamaged; - if despeckle then LandDirty[ty div 32, tx div 32]:= 1; + if despeckle then + LandDirty[ty div 32, tx div 32]:= 1; if (cReducedQuality and rqBlurryLand) = 0 then - LandPixels[ty, tx]:= cExplosionBorderColor - else LandPixels[ty div 2, tx div 2]:= cExplosionBorderColor + LandPixels[ty, tx]:= ExplosionBorderColor + else + LandPixels[ty div 2, tx div 2]:= ExplosionBorderColor end end; nx:= nx - dY; @@ -648,7 +682,7 @@ ddx:= Min(stX + HalfWidth * 2 + 4 + abs(hwRound(dX * ticks)), LAND_WIDTH) - tx; ddy:= Min(stY + HalfWidth * 2 + 4 + abs(hwRound(dY * ticks)), LAND_HEIGHT) - ty; -UpdateLandTexture(tx, ddx, ty, ddy) +UpdateLandTexture(tx, ddx, ty, ddy, false) end; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean; @@ -656,6 +690,7 @@ p: PByteArray; Image: PSDL_Surface; begin +TryPlaceOnLand:= false; numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height; TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true); @@ -666,205 +701,220 @@ col:= Frame div numFramesFirstCol; if SDL_MustLock(Image) then - SDLTry(SDL_LockSurface(Image) >= 0, true); + SDLTry(SDL_LockSurface(Image) >= 0, true); bpp:= Image^.format^.BytesPerPixel; TryDo(bpp = 4, 'It should be 32 bpp sprite', true); // Check that sprite fits free space p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); case bpp of - 4: for y:= 0 to Pred(h) do - begin - for x:= 0 to Pred(w) do - if PLongword(@(p^[x * 4]))^ <> 0 then - if ((cpY + y) <= Longint(topY)) or - ((cpY + y) >= LAND_HEIGHT) or - ((cpX + x) <= Longint(leftX)) or - ((cpX + x) >= Longint(rightX)) or - (Land[cpY + y, cpX + x] <> 0) then - begin - if SDL_MustLock(Image) then - SDL_UnlockSurface(Image); - exit(false) - end; - p:= @(p^[Image^.pitch]); - end; - end; + 4: for y:= 0 to Pred(h) do + begin + for x:= 0 to Pred(w) do + if (PLongword(@(p^[x * 4]))^) <> 0 then + if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or + ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or (Land[cpY + y, cpX + x] <> 0) then + begin + if SDL_MustLock(Image) then + SDL_UnlockSurface(Image); + exit; + end; + p:= @(p^[Image^.pitch]); + end; + end; TryPlaceOnLand:= true; if not doPlace then - begin - if SDL_MustLock(Image) then - SDL_UnlockSurface(Image); - exit - end; + begin + if SDL_MustLock(Image) then + SDL_UnlockSurface(Image); + exit + end; // Checked, now place p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 ]); case bpp of - 4: for y:= 0 to Pred(h) do - begin - for x:= 0 to Pred(w) do - if PLongword(@(p^[x * 4]))^ <> 0 then + 4: for y:= 0 to Pred(h) do + begin + for x:= 0 to Pred(w) do + if (PLongword(@(p^[x * 4]))^) <> 0 then begin - if (cReducedQuality and rqBlurryLand) = 0 then - begin - gX:= cpX + x; - gY:= cpY + y; - end - else - begin - gX:= (cpX + x) div 2; - gY:= (cpY + y) div 2; - end; - if indestructible then - Land[cpY + y, cpX + x]:= lfIndestructible - else if (LandPixels[gY, gX] and AMask) shr AShift = 255 then // This test assumes lfBasic and lfObject differ only graphically - Land[cpY + y, cpX + x]:= lfBasic - else - Land[cpY + y, cpX + x]:= lfObject; - // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun - if (Theme = 'Snow') or (Theme = 'Christmas') then Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or lfIce; - LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ - end; - p:= @(p^[Image^.pitch]); - end; - end; + if (cReducedQuality and rqBlurryLand) = 0 then + begin + gX:= cpX + x; + gY:= cpY + y; + end + else + begin + gX:= (cpX + x) div 2; + gY:= (cpY + y) div 2; + end; + if indestructible then + Land[cpY + y, cpX + x]:= lfIndestructible + else if (LandPixels[gY, gX] and AMask) shr AShift = 255 then // This test assumes lfBasic and lfObject differ only graphically + Land[cpY + y, cpX + x]:= lfBasic + else + Land[cpY + y, cpX + x]:= lfObject; + // For testing only. Intent is to flag this on objects with masks, or use it for an ice ray gun + if (Theme = 'Snow') or (Theme = 'Christmas') then + Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or lfIce; + LandPixels[gY, gX]:= PLongword(@(p^[x * 4]))^ + end; + p:= @(p^[Image^.pitch]); + end; + end; if SDL_MustLock(Image) then - SDL_UnlockSurface(Image); + SDL_UnlockSurface(Image); x:= Max(cpX, leftX); w:= Min(cpX + Image^.w, LAND_WIDTH) - x; y:= Max(cpY, topY); h:= Min(cpY + Image^.h, LAND_HEIGHT) - y; -UpdateLandTexture(x, w, y, h) +UpdateLandTexture(x, w, y, h, true) end; function Despeckle(X, Y: LongInt): boolean; var nx, ny, i, j, c, xx, yy: LongInt; pixelsweep: boolean; begin -if (cReducedQuality and rqBlurryLand) = 0 then - begin - xx:= X; - yy:= Y; - end -else - begin - xx:= X div 2; - yy:= Y div 2; - end; -pixelsweep:= ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0); -if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then + Despeckle:= true; + + if (cReducedQuality and rqBlurryLand) = 0 then + begin + xx:= X; + yy:= Y; + end + else + begin + xx:= X div 2; + yy:= Y div 2; + end; + + pixelsweep:= ((Land[Y, X] and $FF00) = 0) and (LandPixels[yy, xx] <> 0); + if (((Land[Y, X] and lfDamaged) <> 0) and ((Land[Y, X] and lfIndestructible) = 0)) or pixelsweep then begin - c:= 0; - for i:= -1 to 1 do - for j:= -1 to 1 do - if (i <> 0) or (j <> 0) then + c:= 0; + for i:= -1 to 1 do + for j:= -1 to 1 do + if (i <> 0) or (j <> 0) then begin - ny:= Y + i; - nx:= X + j; - if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then + ny:= Y + i; + nx:= X + j; + if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then begin - if pixelsweep then + if pixelsweep then begin - if ((cReducedQuality and rqBlurryLand) <> 0) then + if ((cReducedQuality and rqBlurryLand) <> 0) then begin - nx:= nx div 2; - ny:= ny div 2 + nx:= nx div 2; + ny:= ny div 2 end; - if LandPixels[ny, nx] <> 0 then inc(c); + if LandPixels[ny, nx] <> 0 then + inc(c); end - else if Land[ny, nx] > 255 then inc(c); + else if Land[ny, nx] > 255 then + inc(c); end end; - if c < 4 then // 0-3 neighbours + if c < 4 then // 0-3 neighbours begin - if ((Land[Y, X] and lfBasic) <> 0) and not disableLandBack then - LandPixels[yy, xx]:= LandBackPixel(X, Y) - else - LandPixels[yy, xx]:= 0; + if ((Land[Y, X] and lfBasic) <> 0) and (not disableLandBack) then + LandPixels[yy, xx]:= LandBackPixel(X, Y) + else + LandPixels[yy, xx]:= 0; - Land[Y, X]:= 0; - if not pixelsweep then exit(true); + if not pixelsweep then + begin + Land[Y, X]:= 0; + exit + end end; end; -Despeckle:= false + Despeckle:= false end; procedure Smooth(X, Y: LongInt); begin // a bit of AA for explosions -if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and - (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then +if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and + (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then begin - if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then + if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then begin if (cReducedQuality and rqBlurryLand) = 0 then begin - if ((LandPixels[y,x] and AMask) shr AShift) < 10 then LandPixels[y,x]:= (cExplosionBorderColor and not AMask) or (128 shl AShift) + if ((LandPixels[y,x] and AMask) shr AShift) < 10 then + LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (128 shl AShift) else LandPixels[y,x]:= - (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or - (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or - (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) + (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or + (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or + (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) end; - if (Land[y, x-1] = lfObject) then Land[y,x]:= lfObject - else if (Land[y, x+1] = lfObject) then Land[y,x]:= lfObject - else Land[y,x]:= lfBasic; + if (Land[y, x-1] = lfObject) then + Land[y,x]:= lfObject + else if (Land[y, x+1] = lfObject) then + Land[y,x]:= lfObject + else + Land[y,x]:= lfBasic; end - else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or - (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or - (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or - (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or - (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) or - (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then + else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) + or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) + or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) + or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) + or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) + or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then begin if (cReducedQuality and rqBlurryLand) = 0 then begin - if ((LandPixels[y,x] and AMask) shr AShift) < 10 then LandPixels[y,x]:= (cExplosionBorderColor and not AMask) or (64 shl AShift) + if ((LandPixels[y,x] and AMask) shr AShift) < 10 then + LandPixels[y,x]:= (ExplosionBorderColor and (not AMask)) or (64 shl AShift) else LandPixels[y,x]:= - (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or - (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or - (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) + (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or + (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or + (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) end; - if (Land[y, x-1] = lfObject) then Land[y, x]:= lfObject - else if (Land[y, x+1] = lfObject) then Land[y, x]:= lfObject - else if (Land[y+1, x] = lfObject) then Land[y, x]:= lfObject - else if (Land[y-1, x] = lfObject) then Land[y, x]:= lfObject + if (Land[y, x-1] = lfObject) then + Land[y, x]:= lfObject + else if (Land[y, x+1] = lfObject) then + Land[y, x]:= lfObject + else if (Land[y+1, x] = lfObject) then + Land[y, x]:= lfObject + else if (Land[y-1, x] = lfObject) then + Land[y, x]:= lfObject else Land[y,x]:= lfBasic end end -else if ((cReducedQuality and rqBlurryLand) = 0) and (LandPixels[Y, X] and AMask = 255) and - ((Land[Y, X] and (lfDamaged or lfBasic) = lfBasic) or (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)) and - (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then +else if ((cReducedQuality and rqBlurryLand) = 0) and (LandPixels[Y, X] and AMask = 255) +and ((Land[Y, X] and (lfDamaged or lfBasic) = lfBasic) or (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)) +and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then begin - if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then + if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then begin LandPixels[y,x]:= - (((((LandPixels[y,x] and RMask shr RShift) div 2)+((cExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or - (((((LandPixels[y,x] and GMask shr GShift) div 2)+((cExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or - (((((LandPixels[y,x] and BMask shr BShift) div 2)+((cExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) + (((((LandPixels[y,x] and RMask shr RShift) div 2)+((ExplosionBorderColor and RMask) shr RShift) div 2) and $FF) shl RShift) or + (((((LandPixels[y,x] and GMask shr GShift) div 2)+((ExplosionBorderColor and GMask) shr GShift) div 2) and $FF) shl GShift) or + (((((LandPixels[y,x] and BMask shr BShift) div 2)+((ExplosionBorderColor and BMask) shr BShift) div 2) and $FF) shl BShift) or ($FF shl AShift) end - else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or - (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) or - (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) or - (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or - (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) or - (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) or - (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then + else if ((((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) + or (((Land[y, x-1] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y+2,x] and lfDamaged) <> 0)) + or (((Land[y, x+1] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y-2,x] and lfDamaged) <> 0)) + or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) + or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x+1] and lfDamaged) <> 0) and ((Land[y,x+2] and lfDamaged) <> 0)) + or (((Land[y+1, x] and lfDamaged) <> 0) and ((Land[y+1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0)) + or (((Land[y-1, x] and lfDamaged) <> 0) and ((Land[y-1,x-1] and lfDamaged) <> 0) and ((Land[y,x-2] and lfDamaged) <> 0))) then begin LandPixels[y,x]:= - (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((cExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or - (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((cExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or - (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((cExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) + (((((LandPixels[y,x] and RMask shr RShift) * 3 div 4)+((ExplosionBorderColor and RMask) shr RShift) div 4) and $FF) shl RShift) or + (((((LandPixels[y,x] and GMask shr GShift) * 3 div 4)+((ExplosionBorderColor and GMask) shr GShift) div 4) and $FF) shl GShift) or + (((((LandPixels[y,x] and BMask shr BShift) * 3 div 4)+((ExplosionBorderColor and BMask) shr BShift) div 4) and $FF) shl BShift) or ($FF shl AShift) end end end; @@ -921,7 +971,8 @@ end end; end; - if updateBlock then UpdateLandTexture(tx, 32, ty, 32); + if updateBlock then + UpdateLandTexture(tx, 32, ty, 32, false); LandDirty[y, x]:= 2; end; end; @@ -947,19 +998,204 @@ // Return true if outside of land or not the value tested, used right now for some X/Y movement that does not use normal hedgehog movement in GSHandlers.inc function CheckLandValue(X, Y: LongInt; LandFlag: Word): boolean; inline; begin - CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0) + CheckLandValue:= ((X and LAND_WIDTH_MASK <> 0) or (Y and LAND_HEIGHT_MASK <> 0)) or ((Land[Y, X] and LandFlag) = 0) end; function LandBackPixel(x, y: LongInt): LongWord; inline; var p: PLongWordArray; begin - if LandBackSurface = nil then LandBackPixel:= 0 + if LandBackSurface = nil then + LandBackPixel:= 0 else - begin + begin p:= LandBackSurface^.pixels; LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; + end +end; + + +procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword); +var + eX, eY, dX, dY: LongInt; + i, sX, sY, x, y, d: LongInt; +begin +eX:= 0; +eY:= 0; +dX:= X2 - X1; +dY:= Y2 - Y1; + +if (dX > 0) then + sX:= 1 +else + if (dX < 0) then + begin + sX:= -1; + dX:= -dX + end + else + sX:= dX; + +if (dY > 0) then + sY:= 1 +else + if (dY < 0) then + begin + sY:= -1; + dY:= -dY + end + else + sY:= dY; + +if (dX > dY) then + d:= dX +else + d:= dY; + +x:= X1; +y:= Y1; + +for i:= 0 to d do + begin + inc(eX, dX); + inc(eY, dY); + if (eX > d) then + begin + dec(eX, d); + inc(x, sX); + end; + if (eY > d) then + begin + dec(eY, d); + inc(y, sY); + end; + + if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then + Land[y, x]:= Color; end end; +procedure DrawDots(x, y, xx, yy: Longint; Color: Longword); inline; +begin + if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) then Land[y + yy, x + xx]:= Color; + if (((x + xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) then Land[y - yy, x + xx]:= Color; + if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y + yy) and LAND_HEIGHT_MASK) = 0) then Land[y + yy, x - xx]:= Color; + if (((x - xx) and LAND_WIDTH_MASK) = 0) and (((y - yy) and LAND_HEIGHT_MASK) = 0) then Land[y - yy, x - xx]:= Color; + if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) then Land[y + xx, x + yy]:= Color; + if (((x + yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) then Land[y - xx, x + yy]:= Color; + if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y + xx) and LAND_HEIGHT_MASK) = 0) then Land[y + xx, x - yy]:= Color; + if (((x - yy) and LAND_WIDTH_MASK) = 0) and (((y - xx) and LAND_HEIGHT_MASK) = 0) then Land[y - xx, x - yy]:= Color; +end; + +procedure DrawLines(X1, Y1, X2, Y2, XX, YY: LongInt; color: Longword); +var + eX, eY, dX, dY: LongInt; + i, sX, sY, x, y, d: LongInt; + f: boolean; +begin + eX:= 0; + eY:= 0; + dX:= X2 - X1; + dY:= Y2 - Y1; + + if (dX > 0) then + sX:= 1 + else + if (dX < 0) then + begin + sX:= -1; + dX:= -dX + end + else + sX:= dX; + + if (dY > 0) then + sY:= 1 + else + if (dY < 0) then + begin + sY:= -1; + dY:= -dY + end + else + sY:= dY; + + if (dX > dY) then + d:= dX + else + d:= dY; + + x:= X1; + y:= Y1; + + for i:= 0 to d do + begin + inc(eX, dX); + inc(eY, dY); + + f:= eX > d; + if f then + begin + dec(eX, d); + inc(x, sX); + DrawDots(x, y, xx, yy, color) + end; + if (eY > d) then + begin + dec(eY, d); + inc(y, sY); + f:= true; + DrawDots(x, y, xx, yy, color) + end; + + if not f then + DrawDots(x, y, xx, yy, color) + end +end; + +procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword); +var dx, dy, d: LongInt; +begin + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; + while (dx < dy) do + begin + DrawLines(x1, y1, x2, y2, dx, dy, color); + if (d < 0) then + d:= d + 4 * dx + 6 + else + begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then + DrawLines(x1, y1, x2, y2, dx, dy, color); +end; + + +procedure DumpLandToLog(x, y, r: LongInt); +var xx, yy, dx: LongInt; + s: shortstring; +begin + s[0]:= char(r * 2 + 1); + for yy:= y - r to y + r do + begin + for dx:= 0 to r*2 do + begin + xx:= dx - r + x; + if (xx = x) and (yy = y) then + s[dx + 1]:= 'X' + else if Land[yy, xx] > 255 then + s[dx + 1]:= 'O' + else if Land[yy, xx] > 0 then + s[dx + 1]:= '*' + else + s[dx + 1]:= '.' + end; + AddFileLog('Land dump: ' + s); + end; +end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLandObjects.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,36 +25,37 @@ procedure AddObjects(); procedure FreeLandObjects(); procedure LoadThemeConfig; -procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word = 0); +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline; +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word); procedure AddOnLandObjects(Surface: PSDL_Surface); implementation uses uStore, uConsts, uConsole, uRandom, uSound, GLunit, - uTypes, uVariables, uUtils, uDebug, sysutils; + uTypes, uVariables, uUtils, uDebug, SysUtils; const MaxRects = 512; MAXOBJECTRECTS = 16; MAXTHEMEOBJECTS = 32; -type PRectArray = ^TRectsArray; - TRectsArray = array[0..MaxRects] of TSDL_Rect; +type TRectsArray = array[0..MaxRects] of TSDL_Rect; + PRectArray = ^TRectsArray; TThemeObject = record - Surf: PSDL_Surface; - inland: TSDL_Rect; - outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; - rectcnt: Longword; - Width, Height: Longword; - Maxcnt: Longword; - end; + Surf: PSDL_Surface; + inland: TSDL_Rect; + outland: array[0..Pred(MAXOBJECTRECTS)] of TSDL_Rect; + rectcnt: Longword; + Width, Height: Longword; + Maxcnt: Longword; + end; TThemeObjects = record Count: LongInt; objs: array[0..Pred(MAXTHEMEOBJECTS)] of TThemeObject; end; TSprayObject = record - Surf: PSDL_Surface; - Width, Height: Longword; - Maxcnt: Longword; - end; + Surf: PSDL_Surface; + Width, Height: Longword; + Maxcnt: Longword; + end; TSprayObjects = record Count: LongInt; objs: array[0..Pred(MAXTHEMEOBJECTS)] of TSprayObject @@ -65,8 +66,12 @@ ThemeObjects: TThemeObjects; SprayObjects: TSprayObjects; - -procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word = 0); +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface); inline; +begin + BlitImageAndGenerateCollisionInfo(cpX, cpY, Width, Image, 0); +end; + +procedure BlitImageAndGenerateCollisionInfo(cpX, cpY, Width: Longword; Image: PSDL_Surface; extraFlags: Word); var p: PLongwordArray; x, y: Longword; bpp: LongInt; @@ -74,52 +79,53 @@ WriteToConsole('Generating collision info... '); if SDL_MustLock(Image) then - SDLTry(SDL_LockSurface(Image) >= 0, true); + SDLTry(SDL_LockSurface(Image) >= 0, true); bpp:= Image^.format^.BytesPerPixel; TryDo(bpp = 4, 'Land object should be 32bit', true); -if Width = 0 then Width:= Image^.w; +if Width = 0 then + Width:= Image^.w; p:= Image^.pixels; for y:= 0 to Pred(Image^.h) do begin for x:= 0 to Pred(Width) do - begin - if (cReducedQuality and rqBlurryLand) = 0 then + if (p^[x] and AMask) <> 0 then begin - if (LandPixels[cpY + y, cpX + x] = 0) or - (((p^[x] and AMask) <> 0) and (((LandPixels[cpY + y, cpX + x] and AMask) shr AShift) < 255)) then + if (cReducedQuality and rqBlurryLand) = 0 then + begin + if (LandPixels[cpY + y, cpX + x] = 0) + or (((p^[x] and AMask) <> 0) and (((LandPixels[cpY + y, cpX + x] and AMask) shr AShift) < 255)) then LandPixels[cpY + y, cpX + x]:= p^[x]; - end + end else if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x]; - - if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then - begin - Land[cpY + y, cpX + x]:= lfObject; - Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or extraFlags + if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then + begin + Land[cpY + y, cpX + x]:= lfObject; + Land[cpY + y, cpX + x]:= Land[cpY + y, cpX + x] or extraFlags + end; end; - end; p:= @(p^[Image^.pitch shr 2]) end; if SDL_MustLock(Image) then - SDL_UnlockSurface(Image); + SDL_UnlockSurface(Image); WriteLnToConsole(msgOK) end; procedure AddRect(x1, y1, w1, h1: LongInt); begin with Rects^[RectCount] do - begin - x:= x1; - y:= y1; - w:= w1; - h:= h1 - end; + begin + x:= x1; + y:= y1; + w:= w1; + h:= h1 + end; inc(RectCount); TryDo(RectCount < MaxRects, 'AddRect: overflow', true) end; @@ -142,31 +148,31 @@ i:= 0; if RectCount > 0 then - repeat - with Rects^[i] do - res:= (x < x1 + w1) and (x1 < x + w) and - (y < y1 + h1) and (y1 < y + h); - inc(i) - until (i = RectCount) or (res); + repeat + with Rects^[i] do + res:= (x < x1 + w1) and (x1 < x + w) and (y < y1 + h1) and (y1 < y + h); + inc(i) + until (i = RectCount) or (res); CheckIntersect:= res; end; + +function CountNonZeroz(x, y: LongInt): Longword; +var i: LongInt; + lRes: Longword; +begin + lRes:= 0; + for i:= y to y + 15 do + if Land[i, x] <> 0 then + inc(lRes); + CountNonZeroz:= lRes; +end; + function AddGirder(gX: LongInt): boolean; var tmpsurf: PSDL_Surface; x1, x2, y, k, i: LongInt; rr: TSDL_Rect; bRes: boolean; - - function CountNonZeroz(x, y: LongInt): Longword; - var i: LongInt; - lRes: Longword; - begin - lRes:= 0; - for i:= y to y + 15 do - if Land[i, x] <> 0 then inc(lRes); - CountNonZeroz:= lRes; - end; - begin y:= topY+150; repeat @@ -174,7 +180,8 @@ x1:= gX; x2:= gX; - while (x1 > Longint(leftX)+150) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); + while (x1 > Longint(leftX)+150) and (CountNonZeroz(x1, y) = 0) do + dec(x1, 2); i:= x1 - 12; repeat @@ -185,14 +192,17 @@ inc(x1, 2); if k = 16 then begin - while (x2 < (rightX-150)) and (CountNonZeroz(x2, y) = 0) do inc(x2, 2); + while (x2 < (rightX-150)) and (CountNonZeroz(x2, y) = 0) do + inc(x2, 2); i:= x2 + 12; repeat inc(x2, 2); k:= CountNonZeroz(x2, y) until (x2 >= (rightX-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768); + if (x2 < (rightX - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768) - and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break; + and (not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144)) then + break; end; x1:= 0; until y > (LAND_HEIGHT-125); @@ -200,10 +210,7 @@ if x1 > 0 then begin bRes:= true; - tmpsurf:= LoadImage(UserPathz[ptCurrTheme] + '/Girder', ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Girder', ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/Girder', ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps); + tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps); rr.x:= x1; while rr.x < x2 do @@ -236,25 +243,25 @@ tmpx:= rect.x; tmpx2:= bx; while (tmpx <= bx - rect.w div 2 - 1) and bRes do - begin - bRes:= ((rect.y and LAND_HEIGHT_MASK) = 0) and ((by and LAND_HEIGHT_MASK) = 0) and - ((tmpx and LAND_WIDTH_MASK) = 0) and ((tmpx2 and LAND_WIDTH_MASK) = 0) and - (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) and - (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color); - inc(tmpx); - dec(tmpx2) - end; + begin + bRes:= ((rect.y and LAND_HEIGHT_MASK) = 0) and ((by and LAND_HEIGHT_MASK) = 0) + and ((tmpx and LAND_WIDTH_MASK) = 0) and ((tmpx2 and LAND_WIDTH_MASK) = 0) + and (Land[rect.y, tmpx] = Color) and (Land[by, tmpx] = Color) + and (Land[rect.y, tmpx2] = Color) and (Land[by, tmpx2] = Color); + inc(tmpx); + dec(tmpx2) + end; tmpy:= rect.y+1; tmpy2:= by-1; while (tmpy <= by - rect.h div 2 - 1) and bRes do - begin - bRes:= ((tmpy and LAND_HEIGHT_MASK) = 0) and ((tmpy2 and LAND_HEIGHT_MASK) = 0) and - ((rect.x and LAND_WIDTH_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) and - (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) and - (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color); - inc(tmpy); - dec(tmpy2) - end; + begin + bRes:= ((tmpy and LAND_HEIGHT_MASK) = 0) and ((tmpy2 and LAND_HEIGHT_MASK) = 0) + and ((rect.x and LAND_WIDTH_MASK) = 0) and ((bx and LAND_WIDTH_MASK) = 0) + and (Land[tmpy, rect.x] = Color) and (Land[tmpy, bx] = Color) + and (Land[tmpy2, rect.x] = Color) and (Land[tmpy2, bx] = Color); + inc(tmpy); + dec(tmpy2) + end; {$WARNINGS ON} CheckLand:= bRes; end; @@ -264,18 +271,19 @@ bRes: boolean; begin with Obj do - if CheckLand(inland, x, y, lfBasic) then + if CheckLand(inland, x, y, lfBasic) then begin bRes:= true; i:= 1; while bRes and (i <= rectcnt) do - begin - bRes:= CheckLand(outland[i], x, y, 0); - inc(i) - end; + begin + bRes:= CheckLand(outland[i], x, y, 0); + inc(i) + end; if bRes then - bRes:= not CheckIntersect(x, y, Width, Height) - end else + bRes:= not CheckIntersect(x, y, Width, Height) + end + else bRes:= false; CheckCanPlace:= bRes; end; @@ -287,39 +295,41 @@ cnt, i: Longword; bRes: boolean; begin +TryPut:= false; cnt:= 0; with Obj do - begin - if Maxcnt = 0 then - exit(false); - x:= 0; - repeat - y:= topY+32; // leave room for a hedgie to teleport in - repeat - if CheckCanPlace(x, y, Obj) then + begin + if Maxcnt = 0 then + exit; + x:= 0; + repeat + y:= topY+32; // leave room for a hedgie to teleport in + repeat + if CheckCanPlace(x, y, Obj) then begin ar[cnt].x:= x; ar[cnt].y:= y; inc(cnt); if cnt > MaxPointsIndex then // buffer is full, do not check the rest land - begin - y:= 5000; - x:= 5000; - end + begin + y:= 5000; + x:= 5000; + end end; - inc(y, 3); - until y >= LAND_HEIGHT - Height; - inc(x, getrandom(6) + 3) - until x >= LAND_WIDTH - Width; - bRes:= cnt <> 0; - if bRes then + inc(y, 3); + until y >= LAND_HEIGHT - Height; + inc(x, getrandom(6) + 3) + until x >= LAND_WIDTH - Width; + bRes:= cnt <> 0; + if bRes then begin i:= getrandom(cnt); BlitImageAndGenerateCollisionInfo(ar[i].x, ar[i].y, 0, Obj.Surf); AddRect(ar[i].x, ar[i].y, Width, Height); dec(Maxcnt) - end else Maxcnt:= 0 - end; + end + else Maxcnt:= 0 + end; TryPut:= bRes; end; @@ -331,11 +341,12 @@ r: TSDL_Rect; bRes: boolean; begin +TryPut:= false; cnt:= 0; with Obj do begin if Maxcnt = 0 then - exit(false); + exit; x:= 0; r.x:= 0; r.y:= 0; @@ -345,17 +356,17 @@ y:= 8; repeat if CheckLand(r, x, y - 8, lfBasic) - and not CheckIntersect(x, y, Width, Height) then - begin - ar[cnt].x:= x; - ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + and (not CheckIntersect(x, y, Width, Height)) then begin - y:= 5000; - x:= 5000; - end - end; + ar[cnt].x:= x; + ar[cnt].y:= y; + inc(cnt); + if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + begin + y:= 5000; + x:= 5000; + end + end; inc(y, 12); until y >= LAND_HEIGHT - Height - 8; inc(x, getrandom(12) + 12) @@ -371,34 +382,38 @@ SDL_UpperBlit(Obj.Surf, nil, Surface, @r); AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64); dec(Maxcnt) - end else Maxcnt:= 0 + end + else Maxcnt:= 0 end; TryPut:= bRes; end; + +procedure CheckRect(Width, Height, x, y, w, h: LongWord); +begin + if (x + w > Width) then + OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); + if (y + h > Height) then + OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); +end; + procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects); var s, key: shortstring; f: textfile; i: LongInt; ii, t: Longword; c2: TSDL_Color; - - procedure CheckRect(Width, Height, x, y, w, h: LongWord); - begin - if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); - if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); - end; - begin AddProgress; // Set default water greyscale values -if cGrayScale then +if GrayScale then begin for i:= 0 to 3 do begin t:= round(SDWaterColorArray[i].r * RGB_LUMINANCE_RED + SDWaterColorArray[i].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[i].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; SDWaterColorArray[i].r:= t; SDWaterColorArray[i].g:= t; SDWaterColorArray[i].b:= t @@ -406,7 +421,8 @@ for i:= 0 to 1 do begin t:= round(WaterColorArray[i].r * RGB_LUMINANCE_RED + WaterColorArray[i].g * RGB_LUMINANCE_GREEN + WaterColorArray[i].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; WaterColorArray[i].r:= t; WaterColorArray[i].g:= t; WaterColorArray[i].b:= t @@ -414,7 +430,8 @@ end; s:= UserPathz[ptCurrTheme] + '/' + cThemeCFGFilename; -if not FileExists(s) then s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename; +if not FileExists(s) then + s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename; WriteLnToConsole('Reading objects info...'); Assign(f, s); {$I-} @@ -427,8 +444,10 @@ while not eof(f) do begin Readln(f, s); - if Length(s) = 0 then continue; - if s[1] = ';' then continue; + if Length(s) = 0 then + continue; + if s[1] = ';' then + continue; i:= Pos('=', s); key:= Trim(Copy(s, 1, Pred(i))); @@ -443,10 +462,12 @@ SkyColor.g:= StrToInt(Trim(Copy(s, 1, Pred(i)))); Delete(s, 1, i); SkyColor.b:= StrToInt(Trim(s)); - if cGrayScale then + if GrayScale + then begin t:= round(SkyColor.r * RGB_LUMINANCE_RED + SkyColor.g * RGB_LUMINANCE_GREEN + SkyColor.b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; SkyColor.r:= t; SkyColor.g:= t; SkyColor.b:= t @@ -465,15 +486,16 @@ c2.g:= StrToInt(Trim(Copy(s, 1, Pred(i)))); Delete(s, 1, i); c2.b:= StrToInt(Trim(s)); - if cGrayScale then + if GrayScale then begin t:= round(SkyColor.r * RGB_LUMINANCE_RED + SkyColor.g * RGB_LUMINANCE_GREEN + SkyColor.b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; c2.r:= t; c2.g:= t; c2.b:= t end; - cExplosionBorderColor:= c2.value or AMask; + ExplosionBorderColor:= (c2.r shl RShift) or (c2.g shl GShift) or (c2.b shl BShift) or AMask; end else if key = 'water-top' then begin @@ -485,10 +507,11 @@ Delete(s, 1, i); WaterColorArray[0].b:= StrToInt(Trim(s)); WaterColorArray[0].a := 255; - if cGrayScale then + if GrayScale then begin t:= round(WaterColorArray[0].r * RGB_LUMINANCE_RED + WaterColorArray[0].g * RGB_LUMINANCE_GREEN + WaterColorArray[0].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; WaterColorArray[0].r:= t; WaterColorArray[0].g:= t; WaterColorArray[0].b:= t @@ -505,10 +528,11 @@ Delete(s, 1, i); WaterColorArray[2].b:= StrToInt(Trim(s)); WaterColorArray[2].a := 255; - if cGrayScale then + if GrayScale then begin t:= round(WaterColorArray[2].r * RGB_LUMINANCE_RED + WaterColorArray[2].g * RGB_LUMINANCE_GREEN + WaterColorArray[2].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; WaterColorArray[2].r:= t; WaterColorArray[2].g:= t; WaterColorArray[2].b:= t @@ -517,13 +541,14 @@ end else if key = 'water-opacity' then begin - cWaterOpacity:= StrToInt(Trim(s)); - cSDWaterOpacity:= cWaterOpacity + WaterOpacity:= StrToInt(Trim(s)); + SDWaterOpacity:= WaterOpacity end - else if key = 'music' then MusicFN:= Trim(s) + else if key = 'music' then + SetMusicName(Trim(s)) else if key = 'clouds' then begin - cCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH; + cCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div 4096; cSDCloudsNumber:= cCloudsNumber end else if key = 'object' then @@ -532,15 +557,15 @@ with ThemeObjects.objs[Pred(ThemeObjects.Count)] do begin i:= Pos(',', s); - Surf:= LoadImage(UserPathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps); - if Surf = nil then Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifCritical or ifTransparent or ifIgnoreCaps); + Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps); Width:= Surf^.w; Height:= Surf^.h; Delete(s, 1, i); i:= Pos(',', s); Maxcnt:= StrToInt(Trim(Copy(s, 1, Pred(i)))); Delete(s, 1, i); - if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); + if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then + OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); with inland do begin i:= Pos(',', s); @@ -572,7 +597,8 @@ i:= Pos(',', s); w:= StrToInt(Trim(Copy(s, 1, Pred(i)))); Delete(s, 1, i); - if ii = rectcnt then h:= StrToInt(Trim(s)) + if ii = rectcnt then + h:= StrToInt(Trim(s)) else begin i:= Pos(',', s); @@ -589,8 +615,7 @@ with SprayObjects.objs[Pred(SprayObjects.Count)] do begin i:= Pos(',', s); - Surf:= LoadImage(UserPathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps); - if Surf = nil then Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + Trim(Copy(s, 1, Pred(i))), ifCritical or ifTransparent or ifIgnoreCaps); + Surf:= LoadDataImage(ptCurrTheme, Trim(Copy(s, 1, Pred(i))), ifTransparent or ifIgnoreCaps); Width:= Surf^.w; Height:= Surf^.h; Delete(s, 1, i); @@ -616,8 +641,10 @@ vobFallSpeed:= StrToInt(Trim(s)); end; end - else if key = 'flatten-flakes' then cFlattenFlakes:= true - else if key = 'flatten-clouds' then cFlattenClouds:= true + else if key = 'flatten-flakes' then + cFlattenFlakes:= true + else if key = 'flatten-clouds' then + cFlattenClouds:= true else if key = 'sd-water-top' then begin i:= Pos(',', s); @@ -628,10 +655,11 @@ Delete(s, 1, i); SDWaterColorArray[0].b:= StrToInt(Trim(s)); SDWaterColorArray[0].a := 255; - if cGrayScale then + if GrayScale then begin t:= round(SDWaterColorArray[0].r * RGB_LUMINANCE_RED + SDWaterColorArray[0].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[0].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; SDWaterColorArray[0].r:= t; SDWaterColorArray[0].g:= t; SDWaterColorArray[0].b:= t @@ -648,18 +676,21 @@ Delete(s, 1, i); SDWaterColorArray[2].b:= StrToInt(Trim(s)); SDWaterColorArray[2].a := 255; - if cGrayScale then + if GrayScale then begin t:= round(SDWaterColorArray[2].r * RGB_LUMINANCE_RED + SDWaterColorArray[2].g * RGB_LUMINANCE_GREEN + SDWaterColorArray[2].b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; SDWaterColorArray[2].r:= t; SDWaterColorArray[2].g:= t; SDWaterColorArray[2].b:= t end; SDWaterColorArray[3]:= SDWaterColorArray[2]; end - else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s)) - else if key = 'sd-clouds' then cSDCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH + else if key = 'sd-water-opacity' then + SDWaterOpacity:= StrToInt(Trim(s)) + else if key = 'sd-clouds' then + cSDCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div 4096 else if key = 'sd-flakes' then begin i:= Pos(',', s); @@ -690,10 +721,11 @@ RQSkyColor.g:= StrToInt(Trim(Copy(s, 1, Pred(i)))); Delete(s, 1, i); RQSkyColor.b:= StrToInt(Trim(s)); - if cGrayScale then + if GrayScale then begin t:= round(RQSkyColor.r * RGB_LUMINANCE_RED + RQSkyColor.g * RGB_LUMINANCE_GREEN + RQSkyColor.b * RGB_LUMINANCE_BLUE); - if t > 255 then t:= 255; + if t > 255 then + t:= 255; RQSkyColor.r:= t; RQSkyColor.g:= t; RQSkyColor.b:= t @@ -716,7 +748,8 @@ var i, ii, t: LongInt; b: boolean; begin - if ThemeObjects.Count = 0 then exit; + if ThemeObjects.Count = 0 then + exit; WriteLnToConsole('Adding theme objects...'); for i:=0 to ThemeObjects.Count do @@ -739,7 +772,8 @@ var i, ii, t: LongInt; b: boolean; begin - if SprayObjects.Count = 0 then exit; + if SprayObjects.Count = 0 then + exit; WriteLnToConsole('Adding spray objects...'); for i:=0 to SprayObjects.Count do @@ -759,19 +793,20 @@ end; procedure AddObjects(); -var i, int: Longword; +var i, g: Longword; begin InitRects; if hasGirders then begin - int:= max(playWidth div 8, 256); - i:=leftX+int; + g:= max(playWidth div 8, 256); + i:= leftX + g; repeat AddGirder(i); - i:=i+int; - until (i>rightX-int); + i:=i + g; + until (i > rightX - g); end; -if (GameFlags and gfDisableLandObjects) = 0 then AddThemeObjects(ThemeObjects); +if (GameFlags and gfDisableLandObjects) = 0 then + AddThemeObjects(ThemeObjects); AddProgress(); FreeRects(); end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandOutline.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uLandOutline.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,311 @@ +unit uLandOutline; + +interface + +uses uConsts, SDLh, uFloat; + +type TPixAr = record + Count: Longword; + ar: array[0..Pred(cMaxEdgePoints)] of TPoint; + end; + +procedure DrawEdge(var pa: TPixAr; Color: Longword); +procedure FillLand(x, y: LongInt); +procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat); +procedure RandomizePoints(var pa: TPixAr); + +implementation + +uses uLandGraphics, uDebug, uVariables, uLandTemplates, uRandom, uUtils; + + + +var Stack: record + Count: Longword; + points: array[0..8192] of record + xl, xr, y, dir: LongInt; + end + end; + +procedure Push(_xl, _xr, _y, _dir: LongInt); +begin + TryDo(Stack.Count <= 8192, 'FillLand: stack overflow', true); + _y:= _y + _dir; + if (_y < 0) or (_y >= LAND_HEIGHT) then + exit; + with Stack.points[Stack.Count] do + begin + xl:= _xl; + xr:= _xr; + y:= _y; + dir:= _dir + end; + inc(Stack.Count) +end; + +procedure Pop(var _xl, _xr, _y, _dir: LongInt); +begin + dec(Stack.Count); + with Stack.points[Stack.Count] do + begin + _xl:= xl; + _xr:= xr; + _y:= y; + _dir:= dir + end +end; + +procedure FillLand(x, y: LongInt); +var xl, xr, dir: LongInt; +begin + Stack.Count:= 0; + xl:= x - 1; + xr:= x; + Push(xl, xr, y, -1); + Push(xl, xr, y, 1); + dir:= 0; + while Stack.Count > 0 do + begin + Pop(xl, xr, y, dir); + while (xl > 0) and (Land[y, xl] <> 0) do + dec(xl); + while (xr < LAND_WIDTH - 1) and (Land[y, xr] <> 0) do + inc(xr); + while (xl < xr) do + begin + while (xl <= xr) and (Land[y, xl] = 0) do + inc(xl); + x:= xl; + while (xl <= xr) and (Land[y, xl] <> 0) do + begin + Land[y, xl]:= 0; + inc(xl) + end; + if x < xl then + begin + Push(x, Pred(xl), y, dir); + Push(x, Pred(xl), y,-dir); + end; + end; + end; +end; + +procedure DrawEdge(var pa: TPixAr; Color: Longword); +var i: LongInt; +begin + i:= 0; + with pa do + while i < LongInt(Count) - 1 do + if (ar[i + 1].X = NTPX) then + inc(i, 2) + else + begin + DrawLine(ar[i].x, ar[i].y, ar[i + 1].x, ar[i + 1].y, Color); + inc(i) + end +end; + + +procedure Vector(p1, p2, p3: TPoint; var Vx, Vy: hwFloat); +var d1, d2, d: hwFloat; +begin + Vx:= int2hwFloat(p1.X - p3.X); + Vy:= int2hwFloat(p1.Y - p3.Y); + + d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y); + d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y); + d2:= Distance(Vx, Vy); + + if d1 < d then + d:= d1; + if d2 < d then + d:= d2; + + d:= d * _1div3; + + if d2.QWordValue = 0 then + begin + Vx:= _0; + Vy:= _0 + end + else + begin + d2:= _1 / d2; + Vx:= Vx * d2; + Vy:= Vy * d2; + + Vx:= Vx * d; + Vy:= Vy * d + end +end; + +procedure AddLoopPoints(var pa, opa: TPixAr; StartI, EndI: LongInt; Delta: hwFloat); +var i, pi, ni: LongInt; + NVx, NVy, PVx, PVy: hwFloat; + x1, x2, y1, y2: LongInt; + tsq, tcb, t, r1, r2, r3, cx1, cx2, cy1, cy2: hwFloat; + X, Y: LongInt; +begin +pi:= EndI; +i:= StartI; +ni:= Succ(StartI); +{$HINTS OFF} +Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); +{$HINTS ON} +repeat + inc(pi); + if pi > EndI then + pi:= StartI; + inc(i); + if i > EndI then + i:= StartI; + inc(ni); + if ni > EndI then + ni:= StartI; + PVx:= NVx; + PVy:= NVy; + Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy); + + x1:= opa.ar[pi].x; + y1:= opa.ar[pi].y; + x2:= opa.ar[i].x; + y2:= opa.ar[i].y; + cx1:= int2hwFloat(x1) - PVx; + cy1:= int2hwFloat(y1) - PVy; + cx2:= int2hwFloat(x2) + NVx; + cy2:= int2hwFloat(y2) + NVy; + t:= _0; + while t.Round = 0 do + begin + tsq:= t * t; + tcb:= tsq * t; + r1:= (_1 - t*3 + tsq*3 - tcb); + r2:= ( t*3 - tsq*6 + tcb*3); + r3:= ( tsq*3 - tcb*3); + X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2); + Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2); + t:= t + Delta; + pa.ar[pa.Count].x:= X; + pa.ar[pa.Count].y:= Y; + inc(pa.Count); + TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true) + end; +until i = StartI; +pa.ar[pa.Count].x:= opa.ar[StartI].X; +pa.ar[pa.Count].y:= opa.ar[StartI].Y; +inc(pa.Count) +end; + +procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat); +var i, StartLoop: LongInt; + opa: TPixAr; +begin +opa:= pa; +pa.Count:= 0; +i:= 0; +StartLoop:= 0; +while i < LongInt(opa.Count) do + if (opa.ar[i + 1].X = NTPX) then + begin + AddLoopPoints(pa, opa, StartLoop, i, Delta); + inc(i, 2); + StartLoop:= i; + pa.ar[pa.Count].X:= NTPX; + pa.ar[pa.Count].Y:= 0; + inc(pa.Count); + end else inc(i) +end; + + +function CheckIntersect(V1, V2, V3, V4: TPoint): boolean; +var c1, c2, dm: LongInt; +begin + CheckIntersect:= false; + dm:= (V4.y - V3.y) * (V2.x - V1.x) - (V4.x - V3.x) * (V2.y - V1.y); + c1:= (V4.x - V3.x) * (V1.y - V3.y) - (V4.y - V3.y) * (V1.x - V3.x); + if dm = 0 then + exit; + + CheckIntersect:= true; + c2:= (V2.x - V3.x) * (V1.y - V3.y) - (V2.y - V3.y) * (V1.x - V3.x); + if dm > 0 then + begin + if (c1 < 0) or (c1 > dm) then + CheckIntersect:= false + else if (c2 < 0) or (c2 > dm) then + CheckIntersect:= false; + end + else + begin + if (c1 > 0) or (c1 < dm) then + CheckIntersect:= false + else if (c2 > 0) or (c2 < dm) then + CheckIntersect:= false; + end; + + //AddFileLog('1 (' + inttostr(V1.x) + ',' + inttostr(V1.y) + ')x(' + inttostr(V2.x) + ',' + inttostr(V2.y) + ')'); + //AddFileLog('2 (' + inttostr(V3.x) + ',' + inttostr(V3.y) + ')x(' + inttostr(V4.x) + ',' + inttostr(V4.y) + ')'); +end; + + +function CheckSelfIntersect(var pa: TPixAr; ind: Longword): boolean; +var i: Longword; +begin + CheckSelfIntersect:= false; + if (ind <= 0) or (ind >= Pred(pa.Count)) then + exit; + + CheckSelfIntersect:= true; + for i:= 1 to pa.Count - 3 do + if (i <= ind - 1) or (i >= ind + 2) then + begin + if (i <> ind - 1) and CheckIntersect(pa.ar[ind], pa.ar[ind - 1], pa.ar[i], pa.ar[i - 1]) then + exit; + if (i <> ind + 2) and CheckIntersect(pa.ar[ind], pa.ar[ind + 1], pa.ar[i], pa.ar[i - 1]) then + exit; + end; + CheckSelfIntersect:= false +end; + +procedure RandomizePoints(var pa: TPixAr); +const cEdge = 55; + cMinDist = 8; +var radz: array[0..Pred(cMaxEdgePoints)] of LongInt; + i, k, dist, px, py: LongInt; +begin + for i:= 0 to Pred(pa.Count) do + begin + radz[i]:= 0; + with pa.ar[i] do + if x <> NTPX then + begin + radz[i]:= Min(Max(x - cEdge, 0), Max(LAND_WIDTH - cEdge - x, 0)); + radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(LAND_HEIGHT - cEdge - y, 0))); + if radz[i] > 0 then + for k:= 0 to Pred(i) do + begin + dist:= Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y)); + radz[k]:= Max(0, Min((dist - cMinDist) div 2, radz[k])); + radz[i]:= Max(0, Min(dist - radz[k] - cMinDist, radz[i])) + end + end; + end; + + for i:= 0 to Pred(pa.Count) do + with pa.ar[i] do + if ((x and LAND_WIDTH_MASK) = 0) and ((y and LAND_HEIGHT_MASK) = 0) then + begin + px:= x; + py:= y; + x:= x + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; + y:= y + LongInt(GetRandom(7) - 3) * (radz[i] * 5 div 7) div 3; + if CheckSelfIntersect(pa, i) then + begin + x:= px; + y:= py + end; + end +end; + + +end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandPainted.pas --- a/hedgewars/uLandPainted.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLandPainted.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ procedure freeModule; implementation -uses uLandGraphics, uConsts, uUtils, SDLh, uCommands, uDebug; +uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uDebug; type PointRec = packed record X, Y: SmallInt; @@ -43,69 +43,6 @@ var pointsListHead, pointsListLast: PPointEntry; -procedure DrawLineOnLand(X1, Y1, X2, Y2: LongInt); -var eX, eY, dX, dY: LongInt; - i, sX, sY, x, y, d: LongInt; - b: boolean; - len: LongWord; -begin - len:= 0; - if (X1 = X2) and (Y1 = Y2) then - begin - exit - end; - eX:= 0; - eY:= 0; - dX:= X2 - X1; - dY:= Y2 - Y1; - - if (dX > 0) then sX:= 1 - else - if (dX < 0) then - begin - sX:= -1; - dX:= -dX - end else sX:= dX; - - if (dY > 0) then sY:= 1 - else - if (dY < 0) then - begin - sY:= -1; - dY:= -dY - end else sY:= dY; - - if (dX > dY) then d:= dX - else d:= dY; - - x:= X1; - y:= Y1; - - for i:= 0 to d do - begin - inc(eX, dX); - inc(eY, dY); - b:= false; - if (eX > d) then - begin - dec(eX, d); - inc(x, sX); - b:= true - end; - if (eY > d) then - begin - dec(eY, d); - inc(y, sY); - b:= true - end; - if b then - begin - inc(len); - if (len mod 4) = 0 then FillRoundInLand(X, Y, 34, lfBasic) - end - end -end; - procedure chDraw(var s: shortstring); var rec: PointRec; prec: ^PointRec; @@ -120,8 +57,12 @@ rec:= prec^; rec.X:= SDLNet_Read16(@rec.X); rec.Y:= SDLNet_Read16(@rec.Y); + if rec.X < -318 then rec.X:= -318; + if rec.X > 4096+318 then rec.X:= 4096+318; + if rec.Y < -318 then rec.Y:= -318; + if rec.Y > 2048+318 then rec.Y:= 2048+318; - pe:= new(PPointEntry); + new(pe); if pointsListLast = nil then pointsListHead:= pe else @@ -138,10 +79,13 @@ procedure Draw; var pe: PPointEntry; prevPoint: PointRec; + radius: LongInt; + color: Longword; begin // shutup compiler prevPoint.X:= 0; prevPoint.Y:= 0; + radius:= 0; pe:= pointsListHead; TryDo((pe = nil) or (pe^.point.flags and $80 <> 0), 'Corrupted draw data', true); @@ -150,13 +94,19 @@ begin if (pe^.point.flags and $80 <> 0) then begin - AddFileLog('[DRAW] Move to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')'); - FillRoundInLand(pe^.point.X, pe^.point.Y, 34, lfBasic) + if (pe^.point.flags and $40 <> 0) then + color:= 0 + else + color:= lfBasic; + radius:= (pe^.point.flags and $3F) * 5 + 3; + AddFileLog('[DRAW] Move to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+'), radius = '+inttostr(radius)); + FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color) end else begin - AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')'); - DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y); + AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+'), radius = '+inttostr(radius)); + DrawThickLine(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y, radius, color); + FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color) end; prevPoint:= pe^.point; @@ -169,7 +119,7 @@ pointsListHead:= nil; pointsListLast:= nil; - RegisterVariable('draw', vtCommand, @chDraw, false); + RegisterVariable('draw', @chDraw, false); end; procedure freeModule; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandTemplates.pas --- a/hedgewars/uLandTemplates.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLandTemplates.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,10 +22,10 @@ interface uses SDLh; -const NTPX = Low(TSDL_Rect.x); +const NTPX = Low(SmallInt); -type PPointArray = ^TPointArray; - TPointArray = array[0..64] of TSDL_Rect; +type TPointArray = array[0..64] of TSDL_Rect; + PPointArray = ^TPointArray; TEdgeTemplate = record BasePoints: PPointArray; BasePointsCount: Longword; @@ -65,7 +65,7 @@ ); Template0FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template1Points: array[0..15] of TSDL_Rect = @@ -89,7 +89,7 @@ ); Template1FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template2Points: array[0..21] of TSDL_Rect = @@ -119,7 +119,7 @@ ); Template2FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template3Points: array[0..16] of TSDL_Rect = @@ -144,7 +144,7 @@ ); Template3FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template4Points: array[0..22] of TSDL_Rect = @@ -175,7 +175,7 @@ ); Template4FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template5Points: array[0..15] of TSDL_Rect = @@ -199,7 +199,7 @@ ); Template5FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template6Points: array[0..13] of TSDL_Rect = @@ -221,7 +221,7 @@ ); Template6FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template7Points: array[0..5] of TSDL_Rect = @@ -235,7 +235,7 @@ ); Template7FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); @@ -264,7 +264,7 @@ ); Template8FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template9Points: array[0..31] of TSDL_Rect = @@ -304,7 +304,7 @@ ); Template9FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template10Points: array[0..13] of TSDL_Rect = @@ -326,7 +326,7 @@ ); Template10FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template11Points: array[0..9] of TSDL_Rect = @@ -344,7 +344,7 @@ ); Template11FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template12Points: array[0..13] of TSDL_Rect = @@ -366,7 +366,7 @@ ); Template12FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template13Points: array[0..15] of TSDL_Rect = @@ -390,7 +390,7 @@ ); Template13FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template14Points: array[0..13] of TSDL_Rect = @@ -412,7 +412,7 @@ ); Template14FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template15Points: array[0..23] of TSDL_Rect = @@ -444,7 +444,7 @@ ); Template15FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template16Points: array[0..28] of TSDL_Rect = @@ -481,7 +481,7 @@ ); Template16FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); const Template17Points: array[0..13] of TSDL_Rect = @@ -503,7 +503,7 @@ ); Template17FPoints: array[0..0] of TPoint = ( - (x: 1023; y: 0) + (X: 1023; Y: 0) ); //////////////////// MIXING AND MATCHING ORIGINAL ////////////////////////////////////// const Template18Points: array[0..32] of TSDL_Rect = @@ -544,7 +544,7 @@ ); Template18FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template19Points: array[0..44] of TSDL_Rect = @@ -597,7 +597,7 @@ ); Template19FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template20Points: array[0..45] of TSDL_Rect = @@ -651,7 +651,7 @@ ); Template20FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template21Points: array[0..30] of TSDL_Rect = @@ -690,7 +690,7 @@ ); Template21FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template22Points: array[0..38] of TSDL_Rect = @@ -737,7 +737,7 @@ ); Template22FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template23Points: array[0..29] of TSDL_Rect = @@ -775,7 +775,7 @@ ); Template23FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template24Points: array[0..23] of TSDL_Rect = @@ -807,7 +807,7 @@ ); Template24FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template25Points: array[0..19] of TSDL_Rect = @@ -835,7 +835,7 @@ ); Template25FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); @@ -896,7 +896,7 @@ ); Template26FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template27Points: array[0..42] of TSDL_Rect = @@ -947,7 +947,7 @@ ); Template27FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template28Points: array[0..29] of TSDL_Rect = @@ -985,7 +985,7 @@ ); Template28FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template29Points: array[0..37] of TSDL_Rect = @@ -1031,7 +1031,7 @@ ); Template29FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template30Points: array[0..30] of TSDL_Rect = @@ -1070,7 +1070,7 @@ ); Template30FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template31Points: array[0..32] of TSDL_Rect = @@ -1111,7 +1111,7 @@ ); Template31FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template32Points: array[0..29] of TSDL_Rect = @@ -1149,7 +1149,7 @@ ); Template32FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template33Points: array[0..45] of TSDL_Rect = @@ -1203,7 +1203,7 @@ ); Template33FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template34Points: array[0..25] of TSDL_Rect = @@ -1237,7 +1237,7 @@ ); Template34FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); const Template35Points: array[0..48] of TSDL_Rect = @@ -1294,7 +1294,7 @@ ); Template35FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); ///////////////////////// CAVERNS /////////////////////////////////// @@ -1322,7 +1322,7 @@ ); Template36FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); ////////////////////////////// ... Silly ... //////////////////////////////// /// Ok. Tiy does not care for these. Perhaps they could be saved. @@ -1363,7 +1363,7 @@ ); Template37FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); // attempt to make a series of moderate hills/valleys - was before I really figured out the whole probabilities thing const Template38Points: array[0..16] of TSDL_Rect = @@ -1388,7 +1388,7 @@ ); Template38FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); // 8 tiny islands @@ -1437,7 +1437,7 @@ ); Template39FPoints: array[0..0] of TPoint = ( - (x: 512; y: 0) + (X: 512; Y: 0) ); const Template40Points: array[0..7] of TSDL_Rect = ( @@ -1452,102 +1452,102 @@ ); Template40FPoints: array[0..0] of TPoint = ( - (x: 512; y: 0) + (X: 512; Y: 0) ); // Many islands const Template41Points: array[0..86] of TSDL_Rect = ( - (x: 95; y: 500; w: 1; h: 1), - (x: 100; y: 275; w: 25; h: 100), - (x: 325; y: 275; w: 25; h: 100), - (x: 330; y: 500; w: 1; h: 1), + (x: 95; y: 500; w: 26; h: 26), + (x: 100; y: 275; w: 50; h: 125), + (x: 325; y: 275; w: 50; h: 125), + (x: 330; y: 500; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 725; y: 125; w: 1; h: 1), - (x: 725; y: 25; w: 5; h: 25), - (x: 825; y: 35; w: 5; h: 10), - (x: 825; y: 135; w: 1; h: 1), + (x: 725; y: 125; w: 26; h: 26), + (x: 725; y: 25; w: 30; h: 50), + (x: 825; y: 35; w: 30; h: 35), + (x: 825; y: 135; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 1150; y: 550; w: 25; h: 50), - (x: 1250; y: 300; w: 25; h: 50), - (x: 1350; y: 300; w: 25; h: 50), - (x: 1400; y: 575; w: 25; h: 50), + (x: 1150; y: 550; w: 50; h: 75), + (x: 1250; y: 300; w: 50; h: 75), + (x: 1350; y: 300; w: 50; h: 75), + (x: 1400; y: 575; w: 50; h: 75), (x: NTPX; y: 0; w: 1; h: 1), - (x: 525; y:1050; w: 50; h: 50), - (x: 700; y: 800; w: 100; h: 150), - (x: 950; y: 900; w: 100; h: 150), - (x: 1100; y:1100; w: 50; h: 50), + (x: 525; y:1050; w: 75; h: 75), + (x: 700; y: 800; w: 125; h: 175), + (x: 950; y: 900; w: 125; h: 175), + (x: 1100; y:1100; w: 75; h: 75), (x: NTPX; y: 0; w: 1; h: 1), - (x: 175; y:1500; w: 1; h: 1), - (x: 210; y:1400; w: 5; h: 25), - (x: 240; y:1400; w: 5; h: 25), - (x: 275; y:1510; w: 1; h: 1), + (x: 175; y:1500; w: 26; h: 26), + (x: 210; y:1400; w: 30; h: 50), + (x: 240; y:1400; w: 30; h: 50), + (x: 275; y:1510; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 450; y:1800; w: 100; h: 100), - (x: 600; y:1750; w: 100; h: 100), - (x: 750; y:1750; w: 100; h: 100), - (x: 950; y:1850; w: 100; h: 100), + (x: 450; y:1800; w: 125; h: 125), + (x: 600; y:1750; w: 125; h: 125), + (x: 750; y:1750; w: 125; h: 125), + (x: 950; y:1850; w: 125; h: 125), (x: NTPX; y: 0; w: 1; h: 1), - (x: 1075; y:1450; w: 1; h: 1), - (x: 1110; y:1300; w: 5; h: 25), - (x: 1140; y:1300; w: 5; h: 25), - (x: 1175; y:1430; w: 1; h: 1), + (x: 1075; y:1450; w: 26; h: 26), + (x: 1110; y:1300; w: 30; h: 50), + (x: 1140; y:1300; w: 30; h: 50), + (x: 1175; y:1430; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 1600; y:1250; w: 25; h: 100), - (x: 1700; y:1150; w: 25; h: 100), - (x: 1850; y: 500; w: 50; h: 100), - (x: 1950; y: 550; w: 50; h: 150), - (x: 2250; y:1150; w: 25; h: 100), - (x: 2350; y:1250; w: 25; h: 100), + (x: 1600; y:1250; w: 50; h: 125), + (x: 1700; y:1150; w: 50; h: 125), + (x: 1850; y: 500; w: 75; h: 125), + (x: 1950; y: 550; w: 75; h: 175), + (x: 2250; y:1150; w: 50; h: 125), + (x: 2350; y:1250; w: 50; h: 125), (x: NTPX; y: 0; w: 1; h: 1), - (x: 1750; y:2010; w: 1; h: 1), - (x: 1900; y:1870; w: 50; h: 50), - (x: 2050; y:1870; w: 50; h: 50), - (x: 2175; y:2010; w: 1; h: 1), + (x: 1750; y:2010; w: 26; h: 26), + (x: 1900; y:1870; w: 75; h: 75), + (x: 2050; y:1870; w: 75; h: 75), + (x: 2175; y:2010; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 2500; y:1700; w: 1; h: 1), - (x: 2575; y:1500; w: 10; h: 50), - (x: 2650; y:1500; w: 10; h: 50), - (x: 2700; y:1690; w: 1; h: 1), + (x: 2500; y:1700; w: 26; h: 26), + (x: 2575; y:1500; w: 35; h: 75), + (x: 2650; y:1500; w: 35; h: 75), + (x: 2700; y:1690; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 2000; y: 125; w: 1; h: 1), - (x: 2050; y: 50; w: 25; h: 25), - (x: 2100; y: 50; w: 25; h: 25), - (x: 2150; y: 150; w: 1; h: 1), + (x: 2000; y: 125; w: 26; h: 26), + (x: 2050; y: 50; w: 50; h: 50), + (x: 2100; y: 50; w: 50; h: 50), + (x: 2150; y: 150; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 2600; y: 250; w: 25; h: 100), - (x: 2750; y: 400; w: 50; h: 50), - (x: 2900; y: 525; w: 50; h: 50), - (x: 3150; y: 550; w: 50; h: 100), + (x: 2600; y: 250; w: 50; h: 125), + (x: 2750; y: 400; w: 75; h: 75), + (x: 2900; y: 525; w: 75; h: 75), + (x: 3150; y: 550; w: 75; h: 125), (x: NTPX; y: 0; w: 1; h: 1), - (x: 2800; y:1150; w: 1; h: 1), - (x: 2840; y: 950; w: 25; h: 25), - (x: 2880; y: 950; w: 25; h: 25), - (x: 2900; y:1150; w: 1; h: 1), + (x: 2800; y:1150; w: 26; h: 26), + (x: 2840; y: 950; w: 50; h: 50), + (x: 2880; y: 950; w: 50; h: 50), + (x: 2900; y:1150; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 3075; y:1985; w: 1; h: 1), - (x: 3325; y:1700; w: 50; h: 100), - (x: 3475; y:1700; w: 50; h: 100), - (x: 3625; y:1985; w: 1; h: 1), + (x: 3075; y:1985; w: 26; h: 26), + (x: 3325; y:1700; w: 75; h: 125), + (x: 3475; y:1700; w: 75; h: 125), + (x: 3625; y:1985; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 3200; y:1450; w: 1; h: 1), - (x: 3240; y:1350; w: 25; h: 25), - (x: 3280; y:1350; w: 25; h: 25), - (x: 3300; y:1450; w: 1; h: 1), + (x: 3200; y:1450; w: 26; h: 26), + (x: 3240; y:1350; w: 50; h: 50), + (x: 3280; y:1350; w: 50; h: 50), + (x: 3300; y:1450; w: 26; h: 26), (x: NTPX; y: 0; w: 1; h: 1), - (x: 3500; y:1050; w: 25; h: 50), - (x: 3650; y: 600; w: 50; h: 100), - (x: 3800; y: 600; w: 50; h: 100), - (x: 3900; y:1000; w: 25; h: 50), + (x: 3500; y:1050; w: 50; h: 75), + (x: 3650; y: 600; w: 75; h: 125), + (x: 3800; y: 600; w: 75; h: 125), + (x: 3900; y:1000; w: 50; h: 75), (x: NTPX; y: 0; w: 1; h: 1), - (x: 3800; y: 200; w: 25; h: 50), - (x: 3875; y: 100; w: 50; h: 50), - (x: 3925; y: 50; w: 50; h: 25), - (x: 4050; y: 125; w: 25; h: 50), + (x: 3800; y: 200; w: 50; h: 75), + (x: 3875; y: 100; w: 75; h: 75), + (x: 3925; y: 50; w: 75; h: 50), + (x: 4050; y: 125; w: 50; h: 75), (x: NTPX; y: 0; w: 1; h: 1) ); Template41FPoints: array[0..0] of TPoint = ( - (x: 2047; y: 0) + (X: 2047; Y: 0) ); // 2 tiny islands const Template42Points: array[0..13] of TSDL_Rect = @@ -1569,11 +1569,245 @@ ); Template42FPoints: array[0..0] of TPoint = ( - (x: 512; y: 0) + (X: 512; Y: 0) + ); +// Many islands +const Template43Points: array[0..173] of TSDL_Rect = + ( + (x: 95; y: 500; w: 26; h: 26), + (x: 100; y: 275; w: 50; h: 125), + (x: 325; y: 275; w: 50; h: 125), + (x: 330; y: 500; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 725; y: 125; w: 26; h: 26), + (x: 725; y: 25; w: 30; h: 50), + (x: 825; y: 35; w: 30; h: 35), + (x: 825; y: 135; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 1150; y: 550; w: 50; h: 75), + (x: 1250; y: 300; w: 50; h: 75), + (x: 1350; y: 300; w: 50; h: 75), + (x: 1400; y: 575; w: 50; h: 75), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 525; y:1050; w: 75; h: 75), + (x: 700; y: 800; w: 125; h: 175), + (x: 950; y: 900; w: 125; h: 175), + (x: 1100; y:1100; w: 75; h: 75), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 175; y:1500; w: 26; h: 26), + (x: 210; y:1400; w: 30; h: 50), + (x: 240; y:1400; w: 30; h: 50), + (x: 275; y:1510; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 450; y:1800; w: 125; h: 125), + (x: 600; y:1750; w: 125; h: 125), + (x: 750; y:1750; w: 125; h: 125), + (x: 950; y:1850; w: 125; h: 125), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 1075; y:1450; w: 26; h: 26), + (x: 1110; y:1300; w: 30; h: 50), + (x: 1140; y:1300; w: 30; h: 50), + (x: 1175; y:1430; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 1600; y:1250; w: 50; h: 125), + (x: 1700; y:1150; w: 50; h: 125), + (x: 1850; y: 500; w: 75; h: 125), + (x: 1950; y: 550; w: 75; h: 175), + (x: 2250; y:1150; w: 50; h: 125), + (x: 2350; y:1250; w: 50; h: 125), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 1750; y:2010; w: 26; h: 26), + (x: 1900; y:1870; w: 75; h: 75), + (x: 2050; y:1870; w: 75; h: 75), + (x: 2175; y:2010; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 2500; y:1700; w: 26; h: 26), + (x: 2575; y:1500; w: 35; h: 75), + (x: 2650; y:1500; w: 35; h: 75), + (x: 2700; y:1690; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 2000; y: 125; w: 26; h: 26), + (x: 2050; y: 50; w: 50; h: 50), + (x: 2100; y: 50; w: 50; h: 50), + (x: 2150; y: 150; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 2600; y: 250; w: 50; h: 125), + (x: 2750; y: 400; w: 75; h: 75), + (x: 2900; y: 525; w: 75; h: 75), + (x: 3150; y: 550; w: 75; h: 125), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 2800; y:1150; w: 26; h: 26), + (x: 2840; y: 950; w: 50; h: 50), + (x: 2880; y: 950; w: 50; h: 50), + (x: 2900; y:1150; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 3075; y:1985; w: 26; h: 26), + (x: 3325; y:1700; w: 75; h: 125), + (x: 3475; y:1700; w: 75; h: 125), + (x: 3625; y:1985; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 3200; y:1450; w: 26; h: 26), + (x: 3240; y:1350; w: 50; h: 50), + (x: 3280; y:1350; w: 50; h: 50), + (x: 3300; y:1450; w: 26; h: 26), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 3500; y:1050; w: 50; h: 75), + (x: 3650; y: 600; w: 75; h: 125), + (x: 3800; y: 600; w: 75; h: 125), + (x: 3900; y:1000; w: 50; h: 75), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 3800; y: 200; w: 50; h: 75), + (x: 3875; y: 100; w: 75; h: 75), + (x: 3925; y: 50; w: 75; h: 50), + (x: 4050; y: 125; w: 50; h: 75), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 95; y:2548; w: 26; h: 26), + (x: 100; y:2323; w: 50; h: 125), + (x: 325; y:2323; w: 50; h: 125), + (x: 330; y:2548; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 725; y:2173; w: 26; h: 26), + (x: 725; y:2073; w: 30; h: 50), + (x: 825; y:2083; w: 30; h: 35), + (x: 825; y:2183; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 1150; y:2598; w: 50; h: 75), + (x: 1250; y:2348; w: 50; h: 75), + (x: 1350; y:2348; w: 50; h: 75), + (x: 1400; y:2623; w: 50; h: 75), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 525; y:3098; w: 75; h: 75), + (x: 700; y:2848; w: 125; h: 175), + (x: 950; y:2948; w: 125; h: 175), + (x: 1100; y:3148; w: 75; h: 75), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 175; y:3548; w: 26; h: 26), + (x: 210; y:3448; w: 30; h: 50), + (x: 240; y:3448; w: 30; h: 50), + (x: 275; y:3558; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 450; y:3848; w: 125; h: 125), + (x: 600; y:3798; w: 125; h: 125), + (x: 750; y:3798; w: 125; h: 125), + (x: 950; y:3898; w: 125; h: 125), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 1075; y:3498; w: 26; h: 26), + (x: 1110; y:3348; w: 30; h: 50), + (x: 1140; y:3348; w: 30; h: 50), + (x: 1175; y:3478; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 1600; y:3298; w: 50; h: 125), + (x: 1700; y:3198; w: 50; h: 125), + (x: 1850; y:2548; w: 75; h: 125), + (x: 1950; y:2598; w: 75; h: 175), + (x: 2250; y:3198; w: 50; h: 125), + (x: 2350; y:3298; w: 50; h: 125), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 1750; y:4058; w: 26; h: 26), + (x: 1900; y:3918; w: 75; h: 75), + (x: 2050; y:3918; w: 75; h: 75), + (x: 2175; y:4058; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 2500; y:3748; w: 26; h: 26), + (x: 2575; y:3548; w: 35; h: 75), + (x: 2650; y:3548; w: 35; h: 75), + (x: 2700; y:3738; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 2000; y:2173; w: 26; h: 26), + (x: 2050; y:2098; w: 50; h: 50), + (x: 2100; y:2098; w: 50; h: 50), + (x: 2150; y:2198; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 2600; y:2298; w: 50; h: 125), + (x: 2750; y:2448; w: 75; h: 75), + (x: 2900; y:2573; w: 75; h: 75), + (x: 3150; y:2598; w: 75; h: 125), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 2800; y:3198; w: 26; h: 26), + (x: 2840; y:2998; w: 50; h: 50), + (x: 2880; y:2998; w: 50; h: 50), + (x: 2900; y:3198; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 3075; y:4033; w: 26; h: 26), + (x: 3325; y:3748; w: 75; h: 125), + (x: 3475; y:3748; w: 75; h: 125), + (x: 3625; y:4033; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 3200; y:3498; w: 26; h: 26), + (x: 3240; y:3398; w: 50; h: 50), + (x: 3280; y:3398; w: 50; h: 50), + (x: 3300; y:3498; w: 26; h: 26), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 3500; y:3098; w: 50; h: 75), + (x: 3650; y:2648; w: 75; h: 125), + (x: 3800; y:2648; w: 75; h: 125), + (x: 3900; y:3048; w: 50; h: 75), + (x: NTPX; y:2048; w: 1; h: 1), + (x: 3800; y:2248; w: 50; h: 75), + (x: 3875; y:2148; w: 75; h: 75), + (x: 3925; y:2098; w: 75; h: 50), + (x: 4050; y:2173; w: 50; h: 75), + (x: NTPX; y:2048; w: 1; h: 1) + ); + Template43FPoints: array[0..0] of TPoint = + ( + (X: 4095; Y: 0) + ); + +// 3 large caverns +const Template44Points: array[0..14] of TSDL_Rect = + ( + (x: 0; y: 100; w: 1; h: 50), + (x: 4095; y: 100; w: 1; h: 50), + (x: 4095; y: 400; w: 1; h: 50), + (x: 0; y: 360; w: 1; h: 50), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 0; y: 750; w: 1; h: 50), + (x: 4095; y: 750; w: 1; h: 50), + (x: 4095; y:1100; w: 1; h: 50), + (x: 0; y:1100; w: 1; h: 50), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 0; y:1300; w: 1; h: 250), + (x: 4095; y:1300; w: 1; h: 250), + (x: 4095; y:1800; w: 1; h: 200), + (x: 0; y:1800; w: 1; h: 200), + (x: NTPX; y: 0; w: 1; h: 1) + ); + Template44FPoints: array[0..5] of TSDL_Rect = + ( + (X: 1; Y: 90; w: 0; h: 0), + (X: 1; Y: 500; w: 0; h: 0), + (X:4095; Y: 500; w: 0; h: 0), + (X: 1; Y:1200; w: 0; h: 0), + (X:4095; Y:1200; w: 0; h: 0), + (X: 1; Y:2010; w: 0; h: 0) + ); + +// large caverns with an island +const Template45Points: array[0..11] of TSDL_Rect = + ( + (x: 500; y: 100; w: 1; h: 300), + (x: 3700; y: 100; w: 1; h: 300), + (x: 3700; y: 900; w: 200; h: 300), + (x: 3700; y:1700; w: 1; h: 250), + (x: 500; y:1700; w: 1; h: 250), + (x: 300; y: 900; w: 200; h: 250), + (x: NTPX; y: 0; w: 1; h: 1), + (x: 1000; y: 800; w: 1; h: 1), + (x: 2700; y: 800; w: 600; h: 100), + (x: 2700; y:1200; w: 600; h: 200), + (x: 1000; y:1200; w: 200; h: 200), + (x: NTPX; y: 0; w: 1; h: 1) + ); + Template45FPoints: array[0..2] of TSDL_Rect = + ( + (X: 1; Y: 1; w: 0; h: 0), + (X: 1; Y:2047; w: 0; h: 0), + (X:1005; Y: 805; w: 0; h: 0) ); //////////////////////////////////////////////////////////////////////// -const EdgeTemplates: array[0..42] of TEdgeTemplate = +var EdgeTemplates: array[0..45] of TEdgeTemplate = ( (BasePoints: @Template0Points; BasePointsCount: Succ(High(Template0Points)); @@ -1584,7 +1818,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template1Points; BasePointsCount: Succ(High(Template1Points)); @@ -1595,7 +1829,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template2Points; BasePointsCount: Succ(High(Template2Points)); @@ -1606,7 +1840,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template3Points; BasePointsCount: Succ(High(Template3Points)); @@ -1617,7 +1851,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template4Points; BasePointsCount: Succ(High(Template4Points)); @@ -1628,7 +1862,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template5Points; BasePointsCount: Succ(High(Template5Points)); @@ -1639,7 +1873,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template6Points; BasePointsCount: Succ(High(Template6Points)); @@ -1650,7 +1884,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template7Points; BasePointsCount: Succ(High(Template7Points)); @@ -1661,7 +1895,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template8Points; BasePointsCount: Succ(High(Template8Points)); @@ -1672,7 +1906,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template9Points; BasePointsCount: Succ(High(Template9Points)); @@ -1683,7 +1917,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template10Points; BasePointsCount: Succ(High(Template10Points)); @@ -1694,7 +1928,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template11Points; BasePointsCount: Succ(High(Template11Points)); @@ -1705,7 +1939,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template12Points; BasePointsCount: Succ(High(Template12Points)); @@ -1716,7 +1950,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template13Points; BasePointsCount: Succ(High(Template13Points)); @@ -1727,7 +1961,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template14Points; BasePointsCount: Succ(High(Template14Points)); @@ -1738,7 +1972,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template15Points; BasePointsCount: Succ(High(Template15Points)); @@ -1749,7 +1983,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template16Points; BasePointsCount: Succ(High(Template16Points)); @@ -1760,7 +1994,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template17Points; BasePointsCount: Succ(High(Template17Points)); @@ -1771,7 +2005,7 @@ TemplateHeight: 1424; TemplateWidth: 2848; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 18; + MaxHedgeHogs: 18; ), (BasePoints: @Template18Points; BasePointsCount: Succ(High(Template18Points)); @@ -1782,7 +2016,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template19Points; BasePointsCount: Succ(High(Template19Points)); @@ -1793,7 +2027,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template20Points; BasePointsCount: Succ(High(Template20Points)); @@ -1804,7 +2038,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template21Points; BasePointsCount: Succ(High(Template21Points)); @@ -1815,7 +2049,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template22Points; BasePointsCount: Succ(High(Template22Points)); @@ -1826,7 +2060,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template23Points; BasePointsCount: Succ(High(Template23Points)); @@ -1837,7 +2071,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template24Points; BasePointsCount: Succ(High(Template24Points)); @@ -1848,7 +2082,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template25Points; BasePointsCount: Succ(High(Template25Points)); @@ -1859,7 +2093,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template26Points; BasePointsCount: Succ(High(Template26Points)); @@ -1870,7 +2104,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template27Points; BasePointsCount: Succ(High(Template27Points)); @@ -1881,7 +2115,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template28Points; BasePointsCount: Succ(High(Template28Points)); @@ -1892,7 +2126,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template29Points; BasePointsCount: Succ(High(Template29Points)); @@ -1903,7 +2137,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template30Points; BasePointsCount: Succ(High(Template30Points)); @@ -1914,7 +2148,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template31Points; BasePointsCount: Succ(High(Template31Points)); @@ -1925,7 +2159,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template32Points; BasePointsCount: Succ(High(Template32Points)); @@ -1936,7 +2170,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template33Points; BasePointsCount: Succ(High(Template33Points)); @@ -1947,7 +2181,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template34Points; BasePointsCount: Succ(High(Template34Points)); @@ -1958,7 +2192,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template35Points; BasePointsCount: Succ(High(Template35Points)); @@ -1969,7 +2203,7 @@ TemplateHeight: 1424; TemplateWidth: 3900; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 36; + MaxHedgeHogs: 36; ), (BasePoints: @Template36Points; BasePointsCount: Succ(High(Template36Points)); @@ -1980,7 +2214,7 @@ TemplateHeight: 1024; TemplateWidth: 4096; canMirror: true; canFlip: false; isNegative: true; canInvert: false; hasGirders: false; - MaxHedgehogs: 32; + MaxHedgeHogs: 32; ), (BasePoints: @Template37Points; BasePointsCount: Succ(High(Template37Points)); @@ -1991,7 +2225,7 @@ TemplateHeight: 2048; TemplateWidth: 4096; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 48; + MaxHedgeHogs: 48; ), (BasePoints: @Template38Points; BasePointsCount: Succ(High(Template38Points)); @@ -2002,7 +2236,7 @@ TemplateHeight: 2048; TemplateWidth: 4096; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 48; + MaxHedgeHogs: 48; ), (BasePoints: @Template39Points; BasePointsCount: Succ(High(Template39Points)); @@ -2013,7 +2247,7 @@ TemplateHeight: 512; TemplateWidth: 1536; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: false; - MaxHedgehogs: 8; + MaxHedgeHogs: 8; ), (BasePoints: @Template40Points; BasePointsCount: Succ(High(Template40Points)); @@ -2024,18 +2258,18 @@ TemplateHeight: 1024; TemplateWidth: 1024; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: false; - MaxHedgehogs: 8; + MaxHedgeHogs: 8; ), (BasePoints: @Template41Points; BasePointsCount: Succ(High(Template41Points)); FillPoints: @Template41FPoints; FillPointsCount: Succ(High(Template41FPoints)); - BezierizeCount: 3; - RandPassesCount: 5; + BezierizeCount: 2; + RandPassesCount: 9; TemplateHeight: 2048; TemplateWidth: 4096; canMirror: true; canFlip: true; isNegative: false; canInvert: false; hasGirders: true; - MaxHedgehogs: 48; + MaxHedgeHogs: 48; ), (BasePoints: @Template42Points; BasePointsCount: Succ(High(Template42Points)); @@ -2046,20 +2280,53 @@ TemplateHeight: 512; TemplateWidth: 1536; canMirror: true; canFlip: false; isNegative: false; canInvert: false; hasGirders: false; - MaxHedgehogs: 8; + MaxHedgeHogs: 8; + ), + (BasePoints: @Template43Points; + BasePointsCount: Succ(High(Template43Points)); + FillPoints: @Template43FPoints; + FillPointsCount: Succ(High(Template43FPoints)); + BezierizeCount: 2; + RandPassesCount: 9; + TemplateHeight: 4096; TemplateWidth: 4096; + canMirror: true; canFlip: true; isNegative: false; canInvert: false; + hasGirders: true; + MaxHedgeHogs: 48; + ), + (BasePoints: @Template44Points; + BasePointsCount: Succ(High(Template44Points)); + FillPoints: @Template44FPoints; + FillPointsCount: Succ(High(Template44FPoints)); + BezierizeCount: 5; + RandPassesCount: 3; + TemplateHeight: 2048; TemplateWidth: 4096; + canMirror: false; canFlip: false; isNegative: true; canInvert: false; + hasGirders: false; + MaxHedgeHogs: 48; + ), + (BasePoints: @Template45Points; + BasePointsCount: Succ(High(Template45Points)); + FillPoints: @Template45FPoints; + FillPointsCount: Succ(High(Template45FPoints)); + BezierizeCount: 5; + RandPassesCount: 7; + TemplateHeight: 2048; TemplateWidth: 4096; + canMirror: false; canFlip: false; isNegative: true; canInvert: false; + hasGirders: false; + MaxHedgeHogs: 48; ) ); const SmallTemplates: array[0..2] of Longword = ( 39, 40, 42 ); const MediumTemplates: array[0..17] of Longword = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ); -const LargeTemplates: array[0..19] of Longword = +const LargeTemplates: array[0..20] of Longword = ( 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 37, 38 + 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 43 ); -const CavernTemplates: array[0..4] of Longword = (36, 2, 3, 21, 29); +const CavernTemplates: array[0..5] of Longword = (36, 2, 3, 21, 29, 45); //const WackyTemplates: array[0..4] of Longword = (37, 38, 39, 40, 41); -const WackyTemplates: array[0..2] of Longword = (37, 38, 41); +const WackyTemplates: array[0..4] of Longword = (37, 38, 41, 43, 44); implementation diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLandTexture.pas --- a/hedgewars/uLandTexture.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLandTexture.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,17 +24,18 @@ procedure initModule; procedure freeModule; -procedure UpdateLandTexture(X, Width, Y, Height: LongInt); +procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean); procedure DrawLand(dX, dY: LongInt); procedure ResetLand; +procedure SetLandTexture; implementation uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender; -const TEXSIZE = 256; +const TEXSIZE = 128; type TLandRecord = record - shouldUpdate: boolean; + shouldUpdate, landAdded: boolean; tex: PTexture; end; @@ -62,10 +63,11 @@ Pixels2:= @tmpPixels end; -procedure UpdateLandTexture(X, Width, Y, Height: LongInt); +procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean); var tx, ty: Longword; begin - if (Width <= 0) or (Height <= 0) then exit; + if (Width <= 0) or (Height <= 0) then + exit; TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true); TryDo(X + Width <= LAND_WIDTH, 'UpdateLandTexture: wrong Width parameter', true); TryDo((Y >= 0) and (Y < LAND_HEIGHT), 'UpdateLandTexture: wrong Y parameter', true); @@ -74,34 +76,95 @@ if (cReducedQuality and rqBlurryLand) = 0 then for ty:= Y div TEXSIZE to (Y + Height - 1) div TEXSIZE do for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do - LandTextures[tx, ty].shouldUpdate:= true + begin + LandTextures[tx, ty].shouldUpdate:= true; + LandTextures[tx, ty].landAdded:= landAdded + end else for ty:= (Y div TEXSIZE) div 2 to ((Y + Height - 1) div TEXSIZE) div 2 do for tx:= (X div TEXSIZE) div 2 to ((X + Width - 1) div TEXSIZE) div 2 do + begin LandTextures[tx, ty].shouldUpdate:= true; + LandTextures[tx, ty].landAdded:= landAdded + end end; procedure RealLandTexUpdate; -var x, y: LongWord; +var x, y, ty, tx, lx, ly : LongWord; + isEmpty: boolean; begin +(* if LandTextures[0, 0].tex = nil then for x:= 0 to LANDTEXARW -1 do for y:= 0 to LANDTEXARH - 1 do with LandTextures[x, y] do begin - tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)); - glBindTexture(GL_TEXTURE_2D, tex^.id); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, tpHigh); + tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)); + glBindTexture(GL_TEXTURE_2D, tex^.id); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, tpHigh); end else +*) for x:= 0 to LANDTEXARW -1 do for y:= 0 to LANDTEXARH - 1 do with LandTextures[x, y] do if shouldUpdate then begin shouldUpdate:= false; - glBindTexture(GL_TEXTURE_2D, tex^.id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y)); + isEmpty:= not landAdded; + landAdded:= false; + ty:= 0; + tx:= 1; + ly:= y * TEXSIZE; + lx:= x * TEXSIZE; + // first check edges + while isEmpty and (ty < TEXSIZE) do + begin + isEmpty:= LandPixels[ly + ty, lx] and AMask = 0; + if isEmpty then isEmpty:= LandPixels[ly + ty, lx + TEXSIZE-1] and AMask = 0; + inc(ty) + end; + while isEmpty and (tx < TEXSIZE-1) do + begin + isEmpty:= LandPixels[ly, lx + tx] and AMask = 0; + if isEmpty then isEmpty:= LandPixels[ly + TEXSIZE-1, lx + tx] and AMask = 0; + inc(tx) + end; + // then search every other remaining. does this sort of stuff defeat compiler opts? + ty:= 2; + while isEmpty and (ty < TEXSIZE-1) do + begin + tx:= 2; + while isEmpty and (tx < TEXSIZE-1) do + begin + isEmpty:= LandPixels[ly + ty, lx + tx] and AMask = 0; + inc(tx,2) + end; + inc(ty,2); + end; + // and repeat + ty:= 1; + while isEmpty and (ty < TEXSIZE-1) do + begin + tx:= 1; + while isEmpty and (tx < TEXSIZE-1) do + begin + isEmpty:= LandPixels[ly + ty, lx + tx] and AMask = 0; + inc(tx,2) + end; + inc(ty,2); + end; + if not isEmpty then + begin + if tex = nil then tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)); + glBindTexture(GL_TEXTURE_2D, tex^.id); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y)); + end + else if tex <> nil then + begin + FreeTexture(tex); + tex:= nil + end; end end; @@ -113,14 +176,15 @@ for x:= 0 to LANDTEXARW -1 do for y:= 0 to LANDTEXARH - 1 do with LandTextures[x, y] do - if (cReducedQuality and rqBlurryLand) = 0 then - DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) - else - DrawTexture(dX + x * TEXSIZE * 2, dY + y * TEXSIZE * 2, tex, 2.0) + if tex <> nil then + if (cReducedQuality and rqBlurryLand) = 0 then + DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) + else + DrawTexture(dX + x * TEXSIZE * 2, dY + y * TEXSIZE * 2, tex, 2.0) end; -procedure initModule; +procedure SetLandTexture; begin if (cReducedQuality and rqBlurryLand) = 0 then begin @@ -136,15 +200,22 @@ SetLength(LandTextures, LANDTEXARW, LANDTEXARH); end; +procedure initModule; +begin +end; + procedure ResetLand; var x, y: LongInt; begin - for x:= 0 to LANDTEXARW -1 do + for x:= 0 to LANDTEXARW - 1 do for y:= 0 to LANDTEXARH - 1 do with LandTextures[x, y] do begin - if tex <> nil then FreeTexture(tex); - tex:= nil; + if tex <> nil then + begin + FreeTexture(tex); + tex:= nil + end end; end; @@ -154,6 +225,6 @@ if LandBackSurface <> nil then SDL_FreeSurface(LandBackSurface); LandBackSurface:= nil; - LandTextures:= nil; + SetLength(LandTextures, 0, 0); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uLocale.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,9 +26,13 @@ procedure LoadLocale(FileName: shortstring); function Format(fmt: shortstring; var arg: shortstring): shortstring; -function Format(fmt: ansistring; var arg: ansistring): ansistring; +function FormatA(fmt: ansistring; var arg: ansistring): ansistring; function GetEventString(e: TEventId): ansistring; +{$IFDEF HWLIBRARY} +procedure LoadLocaleWrapper(str: pchar); cdecl; export; +{$ENDIF} + implementation uses uRandom, uUtils, uVariables, uDebug; @@ -44,48 +48,58 @@ loaded: boolean; begin loaded:= false; -for e:= Low(TEventId) to High(TEventId) do first[e]:= true; +for e:= Low(TEventId) to High(TEventId) do + first[e]:= true; {$I-} // iochecks off Assign(f, FileName); filemode:= 0; // readonly Reset(f); -if IOResult = 0 then loaded:= true; +if IOResult = 0 then + loaded:= true; TryDo(loaded, 'Cannot load locale "' + FileName + '"', false); if loaded then - begin - while not eof(f) do - begin - readln(f, s); - if Length(s) = 0 then continue; - if not (s[1] in ['0'..'9']) then continue; - TryDo(Length(s) > 6, 'Load locale: empty string', true); - val(s[1]+s[2], a, c); - TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true); - TryDo(s[3] = ':', 'Load locale: ":" expected', true); - val(s[4]+s[5], b, c); - TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true); - TryDo(s[6] = '=', 'Load locale: "=" expected', true); - Delete(s, 1, 6); - case a of - 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammo[TAmmoStrId(b)]:= s; - 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then trmsg[TMsgStrId(b)]:= s; - 2: if (b >=0) and (b <= ord(High(TEventId))) then begin - TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false); - if first[TEventId(b)] then - begin - trevt_n[TEventId(b)]:= 0; - first[TEventId(b)]:= false; - end; - trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s; - inc(trevt_n[TEventId(b)]); - end; - 3: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammoc[TAmmoStrId(b)]:= s; - 4: if (b >=0) and (b <= ord(High(TAmmoStrId))) then trammod[TAmmoStrId(b)]:= s; - 5: if (b >=0) and (b <= ord(High(TGoalStrId))) then trgoal[TGoalStrId(b)]:= s; + begin + while not eof(f) do + begin + readln(f, s); + if Length(s) = 0 then + continue; + if (s[1] < '0') or (s[1] > '9') then + continue; + TryDo(Length(s) > 6, 'Load locale: empty string', true); + val(s[1]+s[2], a, c); + TryDo(c = 0, 'Load locale: numbers should be two-digit: ' + s, true); + TryDo(s[3] = ':', 'Load locale: ":" expected', true); + val(s[4]+s[5], b, c); + TryDo(c = 0, 'Load locale: numbers should be two-digit' + s, true); + TryDo(s[6] = '=', 'Load locale: "=" expected', true); + Delete(s, 1, 6); + case a of + 0: if (b >=0) and (b <= ord(High(TAmmoStrId))) then + trammo[TAmmoStrId(b)]:= s; + 1: if (b >=0) and (b <= ord(High(TMsgStrId))) then + trmsg[TMsgStrId(b)]:= s; + 2: if (b >=0) and (b <= ord(High(TEventId))) then + begin + TryDo(trevt_n[TEventId(b)] < MAX_EVENT_STRINGS, 'Too many event strings in ' + IntToStr(a) + ':' + IntToStr(b), false); + if first[TEventId(b)] then + begin + trevt_n[TEventId(b)]:= 0; + first[TEventId(b)]:= false; + end; + trevt[TEventId(b)][trevt_n[TEventId(b)]]:= s; + inc(trevt_n[TEventId(b)]); + end; + 3: if (b >=0) and (b <= ord(High(TAmmoStrId))) then + trammoc[TAmmoStrId(b)]:= s; + 4: if (b >=0) and (b <= ord(High(TAmmoStrId))) then + trammod[TAmmoStrId(b)]:= s; + 5: if (b >=0) and (b <= ord(High(TGoalStrId))) then + trgoal[TGoalStrId(b)]:= s; end; end; - Close(f) + Close(f); end; {$I+} end; @@ -102,21 +116,27 @@ var i: LongInt; begin i:= Pos('%1', fmt); -if i = 0 then Format:= fmt - else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) +if i = 0 then + Format:= fmt +else + Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) end; -function Format(fmt: ansistring; var arg: ansistring): ansistring; +function FormatA(fmt: ansistring; var arg: ansistring): ansistring; var i: LongInt; begin i:= Pos('%1', fmt); -if i = 0 then Format:= fmt - else Format:= copy(fmt, 1, i - 1) + arg + Format(copy(fmt, i + 2, Length(fmt) - i - 1), arg) +if i = 0 then + FormatA:= fmt +else + FormatA:= copy(fmt, 1, i - 1) + arg + FormatA(copy(fmt, i + 2, Length(fmt) - i - 1), arg) end; +{$IFDEF HWLIBRARY} procedure LoadLocaleWrapper(str: pchar); cdecl; export; begin LoadLocale(Strpas(str)); end; +{$ENDIF} end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uMisc.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,20 +1,20 @@ (* -* Hedgewars, a free turn based strategy game -* Copyright (c) 2004-2011 Andrey Korotaev -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; version 2 of the License -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -*) + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) {$INCLUDE "options.inc"} @@ -23,16 +23,33 @@ uses SDLh, uConsts, GLunit, uTypes; -procedure movecursor(dx, dy: LongInt); -function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; -function MakeScreenshot(filename: shortstring): boolean; -function GetTeamStatString(p: PTeam): shortstring; - procedure initModule; procedure freeModule; +procedure movecursor(dx, dy: LongInt); +function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; +function MakeScreenshot(filename: shortstring; k: LongInt): boolean; +function GetTeamStatString(p: PTeam): shortstring; +{$IFDEF SDL13} +function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; +{$ELSE} +function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline; +{$ENDIF} + implementation -uses typinfo, sysutils, uVariables, uUtils; +uses SysUtils, uVariables, uUtils + {$IFDEF PNG_SCREENSHOTS}, PNGh, png {$ENDIF} + {$IFNDEF USE_SDLTHREADS} {$IFDEF UNIX}, cthreads{$ENDIF} {$ENDIF}; + +type PScreenshot = ^TScreenshot; + TScreenshot = record + buffer: PByte; + filename: shortstring; + width, height: LongInt; + size: QWord; + end; + +var conversionFormat: PSDL_PixelFormat; procedure movecursor(dx, dy: LongInt); var x, y: LongInt; @@ -45,12 +62,65 @@ SDL_WarpMouse(x, y); end; -// captures and saves the screen. returns true on success. -function MakeScreenshot(filename: shortstring): Boolean; -var success: boolean; - p: Pointer; - size: QWord; +{$IFDEF PNG_SCREENSHOTS} +// this funtion will be executed in separate thread +function SaveScreenshot(screenshot: pointer): PtrInt; +var i: LongInt; + png_ptr: ^png_struct; + info_ptr: ^png_info; f: file; + image: PScreenshot; +begin +image:= PScreenshot(screenshot); + +png_ptr := png_create_write_struct(png_get_libpng_ver(nil), nil, nil, nil); +if png_ptr = nil then +begin + // AddFileLog('Error: Could not create png write struct.'); + SaveScreenshot:= 0; + exit; +end; + +info_ptr := png_create_info_struct(png_ptr); +if info_ptr = nil then +begin + png_destroy_write_struct(@png_ptr, nil); + // AddFileLog('Error: Could not create png info struct.'); + SaveScreenshot:= 0; + exit; +end; + +{$IOCHECKS OFF} +Assign(f, image^.filename); +Rewrite(f, 1); +if IOResult = 0 then + begin + png_init_pascal_io(png_ptr,@f); + png_set_IHDR(png_ptr, info_ptr, image^.width, image^.height, + 8, // bit depth + PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + png_write_info(png_ptr, info_ptr); + // glReadPixels and libpng number rows in different order + for i:= image^.height-1 downto 0 do + png_write_row(png_ptr, image^.buffer + i*4*image^.width); + png_write_end(png_ptr, info_ptr); + Close(f); + end; +{$IOCHECKS ON} + +// free everything +png_destroy_write_struct(@png_ptr, @info_ptr); +FreeMem(image^.buffer, image^.size); +Dispose(image); +SaveScreenshot:= 0; +end; + +{$ELSE} // no PNG_SCREENSHOTS + +// this funtion will be executed in separate thread +function SaveScreenshot(screenshot: pointer): PtrInt; +var f: file; // Windows Bitmap Header head: array[0..53] of Byte = ( $42, $4D, // identifier ("BM") @@ -69,81 +139,162 @@ 0, 0, 0, 0, // number of colors (all) 0, 0, 0, 0 // number of important colors ); + image: PScreenshot; + size: QWord; begin -// flash -ScreenFade:= sfFromWhite; -ScreenFadeValue:= sfMax; -ScreenFadeSpeed:= 5; - -size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4; -p:= GetMem(size); +image:= PScreenshot(screenshot); -// memory could not be allocated -if p = nil then -begin - AddFileLog('Error: Could not allocate memory for screenshot.'); - exit(false); -end; - -// update header information and file name -filename:= UserPathPrefix + '/Screenshots/' + filename + '.bmp'; +size:= image^.Width*image^.Height*4; head[$02]:= (size + 54) and $ff; head[$03]:= ((size + 54) shr 8) and $ff; head[$04]:= ((size + 54) shr 16) and $ff; head[$05]:= ((size + 54) shr 24) and $ff; -head[$12]:= cScreenWidth and $ff; -head[$13]:= (cScreenWidth shr 8) and $ff; -head[$14]:= (cScreenWidth shr 16) and $ff; -head[$15]:= (cScreenWidth shr 24) and $ff; -head[$16]:= cScreenHeight and $ff; -head[$17]:= (cScreenHeight shr 8) and $ff; -head[$18]:= (cScreenHeight shr 16) and $ff; -head[$19]:= (cScreenHeight shr 24) and $ff; +head[$12]:= image^.Width and $ff; +head[$13]:= (image^.Width shr 8) and $ff; +head[$14]:= (image^.Width shr 16) and $ff; +head[$15]:= (image^.Width shr 24) and $ff; +head[$16]:= image^.Height and $ff; +head[$17]:= (image^.Height shr 8) and $ff; +head[$18]:= (image^.Height shr 16) and $ff; +head[$19]:= (image^.Height shr 24) and $ff; head[$22]:= size and $ff; head[$23]:= (size shr 8) and $ff; head[$24]:= (size shr 16) and $ff; head[$25]:= (size shr 24) and $ff; -// read pixel from the front buffer -glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_BGRA, GL_UNSIGNED_BYTE, p); - {$IOCHECKS OFF} -Assign(f, filename); +Assign(f, image^.filename); Rewrite(f, 1); if IOResult = 0 then begin BlockWrite(f, head, sizeof(head)); - BlockWrite(f, p^, size); + BlockWrite(f, image^.buffer^, size); Close(f); - success:= true; end else begin - AddFileLog('Error: Could not write to ' + filename); - success:= false; + //AddFileLog('Error: Could not write to ' + filename); end; {$IOCHECKS ON} -FreeMem(p, size); -MakeScreenshot:= success; +// free everything +FreeMem(image^.buffer, image^.size); +Dispose(image); +SaveScreenshot:= 0; +end; + +{$ENDIF} // no PNG_SCREENSHOTS + +{$IFDEF USE_VIDEO_RECORDING} +// make image k times smaller (useful for saving thumbnails) +procedure ReduceImage(img: PByte; width, height, k: LongInt); +var i, j, i0, j0, w, h, r, g, b: LongInt; +begin + w:= width div k; + h:= height div k; + + // rescale inplace + if k <> 1 then + begin + for i:= 0 to h-1 do + for j:= 0 to w-1 do + begin + r:= 0; + g:= 0; + b:= 0; + for i0:= 0 to k-1 do + for j0:= 0 to k-1 do + begin + inc(r, img[4*(width*(i*k+i0) + j*k+j0)+0]); + inc(g, img[4*(width*(i*k+i0) + j*k+j0)+1]); + inc(b, img[4*(width*(i*k+i0) + j*k+j0)+2]); + end; + img[4*(w*i + j)+0]:= r div (k*k); + img[4*(w*i + j)+1]:= g div (k*k); + img[4*(w*i + j)+2]:= b div (k*k); + img[4*(w*i + j)+3]:= 255; + end; + end; +end; +{$ENDIF} + +// captures and saves the screen. returns true on success. +// saved image will be k times smaller than original (useful for saving thumbnails). +function MakeScreenshot(filename: shortstring; k: LongInt): Boolean; +var p: Pointer; + size: QWord; + image: PScreenshot; + format: GLenum; + ext: string[4]; +begin +{$IFDEF PNG_SCREENSHOTS} +format:= GL_RGBA; +ext:= '.png'; +{$ELSE} +format:= GL_BGRA; +ext:= '.bmp'; +{$ENDIF} + +size:= toPowerOf2(cScreenWidth) * toPowerOf2(cScreenHeight) * 4; +p:= GetMem(size); // will be freed in SaveScreenshot() + +// memory could not be allocated +if p = nil then +begin + AddFileLog('Error: Could not allocate memory for screenshot.'); + MakeScreenshot:= false; + exit; +end; + +// read pixels from the front buffer +glReadPixels(0, 0, cScreenWidth, cScreenHeight, format, GL_UNSIGNED_BYTE, p); + +{$IFDEF USE_VIDEO_RECORDING} +ReduceImage(p, cScreenWidth, cScreenHeight, k); +{$ENDIF} + +// allocate and fill structure that will be passed to new thread +New(image); // will be disposed in SaveScreenshot() +image^.filename:= UserPathPrefix + filename + ext; +image^.width:= cScreenWidth div k; +image^.height:= cScreenHeight div k; +image^.size:= size; +image^.buffer:= p; + +{$IFDEF USE_SDLTHREADS} +SDL_CreateThread(@SaveScreenshot{$IFDEF SDL13}, nil{$ENDIF}, image); +{$ELSE} +BeginThread(@SaveScreenshot, image); +{$ENDIF} +MakeScreenshot:= true; // possibly it is not true but we will not wait for thread to terminate end; // http://www.idevgames.com/forums/thread-5602-post-21860.html#pid21860 function doSurfaceConversion(tmpsurf: PSDL_Surface): PSDL_Surface; var convertedSurf: PSDL_Surface; begin + doSurfaceConversion:= tmpsurf; if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or (tmpsurf^.format^.bitsperpixel = 24) then - begin + begin convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE); SDL_FreeSurface(tmpsurf); - exit(convertedSurf); - end; - - exit(tmpsurf); + doSurfaceConversion:= convertedSurf; + end; end; +{$IFDEF SDL13} +function SDL_RectMake(x, y, width, height: LongInt): TSDL_Rect; inline; +{$ELSE} +function SDL_RectMake(x, y: SmallInt; width, height: Word): TSDL_Rect; inline; +{$ENDIF} +begin + SDL_RectMake.x:= x; + SDL_RectMake.y:= y; + SDL_RectMake.w:= width; + SDL_RectMake.h:= height; +end; function GetTeamStatString(p: PTeam): shortstring; var s: ansistring; @@ -153,14 +304,13 @@ end; procedure initModule; -const SDL_PIXELFORMAT_ABGR8888 = ((1 shl 31) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4); +const SDL_PIXELFORMAT_ABGR8888 = (1 shl 31) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4; begin conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888); end; procedure freeModule; begin - recordFileName:= ''; SDL_FreeFormat(conversionFormat); end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uMobile.pas --- a/hedgewars/uMobile.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uMobile.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,51 +18,71 @@ {$INCLUDE "options.inc"} +(* + * This unit contains a lot of useful functions when hw is running on mobile + * Unlike HwLibrary when you declare functions that you will call from your code, + * here you need to provide functions that Pascall code will call. + *) + unit uMobile; interface -{$IFDEF IPHONEOS} -(* iOS calls written in ObjcExports.m *) -procedure clearView; cdecl; external; -procedure startLoadingIndicator; cdecl; external; -procedure stopLoadingIndicator; cdecl; external; -procedure saveFinishedSynching; cdecl; external; -procedure updateVisualsNewTurn; cdecl; external; -function isApplePhone: Boolean; cdecl; external; -procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; -{$ENDIF} function isPhone: Boolean; inline; +function getScreenDPI: Double; inline; procedure performRumble; inline; procedure GameLoading; inline; procedure GameLoaded; inline; -procedure AmmoUpdate; // do not inline -procedure NewTurnBeginning; inline; procedure SaveLoadingEnded; inline; implementation -uses uVariables; +uses uVariables, uConsole, SDLh; + +// add here any external call that you need +{$IFDEF IPHONEOS} +(* iOS calls written in ObjcExports.m *) +procedure startLoadingIndicator; cdecl; external; +procedure stopLoadingIndicator; cdecl; external; +procedure saveFinishedSynching; cdecl; external; +function isApplePhone: Boolean; cdecl; external; +procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; +{$ENDIF} // this function is just to determine whether we are running on a limited screen device function isPhone: Boolean; inline; begin + isPhone:= false; {$IFDEF IPHONEOS} - exit(isApplePhone()); + isPhone:= isApplePhone(); +{$ENDIF} +{$IFDEF ANDROID} + //nasty nasty hack. TODO: implement callback to java to have a unified way of determining if it is a tablet + if (cScreenWidth < 1000) and (cScreenHeight < 500) then + isPhone:= true; {$ENDIF} - exit(false); +end; + +function getScreenDPI: Double; inline; +begin +{$IFDEF ANDROID} +// getScreenDPI:= Android_JNI_getDensity(); + getScreenDPI:= 1; +{$ELSE} + getScreenDPI:= 1; +{$ENDIF} end; // this function should make the device vibrate in some way -procedure performRumble; inline; -const kSystemSoundID_Vibrate = $00000FFF; +procedure PerformRumble; inline; +{$IFDEF IPHONEOS}const kSystemSoundID_Vibrate = $00000FFF;{$ENDIF} begin // do not vibrate while synchronising a demo/save if not fastUntilLag then - begin + begin {$IFDEF IPHONEOS} AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); {$ENDIF} - end; + end; end; procedure GameLoading; inline; @@ -79,25 +99,6 @@ {$ENDIF} end; -procedure AmmoUpdate; // do not inline -begin -{$IFDEF IPHONEOS} - if (CurrentTeam = nil) or - (CurrentTeam^.ExtDriven) or - (CurrentTeam^.Hedgehogs[0].BotLevel <> 0) then - exit(); // the other way around throws a compiler error - updateVisualsNewTurn(); -{$ENDIF} -end; - -procedure NewTurnBeginning; inline; -begin -{$IFDEF IPHONEOS} - clearView(); -{$ENDIF} - AmmoUpdate(); -end; - procedure SaveLoadingEnded; inline; begin {$IFDEF IPHONEOS} diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uRandom.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,22 +29,26 @@ *) interface uses uFloat; -{$INCLUDE "config.inc"} - -procedure initModule; -procedure freeModule; procedure SetRandomSeed(Seed: shortstring); // Sets the seed that should be used for generating pseudo-random values. -function GetRandom: hwFloat; overload; // Returns a pseudo-random hwFloat. -function GetRandom(m: LongWord): LongWord; overload; // Returns a positive pseudo-random integer smaller than m. +function GetRandomf: hwFloat; overload; // Returns a pseudo-random hwFloat. +function GetRandom(m: LongWord): LongWord; overload; inline; // Returns a positive pseudo-random integer smaller than m. +procedure AddRandomness(r: LongWord); inline; function rndSign(num: hwFloat): hwFloat; // Returns num with a random chance of having a inverted sign. + implementation var cirbuf: array[0..63] of Longword; n: byte; -function GetNext: Longword; +procedure AddRandomness(r: LongWord); inline; +begin +n:= (n + 1) and $3F; +cirbuf[n]:= cirbuf[n] xor r +end; + +function GetNext: Longword; inline; begin n:= (n + 1) and $3F; cirbuf[n]:= @@ -60,7 +64,8 @@ begin n:= 54; -if Length(Seed) > 54 then Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf +if Length(Seed) > 54 then + Seed:= copy(Seed, 1, 54); // not 55 to ensure we have odd numbers in cirbuf for i:= 0 to Pred(Length(Seed)) do cirbuf[i]:= byte(Seed[i + 1]); @@ -68,17 +73,18 @@ for i:= Length(Seed) to 54 do cirbuf[i]:= $A98765 + 68; // odd number -for i:= 0 to 1023 do GetNext +for i:= 0 to 1023 do + GetNext end; -function GetRandom: hwFloat; +function GetRandomf: hwFloat; begin GetNext; -GetRandom.isNegative:= false; -GetRandom.QWordValue:= GetNext +GetRandomf.isNegative:= false; +GetRandomf.QWordValue:= GetNext end; -function GetRandom(m: LongWord): LongWord; +function GetRandom(m: LongWord): LongWord; inline; begin GetNext; GetRandom:= GetNext mod m @@ -90,15 +96,4 @@ rndSign:= num end; -procedure initModule; -begin - n:= 54; - FillChar(cirbuf, 64*sizeof(Longword), 0); -end; - -procedure freeModule; -begin - -end; - end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uRender.pas --- a/hedgewars/uRender.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uRender.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,51 +24,58 @@ uses SDLh, uTypes, GLunit, uConsts; -procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); -procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); -procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); -procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); -procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); -procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); -procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat = 1.0); -procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); -procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); -procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); -procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); -procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); -procedure DrawCentered(X, Top: LongInt; Source: PTexture); -procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); -procedure DrawFillRect(r: TSDL_Rect); -procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); -procedure DrawCircle(X, Y, Radius, Width: LongInt); -procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); -procedure Tint(r, g, b, a: Byte); inline; -procedure Tint(c: Longword); inline; +procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); +procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); +procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); +procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); +procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); +procedure DrawSpriteRotatedF (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); -var - HHTexture: PTexture; +procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; +procedure DrawTexture (X, Y: LongInt; Texture: PTexture; Scale: GLfloat); +procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); +procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); +procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); +procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); +procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); +procedure DrawTextureRotatedF (Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); + +procedure DrawCircle (X, Y, Radius, Width: LongInt); +procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); + +procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); +procedure DrawFillRect (r: TSDL_Rect); +procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); +procedure DrawScreenWidget (widget: POnScreenWidget); + +procedure Tint (r, g, b, a: Byte); inline; +procedure Tint (c: Longword); inline; + implementation uses uVariables; +var LastTint: LongWord = 0; + procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); begin r.y:= r.y + Height * Position; r.h:= Height; -DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) +DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) end; -procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); +procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); begin -DrawFromRect(X, Y, r^.w, r^.h, r, SourceTexture) +DrawTextureFromRect(X, Y, r^.w, r^.h, r, SourceTexture) end; -procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); +procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); var rr: TSDL_Rect; _l, _r, _t, _b: real; VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; begin -if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then exit; +if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then + exit; // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) if (abs(X) > W) and ((abs(X + W / 2) - W / 2) > cScreenWidth / cScaleFactor) then @@ -106,12 +113,15 @@ TextureBuffer[3].X:= _l; TextureBuffer[3].Y:= _b; - glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); end; +procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline; +begin + DrawTexture(X, Y, Texture, 1.0); +end; procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); begin @@ -131,10 +141,10 @@ procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); begin - DrawRotatedTextureF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) + DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) end; -procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); +procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); var ft, fb, fl, fr: GLfloat; hw, nx, ny: LongInt; VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; @@ -194,31 +204,32 @@ glPopMatrix end; -procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); +procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); begin - DrawRotatedTex(SpritesData[Sprite].Texture, + DrawTextureRotated(SpritesData[Sprite].Texture, SpritesData[Sprite].Width, SpritesData[Sprite].Height, X, Y, Dir, Angle) end; -procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); +procedure DrawSpriteRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); begin glPushMatrix; glTranslatef(X, Y, 0); if Dir < 0 then - glRotatef(Angle, 0, 0, -1) + glRotatef(Angle, 0, 0, -1) else - glRotatef(Angle, 0, 0, 1); -if Dir < 0 then glScalef(-1.0, 1.0, 1.0); + glRotatef(Angle, 0, 0, 1); +if Dir < 0 then + glScalef(-1.0, 1.0, 1.0); DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); glPopMatrix end; -procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); +procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); var VertexBuffer: array [0..3] of TVertex2f; begin // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) @@ -231,14 +242,15 @@ glTranslatef(X, Y, 0); if Dir < 0 then - begin - hw:= - hw; - glRotatef(Angle, 0, 0, -1); - end else - glRotatef(Angle, 0, 0, 1); + begin + hw:= - hw; + glRotatef(Angle, 0, 0, -1); + end +else + glRotatef(Angle, 0, 0, 1); -glBindTexture(GL_TEXTURE_2D, Tex^.id); +glBindTexture(GL_TEXTURE_2D, Texture^.id); VertexBuffer[0].X:= -hw; VertexBuffer[0].Y:= -hh; @@ -250,20 +262,31 @@ VertexBuffer[3].Y:= hh; glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); -glTexCoordPointer(2, GL_FLOAT, 0, @Tex^.tb); +glTexCoordPointer(2, GL_FLOAT, 0, @Texture^.tb); glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); glPopMatrix end; -procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); +procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); var row, col, numFramesFirstCol: LongInt; begin -if SpritesData[Sprite].imageHeight = 0 then exit; -numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height; -row:= Frame mod numFramesFirstCol; -col:= Frame div numFramesFirstCol; -DrawSprite2 (Sprite, X, Y, col, row); + if SpritesData[Sprite].imageHeight = 0 then + exit; + numFramesFirstCol:= SpritesData[Sprite].imageHeight div SpritesData[Sprite].Height; + row:= Frame mod numFramesFirstCol; + col:= Frame div numFramesFirstCol; + DrawSprite(Sprite, X, Y, col, row); +end; + +procedure DrawSprite(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); +var r: TSDL_Rect; +begin + r.x:= FrameX * SpritesData[Sprite].Width; + r.w:= SpritesData[Sprite].Width; + r.y:= FrameY * SpritesData[Sprite].Height; + r.h:= SpritesData[Sprite].Height; + DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) end; procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); @@ -287,20 +310,10 @@ dec(r.h, r.y); dec(r.w, r.x); -DrawFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) +DrawTextureFromRect(X + r.x, Y + r.y, @r, SpritesData[Sprite].Texture) end; -procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); -var r: TSDL_Rect; -begin - r.x:= FrameX * SpritesData[Sprite].Width; - r.w:= SpritesData[Sprite].Width; - r.y:= FrameY * SpritesData[Sprite].Height; - r.h:= SpritesData[Sprite].Height; - DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) -end; - -procedure DrawCentered(X, Top: LongInt; Source: PTexture); +procedure DrawTextureCentered(X, Top: LongInt; Source: PTexture); var scale: GLfloat; begin if (Source^.w + 20) > cScreenWidth then @@ -395,10 +408,10 @@ procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); const VertexBuffer: array [0..3] of TVertex2f = ( - (x: -16; y: -16), - (x: 16; y: -16), - (x: 16; y: 16), - (x: -16; y: 16)); + (X: -16; Y: -16), + (X: 16; Y: -16), + (X: 16; Y: 16), + (X: -16; Y: 16)); var l, r, t, b: real; TextureBuffer: array [0..3] of TVertex2f; begin @@ -412,13 +425,14 @@ b:= (Pos + 1) * 32 / HHTexture^.h; if Dir = -1 then - begin - l:= (Step + 1) * 32 / HHTexture^.w; - r:= Step * 32 / HHTexture^.w - end else - begin - l:= Step * 32 / HHTexture^.w; - r:= (Step + 1) * 32 / HHTexture^.w + begin + l:= (Step + 1) * 32 / HHTexture^.w; + r:= Step * 32 / HHTexture^.w + end + else + begin + l:= Step * 32 / HHTexture^.w; + r:= (Step + 1) * 32 / HHTexture^.w end; @@ -444,34 +458,78 @@ glPopMatrix end; +procedure DrawScreenWidget(widget: POnScreenWidget); +{$IFDEF USE_TOUCH_INTERFACE} +var alpha: byte = $FF; +begin +with widget^ do + begin + if (fadeAnimStart <> 0) then + begin + if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then + fadeAnimStart:= 0 + else + if show then + alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) + else + alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); + end; + + with moveAnim do + if animate then + if RealTicks > (startTime + MOVE_ANIM_TIME) then + begin + startTime:= 0; + animate:= false; + frame.x:= target.x; + frame.y:= target.y; + active.x:= active.x + (target.x - source.x); + active.y:= active.y + (target.y - source.y); + end + else + begin + frame.x:= source.x + Round((target.x - source.x) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); + frame.y:= source.y + Round((target.y - source.y) * ((RealTicks - startTime) / MOVE_ANIM_TIME)); + end; + + if show or (fadeAnimStart <> 0) then + begin + Tint($FF, $FF, $FF, alpha); + DrawTexture(frame.x, frame.y, spritesData[sprite].Texture, buttonScale); + Tint($FF, $FF, $FF, $FF); + end; + end; +{$ELSE} +begin +widget:= widget; // avoid hint +{$ENDIF} +end; procedure Tint(r, g, b, a: Byte); inline; -const - lastTint: Longword = 0; -var - nc, tw: Longword; +var nc, tw: Longword; begin -nc:= (a shl 24) or (b shl 16) or (g shl 8) or r; + nc:= (a shl 24) or (b shl 16) or (g shl 8) or r; -if nc = lastTint then - exit; + if nc = lastTint then + exit; -if cGrayScale then - begin - tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE); - if tw > 255 then tw:= 255; - r:= tw; - g:= tw; - b:= tw - end; + if GrayScale then + begin + tw:= round(r * RGB_LUMINANCE_RED + g * RGB_LUMINANCE_GREEN + b * RGB_LUMINANCE_BLUE); + if tw > 255 then + tw:= 255; + r:= tw; + g:= tw; + b:= tw + end; -glColor4ub(r, g, b, a); -lastTint:= nc; + glColor4ub(r, g, b, a); + lastTint:= nc; end; procedure Tint(c: Longword); inline; begin -Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) + Tint(((c shr 24) and $FF), ((c shr 16) and $FF), (c shr 8) and $FF, (c and $FF)) end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uRenderUtils.pas --- a/hedgewars/uRenderUtils.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uRenderUtils.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,20 +24,29 @@ uses SDLh, uTypes; procedure flipSurface(Surface: PSDL_Surface; Vertical: Boolean); + procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL -procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); -function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; -function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; +procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; +procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); + +procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; +procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt; frame: LongInt); +procedure DrawLine2Surf(dest: PSDL_Surface; x0,y0,x1,y1:LongInt; r,g,b: byte); procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); +function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; +function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; +function RenderSpeechBubbleTex(s: ansistring; SpeechType: Longword; font: THWFont): PTexture; + implementation -uses uUtils, uVariables, uConsts, uTextures, sysutils, uDebug; +uses uUtils, uVariables, uConsts, uTextures, SysUtils, uDebug; procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); var r: TSDL_Rect; begin r:= rect^; - if Clear then SDL_FillRect(Surface, @r, 0); + if Clear then + SDL_FillRect(Surface, @r, 0); BorderColor:= SDL_MapRGB(Surface^.format, BorderColor shr 16, BorderColor shr 8, BorderColor and $FF); FillColor:= SDL_MapRGB(Surface^.format, FillColor shr 16, FillColor shr 8, FillColor and $FF); @@ -61,32 +70,42 @@ r.h:= rect^.h - 4; SDL_FillRect(Surface, @r, FillColor) end; +(* +function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; +begin + WriteInRoundRect:= WriteInRoundRect(Surface, X, Y, Color, Font, s, 0); +end;*) -function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; +function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect; var w, h: LongInt; tmpsurf: PSDL_Surface; clr: TSDL_Color; - finalRect: TSDL_Rect; + finalRect, textRect: TSDL_Rect; begin TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h); + if (maxLength <> 0) and (w > maxLength) then w := maxLength; finalRect.x:= X; finalRect.y:= Y; - finalRect.w:= w + FontBorder * 2 + 4; - finalRect.h:= h + FontBorder * 2; - DrawRoundRect(@finalRect, cWhiteColor, endian(cNearBlackColorChannels.value), Surface, true); + finalRect.w:= w + cFontBorder * 2 + 4; + finalRect.h:= h + cFontBorder * 2; + textRect.x:= X; + textRect.y:= Y; + textRect.w:= w; + textRect.h:= h; + DrawRoundRect(@finalRect, cWhiteColor, cNearBlackColor, Surface, true); clr.r:= (Color shr 16) and $FF; clr.g:= (Color shr 8) and $FF; clr.b:= Color and $FF; tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(s), clr); - finalRect.x:= X + FontBorder + 2; - finalRect.y:= Y + FontBorder; + finalRect.x:= X + cFontBorder + 2; + finalRect.y:= Y + cFontBorder; SDLTry(tmpsurf <> nil, true); - SDL_UpperBlit(tmpsurf, nil, Surface, @finalRect); + SDL_UpperBlit(tmpsurf, @textRect, Surface, @finalRect); SDL_FreeSurface(tmpsurf); finalRect.x:= X; finalRect.y:= Y; - finalRect.w:= w + FontBorder * 2 + 4; - finalRect.h:= h + FontBorder * 2; + finalRect.w:= w + cFontBorder * 2 + 4; + finalRect.h:= h + cFontBorder * 2; WriteInRoundRect:= finalRect; end; @@ -119,21 +138,27 @@ end; end; -procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); -var srcX, srcY, i, j, maxDest: LongInt; +procedure copyToXY(src, dest: PSDL_Surface; destX, destY: LongInt); inline; +begin + copyToXYFromRect(src, dest, 0, 0, src^.w, src^.h, destX, destY); +end; + +procedure copyToXYFromRect(src, dest: PSDL_Surface; srcX, srcY, srcW, srcH, destX, destY: LongInt); +var i, j, maxDest, maxSrc, iX, iY: LongInt; srcPixels, destPixels: PLongWordArray; r0, g0, b0, a0, r1, g1, b1, a1: Byte; begin maxDest:= (dest^.pitch div 4) * dest^.h; + maxSrc:= (src^.pitch div 4) * src^.h; srcPixels:= src^.pixels; destPixels:= dest^.pixels; - for srcX:= 0 to src^.w - 1 do - for srcY:= 0 to src^.h - 1 do + for iX:= 0 to srcW - 1 do + for iY:= 0 to srcH - 1 do begin - i:= (destY + srcY) * (dest^.pitch div 4) + destX + srcX; - j:= srcY * (src^.pitch div 4) + srcX; - if (i < maxDest) and (srcPixels^[j] and AMask <> 0) then + i:= (destY + iY) * (dest^.pitch div 4) + (destX + iX); + j:= (srcY + iY) * (src^.pitch div 4) + (srcX + iX); + if (i < maxDest) and (j < maxSrc) and (srcPixels^[j] and AMask <> 0) then begin SDL_GetRGBA(destPixels^[i], dest^.format, @r0, @g0, @b0, @a0); SDL_GetRGBA(srcPixels^[j], src^.format, @r1, @g1, @b1, @a1); @@ -146,6 +171,63 @@ end; end; +procedure DrawSprite2Surf(sprite: TSprite; dest: PSDL_Surface; x,y: LongInt); inline; +begin + DrawSpriteFrame2Surf(sprite, dest, x, y, 0); +end; + +procedure DrawSpriteFrame2Surf(sprite: TSprite; dest: PSDL_Surface; x,y,frame: LongInt); +var numFramesFirstCol, row, col: LongInt; +begin + numFramesFirstCol:= SpritesData[sprite].imageHeight div SpritesData[sprite].Height; + row:= Frame mod numFramesFirstCol; + col:= Frame div numFramesFirstCol; + + copyToXYFromRect(SpritesData[sprite].Surface, dest, + col*SpritesData[sprite].Width, + row*SpritesData[sprite].Height, + SpritesData[sprite].Width, + spritesData[sprite].Height, + x,y); +end; + +procedure DrawLine2Surf(dest: PSDL_Surface; x0, y0,x1,y1: LongInt; r,g,b: byte); +var + dx,dy,err,e2,sx,sy: LongInt; + yMax: LongInt; + destPixels: PLongwordArray; +begin + //max:= (dest^.pitch div 4) * dest^.h; + yMax:= dest^.pitch div 4; + destPixels:= dest^.pixels; + + dx:= abs(x1-x0); + dy:= abs(y1-y0); + if x0 < x1 then sx:= 1 else sx:= -1; + if y0 < y1 then sy:= 1 else sy:= -1; + err:= dx-dy; + + while(true) do + begin + destPixels^[(y0 * yMax) + x0]:= SDL_MapRGB(dest^.format, r,g,b); //But will it blend? no + + if (x0 = x1) and (y0 = y1) then break; + + e2:= 2*err; + if e2 > -dy then + begin + err:= err - dy; + x0 := x0 + sx; + end; + + if e2 < dx then + begin + err:= err + dx; + y0:=y0+sy + end; + end; +end; + procedure copyRotatedSurface(src, dest: PSDL_Surface); // this is necessary since width/height are read only in SDL, apparently var y, x, i, j: LongInt; srcPixels, destPixels: PLongWordArray; @@ -166,25 +248,31 @@ end; end; -function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; +function RenderStringTex(s: ansistring; Color: Longword; font: THWFont): PTexture; +begin + RenderStringTex:= RenderStringTexLim(s, Color, font, 0); +end; + +function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture; var w, h: LongInt; finalSurface: PSDL_Surface; begin - if length(s) = 0 then s:= ' '; + if length(s) = 0 then s:= _S' '; font:= CheckCJKFont(s, font); w:= 0; h:= 0; // avoid compiler hints TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); + if (maxLength <> 0) and (w > maxLength) then w := maxLength; - finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + FontBorder * 2 + 4, h + FontBorder * 2, + finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2, 32, RMask, GMask, BMask, AMask); TryDo(finalSurface <> nil, 'RenderString: fail to create surface', true); - WriteInRoundRect(finalSurface, 0, 0, Color, font, s); + WriteInRoundRect(finalSurface, 0, 0, Color, font, s, maxLength); TryDo(SDL_SetColorKey(finalSurface, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - RenderStringTex:= Surface2Tex(finalSurface, false); + RenderStringTexLim:= Surface2Tex(finalSurface, false); SDL_FreeSurface(finalSurface); end; @@ -226,11 +314,13 @@ numLines:= 0; - if length(s) = 0 then s:= '...'; + if length(s) = 0 then + s:= '...'; font:= CheckCJKFont(s, font); w:= 0; h:= 0; // avoid compiler hints TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(s), @w, @h); - if w<8 then w:= 8; + if w<8 then + w:= 8; j:= 0; if (length(s) > 20) then begin @@ -249,7 +339,8 @@ substr:= copy(s, prevpos+1, pos-prevpos-1); i:= 0; j:= 0; TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(substr), @i, @j); - if i > w then w:= i; + if i > w then + w:= i; prevpos:= pos; end; inc(pos); @@ -347,22 +438,24 @@ begin if (s[pos] = #1) or (pos = length(s)) then begin - if s[pos] <> #1 then inc(pos); - while s[prevpos+1] = ' 'do inc(prevpos); + if s[pos] <> #1 then + inc(pos); + while s[prevpos+1] = ' 'do + inc(prevpos); substr:= copy(s, prevpos+1, pos-prevpos-1); if Length(substr) <> 0 then - begin - tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cNearBlackColorChannels); - rect.x:= edgeHeight + 1 + ((i - w) div 2); - // trying to more evenly position the text, vertically - rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h; - SDLTry(tmpsurf <> nil, true); - SDL_UpperBlit(tmpsurf, nil, finalSurface, @rect); - SDL_FreeSurface(tmpsurf); - inc(line); - prevpos:= pos; - end; - end; + begin + tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cNearBlackColorChannels); + rect.x:= edgeHeight + 1 + ((i - w) div 2); + // trying to more evenly position the text, vertically + rect.y:= edgeHeight + ((j-(numLines*h)) div 2) + line * h; + SDLTry(tmpsurf <> nil, true); + SDL_UpperBlit(tmpsurf, nil, finalSurface, @rect); + SDL_FreeSurface(tmpsurf); + inc(line); + prevpos:= pos; + end; + end; inc(pos); end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uScript.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ procedure ScriptLoad(name : shortstring); procedure ScriptOnGameInit; -procedure ScriptOnScreenResize(); +procedure ScriptOnScreenResize; procedure ScriptCall(fname : shortstring); function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; @@ -46,21 +46,24 @@ function ScriptExists(fname : shortstring) : boolean; -function ParseCommandOverride(key, value : shortstring) : shortstring; +//function ParseCommandOverride(key, value : shortstring) : shortstring; This did not work out well procedure initModule; procedure freeModule; implementation -{$IFNDEF LUA_DISABLED} -uses LuaPas in 'LuaPas.pas', +{$IFDEF USE_LUA_SCRIPT} +uses LuaPas, uConsole, uConsts, uVisualGears, uGears, + uGearsList, + uGearsUtils, uFloat, uWorld, uAmmos, + uTeams, uSound, uChat, uStats, @@ -77,7 +80,8 @@ uTextures, uLandGraphics, SDLh, - sysutils; + SysUtils, + uIO; var luaState : Plua_State; ScriptAmmoLoadout : shortstring; @@ -110,7 +114,8 @@ LuaError('Lua: Wrong number of parameters passed to band!'); lua_pushnil(L); end - else lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); + else + lua_pushinteger(L, lua_tointeger(L, 2) and lua_tointeger(L, 1)); lc_band := 1; end; @@ -121,7 +126,8 @@ LuaError('Lua: Wrong number of parameters passed to bor!'); lua_pushnil(L); end - else lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); + else + lua_pushinteger(L, lua_tointeger(L, 2) or lua_tointeger(L, 1)); lc_bor := 1; end; @@ -132,15 +138,29 @@ LuaError('Lua: Wrong number of parameters passed to bnot!'); lua_pushnil(L); end - else lua_pushinteger(L, not lua_tointeger(L, 1)); + else + lua_pushinteger(L, not lua_tointeger(L, 1)); lc_bnot := 1; end; +function lc_div(L: PLua_State): LongInt; Cdecl; +begin + if lua_gettop(L) <> 2 then + begin + LuaError('Lua: Wrong number of parameters passed to div!'); + lua_pushnil(L); + end + else + lua_pushinteger(L, lua_tointeger(L, 1) div lua_tointeger(L, 2)); + lc_div := 1; +end; + function lc_getinputmask(L : Plua_State) : LongInt; Cdecl; begin if lua_gettop(L) <> 0 then LuaError('Lua: Wrong number of parameters passed to GetInputMask!') - else lua_pushinteger(L, InputMask); + else + lua_pushinteger(L, InputMask); lc_getinputmask:= 1 end; @@ -148,7 +168,8 @@ begin if lua_gettop(L) <> 1 then LuaError('Lua: Wrong number of parameters passed to SetInputMask!') - else InputMask:= lua_tointeger(L, 1); + else + InputMask:= lua_tointeger(L, 1); lc_setinputmask:= 0 end; @@ -164,10 +185,19 @@ end; function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; +var t: PChar; + i,c: LongWord; + s: shortstring; begin if lua_gettop(L) = 1 then begin - ParseCommand(lua_tostring(L ,1), true); + t:= lua_tolstring(L,1,@c); + + for i:= 1 to c do s[i]:= t[i-1]; + s[0]:= char(c); + + ParseCommand(s, true, true); + end else LuaError('Lua: Wrong number of parameters passed to ParseCommand!'); @@ -230,45 +260,51 @@ function lc_spawnfakehealthcrate(L: Plua_State) : LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 4 then begin + if lua_gettop(L) <> 4 then + begin LuaError('Lua: Wrong number of parameters passed to SpawnFakeHealthCrate!'); lua_pushnil(L); - end - else begin + end + else + begin gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); lua_pushinteger(L, gear^.uid); - end; + end; lc_spawnfakehealthcrate := 1; end; function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 4 then begin + if lua_gettop(L) <> 4 then + begin LuaError('Lua: Wrong number of parameters passed to SpawnFakeAmmoCrate!'); lua_pushnil(L); - end - else begin + end + else + begin gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + AmmoCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); lua_pushinteger(L, gear^.uid); - end; + end; lc_spawnfakeammocrate := 1; end; function lc_spawnfakeutilitycrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 4 then begin + if lua_gettop(L) <> 4 then + begin LuaError('Lua: Wrong number of parameters passed to SpawnFakeUtilityCrate!'); lua_pushnil(L); - end - else begin + end + else + begin gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); + UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); lua_pushinteger(L, gear^.uid); - end; + end; lc_spawnfakeutilitycrate := 1; end; @@ -276,48 +312,65 @@ var gear: PGear; var health: LongInt; begin - if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then begin + if (lua_gettop(L) < 2) or (lua_gettop(L) > 3) then + begin LuaError('Lua: Wrong number of parameters passed to SpawnHealthCrate!'); lua_pushnil(L); - end - else begin - if lua_gettop(L) = 3 then health:= lua_tointeger(L, 3) - else health:= cHealthCaseAmount; - gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health); - if gear <> nil then lua_pushinteger(L, gear^.uid) - else lua_pushnil(L); - end; + end + else + begin + if lua_gettop(L) = 3 then + health:= lua_tointeger(L, 3) + else + health:= cHealthCaseAmount; + gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), HealthCrate, health, 0); + if gear <> nil then + lua_pushinteger(L, gear^.uid) + else + lua_pushnil(L); + end; lc_spawnhealthcrate := 1; end; function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 3 then begin + if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then + begin LuaError('Lua: Wrong number of parameters passed to SpawnAmmoCrate!'); lua_pushnil(L); - end - else begin - gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3)); - if gear <> nil then lua_pushinteger(L, gear^.uid) - else lua_pushnil(L); - end; + end + else + begin + if (lua_gettop(L) = 3) then + gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), 0) + else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), AmmoCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); + if gear <> nil then + lua_pushinteger(L, gear^.uid) + else + lua_pushnil(L); + end; lc_spawnammocrate := 1; end; function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 3 then begin + if (lua_gettop(L) <> 3) and (lua_gettop(L) <> 4) then + begin LuaError('Lua: Wrong number of parameters passed to SpawnUtilityCrate!'); lua_pushnil(L); - end - else begin - gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), - UtilityCrate, lua_tointeger(L, 3)); - if gear <> nil then lua_pushinteger(L, gear^.uid) - else lua_pushnil(L); - end; + end + else + begin + if (lua_gettop(L) = 3) then + gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), 0) + else gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_tointeger(L, 3), lua_tointeger(L, 4)); + if gear <> nil then + lua_pushinteger(L, gear^.uid) + else + lua_pushnil(L); + end; lc_spawnutilitycrate := 1; end; @@ -359,7 +412,8 @@ else begin gear:= GearByUID(lua_tointeger(L, 1)); - if gear <> nil then DeleteGear(gear); + if gear <> nil then + gear^.Message:= gear^.Message or gmDelete; end; lc_deletegear:= 0 end; @@ -389,7 +443,8 @@ lastVisualGearByUID:= vg; lua_pushinteger(L, vg^.uid) end - else lua_pushinteger(L, 0) + else + lua_pushinteger(L, 0) end; lc_addvisualgear:= 1; // 1 return value end; @@ -404,7 +459,8 @@ else begin vg:= VisualGearByUID(lua_tointeger(L, 1)); - if vg <> nil then DeleteVisualGear(vg); + if vg <> nil then + DeleteVisualGear(vg); end; lc_deletevisualgear:= 0 end; @@ -462,7 +518,8 @@ vg^.dY:= lua_tonumber(L, 5); vg^.Angle:= lua_tonumber(L, 6); vg^.Frame:= lua_tointeger(L, 7); - if lua_tointeger(L, 8) <> 0 then vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. + if lua_tointeger(L, 8) <> 0 then + vg^.FrameTicks:= lua_tointeger(L, 8); // find a better way to do this. maybe need to break all these up. vg^.State:= lua_tointeger(L, 9); vg^.Timer:= lua_tointeger(L, 10); vg^.Tint:= lua_tointeger(L, 11); @@ -557,12 +614,79 @@ lc_setgearmessage:= 0 end; +function lc_getgearpos(L : Plua_State) : LongInt; Cdecl; +var gear : PGear; +begin + if lua_gettop(L) <> 1 then + begin + LuaError('Lua: Wrong number of parameters passed to GetGearPos!'); + lua_pushnil(L); // return value on stack (nil) + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + lua_pushinteger(L, gear^.Pos) + else + lua_pushnil(L); + end; + lc_getgearpos:= 1 +end; + +function lc_setgearpos(L : Plua_State) : LongInt; Cdecl; +var gear : PGear; +begin + if lua_gettop(L) <> 2 then + LuaError('Lua: Wrong number of parameters passed to SetGearPos!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + gear^.Pos:= lua_tointeger(L, 2); + end; + lc_setgearpos:= 0 +end; + +function lc_getgearcollisionmask(L : Plua_State) : LongInt; Cdecl; +var gear : PGear; +begin + if lua_gettop(L) <> 1 then + begin + LuaError('Lua: Wrong number of parameters passed to GetGearCollisionMask!'); + lua_pushnil(L); // return value on stack (nil) + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + lua_pushinteger(L, gear^.CollisionMask) + else + lua_pushnil(L); + end; + lc_getgearcollisionmask:= 1 +end; + +function lc_setgearcollisionmask(L : Plua_State) : LongInt; Cdecl; +var gear : PGear; +begin + if lua_gettop(L) <> 2 then + LuaError('Lua: Wrong number of parameters passed to SetGearCollisionMask!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + gear^.CollisionMask:= lua_tointeger(L, 2); + end; + lc_setgearcollisionmask:= 0 +end; + function lc_gethoglevel(L : Plua_State): LongInt; Cdecl; var gear : PGear; begin if lua_gettop(L) <> 1 then LuaError('Lua: Wrong number of parameters passed to GetHogLevel!') - else begin + else + begin gear := GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then lua_pushinteger(L, gear^.Hedgehog^.BotLevel) @@ -654,7 +778,7 @@ TryDo(texsurf <> nil, errmsgCreateSurface, true); TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true); + DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); rr:= r; inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); DrawRoundRect(@rr, clan^.Color, clan^.Color, texsurf, false); @@ -724,11 +848,11 @@ gear:= GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then - hogName:= lua_tostring(L, 2); + hogName:= lua_tostring(L, 2); gear^.Hedgehog^.Name:= hogName; - FreeTexture(gear^.Hedgehog^.NameTagTex); - gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16); + FreeTexture(gear^.Hedgehog^.NameTagTex); + gear^.Hedgehog^.NameTagTex:= RenderStringTex(gear^.Hedgehog^.Name, gear^.Hedgehog^.Team^.Clan^.Color, fnt16); end; lc_sethogname:= 0; @@ -850,8 +974,10 @@ vgear : PVisualGear; s : LongWord; begin - if lua_gettop(L) = 4 then s:= lua_tointeger(L, 4) - else s:= 0; + if lua_gettop(L) = 4 then + s:= lua_tointeger(L, 4) + else + s:= 0; if (lua_gettop(L) = 4) or (lua_gettop(L) = 3) then begin @@ -864,11 +990,13 @@ vgear^.Text:= lua_tostring(L, 2); vgear^.Hedgehog:= gear^.Hedgehog; vgear^.FrameTicks:= lua_tointeger(L, 3); - if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1; + if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then + vgear^.FrameTicks:= 1; lua_pushinteger(L, vgear^.Uid) end end - else lua_pushnil(L) + else + lua_pushnil(L) end else LuaError('Lua: Wrong number of parameters passed to HogSay!'); lc_hogsay:= 1 @@ -886,21 +1014,21 @@ if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) and (CurrentHedgehog <> nil) then begin prevgear := CurrentHedgehog^.Gear; - prevgear^.Active := false; - prevgear^.State:= prevgear^.State and not gstHHDriven; - prevgear^.Z := cHHZ; - RemoveGearFromList(prevgear); - InsertGearToList(prevgear); - - CurrentHedgehog := gear^.Hedgehog; -// yes, this will muck up turn sequence - CurrentTeam := gear^.Hedgehog^.Team; + if prevgear <> nil then + begin + prevgear^.Active := false; + prevgear^.State:= prevgear^.State and (not gstHHDriven); + prevgear^.Z := cHHZ; + prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; + end; + + SwitchCurrentHedgehog(gear^.Hedgehog); + CurrentTeam:= CurrentHedgehog^.Team; gear^.State:= gear^.State or gstHHDriven; gear^.Active := true; gear^.Z := cCurrHHZ; - RemoveGearFromList(gear); - InsertGearToList(gear); + gear^.Message:= gear^.Message or gmRemoveFromList or gmAddToList; end end; lc_switchhog:= 0 @@ -912,19 +1040,19 @@ if lua_gettop(L) = 3 then begin - gear:= GearByUID(lua_tointeger(L, 1)); + gear:= GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Hedgehog <> nil) then AddAmmoAmount(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L,3) ); end else if lua_gettop(L) = 2 then begin - gear:= GearByUID(lua_tointeger(L, 1)); + gear:= GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Hedgehog <> nil) then AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); end else begin - LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); + LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); end; lc_addammo:= 0; @@ -938,8 +1066,10 @@ begin gear:= GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Hedgehog <> nil) then - if lua_gettop(L) = 2 then AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) - else AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) + if lua_gettop(L) = 2 then + AddAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))) + else + SetAmmo(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2)), lua_tointeger(L, 3)) end else LuaError('Lua: Wrong number of parameters passed to AddAmmo!'); lc_addammo:= 0 @@ -955,8 +1085,10 @@ if (gear <> nil) and (gear^.Hedgehog <> nil) then begin ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); - if ammo^.AmmoType = amNothing then lua_pushinteger(L, 0) - else lua_pushinteger(L, ammo^.Count) + if ammo^.AmmoType = amNothing then + lua_pushinteger(L, 0) + else + lua_pushinteger(L, ammo^.Count) end else lua_pushinteger(L, 0) end @@ -982,9 +1114,10 @@ begin gear^.Health:= lua_tointeger(L, 2); - if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then begin - RenderHealth(gear^.Hedgehog^); + RenderHealth(gear^.Hedgehog^); + RecountTeamHealth(gear^.Hedgehog^.Team) end; SetAllToActive; @@ -1016,7 +1149,7 @@ else begin gear := GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Hedgehog <> nil) then - gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_toboolean(L, 3); + gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]:= lua_tointeger(L, 3); end; lc_seteffect := 0; end; @@ -1031,9 +1164,9 @@ begin gear:= GearByUID(lua_tointeger(L, 1)); if (gear <> nil) and (gear^.Hedgehog <> nil) then - lua_pushboolean(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]) + lua_pushinteger(L, gear^.Hedgehog^.Effects[THogEffect(lua_tointeger(L, 2))]) else - lua_pushboolean(L, false) + lua_pushinteger(L, 0) end; lc_geteffect:= 1 end; @@ -1075,6 +1208,25 @@ lc_getstate:= 1 end; +function lc_gettag(L : Plua_State) : LongInt; Cdecl; +var gear : PGear; +begin + if lua_gettop(L) <> 1 then + begin + LuaError('Lua: Wrong number of parameters passed to GetX!'); + lua_pushnil(L); // return value on stack (nil) + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + lua_pushinteger(L, gear^.Tag) + else + lua_pushnil(L); + end; + lc_gettag:= 1 +end; + function lc_settag(L : Plua_State) : LongInt; Cdecl; var gear : PGear; begin @@ -1116,11 +1268,14 @@ fall:= lua_toboolean(L, 2); left:= lua_tointeger(L, 3); right:= lua_tointeger(L, 4); - if lua_gettop(L) = 5 then tryhard:= lua_toboolean(L, 5); + if lua_gettop(L) = 5 then + tryhard:= lua_toboolean(L, 5); if gear <> nil then FindPlace(gear, fall, left, right, tryhard); - if gear <> nil then lua_pushinteger(L, gear^.uid) - else lua_pushnil(L); + if gear <> nil then + lua_pushinteger(L, gear^.uid) + else + lua_pushnil(L); end; lc_findplace:= 1 end; @@ -1151,11 +1306,11 @@ end else begin - ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); - ParseCommand('grave ' + lua_tostring(L, 3), true); - ParseCommand('fort ' + lua_tostring(L, 4), true); - ParseCommand('voicepack ' + lua_tostring(L, 5), true); - if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true); + ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true, true); + ParseCommand('grave ' + lua_tostring(L, 3), true, true); + ParseCommand('fort ' + lua_tostring(L, 4), true, true); + ParseCommand('voicepack ' + lua_tostring(L, 5), true, true); + if (np = 6) then ParseCommand('flag ' + lua_tostring(L, 6), true, true); CurrentTeam^.Binds:= DefaultBinds // fails on x64 //lua_pushinteger(L, LongInt(CurrentTeam)); @@ -1174,8 +1329,8 @@ else begin temp:= lua_tostring(L, 4); - ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); - ParseCommand('hat ' + temp, true); + ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true, true); + ParseCommand('hat ' + temp, true, true); lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); end; lc_addhog:= 1; @@ -1238,10 +1393,12 @@ col:= gear^.CollisionIndex >= 0; x:= lua_tointeger(L, 2); y:= lua_tointeger(L, 3); - if col then DeleteCI(gear); + if col then + DeleteCI(gear); gear^.X:= int2hwfloat(x); gear^.Y:= int2hwfloat(y); - if col then AddGearCI(gear); + if col then + AddGearCI(gear); SetAllToActive end end; @@ -1293,6 +1450,7 @@ function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl; var gear: PGear; +var t: LongInt; begin if lua_gettop(L) <> 1 then begin @@ -1305,7 +1463,10 @@ gear:= GearByUID(lua_tointeger(L, 1)); if gear <> nil then begin - lua_pushinteger(L, hwRound(gear^.dX * 1000000)); + t:= hwRound(gear^.dX * 1000000); + // gear dX determines hog orientation + if (gear^.dX.isNegative) and (t = 0) then t:= -1; + lua_pushinteger(L, t); lua_pushinteger(L, hwRound(gear^.dY * 1000000)) end end; @@ -1337,8 +1498,10 @@ else begin ZoomValue:= lua_tonumber(L, 1); - if ZoomValue < cMaxZoomLevel then ZoomValue:= cMaxZoomLevel; - if ZoomValue > cMinZoomLevel then ZoomValue:= cMinZoomLevel; + if ZoomValue < cMaxZoomLevel then + ZoomValue:= cMaxZoomLevel; + if ZoomValue > cMinZoomLevel then + ZoomValue:= cMinZoomLevel; end; lc_setzoom:= 0 end; @@ -1368,6 +1531,22 @@ lc_setammo:= 0 end; +function lc_setammostore(L : Plua_State) : LongInt; Cdecl; +var np: LongInt; +begin + np:= lua_gettop(L); + if (np <> 4) then + LuaError('Lua: Wrong number of parameters passed to SetAmmoStore!') + else + begin + ScriptAmmoLoadout:= lua_tostring(L, 1); + ScriptAmmoProbability:= lua_tostring(L, 2); + ScriptAmmoDelay:= lua_tostring(L, 3); + ScriptAmmoReinforcement:= lua_tostring(L, 4); + end; + lc_setammostore:= 0 +end; + function lc_getrandom(L : Plua_State) : LongInt; Cdecl; var m : LongInt; begin @@ -1490,7 +1669,7 @@ if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then hat:= lua_tostring(L, 2); gear^.Hedgehog^.Hat:= hat; - LoadHedgehogHat(gear, hat); + LoadHedgehogHat(gear^.Hedgehog^, hat); end; lc_sethoghat:= 0; end; @@ -1516,6 +1695,68 @@ lc_getcurammotype := 1; end; +function lc_savecampaignvar(L : Plua_State): LongInt; Cdecl; +begin + if lua_gettop(L) <> 2 then + LuaError('Lua: Wrong number of parameters passed to SaveCampaignVar!') + else begin + SendIPC('V!' + lua_tostring(L, 1) + ' ' + lua_tostring(L, 2) + #0); + end; + lc_savecampaignvar := 0; +end; + +function lc_getcampaignvar(L : Plua_State): LongInt; Cdecl; +begin + if (lua_gettop(L) <> 1) then + LuaError('Lua: Wrong number of parameters passed to GetCampaignVar!') + else + SendIPCAndWaitReply('V?' + lua_tostring(L, 1)); + lua_pushstring(L, str2pchar(CampaignVariable)); + lc_getcampaignvar := 1; +end; + +function lc_hidehog(L: Plua_State): LongInt; Cdecl; +var gear: PGear; +begin + if lua_gettop(L) <> 1 then + LuaError('Lua: Wrong number of parameters passed to HideHog!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + hiddenHedgehogs[hiddenHedgehogsNumber]:=gear^.hedgehog; + inc(hiddenHedgehogsNumber); + HideHog(gear^.hedgehog); + end; + lc_hidehog := 0; +end; + +function lc_restorehog(L: Plua_State): LongInt; Cdecl; +var hog: PHedgehog; + i, j: LongInt; +begin + if lua_gettop(L) <> 1 then + LuaError('Lua: Wrong number of parameters passed to RestoreHog!') + else + begin + i := 0; + while (i < hiddenHedgehogsNumber) do + begin + if hiddenHedgehogs[i]^.gearHidden^.uid = LongWord(lua_tointeger(L, 1)) then + begin + hog := hiddenHedgehogs[i]; + RestoreHog(hog); + dec(hiddenHedgehogsNumber); + for j := i to hiddenHedgehogsNumber - 1 do + hiddenHedgehogs[j] := hiddenHedgehogs[j + 1]; + lc_restorehog := 0; + exit; + end; + inc(i); + end; + end; + lc_restorehog := 0; +end; + // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly) function lc_testrectforobstacle(L : Plua_State) : LongInt; Cdecl; var rtn: Boolean; @@ -1556,52 +1797,54 @@ procedure ScriptClearStack; begin -lua_settop(luaState, 0) + lua_settop(luaState, 0) end; procedure ScriptSetNil(name : shortstring); begin -lua_pushnil(luaState); -lua_setglobal(luaState, Str2PChar(name)); + lua_pushnil(luaState); + lua_setglobal(luaState, Str2PChar(name)); end; procedure ScriptSetInteger(name : shortstring; value : LongInt); begin -lua_pushinteger(luaState, value); -lua_setglobal(luaState, Str2PChar(name)); + lua_pushinteger(luaState, value); + lua_setglobal(luaState, Str2PChar(name)); end; procedure ScriptSetString(name : shortstring; value : shortstring); begin -lua_pushstring(luaState, Str2PChar(value)); -lua_setglobal(luaState, Str2PChar(name)); + lua_pushstring(luaState, Str2PChar(value)); + lua_setglobal(luaState, Str2PChar(name)); end; function ScriptGetInteger(name : shortstring) : LongInt; begin -lua_getglobal(luaState, Str2PChar(name)); -ScriptGetInteger:= lua_tointeger(luaState, -1); -lua_pop(luaState, 1); + lua_getglobal(luaState, Str2PChar(name)); + ScriptGetInteger:= lua_tointeger(luaState, -1); + lua_pop(luaState, 1); end; function ScriptGetString(name : shortstring) : shortstring; begin -lua_getglobal(luaState, Str2PChar(name)); -ScriptGetString:= lua_tostring(luaState, -1); -lua_pop(luaState, 1); + lua_getglobal(luaState, Str2PChar(name)); + ScriptGetString:= lua_tostring(luaState, -1); + lua_pop(luaState, 1); end; procedure ScriptOnGameInit; +var i, j, k: LongInt; begin // not required if there is no script to run if not ScriptLoaded then exit; // push game variables so they may be modified by the script -ScriptSetInteger('BorderColor', cExplosionBorderColor); +ScriptSetInteger('BorderColor', ExplosionBorderColor); ScriptSetInteger('GameFlags', GameFlags); ScriptSetString('Seed', cSeed); ScriptSetInteger('TemplateFilter', cTemplateFilter); +ScriptSetInteger('TemplateNumber', LuaTemplateNumber); ScriptSetInteger('MapGen', cMapGen); ScriptSetInteger('ScreenHeight', cScreenHeight); ScriptSetInteger('ScreenWidth', cScreenWidth); @@ -1610,6 +1853,7 @@ ScriptSetInteger('HealthCaseProb', cHealthCaseProb); ScriptSetInteger('HealthCaseAmount', cHealthCaseAmount); ScriptSetInteger('DamagePercent', cDamagePercent); +ScriptSetInteger('RopePercent', cRopePercent); ScriptSetInteger('MinesNum', cLandMines); ScriptSetInteger('MinesTime', cMinesTime); ScriptSetInteger('MineDudPercent', cMineDudPercent); @@ -1619,15 +1863,17 @@ ScriptSetInteger('SuddenDeathTurns', cSuddenDTurns); ScriptSetInteger('WaterRise', cWaterRise); ScriptSetInteger('HealthDecrease', cHealthDecrease); -ScriptSetString('Map', ''); +ScriptSetString('Map', cMapName); + ScriptSetString('Theme', ''); ScriptSetString('Goals', ''); ScriptCall('onGameInit'); // pop game variables -ParseCommand('seed ' + ScriptGetString('Seed'), true); +ParseCommand('seed ' + ScriptGetString('Seed'), true, true); cTemplateFilter := ScriptGetInteger('TemplateFilter'); +LuaTemplateNumber:= ScriptGetInteger('TemplateNumber'); cMapGen := ScriptGetInteger('MapGen'); GameFlags := ScriptGetInteger('GameFlags'); cHedgehogTurnTime:= ScriptGetInteger('TurnTime'); @@ -1635,6 +1881,7 @@ cHealthCaseProb := ScriptGetInteger('HealthCaseProb'); cHealthCaseAmount:= ScriptGetInteger('HealthCaseAmount'); cDamagePercent := ScriptGetInteger('DamagePercent'); +cRopePercent := ScriptGetInteger('RopePercent'); cLandMines := ScriptGetInteger('MinesNum'); cMinesTime := ScriptGetInteger('MinesTime'); cMineDudPercent := ScriptGetInteger('MineDudPercent'); @@ -1645,16 +1892,49 @@ cWaterRise := ScriptGetInteger('WaterRise'); cHealthDecrease := ScriptGetInteger('HealthDecrease'); -if ScriptGetString('Map') <> '' then - ParseCommand('map ' + ScriptGetString('Map'), true); +if cMapName <> ScriptGetString('Map') then + ParseCommand('map ' + ScriptGetString('Map'), true, true); if ScriptGetString('Theme') <> '' then - ParseCommand('theme ' + ScriptGetString('Theme'), true); + ParseCommand('theme ' + ScriptGetString('Theme'), true, true); LuaGoals:= ScriptGetString('Goals'); -if ScriptExists('onAmmoStoreInit') then +// Support lua changing the ammo layout - assume all hogs have same ammo, note this might leave a few ammo stores lying around. +k:= 0; +if (GameFlags and gfSharedAmmo) <> 0 then + for i:= 0 to Pred(ClansCount) do + for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do + for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do + ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= i +else if (GameFlags and gfPerHogAmmo) <> 0 then + for i:= 0 to Pred(TeamsCount) do + for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do + begin + TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; + if StoreCnt-1 < k then AddAmmoStore; + inc(k) + end +else + for i:= 0 to Pred(TeamsCount) do + begin + for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do + TeamsArray[i]^.Hedgehogs[j].AmmoStore:= k; + if StoreCnt-1 < k then AddAmmoStore; + inc(k) + end; +if ScriptExists('onAmmoStoreInit') or ScriptExists('onNewAmmoStore') then begin - ScriptPrepareAmmoStore; - ScriptCall('onAmmoStoreInit'); + // reset ammostore (quite unclean, but works?) + uAmmos.freeModule; + uAmmos.initModule; + if ScriptExists('onAmmoStoreInit') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onAmmoStoreInit'); + SetAmmoLoadout(ScriptAmmoLoadout); + SetAmmoProbability(ScriptAmmoProbability); + SetAmmoDelay(ScriptAmmoDelay); + SetAmmoReinforcement(ScriptAmmoReinforcement) + end; ScriptApplyAmmoStore end; @@ -1677,8 +1957,10 @@ s : shortstring; begin s:= UserPathz[ptData] + '/' + name; -if not FileExists(s) then s:= Pathz[ptData] + '/' + name; -if not FileExists(s) then exit; +if not FileExists(s) then + s:= Pathz[ptData] + '/' + name; +if not FileExists(s) then + exit; ret:= luaL_loadfile(luaState, Str2PChar(s)); if ret <> 0 then @@ -1702,6 +1984,14 @@ ScriptSetInteger('RealTime', RealTicks); ScriptSetInteger('TotalRounds', TotalRounds); ScriptSetInteger('WaterLine', cWaterLine); +if GameTicks = 0 then + begin + ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); + ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); + ScriptSetInteger('LeftX', leftX); + ScriptSetInteger('RightX', rightX); + ScriptSetInteger('TopY', topY) + end; if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID) else @@ -1715,7 +2005,7 @@ procedure ScriptCall(fname : shortstring); begin -if not ScriptLoaded or not ScriptExists(fname) then +if not ScriptLoaded or (not ScriptExists(fname)) then exit; SetGlobals; lua_getglobal(luaState, Str2PChar(fname)); @@ -1727,10 +2017,12 @@ GetGlobals; end; +(* function ParseCommandOverride(key, value : shortstring) : shortstring; begin ParseCommandOverride:= value; -if not ScriptExists('ParseCommandOverride') then exit; +if not ScriptExists('ParseCommandOverride') then + exit; lua_getglobal(luaState, Str2PChar('ParseCommandOverride')); lua_pushstring(luaState, Str2PChar(key)); lua_pushstring(luaState, Str2PChar(value)); @@ -1745,6 +2037,7 @@ lua_pop(luaState, 1) end; end; +*) function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; begin @@ -1763,7 +2056,7 @@ function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; begin -if not ScriptLoaded or not ScriptExists(fname) then +if not ScriptLoaded or (not ScriptExists(fname)) then exit; SetGlobals; lua_getglobal(luaState, Str2PChar(fname)); @@ -1800,9 +2093,6 @@ procedure ScriptPrepareAmmoStore; var i: ShortInt; begin -// reset ammostore (quite unclean, but works?) -uAmmos.freeModule; -uAmmos.initModule; ScriptAmmoLoadout:= ''; ScriptAmmoDelay:= ''; ScriptAmmoProbability:= ''; @@ -1828,23 +2118,57 @@ end; procedure ScriptApplyAmmoStore; -var i, j : LongInt; +var i, j, k : LongInt; begin -SetAmmoLoadout(ScriptAmmoLoadout); -SetAmmoProbability(ScriptAmmoProbability); -SetAmmoDelay(ScriptAmmoDelay); -SetAmmoReinforcement(ScriptAmmoReinforcement); - if (GameFlags and gfSharedAmmo) <> 0 then for i:= 0 to Pred(ClansCount) do - AddAmmoStore + begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onNewAmmoStore',i,-1); + SetAmmoLoadout(ScriptAmmoLoadout); + SetAmmoProbability(ScriptAmmoProbability); + SetAmmoDelay(ScriptAmmoDelay); + SetAmmoReinforcement(ScriptAmmoReinforcement) + end; + AddAmmoStore; + for j:= 0 to Pred(ClansArray[i]^.TeamsNumber) do + for k:= 0 to Pred(ClansArray[i]^.Teams[j]^.HedgehogsNumber) do + ClansArray[i]^.Teams[j]^.Hedgehogs[k].AmmoStore:= StoreCnt - 1 + end else if (GameFlags and gfPerHogAmmo) <> 0 then for i:= 0 to Pred(TeamsCount) do for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do - AddAmmoStore + begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onNewAmmoStore',i,j); + SetAmmoLoadout(ScriptAmmoLoadout); + SetAmmoProbability(ScriptAmmoProbability); + SetAmmoDelay(ScriptAmmoDelay); + SetAmmoReinforcement(ScriptAmmoReinforcement) + end; + AddAmmoStore; + TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 + end else for i:= 0 to Pred(TeamsCount) do - AddAmmoStore + begin + if ScriptExists('onNewAmmoStore') then + begin + ScriptPrepareAmmoStore; + ScriptCall('onNewAmmoStore',i,-1); + SetAmmoLoadout(ScriptAmmoLoadout); + SetAmmoProbability(ScriptAmmoProbability); + SetAmmoDelay(ScriptAmmoDelay); + SetAmmoReinforcement(ScriptAmmoReinforcement) + end; + AddAmmoStore; + for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do + TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 + end end; procedure initModule; @@ -1866,9 +2190,7 @@ luaopen_table(luaState); // import some variables -ScriptSetInteger('LAND_WIDTH', LAND_WIDTH); -ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT); -ScriptSetString('L', cLocale); +ScriptSetString(_S'L', cLocale); // import game flags ScriptSetInteger('gfForts', gfForts); @@ -1962,86 +2284,97 @@ ScriptSetInteger('gstInvisible' ,$00200000); // register functions -lua_register(luaState, 'band', @lc_band); -lua_register(luaState, 'bor', @lc_bor); -lua_register(luaState, 'bnot', @lc_bnot); -lua_register(luaState, 'GetInputMask', @lc_getinputmask); -lua_register(luaState, 'SetInputMask', @lc_setinputmask); -lua_register(luaState, 'AddGear', @lc_addgear); -lua_register(luaState, 'DeleteGear', @lc_deletegear); -lua_register(luaState, 'AddVisualGear', @lc_addvisualgear); -lua_register(luaState, 'DeleteVisualGear', @lc_deletevisualgear); -lua_register(luaState, 'GetVisualGearValues', @lc_getvisualgearvalues); -lua_register(luaState, 'SetVisualGearValues', @lc_setvisualgearvalues); -lua_register(luaState, 'SpawnHealthCrate', @lc_spawnhealthcrate); -lua_register(luaState, 'SpawnAmmoCrate', @lc_spawnammocrate); -lua_register(luaState, 'SpawnUtilityCrate', @lc_spawnutilitycrate); -lua_register(luaState, 'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); -lua_register(luaState, 'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); -lua_register(luaState, 'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); -lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); -lua_register(luaState, 'GetGearType', @lc_getgeartype); -lua_register(luaState, 'EndGame', @lc_endgame); -lua_register(luaState, 'FindPlace', @lc_findplace); -lua_register(luaState, 'SetGearPosition', @lc_setgearposition); -lua_register(luaState, 'GetGearPosition', @lc_getgearposition); -lua_register(luaState, 'SetGearTarget', @lc_setgeartarget); -lua_register(luaState, 'GetGearTarget', @lc_getgeartarget); -lua_register(luaState, 'SetGearVelocity', @lc_setgearvelocity); -lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity); -lua_register(luaState, 'ParseCommand', @lc_parsecommand); -lua_register(luaState, 'ShowMission', @lc_showmission); -lua_register(luaState, 'HideMission', @lc_hidemission); -lua_register(luaState, 'AddCaption', @lc_addcaption); -lua_register(luaState, 'SetAmmo', @lc_setammo); -lua_register(luaState, 'PlaySound', @lc_playsound); -lua_register(luaState, 'AddTeam', @lc_addteam); -lua_register(luaState, 'AddHog', @lc_addhog); -lua_register(luaState, 'AddAmmo', @lc_addammo); -lua_register(luaState, 'GetAmmoCount', @lc_getammocount); -lua_register(luaState, 'SetHealth', @lc_sethealth); -lua_register(luaState, 'GetHealth', @lc_gethealth); -lua_register(luaState, 'SetEffect', @lc_seteffect); -lua_register(luaState, 'GetEffect', @lc_geteffect); -lua_register(luaState, 'GetHogClan', @lc_gethogclan); -lua_register(luaState, 'GetClanColor', @lc_getclancolor); -lua_register(luaState, 'SetClanColor', @lc_setclancolor); -lua_register(luaState, 'GetHogTeamName', @lc_gethogteamname); -lua_register(luaState, 'GetHogName', @lc_gethogname); -lua_register(luaState, 'SetHogName', @lc_sethogname); -lua_register(luaState, 'GetHogLevel', @lc_gethoglevel); -lua_register(luaState, 'SetHogLevel', @lc_sethoglevel); -lua_register(luaState, 'GetX', @lc_getx); -lua_register(luaState, 'GetY', @lc_gety); -lua_register(luaState, 'CopyPV', @lc_copypv); -lua_register(luaState, 'FollowGear', @lc_followgear); -lua_register(luaState, 'GetFollowGear', @lc_getfollowgear); -lua_register(luaState, 'SetState', @lc_setstate); -lua_register(luaState, 'GetState', @lc_getstate); -lua_register(luaState, 'SetTag', @lc_settag); -lua_register(luaState, 'SetTimer', @lc_settimer); -lua_register(luaState, 'GetTimer', @lc_gettimer); -lua_register(luaState, 'SetZoom', @lc_setzoom); -lua_register(luaState, 'GetZoom', @lc_getzoom); -lua_register(luaState, 'HogSay', @lc_hogsay); -lua_register(luaState, 'SwitchHog', @lc_switchhog); -lua_register(luaState, 'HogTurnLeft', @lc_hogturnleft); -lua_register(luaState, 'CampaignLock', @lc_campaignlock); -lua_register(luaState, 'CampaignUnlock', @lc_campaignunlock); -lua_register(luaState, 'GetGearElasticity', @lc_getgearelasticity); -lua_register(luaState, 'GetGearRadius', @lc_getgearradius); -lua_register(luaState, 'GetGearMessage', @lc_getgearmessage); -lua_register(luaState, 'SetGearMessage', @lc_setgearmessage); -lua_register(luaState, 'GetRandom', @lc_getrandom); -lua_register(luaState, 'SetWind', @lc_setwind); -lua_register(luaState, 'GetDataPath', @lc_getdatapath); -lua_register(luaState, 'GetUserDataPath', @lc_getuserdatapath); -lua_register(luaState, 'MapHasBorder', @lc_maphasborder); -lua_register(luaState, 'GetHogHat', @lc_gethoghat); -lua_register(luaState, 'SetHogHat', @lc_sethoghat); -lua_register(luaState, 'PlaceGirder', @lc_placegirder); -lua_register(luaState, 'GetCurAmmoType', @lc_getcurammotype); -lua_register(luaState, 'TestRectForObstacle', @lc_testrectforobstacle); +lua_register(luaState, _P'HideHog', @lc_hidehog); +lua_register(luaState, _P'RestoreHog', @lc_restorehog); +lua_register(luaState, _P'SaveCampaignVar', @lc_savecampaignvar); +lua_register(luaState, _P'GetCampaignVar', @lc_getcampaignvar); +lua_register(luaState, _P'band', @lc_band); +lua_register(luaState, _P'bor', @lc_bor); +lua_register(luaState, _P'bnot', @lc_bnot); +lua_register(luaState, _P'div', @lc_div); +lua_register(luaState, _P'GetInputMask', @lc_getinputmask); +lua_register(luaState, _P'SetInputMask', @lc_setinputmask); +lua_register(luaState, _P'AddGear', @lc_addgear); +lua_register(luaState, _P'DeleteGear', @lc_deletegear); +lua_register(luaState, _P'AddVisualGear', @lc_addvisualgear); +lua_register(luaState, _P'DeleteVisualGear', @lc_deletevisualgear); +lua_register(luaState, _P'GetVisualGearValues', @lc_getvisualgearvalues); +lua_register(luaState, _P'SetVisualGearValues', @lc_setvisualgearvalues); +lua_register(luaState, _P'SpawnHealthCrate', @lc_spawnhealthcrate); +lua_register(luaState, _P'SpawnAmmoCrate', @lc_spawnammocrate); +lua_register(luaState, _P'SpawnUtilityCrate', @lc_spawnutilitycrate); +lua_register(luaState, _P'SpawnFakeHealthCrate', @lc_spawnfakehealthcrate); +lua_register(luaState, _P'SpawnFakeAmmoCrate', @lc_spawnfakeammocrate); +lua_register(luaState, _P'SpawnFakeUtilityCrate', @lc_spawnfakeutilitycrate); +lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); +lua_register(luaState, _P'GetGearType', @lc_getgeartype); +lua_register(luaState, _P'EndGame', @lc_endgame); +lua_register(luaState, _P'FindPlace', @lc_findplace); +lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); +lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); +lua_register(luaState, _P'SetGearTarget', @lc_setgeartarget); +lua_register(luaState, _P'GetGearTarget', @lc_getgeartarget); +lua_register(luaState, _P'SetGearVelocity', @lc_setgearvelocity); +lua_register(luaState, _P'GetGearVelocity', @lc_getgearvelocity); +lua_register(luaState, _P'ParseCommand', @lc_parsecommand); +lua_register(luaState, _P'ShowMission', @lc_showmission); +lua_register(luaState, _P'HideMission', @lc_hidemission); +lua_register(luaState, _P'AddCaption', @lc_addcaption); +lua_register(luaState, _P'SetAmmo', @lc_setammo); +lua_register(luaState, _P'SetAmmoStore', @lc_setammostore); +lua_register(luaState, _P'PlaySound', @lc_playsound); +lua_register(luaState, _P'AddTeam', @lc_addteam); +lua_register(luaState, _P'AddHog', @lc_addhog); +lua_register(luaState, _P'AddAmmo', @lc_addammo); +lua_register(luaState, _P'GetAmmoCount', @lc_getammocount); +lua_register(luaState, _P'SetHealth', @lc_sethealth); +lua_register(luaState, _P'GetHealth', @lc_gethealth); +lua_register(luaState, _P'SetEffect', @lc_seteffect); +lua_register(luaState, _P'GetEffect', @lc_geteffect); +lua_register(luaState, _P'GetHogClan', @lc_gethogclan); +lua_register(luaState, _P'GetClanColor', @lc_getclancolor); +lua_register(luaState, _P'SetClanColor', @lc_setclancolor); +lua_register(luaState, _P'GetHogTeamName', @lc_gethogteamname); +lua_register(luaState, _P'GetHogName', @lc_gethogname); +lua_register(luaState, _P'SetHogName', @lc_sethogname); +lua_register(luaState, _P'GetHogLevel', @lc_gethoglevel); +lua_register(luaState, _P'SetHogLevel', @lc_sethoglevel); +lua_register(luaState, _P'GetX', @lc_getx); +lua_register(luaState, _P'GetY', @lc_gety); +lua_register(luaState, _P'CopyPV', @lc_copypv); +lua_register(luaState, _P'FollowGear', @lc_followgear); +lua_register(luaState, _P'GetFollowGear', @lc_getfollowgear); +lua_register(luaState, _P'SetState', @lc_setstate); +lua_register(luaState, _P'GetState', @lc_getstate); +lua_register(luaState, _P'GetTag', @lc_gettag); +lua_register(luaState, _P'SetTag', @lc_settag); +lua_register(luaState, _P'SetTimer', @lc_settimer); +lua_register(luaState, _P'GetTimer', @lc_gettimer); +lua_register(luaState, _P'SetZoom', @lc_setzoom); +lua_register(luaState, _P'GetZoom', @lc_getzoom); +lua_register(luaState, _P'HogSay', @lc_hogsay); +lua_register(luaState, _P'SwitchHog', @lc_switchhog); +lua_register(luaState, _P'HogTurnLeft', @lc_hogturnleft); +lua_register(luaState, _P'CampaignLock', @lc_campaignlock); +lua_register(luaState, _P'CampaignUnlock', @lc_campaignunlock); +lua_register(luaState, _P'GetGearElasticity', @lc_getgearelasticity); +lua_register(luaState, _P'GetGearRadius', @lc_getgearradius); +lua_register(luaState, _P'GetGearMessage', @lc_getgearmessage); +lua_register(luaState, _P'SetGearMessage', @lc_setgearmessage); +lua_register(luaState, _P'GetGearPos', @lc_getgearpos); +lua_register(luaState, _P'SetGearPos', @lc_setgearpos); +lua_register(luaState, _P'GetGearCollisionMask', @lc_getgearcollisionmask); +lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask); +lua_register(luaState, _P'GetRandom', @lc_getrandom); +lua_register(luaState, _P'SetWind', @lc_setwind); +lua_register(luaState, _P'GetDataPath', @lc_getdatapath); +lua_register(luaState, _P'GetUserDataPath', @lc_getuserdatapath); +lua_register(luaState, _P'MapHasBorder', @lc_maphasborder); +lua_register(luaState, _P'GetHogHat', @lc_gethoghat); +lua_register(luaState, _P'SetHogHat', @lc_sethoghat); +lua_register(luaState, _P'PlaceGirder', @lc_placegirder); +lua_register(luaState, _P'GetCurAmmoType', @lc_getcurammotype); +lua_register(luaState, _P'TestRectForObstacle', @lc_testrectforobstacle); ScriptClearStack; // just to be sure stack is empty @@ -2064,6 +2397,7 @@ procedure ScriptLoad(name : shortstring); begin + name:= name; // avoid hint end; procedure ScriptOnGameInit; @@ -2072,36 +2406,64 @@ procedure ScriptCall(fname : shortstring); begin + fname:= fname; // avoid hint end; function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; begin -ScriptCall:= 0 + // avoid hints + fname:= fname; + par1:= par1; + par2:= par2; + par3:= par3; + par4:= par4; + ScriptCall:= 0 end; function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; begin -ScriptCall:= 0 + // avoid hints + fname:= fname; + par1:= par1; + ScriptCall:= 0 end; function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt; begin -ScriptCall:= 0 + // avoid hints + fname:= fname; + par1:= par1; + par2:= par2; + ScriptCall:= 0 end; function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt; begin -ScriptCall:= 0 + // avoid hints + fname:= fname; + par1:= par1; + par2:= par2; + par3:= par3; + ScriptCall:= 0 end; function ScriptExists(fname : shortstring) : boolean; begin -ScriptExists:= false + fname:= fname; // avoid hint + ScriptExists:= false end; - +(* function ParseCommandOverride(key, value : shortstring) : shortstring; begin -ParseCommandOverride:= value + // avoid hints + key:= key; + value:= value; + ParseCommandOverride:= '' +end; +*) + +procedure ScriptOnScreenResize; +begin end; procedure initModule; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uSinTable.pas --- a/hedgewars/uSinTable.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uSinTable.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1045,7 +1045,7 @@ $FFFF4E59, $FFFFB10B, $FFFFEC43, - $100000000 + $100000000 ); implementation diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uSound.pas --- a/hedgewars/uSound.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uSound.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,25 +33,26 @@ * The channel id can be used to stop a specific sound loop. *) interface -uses SDLh, uConsts, uTypes, sysutils; - -var MusicFN: shortstring; // music file name +uses SDLh, uConsts, uTypes, SysUtils; procedure initModule; procedure freeModule; -procedure InitSound; // Initiates sound-system if isSoundEnabled. -procedure ReleaseSound; // Releases sound-system and used resources. -procedure SoundLoad; // Preloads some sounds for performance reasons. - +procedure InitSound; // Initiates sound-system if isSoundEnabled. +procedure ReleaseSound(complete: boolean); // Releases sound-system and used resources. +procedure ResetSound; // Reset sound state to the previous state. +procedure SetSound(enabled: boolean); // Enable/disable sound-system and backup status. // MUSIC -// Obvious music commands for music track specified in MusicFN. -procedure PlayMusic; -procedure PauseMusic; -procedure ResumeMusic; -procedure ChangeMusic; // Replaces music track with current MusicFN and plays it. +// Obvious music commands for music track +procedure SetMusic(enabled: boolean); // Enable/disable music. +procedure SetMusicName(musicname: shortstring); // Set name of the file to play. +procedure PlayMusic; // Play music from the start. +procedure PauseMusic; // Pause music. +procedure ResumeMusic; // Resume music from pause point. +procedure ChangeMusic(musicname: shortstring); // Replaces music track with musicname and plays it. +procedure StopMusic; // Stops and releases the current track. // SOUNDS @@ -61,28 +62,41 @@ // then the sound's playback won't be interrupted if asked to play again. procedure PlaySound(snd: TSound); procedure PlaySound(snd: TSound; keepPlaying: boolean); -procedure PlaySound(snd: TSound; voicepack: PVoicepack); -procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); +procedure PlaySoundV(snd: TSound; voicepack: PVoicepack); +procedure PlaySoundV(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); // Plays sound snd [of voicepack] in a loop, but starts with fadems milliseconds of fade-in. // Returns sound channel of the looped sound. function LoopSound(snd: TSound): LongInt; function LoopSound(snd: TSound; fadems: LongInt): LongInt; -function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; // WTF? -function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; +function LoopSoundV(snd: TSound; voicepack: PVoicepack): LongInt; // WTF? +function LoopSoundV(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; // Stops the normal/looped sound of the given type/in the given channel // [with a fade-out effect for fadems milliseconds]. procedure StopSound(snd: TSound); -procedure StopSound(chn: LongInt); -procedure StopSound(chn, fadems: LongInt); +procedure StopSoundChan(chn: LongInt); +procedure StopSoundChan(chn, fadems: LongInt); procedure AddVoice(snd: TSound; voicepack: PVoicepack); procedure PlayNextVoice; +// GLOBAL FUNCTIONS + +// Drastically lower the volume when we lose focus (and restore the previous value). +procedure DampenAudio; +procedure UndampenAudio; + +// Mute/Unmute audio +procedure MuteAudio; + + // MISC +// Set the initial volume +procedure SetVolume(vol: LongInt); + // Modifies the sound volume of the game by voldelta and returns the new volume level. function ChangeVolume(voldelta: LongInt): LongInt; @@ -95,10 +109,17 @@ const chanTPU = 32; var Volume: LongInt; + cInitVolume: LongInt; + previousVolume: LongInt; // cached volume value lastChan: array [TSound] of LongInt; voicepacks: array[0..cMaxTeams] of TVoicepack; defVoicepack: PVoicepack; - Mus: PMixMusic = nil; + Mus: PMixMusic; // music pointer + MusicFN: shortstring; // music file name + isMusicEnabled: boolean; + isSoundEnabled: boolean; + isSEBackup: boolean; + function AskForVoicepack(name: shortstring): Pointer; var i: Longword; @@ -110,20 +131,25 @@ begin locName:= name+'_'+cLocale; path:= UserPathz[ptVoices] + '/' + locName; - if DirectoryExists(path) then name:= locName + if DirectoryExists(path) then + name:= locName else begin path:= Pathz[ptVoices] + '/' + locName; - if DirectoryExists(path) then name:= locName - else if Length(cLocale) > 2 then + if DirectoryExists(path) then + name:= locName + else if Length(cLocale) > 2 + then begin locName:= name+'_'+Copy(cLocale,1,2); path:= UserPathz[ptVoices] + '/' + locName; - if DirectoryExists(path) then name:= locName + if DirectoryExists(path) then + name:= locName else begin path:= Pathz[ptVoices] + '/' + locName; - if DirectoryExists(path) then name:= locName + if DirectoryExists(path) then + name:= locName end end end @@ -141,110 +167,93 @@ end; procedure InitSound; -var i: TSound; - channels: LongInt; +const channels: LongInt = {$IFDEF MOBILE}1{$ELSE}2{$ENDIF}; begin - if not isSoundEnabled then exit; + if not isSoundEnabled then + exit; WriteToConsole('Init sound...'); isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; -{$IFDEF MOBILE} - channels:= 1; -{$ELSE} - channels:= 2; -{$ENDIF} - if isSoundEnabled then isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; - WriteToConsole('Init SDL_mixer... '); - SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); - WriteLnToConsole(msgOK); - if isSoundEnabled then WriteLnToConsole(msgOK) else WriteLnToConsole(msgFailed); + WriteToConsole('Init SDL_mixer... '); + SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); + WriteLnToConsole(msgOK); + Mix_AllocateChannels(Succ(chanTPU)); - if isMusicEnabled then - Mix_VolumeMusic(50); - for i:= Low(TSound) to High(TSound) do - lastChan[i]:= -1; - - Volume:= 0; - ChangeVolume(cInitVolume) + ChangeVolume(cInitVolume); end; -procedure ReleaseSound; +procedure ResetSound; +begin + isSoundEnabled:= isSEBackup; +end; + +procedure SetSound(enabled: boolean); +begin + isSEBackup:= isSoundEnabled; + isSoundEnabled:= enabled; +end; + +// when complete is false, this procedure just releases some of the chucks on inactive channels +// in this way music is not stopped, nor are chucks currently being played +procedure ReleaseSound(complete: boolean); var i: TSound; t: Longword; begin + // release and nil all sounds for t:= 0 to cMaxTeams do if voicepacks[t].name <> '' then for i:= Low(TSound) to High(TSound) do if voicepacks[t].chunks[i] <> nil then - Mix_FreeChunk(voicepacks[t].chunks[i]); - - if Mus <> nil then - Mix_FreeMusic(Mus); - - // make sure all instances of sdl_mixer are unloaded before continuing - while Mix_Init(0) <> 0 do - Mix_Quit(); - - Mix_CloseAudio(); -end; - -procedure SoundLoad; -var i: TSound; - t: Longword; - s:shortstring; -begin - if not isSoundEnabled then exit; - - defVoicepack:= AskForVoicepack('Default'); + if complete or (Mix_Playing(lastChan[i]) = 0) then + begin + Mix_HaltChannel(lastChan[i]); + lastChan[i]:= -1; + Mix_FreeChunk(voicepacks[t].chunks[i]); + voicepacks[t].chunks[i]:= nil; + end; - for t:= 0 to cMaxTeams do - if voicepacks[t].name <> '' then - for i:= Low(TSound) to High(TSound) do - voicepacks[t].chunks[i]:= nil; + // stop music + if complete then + begin + if Mus <> nil then + begin + Mix_HaltMusic(); + Mix_FreeMusic(Mus); + Mus:= nil; + end; - for i:= Low(TSound) to High(TSound) do - begin - defVoicepack^.chunks[i]:= nil; - // preload all the big sound files (>32k) that would otherwise lockup the game - if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, - sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo]) - and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then - begin - s:= UserPathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - if not FileExists(s) then s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); - WriteLnToConsole(msgOK); + // make sure all instances of sdl_mixer are unloaded before continuing + while Mix_Init(0) <> 0 do + Mix_Quit(); + + Mix_CloseAudio(); end; - end; - end; procedure PlaySound(snd: TSound); begin - PlaySound(snd, nil, false); + PlaySoundV(snd, nil, false); end; procedure PlaySound(snd: TSound; keepPlaying: boolean); begin - PlaySound(snd, nil, keepPlaying); + PlaySoundV(snd, nil, keepPlaying); end; -procedure PlaySound(snd: TSound; voicepack: PVoicepack); +procedure PlaySoundV(snd: TSound; voicepack: PVoicepack); begin - PlaySound(snd, voicepack, false); + PlaySoundV(snd, voicepack, false); end; -procedure PlaySound(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); +procedure PlaySoundV(snd: TSound; voicepack: PVoicepack; keepPlaying: boolean); var s:shortstring; begin if (not isSoundEnabled) or fastUntilLag then @@ -258,9 +267,10 @@ if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then begin s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; - if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; + if not FileExists(s) then + s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; WriteToConsole(msgLoading + s + ' '); - voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); if voicepack^.chunks[snd] = nil then WriteLnToConsole(msgFailed) else @@ -273,10 +283,11 @@ if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then begin s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; - if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; + if not FileExists(s) then + s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; WriteToConsole(msgLoading + s + ' '); - defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); + defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); + SDLTry(defVoicepack^.chunks[snd] <> nil, true); WriteLnToConsole(msgOK); end; lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) @@ -286,12 +297,23 @@ procedure AddVoice(snd: TSound; voicepack: PVoicepack); var i : LongInt; begin - if (not isSoundEnabled) or fastUntilLag or ((LastVoice.snd = snd) and (LastVoice.voicepack = voicepack)) then exit; + if (not isSoundEnabled) or fastUntilLag or ((LastVoice.snd = snd) and (LastVoice.voicepack = voicepack)) then + exit; + if (snd = sndVictory) or (snd = sndFlawless) then + begin + Mix_FadeOutChannel(-1, 800); + for i:= 0 to 7 do + VoiceList[i].snd:= sndNone; + LastVoice.snd:= sndNone; + end; + i:= 0; - while (i<8) and (VoiceList[i].snd <> sndNone) do inc(i); + while (i<8) and (VoiceList[i].snd <> sndNone) do + inc(i); // skip playing same sound for same hog twice - if (i>0) and (VoiceList[i-1].snd = snd) and (VoiceList[i-1].voicepack = voicepack) then exit; + if (i>0) and (VoiceList[i-1].snd = snd) and (VoiceList[i-1].voicepack = voicepack) then + exit; VoiceList[i].snd:= snd; VoiceList[i].voicepack:= voicepack; end; @@ -299,100 +321,107 @@ procedure PlayNextVoice; var i : LongInt; begin - if (not isSoundEnabled) or fastUntilLag or ((LastVoice.snd <> sndNone) and (lastChan[LastVoice.snd] <> -1) and (Mix_Playing(lastChan[LastVoice.snd]) <> 0)) then exit; + if (not isSoundEnabled) or fastUntilLag or ((LastVoice.snd <> sndNone) and (lastChan[LastVoice.snd] <> -1) and (Mix_Playing(lastChan[LastVoice.snd]) <> 0)) then + exit; i:= 0; - while (i<8) and (VoiceList[i].snd = sndNone) do inc(i); + while (i<8) and (VoiceList[i].snd = sndNone) do + inc(i); if (VoiceList[i].snd <> sndNone) then begin LastVoice.snd:= VoiceList[i].snd; LastVoice.voicepack:= VoiceList[i].voicepack; VoiceList[i].snd:= sndNone; - PlaySound(LastVoice.snd, LastVoice.voicepack) + PlaySoundV(LastVoice.snd, LastVoice.voicepack) end else LastVoice.snd:= sndNone; end; function LoopSound(snd: TSound): LongInt; begin - LoopSound:= LoopSound(snd, nil) + LoopSound:= LoopSoundV(snd, nil) end; function LoopSound(snd: TSound; fadems: LongInt): LongInt; begin - LoopSound:= LoopSound(snd, nil, fadems) + LoopSound:= LoopSoundV(snd, nil, fadems) end; -function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; +function LoopSoundV(snd: TSound; voicepack: PVoicepack): LongInt; begin voicepack:= voicepack; // avoid compiler hint - LoopSound:= LoopSound(snd, nil, 0) + LoopSoundV:= LoopSoundV(snd, nil, 0) end; -function LoopSound(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; +function LoopSoundV(snd: TSound; voicepack: PVoicepack; fadems: LongInt): LongInt; var s: shortstring; begin if (not isSoundEnabled) or fastUntilLag then - begin - LoopSound:= -1; + begin + LoopSoundV:= -1; exit - end; + end; if (voicepack <> nil) then - begin + begin if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then - begin + begin s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; - if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; + if not FileExists(s) then + s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; WriteToConsole(msgLoading + s + ' '); - voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); if voicepack^.chunks[snd] = nil then WriteLnToConsole(msgFailed) else WriteLnToConsole(msgOK) - end; - LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) - end + end; + LoopSoundV:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) + end else - begin + begin if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then - begin + begin s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; - if not FileExists(s) then s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; + if not FileExists(s) then + s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName; WriteToConsole(msgLoading + s + ' '); - defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(defVoicepack^.chunks[snd] <> nil, msgFailed, true); + defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1); + SDLTry(defVoicepack^.chunks[snd] <> nil, true); WriteLnToConsole(msgOK); - end; + end; if fadems > 0 then - LoopSound:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1) + LoopSoundV:= Mix_FadeInChannelTimed(-1, defVoicepack^.chunks[snd], -1, fadems, -1) else - LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); - end; + LoopSoundV:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1); + end; end; procedure StopSound(snd: TSound); begin - if not isSoundEnabled then exit; + if not isSoundEnabled then + exit; if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then - begin + begin Mix_HaltChannel(lastChan[snd]); lastChan[snd]:= -1; - end; + end; end; -procedure StopSound(chn: LongInt); +procedure StopSoundChan(chn: LongInt); begin - if not isSoundEnabled then exit; + if not isSoundEnabled then + exit; if (chn <> -1) and (Mix_Playing(chn) <> 0) then Mix_HaltChannel(chn); end; -procedure StopSound(chn, fadems: LongInt); +procedure StopSoundChan(chn, fadems: LongInt); begin - if not isSoundEnabled then exit; + if not isSoundEnabled then + exit; if (chn <> -1) and (Mix_Playing(chn) <> 0) then Mix_FadeOutChannel(chn, fadems); @@ -405,27 +434,91 @@ exit; s:= UserPathPrefix + '/Data/Music/' + MusicFN; - if not FileExists(s) then s:= PathPrefix + '/Music/' + MusicFN; + if not FileExists(s) then + s:= PathPrefix + '/Music/' + MusicFN; WriteToConsole(msgLoading + s + ' '); Mus:= Mix_LoadMUS(Str2PChar(s)); - TryDo(Mus <> nil, msgFailed, false); + SDLTry(Mus <> nil, false); WriteLnToConsole(msgOK); SDLTry(Mix_FadeInMusic(Mus, -1, 3000) <> -1, false) end; +procedure SetVolume(vol: LongInt); +begin + cInitVolume:= vol; +end; + function ChangeVolume(voldelta: LongInt): LongInt; begin - if not isSoundEnabled then - exit(0); + ChangeVolume:= 0; + if (not isSoundEnabled) or ((voldelta = 0) and not (cInitVolume = 0)) then + exit; inc(Volume, voldelta); - if Volume < 0 then Volume:= 0; + if Volume < 0 then + Volume:= 0; + // apply Volume to all channels Mix_Volume(-1, Volume); + // get assigned Volume Volume:= Mix_Volume(-1, -1); - if isMusicEnabled then Mix_VolumeMusic(Volume * 4 div 8); - ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME + if isMusicEnabled then + Mix_VolumeMusic(Volume * 4 div 8); + ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME; + + if (isMusicEnabled) then + if (Volume = 0) then + PauseMusic + else + ResumeMusic; + + isAudioMuted:= (Volume = 0); +end; + +procedure DampenAudio; +begin + if (isAudioMuted) then + exit; + previousVolume:= Volume; + ChangeVolume(-Volume * 7 div 9); +end; + +procedure UndampenAudio; +begin + if (isAudioMuted) then + exit; + ChangeVolume(previousVolume - Volume); +end; + +procedure MuteAudio; +begin + if (not isSoundEnabled) then + exit; + + if (isAudioMuted) then + begin + ResumeMusic; + ChangeVolume(previousVolume); + end + else + begin + PauseMusic; + previousVolume:= Volume; + ChangeVolume(-Volume); + end; + + // isAudioMuted is updated in ChangeVolume +end; + +procedure SetMusic(enabled: boolean); +begin + isMusicEnabled:= enabled; +end; + +procedure SetMusicName(musicname: shortstring); +begin + MusicFN:= musicname; end; procedure PauseMusic; @@ -433,7 +526,8 @@ if (MusicFN = '') or (not isMusicEnabled) then exit; - Mix_PauseMusic(Mus); + if Mus <> nil then + Mix_PauseMusic(Mus); end; procedure ResumeMusic; @@ -441,39 +535,85 @@ if (MusicFN = '') or (not isMusicEnabled) then exit; - Mix_ResumeMusic(Mus); + if Mus <> nil then + Mix_ResumeMusic(Mus); end; -procedure ChangeMusic; +procedure ChangeMusic(musicname: shortstring); +begin + MusicFN:= musicname; + if (MusicFN = '') or (not isMusicEnabled) then + exit; + + StopMusic; + PlayMusic; +end; + +procedure StopMusic; begin if (MusicFN = '') or (not isMusicEnabled) then exit; - // get rid of current music if Mus <> nil then + begin Mix_FreeMusic(Mus); - - PlayMusic; + Mus:= nil; + end end; procedure chVoicepack(var s: shortstring); begin - if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/voicepack"', true); + if CurrentTeam = nil then + OutError(errmsgIncorrectUse + ' "/voicepack"', true); if s[1]='"' then Delete(s, 1, 1); - if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); + if s[byte(s[0])]='"' then + Delete(s, byte(s[0]), 1); CurrentTeam^.voicepack:= AskForVoicepack(s) end; +procedure chMute(var s: shortstring); +begin + s:= s; // avoid compiler hint + MuteAudio; +end; + procedure initModule; +var t: LongInt; + i: TSound; begin - RegisterVariable('voicepack', vtCommand, @chVoicepack, false); + RegisterVariable('voicepack', @chVoicepack, false); + RegisterVariable('mute' , @chMute , true ); + MusicFN:=''; + Mus:= nil; + isMusicEnabled:= true; + isSoundEnabled:= true; + isAudioMuted:= false; + isSEBackup:= isSoundEnabled; + Volume:= 0; + cInitVolume:= 100; + defVoicepack:= AskForVoicepack('Default'); + + for i:= Low(TSound) to High(TSound) do + lastChan[i]:= -1; + + // initialize all voices to nil so that they can be loaded lazily + for t:= 0 to cMaxTeams do + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + voicepacks[t].chunks[i]:= nil; + + (* on MOBILE SDL_mixer has to be compiled against Tremor (USE_OGG_TREMOR) + or sound files bigger than 32k will lockup the game *) + for i:= Low(TSound) to High(TSound) do + defVoicepack^.chunks[i]:= nil; + end; procedure freeModule; begin if isSoundEnabled then - ReleaseSound(); + ReleaseSound(true); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uStats.pas --- a/hedgewars/uStats.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uStats.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -71,13 +71,15 @@ inc(Kills); inc(KillsTotal); inc(Attacker^.Team^.stats.Kills); - if (Attacker^.Team^.TeamName = - Gear^.Hedgehog^.Team^.TeamName) then begin + if (Attacker^.Team^.TeamName = Gear^.Hedgehog^.Team^.TeamName) then + begin inc(Attacker^.Team^.stats.TeamKills); inc(Attacker^.Team^.stats.TeamDamage, Gear^.Damage); end; - if Gear = Attacker^.Gear then inc(Attacker^.Team^.stats.Suicides); - if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then inc(KillsClan); + if Gear = Attacker^.Gear then + inc(Attacker^.Team^.stats.Suicides); + if Attacker^.Team^.Clan = Gear^.Hedgehog^.Team^.Clan then + inc(KillsClan); end; inc(DamageTotal, Damage) @@ -130,7 +132,7 @@ else if AmmoDamagingUsed then AddVoice(sndMissed, PreviousTeam^.voicepack) else if (AmmoUsedCount > 0) and (not isTurnSkipped) then - // nothing ? + begin end// nothing ? else if isTurnSkipped then begin AddVoice(sndBoring, PreviousTeam^.voicepack); @@ -148,9 +150,12 @@ begin inc(DamageRecv, StepDamageRecv); inc(DamageGiven, StepDamageGiven); - if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; - if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; - if StepKills > MaxStepKills then MaxStepKills:= StepKills; + if StepDamageRecv > MaxStepDamageRecv then + MaxStepDamageRecv:= StepDamageRecv; + if StepDamageGiven > MaxStepDamageGiven then + MaxStepDamageGiven:= StepDamageGiven; + if StepKills > MaxStepKills then + MaxStepKills:= StepKills; StepKills:= 0; StepDamageRecv:= 0; StepDamageGiven:= 0 @@ -180,10 +185,10 @@ begin if time > 4000 then begin - writeln('FLIGHT'); - writeln(Gear^.Hedgehog^.Team^.TeamName); - writeln(time); - writeln; + writeln(stdout, 'FLIGHT'); + writeln(stdout, Gear^.Hedgehog^.Team^.TeamName); + writeln(stdout, inttostr(time)); + writeln(stdout, ''); end end; @@ -212,7 +217,8 @@ begin if not ExtDriven then SendStat(siTeamStats, GetTeamStatString(TeamsArray[t])); - for i:= 0 to cMaxHHIndex do begin + for i:= 0 to cMaxHHIndex do + begin if Hedgehogs[i].stats.MaxStepDamageGiven > msd then begin msdhh:= @Hedgehogs[i]; @@ -230,22 +236,26 @@ end; { send player stats for winner teams } - if Clan^.ClanHealth > 0 then begin + if Clan^.ClanHealth > 0 then + begin winnersClan:= Clan; SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + IntToStr(stats.Kills) + ' ' + TeamName); end; { determine maximum values of TeamKills, TurnSkips, TeamDamage } - if stats.TeamKills > maxTeamKills then begin + if stats.TeamKills > maxTeamKills then + begin maxTeamKills := stats.TeamKills; maxTeamKillsName := TeamName; end; - if stats.TurnSkips > maxTurnSkips then begin + if stats.TurnSkips > maxTurnSkips then + begin maxTurnSkips := stats.TurnSkips; maxTurnSkipsName := TeamName; end; - if stats.TeamDamage > maxTeamDamage then begin + if stats.TeamDamage > maxTeamDamage then + begin maxTeamDamage := stats.TeamDamage; maxTeamDamageName := TeamName; end; @@ -253,9 +263,12 @@ end; { now send player stats for loser teams } -for t:= 0 to Pred(TeamsCount) do begin - with TeamsArray[t]^ do begin - if Clan^.ClanHealth = 0 then begin +for t:= 0 to Pred(TeamsCount) do + begin + with TeamsArray[t]^ do + begin + if Clan^.ClanHealth = 0 then + begin SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + IntToStr(stats.Kills) + ' ' + TeamName); end; @@ -274,18 +287,20 @@ if maxTeamDamage > 30 then SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName); -if KilledHHs > 0 then SendStat(siKilledHHs, IntToStr(KilledHHs)); +if KilledHHs > 0 then + SendStat(siKilledHHs, IntToStr(KilledHHs)); // now to console if winnersClan <> nil then begin - writeln('WINNERS'); + writeln(stdout, 'WINNERS'); for t:= 0 to winnersClan^.TeamsNumber - 1 do - writeln(winnersClan^.Teams[t]^.TeamName); - end else - writeln('DRAW'); + writeln(stdout, winnersClan^.Teams[t]^.TeamName); + end +else + writeln(stdout, 'DRAW'); -writeln; +writeln(stdout, ''); end; procedure initModule; @@ -296,7 +311,6 @@ procedure freeModule; begin - end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uStore.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,18 +21,26 @@ unit uStore; interface -uses sysutils, uConsts, SDLh, GLunit, uTypes, uLandTexture; +uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uConsts, SDLh, GLunit, uTypes, uLandTexture, uCaptions, uChat; procedure initModule; procedure freeModule; -procedure StoreLoad(reload: boolean = false); -procedure StoreRelease(reload: boolean = false); +procedure StoreLoad(reload: boolean); +procedure StoreRelease(reload: boolean); procedure RenderHealth(var Hedgehog: THedgehog); procedure AddProgress; procedure FinishProgress; function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; -procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); + +// loads an image from the game's data files +function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; +// like LoadDataImage but uses altPath as fallback-path if file not found/loadable in path +function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; +// like LoadDataImage but uses altFile as fallback-filename if file cannot be loaded +function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; + +procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); procedure SetupOpenGL; procedure SetScale(f: GLfloat); function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; @@ -40,14 +48,27 @@ procedure ShowWeaponTooltip(x, y: LongInt); procedure FreeWeaponTooltip; procedure MakeCrossHairs; +{$IFDEF USE_VIDEO_RECORDING} +procedure InitOffscreenOpenGL; +{$ENDIF} + +procedure WarpMouse(x, y: Word); inline; +procedure SwapBuffers; inline; implementation -uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug; +uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, + uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} + {$IF NOT DEFINED(SDL13) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple); var MaxTextureSize: LongInt; -// cGPUVendor: TGPUVendor; +{$IFDEF SDL13} + SDLwindow: PSDL_Window; + SDLGLcontext: PSDL_GLContext; +{$ELSE} + SDLPrimSurface: PSDL_Surface; +{$ENDIF} function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; var w, h: LongInt; @@ -57,10 +78,10 @@ begin w:= 0; h:= 0; // avoid compiler hints TTF_SizeUTF8(Fontz[Font].Handle, Str2PChar(s), @w, @h); -finalRect.x:= X + FontBorder + 2; -finalRect.y:= Y + FontBorder; -finalRect.w:= w + FontBorder * 2 + 4; -finalRect.h:= h + FontBorder * 2; +finalRect.x:= X + cFontBorder + 2; +finalRect.y:= Y + cFontBorder; +finalRect.w:= w + cFontBorder * 2 + 4; +finalRect.h:= h + cFontBorder * 2; clr.r:= Color shr 16; clr.g:= (Color shr 8) and $FF; clr.b:= Color and $FF; @@ -71,8 +92,8 @@ SDL_FreeSurface(tmpsurf); finalRect.x:= X; finalRect.y:= Y; -finalRect.w:= w + FontBorder * 2 + 4; -finalRect.h:= h + FontBorder * 2; +finalRect.w:= w + cFontBorder * 2 + 4; +finalRect.h:= h + cFontBorder * 2; WriteInRect:= finalRect end; @@ -80,11 +101,8 @@ var t: LongInt; tmpsurf, texsurf: PSDL_Surface; Color, i: Longword; - s : shortstring; begin -s:= UserPathz[ptGraphics] + '/' + cCHFileName; -if not FileExists(s+'.png') then s:= Pathz[ptGraphics] + '/' + cCHFileName; -tmpsurf:= LoadImage(s, ifAlpha or ifCritical); +tmpsurf:= LoadDataImage(ptGraphics, cCHFileName, ifAlpha or ifCritical); for t:= 0 to Pred(TeamsCount) do with TeamsArray[t]^ do @@ -105,12 +123,13 @@ // make black pixel be alpha-transparent for i:= 0 to texsurf^.w * texsurf^.h - 1 do - if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color; + if PLongwordArray(texsurf^.pixels)^[i] = AMask then + PLongwordArray(texsurf^.pixels)^[i]:= (RMask or GMask or BMask) and Color; if SDL_MustLock(texsurf) then SDL_UnlockSurface(texsurf); - if CrosshairTex <> nil then FreeTexture(CrosshairTex); + FreeTexture(CrosshairTex); CrosshairTex:= Surface2Tex(texsurf, false); SDL_FreeSurface(texsurf) end; @@ -118,23 +137,22 @@ SDL_FreeSurface(tmpsurf) end; -procedure StoreLoad(reload: boolean); -var s: shortstring; - procedure WriteNames(Font: THWFont); - var t: LongInt; - i: LongInt; - r, rr: TSDL_Rect; - drY: LongInt; - texsurf, flagsurf, iconsurf: PSDL_Surface; - begin - r.x:= 0; - r.y:= 0; - drY:= - 4; - for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do +procedure WriteNames(Font: THWFont); +var t: LongInt; + i, maxLevel: LongInt; + r, rr: TSDL_Rect; + drY: LongInt; + texsurf, flagsurf, iconsurf: PSDL_Surface; + foundBot: boolean; +begin +r.x:= 0; +r.y:= 0; +drY:= - 4; +for t:= 0 to Pred(TeamsCount) do + with TeamsArray[t]^ do begin - NameTagTex:= RenderStringTex(TeamName, Clan^.Color, Font); + NameTagTex:= RenderStringTexLim(TeamName, Clan^.Color, Font, cTeamHealthWidth); r.w:= cTeamHealthWidth + 5; r.h:= NameTagTex^.h; @@ -143,7 +161,7 @@ TryDo(texsurf <> nil, errmsgCreateSurface, true); TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true); + DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); rr:= r; inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false); @@ -164,26 +182,52 @@ DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); // overwrite flag for cpu teams and keep players from using it - if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then - if Flag = 'hedgewars' then Flag:= 'cpu' - else if Flag = 'cpu' then - Flag:= 'hedgewars'; + foundBot:= false; + maxLevel:= -1; + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if (Gear <> nil) and (BotLevel > 0) then + begin + foundBot:= true; + // initially was going to do the highest botlevel of the team, but for now, just apply if entire team has same bot level + if maxLevel = -1 then maxLevel:= BotLevel + else if (maxLevel > 0) and (maxLevel <> BotLevel) then maxLevel:= 0; + //if (maxLevel > 0) and (BotLevel < maxLevel) then maxLevel:= BotLevel + end + else if Gear <> nil then maxLevel:= 0; - flagsurf:= LoadImage(UserPathz[ptFlags] + '/' + Flag, ifNone); - if flagsurf = nil then flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); - if flagsurf = nil then flagsurf:= LoadImage(UserPathz[ptFlags] + '/hedgewars', ifNone); - if flagsurf = nil then flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); + if foundBot then + begin + // disabled the plain flag - I think it looks ok even w/ full bars obscuring CPU + //if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else + Flag:= 'cpu' + end + else if (Flag = 'cpu') or (Flag = 'cpu_plain') then + Flag:= 'hedgewars'; + + flagsurf:= LoadDataImageAltFile(ptFlags, Flag, 'hedgewars', ifNone); TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); + + case maxLevel of + 1: copyToXY(SpritesData[sprBotlevels].Surface, flagsurf, 0, 0); + 2: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 5, 2, 17, 13, 5, 2); + 3: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 9, 5, 13, 10, 9, 5); + 4: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 13, 9, 9, 6, 13, 9); + 5: copyToXYFromRect(SpritesData[sprBotlevels].Surface, flagsurf, 17, 11, 5, 4, 17, 11) + end; + copyToXY(flagsurf, texsurf, 2, 2); SDL_FreeSurface(flagsurf); flagsurf:= nil; + // restore black border pixels inside the flag PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; + FlagTex:= Surface2Tex(texsurf, false); SDL_FreeSurface(texsurf); texsurf:= nil; @@ -192,22 +236,21 @@ dec(drY, r.h + 2); DrawHealthY:= drY; - for i:= 0 to 7 do + for i:= 0 to cMaxHHIndex do with Hedgehogs[i] do if Gear <> nil then begin - NameTagTex:= RenderStringTex(Name, Clan^.Color, fnt16); + NameTagTex:= RenderStringTexLim(Name, Clan^.Color, fnt16, cTeamHealthWidth); if Hat <> 'NoHat' then begin if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then - LoadHedgehogHat(Gear, 'Reserved/' + Copy(Hat,9,Length(s)-8)) + LoadHedgehogHat(Hedgehogs[i], 'Reserved/' + Copy(Hat,9,Length(Hat)-8)) else - LoadHedgehogHat(Gear, Hat); + LoadHedgehogHat(Hedgehogs[i], Hat); end end; end; - MissionIcons:= LoadImage(UserPathz[ptGraphics] + '/missions', ifNone); - if MissionIcons = nil then MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); + MissionIcons:= LoadDataImage(ptGraphics, 'missions', ifCritical); iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); if iconsurf <> nil then begin @@ -220,44 +263,44 @@ SDL_FreeSurface(iconsurf); iconsurf:= nil; end; - end; +end; - procedure InitHealth; - var i, t: LongInt; - begin - for t:= 0 to Pred(TeamsCount) do - if TeamsArray[t] <> nil then - with TeamsArray[t]^ do - begin - for i:= 0 to cMaxHHIndex do - if Hedgehogs[i].Gear <> nil then - RenderHealth(Hedgehogs[i]); - end - end; - - procedure LoadGraves; - var t: LongInt; - texsurf: PSDL_Surface; - begin - for t:= 0 to Pred(TeamsCount) do +procedure InitHealth; +var i, t: LongInt; +begin +for t:= 0 to Pred(TeamsCount) do if TeamsArray[t] <> nil then with TeamsArray[t]^ do begin - if GraveName = '' then GraveName:= 'Statue'; - texsurf:= LoadImage(UserPathz[ptGraves] + '/' + GraveName, ifTransparent); - if texsurf = nil then texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifTransparent); - if texsurf = nil then texsurf:= LoadImage(UserPathz[ptGraves] + '/Statue', ifTransparent); - if texsurf = nil then texsurf:= LoadImage(Pathz[ptGraves] + '/Statue', ifCritical or ifTransparent); + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + RenderHealth(Hedgehogs[i]); + end +end; + +procedure LoadGraves; +var t: LongInt; + texsurf: PSDL_Surface; +begin +for t:= 0 to Pred(TeamsCount) do + if TeamsArray[t] <> nil then + with TeamsArray[t]^ do + begin + if GraveName = '' then + GraveName:= 'Statue'; + texsurf:= LoadDataImageAltFile(ptGraves, GraveName, 'Statue', ifCritical or ifTransparent); GraveTex:= Surface2Tex(texsurf, false); SDL_FreeSurface(texsurf) end - end; +end; -var ii: TSprite; +procedure StoreLoad(reload: boolean); +var s: shortstring; + ii: TSprite; fi: THWFont; ai: TAmmoType; tmpsurf: PSDL_Surface; - i: LongInt; + i, imflags: LongInt; begin AddFileLog('StoreLoad()'); @@ -266,7 +309,8 @@ with Fontz[fi] do begin s:= UserPathz[ptFonts] + '/' + Name; - if not FileExists(s) then s:= Pathz[ptFonts] + '/' + Name; + if not FileExists(s) then + s:= Pathz[ptFonts] + '/' + Name; WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... '); Handle:= TTF_OpenFont(Str2PChar(s), Height); SDLTry(Handle <> nil, true); @@ -274,11 +318,11 @@ WriteLnToConsole(msgOK) end; -WriteNames(fnt16); MakeCrossHairs; LoadGraves; +if not reload then + AddProgress; -AddProgress; for ii:= Low(TSprite) to High(TSprite) do with SpritesData[ii] do // FIXME - add a sprite attribute to match on rq flags? @@ -288,35 +332,19 @@ (((cReducedQuality and rqKillFlakes) = 0) or (Theme = 'Snow') or (Theme = 'Christmas') or ((not (ii in [sprFlake, sprSDFlake])))) and ((cCloudsNumber > 0) or (ii <> sprCloud)) and ((vobCount > 0) or (ii <> sprFlake)) then - begin - if AltPath = ptNone then - if ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk, sprFireButton] then // FIXME: hack - begin - if not reload then - begin - tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent) - end - else tmpsurf:= Surface - end - else - begin - if not reload then - begin - tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical) - end - else tmpsurf:= Surface - end - else begin - if not reload then - begin - tmpsurf:= LoadImage(UserPathz[Path] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(UserPathz[AltPath] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent) - end - else tmpsurf:= Surface + begin + if reload then + tmpsurf:= Surface + else + begin + imflags := (ifAlpha or ifTransparent); + + // these sprites are optional + if not (ii in [sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, sprChunk]) then // FIXME: hack + imflags := (imflags or ifCritical); + + // load the image + tmpsurf := LoadDataImageAltPath(Path, AltPath, FileName, imflags) end; if tmpsurf <> nil then @@ -347,10 +375,13 @@ // This should maybe be flagged. It wastes quite a bit of memory. if not reload then begin -{$IF DEFINED(DARWIN) OR DEFINED(WIN32)} +{$IFDEF USE_CONTEXT_RESTORE} Surface:= tmpsurf {$ELSE} - if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) + if saveSurf then + Surface:= tmpsurf + else + SDL_FreeSurface(tmpsurf) {$ENDIF} end end @@ -358,10 +389,13 @@ Surface:= nil end; -AddProgress; +WriteNames(fnt16); -tmpsurf:= LoadImage(UserPathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifTransparent); -if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent); +if not reload then + AddProgress; + +tmpsurf:= LoadDataImage(ptGraphics, cHHFileName, ifAlpha or ifCritical or ifTransparent); + HHTexture:= Surface2Tex(tmpsurf, false); SDL_FreeSurface(tmpsurf); @@ -371,82 +405,112 @@ ConfirmTexture:= RenderStringTex(trmsg[sidConfirm], cYellowColor, fntBig); SyncTexture:= RenderStringTex(trmsg[sidSync], cYellowColor, fntBig); -AddProgress; +if not reload then + AddProgress; // name of weapons in ammo menu for ai:= Low(TAmmoType) to High(TAmmoType) do with Ammoz[ai] do - begin + begin TryDo(trAmmo[NameId] <> '','No default text/translation found for ammo type #' + intToStr(ord(ai)) + '!',true); tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels); TryDo(tmpsurf <> nil,'Name-texture creation for ammo type #' + intToStr(ord(ai)) + ' failed!',true); tmpsurf:= doSurfaceConversion(tmpsurf); - if (NameTex <> nil) then - FreeTexture(NameTex); + FreeTexture(NameTex); NameTex:= Surface2Tex(tmpsurf, false); SDL_FreeSurface(tmpsurf) - end; + end; // number of weapons in ammo menu for i:= Low(CountTexz) to High(CountTexz) do -begin + begin tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels); tmpsurf:= doSurfaceConversion(tmpsurf); - if (CountTexz[i] <> nil) then - FreeTexture(CountTexz[i]); + FreeTexture(CountTexz[i]); CountTexz[i]:= Surface2Tex(tmpsurf, false); SDL_FreeSurface(tmpsurf) + end; + +if not reload then + AddProgress; +IMG_Quit(); end; -AddProgress; -IMG_Quit(); +{$IF NOT DEFINED(S3D_DISABLED) OR DEFINED(USE_VIDEO_RECORDING)} +procedure CreateFramebuffer(var frame, depth, tex: GLuint); +begin + glGenFramebuffersEXT(1, @frame); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); + glGenRenderbuffersEXT(1, @depth); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth); + glGenTextures(1, @tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); end; +procedure DeleteFramebuffer(var frame, depth, tex: GLuint); +begin + glDeleteTextures(1, @tex); + glDeleteRenderbuffersEXT(1, @depth); + glDeleteFramebuffersEXT(1, @frame); +end; +{$ENDIF} + procedure StoreRelease(reload: boolean); var ii: TSprite; ai: TAmmoType; i, t: LongInt; begin - for ii:= Low(TSprite) to High(TSprite) do +for ii:= Low(TSprite) to High(TSprite) do + begin + FreeTexture(SpritesData[ii].Texture); + SpritesData[ii].Texture:= nil; + if (SpritesData[ii].Surface <> nil) and (not reload) then begin - FreeTexture(SpritesData[ii].Texture); - SpritesData[ii].Texture:= nil; - if (SpritesData[ii].Surface <> nil) and not reload then - begin - SDL_FreeSurface(SpritesData[ii].Surface); - SpritesData[ii].Surface:= nil - end - end; - SDL_FreeSurface(MissionIcons); - FreeTexture(ropeIconTex); - ropeIconTex:= nil; - FreeTexture(HHTexture); - HHTexture:= nil; - FreeTexture(PauseTexture); - PauseTexture:= nil; - FreeTexture(ConfirmTexture); - ConfirmTexture:= nil; - FreeTexture(SyncTexture); - SyncTexture:= nil; - // free all ammo name textures - for ai:= Low(TAmmoType) to High(TAmmoType) do - begin - FreeTexture(Ammoz[ai].NameTex); - Ammoz[ai].NameTex:= nil - end; + SDL_FreeSurface(SpritesData[ii].Surface); + SpritesData[ii].Surface:= nil + end + end; +SDL_FreeSurface(MissionIcons); - // free all count textures - for i:= Low(CountTexz) to High(CountTexz) do - begin - FreeTexture(CountTexz[i]); - CountTexz[i]:= nil - end; +// free the textures declared in uVariables +FreeTexture(WeaponTooltipTex); +WeaponTooltipTex:= nil; +FreeTexture(PauseTexture); +PauseTexture:= nil; +FreeTexture(SyncTexture); +SyncTexture:= nil; +FreeTexture(ConfirmTexture); +ConfirmTexture:= nil; +FreeTexture(ropeIconTex); +ropeIconTex:= nil; +FreeTexture(HHTexture); +HHTexture:= nil; + +// free all ammo name textures +for ai:= Low(TAmmoType) to High(TAmmoType) do + begin + FreeTexture(Ammoz[ai].NameTex); + Ammoz[ai].NameTex:= nil + end; + +// free all count textures +for i:= Low(CountTexz) to High(CountTexz) do + begin + FreeTexture(CountTexz[i]); + CountTexz[i]:= nil + end; // free all team and hedgehog textures for t:= 0 to Pred(TeamsCount) do - begin + begin if TeamsArray[t] <> nil then - begin + begin FreeTexture(TeamsArray[t]^.NameTagTex); TeamsArray[t]^.NameTagTex:= nil; FreeTexture(TeamsArray[t]^.CrosshairTex); @@ -460,26 +524,26 @@ FreeTexture(TeamsArray[t]^.FlagTex); TeamsArray[t]^.FlagTex:= nil; for i:= 0 to cMaxHHIndex do - begin + begin FreeTexture(TeamsArray[t]^.Hedgehogs[i].NameTagTex); TeamsArray[t]^.Hedgehogs[i].NameTagTex:= nil; FreeTexture(TeamsArray[t]^.Hedgehogs[i].HealthTagTex); TeamsArray[t]^.Hedgehogs[i].HealthTagTex:= nil; FreeTexture(TeamsArray[t]^.Hedgehogs[i].HatTex); TeamsArray[t]^.Hedgehogs[i].HatTex:= nil; + end; end; end; - end; +{$IFDEF USE_VIDEO_RECORDING} + if defaultFrame <> 0 then + DeleteFramebuffer(defaultFrame, depthv, texv); +{$ENDIF} {$IFNDEF S3D_DISABLED} if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then - begin - glDeleteTextures(1, @texl); - glDeleteRenderbuffersEXT(1, @depthl); - glDeleteFramebuffersEXT(1, @framel); - glDeleteTextures(1, @texr); - glDeleteRenderbuffersEXT(1, @depthr); - glDeleteFramebuffersEXT(1, @framer) - end + begin + DeleteFramebuffer(framel, depthl, texl); + DeleteFramebuffer(framer, depthr, texr); + end {$ENDIF} end; @@ -487,33 +551,34 @@ procedure RenderHealth(var Hedgehog: THedgehog); var s: shortstring; begin - str(Hedgehog.Gear^.Health, s); - if Hedgehog.HealthTagTex <> nil then - FreeTexture(Hedgehog.HealthTagTex); - Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) +str(Hedgehog.Gear^.Health, s); +FreeTexture(Hedgehog.HealthTagTex); +Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) end; -function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; +function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; var tmpsurf: PSDL_Surface; s: shortstring; begin + LoadImage:= nil; WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] '); s:= filename + '.png'; tmpsurf:= IMG_Load(Str2PChar(s)); if tmpsurf = nil then - begin + begin OutError(msgFailed, (imageFlags and ifCritical) <> 0); - exit(nil) - end; + exit; + end; if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then begin SDL_FreeSurface(tmpsurf); OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); // dummy surface to replace non-critical textures that failed to load due to their size - exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask)); + LoadImage:= SDL_CreateRGBSurface(SDL_SWSURFACE, 2, 2, 32, RMask, GMask, BMask, AMask); + exit; end; tmpsurf:= doSurfaceConversion(tmpsurf); @@ -526,20 +591,69 @@ LoadImage:= tmpsurf //Result end; -procedure LoadHedgehogHat(HHGear: PGear; newHat: shortstring); + +function LoadDataImage(const path: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; +var tmpsurf: PSDL_Surface; +begin + // check for file in user dir (never critical) + tmpsurf:= LoadImage(UserPathz[path] + '/' + filename, imageFlags and (not ifCritical)); + + // if unsuccessful check data dir + if (tmpsurf = nil) then + tmpsurf:= LoadImage(Pathz[path] + '/' + filename, imageFlags); + + LoadDataImage:= tmpsurf; +end; + + +function LoadDataImageAltPath(const path, altPath: TPathType; const filename: shortstring; imageFlags: LongInt): PSDL_Surface; +var tmpsurf: PSDL_Surface; +begin + // if there is no alternative path, just forward and return result + if (altPath = ptNone) then + exit(LoadDataImage(path, filename, imageFlags)); + + // since we have a fallback path this search isn't critical yet + tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); + + // if image still not found try alternative path + if (tmpsurf = nil) then + tmpsurf:= LoadDataImage(altPath, filename, imageFlags); + + LoadDataImageAltPath:= tmpsurf; +end; + +function LoadDataImageAltFile(const path: TPathType; const filename, altFile: shortstring; imageFlags: LongInt): PSDL_Surface; +var tmpsurf: PSDL_Surface; +begin + // if there is no alternative filename, just forward and return result + if (altFile = '') then + exit(LoadDataImage(path, filename, imageFlags)); + + // since we have a fallback filename this search isn't critical yet + tmpsurf:= LoadDataImage(path, filename, imageFlags and (not ifCritical)); + + // if image still not found try alternative filename + if (tmpsurf = nil) then + tmpsurf:= LoadDataImage(path, altFile, imageFlags); + + LoadDataImageAltFile:= tmpsurf; +end; + +procedure LoadHedgehogHat(var HH: THedgehog; newHat: shortstring); var texsurf: PSDL_Surface; begin - texsurf:= LoadImage(UserPathz[ptHats] + '/' + newHat, ifNone); - if texsurf = nil then texsurf:= LoadImage(Pathz[ptHats] + '/' + newHat, ifNone); - + texsurf:= LoadDataImage(ptHats, newHat, ifNone); +AddFileLog('Hat => '+newHat); // only do something if the hat could be loaded if texsurf <> nil then begin +AddFileLog('Got Hat'); // free the mem of any previously assigned texture - FreeTexture(HHGear^.Hedgehog^.HatTex); + FreeTexture(HH.HatTex); // assign new hat to hedgehog - HHGear^.Hedgehog^.HatTex:= Surface2Tex(texsurf, true); + HH.HatTex:= Surface2Tex(texsurf, true); // cleanup: free temporary surface mem SDL_FreeSurface(texsurf) @@ -585,14 +699,23 @@ procedure SetupOpenGL; //var vendor: shortstring = ''; var buf: array[byte] of char; +{$IFDEF USE_VIDEO_RECORDING} + AuxBufNum: LongInt; +{$ENDIF} + tmpstr: AnsiString; + tmpint: LongInt; + tmpn: LongInt; begin buf[0]:= char(0); // avoid compiler hint AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')'); {$IFDEF SDL13} // this function creates an opengles1.1 context by default on mobile devices - // use SDL_GL_SetAttribute to change this behaviour - SDLGLcontext:=SDL_GL_CreateContext(SDLwindow); + // unless you un-comment this two attributes + //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + if SDLGLcontext = nil then + SDLGLcontext:= SDL_GL_CreateContext(SDLwindow); SDLTry(SDLGLcontext <> nil, true); SDL_GL_SetSwapInterval(1); {$ENDIF} @@ -632,60 +755,84 @@ AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); AddFileLog(' |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR)))); AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); - AddFileLog(' \----- Texture Size: ' + inttostr(MaxTextureSize)); + AddFileLog(' |----- Texture Size: ' + inttostr(MaxTextureSize)); +{$IFDEF USE_VIDEO_RECORDING} + glGetIntegerv(GL_AUX_BUFFERS, @AuxBufNum); + AddFileLog(' |----- Number of auxiliary buffers: ' + inttostr(AuxBufNum)); +{$ENDIF} + AddFileLog(' \----- Extensions: '); +{$IFNDEF PAS2C} + // fetch extentions and store them in string + tmpstr := StrPas(PChar(glGetString(GL_EXTENSIONS))); + tmpn := WordCount(tmpstr, [' ']); + tmpint := 1; + + repeat + begin + // print up to 3 extentions per row + // ExtractWord will return empty string if index out of range + AddFileLog(TrimRight( + ExtractWord(tmpint, tmpstr, [' ']) + ' ' + + ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' + + ExtractWord(tmpint+2, tmpstr, [' ']) + )); + tmpint := tmpint + 3; + end; + until (tmpint > tmpn); +{$ELSE} + // doesn't seem to print >256 chars + AddFileLogRaw(PChar(glGetString(GL_EXTENSIONS))); +{$ENDIF} + AddFileLog(''); + + defaultFrame:= 0; +{$IFDEF USE_VIDEO_RECORDING} + if GameType = gmtRecord then + begin + if glLoadExtension('GL_EXT_framebuffer_object') then + begin + CreateFramebuffer(defaultFrame, depthv, texv); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); + AddFileLog('Using framebuffer for video recording.'); + end + else if AuxBufNum > 0 then + begin + glDrawBuffer(GL_AUX0); + glReadBuffer(GL_AUX0); + AddFileLog('Using auxiliary buffer for video recording.'); + end + else + begin + glDrawBuffer(GL_BACK); + glReadBuffer(GL_BACK); + AddFileLog('Warning: off-screen rendering is not supported; using back buffer but it may not work.'); + end; + end; +{$ENDIF} {$IFNDEF S3D_DISABLED} if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then begin // prepare left and right frame buffers and associated textures if glLoadExtension('GL_EXT_framebuffer_object') then - begin - // left - glGenFramebuffersEXT(1, @framel); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel); - glGenRenderbuffersEXT(1, @depthl); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthl); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthl); - glGenTextures(1, @texl); - glBindTexture(GL_TEXTURE_2D, texl); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texl, 0); - - // right - glGenFramebuffersEXT(1, @framer); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer); - glGenRenderbuffersEXT(1, @depthr); - glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthr); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthr); - glGenTextures(1, @texr); - glBindTexture(GL_TEXTURE_2D, texr); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texr, 0); + begin + CreateFramebuffer(framel, depthl, texl); + CreateFramebuffer(framer, depthr, texr); // reset - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) - end + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame) + end else cStereoMode:= smNone; end; {$ENDIF} // set view port to whole window - if (rotationQt = 0) or (rotationQt = 180) then - glViewport(0, 0, cScreenWidth, cScreenHeight) - else - glViewport(0, 0, cScreenHeight, cScreenWidth); + glViewport(0, 0, cScreenWidth, cScreenHeight); glMatrixMode(GL_MODELVIEW); // prepare default translation/scaling glLoadIdentity(); - glRotatef(rotationQt, 0, 0, 1); glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); glTranslatef(0, -cScreenHeight / 2, 0); @@ -704,19 +851,19 @@ procedure SetScale(f: GLfloat); begin - // leave immediately if scale factor did not change - if f = cScaleFactor then exit; +// leave immediately if scale factor did not change + if f = cScaleFactor then + exit; if f = cDefaultZoomLevel then glPopMatrix // "return" to default scaling else // other scaling - begin + begin glPushMatrix; // save default scaling glLoadIdentity; - glRotatef(rotationQt, 0, 0, 1); glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); glTranslatef(0, -cScreenHeight / 2, 0); - end; + end; cScaleFactor:= f; end; @@ -729,8 +876,7 @@ if Step = 0 then begin WriteToConsole(msgLoading + 'progress sprite: '); - texsurf:= LoadImage(UserPathz[ptGraphics] + '/Progress', ifTransparent); - if texsurf = nil then texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); + texsurf:= LoadDataImage(ptGraphics, 'Progress', ifCritical or ifTransparent); ProgrTex:= Surface2Tex(texsurf, false); @@ -739,33 +885,32 @@ SDL_FreeSurface(texsurf); uMobile.GameLoading(); - end; + end; TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); glClear(GL_COLOR_BUFFER_BIT); - if Step < numsquares then r.x:= 0 - else r.x:= squaresize; + if Step < numsquares then + r.x:= 0 + else + r.x:= squaresize; r.y:= (Step mod numsquares) * squaresize; r.w:= squaresize; r.h:= squaresize; - DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); + DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); -{$IFDEF SDL13} - SDL_GL_SwapWindow(SDLwindow); -{$ELSE} - SDL_GL_SwapBuffers(); -{$ENDIF} + SwapBuffers; inc(Step); end; procedure FinishProgress; begin + uMobile.GameLoaded(); WriteLnToConsole('Freeing progress surface... '); FreeTexture(ProgrTex); - uMobile.GameLoaded(); + ProgrTex:= nil; Step:= 0 end; @@ -778,8 +923,10 @@ tmpline, tmpline2, tmpdesc: ansistring; begin // make sure there is a caption as well as a sub caption - description is optional -if caption = '' then caption:= '???'; -if subcaption = '' then subcaption:= ' '; +if caption = '' then + caption:= '???'; +if subcaption = '' then + subcaption:= _S' '; font:= CheckCJKFont(caption,fnt16); font:= CheckCJKFont(subcaption,font); @@ -788,8 +935,8 @@ w:= 0; h:= 0; -wa:= FontBorder * 2 + 4; -ha:= FontBorder * 2; +wa:= cFontBorder * 2 + 4; +ha:= cFontBorder * 2; i:= 0; j:= 0; // avoid compiler hints @@ -804,7 +951,8 @@ // get sub caption's dimensions TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(subcaption), @i, @j); // width adds 36 px (image + space) -if w < (i + 36 + wa) then w:= i + 36 + wa; +if w < (i + 36 + wa) then + w:= i + 36 + wa; inc(h, j + ha); // get description's dimensions @@ -816,7 +964,8 @@ if tmpline <> '' then begin TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), @i, @j); - if w < (i + wa) then w:= i + wa; + if w < (i + wa) then + w:= i + wa; inc(h, j + ha) end end; @@ -825,7 +974,8 @@ begin // get extra label's dimensions TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), @i, @j); - if w < (i + wa) then w:= i + wa; + if w < (i + wa) then + w:= i + wa; inc(h, j + ha); end; @@ -844,9 +994,9 @@ DrawRoundRect(@r, cWhiteColor, cNearBlackColor, tmpsurf, true); // render caption -r:= WriteInRect(tmpsurf, 36 + FontBorder + 2, ha, $ffffffff, font, caption); +r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, ha, $ffffffff, font, caption); // render sub caption -r:= WriteInRect(tmpsurf, 36 + FontBorder + 2, r.y + r.h, $ffc7c7c7, font, subcaption); +r:= WriteInRect(tmpsurf, 36 + cFontBorder + 2, r.y + r.h, $ffc7c7c7, font, subcaption); // render all description lines tmpdesc:= description; @@ -857,21 +1007,21 @@ r2:= r; if tmpline <> '' then begin - r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline); + r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, $ff707070, font, tmpline); // render highlighted caption (if there is a ':') - tmpline2:= ''; + tmpline2:= _S''; SplitByChar(tmpline, tmpline2, ':'); - if tmpline2 <> '' then - WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); + if tmpline2 <> _S'' then + WriteInRect(tmpsurf, cFontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); end end; if extra <> '' then - r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, extracolor, font, extra); + r:= WriteInRect(tmpsurf, cFontBorder + 2, r.y + r.h, extracolor, font, extra); -r.x:= FontBorder + 6; -r.y:= FontBorder + 4; +r.x:= cFontBorder + 6; +r.y:= cFontBorder + 4; r.w:= 32; r.h:= 32; SDL_FillRect(tmpsurf, @r, $ffffffff); @@ -887,12 +1037,12 @@ extra: ansistring; extracolor: LongInt; begin - // don't do anything if the window shouldn't be shown +// don't do anything if the window shouldn't be shown if (cReducedQuality and rqTooltipsOff) <> 0 then - begin + begin WeaponTooltipTex:= nil; exit - end; + end; // free old texture FreeWeaponTooltip; @@ -905,7 +1055,7 @@ r.h:= 32; // default (no extra text) -extra:= ''; +extra:= _S''; extracolor:= 0; if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available @@ -920,7 +1070,7 @@ end else begin - extra:= ''; + extra:= _S''; extracolor:= 0; end; @@ -938,52 +1088,100 @@ procedure FreeWeaponTooltip; begin // free the existing texture (if there is any) -if WeaponTooltipTex = nil then - exit; FreeTexture(WeaponTooltipTex); WeaponTooltipTex:= nil end; +{$IFDEF USE_VIDEO_RECORDING} +{$IFDEF SDL13} +procedure InitOffscreenOpenGL; +begin + // create hidden window + SDLwindow:= SDL_CreateWindow('hedgewars (you don''t see this)', + SDL_WINDOWPOS_CENTERED_MASK, SDL_WINDOWPOS_CENTERED_MASK, + cScreenWidth, cScreenHeight, + SDL_WINDOW_HIDDEN or SDL_WINDOW_OPENGL); + SDLTry(SDLwindow <> nil, true); + SetupOpenGL(); +end; +{$ELSE} +procedure InitOffscreenOpenGL; +var ArgCount: LongInt; + PrgName: pchar; +begin + ArgCount:= 1; + PrgName:= 'hwengine'; + glutInit(@ArgCount, @PrgName); + glutInitWindowSize(cScreenWidth, cScreenHeight); + glutCreateWindow('hedgewars (you don''t see this)'); // we don't need a window, but if this function is not called then OpenGL will not be initialized + glutHideWindow(); + SetupOpenGL(); +end; +{$ENDIF} // SDL13 +{$ENDIF} // USE_VIDEO_RECORDING + procedure chFullScr(var s: shortstring); var flags: Longword = 0; reinit: boolean = false; {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF} {$IFDEF SDL13}x, y: LongInt;{$ENDIF} begin - if Length(s) = 0 then cFullScreen:= not cFullScreen - else cFullScreen:= s = '1'; + if Length(s) = 0 then + cFullScreen:= (not cFullScreen) + else + cFullScreen:= s = '1'; AddFileLog('Preparing to change video parameters...'); -{$IFNDEF IPHONEOS} +{$IFDEF SDL13} + if SDLwindow = nil then +{$ELSE} if SDLPrimSurface = nil then +{$ENDIF} begin // set window title - SDL_WM_SetCaption('Hedgewars', nil); + {$IFNDEF SDL13}SDL_WM_SetCaption(_P'Hedgewars', nil);{$ENDIF} WriteToConsole('Init SDL_image... '); SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); WriteLnToConsole(msgOK); // load engine icon -{$IFNDEF DARWIN} - ico:= LoadImage(UserPathz[ptGraphics] + '/hwengine', ifIgnoreCaps); - if ico = nil then ico:= LoadImage(Pathz[ptGraphics] + '/hwengine', ifIgnoreCaps); + {$IFNDEF DARWIN} + ico:= LoadDataImage(ptGraphics, 'hwengine', ifIgnoreCaps); if ico <> nil then begin SDL_WM_SetIcon(ico, 0); SDL_FreeSurface(ico) end; -{$ENDIF} + {$ENDIF} end else begin + AmmoMenuInvalidated:= true; +{$IFDEF IPHONEOS} + // chFullScr is called when there is a rotation event and needs the SetScale and SetupOpenGL to set up the new resolution + // this 6 gl functions are the relevant ones and are hacked together here for optimisation + glMatrixMode(GL_MODELVIEW); + glPopMatrix; + glLoadIdentity(); + glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); + glTranslatef(0, -cScreenHeight / 2, 0); + glViewport(0, 0, cScreenWidth, cScreenHeight); + exit; +{$ELSE} SetScale(cDefaultZoomLevel); -{$IF DEFINED(DARWIN) OR DEFINED(WIN32)} + {$IFDEF USE_CONTEXT_RESTORE} reinit:= true; -{$ENDIF} + StoreRelease(true); + ResetLand; + ResetWorldTex; + //uTextures.freeModule; //DEBUG ONLY + {$ENDIF} AddFileLog('Freeing old primary surface...'); + {$IFNDEF SDL13} SDL_FreeSurface(SDLPrimSurface); SDLPrimSurface:= nil; + {$ENDIF} +{$ENDIF} end; -{$ENDIF} // these attributes must be set up before creating the sdl window {$IFNDEF WIN32} @@ -997,20 +1195,21 @@ // these values in x and y make the window appear in the center x:= SDL_WINDOWPOS_CENTERED_MASK; y:= SDL_WINDOWPOS_CENTERED_MASK; - flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN; + // SDL_WINDOW_RESIZABLE makes the window respond to rotation events on mobile devices + flags:= SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN or SDL_WINDOW_RESIZABLE; -{$IFDEF MOBILE} - // make the sdl window appear on the second monitor when present - x:= x or (SDL_GetNumVideoDisplays() - 1); - y:= y or (SDL_GetNumVideoDisplays() - 1); - - SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); - flags:= flags or SDL_WINDOW_BORDERLESS or SDL_WINDOW_RESIZABLE; -{$ENDIF} + {$IFDEF MOBILE} + if isPhone() then + SDL_SetHint('SDL_IOS_ORIENTATIONS','LandscapeLeft LandscapeRight'); + // no need for borders on mobile devices + flags:= flags or SDL_WINDOW_BORDERLESS; + {$ENDIF} if SDLwindow = nil then - if cFullScreen then SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) - else SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); + if cFullScreen then + SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cOrigScreenWidth, cOrigScreenHeight, flags or SDL_WINDOW_FULLSCREEN) + else + SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags); SDLTry(SDLwindow <> nil, true); {$ELSE} flags:= SDL_OPENGL or SDL_RESIZABLE; @@ -1019,31 +1218,34 @@ if not cOnlyStats then begin -{$IFDEF WIN32} + {$IFDEF WIN32} s:= SDL_getenv('SDL_VIDEO_CENTERED'); SDL_putenv('SDL_VIDEO_CENTERED=1'); -{$ENDIF} + {$ENDIF} SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); SDLTry(SDLPrimSurface <> nil, true); -{$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} + {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} end; {$ENDIF} SetupOpenGL(); if reinit then begin + // clean the window from any previous content + glClear(GL_COLOR_BUFFER_BIT); if SuddenDeathDmg then - glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) + glClearColor(SDSkyColor.r * (SDTint/255) / 255, SDSkyColor.g * (SDTint/255) / 255, SDSkyColor.b * (SDTint/255) / 255, 0.99) else if ((cReducedQuality and rqNoBackground) = 0) then - glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) - else glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); + glClearColor(SkyColor.r / 255, SkyColor.g / 255, SkyColor.b / 255, 0.99) + else + glClearColor(RQSkyColor.r / 255, RQSkyColor.g / 255, RQSkyColor.b / 255, 0.99); - StoreRelease(true); + // reload everything we had before + ReloadCaptions(false); + ReloadLines; StoreLoad(true); - - ResetLand; - - UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT) + // redraw all land + UpdateLandTexture(0, LAND_WIDTH, 0, LAND_HEIGHT, false); end; end; @@ -1051,16 +1253,12 @@ var ai: TAmmoType; i: LongInt; begin - RegisterVariable('fullscr', vtCommand, @chFullScr, true); + RegisterVariable('fullscr', @chFullScr, true); - SDLPrimSurface:= nil; - - rotationQt:= 0; cScaleFactor:= 2.0; Step:= 0; ProgrTex:= nil; SupportNPOTT:= false; -// cGPUVendor:= gvUnknown; // init all ammo name texture pointers for ai:= Low(TAmmoType) to High(TAmmoType) do @@ -1070,10 +1268,43 @@ // init all count texture pointers for i:= Low(CountTexz) to High(CountTexz) do CountTexz[i] := nil; +{$IFDEF SDL13} + SDLwindow:= nil; + SDLGLcontext:= nil; +{$ELSE} + SDLPrimSurface:= nil; +{$ENDIF} end; procedure freeModule; begin + StoreRelease(false); + TTF_Quit(); +{$IFDEF SDL13} + SDL_GL_DeleteContext(SDLGLcontext); + SDL_DestroyWindow(SDLwindow); +{$ENDIF} + SDL_Quit(); +end; + +procedure WarpMouse(x, y: Word); inline; +begin +{$IFDEF SDL13} + SDL_WarpMouseInWindow(SDLwindow, x, y); +{$ELSE} + x:= x; y:= y; // avoid hints +{$ENDIF} +end; + +procedure SwapBuffers; inline; +begin + if GameType = gmtRecord then + exit; +{$IFDEF SDL13} + SDL_GL_SwapWindow(SDLwindow); +{$ELSE} + SDL_GL_SwapBuffers(); +{$ENDIF} end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uTeams.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,10 @@ unit uTeams; interface -uses uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, uSound, uTypes; +uses uConsts, uInputHandler, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, GLunit, + uSound, uStore, uTypes + {$IFDEF USE_TOUCH_INTERFACE}, uWorld{$ENDIF}; + procedure initModule; procedure freeModule; @@ -34,17 +37,22 @@ procedure RestoreTeamsFromSave; function CheckForWin: boolean; procedure TeamGoneEffect(var Team: TTeam); +procedure SwitchCurrentHedgehog(newHog: PHedgehog); implementation -uses uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript; +uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript, + uGearsUtils, uGearsList + {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}; -const MaxTeamHealth: LongInt = 0; +var MaxTeamHealth: LongInt; + GameOver: boolean; function CheckForWin: boolean; var AliveClan: PClan; s: shortstring; t, AliveCount, i, j: LongInt; begin +CheckForWin:= false; AliveCount:= 0; for t:= 0 to Pred(ClansCount) do if ClansArray[t]^.ClanHealth > 0 then @@ -53,12 +61,17 @@ AliveClan:= ClansArray[t] end; -if (AliveCount > 1) -or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); +if (AliveCount > 1) or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then + exit; CheckForWin:= true; TurnTimeLeft:= 0; ReadyTimeLeft:= 0; + +// if the game ends during a multishot, do last TurnReaction +if (not bBetweenTurns) and isInMultiShoot then + TurnReaction(); + if not GameOver then begin if AliveCount = 0 then @@ -66,7 +79,8 @@ AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); SendStat(siGameResult, trmsg[sidDraw]); AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) - end else // win + end + else // win with AliveClan^ do begin if TeamsNumber = 1 then @@ -108,7 +122,8 @@ begin DeleteCI(Gear); FindPlace(Gear, false, 0, LAND_WIDTH); - if Gear <> nil then AddGearCI(Gear) + if Gear <> nil then + AddGearCI(Gear) end end; @@ -133,7 +148,8 @@ repeat begin inc(c); - if c > cMaxHHIndex then c:= 0 + if c > cMaxHHIndex then + c:= 0 end until (c = CurrHedgehog) or (Hedgehogs[c].Gear <> nil); LocalAmmo:= Hedgehogs[c].AmmoStore @@ -142,7 +158,7 @@ c:= CurrentTeam^.Clan^.ClanIndex; repeat with ClansArray[c]^ do - if (CurrTeam = TagTeamIndex) and ((GameFlags And gfTagTeam) <> 0) then + if (CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0) then begin TagTeamIndex:= Pred(TagTeamIndex) mod TeamsNumber; CurrTeam:= Pred(CurrTeam) mod TeamsNumber; @@ -150,11 +166,13 @@ NextClan:= true; end; - if (GameFlags And gfTagTeam) = 0 then inc(c); + if (GameFlags and gfTagTeam) = 0 then + inc(c); if c = ClansCount then begin - if not PlacingHogs then inc(TotalRounds); + if not PlacingHogs then + inc(TotalRounds); c:= 0 end; @@ -171,38 +189,59 @@ CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) end - until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags And gfTagTeam) <> 0)); + until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0)); end until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); -CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]); +SwitchCurrentHedgehog(@(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog])); +{$IFDEF USE_TOUCH_INTERFACE} +if (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0 then + begin + if not(arrowUp.show) then + begin + animateWidget(@arrowUp, true, true); + animateWidget(@arrowDown, true, true); + end; + end +else + if arrowUp.show then + begin + animateWidget(@arrowUp, true, false); + animateWidget(@arrowDown, true, false); + end; +{$ENDIF} +AmmoMenuInvalidated:= true; end; procedure AfterSwitchHedgehog; var i, t: LongInt; CurWeapon: PAmmo; + w: real; + vg: PVisualGear; begin if PlacingHogs then - begin - PlacingHogs:= false; - for t:= 0 to Pred(TeamsCount) do - for i:= 0 to cMaxHHIndex do - if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then - PlacingHogs:= true; + begin + PlacingHogs:= false; + for t:= 0 to Pred(TeamsCount) do + for i:= 0 to cMaxHHIndex do + if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then + PlacingHogs:= true; - if not PlacingHogs then // Reset various things I mucked with - begin - for i:= 0 to ClansCount do - if ClansArray[i] <> nil then ClansArray[i]^.TurnNumber:= 0; - ResetWeapons - end - end; + if not PlacingHogs then // Reset various things I mucked with + begin + for i:= 0 to ClansCount do + if ClansArray[i] <> nil then + ClansArray[i]^.TurnNumber:= 0; + ResetWeapons + end + end; inc(CurrentTeam^.Clan^.TurnNumber); -CurWeapon:= GetAmmoEntry(CurrentHedgehog^); -if CurWeapon^.Count = 0 then CurrentHedgehog^.CurAmmoType:= amNothing; +CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); +if CurWeapon^.Count = 0 then + CurrentHedgehog^.CurAmmoType:= amNothing; with CurrentHedgehog^ do begin @@ -211,6 +250,7 @@ Z:= cCurrHHZ; State:= gstHHDriven; Active:= true; + Power:= 0; LastDamage:= nil end; RemoveGearFromList(Gear); @@ -218,34 +258,32 @@ FollowGear:= Gear end; -ResetKbd; - if (GameFlags and gfDisableWind) = 0 then begin - cWindSpeed:= rndSign(GetRandom * 2 * cMaxWindSpeed); - // cWindSpeedf:= cWindSpeed.QWordValue / _1.QWordValue throws 'Internal error 200502052' on Darwin - // see http://mantis.freepascal.org/view.php?id=17714 - cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue; - if cWindSpeed.isNegative then - CWindSpeedf := -cWindSpeedf; - AddVisualGear(0, 0, vgtSmoothWindBar); + cWindSpeed:= rndSign(GetRandomf * 2 * cMaxWindSpeed); + w:= hwFloat2Float(cWindSpeed); + vg:= AddVisualGear(0, 0, vgtSmoothWindBar); + if vg <> nil then vg^.dAngle:= w; AddFileLog('Wind = '+FloatToStr(cWindSpeed)); end; ApplyAmmoChanges(CurrentHedgehog^); -if (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then SetBinds(CurrentTeam^.Binds); +if (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then + SetBinds(CurrentTeam^.Binds); bShowFinger:= true; if PlacingHogs then begin - if CurrentHedgehog^.Unplaced then TurnTimeLeft:= 15000 + if CurrentHedgehog^.Unplaced then + TurnTimeLeft:= 15000 else TurnTimeLeft:= 0 end -else if ((GameFlags And gfTagTeam) <> 0) and not NextClan then +else if ((GameFlags and gfTagTeam) <> 0) and (not NextClan) then begin - if TagTurnTimeLeft <> 0 then TurnTimeLeft:= TagTurnTimeLeft; + if TagTurnTimeLeft <> 0 then + TurnTimeLeft:= TagTurnTimeLeft; TagTurnTimeLeft:= 0; end else @@ -260,7 +298,8 @@ AddVoice(sndIllGetYou, CurrentTeam^.voicepack) else AddVoice(sndYesSir, CurrentTeam^.voicepack); - if PlacingHogs or (cHedgehogTurnTime < 1000000) then ReadyTimeLeft:= cReadyDelay; + if cHedgehogTurnTime < 1000000 then + ReadyTimeLeft:= cReadyDelay; AddCaption(Format(shortstring(trmsg[sidReady]), CurrentTeam^.TeamName), cWhiteColor, capgrpGameState) end else @@ -270,7 +309,9 @@ ReadyTimeLeft:= 0 end; -uMobile.NewTurnBeginning(); +{$IFDEF SDL13} +uTouch.NewTurnBeginning(); +{$ENDIF} ScriptCall('onNewTurn'); end; @@ -292,22 +333,23 @@ c:= Pred(ClansCount); while (c >= 0) and (ClansArray[c]^.Color <> TeamColor) do dec(c); if c < 0 then - begin - new(team^.Clan); - FillChar(team^.Clan^, sizeof(TClan), 0); - ClansArray[ClansCount]:= team^.Clan; - inc(ClansCount); - with team^.Clan^ do + begin + new(team^.Clan); + FillChar(team^.Clan^, sizeof(TClan), 0); + ClansArray[ClansCount]:= team^.Clan; + inc(ClansCount); + with team^.Clan^ do begin ClanIndex:= Pred(ClansCount); Color:= TeamColor; TagTeamIndex:= 0; Flawless:= true end - end else - begin - team^.Clan:= ClansArray[c]; - end; + end +else + begin + team^.Clan:= ClansArray[c]; + end; with team^.Clan^ do begin @@ -343,23 +385,26 @@ th:= 0; for i:= 0 to cMaxHHIndex do if Hedgehogs[i].Gear <> nil then - inc(th, Hedgehogs[i].Gear^.Health); - if th > MaxTeamHealth then MaxTeamHealth:= th; + inc(th, Hedgehogs[i].Gear^.Health); + if th > MaxTeamHealth then + MaxTeamHealth:= th; // Some initial King buffs if (GameFlags and gfKing) <> 0 then begin Hedgehogs[0].King:= true; Hedgehogs[0].Hat:= 'crown'; - Hedgehogs[0].Effects[hePoisoned] := false; + Hedgehogs[0].Effects[hePoisoned] := 0; h:= Hedgehogs[0].Gear^.Health; Hedgehogs[0].Gear^.Health:= hwRound(int2hwFloat(th)*_0_375); if Hedgehogs[0].Gear^.Health > h then begin dec(th, h); inc(th, Hedgehogs[0].Gear^.Health); - if th > MaxTeamHealth then MaxTeamHealth:= th + if th > MaxTeamHealth then + MaxTeamHealth:= th end - else Hedgehogs[0].Gear^.Health:= h; + else + Hedgehogs[0].Gear^.Health:= h; Hedgehogs[0].InitialHealth:= Hedgehogs[0].Gear^.Health end; end; @@ -372,7 +417,8 @@ begin value:= 0; for i:= 0 to cMaxHHIndex do - if p^.Hedgehogs[i].Gear <> nil then inc(value); + if p^.Hedgehogs[i].Gear <> nil then + inc(value); TeamSize:= value; end; @@ -406,7 +452,8 @@ begin MaxTeamHealth:= NewTeamHealthBarWidth; RecountAllTeamsHealth; - end else if NewTeamHealthBarWidth > 0 then NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth + end else if NewTeamHealthBarWidth > 0 then + NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth end; RecountClanHealth(team^.Clan); @@ -435,7 +482,7 @@ begin Gear^.Invulnerable:= false; Gear^.Damage:= Gear^.Health; - Gear^.State:= (Gear^.State or gstHHGone) and not gstHHDriven + Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven) end end end; @@ -443,102 +490,124 @@ procedure chAddHH(var id: shortstring); var s: shortstring; Gear: PGear; + c: LongInt; begin - s:= ''; - if (not isDeveloperMode) or (CurrentTeam = nil) then exit; - with CurrentTeam^ do +s:= ''; +if (not isDeveloperMode) or (CurrentTeam = nil) then + exit; +with CurrentTeam^ do + begin + SplitBySpace(id, s); + SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]); + val(id, CurrentHedgehog^.BotLevel, c); + Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); + SplitBySpace(s, id); + val(s, Gear^.Health, c); + TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); + Gear^.Hedgehog^.Team:= CurrentTeam; + if (GameFlags and gfSharedAmmo) <> 0 then + CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex + else if (GameFlags and gfPerHogAmmo) <> 0 then begin - SplitBySpace(id, s); - CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; - val(id, CurrentHedgehog^.BotLevel); - Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); - SplitBySpace(s, id); - val(s, Gear^.Health); - TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); - Gear^.Hedgehog^.Team:= CurrentTeam; - if (GameFlags and gfSharedAmmo) <> 0 then CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex - else if (GameFlags and gfPerHogAmmo) <> 0 then - begin - AddAmmoStore; - CurrentHedgehog^.AmmoStore:= StoreCnt - 1 - end - else CurrentHedgehog^.AmmoStore:= TeamsCount - 1; - CurrentHedgehog^.Gear:= Gear; - CurrentHedgehog^.Name:= id; - CurrentHedgehog^.InitialHealth:= Gear^.Health; - CurrHedgehog:= HedgehogsNumber; - inc(HedgehogsNumber) + AddAmmoStore; + CurrentHedgehog^.AmmoStore:= StoreCnt - 1 end + else CurrentHedgehog^.AmmoStore:= TeamsCount - 1; + CurrentHedgehog^.Gear:= Gear; + CurrentHedgehog^.Name:= id; + CurrentHedgehog^.InitialHealth:= Gear^.Health; + CurrHedgehog:= HedgehogsNumber; + inc(HedgehogsNumber) + end end; procedure chAddTeam(var s: shortstring); var Color: Longword; + c: LongInt; ts, cs: shortstring; begin - cs:= ''; - ts:= ''; - if isDeveloperMode then - begin - SplitBySpace(s, cs); - SplitBySpace(cs, ts); - val(cs, Color); - TryDo(Color <> 0, 'Error: black team color', true); +cs:= ''; +ts:= ''; +if isDeveloperMode then + begin + SplitBySpace(s, cs); + SplitBySpace(cs, ts); + val(cs, Color, c); + TryDo(Color <> 0, 'Error: black team color', true); - // color is always little endian so the mask must be constant also in big endian archs - Color:= Color or $FF000000; + // color is always little endian so the mask must be constant also in big endian archs + Color:= Color or $FF000000; + AddTeam(Color); + CurrentTeam^.TeamName:= ts; + CurrentTeam^.PlayerHash:= s; + if GameType in [gmtDemo, gmtSave, gmtRecord] then + CurrentTeam^.ExtDriven:= true; - AddTeam(Color); - CurrentTeam^.TeamName:= ts; - CurrentTeam^.PlayerHash:= s; - if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true; - - CurrentTeam^.voicepack:= AskForVoicepack('Default') - end + CurrentTeam^.voicepack:= AskForVoicepack('Default') + end end; procedure chSetHHCoords(var x: shortstring); var y: shortstring; - t: Longint; + t, c: Longint; begin y:= ''; -if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then exit; +if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then + exit; SplitBySpace(x, y); -val(x, t); +val(x, t, c); CurrentHedgehog^.Gear^.X:= int2hwFloat(t); -val(y, t); +val(y, t, c); CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) end; procedure chBind(var id: shortstring); -var s: shortstring; +var KeyName, Modifier, tmp: shortstring; b: LongInt; begin -s:= ''; -if CurrentTeam = nil then exit; -SplitBySpace(id, s); -if s[1]='"' then Delete(s, 1, 1); -if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); -b:= KeyNameToCode(id); -if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) - else CurrentTeam^.Binds[b]:= s +KeyName:= ''; +Modifier:= ''; + +if CurrentTeam = nil then + exit; + +if(Pos('mod:', id) <> 0)then + begin + tmp:= ''; + SplitBySpace(id, tmp); + Modifier:= id; + id:= tmp; + end; + +SplitBySpace(id, KeyName); +if KeyName[1]='"' then + Delete(KeyName, 1, 1); +if KeyName[byte(KeyName[0])]='"' then + Delete(KeyName, byte(KeyName[0]), 1); +b:= KeyNameToCode(id, Modifier); +if b = 0 then + OutError(errmsgUnknownVariable + ' "' + id + '"', false) +else + CurrentTeam^.Binds[b]:= KeyName; end; procedure chTeamGone(var s:shortstring); var t: LongInt; begin t:= 0; -while (t < cMaxTeams) - and (TeamsArray[t] <> nil) - and (TeamsArray[t]^.TeamName <> s) do inc(t); -if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit; +while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do + inc(t); +if (t = cMaxTeams) or (TeamsArray[t] = nil) then + exit; with TeamsArray[t]^ do - begin - AddChatString('** '+ TeamName + ' is gone'); - hasGone:= true - end; + if not hasGone then + begin + AddChatString('** '+ TeamName + ' is gone'); + hasGone:= true; -RecountTeamHealth(TeamsArray[t]) + RecountTeamHealth(TeamsArray[t]) + end; end; @@ -559,43 +628,64 @@ RecountAllTeamsHealth(); end; +procedure SwitchCurrentHedgehog(newHog: PHedgehog); +var oldCI, newCI: boolean; + oldHH: PHedgehog; +begin + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.CurAmmoType = amKnife) then + LoadHedgehogHat(CurrentHedgehog^, CurrentHedgehog^.Hat); + oldCI:= (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex >= 0); + newCI:= (newHog^.Gear <> nil) and (newHog^.Gear^.CollisionIndex >= 0); + if oldCI then DeleteCI(CurrentHedgehog^.Gear); + if newCI then DeleteCI(newHog^.Gear); + oldHH:= CurrentHedgehog; + CurrentHedgehog:= newHog; + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.CurAmmoType = amKnife) then + LoadHedgehogHat(CurrentHedgehog^, 'Reserved/chef'); + if oldCI then AddGearCI(oldHH^.Gear); + if newCI then AddGearCI(newHog^.Gear) +end; + + procedure initModule; begin - RegisterVariable('addhh', vtCommand, @chAddHH, false); - RegisterVariable('addteam', vtCommand, @chAddTeam, false); - RegisterVariable('hhcoords', vtCommand, @chSetHHCoords, false); - RegisterVariable('bind', vtCommand, @chBind, true ); - RegisterVariable('teamgone', vtCommand, @chTeamGone, true ); - RegisterVariable('finish', vtCommand, @chFinish, true ); // all teams gone +RegisterVariable('addhh', @chAddHH, false); +RegisterVariable('addteam', @chAddTeam, false); +RegisterVariable('hhcoords', @chSetHHCoords, false); +RegisterVariable('bind', @chBind, true ); +RegisterVariable('teamgone', @chTeamGone, true ); +RegisterVariable('finish', @chFinish, true ); // all teams gone - CurrentTeam:= nil; - PreviousTeam:= nil; - CurrentHedgehog:= nil; - TeamsCount:= 0; - ClansCount:= 0; - LocalClan:= -1; - LocalTeam:= -1; - LocalAmmo:= -1; - GameOver:= false; - NextClan:= true; +CurrentTeam:= nil; +PreviousTeam:= nil; +CurrentHedgehog:= nil; +TeamsCount:= 0; +ClansCount:= 0; +LocalClan:= -1; +LocalTeam:= -1; +LocalAmmo:= -1; +GameOver:= false; +NextClan:= true; +MaxTeamHealth:= 0; end; procedure freeModule; var i, h: LongWord; begin - if TeamsCount > 0 then - begin - for i:= 0 to Pred(TeamsCount) do +if TeamsCount > 0 then + begin + for i:= 0 to Pred(TeamsCount) do begin - for h:= 0 to cMaxHHIndex do - if TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil then - Dispose(TeamsArray[i]^.Hedgehogs[h].GearHidden); - Dispose(TeamsArray[i]); - end; - for i:= 0 to Pred(ClansCount) do Dispose(ClansArray[i]); - end; - TeamsCount:= 0; - ClansCount:= 0; + for h:= 0 to cMaxHHIndex do + if TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil then + Dispose(TeamsArray[i]^.Hedgehogs[h].GearHidden); + Dispose(TeamsArray[i]); + end; +for i:= 0 to Pred(ClansCount) do + Dispose(ClansArray[i]); + end; +TeamsCount:= 0; +ClansCount:= 0; end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uTextures.pas --- a/hedgewars/uTextures.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uTextures.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,7 +31,7 @@ procedure freeModule; implementation -uses GLunit, uUtils, uVariables, uConsts, uDebug; +uses GLunit, uUtils, uVariables, uConsts, uDebug, uConsole; var TextureList: PTexture; @@ -39,10 +39,10 @@ procedure SetTextureParameters(enableClamp: Boolean); begin if enableClamp and ((cReducedQuality and rqClampLess) = 0) then - begin + begin glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) - end; + end; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) end; @@ -119,6 +119,8 @@ fromP4:= @(fromP4^[Surf^.pitch div 4]) end; end; + + function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture; var tw, th, x, y: Longword; tmpp: pointer; @@ -154,7 +156,8 @@ fromP4:= Surf^.pixels; -if cGrayScale then Surface2GrayScale(Surf); +if GrayScale then + Surface2GrayScale(Surf); if (not SupportNPOTT) and (not (isPowerOf2(Surf^.w) and isPowerOf2(Surf^.h))) then begin @@ -164,22 +167,25 @@ Surface2Tex^.rx:= Surf^.w / tw; Surface2Tex^.ry:= Surf^.h / th; - GetMem(tmpp, tw * th * surf^.format^.BytesPerPixel); + tmpp:= GetMem(tw * th * surf^.format^.BytesPerPixel); fromP4:= Surf^.pixels; toP4:= tmpp; for y:= 0 to Pred(Surf^.h) do begin - for x:= 0 to Pred(Surf^.w) do toP4^[x]:= fromP4^[x]; - for x:= Surf^.w to Pred(tw) do toP4^[x]:= 0; + for x:= 0 to Pred(Surf^.w) do + toP4^[x]:= fromP4^[x]; + for x:= Surf^.w to Pred(tw) do + toP4^[x]:= 0; toP4:= @(toP4^[tw]); fromP4:= @(fromP4^[Surf^.pitch div 4]) end; for y:= Surf^.h to Pred(th) do begin - for x:= 0 to Pred(tw) do toP4^[x]:= 0; + for x:= 0 to Pred(tw) do + toP4^[x]:= 0; toP4:= @(toP4^[tw]) end; @@ -206,16 +212,16 @@ // if nil is passed nothing is done procedure FreeTexture(tex: PTexture); begin - if tex <> nil then +if tex <> nil then begin - if tex^.NextTexture <> nil then - tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; - if tex^.PrevTexture <> nil then - tex^.PrevTexture^.NextTexture:= tex^.NextTexture - else - TextureList:= tex^.NextTexture; - glDeleteTextures(1, @tex^.id); - Dispose(tex); + if tex^.NextTexture <> nil then + tex^.NextTexture^.PrevTexture:= tex^.PrevTexture; + if tex^.PrevTexture <> nil then + tex^.PrevTexture^.NextTexture:= tex^.NextTexture + else + TextureList:= tex^.NextTexture; + glDeleteTextures(1, @tex^.id); + Dispose(tex); end end; @@ -226,7 +232,13 @@ procedure freeModule; begin - while TextureList <> nil do FreeTexture(TextureList); +if TextureList <> nil then + WriteToConsole('FIXME FIXME FIXME. App shutdown without full cleanup of texture list; read game0.log and please report this problem'); + while TextureList <> nil do + begin + AddFileLog('Texture not freed: width='+inttostr(LongInt(TextureList^.w))+' height='+inttostr(LongInt(TextureList^.h))+' priority='+inttostr(round(TextureList^.priority*1000))); + FreeTexture(TextureList); + end end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uTouch.pas --- a/hedgewars/uTouch.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uTouch.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2011 Richard Deurwaarder + * Copyright (c) 2012 Richard Deurwaarder * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,61 +22,54 @@ interface -uses sysutils, math, uConsole, uVariables, SDLh, uTypes, uFloat, uConsts, uIO, uCommands, GLUnit; - -// TODO: this type should be Int64 -// TODO: this type should be named TSDL_FingerId -type SDL_FingerId = LongInt; +uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uAmmos, uWorld, uMobile; -type - PTouch_Finger = ^Touch_Finger; - Touch_Finger = record - id : SDL_FingerId; - x,y : LongInt; - historicalX, historicalY : LongInt; - timeSinceDown : Longword; - end; procedure initModule; +procedure freeModule; procedure ProcessTouch; -procedure onTouchDown(x,y: Longword; pointerId: SDL_FingerId); -procedure onTouchMotion(x,y: Longword; dx,dy: LongInt; pointerId: SDL_FingerId); -procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId); -function convertToCursor(scale: LongInt; xy: LongInt): LongInt; -function addFinger(x,y: Longword; id: SDL_FingerId): PTouch_Finger; -procedure deleteFinger(id: SDL_FingerId); -procedure onTouchClick(finger: Touch_Finger); -procedure onTouchDoubleClick(finger: Touch_Finger); +procedure NewTurnBeginning; -function findFinger(id: SDL_FingerId): PTouch_Finger; -procedure aim(finger: Touch_Finger); -function isOnCrosshair(finger: Touch_Finger): boolean; -function isOnCurrentHog(finger: Touch_Finger): boolean; -function isOnFireButton(finger: Touch_Finger): boolean; -procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger); -procedure convertToFingerCoord(var x,y: hwFloat; oldX, oldY: hwFloat); -function fingerHasMoved(finger: Touch_Finger): boolean; -function calculateDelta(finger1, finger2: Touch_Finger): hwFloat; -function getSecondFinger(finger: Touch_Finger): PTouch_Finger; -procedure printFinger(finger: Touch_Finger); +procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId); +procedure onTouchMotion(x,y: Longword; dx,dy: LongInt; pointerId: TSDL_FingerId); +procedure onTouchUp(x,y: Longword; pointerId: TSDL_FingerId); +function convertToCursorX(x: LongInt): LongInt; +function convertToCursorY(y: LongInt): LongInt; +function convertToCursorDeltaX(x: LongInt): LongInt; +function convertToCursorDeltaY(y: LongInt): LongInt; +function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data; +function updateFinger(x,y,dx,dy: Longword; id: TSDL_FingerId): PTouch_Data; +procedure deleteFinger(id: TSDL_FingerId); +procedure onTouchClick(finger: TTouch_Data); +procedure onTouchDoubleClick(finger: TTouch_Data); +procedure onTouchLongClick(finger: TTouch_Data); + +function findFinger(id: TSDL_FingerId): PTouch_Data; +procedure aim(finger: TTouch_Data); +function isOnCrosshair(finger: TTouch_Data): boolean; +function isOnCurrentHog(finger: TTouch_Data): boolean; +procedure convertToWorldCoord(var x,y: LongInt; finger: TTouch_Data); +procedure convertToFingerCoord(var x,y: LongInt; oldX, oldY: LongInt); +function fingerHasMoved(finger: TTouch_Data): boolean; +function calculateDelta(finger1, finger2: TTouch_Data): LongInt; +function getSecondFinger(finger: TTouch_Data): PTouch_Data; +function isOnRect(rect: TSDL_Rect; finger: TTouch_Data): boolean; +function isOnRect(x,y,w,h: LongInt; finger: TTouch_Data): boolean; +function isOnWidget(widget: TOnScreenWidget; finger: TTouch_Data): boolean; +procedure printFinger(finger: TTouch_Data); implementation const - clicktime = 200; - nilFingerId = High(SDL_FingerId); + clickTime = 200; + nilFingerId = High(TSDL_FingerId); + baseRectSize = 96; var - fireButtonLeft, fireButtonRight, fireButtonTop, fireButtonBottom : LongInt; - - + rectSize, halfRectSize: LongInt; - leftButtonBoundary : LongInt; - rightButtonBoundary : LongInt; - topButtonBoundary : LongInt; - pointerCount : Longword; - fingers: array of Touch_Finger; + fingers: array of TTouch_Data; moveCursor : boolean; invertCursor : boolean; @@ -84,188 +77,275 @@ timeSinceClick : Longword; //Pinch to zoom - pinchSize : hwFloat; + pinchSize : LongInt; baseZoomValue: GLFloat; - //aiming - aiming, movingCrosshair: boolean; - crosshairCommand: ShortString; + aimingCrosshair: boolean; + aimingUp, aimingDown: boolean; targetAngle: LongInt; - stopFiring: boolean; + + buttonsDown: Longword; + targetting, targetted: boolean; //true when targetting an airstrike or the like + +procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId); +var + finger: PTouch_Data; +begin +{$IFDEF USE_TOUCH_INTERFACE} +finger := addFinger(x,y,pointerId); + +inc(buttonsDown);//inc buttonsDown, if we don't see a button down we'll dec it + +if isOnCrosshair(finger^) then +begin + aimingCrosshair:= true; + aim(finger^); + moveCursor:= false; + exit; +end; - //moving - stopLeft, stopRight, walkingLeft, walkingRight : boolean; - +if isOnWidget(fireButton, finger^) then + begin + ParseTeamCommand('+attack'); + moveCursor:= false; + finger^.pressedWidget:= @fireButton; + exit; + end; +if isOnWidget(arrowLeft, finger^) then + begin + ParseTeamCommand('+left'); + moveCursor:= false; + finger^.pressedWidget:= @arrowLeft; + exit; + end; +if isOnWidget(arrowRight, finger^) then + begin + ParseTeamCommand('+right'); + moveCursor:= false; + finger^.pressedWidget:= @arrowRight; + exit; + end; +if isOnWidget(arrowUp, finger^) then + begin + ParseTeamCommand('+up'); + aimingUp:= true; + moveCursor:= false; + finger^.pressedWidget:= @arrowUp; + exit; + end; +if isOnWidget(arrowDown, finger^) then + begin + ParseTeamCommand('+down'); + aimingDown:= true; + moveCursor:= false; + finger^.pressedWidget:= @arrowDown; + exit; + end; -procedure onTouchDown(x,y: Longword; pointerId: SDL_FingerId); -var - finger: PTouch_Finger; -begin - finger := addFinger(x,y,pointerId); +if isOnWidget(pauseButton, finger^) then + begin + isPaused:= not isPaused; + moveCursor:= false; + finger^.pressedWidget:= @pauseButton; + exit; + end; + +if isOnWidget(utilityWidget, finger^) then + begin + finger^.pressedWidget:= @utilityWidget; + moveCursor:= false; + if(CurrentHedgehog <> nil) then + begin + if Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Timerable <> 0 then + ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1)); + end; + exit; + end; +dec(buttonsDown);//no buttonsDown, undo the inc() above +if buttonsDown = 0 then + begin + moveCursor:= true; case pointerCount of 1: - begin - moveCursor:= false; - if bShowAmmoMenu then - begin - moveCursor := true; - exit; - end; - - if isOnCrosshair(finger^) then - begin - aiming:= true; - exit; - end; - - if isOnFireButton(finger^) then - begin - stopFiring:= false; - ParseCommand('+attack', true); - exit; - end; - if (finger^.x < leftButtonBoundary) and (finger^.y < 390) then + targetting:= not(targetted) and (CurrentHedgehog <> nil) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0); + 2: begin - ParseCommand('+left', true); - walkingLeft := true; - exit; - end; - if finger^.x > rightButtonBoundary then - begin - ParseCommand('+right', true); - walkingRight:= true; - exit; - end; - if finger^.y < topButtonBoundary then - begin - ParseCommand('hjump', true); - exit; - end; - moveCursor:= true; - end; - 2: - begin - aiming:= false; - stopFiring:= true; moveCursor:= false; pinchSize := calculateDelta(finger^, getSecondFinger(finger^)^); baseZoomValue := ZoomValue + end; end; - end;//end case pointerCount of + end; +{$ENDIF} end; -procedure onTouchMotion(x,y: Longword;dx,dy: LongInt; pointerId: SDL_FingerId); +procedure onTouchMotion(x,y: Longword;dx,dy: LongInt; pointerId: TSDL_FingerId); var - finger, secondFinger: PTouch_Finger; - currentPinchDelta, zoom : hwFloat; - tmpX, tmpY: LongInt; + finger, secondFinger: PTouch_Data; + currentPinchDelta, zoom : single; begin - x := x; - y := y; - dx := dx; - dy := dy; - finger:= findFinger(pointerId); - tmpX := convertToCursor(cScreenWidth, x); - tmpY := convertToCursor(cScreenHeight, y); +finger:= updateFinger(x,y,dx,dy,pointerId); - if moveCursor then +if moveCursor then begin if invertCursor then begin - CursorPoint.X := CursorPoint.X + (finger^.x - tmpX); - CursorPoint.Y := CursorPoint.Y - (finger^.y - tmpY); + CursorPoint.X := CursorPoint.X - finger^.dx; + CursorPoint.Y := CursorPoint.Y + finger^.dy; end - else + else begin - CursorPoint.X := CursorPoint.X - (finger^.x - tmpX); - CursorPoint.Y := CursorPoint.Y + (finger^.y - tmpY); + CursorPoint.X := CursorPoint.X + finger^.dx; + CursorPoint.Y := CursorPoint.Y - finger^.dy; end; - finger^.x := tmpX; - finger^.y := tmpY; exit //todo change into switch rather than ugly ifs end; - finger^.x := tmpX; - finger^.y := tmpY; - - if aiming then +if aimingCrosshair then begin aim(finger^); exit end; - if pointerCount = 2 then + +if (buttonsDown = 0) and (pointerCount = 2) then begin secondFinger := getSecondFinger(finger^); currentPinchDelta := calculateDelta(finger^, secondFinger^) - pinchSize; zoom := currentPinchDelta/cScreenWidth; - ZoomValue := baseZoomValue - ((hwFloat2Float(zoom) * cMinMaxZoomLevelDelta)); - if ZoomValue < cMaxZoomLevel then ZoomValue := cMaxZoomLevel; - if ZoomValue > cMinZoomLevel then ZoomValue := cMinZoomLevel; - end; -end; - -procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId); -begin - x := x; - y := y; - aiming:= false; - stopFiring:= true; - deleteFinger(pointerId); - - if walkingLeft then - begin - ParseCommand('-left', true); - walkingLeft := false; + ZoomValue := baseZoomValue - (zoom * cMinMaxZoomLevelDelta); + if ZoomValue < cMaxZoomLevel then + ZoomValue := cMaxZoomLevel; + if ZoomValue > cMinZoomLevel then + ZoomValue := cMinZoomLevel; end; - if walkingRight then - begin - ParseCommand('-right', true); - walkingRight := false; - end; -end; - -procedure onTouchDoubleClick(finger: Touch_Finger); -begin - finger := finger;//avoid compiler hint - ParseCommand('ljump', true); end; -procedure onTouchClick(finger: Touch_Finger); +procedure onTouchUp(x,y: Longword; pointerId: TSDL_FingerId); +var + finger: PTouch_Data; + widget: POnScreenWidget; begin - if (SDL_GetTicks - timeSinceClick < 300) and (DistanceI(finger.X-xTouchClick, finger.Y-yTouchClick) < _30) then +{$IFDEF USE_TOUCH_INTERFACE} +x := x; +y := y; +finger:= updateFinger(x,y,0,0,pointerId); +//Check for onTouchClick event +if not(fingerHasMoved(finger^)) then begin - onTouchDoubleClick(finger); - exit; - end + if (RealTicks - finger^.timeSinceDown) < clickTime then + onTouchClick(finger^) else + onTouchLongClick(finger^); + end; + +if aimingCrosshair then begin - xTouchClick := finger.x; - yTouchClick := finger.y; - timeSinceClick := SDL_GetTicks; + aimingCrosshair:= false; + ParseTeamCommand('-up'); + ParseTeamCommand('-down'); + dec(buttonsDown); end; - if bShowAmmoMenu then +widget:= finger^.pressedWidget; +if (buttonsDown > 0) and (widget <> nil) then begin - doPut(CursorPoint.X, CursorPoint.Y, false); - exit + dec(buttonsDown); + + if widget = @arrowLeft then + ParseTeamCommand('-left'); + + if widget = @arrowRight then + ParseTeamCommand('-right'); + + if widget = @arrowUp then + ParseTeamCommand('-up'); + + if widget = @arrowDown then + ParseTeamCommand('-down'); + + if widget = @fireButton then + ParseTeamCommand('-attack'); + + if widget = @utilityWidget then + if (CurrentHedgehog <> nil)then + if(Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0)then + begin + ParseTeamCommand('put'); + targetted:= true; + end + else if (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amSwitch) then + ParseTeamCommand('switch') + else WriteLnToConsole(inttostr(ord(Ammoz[CurrentHedgehog^.CurAmmoType].NameId)) + ' ' + inttostr(ord(sidSwitch))); + end; + +if targetting then + AddCaption('Press the target button to mark the target', cWhiteColor, capgrpAmmoInfo); + +deleteFinger(pointerId); +{$ENDIF} +end; + +procedure onTouchDoubleClick(finger: TTouch_Data); +begin +finger := finger;//avoid compiler hint +end; + +procedure onTouchLongClick(finger: TTouch_Data); +begin +{$IFDEF USE_TOUCH_INTERFACE} +if isOnWidget(jumpWidget, finger) then + begin + ParseTeamCommand('ljump'); + exit; end; - if isOnCurrentHog(finger) then - begin - bShowAmmoMenu := true; - exit; +{$ENDIF} +end; + +procedure onTouchClick(finger: TTouch_Data); +begin +//if (RealTicks - timeSinceClick < 300) and (sqrt(sqr(finger.X-xTouchClick) + sqr(finger.Y-yTouchClick)) < 30) then +// begin +// onTouchDoubleClick(finger); +// timeSinceClick:= 0;//we make an assumption there won't be an 'click' in the first 300 ticks(milliseconds) +// exit; +// end; + +xTouchClick:= finger.x; +yTouchClick:= finger.y; +timeSinceClick:= RealTicks; + +if bShowAmmoMenu then + begin + if isOnRect(AmmoRect, finger) then + begin + CursorPoint.X:= finger.x; + CursorPoint.Y:= finger.y; + ParseTeamCommand('put'); + end + else + bShowAmmoMenu:= false; + exit; end; - if finger.y < topButtonBoundary then +{$IFDEF USE_TOUCH_INTERFACE} +if isOnCurrentHog(finger) or isOnWidget(AMWidget, finger) then begin - ParseCommand('hjump', true); - exit; + bShowAmmoMenu := true; + exit; end; + +if isOnWidget(jumpWidget, finger) then + begin + ParseTeamCommand('hjump'); + exit; + end; +{$ENDIF} end; -function addFinger(x,y: Longword; id: SDL_FingerId): PTouch_Finger; +function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data; var xCursor, yCursor, index : LongInt; begin @@ -273,12 +353,13 @@ if length(fingers) < Integer(pointerCount) then begin setLength(fingers, length(fingers)*2); - for index := length(fingers) div 2 to length(fingers) do fingers[index].id := nilFingerId; + for index := length(fingers) div 2 to length(fingers) do + fingers[index].id := nilFingerId; end; - xCursor := convertToCursor(cScreenWidth, x); - yCursor := convertToCursor(cScreenHeight, y); + xCursor := convertToCursorX(x); + yCursor := convertToCursorY(y); //on removing fingers, all fingers are moved to the left //with dynamic arrays being zero based, the new position of the finger is the old pointerCount @@ -287,13 +368,26 @@ fingers[pointerCount].historicalY := yCursor; fingers[pointerCount].x := xCursor; fingers[pointerCount].y := yCursor; - fingers[pointerCount].timeSinceDown:= SDL_GetTicks; + fingers[pointerCount].dx := 0; + fingers[pointerCount].dy := 0; + fingers[pointerCount].timeSinceDown:= RealTicks; + fingers[pointerCount].pressedWidget:= nil; addFinger:= @fingers[pointerCount]; inc(pointerCount); end; -procedure deleteFinger(id: SDL_FingerId); +function updateFinger(x,y,dx,dy: Longword; id: TSDL_FingerId): PTouch_Data; +begin + updateFinger:= findFinger(id); + + updateFinger^.x:= convertToCursorX(x); + updateFinger^.y:= convertToCursorY(y); + updateFinger^.dx:= convertToCursorDeltaX(dx); + updateFinger^.dy:= convertToCursorDeltaY(dy); +end; + +procedure deleteFinger(id: TSDL_FingerId); var index : Longword; begin @@ -301,16 +395,13 @@ dec(pointerCount); for index := 0 to pointerCount do begin - if fingers[index].id = id then - begin - //Check for onTouchClick event - if ((SDL_GetTicks - fingers[index].timeSinceDown) < clickTime) AND - not(fingerHasMoved(fingers[index])) then onTouchClick(fingers[index]); - - //put the last finger into the spot of the finger to be removed, - //so that all fingers are packed to the far left - if pointerCount <> index then - begin + if fingers[index].id = id then + begin + + //put the last finger into the spot of the finger to be removed, + //so that all fingers are packed to the far left + if pointerCount <> index then + begin fingers[index].id := fingers[pointerCount].id; fingers[index].x := fingers[pointerCount].x; fingers[index].y := fingers[pointerCount].y; @@ -319,170 +410,221 @@ fingers[index].timeSinceDown := fingers[pointerCount].timeSinceDown; fingers[pointerCount].id := nilFingerId; - end - else fingers[index].id := nilFingerId; - break; - end; + end + else fingers[index].id := nilFingerId; + break; + end; end; end; +procedure NewTurnBeginning; +begin +targetted:= false; +targetting:= false; +SetUtilityWidgetState(amNothing); +end; + + procedure ProcessTouch; var deltaAngle: LongInt; begin - invertCursor := not(bShowAmmoMenu); - if aiming then - begin - if CurrentHedgehog^.Gear <> nil then +invertCursor := not(bShowAmmoMenu or targetting); +if aimingCrosshair then + if CurrentHedgehog^.Gear <> nil then begin - deltaAngle:= CurrentHedgehog^.Gear^.Angle - targetAngle; - if (deltaAngle <> 0) and not(movingCrosshair) then + deltaAngle:= CurrentHedgehog^.Gear^.Angle - targetAngle; + if (deltaAngle > -5) and (deltaAngle < 5) then + begin + if(aimingUp)then + begin + aimingUp:= false; + ParseTeamCommand('-up'); + end; + if(aimingDown)then + begin + aimingDown:= false; + ParseTeamCommand('-down'); + end + end + else begin - ParseCommand('+' + crosshairCommand, true); - movingCrosshair := true; - end - else - if movingCrosshair then + if (deltaAngle < 0) then + begin + if aimingUp then + begin + aimingUp:= false; + ParseTeamCommand('-up'); + end; + if(aimingDown)then + begin + aimingDown:= true; + ParseTeamCommand('-down'); + end + end + else begin - ParseCommand('-' + crosshairCommand, true); - movingCrosshair:= false; - end; + if aimingDown then + begin + ParseTeamCommand('-down'); + aimingDown:= false; + end; + if aimingUp then + begin + aimingUp:= true; + ParseTeamCommand('+up'); + end; + end; + end; + end + else + begin + if aimingUp then + begin + ParseTeamCommand('-up'); + aimingUp:= false; + end; + if aimingDown then + begin + ParseTeamCommand('-down'); + aimingDown:= false; + end; end; - end - else if movingCrosshair then - begin - ParseCommand('-' + crosshairCommand, true); - movingCrosshair := false; - end; - - if stopFiring then - begin - ParseCommand('-attack', true); - stopFiring:= false; - end; - - if stopRight then - begin - stopRight := false; - ParseCommand('-right', true); - end; - - if stopLeft then - begin - stopLeft := false; - ParseCommand('-left', true); - end; - end; -function findFinger(id: SDL_FingerId): PTouch_Finger; +function findFinger(id: TSDL_FingerId): PTouch_Data; var index: LongWord; begin - for index := 0 to High(fingers) do - if fingers[index].id = id then - begin - findFinger := @fingers[index]; - break; - end; + for index := 0 to High(fingers) do + if fingers[index].id = id then + begin + findFinger := @fingers[index]; + break; + end; end; -procedure aim(finger: Touch_Finger); +procedure aim(finger: TTouch_Data); var - hogX, hogY, touchX, touchY, deltaX, deltaY, tmpAngle: hwFloat; - tmp: ShortString; + hogX, hogY, touchX, touchY, deltaX, deltaY: LongInt; begin if CurrentHedgehog^.Gear <> nil then - begin - touchX := _0;//avoid compiler hint - touchY := _0; - hogX := CurrentHedgehog^.Gear^.X; - hogY := CurrentHedgehog^.Gear^.Y; + begin + touchX := 0;//avoid compiler hint + touchY := 0; + hogX := hwRound(CurrentHedgehog^.Gear^.X); + hogY := hwRound(CurrentHedgehog^.Gear^.Y); convertToWorldCoord(touchX, touchY, finger); - deltaX := hwAbs(TouchX-HogX); - deltaY := (TouchY-HogY); + deltaX := abs(TouchX-HogX); + deltaY := TouchY-HogY; - tmpAngle:= DeltaY / Distance(deltaX, deltaY) *_2048; - targetAngle:= (hwRound(tmpAngle) + 2048) div 2; + targetAngle:= (Round(DeltaY / sqrt(sqr(deltaX) + sqr(deltaY)) * 2048) + 2048) div 2; + end; //if CurrentHedgehog^.Gear <> nil +end; - tmp := crosshairCommand; - if CurrentHedgehog^.Gear^.Angle - targetAngle < 0 then crosshairCommand := 'down' - else crosshairCommand:= 'up'; - if movingCrosshair and (tmp <> crosshairCommand) then - begin - ParseCommand('-' + tmp, true); - movingCrosshair := false; - end; +// These 4 convertToCursor functions convert xy coords from the SDL coordinate system to our CursorPoint coor system: +// - the SDL coordinate system goes from 0 to 32768 on the x axis and 0 to 32768 on the y axis, (0,0) being top left; +// - the CursorPoint coordinate system goes from -cScreenWidth/2 to cScreenWidth/2 on the x axis +// and 0 to cScreenHeight on the x axis, (-cScreenWidth, cScreenHeight) being top left. +function convertToCursorX(x: LongInt): LongInt; +begin + convertToCursorX := round((x/32768)*cScreenWidth) - (cScreenWidth shr 1); +end; - end; //if CurrentHedgehog^.Gear <> nil +function convertToCursorY(y: LongInt): LongInt; +begin + convertToCursorY := cScreenHeight - round((y/32768)*cScreenHeight) end; -function convertToCursor(scale: LongInt; xy: LongInt): LongInt; +function convertToCursorDeltaX(x: LongInt): LongInt; begin - convertToCursor := round(xy/32768*scale) + convertToCursorDeltaX := round(x/32768*cScreenWidth) +end; + +function convertToCursorDeltaY(y: LongInt): LongInt; +begin + convertToCursorDeltaY := round(y/32768*cScreenHeight) end; -function isOnFireButton(finger: Touch_Finger): boolean; -begin - isOnFireButton:= (finger.x <= fireButtonRight) and (finger.x >= fireButtonLeft) and (finger.y <= fireButtonBottom) and (finger.y >= fireButtonTop); -end; - -function isOnCrosshair(finger: Touch_Finger): boolean; +function isOnCrosshair(finger: TTouch_Data): boolean; var - x,y : hwFloat; + x,y : LongInt; begin - x := _0;//avoid compiler hint - y := _0; - convertToFingerCoord(x, y, int2hwFloat(CrosshairX), int2hwFloat(CrosshairY)); - isOnCrosshair:= Distance(int2hwFloat(finger.x)-x, int2hwFloat(finger.y)-y) < _50; + x := 0;//avoid compiler hint + y := 0; + convertToFingerCoord(x, y, CrosshairX, CrosshairY); + isOnCrosshair:= isOnRect((x-HalfRectSize), (y-HalfRectSize), RectSize, RectSize, finger); + printFinger(finger); + WriteLnToConsole(inttostr(finger.x) + ' ' + inttostr(x)); + WriteLnToConsole(inttostr(x) + ' ' + inttostr(y) + ' ' + inttostr(round(uMobile.getScreenDPI * 10))); end; -function isOnCurrentHog(finger: Touch_Finger): boolean; +function isOnCurrentHog(finger: TTouch_Data): boolean; var - x,y : hwFloat; + x,y : LongInt; begin - x := _0; - y := _0; - convertToFingerCoord(x, y, CurrentHedgehog^.Gear^.X, CurrentHedgehog^.Gear^.Y); - isOnCurrentHog := Distance(int2hwFloat(finger.X)-x, int2hwFloat(finger.Y)-y) < _50; + x := 0; + y := 0; + convertToFingerCoord(x,y, hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y)); + isOnCurrentHog:= isOnRect((x-HalfRectSize), (y-HalfRectSize), RectSize, RectSize, finger); end; -procedure convertToFingerCoord(var x,y : hwFloat; oldX, oldY: hwFloat); +procedure convertToFingerCoord(var x,y : LongInt; oldX, oldY: LongInt); begin - x := oldX + int2hwFloat(WorldDx + (cScreenWidth div 2)); - y := oldY + int2hwFloat(WorldDy); + x := oldX + WorldDx; + y := cScreenHeight - (oldY + WorldDy); end; -procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger); +procedure convertToWorldCoord(var x,y: LongInt; finger: TTouch_Data); begin //if x <> nil then - x := int2hwFloat((finger.x-WorldDx) - (cScreenWidth div 2)); + x := finger.x-WorldDx; //if y <> nil then - y := int2hwFloat(finger.y-WorldDy); + y := (cScreenHeight - finger.y)-WorldDy; end; //Method to calculate the distance this finger has moved since the downEvent -function fingerHasMoved(finger: Touch_Finger): boolean; +function fingerHasMoved(finger: TTouch_Data): boolean; begin - fingerHasMoved := trunc(sqrt(Power(finger.X-finger.historicalX,2) + Power(finger.y-finger.historicalY, 2))) > 330; + fingerHasMoved := trunc(sqrt(sqr(finger.X-finger.historicalX) + sqr(finger.y-finger.historicalY))) > 30; end; -function calculateDelta(finger1, finger2: Touch_Finger): hwFloat; inline; +function calculateDelta(finger1, finger2: TTouch_Data): LongInt; inline; begin - calculateDelta := DistanceI(finger2.x-finger1.x, finger2.y-finger1.y); + calculateDelta := Round(sqrt(sqr(finger2.x-finger1.x) + sqr(finger2.y-finger1.y))); +end; + +// Under the premise that all pointer ids in pointerIds:TSDL_FingerId are packed to the far left. +// If the pointer to be ignored is not pointerIds[0] the second must be there +function getSecondFinger(finger: TTouch_Data): PTouch_Data; +begin + if fingers[0].id = finger.id then + getSecondFinger := @fingers[1] + else + getSecondFinger := @fingers[0]; end; -// Under the premise that all pointer ids in pointerIds:SDL_FingerId are packed to the far left. -// If the pointer to be ignored is not pointerIds[0] the second must be there -function getSecondFinger(finger: Touch_Finger): PTouch_Finger; +function isOnRect(rect: TSDL_Rect; finger: TTouch_Data): boolean; begin - if fingers[0].id = finger.id then getSecondFinger := @fingers[1] - else getSecondFinger := @fingers[0]; + isOnRect:= isOnRect(rect.x, rect.y, rect.w, rect.h, finger); end; -procedure printFinger(finger: Touch_Finger); +function isOnRect(x,y,w,h: LongInt; finger: TTouch_Data): boolean; +begin + isOnRect:= (finger.x > x) and + (finger.x < x + w) and + (cScreenHeight - finger.y > y) and + (cScreenHeight - finger.y < y + h); +end; + +function isOnWidget(widget: TOnScreenWidget; finger: TTouch_Data): boolean; +begin + isOnWidget:= widget.show and isOnRect(widget.active, finger); +end; + +procedure printFinger(finger: TTouch_Data); begin WriteToConsole(Format('id:%d, (%d,%d), (%d,%d), time: %d', [finger.id, finger.x, finger.y, finger.historicalX, finger.historicalY, finger.timeSinceDown])); end; @@ -492,25 +634,18 @@ index: Longword; //uRenderCoordScaleX, uRenderCoordScaleY: Longword; begin - movingCrosshair := false; - stopFiring:= false; - walkingLeft := false; - walkingRight := false; + buttonsDown:= 0; - leftButtonBoundary := cScreenWidth div 4; - rightButtonBoundary := cScreenWidth div 4*3; - topButtonBoundary := cScreenHeight div 6; - setLength(fingers, 4); for index := 0 to High(fingers) do fingers[index].id := nilFingerId; + rectSize:= round(baseRectSize * uMobile.getScreenDPI); + halfRectSize:= rectSize shl 1; +end; - //uRenderCoordScaleX := Round(cScreenWidth/0.8 * 2); - fireButtonLeft := Round(cScreenWidth*0.01); - fireButtonRight := Round(fireButtonLeft + (spritesData[sprFireButton].Width*0.4)); - fireButtonBottom := Round(cScreenHeight*0.99); - fireButtonTop := fireButtonBottom - Round(spritesData[sprFireButton].Height*0.4); +procedure freeModule; +begin end; begin diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uTypes.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,7 +39,7 @@ TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit, gsSuspend); // Game types that help determining what the engine is actually supposed to do - TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax); + TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax, gmtRecord); // Different files are stored in different folders, this enumeration is used to tell which folder to use TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps, @@ -51,20 +51,23 @@ sprLag, sprArrow, sprBazookaShell, sprTargetP, sprBee, sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff, sprMineOn, sprMineDead, sprCase, sprFAid, sprDynamite, sprPower, - sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont, - sprHorizontL, sprHorizontR, sprSky, sprSkyL, - sprSkyR, sprAMBorderHorizontal, sprAMBorderVertical, sprAMSlot, sprAMAmmos, - sprAMSlotKeys, sprAMCorners, sprFinger, sprAirBomb, - sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask, - sprSwitch, sprParachute, sprTarget, sprRopeNode, + sprClusterBomb, sprClusterParticle, sprFlame, + sprHorizont, sprHorizontL, sprHorizontR, sprSky, sprSkyL, sprSkyR, + sprAMSlot, sprAMAmmos, sprAMAmmosBW, sprAMSlotKeys, sprAMCorners, + sprFinger, sprAirBomb, sprAirplane, sprAmAirplane, sprAmGirder, + sprHHTelepMask, sprSwitch, sprParachute, sprTarget, sprRopeNode, sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR, +{$IFDEF USE_TOUCH_INTERFACE} + sprFireButton, sprArrowUp, sprArrowDown, sprArrowLeft, sprArrowRight, + sprJumpWidget, sprAMWidget, sprPauseButton, sprTimerButton, sprTargetButton, +{$ENDIF} sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun, sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer, sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath, sprShotgun, sprDEagle, sprHHIdle, sprMortar, sprTurnsLeft, sprKamikaze, sprWhip, sprKowtow, sprSad, sprWave, sprHurrah, sprLemonade, sprShrug, sprJuggle, sprExplPart, sprExplPart2, - sprCakeWalk, sprCakeDown, sprAMAmmosBW, sprWatermelon, + sprCakeWalk, sprCakeDown, sprWatermelon, sprEvilTrace, sprHellishBomb, sprSeduction, sprDress, sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls, sprPlane, sprHandPlane, sprUtility, sprInvulnerable, sprVampiric, sprGirder, @@ -83,22 +86,24 @@ sprHandResurrector, sprCross, sprAirDrill, sprNapalmBomb, sprBulletHit, sprSnowball, sprHandSnowball, sprSnow, sprSDFlake, sprSDWater, sprSDCloud, sprSDSplash, sprSDDroplet, sprTardis, - sprFireButton + sprSlider, sprBotlevels, sprHandKnife, sprKnife, sprStar ); // Gears that interact with other Gears and/or Land - TGearType = (gtGrenade, gtHedgehog, gtShell, gtGrave, gtBee, // 4 - gtShotgunShot, gtPickHammer, gtRope, gtMine, gtCase, // 9 - gtDEagleShot, gtDynamite, gtClusterBomb, gtCluster, gtShover, // 14 - gtFlame, gtFirePunch, gtATStartGame, // 17 - gtATFinishGame, gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, // 22 - gtGirder, gtTeleport, gtSwitcher, gtTarget, gtMortar, // 27 - gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 33 - gtHellishBomb, gtWaterUp, gtDrill, gtBallGun, gtBall, gtRCPlane, // 39 - gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives, gtBirdy, // 44 + TGearType = ({-->}gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives, // <-- these are gears which should be avoided when searching a spawn place + gtGrenade, gtShell, gtGrave, gtBee, // 8 + gtShotgunShot, gtPickHammer, gtRope, // 11 + gtDEagleShot, gtDynamite, gtClusterBomb, gtCluster, gtShover, // 16 + gtFirePunch, gtATStartGame, // 18 + gtATFinishGame, gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, // 23 + gtGirder, gtTeleport, gtSwitcher, gtTarget, gtMortar, // 28 + gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 34 + gtHellishBomb, gtWaterUp, gtDrill, gtBallGun, gtBall, gtRCPlane, // 40 + gtSniperRifleShot, gtJetpack, gtMolotov, gtBirdy, // 44 gtEgg, gtPortal, gtPiano, gtGasBomb, gtSineGunShot, gtFlamethrower, // 50 gtSMine, gtPoisonCloud, gtHammer, gtHammerHit, gtResurrector, // 55 - gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun, gtTardis); // 61 + gtNapalmBomb, gtSnowball, gtFlake, gtStructure, gtLandGun, gtTardis, // 61 + gtIceGun, gtAddAmmo, gtGenericFaller, gtKnife); // 65 // Gears that are _only_ of visual nature (e.g. background stuff, visual effects, speechbubbles, etc.) TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire, @@ -109,8 +114,6 @@ vgtBigExplosion, vgtChunk, vgtNote, vgtLineTrail, vgtBulletHit, vgtCircle, vgtSmoothWindBar, vgtStraightShot); - TGearsType = set of TGearType; - // Damage can be caused by different sources TDamageSource = (dsUnknown, dsFall, dsBullet, dsExplosion, dsShove, dsPoison); @@ -148,7 +151,7 @@ amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, // 35 amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov, amBirdy, amPortalGun, // 42 amPiano, amGasBomb, amSineGun, amFlamethrower, amSMine, amHammer, // 48 - amResurrector, amDrillStrike, amSnowball, amTardis, amStructure, amLandGun); // 54 + amResurrector, amDrillStrike, amSnowball, amTardis, amStructure, amLandGun, amIceGun, amKnife); // 54 // Different kind of crates that e.g. hedgehogs can pick up TCrateType = (HealthCrate, AmmoCrate, UtilityCrate); @@ -172,7 +175,7 @@ Handle: PTTF_Font; Height: LongInt; style: LongInt; - Name: string[21]; + Name: string[31]; end; PAmmo = ^TAmmo; @@ -190,12 +193,12 @@ end; TVertex2f = record - X, Y: GLfloat; - end; + X, Y: GLfloat; + end; TVertex2i = record - X, Y: GLint; - end; + X, Y: GLint; + end; PTexture = ^TTexture; TTexture = record @@ -207,7 +210,7 @@ PrevTexture, NextTexture: PTexture; end; - THogEffect = (heInvulnerable, heResurrectable, hePoisoned, heResurrected); + THogEffect = (heInvulnerable, heResurrectable, hePoisoned, heResurrected, heFrozen); TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite); @@ -247,7 +250,8 @@ Tag: LongInt; Tex: PTexture; Z: Longword; - IntersectGear: PGear; + CollisionMask: Word; + LinkedGear: PGear; FlightTime: Longword; uid: Longword; ImpactSound: TSound; // first sound, others have to be after it in the sounds def. @@ -255,8 +259,12 @@ SoundChannel: LongInt; PortalCounter: LongWord; // Hopefully temporary, but avoids infinite portal loops in a guaranteed fashion. LastDamage: PHedgehog; + end; + TPGearArray = array of PGear; + PGearArrayS = record + size: LongWord; + ar: ^TPGearArray; end; - TPGearArray = Array of PGear; PVisualGear = ^TVisualGear; TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword); @@ -306,7 +314,7 @@ TeamDamage : Longword; end; - TBinds = array[0..cKeyMaxIndex] of shortstring; + TBinds = array[0..cKbdMaxIndex] of shortstring; TKeyboardState = array[0..cKeyMaxIndex] of Byte; PVoicepack = ^TVoicepack; @@ -320,11 +328,11 @@ voicepack: PVoicePack; end; + THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; PHHAmmo = ^THHAmmo; - THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; THedgehog = record - Name: string[MAXNAMELEN]; + Name: shortstring; Gear: PGear; GearHidden: PGear; SpeechGear: PVisualGear; @@ -333,6 +341,8 @@ HatTex: PTexture; Ammo: PHHAmmo; CurAmmoType: TAmmoType; + PickUpType: LongWord; + PickUpDelay: LongInt; AmmoStore: Longword; Team: PTeam; MultiShootAttacks: Longword; @@ -345,12 +355,12 @@ King: boolean; // Flag for a bunch of hedgehog attributes Unplaced: boolean; // Flag for hog placing mode Timer: Longword; - Effects: Array[THogEffect] of boolean; + Effects: array[THogEffect] of LongInt; end; TTeam = record Clan: PClan; - TeamName: string[MAXNAMELEN]; + TeamName: shortstring; ExtDriven: boolean; Binds: TBinds; Hedgehogs: array[0..cMaxHHIndex] of THedgehog; @@ -397,29 +407,62 @@ sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane, sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack, - sidMolotov, sidBirdy, sidPortalGun, sidPiano, sidGasBomb, sidSineGun, sidFlamethrower, - sidSMine, sidHammer, sidResurrector, sidDrillStrike, sidSnowball, sidNothing, sidTardis, sidStructure, sidLandGun); + sidMolotov, sidBirdy, sidPortalGun, sidPiano, sidGasBomb, + sidSineGun, sidFlamethrower,sidSMine, sidHammer, sidResurrector, + sidDrillStrike, sidSnowball, sidNothing, sidTardis, + sidStructure, sidLandGun, sidIceGun, sidKnife); TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady, - sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce); + sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce, + sidMute); // Events that are important for the course of the game or at least interesting for other reasons TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw, - eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf, - eidHomerun, eidGone); + eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, + eidHurtSelf, eidHomerun, eidGone); TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable, gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery, - gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer, - gidDamageModifier, gidResetHealth, gidAISurvival, gidInfAttack, gidResetWeps, gidPerHogAmmo, gidTagTeam); + gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, + gidRandomMineTimer, gidDamageModifier, gidResetHealth, gidAISurvival, + gidInfAttack, gidResetWeps, gidPerHogAmmo, gidTagTeam); TLandArray = packed array of array of LongWord; TCollisionArray = packed array of array of Word; TPreview = packed array[0..127, 0..31] of byte; TDirtyTag = packed array of array of byte; + PWidgetMovement = ^TWidgetMovement; + TWidgetMovement = record + animate : Boolean; + source : TPoint; + target : TPoint; + startTime : Longword; + end; + + POnScreenWidget = ^TOnScreenWidget; + TOnScreenWidget = record + show : boolean; // if false widget will not be drawn + sprite : TSprite; // a convenience type + frame : TSDL_Rect; // graphical coordinates + active : TSDL_Rect; // active touch region + fadeAnimStart : Longword; // time the fade started, 0 means don't fade + moveAnim : TWidgetMovement; // the animation associated to the widget + end; + +{$IFDEF SDL13} + PTouch_Data = ^TTouch_Data; + TTouch_Data = record + id : TSDL_FingerId; + x,y : LongInt; + dx,dy : LongInt; + historicalX, historicalY : LongInt; + timeSinceDown : Longword; + pressedWidget : POnScreenWidget; + end; +{$ENDIF} implementation diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uUtils.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,25 +24,29 @@ uses uTypes, uFloat, GLunit; procedure SplitBySpace(var a, b: shortstring); +procedure SplitByChar(var a, b: shortstring; c: char); procedure SplitByChar(var a, b: ansistring; c: char); +{$IFNDEF PAS2C} function EnumToStr(const en : TGearType) : shortstring; overload; function EnumToStr(const en : TVisualGearType) : shortstring; overload; function EnumToStr(const en : TSound) : shortstring; overload; function EnumToStr(const en : TAmmoType) : shortstring; overload; function EnumToStr(const en : THogEffect) : shortstring; overload; function EnumToStr(const en : TCapGroup) : shortstring; overload; +{$ENDIF} function Min(a, b: LongInt): LongInt; inline; function Max(a, b: LongInt): LongInt; inline; function IntToStr(n: LongInt): shortstring; +function StrToInt(s: shortstring): LongInt; function FloatToStr(n: hwFloat): shortstring; -function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; +function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline; function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt; function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt; -function DxDy2AttackAngle(const _dY, _dX: extended): LongInt; +function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; procedure SetLittle(var r: hwFloat); @@ -57,35 +61,53 @@ function CheckCJKFont(s: ansistring; font: THWFont): THWFont; procedure AddFileLog(s: shortstring); +procedure AddFileLogRaw(s: pchar); cdecl; function CheckNoTeamOrHH: boolean; inline; function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; -procedure initModule; +{$IFNDEF PAS2C} +procedure Write(var f: textfile; s: shortstring); +procedure WriteLn(var f: textfile; s: shortstring); +{$ENDIF} + +procedure initModule(isGame: boolean); procedure freeModule; implementation -uses typinfo, Math, uConsts, uVariables, SysUtils; +uses {$IFNDEF PAS2C}typinfo, {$ENDIF}Math, uConsts, uVariables, SysUtils; {$IFDEF DEBUGFILE} var f: textfile; +{$IFDEF USE_VIDEO_RECORDING} + logMutex: TRTLCriticalSection; // mutex for debug file {$ENDIF} +{$ENDIF} +var CharArray: array[byte] of Char; + +procedure SplitBySpace(var a,b: shortstring); +begin +SplitByChar(a,b,' '); +end; // should this include "strtolower()" for the split string? -procedure SplitBySpace(var a, b: shortstring); +procedure SplitByChar(var a, b: shortstring; c : char); var i, t: LongInt; begin -i:= Pos(' ', a); +i:= Pos(c, a); if i > 0 then begin for t:= 1 to Pred(i) do - if (a[t] >= 'A')and(a[t] <= 'Z') then Inc(a[t], 32); + if (a[t] >= 'A')and(a[t] <= 'Z') then + Inc(a[t], 32); b:= copy(a, i + 1, Length(a) - i); - byte(a[0]):= Pred(i) - end else b:= ''; + a[0]:= char(Pred(i)) + end +else + b:= ''; end; procedure SplitByChar(var a, b: ansistring; c: char); @@ -99,6 +121,7 @@ end else b:= ''; end; +{$IFNDEF PAS2C} function EnumToStr(const en : TGearType) : shortstring; overload; begin EnumToStr:= GetEnumName(TypeInfo(TGearType), ord(en)) @@ -127,16 +150,22 @@ begin EnumToStr := GetEnumName(TypeInfo(TCapGroup), ord(en)) end; - +{$ENDIF} function Min(a, b: LongInt): LongInt; begin -if a < b then Min:= a else Min:= b +if a < b then + Min:= a +else + Min:= b end; function Max(a, b: LongInt): LongInt; begin -if a > b then Max:= a else Max:= b +if a > b then + Max:= a +else + Max:= b end; @@ -145,19 +174,23 @@ str(n, IntToStr) end; +function StrToInt(s: shortstring): LongInt; +var c: LongInt; +begin +val(s, StrToInt, c) +end; + function FloatToStr(n: hwFloat): shortstring; begin FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue)) end; -function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; +function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat; inline; var dY, dX: Extended; begin -dY:= _dY.QWordValue / $100000000; -if _dY.isNegative then dY:= - dY; -dX:= _dX.QWordValue / $100000000; -if _dX.isNegative then dX:= - dX; +dY:= hwFloat2Float(_dY); +dX:= hwFloat2Float(_dX); DxDy2Angle:= arctan2(dY, dX) * 180 / pi end; @@ -165,10 +198,8 @@ const _16divPI: Extended = 16/pi; var dY, dX: Extended; begin -dY:= _dY.QWordValue / $100000000; -if _dY.isNegative then dY:= - dY; -dX:= _dX.QWordValue / $100000000; -if _dX.isNegative then dX:= - dX; +dY:= hwFloat2Float(_dY); +dX:= hwFloat2Float(_dX); DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f end; @@ -176,16 +207,14 @@ const MaxAngleDivPI: Extended = cMaxAngle/pi; var dY, dX: Extended; begin -dY:= _dY.QWordValue / $100000000; -if _dY.isNegative then dY:= - dY; -dX:= _dX.QWordValue / $100000000; -if _dX.isNegative then dX:= - dX; +dY:= hwFloat2Float(_dY); +dX:= hwFloat2Float(_dX); DxDy2AttackAngle:= trunc(arctan2(dY, dX) * MaxAngleDivPI) end; -function DxDy2AttackAngle(const _dY, _dX: extended): LongInt; inline; +function DxDy2AttackAnglef(const _dY, _dX: extended): LongInt; inline; begin -DxDy2AttackAngle:= trunc(arctan2(_dY, _dX) * (cMaxAngle/pi)) +DxDy2AttackAnglef:= trunc(arctan2(_dY, _dX) * (cMaxAngle/pi)) end; @@ -215,8 +244,12 @@ for i:= 1 to Length(s) do begin t:= Pos(s[i], table); - if s[i] = '=' then inc(c); - if t > 0 then byte(s[i]):= t - 1 else byte(s[i]):= 0 + if s[i] = '=' then + inc(c); + if t > 0 then + s[i]:= char(t - 1) + else + s[i]:= #0 end; i:= 1; @@ -230,14 +263,14 @@ inc(i, 4) end; -if c < 3 then t:= t - c; +if c < 3 then + t:= t - c; -byte(DecodeBase64[0]):= t - 1 +DecodeBase64[0]:= char(t - 1) end; function Str2PChar(const s: shortstring): PChar; -const CharArray: array[byte] of Char = ''; begin CharArray:= s; CharArray[Length(s)]:= #0; @@ -262,23 +295,44 @@ begin s:= s; {$IFDEF DEBUGFILE} -writeln(f, GameTicks: 6, ': ', s); -flush(f) +{$IFDEF USE_VIDEO_RECORDING} +EnterCriticalSection(logMutex); +{$ENDIF} +writeln(f, inttostr(GameTicks) + ': ' + s); +flush(f); +{$IFDEF USE_VIDEO_RECORDING} +LeaveCriticalSection(logMutex); +{$ENDIF} {$ENDIF} end; +procedure AddFileLogRaw(s: pchar); cdecl; +begin +s:= s; +{$IFDEF DEBUGFILE} +{$IFDEF USE_VIDEO_RECORDING} +EnterCriticalSection(logMutex); +{$ENDIF} +write(f, s); +flush(f); +{$IFDEF USE_VIDEO_RECORDING} +LeaveCriticalSection(logMutex); +{$ENDIF} +{$ENDIF} +end; function CheckCJKFont(s: ansistring; font: THWFont): THWFont; var l, i : LongInt; u: WideChar; tmpstr: array[0..256] of WideChar; begin +CheckCJKFont:= font; {$IFNDEF MOBILE} // remove chinese fonts for now if (font >= CJKfnt16) or (length(s) = 0) then {$ENDIF} - exit(font); + exit; l:= Utf8ToUnicode(@tmpstr, Str2PChar(s), length(s))-1; i:= 0; @@ -297,10 +351,13 @@ ((#$AC00 <= u) and (u <= #$D7AF)) or // Hangul Syllables ((#$F900 <= u) and (u <= #$FAFF)) or // CJK Compatibility Ideographs ((#$FE30 <= u) and (u <= #$FE4F))) // CJK Compatibility Forms - then exit(THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) )); + then + begin + CheckCJKFont:= THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ); + exit; + end; inc(i) end; -exit(font); (* two more to check. pascal WideChar is only 16 bit though ((#$20000 <= u) and (u >= #$2A6DF)) or // CJK Unified Ideographs Extension B ((#$2F800 <= u) and (u >= #$2FA1F))) // CJK Compatibility Ideographs Supplement *) @@ -309,7 +366,7 @@ function GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt; begin - GetLaunchX:= 0 +GetLaunchX:= 0 (* if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then GetLaunchX:= sign(dir) * (8 + hwRound(AngleSin(angle) * Ammoz[at].ejectX) + hwRound(AngleCos(angle) * Ammoz[at].ejectY)) @@ -319,7 +376,7 @@ function GetLaunchY(at: TAmmoType; angle: LongInt): LongInt; begin - GetLaunchY:= 0 +GetLaunchY:= 0 (* if (Ammoz[at].ejectX <> 0) or (Ammoz[at].ejectY <> 0) then GetLaunchY:= hwRound(AngleSin(angle) * Ammoz[at].ejectY) - hwRound(AngleCos(angle) * Ammoz[at].ejectX) - 2 @@ -332,14 +389,41 @@ CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil); end; -procedure initModule; -{$IFDEF DEBUGFILE}{$IFNDEF MOBILE}var i: LongInt;{$ENDIF}{$ENDIF} +{$IFNDEF PAS2C} +procedure Write(var f: textfile; s: shortstring); +begin +system.write(f, s) +end; + +procedure WriteLn(var f: textfile; s: shortstring); +begin +system.writeln(f, s) +end; +{$ENDIF} + +procedure initModule(isGame: boolean); +{$IFDEF DEBUGFILE} +var logfileBase: shortstring; +{$IFNDEF MOBILE}var i: LongInt;{$ENDIF} +{$ENDIF} begin {$IFDEF DEBUGFILE} + if isGame then + begin + if GameType = gmtRecord then + logfileBase:= 'rec' + else + logfileBase:= 'game'; + end + else + logfileBase:= 'preview'; +{$IFDEF USE_VIDEO_RECORDING} + InitCriticalSection(logMutex); +{$ENDIF} {$I-} {$IFDEF MOBILE} - {$IFDEF IPHONEOS} Assign(f,'../Documents/hw-' + cLogfileBase + '.log'); {$ENDIF} - {$IFDEF ANDROID} Assign(f,pathPrefix + '/' + cLogfileBase + '.log'); {$ENDIF} + {$IFDEF IPHONEOS} Assign(f,'../Documents/hw-' + logfileBase + '.log'); {$ENDIF} + {$IFDEF ANDROID} Assign(f,pathPrefix + '/' + logfileBase + '.log'); {$ENDIF} Rewrite(f); {$ELSE} if (UserPathPrefix <> '') then @@ -347,12 +431,14 @@ i:= 0; while(i < 7) do begin - assign(f, UserPathPrefix + '/Logs/' + cLogfileBase + inttostr(i) + '.log'); + assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log'); rewrite(f); - if IOResult = 0 then break; + if IOResult = 0 then + break; inc(i) end; - if i = 7 then f:= stderr; // if everything fails, write to stderr + if i = 7 then + f:= stderr; // if everything fails, write to stderr end else f:= stderr; @@ -364,12 +450,15 @@ procedure freeModule; begin - recordFileName:= ''; +recordFileName:= ''; {$IFDEF DEBUGFILE} - writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft); + writeln(f, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft)); flush(f); close(f); +{$IFDEF USE_VIDEO_RECORDING} + DoneCriticalSection(logMutex); +{$ENDIF} {$ENDIF} end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uVariables.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) -{$INCLUDE options.inc} +{$INCLUDE "options.inc"} unit uVariables; interface @@ -25,54 +25,58 @@ var /////// init flags /////// - cMinScreenWidth : LongInt = 640; - cMinScreenHeight : LongInt = 480; - cScreenWidth : LongInt = 1024; - cScreenHeight : LongInt = 768; - cOrigScreenWidth : LongInt = 1024; - cOrigScreenHeight : LongInt = 768; - cNewScreenWidth : LongInt = 1024; - cNewScreenHeight : LongInt = 768; - cScreenResizeDelay : LongWord = 0; - cBits : LongInt = 32; - ipcPort : Word = 0; - cFullScreen : boolean = false; - isSoundEnabled : boolean = true; - isMusicEnabled : boolean = false; - cLocaleFName : shortstring = 'en.txt'; - cLocale : shortstring = 'en'; - cInitVolume : LongInt = 100; - cTimerInterval : LongInt = 8; - PathPrefix : shortstring = './'; - UserPathPrefix : shortstring = './'; - cShowFPS : boolean = false; - cFlattenFlakes : boolean = false; - cFlattenClouds : boolean = false; - cAltDamage : boolean = true; - cReducedQuality : LongWord = rqNone; - UserNick : shortstring = ''; - recordFileName : shortstring = ''; - cReadyDelay : Longword = 5000; - cLogfileBase : shortstring = 'debug'; - cStereoMode : TStereoMode = smNone; - cOnlyStats : boolean = False; + cMinScreenWidth : LongInt; + cMinScreenHeight : LongInt; + cScreenWidth : LongInt; + cScreenHeight : LongInt; + cOrigScreenWidth : LongInt; + cOrigScreenHeight : LongInt; + cNewScreenWidth : LongInt; + cNewScreenHeight : LongInt; + cScreenResizeDelay : LongWord; + cBits : LongInt; + ipcPort : Word; + cFullScreen : boolean; + cLocaleFName : shortstring; + cLocale : shortstring; + cTimerInterval : LongInt; + PathPrefix : shortstring; + UserPathPrefix : shortstring; + cShowFPS : boolean; + cFlattenFlakes : boolean; + cFlattenClouds : boolean; + cAltDamage : boolean; + cReducedQuality : LongWord; + UserNick : shortstring; + recordFileName : shortstring; + cReadyDelay : Longword; + cStereoMode : TStereoMode; + cOnlyStats : boolean; +{$IFDEF USE_VIDEO_RECORDING} + RecPrefix : shortstring; + cAVFormat : shortstring; + cVideoCodec : shortstring; + cVideoFramerateNum : LongInt; + cVideoFramerateDen : LongInt; + cVideoQuality : LongInt; + cAudioCodec : shortstring; +{$ENDIF} ////////////////////////// - - alsoShutdownFrontend: boolean = false; - + cMapName : shortstring; isCursorVisible : boolean; - isTerminated : boolean; isInLag : boolean; isPaused : boolean; - - isSEBackup : boolean; isInMultiShoot : boolean; isSpeed : boolean; - isFirstFrame : boolean; + SpeedStart : LongWord; fastUntilLag : boolean; + fastScrolling : boolean; autoCameraOn : boolean; + CheckSum : LongWord; + CampaignVariable: shortstring; + GameTicks : LongWord; GameState : TGameState; GameType : TGameType; InputMask : LongWord; @@ -106,18 +110,22 @@ cWaterLine : Word; cGearScrEdgesDist: LongInt; + isAudioMuted : boolean; - GameTicks : LongWord; + // originally typed consts + ExplosionBorderColor: LongWord; + WaterOpacity: byte; + SDWaterOpacity: byte; + GrayScale: Boolean; // originally from uConsts Pathz: array[TPathType] of shortstring; UserPathz: array[TPathType] of shortstring; - CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture; + CountTexz: array[0..Pred(AMMO_INFINITE)] of PTexture; LAND_WIDTH : Word; LAND_HEIGHT : Word; LAND_WIDTH_MASK : LongWord; LAND_HEIGHT_MASK : LongWord; - cMaxCaptions : LongInt; cLeftScreenBorder : LongInt; cRightScreenBorder : LongInt; @@ -136,7 +144,6 @@ bBetweenTurns : boolean; bWaterRising : boolean; - //ShowCrosshair : boolean; This variable is inconvenient to set. Easier to decide when rendering CrosshairX : LongInt; CrosshairY : LongInt; CursorMovementX : LongInt; @@ -152,7 +159,12 @@ cLaserSighting : boolean; cVampiric : boolean; cArtillery : boolean; - WeaponTooltipTex : PTexture; + WeaponTooltipTex: PTexture; + AmmoMenuTex : PTexture; + AmmoMenuInvalidated: boolean; + AmmoRect : TSDL_Rect; + HHTexture : PTexture; + flagMakeCapture : boolean; @@ -162,7 +174,6 @@ WaterColorArray : array[0..3] of HwColor4f; SDWaterColorArray : array[0..3] of HwColor4f; - SDMusic : shortstring; SDTint : LongInt; CursorPoint : TPoint; @@ -174,12 +185,6 @@ Theme : shortstring; disableLandBack : boolean; - conversionFormat: PSDL_PixelFormat; - -{$IFDEF SDL13} - SDLwindow : PSDL_Window; - SDLGLcontext : PSDL_GLContext; -{$ENDIF} WorldDx: LongInt; WorldDy: LongInt; @@ -187,19 +192,41 @@ hiTicks: Word; LuaGoals : shortstring; + hiddenHedgehogs : array [0..cMaxHHs] of PHedgehog; + hiddenHedgehogsNumber : longint; -const - cHHFileName = 'Hedgehog'; - cCHFileName = 'Crosshair'; - cThemeCFGFilename = 'theme.cfg'; + LuaTemplateNumber : LongWord; + + VoiceList : array[0..7] of TVoice = ( + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil), + ( snd: sndNone; voicepack: nil)); + LastVoice : TVoice = ( snd: sndNone; voicepack: nil ); - FontBorder = 2; +///////////////////////////////////// +//Buttons +{$IFDEF USE_TOUCH_INTERFACE} + buttonScale: GLFloat; + + arrowUp, arrowDown, arrowLeft, arrowRight : TOnScreenWidget; + firebutton, jumpWidget, AMWidget : TOnScreenWidget; + pauseButton, utilityWidget : TOnScreenWidget; +{$ENDIF} + + +var + // these consts are here because they would cause circular dependencies in uConsts/uTypes cPathz: array[TPathType] of shortstring = ( '', // ptNone '', // ptData 'Graphics', // ptGraphics 'Themes', // ptThemes - 'Themes/avematan', // ptCurrTheme + 'Themes/Bamboo', // ptCurrTheme 'Teams', // ptTeams 'Maps', // ptMaps '', // ptMapCurrent @@ -219,20 +246,6 @@ 'Graphics/Buttons' // ptButton ); - cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13); - cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0); - - VoiceList : array[0..7] of TVoice = ( - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil), - ( snd: sndNone; voicepack: nil)); - LastVoice : TVoice = ( snd: sndNone; voicepack: nil ); - Fontz: array[THWFont] of THHFont = ( (Handle: nil; Height: 12; @@ -262,8 +275,9 @@ {$ENDIF} ); +var SpritesData: array[TSprite] of record - FileName: String[16]; + FileName: string[15]; Path, AltPath: TPathType; Texture: PTexture; Surface: PSDL_Surface; @@ -330,14 +344,12 @@ Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: true; getImageDimensions: true),// sprSky (FileName: 'SkyR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: true; getImageDimensions: true),// sprSky - (FileName: 'BorderHorizontal'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 33; Height: 2; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpLow; getDimensions: false; getImageDimensions: true),// sprAMBorderHorizontal - (FileName: 'BorderVertical'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 2; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpLow; getDimensions: false; getImageDimensions: true),// sprAMBorderVertical (FileName: 'Slot'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 33; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprAMSlot + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprAMSlot (FileName: 'Ammos'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprAMAmmos + (FileName: 'Ammos_bw'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpHigh; getDimensions: false; getImageDimensions: true),// sprAMAmmosBW (FileName: 'SlotKeys'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprAMSlotKeys (FileName: 'Corners'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; @@ -372,6 +384,28 @@ Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprWindL (FileName: 'WindR'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprWindR +{$IFDEF USE_TOUCH_INTERFACE} + (FileName: 'firebutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprFireButton + (FileName: 'arrowUp'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowUp + (FileName: 'arrowDown'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowDown + (FileName: 'arrowLeft'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowLeft + (FileName: 'arrowRight'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 100; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprArrowRight + (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprAMWidget + (FileName: 'backjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprJumpWidget + (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 120; Height: 100; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprPauseButton + (FileName: 'pause'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image + Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTimerButton + (FileName: 'forwardjump'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil;//TODO correct image + Width: 120; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true), // sprTargetButton +{$ENDIF} (FileName: 'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil; Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprFlake (FileName: 'amRope'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; @@ -405,7 +439,7 @@ (FileName: 'Mortar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprMortar (FileName: 'TurnsLeft'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTurnsLeft + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTurnsLeft (FileName: 'amKamikaze'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprKamikaze (FileName: 'amWhip'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; @@ -432,8 +466,6 @@ Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprCakeWalk (FileName: 'Cake_down'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprCakeDown - (FileName: 'Ammos_bw'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true),// sprAMAmmosBW (FileName: 'Watermelon'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprWatermelon (FileName: 'EvilTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; @@ -581,13 +613,13 @@ (FileName: 'amSMine'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandSMine (FileName: 'amHammer'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 128; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprWhip + Width: 128; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), // sprHammer (FileName: 'amResurrector'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), //sprHandResurrector - (FileName: 'Cross'; Path: ptGraphics; altPath: ptNone; + (FileName: 'Cross'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 108; Height: 138; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true), @@ -623,18 +655,30 @@ Width: 80; Height: 50; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprSDSplash (FileName: 'SDDroplet'; Path: ptCurrTheme; AltPath: ptSuddenDeath; Texture: nil; Surface: nil; Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprSDDroplet - (FileName: 'Egg'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;//TODO change back 'Egg' to 'Tardis' - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: true; getImageDimensions: true),// sprTardis - (FileName: 'firebutton'; Path: ptButtons; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 450; Height: 150; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true) // sprFireButton + (FileName: 'TARDIS'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 79; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprTardis + (FileName: 'slider'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 3; Height: 17; imageWidth: 3; imageHeight: 17; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false), // sprSlider + (FileName: 'botlevels'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 22; Height: 15; imageWidth: 22; imageHeight: 15; saveSurf: true; priority: tpLow; getDimensions: false; getImageDimensions: false), // sprBotlevels + (* (FileName: 'amKnife'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandKnife*) + (FileName: 'amCleaver'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 64; imageHeight: 64; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: false),// sprHandKnife + (*(FileName: 'knife'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 29; Height: 14; imageWidth: 64; imageHeight: 64; saveSurf: true; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprKnife*) + (FileName: 'cleaver'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 64; imageHeight: 128; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false), // sprKnife + (FileName: 'star'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 12; Height: 12; imageWidth: 12; imageHeight: 12; saveSurf: false; priority: tpLow; getDimensions: false; getImageDimensions: false) // sprStar ); - +const Wavez: array [TWave] of record Sprite: TSprite; FramesCount: Longword; Interval: Longword; - cmd: String[20]; + cmd: string[31]; Voice: TSound; VoiceDelay: LongWord; end = ( @@ -648,7 +692,7 @@ ); Soundz: array[TSound] of record - FileName: String[25]; + FileName: string[31]; Path : TPathType; end = ( (FileName: ''; Path: ptNone ),// sndNone @@ -763,10 +807,10 @@ (FileName: 'parachute.ogg'; Path: ptSounds),// sndParachute (FileName: 'bump.ogg'; Path: ptSounds),// sndBump (FileName: 'hogchant3.ogg'; Path: ptSounds),// sndResurrector - (FileName: 'plane.ogg'; Path: ptSounds), // sndPlane - (FileName: 'plane.ogg'; Path: ptSounds) // sndTardis TODO change when using a new data set + (FileName: 'plane.ogg'; Path: ptSounds),// sndPlane + (FileName: 'TARDIS.ogg'; Path: ptSounds) // sndTardis ); - +var Ammoz: array [TAmmoType] of record NameId: TAmmoStrId; NameTex: PTexture; @@ -809,7 +853,11 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse or ammoprop_SetBounce; + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or + ammoprop_SetBounce or + ammoprop_NeedUpDown; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 3000; @@ -833,7 +881,11 @@ NameTex: nil; Probability: 100; NumberInCase: 3; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse or ammoprop_SetBounce; + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or + ammoprop_SetBounce or + ammoprop_NeedUpDown; Count: 5; NumPerTurn: 0; Timer: 3000; @@ -857,7 +909,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Ammo: (Propz: ammoprop_Power or + ammoprop_AltUse or + ammoprop_NeedUpDown; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 0; @@ -881,7 +935,10 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget or ammoprop_DontHold; + Ammo: (Propz: ammoprop_Power or + ammoprop_NeedTarget or + ammoprop_DontHold or + ammoprop_NeedUpDown; Count: 2; NumPerTurn: 0; Timer: 0; @@ -905,7 +962,8 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown; Count: AMMO_INFINITE; NumPerTurn: 1; Timer: 0; @@ -929,7 +987,10 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInMove or ammoprop_NoCrosshair or ammoprop_DontHold; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_AttackInMove or + ammoprop_NoCrosshair or + ammoprop_DontHold; Count: 2; NumPerTurn: 0; Timer: 0; @@ -953,7 +1014,8 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_DontHold; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 0; @@ -981,7 +1043,8 @@ ammoprop_ForwMsgs or ammoprop_AttackInMove or ammoprop_Utility or - ammoprop_AltAttack; + ammoprop_AltAttack or + ammoprop_NeedUpDown; Count: 5; NumPerTurn: 0; Timer: 0; @@ -1005,7 +1068,11 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse or ammoprop_SetBounce; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_AttackInMove or + ammoprop_DontHold or + ammoprop_AltUse or + ammoprop_SetBounce; Count: 2; NumPerTurn: 0; Timer: 0; @@ -1029,7 +1096,7 @@ NameTex: nil; Probability: 20; NumberInCase: 2; - Ammo: (Propz: 0; + Ammo: (Propz: ammoprop_NeedUpDown; Count: 3; NumPerTurn: 3; Timer: 0; @@ -1053,7 +1120,10 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_AttackInMove or + ammoprop_DontHold or + ammoprop_AltUse; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1077,7 +1147,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or ammoprop_AttackInMove; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_ForwMsgs or + ammoprop_AttackInMove; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 0; @@ -1087,7 +1159,7 @@ Bounciness: 1000); Slot: 3; TimeAfterTurn: 3000; - MinAngle: 0; + minAngle: 0; maxAngle: 0; isDamaging: true; SkipTurns: 0; @@ -1111,7 +1183,7 @@ Bounciness: 1000); Slot: 3; TimeAfterTurn: 3000; - MinAngle: 0; + minAngle: 0; maxAngle: 0; isDamaging: true; SkipTurns: 0; @@ -1125,7 +1197,8 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_DontHold; + Ammo: (Propz: ammoprop_DontHold or + ammoprop_NeedUpDown; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1155,7 +1228,8 @@ ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Utility or - ammoprop_AltAttack; + ammoprop_AltAttack or + ammoprop_NeedUpDown; Count: 2; NumPerTurn: 0; Timer: 0; @@ -1180,10 +1254,10 @@ Probability: 100; NumberInCase: 1; Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1208,10 +1282,10 @@ Probability: 200; NumberInCase: 1; Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1235,7 +1309,8 @@ NameTex: nil; Probability: 100; NumberInCase: 2; - Ammo: (Propz: ammoprop_ForwMsgs; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1368,7 +1443,10 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_AttackInMove; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_DontHold or + ammoprop_NeedUpDown or + ammoprop_AttackInMove; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1392,7 +1470,10 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NoCrosshair or ammoprop_DontHold; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_Track; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1416,7 +1497,9 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_NoCrosshair; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_DontHold or + ammoprop_NoCrosshair; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1440,7 +1523,10 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_NeedUpDown or + ammoprop_AltUse; Count: 0; NumPerTurn: 0; Timer: 3000; @@ -1464,7 +1550,9 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Ammo: (Propz: ammoprop_Power or + ammoprop_NeedUpDown or + ammoprop_AltUse; Count: 0; NumPerTurn: 0; Timer: 5000; @@ -1489,10 +1577,10 @@ Probability: 100; NumberInCase: 1; Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1516,7 +1604,9 @@ NameTex: nil; Probability: 300; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Ammo: (Propz: ammoprop_Power or + ammoprop_NeedUpDown or + ammoprop_AltUse; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 0; @@ -1540,7 +1630,9 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown or + ammoprop_DontHold; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 5001; @@ -1564,9 +1656,10 @@ NameTex: nil; Probability: 200; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs{ or - ammoprop_DontHold or - ammoprop_AltAttack}; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown{ or + ammoprop_DontHold or + ammoprop_AltAttack}; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1711,6 +1804,7 @@ ammoprop_DontHold or ammoprop_AltUse or ammoprop_Utility or + ammoprop_NeedUpDown or ammoprop_Effect; Count: 1; NumPerTurn: 0; @@ -1764,7 +1858,9 @@ NameTex: nil; Probability: 20; NumberInCase: 2; - Ammo: (Propz: 0; + Ammo: (Propz: ammoprop_NeedUpDown or + ammoprop_OscAim or + ammoprop_NoMoveAfter; Count: 2; NumPerTurn: 1; Timer: 0; @@ -1794,6 +1890,7 @@ ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Utility or + ammoprop_NeedUpDown or ammoprop_AltAttack; Count: 1; NumPerTurn: 0; @@ -1818,7 +1915,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Ammo: (Propz: ammoprop_Power or + ammoprop_NeedUpDown or + ammoprop_AltUse; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 3000; @@ -1844,6 +1943,7 @@ NumberInCase: 1; Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NoCrosshair or + ammoprop_NeedUpDown or ammoprop_DontHold; Count: 1; NumPerTurn: 0; @@ -1871,6 +1971,7 @@ Ammo: (Propz: ammoprop_NoRoundEnd or ammoprop_AttackInMove or ammoprop_DontHold or + ammoprop_NeedUpDown or ammoprop_Utility; Count: 1; NumPerTurn: 3; @@ -1923,7 +2024,11 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse or ammoprop_SetBounce; + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or + ammoprop_NeedUpDown or + ammoprop_SetBounce; Count: AMMO_INFINITE; NumPerTurn: 0; Timer: 3000; @@ -1947,7 +2052,8 @@ NameTex: nil; Probability: 20; NumberInCase: 2; - Ammo: (Propz: ammoprop_AttackInMove; + Ammo: (Propz: ammoprop_AttackInMove or + ammoprop_NeedUpDown; Count: 1; NumPerTurn: 0; Timer: 0; @@ -1971,7 +2077,9 @@ NameTex: nil; Probability: 20; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown or + ammoprop_DontHold; Count: 1; NumPerTurn: 0; Timer: 5001; @@ -1995,7 +2103,9 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power; //FIXME: enable multishoot at altuse, until then removed ammoprop_AltUse + Ammo: (Propz: ammoprop_Power or + ammoprop_AltUse or + ammoprop_NeedUpDown; Count: 1; NumPerTurn: 1; Timer: 0; @@ -2029,7 +2139,7 @@ Bounciness: 1000); Slot: 3; TimeAfterTurn: 3000; - MinAngle: 0; + minAngle: 0; maxAngle: 0; isDamaging: true; SkipTurns: 0; @@ -2196,26 +2306,78 @@ PosCount: 1; PosSprite: sprWater; ejectX: 0; //20; - ejectY: -3) + ejectY: -3), +// Freezer + (NameId: sidIceGun; + NameTex: nil; + Probability: 20; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NeedUpDown or + ammoprop_DontHold; + Count: 1; + NumPerTurn: 0; + Timer: 5001; + Pos: 0; + AmmoType: amIceGun; + AttackVoice: sndNone; + Bounciness: 1000); + Slot: 9; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater; + ejectX: 0; //20; + ejectY: -3), +// Knife + (NameId: sidKnife; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or + ammoprop_AltUse or + ammoprop_NeedUpDown; + Count: 1; + NumPerTurn: 1; + Timer: 0; + Pos: 0; + AmmoType: amKnife; + AttackVoice: sndNone; + Bounciness: 1000); + Slot: 6; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater; + ejectX: 0; + ejectY: 0) ); +const GearKindAmmoTypeMap : array [TGearType] of TAmmoType = ( -(* gtGrenade *) amGrenade +(* gtFlame *) amNothing (* gtHedgehog *) , amNothing +(* gtMine *) , amMine +(* gtCase *) , amNothing +(* gtExplosives *) , amNothing +(* gtGrenade *) , amGrenade (* gtShell *) , amBazooka (* gtGrave *) , amNothing (* gtBee *) , amBee (* gtShotgunShot *) , amShotgun (* gtPickHammer *) , amPickHammer (* gtRope *) , amRope -(* gtMine *) , amNothing -(* gtCase *) , amNothing (* gtDEagleShot *) , amDEagle (* gtDynamite *) , amDynamite (* gtClusterBomb *) , amClusterBomb (* gtCluster *) , amClusterBomb (* gtShover *) , amBaseballBat // Shover is only used for baseball bat right now -(* gtFlame *) , amNothing (* gtFirePunch *) , amFirePunch (* gtATStartGame *) , amNothing (* gtATFinishGame *) , amNothing @@ -2243,7 +2405,6 @@ (*gtSniperRifleShot *) , amSniperRifle (* gtJetpack *) , amJetpack (* gtMolotov *) , amMolotov -(* gtExplosives *) , amNothing (* gtBirdy *) , amBirdy (* gtEgg *) , amBirdy (* gtPortal *) , amPortalGun @@ -2262,6 +2423,10 @@ (* gtStructure *) , amStructure // TODO - This will undoubtedly change once there is more than one structure (* gtLandGun *) , amLandGun (* gtTardis *) , amTardis +(* gtIceGun *) , amIceGun +(* gtAddAmmo *) , amNothing +(* gtGenericFaller *) , amNothing +(* gtKnife *) , amKnife ); var @@ -2270,10 +2435,8 @@ LandDirty: TDirtyTag; hasBorder: boolean; hasGirders: boolean; - isMap: boolean; playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border. LandBackSurface: PSDL_Surface; - digest: shortstring; CurAmmoGear: PGear; lastGearByUID: PGear; GearsList: PGear; @@ -2284,7 +2447,6 @@ SuddenDeathDmg: Boolean; SpeechType: Longword; SpeechText: shortstring; - skipFlag: boolean; PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress StepSoundTimer: LongInt; StepSoundChannel: LongInt; @@ -2300,7 +2462,6 @@ LocalTeam: LongInt; // last non-bot, non-extdriven clan first team LocalAmmo: LongInt; // last non-bot, non-extdriven clan's first team's ammo index, updated to next upcoming hog for per-hog-ammo CurMinAngle, CurMaxAngle: Longword; - GameOver: boolean; NextClan: boolean; FollowGear: PGear; @@ -2321,7 +2482,6 @@ bAFRRight: Boolean; - SDLPrimSurface: PSDL_Surface; PauseTexture, SyncTexture, ConfirmTexture: PTexture; @@ -2333,12 +2493,15 @@ ProgrTex: PTexture; MissionIcons: PSDL_Surface; ropeIconTex: PTexture; - // orientation of the viewport - rotationQt: GLfloat; + // stereoscopic framebuffer and textures framel, framer, depthl, depthr: GLuint; texl, texr: GLuint; + // video recorder framebuffer and texture + defaultFrame, depthv: GLuint; + texv: GLuint; + VisualGearLayers: array[0..6] of PVisualGear; lastVisualGearByUID: PVisualGear; vobFrameTicks, vobFramesCount, vobCount: Longword; @@ -2346,10 +2509,7 @@ vobSDFrameTicks, vobSDFramesCount, vobSDCount: Longword; vobSDVelocity, vobSDFallSpeed: LongInt; - hideAmmoMenu: boolean; - wheelUp: boolean; - wheelDown: boolean; ControllerNumControllers: Integer; ControllerEnabled: Integer; @@ -2362,29 +2522,9 @@ ControllerHats: array[0..5] of array[0..19] of Byte; ControllerButtons: array[0..5] of array[0..19] of Byte; - DefaultBinds, CurrentBinds: TBinds; - - coeff: LongInt; - -{$IFDEF HWLIBRARY} - leftClick: boolean; - middleClick: boolean; - rightClick: boolean; + DefaultBinds : TBinds; - upKey: boolean; - downKey: boolean; - rightKey: boolean; - leftKey: boolean; - preciseKey: boolean; - - backspaceKey: boolean; - spaceKey: boolean; - enterKey: boolean; - tabKey: boolean; - - chatAction: boolean; - pauseAction: boolean; -{$ENDIF} + lastTurnChecksum : Longword; var trammo: array[TAmmoStrId] of ansistring; // name of the weapon trammoc: array[TAmmoStrId] of ansistring; // caption of the weapon @@ -2400,6 +2540,32 @@ procedure initModule; begin + // initialisation flags - they are going to be overwritten by args or by msgs + cScreenWidth := 1024; + cScreenHeight := 768; + cBits := 32; + ipcPort := 0; + cFullScreen := false; + cLocaleFName := 'en.txt'; + cLocale := 'en'; + cTimerInterval := 8; + PathPrefix := './'; + UserPathPrefix := './'; + cShowFPS := false; + cFlattenFlakes := false; + cFlattenClouds := false; + cAltDamage := true; + cReducedQuality := rqNone; + UserNick := ''; + recordFileName := ''; + cScriptName := ''; + cReadyDelay := 5000; + cStereoMode := smNone; + GrayScale := false; + + cFlattenFlakes := false; + cFlattenClouds := false; + cOnlyStats := False; lastVisualGearByUID:= nil; lastGearByUID:= nil; @@ -2434,9 +2600,10 @@ SDWaterColorArray[2].a := 255; SDWaterColorArray[1]:= SDWaterColorArray[0]; SDWaterColorArray[3]:= SDWaterColorArray[2]; - - SDMusic:= 'hell.ogg'; + SDWaterOpacity:= $80; SDTint:= $80; + ExplosionBorderColor:= $FF808080; + WaterOpacity:= $80; cDrownSpeed.QWordValue := 257698038; // 0.06 cDrownSpeedf := 0.06; @@ -2452,6 +2619,7 @@ CursorMovementX := 0; CursorMovementY := 0; GameTicks := 0; + CheckSum := 0; cWaterLine := LAND_HEIGHT; cGearScrEdgesDist := 240; @@ -2485,7 +2653,6 @@ cExplosives := 2; GameState := Low(TGameState); - GameType := gmtLocal; zoom := cDefaultZoomLevel; ZoomValue := cDefaultZoomLevel; WeaponTooltipTex:= nil; @@ -2496,14 +2663,13 @@ bBetweenTurns := false; bWaterRising := false; isCursorVisible := false; - isTerminated := false; isInLag := false; isPaused := false; isInMultiShoot := false; isSpeed := false; + SpeedStart := 0; fastUntilLag := false; - isFirstFrame := true; - isSEBackup := true; + fastScrolling := false; autoCameraOn := true; cScriptName := ''; cSeed := ''; @@ -2516,20 +2682,16 @@ ScreenFade := sfNone; -{$IFDEF SDL13} - SDLwindow := nil; - SDLGLcontext := nil; -{$ENDIF} - // those values still are not perfect cLeftScreenBorder:= round(-cMinZoomLevel * cScreenWidth); cRightScreenBorder:= round(cMinZoomLevel * cScreenWidth + LAND_WIDTH); cScreenSpace:= cRightScreenBorder - cLeftScreenBorder; - if isPhone() then - cMaxCaptions:= 3 - else - cMaxCaptions:= 4; + vobFrameTicks:= 99999; + vobFramesCount:= 4; + vobCount:= 0; + vobVelocity:= 10; + vobFallSpeed:= 100; vobSDFrameTicks:= 99999; vobSDFramesCount:= 4; @@ -2537,34 +2699,25 @@ vobSDVelocity:= 15; vobSDFallSpeed:= 250; + cMinScreenWidth := 640; + cMinScreenHeight := 480; + cScreenWidth := 1024; + cScreenHeight := 768; + cOrigScreenWidth := 1024; + cOrigScreenHeight := 768; + cNewScreenWidth := 1024; + cNewScreenHeight := 768; + cScreenResizeDelay := 0; + LuaGoals:= ''; + cMapName:= ''; + + LuaTemplateNumber:= 0; + hiddenHedgehogsNumber:=0; end; procedure freeModule; begin - // re-init flags so they will always contain safe values - cScreenWidth := 1024; - cScreenHeight := 768; - cBits := 32; - ipcPort := 0; - cFullScreen := false; - isSoundEnabled := true; - isMusicEnabled := false; - cLocaleFName := 'en.txt'; - cInitVolume := 100; - cTimerInterval := 8; - PathPrefix := './'; - UserPathPrefix := './'; - cShowFPS := false; - cFlattenFlakes := false; - cFlattenClouds := false; - cAltDamage := true; - cReducedQuality := rqNone; - UserNick := ''; - recordFileName := ''; - cScriptName := ''; - cReadyDelay := 5000; - cStereoMode := smNone; end; end. diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uVideoRec.pas --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/uVideoRec.pas Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,382 @@ +(* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + *) + + +{$INCLUDE "options.inc"} + +unit uVideoRec; + +{$IFNDEF USE_VIDEO_RECORDING} +interface +implementation +end. +{$ELSE} + +{$IFNDEF WIN32} + {$LINKLIB ../bin/libavwrapper.a} +{$ENDIF} +{$IFDEF DARWIN} + {$LINKLIB bz2} + {$LINKFRAMEWORK CoreVideo} + {$LINKFRAMEWORK VideoDecodeAcceleration} +{$ENDIF} + +interface + +var flagPrerecording: boolean = false; + +function BeginVideoRecording: Boolean; +function LoadNextCameraPosition(out newRealTicks, newGameTicks: LongInt): Boolean; +procedure EncodeFrame; +procedure StopVideoRecording; + +procedure BeginPreRecording; +procedure StopPreRecording; +procedure SaveCameraPosition; + +procedure initModule; +procedure freeModule; + +implementation + +uses uVariables, uUtils, GLunit, SDLh, SysUtils, uIO, uMisc, uTypes; + +type TAddFileLogRaw = procedure (s: pchar); cdecl; + +procedure AVWrapper_Init( + AddLog: TAddFileLogRaw; + filename, desc, soundFile, format, vcodec, acodec: PChar; + width, height, framerateNum, framerateDen, vquality: LongInt); cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; +procedure AVWrapper_Close; cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; +procedure AVWrapper_WriteFrame( pY, pCb, pCr: PByte ); cdecl; external {$IFDEF WIN32}'libavwrapper.dll'{$ENDIF}; + +type TFrame = record + realTicks: LongWord; + gameTicks: LongWord; + CamX, CamY: LongInt; + zoom: single; + end; + +var YCbCr_Planes: array[0..2] of PByte; + RGB_Buffer: PByte; + cameraFile: File of TFrame; + audioFile: File; + numPixels: LongWord; + startTime, numFrames, curTime, progress, maxProgress: LongWord; + soundFilePath: shortstring; + thumbnailSaved : Boolean; + +function BeginVideoRecording: Boolean; +var filename, desc: shortstring; +begin + AddFileLog('BeginVideoRecording'); + +{$IOCHECKS OFF} + // open file with prerecorded camera positions + filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtin'; + Assign(cameraFile, filename); + Reset(cameraFile); + maxProgress:= FileSize(cameraFile); + if IOResult <> 0 then + begin + AddFileLog('Error: Could not read from ' + filename); + exit(false); + end; +{$IOCHECKS ON} + + // store some description in output file + desc:= ''; + if UserNick <> '' then + desc:= desc + 'Player: ' + UserNick + #10; + if recordFileName <> '' then + desc:= desc + 'Record: ' + recordFileName + #10; + if cMapName <> '' then + desc:= desc + 'Map: ' + cMapName + #10; + if Theme <> '' then + desc:= desc + 'Theme: ' + Theme + #10; + desc:= desc + 'prefix[' + RecPrefix + ']prefix'; + + filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix; + soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; + + AVWrapper_Init(@AddFileLogRaw + , PChar(ansistring(filename)) + , PChar(ansistring(desc)) + , PChar(ansistring(soundFilePath)) + , PChar(ansistring(cAVFormat)) + , PChar(ansistring(cVideoCodec)) + , PChar(ansistring(cAudioCodec)) + , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality); + + numPixels:= cScreenWidth*cScreenHeight; + YCbCr_Planes[0]:= GetMem(numPixels); + YCbCr_Planes[1]:= GetMem(numPixels div 4); + YCbCr_Planes[2]:= GetMem(numPixels div 4); + + if (YCbCr_Planes[0] = nil) or (YCbCr_Planes[1] = nil) or (YCbCr_Planes[2] = nil) then + begin + AddFileLog('Error: Could not allocate memory for video recording (YCbCr buffer).'); + exit(false); + end; + + RGB_Buffer:= GetMem(4*numPixels); + if RGB_Buffer = nil then + begin + AddFileLog('Error: Could not allocate memory for video recording (RGB buffer).'); + exit(false); + end; + + curTime:= 0; + numFrames:= 0; + progress:= 0; + BeginVideoRecording:= true; +end; + +procedure StopVideoRecording; +begin + AddFileLog('StopVideoRecording'); + FreeMem(YCbCr_Planes[0], numPixels); + FreeMem(YCbCr_Planes[1], numPixels div 4); + FreeMem(YCbCr_Planes[2], numPixels div 4); + FreeMem(RGB_Buffer, 4*numPixels); + Close(cameraFile); + AVWrapper_Close(); + Erase(cameraFile); + DeleteFile(soundFilePath); + SendIPC(_S'v'); // inform frontend that we finished +end; + +function pixel(x, y, color: LongInt): LongInt; +begin + pixel:= RGB_Buffer[(cScreenHeight-y-1)*cScreenWidth*4 + x*4 + color]; +end; + +procedure EncodeFrame; +var x, y, r, g, b: LongInt; + s: shortstring; +begin + // read pixels from OpenGL + glReadPixels(0, 0, cScreenWidth, cScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, RGB_Buffer); + + // convert to YCbCr 4:2:0 format + // Y + for y := 0 to cScreenHeight-1 do + for x := 0 to cScreenWidth-1 do + YCbCr_Planes[0][y*cScreenWidth + x]:= Byte(16 + ((16828*pixel(x,y,0) + 33038*pixel(x,y,1) + 6416*pixel(x,y,2)) shr 16)); + + // Cb and Cr + for y := 0 to cScreenHeight div 2 - 1 do + for x := 0 to cScreenWidth div 2 - 1 do + begin + r:= pixel(2*x,2*y,0) + pixel(2*x+1,2*y,0) + pixel(2*x,2*y+1,0) + pixel(2*x+1,2*y+1,0); + g:= pixel(2*x,2*y,1) + pixel(2*x+1,2*y,1) + pixel(2*x,2*y+1,1) + pixel(2*x+1,2*y+1,1); + b:= pixel(2*x,2*y,2) + pixel(2*x+1,2*y,2) + pixel(2*x,2*y+1,2) + pixel(2*x+1,2*y+1,2); + YCbCr_Planes[1][y*(cScreenWidth div 2) + x]:= Byte(128 + ((-2428*r - 4768*g + 7196*b) shr 16)); + YCbCr_Planes[2][y*(cScreenWidth div 2) + x]:= Byte(128 + (( 7196*r - 6026*g - 1170*b) shr 16)); + end; + + AVWrapper_WriteFrame(YCbCr_Planes[0], YCbCr_Planes[1], YCbCr_Planes[2]); + + // inform frontend that we have encoded new frame + s[0]:= #3; + s[1]:= 'p'; // p for progress + SDLNet_Write16(progress*10000 div maxProgress, @s[2]); + SendIPC(s); + inc(numFrames); +end; + +function LoadNextCameraPosition(out newRealTicks, newGameTicks: LongInt): Boolean; +var frame: TFrame; +begin + // we need to skip or duplicate frames to match target framerate + while Int64(curTime)*cVideoFramerateNum <= Int64(numFrames)*cVideoFramerateDen*1000 do + begin + {$IOCHECKS OFF} + if eof(cameraFile) then + exit(false); + BlockRead(cameraFile, frame, 1); + {$IOCHECKS ON} + curTime:= frame.realTicks; + WorldDx:= frame.CamX; + WorldDy:= frame.CamY + cScreenHeight div 2; + zoom:= frame.zoom*cScreenWidth; + ZoomValue:= zoom; + inc(progress); + newRealTicks:= frame.realTicks; + newGameTicks:= frame.gameTicks; + end; + LoadNextCameraPosition:= true; +end; + +// Callback which records sound. +// This procedure may be called from different thread. +procedure RecordPostMix(udata: pointer; stream: PByte; len: LongInt); cdecl; +begin + udata:= udata; // avoid warning +{$IOCHECKS OFF} + BlockWrite(audioFile, stream^, len); +{$IOCHECKS ON} +end; + +procedure SaveThumbnail; +var thumbpath: shortstring; + k: LongInt; +begin + thumbpath:= '/VideoTemp/' + RecPrefix; + AddFileLog('Saving thumbnail ' + thumbpath); + k:= max(max(cScreenWidth, cScreenHeight) div 400, 1); // here 400 is minimum size of thumbnail + MakeScreenshot(thumbpath, k); + thumbnailSaved:= true; +end; + +// copy file (free pascal doesn't have copy file function) +procedure CopyFile(src, dest: shortstring); +var inF, outF: file; + buffer: array[0..1023] of byte; + result: LongInt; +begin +{$IOCHECKS OFF} + result:= 0; // avoid compiler hint + + Assign(inF, src); + Reset(inF, 1); + if IOResult <> 0 then + begin + AddFileLog('Error: Could not read from ' + src); + exit; + end; + + Assign(outF, dest); + Rewrite(outF, 1); + if IOResult <> 0 then + begin + AddFileLog('Error: Could not write to ' + dest); + exit; + end; + + repeat + BlockRead(inF, buffer, 1024, result); + BlockWrite(outF, buffer, result); + until result < 1024; +{$IOCHECKS ON} +end; + +procedure BeginPreRecording; +var format: word; + filename: shortstring; + frequency, channels: LongInt; +begin + AddFileLog('BeginPreRecording'); + + thumbnailSaved:= false; + RecPrefix:= 'hw-' + FormatDateTime('YYYY-MM-DD_HH-mm-ss-z', Now()); + + // If this video is recorded from demo executed directly (without frontend) + // then we need to copy demo so that frontend will be able to find it later. + if recordFileName <> '' then + begin + if GameType <> gmtDemo then // this is save and game demo is not recording, abort + exit; + CopyFile(recordFileName, UserPathPrefix + '/VideoTemp/' + RecPrefix + '.hwd'); + end; + + Mix_QuerySpec(@frequency, @format, @channels); + AddFileLog('sound: frequency = ' + IntToStr(frequency) + ', format = ' + IntToStr(format) + ', channels = ' + IntToStr(channels)); + if format <> $8010 then + begin + // TODO: support any audio format + AddFileLog('Error: Unexpected audio format ' + IntToStr(format)); + exit; + end; + +{$IOCHECKS OFF} + // create sound file + filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw'; + Assign(audioFile, filename); + Rewrite(audioFile, 1); + if IOResult <> 0 then + begin + AddFileLog('Error: Could not write to ' + filename); + exit; + end; + + // create file with camera positions + filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.txtout'; + Assign(cameraFile, filename); + Rewrite(cameraFile); + if IOResult <> 0 then + begin + AddFileLog('Error: Could not write to ' + filename); + exit; + end; + + // save audio parameters in sound file + BlockWrite(audioFile, frequency, 4); + BlockWrite(audioFile, channels, 4); +{$IOCHECKS ON} + + // register callback for actual audio recording + Mix_SetPostMix(@RecordPostMix, nil); + + startTime:= SDL_GetTicks(); + flagPrerecording:= true; +end; + +procedure StopPreRecording; +begin + AddFileLog('StopPreRecording'); + flagPrerecording:= false; + + // call SDL_LockAudio because RecordPostMix may be executing right now + SDL_LockAudio(); + Close(audioFile); + Close(cameraFile); + Mix_SetPostMix(nil, nil); + SDL_UnlockAudio(); + + if not thumbnailSaved then + SaveThumbnail(); +end; + +procedure SaveCameraPosition; +var frame: TFrame; +begin + if (not thumbnailSaved) and (ScreenFade = sfNone) then + SaveThumbnail(); + + frame.realTicks:= SDL_GetTicks() - startTime; + frame.gameTicks:= GameTicks; + frame.CamX:= WorldDx; + frame.CamY:= WorldDy - cScreenHeight div 2; + frame.zoom:= zoom/cScreenWidth; + BlockWrite(cameraFile, frame, 1); +end; + +procedure initModule; +begin +end; + +procedure freeModule; +begin + if flagPrerecording then + StopPreRecording(); +end; + +end. + +{$ENDIF} // USE_VIDEO_RECORDING diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uVisualGears.pas --- a/hedgewars/uVisualGears.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uVisualGears.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,22 +34,29 @@ procedure initModule; procedure freeModule; -function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear; +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; + procedure ProcessVisualGears(Steps: Longword); -procedure KickFlakes(Radius, X, Y: LongInt); procedure DrawVisualGears(Layer: LongWord); procedure DeleteVisualGear(Gear: PVisualGear); function VisualGearByUID(uid : Longword) : PVisualGear; + procedure AddClouds; -procedure ChangeToSDClouds; procedure AddFlakes; -procedure ChangeToSDFlakes; procedure AddDamageTag(X, Y, Damage, Color: LongWord); +procedure ChangeToSDClouds; +procedure ChangeToSDFlakes; + +procedure KickFlakes(Radius, X, Y: LongInt); + implementation -uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils, uStore; +uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils, uStore, uUtils; const cExplFrameTicks = 110; +var VGCounter: LongWord; // For better maintainability the step handlers of visual gears are stored // in a separate file. @@ -112,19 +119,29 @@ @doStepStraightShot ); -function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord = 0; Critical: Boolean = false): PVisualGear; -const VGCounter: Longword = 0; +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; +begin + AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false); +end; + +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; +begin + AddVisualGear:= AddVisualGear(X, Y, Kind, State, false); +end; + +function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; var gear: PVisualGear; t: Longword; sp: real; begin AddVisualGear:= nil; -if ((GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet))) and // we are scrolling now - ((Kind <> vgtCloud) and not Critical) then exit; +if ((GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) or fastScrolling) and // we are scrolling now + ((Kind <> vgtCloud) and (not Critical)) then + exit; if ((cReducedQuality and rqAntiBoom) <> 0) and - not Critical and - not (Kind in + (not Critical) and + (not (Kind in [vgtTeamHealthSorter, vgtSmallDamageTag, vgtSpeechBubble, @@ -133,7 +150,9 @@ vgtSmokeTrace, vgtEvilTrace, vgtNote, - vgtSmoothWindBar]) then exit; + vgtSmoothWindBar])) then + + exit; inc(VGCounter); New(gear); @@ -149,10 +168,12 @@ with gear^ do case Kind of - vgtFlake: begin + vgtFlake: + begin Timer:= 0; tdX:= 0; tdY:= 0; + Scale:= 1.0; if SuddenDeathDmg then begin FrameTicks:= random(vobSDFrameTicks); @@ -163,105 +184,135 @@ FrameTicks:= random(vobFrameTicks); Frame:= random(vobFramesCount); end; - Angle:= random * 360; + Angle:= random(360); dx:= 0.0000038654705 * random(10000); dy:= 0.000003506096 * random(7000); - if random(2) = 0 then dx := -dx; - if SuddenDeathDmg then dAngle:= (random(2) * 2 - 1) * (1 + random) * vobSDVelocity / 1000 - else dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000 + if random(2) = 0 then + dx := -dx; + if SuddenDeathDmg then + dAngle:= (random(2) * 2 - 1) * (vobSDVelocity + random(vobSDVelocity)) / 1000 + else + dAngle:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) / 1000 end; - vgtCloud: begin + vgtCloud: + begin Frame:= random(4); dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind timer:= random(4096); + Scale:= 1.0 end; vgtExplPart, - vgtExplPart2: begin + vgtExplPart2: + begin t:= random(1024); sp:= 0.001 * (random(95) + 70); dx:= hwFloat2Float(AngleSin(t)) * sp; dy:= hwFloat2Float(AngleCos(t)) * sp; - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; Frame:= 7 - random(3); FrameTicks:= cExplFrameTicks end; - vgtFire: begin + vgtFire: + begin t:= random(1024); sp:= 0.001 * (random(85) + 95); dx:= hwFloat2Float(AngleSin(t)) * sp; dy:= hwFloat2Float(AngleCos(t)) * sp; - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= 650 + random(250); Frame:= random(8) end; - vgtEgg: begin + vgtEgg: + begin t:= random(1024); sp:= 0.001 * (random(85) + 95); dx:= hwFloat2Float(AngleSin(t)) * sp; dy:= hwFloat2Float(AngleCos(t)) * sp; - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= 650 + random(250); Frame:= 1 end; vgtShell: FrameTicks:= 500; - vgtSmallDamageTag: begin + vgtSmallDamageTag: + begin gear^.FrameTicks:= 1100 end; - vgtBubble: begin + vgtBubble: + begin dx:= 0.0000038654705 * random(10000); dy:= 0; - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; FrameTicks:= 250 + random(1751); Frame:= random(5) end; - vgtSteam: begin + vgtSteam: + begin dx:= 0.0000038654705 * random(10000); dy:= 0.001 * (random(85) + 95); - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; Frame:= 7 - random(3); FrameTicks:= cExplFrameTicks * 2; end; - vgtAmmo: begin + vgtAmmo: + begin alpha:= 1.0; scale:= 1.0 end; vgtSmokeWhite, - vgtSmoke: begin + vgtSmoke: + begin Scale:= 1.0; dx:= 0.0002 * (random(45) + 10); dy:= 0.0002 * (random(45) + 10); - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; Frame:= 7 - random(2); FrameTicks:= cExplFrameTicks * 2; end; - vgtDust: begin + vgtDust: + begin dx:= 0.005 * (random(15) + 10); dy:= 0.001 * (random(40) + 20); if random(2) = 0 then dx := -dx; + if random(2) = 0 then Tag:= 1 + else Tag:= -1; Frame:= 7 - random(2); FrameTicks:= random(20) + 15; end; - vgtSplash: begin + vgtSplash: + begin dx:= 0; dy:= 0; FrameTicks:= 740; Frame:= 19; + Scale:= 0.75; + Timer:= 1; end; - vgtDroplet: begin - dx:= 0.001 * (random(75) + 15); - dy:= -0.001 * (random(80) + 120); - if random(2) = 0 then dx := -dx; + vgtDroplet: + begin + dx:= 0.001 * (random(180) - 90); + dy:= -0.001 * (random(160) + 40); FrameTicks:= 250 + random(1751); Frame:= random(3) end; - vgtBeeTrace: begin + vgtBeeTrace: + begin FrameTicks:= 1000; Frame:= random(16); end; - vgtSmokeRing: begin + vgtSmokeRing: + begin dx:= 0; dy:= 0; FrameTicks:= 600; @@ -271,17 +322,21 @@ alpha:= 1; angle:= random(360); end; - vgtFeather: begin + vgtFeather: + begin t:= random(1024); sp:= 0.001 * (random(85) + 95); dx:= hwFloat2Float(AngleSin(t)) * sp; dy:= hwFloat2Float(AngleCos(t)) * sp; - if random(2) = 0 then dx := -dx; - if random(2) = 0 then dy := -dy; + if random(2) = 0 then + dx := -dx; + if random(2) = 0 then + dy := -dy; FrameTicks:= 650 + random(250); Frame:= 1 end; - vgtHealthTag: begin + vgtHealthTag: + begin Frame:= 0; Timer:= 1500; dY:= -0.08; @@ -289,64 +344,103 @@ //gear^.Z:= 2002; end; vgtSmokeTrace, - vgtEvilTrace: begin + vgtEvilTrace: + begin gear^.X:= gear^.X - 16; gear^.Y:= gear^.Y - 16; gear^.State:= 8; //gear^.Z:= cSmokeZ end; -vgtBigExplosion: begin +vgtBigExplosion: + begin gear^.Angle:= random(360); end; - vgtChunk: begin + vgtChunk: + begin gear^.Frame:= random(4); t:= random(1024); sp:= 0.001 * (random(85) + 47); dx:= hwFloat2Float(AngleSin(t)) * sp; dy:= hwFloat2Float(AngleCos(t)) * sp * -2; - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; end; - vgtNote: begin + vgtNote: + begin dx:= 0.005 * (random(15) + 10); dy:= -0.001 * (random(40) + 20); - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; Frame:= random(4); FrameTicks:= random(2000) + 1500; end; - vgtBulletHit: begin + vgtBulletHit: + begin dx:= 0; dy:= 0; FrameTicks:= 350; Frame:= 7; Angle:= 0; end; -vgtSmoothWindBar: Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); - vgtStraightShot: begin +vgtSmoothWindBar: + begin + Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change + Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); + end; + vgtStraightShot: + begin Angle:= 0; Scale:= 1.0; dx:= 0.001 * random(45); dy:= 0.001 * (random(20) + 25); State:= ord(sprHealth); - if random(2) = 0 then dx := -dx; + if random(2) = 0 then + dx := -dx; Frame:= 0; FrameTicks:= random(750) + 1250; State:= ord(sprSnowDust); end; end; -if State <> 0 then gear^.State:= State; +if State <> 0 then + gear^.State:= State; case Gear^.Kind of - vgtFlake: if cFlattenFlakes then gear^.Layer:= 0 - else if random(3) = 0 then gear^.Layer:= 0 // 33% - far back - else if random(3) = 0 then gear^.Layer:= 4 // 22% - mid-distance - else if random(3) <> 0 then gear^.Layer:= 5 // 30% - just behind land - else if random(2) = 0 then gear^.Layer:= 6 // 7% - just in front of land - else gear^.Layer:= 2; // 7% - close up + vgtFlake: if cFlattenFlakes then + gear^.Layer:= 0 + else if random(3) = 0 then + begin + gear^.Scale:= 0.5; + gear^.Layer:= 0 // 33% - far back + end + else if random(3) = 0 then + begin + gear^.Scale:= 0.8; + gear^.Layer:= 4 // 22% - mid-distance + end + else if random(3) <> 0 then + gear^.Layer:= 5 // 30% - just behind land + else if random(2) = 0 then + gear^.Layer:= 6 // 7% - just in front of land + else + begin + gear^.Scale:= 1.5; + gear^.Layer:= 2; // 7% - close up + end; vgtCloud: if cFlattenClouds then gear^.Layer:= 5 - else if random(3) = 0 then gear^.Layer:= 0 - else gear^.Layer:= random(2) + 4; + else if random(3) = 0 then + begin + gear^.Scale:= 0.25; + gear^.Layer:= 0 + end + else if random(2) = 0 then + gear^.Layer:= 5 + else + begin + gear^.Scale:= 0.4; + gear^.Layer:= 4 + end; // 0: this layer is very distant in the background when in stereo vgtTeamHealthSorter, @@ -401,15 +495,18 @@ procedure DeleteVisualGear(Gear: PVisualGear); begin - if Gear^.Tex <> nil then - FreeTexture(Gear^.Tex); + FreeTexture(Gear^.Tex); Gear^.Tex:= nil; - if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; - if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear - else VisualGearLayers[Gear^.Layer]:= Gear^.NextGear; + if Gear^.NextGear <> nil then + Gear^.NextGear^.PrevGear:= Gear^.PrevGear; + if Gear^.PrevGear <> nil then + Gear^.PrevGear^.NextGear:= Gear^.NextGear + else + VisualGearLayers[Gear^.Layer]:= Gear^.NextGear; - if lastVisualGearByUID = Gear then lastVisualGearByUID:= nil; + if lastVisualGearByUID = Gear then + lastVisualGearByUID:= nil; Dispose(Gear); end; @@ -418,17 +515,18 @@ var Gear, t: PVisualGear; i: LongWord; begin -if Steps = 0 then exit; +if Steps = 0 then + exit; for i:= 0 to 6 do begin t:= VisualGearLayers[i]; while t <> nil do - begin - Gear:= t; - t:= Gear^.NextGear; - Gear^.doStep(Gear, Steps) - end; + begin + Gear:= t; + t:= Gear^.NextGear; + Gear^.doStep(Gear, Steps) + end; end end; @@ -436,30 +534,33 @@ var Gear, t: PVisualGear; dmg, i: LongInt; begin -if (vobCount = 0) or (vobCount > 200) then exit; +if (vobCount = 0) or (vobCount > 200) then + exit; for i:= 2 to 6 do if i <> 3 then begin t:= VisualGearLayers[i]; while t <> nil do - begin - Gear:= t; - if Gear^.Kind = vgtFlake then - begin - // Damage calc from doMakeExplosion - dmg:= Min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5); - if dmg > 1 then - begin - Gear^.tdX:= 0.02 * dmg + 0.01; - if Gear^.X - X < 0 then Gear^.tdX := -Gear^.tdX; - Gear^.tdY:= 0.02 * dmg + 0.01; - if Gear^.Y - Y < 0 then Gear^.tdY := -Gear^.tdY; - Gear^.Timer:= 200 - end - end; - t:= Gear^.NextGear - end - end + begin + Gear:= t; + if Gear^.Kind = vgtFlake then + begin + // Damage calc from doMakeExplosion + dmg:= Min(101, Radius + cHHRadius div 2 - LongInt(abs(round(Gear^.X) - X) + abs(round(Gear^.Y) - Y)) div 5); + if dmg > 1 then + begin + Gear^.tdX:= 0.02 * dmg + 0.01; + if Gear^.X - X < 0 then + Gear^.tdX := -Gear^.tdX; + Gear^.tdY:= 0.02 * dmg + 0.01; + if Gear^.Y - Y < 0 then + Gear^.tdY := -Gear^.tdY; + Gear^.Timer:= 200 + end + end; + t:= Gear^.NextGear + end + end end; procedure DrawVisualGears(Layer: LongWord); @@ -471,43 +572,44 @@ case Layer of // this layer is very distant in the background when stereo 0: begin - Gear:= VisualGearLayers[0]; - while Gear <> nil do - begin - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); - case Gear^.Kind of + Gear:= VisualGearLayers[0]; + while Gear <> nil do + begin + if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); + case Gear^.Kind of vgtCloud: if SuddenDeathDmg then - DrawTextureF(SpritesData[sprSDCloud].Texture, 0.25, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height) + DrawTextureF(SpritesData[sprSDCloud].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height) else - DrawTextureF(SpritesData[sprCloud].Texture, 0.25, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height); + DrawTextureF(SpritesData[sprCloud].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height); vgtFlake: if cFlattenFlakes then begin if SuddenDeathDmg then if vobSDVelocity = 0 then DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + DrawSpriteRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) else if vobVelocity = 0 then DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) end else begin if SuddenDeathDmg then if vobSDVelocity = 0 then - DrawTextureF(SpritesData[sprSDFlake].Texture, 0.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + DrawTextureF(SpritesData[sprSDFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) else - DrawRotatedTextureF(SpritesData[sprSDFlake].Texture, 0.5, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) + DrawTextureRotatedF(SpritesData[sprSDFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) else if vobVelocity = 0 then - DrawTextureF(SpritesData[sprFlake].Texture, 0.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + DrawTextureF(SpritesData[sprFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) else - DrawRotatedTextureF(SpritesData[sprFlake].Texture, 0.5, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) + DrawTextureRotatedF(SpritesData[sprFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) end; end; - if Gear^.Tint <> $FFFFFFFF then Tint($FF,$FF,$FF,$FF); + if Gear^.Tint <> $FFFFFFFF then + Tint($FF,$FF,$FF,$FF); Gear:= Gear^.NextGear end end; @@ -517,20 +619,23 @@ while Gear <> nil do begin //tinted:= false; - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); case Gear^.Kind of vgtFlake: if SuddenDeathDmg then if vobSDVelocity = 0 then DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + DrawSpriteRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) else if vobVelocity = 0 then DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); - vgtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State); - vgtEvilTrace: if Gear^.State < 8 then DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State); + DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); + vgtSmokeTrace: if Gear^.State < 8 then + DrawSprite(sprSmokeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State); + vgtEvilTrace: if Gear^.State < 8 then + DrawSprite(sprEvilTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State); vgtLineTrail: DrawLine(Gear^.X, Gear^.Y, Gear^.dX, Gear^.dY, 1.0, $FF, min(Gear^.Timer, $C0), min(Gear^.Timer, $80), min(Gear^.Timer, $FF)); end; if (cReducedQuality and rqAntiBoom) = 0 then @@ -538,17 +643,19 @@ vgtSmoke: DrawTextureF(SpritesData[sprSmoke].Texture, Gear^.scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 7 - Gear^.Frame, 1, SpritesData[sprSmoke].Width, SpritesData[sprSmoke].Height); vgtSmokeWhite: DrawSprite(sprSmokeWhite, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); vgtDust: if Gear^.State = 1 then - DrawSprite(sprSnowDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame) + DrawSpriteRotatedF(sprSnowDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame, Gear^.Tag, Gear^.Angle) else - DrawSprite(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); + DrawSpriteRotatedF(sprDust, round(Gear^.X) + WorldDx - 11, round(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame, Gear^.Tag, Gear^.Angle); vgtFire: if (Gear^.State and gstTmpFlag) = 0 then DrawSprite(sprFlame, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy, (RealTicks shr 6 + Gear^.Frame) mod 8) else DrawTextureF(SpritesData[sprFlame].Texture, Gear^.FrameTicks / 900, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, (RealTicks shr 7 + Gear^.Frame) mod 8, 1, 16, 16); vgtSplash: if SuddenDeathDmg then - DrawSprite(sprSDSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37)) + //DrawSprite(sprSDSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37)) + DrawTextureF(SpritesData[sprSDSplash].Texture, Gear^.scale, round(Gear^.X + WorldDx), round(Gear^.Y + WorldDy - ((SpritesData[sprSDSplash].Height+8)*Gear^.Scale)/2), 19 - (Gear^.FrameTicks div Gear^.Timer div 37), 1, SpritesData[sprSDSplash].Width, SpritesData[sprSDSplash].Height) else - DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37)); + //DrawSprite(sprSplash, round(Gear^.X) + WorldDx - 40, round(Gear^.Y) + WorldDy - 58, 19 - (Gear^.FrameTicks div 37)); + DrawTextureF(SpritesData[sprSplash].Texture, Gear^.scale, round(Gear^.X + WorldDx), round(Gear^.Y + WorldDy - ((SpritesData[sprSplash].Height+8)*Gear^.Scale)/2), 19 - (Gear^.FrameTicks div Gear^.Timer div 37), 1, SpritesData[sprSplash].Width, SpritesData[sprSplash].Height); vgtDroplet: if SuddenDeathDmg then DrawSprite(sprSDDroplet, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame) else @@ -556,7 +663,8 @@ vgtBubble: DrawSprite(sprBubbles, round(Gear^.X) + WorldDx - 8, round(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8); end; //if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF); - if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF); + if (Gear^.Tint <> $FFFFFFFF) then + Tint($FF,$FF,$FF,$FF); Gear:= Gear^.NextGear end end; @@ -566,52 +674,59 @@ while Gear <> nil do begin tinted:= false; - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); case Gear^.Kind of (* vgtFlake: if SuddenDeathDmg then if vobSDVelocity = 0 then DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + DrawSpriteRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) else if vobVelocity = 0 then DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) else - DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);*) + DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);*) vgtSpeechBubble: begin if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team <> CurrentTeam)) or (Gear^.State = 1)) then begin tinted:= true; Tint($FF, $FF, $FF, $66); - DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex) + DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex) end else if (Gear^.Tex <> nil) and (((Gear^.State = 0) and (Gear^.Hedgehog^.Team = CurrentTeam)) or (Gear^.State = 2)) then - DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); + DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); end; - vgtSmallDamageTag: DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); + vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); vgtHealthTag: if Gear^.Tex <> nil then begin if Gear^.Frame = 0 then - DrawCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex) + DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex) else begin SetScale(cDefaultZoomLevel); - if Gear^.Angle = 0 then DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex) - else DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle); + if Gear^.Angle = 0 then + DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex) + else + DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle); SetScale(zoom) end end; vgtStraightShot: begin - if Gear^.dX < 0 then i:= -1 else i:= 1; - DrawRotatedTextureF(SpritesData[TSprite(Gear^.State)].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, i, SpritesData[TSprite(Gear^.State)].Width, SpritesData[TSprite(Gear^.State)].Height, Gear^.Angle); + if Gear^.dX < 0 then + i:= -1 + else + i:= 1; + DrawTextureRotatedF(SpritesData[TSprite(Gear^.State)].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, i, SpritesData[TSprite(Gear^.State)].Width, SpritesData[TSprite(Gear^.State)].Height, Gear^.Angle); end; end; if (cReducedQuality and rqAntiBoom) = 0 then case Gear^.Kind of - vgtChunk: DrawRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + vgtChunk: DrawSpriteRotatedF(sprChunk, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); end; - if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF); + if (Gear^.Tint <> $FFFFFFFF) or tinted then + Tint($FF,$FF,$FF,$FF); Gear:= Gear^.NextGear end end; @@ -621,13 +736,14 @@ while Gear <> nil do begin tinted:= false; - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); case Gear^.Kind of vgtExplosion: DrawSprite(sprExplosion50, round(Gear^.X) - 32 + WorldDx, round(Gear^.Y) - 32 + WorldDy, Gear^.State); vgtBigExplosion: begin tinted:= true; Tint($FF, $FF, $FF, round($FF * (1 - power(Gear^.Timer / 250, 4)))); - DrawRotatedTextureF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle); + DrawTextureRotatedF(SpritesData[sprBigExplosion].Texture, 0.85 * (-power(2, -10 * Int(Gear^.Timer)/250) + 1) + 0.4, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 385, 385, Gear^.Angle); end; end; if (cReducedQuality and rqAntiBoom) = 0 then @@ -647,7 +763,7 @@ Tint($FF, $FF, $FF, Gear^.FrameTicks); tinted:= true end; - DrawRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + DrawSpriteRotatedF(sprShell, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); end; vgtFeather: begin if Gear^.FrameTicks < 255 then @@ -655,121 +771,129 @@ Tint($FF, $FF, $FF, Gear^.FrameTicks); tinted:= true end; - DrawRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + DrawSpriteRotatedF(sprFeather, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); end; - vgtEgg: DrawRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + vgtEgg: DrawSpriteRotatedF(sprEgg, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); vgtBeeTrace: begin if Gear^.FrameTicks < $FF then Tint($FF, $FF, $FF, Gear^.FrameTicks div 2) else Tint($FF, $FF, $FF, $80); tinted:= true; - DrawRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle); + DrawSpriteRotatedF(sprBeeTrace, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, (RealTicks shr 4) mod cMaxAngle); end; vgtSmokeRing: begin tinted:= true; Tint($FF, $FF, $FF, round(Gear^.alpha * $FF)); - DrawRotatedTextureF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle); + DrawTextureRotatedF(SpritesData[sprSmokeRing].Texture, Gear^.scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, 0, 1, 200, 200, Gear^.Angle); end; - vgtNote: DrawRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); - vgtBulletHit: DrawRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle); + vgtNote: DrawSpriteRotatedF(sprNote, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + vgtBulletHit: DrawSpriteRotatedF(sprBulletHit, round(Gear^.X) + WorldDx - 0, round(Gear^.Y) + WorldDy - 0, 7 - (Gear^.FrameTicks div 50), 1, Gear^.Angle); end; case Gear^.Kind of vgtFlake: if SuddenDeathDmg then if vobSDVelocity = 0 then - DrawTextureF(SpritesData[sprSDFlake].Texture, 1.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + DrawTextureF(SpritesData[sprSDFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) else - DrawRotatedTextureF(SpritesData[sprSDFlake].Texture, 1.5, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) + DrawTextureRotatedF(SpritesData[sprSDFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) else if vobVelocity = 0 then - DrawTextureF(SpritesData[sprFlake].Texture, 1.5, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + DrawTextureF(SpritesData[sprFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) else - DrawRotatedTextureF(SpritesData[sprFlake].Texture, 1.5, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle); + DrawTextureRotatedF(SpritesData[sprFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle); vgtCircle: if gear^.Angle = 1 then begin tmp:= Gear^.State / 100; DrawTexture(round(Gear^.X-24*tmp) + WorldDx, round(Gear^.Y-24*tmp) + WorldDy, SpritesData[sprVampiric].Texture, tmp) end - else DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer); + else + DrawCircle(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.State, Gear^.Timer); end; - if (Gear^.Tint <> $FFFFFFFF) or tinted then Tint($FF,$FF,$FF,$FF); - Gear:= Gear^.NextGear - end - end; - // this layer is half-way between the screen plane (depth = 0) when in stereo, and the land - 4: begin - Gear:= VisualGearLayers[4]; - while Gear <> nil do - begin - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); - case Gear^.Kind of - vgtCloud: if SuddenDeathDmg then - DrawTextureF(SpritesData[sprSDCloud].Texture, 0.4, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height) - else - DrawTextureF(SpritesData[sprCloud].Texture, 0.4, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height); - vgtFlake: if SuddenDeathDmg then - if vobSDVelocity = 0 then - DrawTextureF(SpritesData[sprSDFlake].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) - else - DrawRotatedTextureF(SpritesData[sprSDFlake].Texture, 0.8, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) - else - if vobVelocity = 0 then - DrawTextureF(SpritesData[sprFlake].Texture, 0.8, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) - else - DrawRotatedTextureF(SpritesData[sprFlake].Texture, 0.8, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle); - end; - if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF); + if (Gear^.Tint <> $FFFFFFFF) or tinted then + Tint($FF,$FF,$FF,$FF); Gear:= Gear^.NextGear end end; - // this layer is on the screen plane (depth = 0) when stereo, but just behind the land - 5: begin - Gear:= VisualGearLayers[5]; - while Gear <> nil do - begin - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); - case Gear^.Kind of + // this layer is half-way between the screen plane (depth = 0) when in stereo, and the land + 4: begin + Gear:= VisualGearLayers[4]; + while Gear <> nil do + begin + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); + case Gear^.Kind of vgtCloud: if SuddenDeathDmg then - DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) - else - DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame); + DrawTextureF(SpritesData[sprSDCloud].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height) + else + DrawTextureF(SpritesData[sprCloud].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 2, SpritesData[sprCloud].Width, SpritesData[sprCloud].Height); vgtFlake: if SuddenDeathDmg then - if vobSDVelocity = 0 then - DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) - else - DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) - else - if vobVelocity = 0 then - DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) - else - DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); - end; - if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF); - Gear:= Gear^.NextGear - end - end; - // this layer is on the screen plane (depth = 0) when stereo, but just in front of the land + if vobSDVelocity = 0 then + DrawTextureF(SpritesData[sprSDFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + else + DrawTextureRotatedF(SpritesData[sprSDFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle) + else + if vobVelocity = 0 then + DrawTextureF(SpritesData[sprFlake].Texture, Gear^.Scale, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height) + else + DrawTextureRotatedF(SpritesData[sprFlake].Texture, Gear^.Scale, 0, 0, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, SpritesData[sprFlake].Width, SpritesData[sprFlake].Height, Gear^.Angle); + end; + if (Gear^.Tint <> $FFFFFFFF) then + Tint($FF,$FF,$FF,$FF); + Gear:= Gear^.NextGear + end + end; + // this layer is on the screen plane (depth = 0) when stereo, but just behind the land + 5: begin + Gear:= VisualGearLayers[5]; + while Gear <> nil do + begin + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); + case Gear^.Kind of + vgtCloud: if SuddenDeathDmg then + DrawSprite(sprSDCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) + else + DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame); + vgtFlake: if SuddenDeathDmg then + if vobSDVelocity = 0 then + DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) + else + DrawSpriteRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + else + if vobVelocity = 0 then + DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) + else + DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); + end; + if (Gear^.Tint <> $FFFFFFFF) then + Tint($FF,$FF,$FF,$FF); + Gear:= Gear^.NextGear + end + end; + // this layer is on the screen plane (depth = 0) when stereo, but just in front of the land 6: begin - Gear:= VisualGearLayers[6]; - while Gear <> nil do - begin - if Gear^.Tint <> $FFFFFFFF then Tint(Gear^.Tint); - case Gear^.Kind of - vgtFlake: if SuddenDeathDmg then - if vobSDVelocity = 0 then - DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) - else - DrawRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) - else - if vobVelocity = 0 then - DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) - else - DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); - end; - if (Gear^.Tint <> $FFFFFFFF) then Tint($FF,$FF,$FF,$FF); - Gear:= Gear^.NextGear - end - end; + Gear:= VisualGearLayers[6]; + while Gear <> nil do + begin + if Gear^.Tint <> $FFFFFFFF then + Tint(Gear^.Tint); + case Gear^.Kind of + vgtFlake: if SuddenDeathDmg then + if vobSDVelocity = 0 then + DrawSprite(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) + else + DrawSpriteRotatedF(sprSDFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle) + else + if vobVelocity = 0 then + DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame) + else + DrawSpriteRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle); + end; + if (Gear^.Tint <> $FFFFFFFF) then + Tint($FF,$FF,$FF,$FF); + Gear:= Gear^.NextGear + end + end; end; end; @@ -778,7 +902,8 @@ i: LongWord; begin VisualGearByUID:= nil; -if uid = 0 then exit; +if uid = 0 then + exit; if (lastVisualGearByUID <> nil) and (lastVisualGearByUID^.uid = uid) then begin VisualGearByUID:= lastVisualGearByUID; @@ -791,11 +916,11 @@ while vg <> nil do begin if vg^.uid = uid then - begin - lastVisualGearByUID:= vg; - VisualGearByUID:= vg; - exit - end; + begin + lastVisualGearByUID:= vg; + VisualGearByUID:= vg; + exit + end; vg:= vg^.NextGear end end @@ -812,7 +937,8 @@ var i: LongInt; vg, tmp: PVisualGear; begin -if cCloudsNumber = cSDCloudsNumber then exit; +if cCloudsNumber = cSDCloudsNumber then + exit; vg:= VisualGearLayers[0]; while vg <> nil do if vg^.Kind = vgtCloud then @@ -829,13 +955,14 @@ procedure AddFlakes; var i: LongInt; begin -if (cReducedQuality and rqKillFlakes) <> 0 then exit; +if (cReducedQuality and rqKillFlakes) <> 0 then + exit; if hasBorder or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then - for i:= 0 to Pred(vobCount * cScreenSpace div LAND_WIDTH) do + for i:= 0 to Pred(vobCount * cScreenSpace div 4096) do AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake) else - for i:= 0 to Pred((vobCount * cScreenSpace div LAND_WIDTH) div 3) do + for i:= 0 to Pred((vobCount * cScreenSpace div 4096) div 3) do AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake); end; @@ -843,8 +970,10 @@ var i: LongInt; vg, tmp: PVisualGear; begin -if (cReducedQuality and rqKillFlakes) <> 0 then exit; -if vobCount = vobSDCount then exit; +if (cReducedQuality and rqKillFlakes) <> 0 then + exit; +if vobCount = vobSDCount then + exit; for i:= 0 to 6 do begin vg:= VisualGearLayers[i]; @@ -858,16 +987,17 @@ else vg:= vg^.NextGear; end; if ((GameFlags and gfBorder) <> 0) or ((Theme <> 'Snow') and (Theme <> 'Christmas')) then - for i:= 0 to Pred(vobSDCount * cScreenSpace div LAND_WIDTH) do + for i:= 0 to Pred(vobSDCount * cScreenSpace div 4096) do AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake) else - for i:= 0 to Pred((vobSDCount * cScreenSpace div LAND_WIDTH) div 3) do + for i:= 0 to Pred((vobSDCount * cScreenSpace div 4096) div 3) do AddVisualGear(cLeftScreenBorder + random(cScreenSpace), random(1024+200) - 100 + LAND_HEIGHT, vgtFlake); end; procedure initModule; var i: LongWord; begin +VGCounter:= 0; for i:= 0 to 6 do VisualGearLayers[i]:= nil; end; @@ -875,6 +1005,7 @@ procedure freeModule; var i: LongWord; begin +VGCounter:= 0; for i:= 0 to 6 do while VisualGearLayers[i] <> nil do DeleteVisualGear(VisualGearLayers[i]); end; diff -r 41b0a9955c47 -r ddcdedd3330b hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Thu Nov 24 13:44:30 2011 +0100 +++ b/hedgewars/uWorld.pas Sun Oct 28 13:28:23 2012 +0100 @@ -1,6 +1,6 @@ (* * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2011 Andrey Korotaev + * Copyright (c) 2004-2012 Andrey Korotaev * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,45 +21,55 @@ unit uWorld; interface -uses SDLh, uGears, uConsts, uFloat, uRandom, uTypes; +uses SDLh, uGears, uConsts, uFloat, uRandom, uTypes, uRenderUtils; procedure initModule; procedure freeModule; procedure InitWorld; +procedure ResetWorldTex; + procedure DrawWorld(Lag: LongInt); procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); procedure HideMission; procedure ShakeCamera(amount: LongInt); procedure InitCameraBorders; +procedure InitTouchInterface; +procedure SetUtilityWidgetState(ammoType: TAmmoType); +procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean); procedure MoveCamera; procedure onFocusStateChanged; implementation uses - uStore, - uMisc, - uIO, - uLocale, - uSound, - uAmmos, - uVisualGears, - uChat, - uLandTexture, - GLunit, - uVariables, - uUtils, - uTextures, - uRender, - uCaptions, - uCursor, - uCommands, - uMobile + uStore + , uMisc + , uIO + , uLocale + , uSound + , uAmmos + , uVisualGears + , uChat + , uLandTexture + , GLunit + , uVariables + , uUtils + , uTextures + , uRender + , uCaptions + , uCursor + , uCommands + , uMobile +{$IFDEF USE_VIDEO_RECORDING} + , uVideoRec +{$ENDIF} ; var cWaveWidth, cWaveHeight: LongInt; - AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt; + AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt; + AMAnimStartTime, AMState : LongInt; + AMAnimState: Single; tmpSurface: PSDL_Surface; fpsTexture: PTexture; timeTexture: PTexture; @@ -71,6 +81,9 @@ missionTex: PTexture; missionTimer: LongInt; stereoDepth: GLfloat; + isFirstFrame: boolean; + AMAnimType: LongInt; + recTexture: PTexture; const cStereo_Sky = 0.0500; cStereo_Horizon = 0.0250; @@ -80,56 +93,59 @@ cStereo_Water_near = 0.0025; cStereo_Outside = -0.0400; +// helper functions to create the goal/game mode string +function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; +var t: ansistring; +begin + if (GameFlags and gf) <> 0 then + begin + t:= inttostr(i); + s:= s + FormatA(trgoal[si], t) + '|' + end; + AddGoal:= s; +end; + +function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; +begin + if (GameFlags and gf) <> 0 then + s:= s + trgoal[si] + '|'; + AddGoal:= s; +end; + procedure InitWorld; var i, t: LongInt; cp: PClan; g: ansistring; - - // helper functions to create the goal/game mode string - function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; - var t: ansistring; - begin - if (GameFlags and gf) <> 0 then - begin - t:= inttostr(i); - s:= s + format(trgoal[si], t) + '|' - end; - AddGoal:= s; - end; - - function AddGoal(s: ansistring; gf: longword; si: TGoalStrId): ansistring; - begin - if (GameFlags and gf) <> 0 then - s:= s + trgoal[si] + '|'; - AddGoal:= s; - end; begin missionTimer:= 0; if (GameFlags and gfRandomOrder) <> 0 then // shuffle them up a bit - begin - for i:= 0 to ClansCount * 4 do - begin - t:= GetRandom(ClansCount); - if t <> 0 then - begin - cp:= ClansArray[0]; - ClansArray[0]:= ClansArray[t]; - ClansArray[t]:= cp; - ClansArray[t]^.ClanIndex:= t; - ClansArray[0]^.ClanIndex:= 0; - if (LocalClan = t) then LocalClan:= 0 - else if (LocalClan = 0) then LocalClan:= t - end; - end; - CurrentTeam:= ClansArray[0]^.Teams[0]; - end; + begin + for i:= 0 to ClansCount * 4 do + begin + t:= GetRandom(ClansCount); + if t <> 0 then + begin + cp:= ClansArray[0]; + ClansArray[0]:= ClansArray[t]; + ClansArray[t]:= cp; + ClansArray[t]^.ClanIndex:= t; + ClansArray[0]^.ClanIndex:= 0; + if (LocalClan = t) then + LocalClan:= 0 + else if (LocalClan = 0) then + LocalClan:= t + end; + end; + CurrentTeam:= ClansArray[0]^.Teams[0]; + end; // if special game flags/settings are changed, add them to the game mode notice window and then show it g:= ''; // no text/things to note yet // add custom goals from lua script if there are any -if LuaGoals <> '' then g:= LuaGoals + '|'; +if LuaGoals <> '' then + g:= LuaGoals + '|'; // check different game flags (goals/game modes first for now) g:= AddGoal(g, gfKing, gidKing); // king? @@ -172,7 +188,8 @@ end; // if the string has been set, show it for (default timeframe) seconds -if g <> '' then ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0); +if g <> '' then + ShowMission(trgoal[gidCaption], trgoal[gidSubCaption], g, 1, 0); cWaveWidth:= SpritesData[sprWater].Width; //cWaveHeight:= SpritesData[sprWater].Height; @@ -182,29 +199,15 @@ uCursor.init(); prevPoint.X:= 0; prevPoint.Y:= cScreenHeight div 2; -WorldDx:= - (LAND_WIDTH div 2) + cScreenWidth div 2; -WorldDy:= - (LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2); -AMSlotSize:= 33; -{$IFDEF IPHONEOS} -if isPhone() then - begin - AMxOffset:= -30 + cScreenHeight div 2; - AMyOffset:= 10; - end -else - begin - AMxOffset:= AMSlotSize + cScreenHeight div 2; - AMyOffset:= -10 + cScreenWidth div 3; - end; -AMWidth:= (cMaxSlotAmmoIndex + 1) * AMSlotSize + AMxOffset; -{$ELSE} -AMxOffset:= 10; -AMyOffset:= 60; -AMWidth:= (cMaxSlotAmmoIndex + 2) * AMSlotSize + AMxOffset; -{$ENDIF} -AMxShift:= AMWidth; +WorldDx:= -(LAND_WIDTH div 2) + cScreenWidth div 2; +WorldDy:= -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2); + +//aligns it to the bottom of the screen, minus the border SkyOffset:= 0; HorizontOffset:= 0; + +InitTouchInterface(); +AMAnimType:= AMTypeMaskX or AMTypeMaskAlpha; end; procedure InitCameraBorders; @@ -212,173 +215,483 @@ cGearScrEdgesDist:= min(2 * cScreenHeight div 5, 2 * cScreenWidth div 5); end; -procedure ShowAmmoMenu; -const MENUSPEED = 15; -const BORDERSIZE = 2; -var x, y, i, t, g: LongInt; - Slot, Pos, STurns: LongInt; - Ammo: PHHAmmo; +procedure InitTouchInterface; begin - if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or - ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then - bShowAmmoMenu:= false; +{$IFDEF USE_TOUCH_INTERFACE} + +//positioning of the buttons +buttonScale:= uMobile.getScreenDPI/cDefaultZoomLevel; + + +with JumpWidget do + begin + show:= true; + sprite:= sprJumpWidget; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= (cScreenWidth shr 1) - Round(frame.w * 1.2); + frame.y:= cScreenHeight - frame.h * 2; + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; + +with AMWidget do + begin + show:= true; + sprite:= sprAMWidget; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= (cScreenWidth shr 1) - frame.w * 2; + frame.y:= cScreenHeight - Round(frame.h * 1.2); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; + +with arrowLeft do + begin + show:= true; + sprite:= sprArrowLeft; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= -(cScreenWidth shr 1) + Round(frame.w * 0.25); + frame.y:= cScreenHeight - Round(frame.h * 1.5); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; - if bShowAmmoMenu then - // show ammo menu - begin - FollowGear:= nil; - if AMxShift = AMWidth then prevPoint.X:= 0; - if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= 0 - else - if AMxShift > MENUSPEED then dec(AMxShift, MENUSPEED) - else AMxShift:= 0; - end - else - // hide ammo menu +with arrowRight do + begin + show:= true; + sprite:= sprArrowRight; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= -(cScreenWidth shr 1) + Round(frame.w * 1.5); + frame.y:= cScreenHeight - Round(frame.h * 1.5); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; + +with firebutton do + begin + show:= true; + sprite:= sprFireButton; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= arrowRight.frame.x + arrowRight.frame.w; + frame.y:= arrowRight.frame.y + (arrowRight.frame.w shr 1) - (frame.w shr 1); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; + +with arrowUp do + begin + show:= false; + sprite:= sprArrowUp; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= (cScreenWidth shr 1) - frame.w * 2; + frame.y:= jumpWidget.frame.y - Round(frame.h * 1.25); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + with moveAnim do + begin + target.x:= frame.x; + target.y:= frame.y; + source.x:= frame.x - Round(frame.w * 0.75); + source.y:= frame.y; + end; + end; + +with arrowDown do + begin + show:= false; + sprite:= sprArrowDown; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= (cScreenWidth shr 1) - frame.w * 2; + frame.y:= jumpWidget.frame.y - Round(frame.h * 1.25); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + with moveAnim do begin - if AMxShift = 0 then - begin - CursorPoint.X:= cScreenWidth shr 1; - CursorPoint.Y:= cScreenHeight shr 1; - prevPoint:= CursorPoint; - end; - if (cReducedQuality and rqSlowMenu) <> 0 then AMxShift:= AMWidth+2 - else - if AMxShift < (AMWidth - MENUSPEED) then inc(AMxShift, MENUSPEED) - else AMxShift:= AMWidth; + target.x:= frame.x; + target.y:= frame.y; + source.x:= frame.x + Round(frame.w * 0.75); + source.y:= frame.y; end; + end; + +with pauseButton do + begin + show:= true; + sprite:= sprPauseButton; + frame.w:= Round(spritesData[sprPauseButton].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprPauseButton].Texture^.h * buttonScale); + frame.x:= cScreenWidth div 2 - frame.w; + frame.y:= 0; + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + end; + +with utilityWidget do + begin + show:= false; + sprite:= sprTimerButton; + frame.w:= Round(spritesData[sprite].Texture^.w * buttonScale); + frame.h:= Round(spritesData[sprite].Texture^.h * buttonScale); + frame.x:= arrowLeft.frame.x; + frame.y:= arrowLeft.frame.y - Round(frame.h * 1.25); + active.x:= frame.x; + active.y:= frame.y; + active.w:= frame.w; + active.h:= frame.h; + with moveAnim do + begin + target.x:= frame.x; + target.y:= frame.y; + source.x:= frame.x; + source.y:= frame.y; + end; + end; +{$ENDIF} +end; - // give the assigned ammo to hedgehog - Ammo:= nil; - if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and - (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then - Ammo:= CurrentHedgehog^.Ammo - else if (LocalAmmo <> -1) then - Ammo:= GetAmmoByNum(LocalAmmo); - Pos:= -1; - if Ammo = nil then - begin - bShowAmmoMenu:= false; - exit - end; +// for uStore texture resetting +procedure ResetWorldTex; +begin + FreeTexture(fpsTexture); + fpsTexture:= nil; + FreeTexture(timeTexture); + timeTexture:= nil; + FreeTexture(missionTex); + missionTex:= nil; + FreeTexture(recTexture); + recTexture:= nil; +end; + +function GetAmmoMenuTexture(Ammo: PHHAmmo): PTexture; +const BORDERSIZE = 2; +var x, y, i, t, SlotsNumY, SlotsNumX, AMFrame: LongInt; + STurns: LongInt; + amSurface: PSDL_Surface; + AMRect: TSDL_Rect; +{$IFDEF USE_AM_NUMCOLUMN}tmpsurf: PSDL_Surface;{$ENDIF} +begin SlotsNum:= 0; - x:= (cScreenWidth shr 1) - AMWidth + AMxShift; + for i:= 0 to cMaxSlotIndex do + if((i = 0) and (Ammo^[i,1].Count > 0)) or ((i <> 0) and (Ammo^[i,0].Count > 0)) then + inc(SlotsNum); +{$IFDEF USE_LANDSCAPE_AMMOMENU} + SlotsNumX:= SlotsNum; + SlotsNumY:= cMaxSlotAmmoIndex + 2; + {$IFDEF USE_AM_NUMCOLUMN} + inc(SlotsNumY); + {$ENDIF} +{$ELSE} + SlotsNumX:= cMaxSlotAmmoIndex + 1; + SlotsNumY:= SlotsNum + 1; + {$IFDEF USE_AM_NUMCOLUMN} + inc(SlotsNumX); + {$ENDIF} +{$ENDIF} -{$IFDEF IPHONEOS} - Slot:= cMaxSlotIndex; - x:= x - cOffsetY; - y:= AMyOffset; - dec(y, BORDERSIZE); - DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); - for i:= 0 to cMaxSlotAmmoIndex do - DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); - DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); - inc(y, BORDERSIZE); + AmmoRect.w:= (BORDERSIZE*2) + (SlotsNumX * AMSlotSize) + (SlotsNumX-1); + AmmoRect.h:= (BORDERSIZE*2) + (SlotsNumY * AMSlotSize) + (SlotsNumY-1); + amSurface := SDL_CreateRGBSurface(SDL_SWSURFACE, AmmoRect.w, AmmoRect.h, 32, RMask, GMask, BMask, AMask); + + AMRect.x:= BORDERSIZE; + AMRect.y:= BORDERSIZE; + AMRect.w:= AmmoRect.w - (BORDERSIZE*2); + AMRect.h:= AmmoRect.h - (BORDERSIZE*2); + + SDL_FillRect(amSurface, @AMRect, SDL_MapRGB(amSurface^.format, 0,0,0)); + + x:= AMRect.x; + y:= AMRect.y; for i:= 0 to cMaxSlotIndex do if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then begin - if (cScreenHeight - CursorPoint.Y >= y) and (cScreenHeight - CursorPoint.Y <= y + AMSlotSize) then Slot:= i; - inc(SlotsNum); - DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); - t:= 0; - g:= 0; - while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do +{$IFDEF USE_LANDSCAPE_AMMOMENU} + y:= AMRect.y; +{$ELSE} + x:= AMRect.x; +{$ENDIF} +{$IFDEF USE_AM_NUMCOLUMN} + tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar('F' + IntToStr(i+1)), cWhiteColorChannels); + copyToXY(tmpsurf, amSurface, + x + AMSlotPadding + (AMSlotSize shr 1) - (tmpsurf^.w shr 1), + y + AMSlotPadding + (AMSlotSize shr 1) - (tmpsurf^.h shr 1)); + + SDL_FreeSurface(tmpsurf); + {$IFDEF USE_LANDSCAPE_AMMOMENU} + y:= AMRect.y + AMSlotSize + 1; + {$ELSE} + x:= AMRect.x + AMSlotSize + 1; + {$ENDIF} +{$ENDIF} + + + for t:=0 to cMaxSlotAmmoIndex do begin - DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); - if (Ammo^[i, t].AmmoType <> amNothing) then + if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then begin STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; - - if STurns >= 0 then + AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; + if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining begin - DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); + DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, + y + AMSlotPadding, AMFrame); + if STurns < 100 then + DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, + x + AMSlotSize-16, + y + AMSlotSize + 1 - 16, STurns); end - else - DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and - (CursorPoint.X <= x + (g + 1) * AMSlotSize) then + else //draw colored version begin - if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); - Pos:= t; + DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, + y + AMSlotPadding, AMFrame); end; - inc(g) - end; - inc(t) - end; - for g:= g to cMaxSlotAmmoIndex do - DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); - DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); - inc(y, AMSlotSize); - end; +{$IFDEF USE_LANDSCAPE_AMMOMENU} + inc(y, AMSlotSize + 1); //the plus one is for the border +{$ELSE} + inc(x, AMSlotSize + 1); +{$ENDIF} + end; + end; +{$IFDEF USE_LANDSCAPE_AMMOMENU} + inc(x, AMSlotSize + 1); +{$ELSE} + inc(y, AMSlotSize + 1); +{$ENDIF} + end; + +for i:= 1 to SlotsNumX -1 do +DrawLine2Surf(amSurface, i * (AMSlotSize+1)+1, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.h + BORDERSIZE - AMSlotSize - 2,160,160,160); +for i:= 1 to SlotsNumY -1 do +DrawLine2Surf(amSurface, BORDERSIZE, i * (AMSlotSize+1)+1, AMRect.w + BORDERSIZE, i * (AMSlotSize+1)+1,160,160,160); + +//draw outer border +DrawSpriteFrame2Surf(sprAMCorners, amSurface, 0 , 0 , 0); +DrawSpriteFrame2Surf(sprAMCorners, amSurface, AMRect.w + BORDERSIZE, AMRect.y , 1); +DrawSpriteFrame2Surf(sprAMCorners, amSurface, AMRect.x , AMRect.h + BORDERSIZE, 2); +DrawSpriteFrame2Surf(sprAMCorners, amSurface, AMRect.w + BORDERSIZE, AMRect.h + BORDERSIZE, 3); + +for i:=0 to BORDERSIZE-1 do +begin +DrawLine2Surf(amSurface, BORDERSIZE, i, AMRect.w + BORDERSIZE, i,160,160,160);//top +DrawLine2Surf(amSurface, BORDERSIZE, AMRect.h+BORDERSIZE+i, AMRect.w + BORDERSIZE, AMRect.h+BORDERSIZE+i,160,160,160);//bottom +DrawLine2Surf(amSurface, i, BORDERSIZE, i, AMRect.h + BORDERSIZE,160,160,160);//left +DrawLine2Surf(amSurface, AMRect.w+BORDERSIZE+i, BORDERSIZE, AMRect.w + BORDERSIZE+i, AMRect.h + BORDERSIZE, 160,160,160);//right +end; + +GetAmmoMenuTexture:= Surface2Tex(amSurface, false); +if amSurface <> nil then SDL_FreeSurface(amSurface); +end; - DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); - for i:= 0 to cMaxSlotAmmoIndex do - DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); - DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); +procedure ShowAmmoMenu; +const BORDERSIZE = 2; +var Slot, Pos: LongInt; + Ammo: PHHAmmo; + c,i,g,t,STurns: LongInt; +begin +if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) +or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then + bShowAmmoMenu:= false; + +// give the assigned ammo to hedgehog +Ammo:= nil; +if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) +and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then + Ammo:= CurrentHedgehog^.Ammo +else if (LocalAmmo <> -1) then + Ammo:= GetAmmoByNum(LocalAmmo); +Pos:= -1; +if Ammo = nil then + begin + bShowAmmoMenu:= false; + AMState:= AMHidden; + exit + end; + +//Init the menu +if(AmmoMenuInvalidated) then + begin + AmmoMenuInvalidated:= false; + FreeTexture(AmmoMenuTex); + AmmoMenuTex:= GetAmmoMenuTexture(Ammo); + +{$IFDEF USE_LANDSCAPE_AMMOMENU} + if isPhone() then + begin + AmmoRect.x:= -(AmmoRect.w shr 1); + AmmoRect.y:= (cScreenHeight shr 1) - (AmmoRect.h shr 1); + end + else + begin + AmmoRect.x:= -(AmmoRect.w shr 1); + AmmoRect.y:= cScreenHeight - (AmmoRect.h + AMSlotSize); + end; {$ELSE} - Slot:= 0; - y:= cScreenHeight - AMyOffset; - DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2); - for i:= 0 to cMaxSlotAmmoIndex + 1 do - DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1); - DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 3); - dec(y, AMSlotSize); - DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); - for i:= 0 to cMaxSlotAmmoIndex do - DrawSprite(sprAMSlot, x + i * AMSlotSize, y, 2); - DrawSprite(sprAMSlot, x + (cMaxSlotAmmoIndex + 1) * AMSlotSize, y, 1); - DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); + AmmoRect.x:= (cScreenWidth shr 1) - AmmoRect.w - AMSlotSize; + AmmoRect.y:= cScreenHeight - (AmmoRect.h + AMSlotSize); +{$ENDIF} + AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x; + AMShiftTargetY:= cScreenHeight - AmmoRect.y; + + if (AMAnimType and AMTypeMaskX) <> 0 then AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x + else AMShiftTargetX:= 0; + if (AMAnimType and AMTypeMaskY) <> 0 then AMShiftTargetY:= cScreenHeight - AmmoRect.y + else AMShiftTargetY:= 0; + + AMShiftX:= AMShiftTargetX; + AMShiftY:= AMShiftTargetY; +end; + +AMAnimState:= (RealTicks - AMAnimStartTime) / AMAnimDuration; + +if AMState = AMShowing then + begin + FollowGear:=nil; + end; - for i:= cMaxSlotIndex downto 0 do +if AMState = AMShowingUp then // show ammo menu + begin + if (cReducedQuality and rqSlowMenu) <> 0 then + begin + AMShiftX:= 0; + AMShiftY:= 0; + AMState:= AMShowing; + end + else + if AMAnimState < 1 then + begin + AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState)); + AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState)); + if (AMAnimType and AMTypeMaskAlpha) <> 0 then + Tint($FF, $ff, $ff, Round($ff * AMAnimState)); + end + else + begin + AMShiftX:= 0; + AMShiftY:= 0; + CursorPoint.X:= AmmoRect.x + AmmoRect.w; + CursorPoint.Y:= AmmoRect.y; + AMState:= AMShowing; + end; + end; +if AMState = AMHiding then // hide ammo menu + begin + if (cReducedQuality and rqSlowMenu) <> 0 then + begin + AMShiftX:= AMShiftTargetX; + AMShiftY:= AMShiftTargetY; + AMState:= AMHidden; + end + else + if AMAnimState < 1 then + begin + AMShiftX:= Round(AMShiftTargetX * AMAnimState); + AMShiftY:= Round(AMShiftTargetY * AMAnimState); + if (AMAnimType and AMTypeMaskAlpha) <> 0 then + Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState))); + end + else + begin + AMShiftX:= AMShiftTargetX; + AMShiftY:= AMShiftTargetY; + prevPoint:= CursorPoint; + AMState:= AMHidden; + end; + end; + +DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); + +if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then + Tint($FF, $ff, $ff, $ff); + +Pos:= -1; +Slot:= -1; +{$IFDEF USE_LANDSCAPE_AMMOMENU} +c:= -1; + for i:= 0 to cMaxSlotIndex do if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then begin - if (cScreenHeight - CursorPoint.Y >= y - AMSlotSize) and (cScreenHeight - CursorPoint.Y <= y) then Slot:= i; - dec(y, AMSlotSize); - inc(SlotsNum); - DrawSprite(sprAMBorderVertical, x - BORDERSIZE, y, 0); - DrawSprite(sprAMSlot, x, y, 1); - DrawSprite(sprAMSlotKeys, x, y + 1, i); - t:= 0; + inc(c); + {$IFDEF USE_AM_NUMCOLUMN} g:= 1; - while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do - begin - DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); - if (Ammo^[i, t].AmmoType <> amNothing) then + {$ELSE} + g:= 0; + {$ENDIF} + for t:=0 to cMaxSlotAmmoIndex do + if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then begin - STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; - - if STurns >= 0 then + if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( g * (AMSlotSize+1))) and + (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((g+1) * (AMSlotSize+1))) and + (CursorPoint.X > AmmoRect.x + ( c * (AMSlotSize+1))) and + (CursorPoint.X <= AmmoRect.x + ((c+1) * (AMSlotSize+1))) then begin - DrawSprite(sprAMAmmosBW, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if STurns < 100 then DrawSprite(sprTurnsLeft, x + (g + 1) * AMSlotSize - 16, y + AMSlotSize - 16, STurns); - end else - DrawSprite(sprAMAmmos, x + g * AMSlotSize, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if (Slot = i) and (CursorPoint.X >= x + g * AMSlotSize) and - (CursorPoint.X <= x + (g + 1) * AMSlotSize) then - begin - if (STurns < 0) then DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 0); + Slot:= i; Pos:= t; + STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; + if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then + DrawSprite(sprAMSlot, + AmmoRect.x + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding, + AmmoRect.y + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 0); end; - inc(g) - end; - inc(t) - end; - for g:= g to cMaxSlotAmmoIndex + 1 do - DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1); - DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1); + inc(g); + end; end; - - dec(y, BORDERSIZE); - DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0); - for i:= 0 to cMaxSlotAmmoIndex + 1 do - DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 0); - DrawSprite(sprAMCorners, x + AMWidth - AMxOffset, y, 1); +{$ELSE} +c:= -1; + for i:= 0 to cMaxSlotIndex do + if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then + begin + inc(c); + {$IFDEF USE_AM_NUMCOLUMN} + g:= 1; + {$ELSE} + g:= 0; + {$ENDIF} + for t:=0 to cMaxSlotAmmoIndex do + if (Ammo^[i, t].Count > 0) and (Ammo^[i, t].AmmoType <> amNothing) then + begin + if (CursorPoint.Y <= (cScreenHeight - AmmoRect.y) - ( c * (AMSlotSize+1))) and + (CursorPoint.Y > (cScreenHeight - AmmoRect.y) - ((c+1) * (AMSlotSize+1))) and + (CursorPoint.X > AmmoRect.x + ( g * (AMSlotSize+1))) and + (CursorPoint.X <= AmmoRect.x + ((g+1) * (AMSlotSize+1))) then + begin + Slot:= i; + Pos:= t; + STurns:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; + if (STurns < 0) and (AMShiftX = 0) and (AMShiftY = 0) then + DrawSprite(sprAMSlot, + AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding, + AmmoRect.y + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding -1, 0); + end; + inc(g); + end; + end; {$ENDIF} - - if (Pos >= 0) then + if (Pos >= 0) and (Pos <= cMaxSlotAmmoIndex) and (Slot >= 0) and (Slot <= cMaxSlotIndex)then begin + if (AMShiftX = 0) and (AMShiftY = 0) then if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then begin if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then @@ -387,15 +700,13 @@ RenderWeaponTooltip(amSel) end; -{$IFDEF IPHONEOS} - DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); + DrawTexture(AmmoRect.x + (AMSlotSize shr 1), + AmmoRect.y + AmmoRect.h - BORDERSIZE - (AMSlotSize shr 1) - (Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex^.h shr 1), + Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); if Ammo^[Slot, Pos].Count < AMMO_INFINITE then - DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + 163, AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); -{$ELSE} - DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, cScreenHeight - AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); - if Ammo^[Slot, Pos].Count < AMMO_INFINITE then - DrawTexture(cScreenWidth div 2 + AMxOffset - 45, cScreenHeight - AMyOffset - 25, CountTexz[Ammo^[Slot, Pos].Count]); -{$ENDIF} + DrawTexture(AmmoRect.x + AmmoRect.w - 20 - (CountTexz[Ammo^[Slot, Pos].Count]^.w), + AmmoRect.y + AmmoRect.h - BORDERSIZE - (AMslotSize shr 1) - (CountTexz[Ammo^[Slot, Pos].Count]^.w shr 1), + CountTexz[Ammo^[Slot, Pos].Count]); if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then begin @@ -403,6 +714,23 @@ SetWeapon(Ammo^[Slot, Pos].AmmoType); bSelected:= false; FreeWeaponTooltip; +{$IFDEF USE_TOUCH_INTERFACE}//show the aiming buttons + animation + if (Ammo^[Slot, Pos].Propz and ammoprop_NeedUpDown) <> 0 then + begin + if not(arrowUp.show) then + begin + animateWidget(@arrowUp, true, true); + animateWidget(@arrowDown, true, true); + end; + end + else + if arrowUp.show then + begin + animateWidget(@arrowUp, true, false); + animateWidget(@arrowDown, true, false); + end; + SetUtilityWidgetState(Ammo^[Slot, Pos].AmmoType); +{$ENDIF} exit end; end @@ -410,15 +738,19 @@ else FreeWeaponTooltip; - if (WeaponTooltipTex <> nil) and (AMxShift = 0) then -{$IFDEF IPHONEOS} - ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, 100); + if (WeaponTooltipTex <> nil) and (AMShiftX = 0) and (AMShiftY = 0) then +{$IFDEF USE_LANDSCAPE_AMMOMENU} + if not isPhone() then + ShowWeaponTooltip(-WeaponTooltipTex^.w div 2, AmmoRect.y - WeaponTooltipTex^.h - AMSlotSize); {$ELSE} - ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, Min(y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); + ShowWeaponTooltip(AmmoRect.x - WeaponTooltipTex^.w - 3, Min(AmmoRect.y + 1, cScreenHeight - WeaponTooltipTex^.h - 40)); {$ENDIF} bSelected:= false; - if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) +{$IFNDEF USE_TOUCH_INTERFACE} + if (AMShiftX = 0) and (AMShiftY = 0) then + DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); +{$ENDIF} end; procedure DrawWater(Alpha: byte; OffsetY: LongInt); @@ -426,27 +758,27 @@ r: TSDL_Rect; lw, lh: GLfloat; begin - if SuddenDeathDmg then - begin - SDWaterColorArray[0].a := Alpha; - SDWaterColorArray[1].a := Alpha; - SDWaterColorArray[2].a := Alpha; - SDWaterColorArray[3].a := Alpha - end - else - begin - WaterColorArray[0].a := Alpha; - WaterColorArray[1].a := Alpha; - WaterColorArray[2].a := Alpha; - WaterColorArray[3].a := Alpha - end; +if SuddenDeathDmg then + begin + SDWaterColorArray[0].a := Alpha; + SDWaterColorArray[1].a := Alpha; + SDWaterColorArray[2].a := Alpha; + SDWaterColorArray[3].a := Alpha + end +else + begin + WaterColorArray[0].a := Alpha; + WaterColorArray[1].a := Alpha; + WaterColorArray[2].a := Alpha; + WaterColorArray[3].a := Alpha + end; - lw:= cScreenWidth / cScaleFactor; - lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; +lw:= cScreenWidth / cScaleFactor; +lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16; // Water - r.y:= OffsetY + WorldDy + cWaterLine; - if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then +r.y:= OffsetY + WorldDy + cWaterLine; +if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then begin if r.y < 0 then r.y:= 0; @@ -545,74 +877,72 @@ procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt); var i, w, h, lw, lh, rw, rh, sw: LongInt; begin - sw:= round(cScreenWidth / cScaleFactor); - if (SpritesData[sprL].Texture = nil) and (SpritesData[spr].Texture <> nil) then - begin - w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; - h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; - i:= Shift mod w; - if i > 0 then dec(i, w); - dec(i, w * (sw div w + 1)); - repeat - DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); - inc(i, w) - until i > sw - end - else if SpritesData[spr].Texture <> nil then +sw:= round(cScreenWidth / cScaleFactor); +if (SpritesData[sprL].Texture = nil) and (SpritesData[spr].Texture <> nil) then + begin + w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; + h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; + i:= Shift mod w; + if i > 0 then + dec(i, w); + dec(i, w * (sw div w + 1)); + repeat + DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); + inc(i, w) + until i > sw + end +else if SpritesData[spr].Texture <> nil then + begin + w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; + h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; + lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale; + lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale; + if SpritesData[sprR].Texture <> nil then begin - w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale; - h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale; - lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale; - lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale; - if SpritesData[sprR].Texture <> nil then + rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale; + rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale + end; + dec(Shift, w div 2); + DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); + + i:= Shift - lw; + while i >= -sw - lw do + begin + DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale); + dec(i, lw); + end; + + i:= Shift + w; + if SpritesData[sprR].Texture <> nil then + while i <= sw do begin - rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale; - rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale - end; - dec(Shift, w div 2); - DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale); - - i:= Shift - lw; - while i >= -sw - lw do + DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale); + inc(i, rw) + end + else + while i <= sw do begin DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale); - dec(i, lw); - end; - - i:= Shift + w; - if SpritesData[sprR].Texture <> nil then - while i <= sw do - begin - DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale); - inc(i, rw) - end - else - while i <= sw do - begin - DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale); - inc(i, lw) - end - end + inc(i, lw) + end + end end; procedure DrawWorld(Lag: LongInt); begin - if not isPaused then + if ZoomValue < zoom then begin - if ZoomValue < zoom then - begin - zoom:= zoom - 0.002 * Lag; - if ZoomValue > zoom then - zoom:= ZoomValue - end - else + zoom:= zoom - 0.002 * Lag; + if ZoomValue > zoom then + zoom:= ZoomValue + end + else if ZoomValue > zoom then begin - zoom:= zoom + 0.002 * Lag; - if ZoomValue < zoom then - zoom:= ZoomValue - end + zoom:= zoom + 0.002 * Lag; + if ZoomValue < zoom then + zoom:= ZoomValue end else ZoomValue:= zoom; @@ -622,7 +952,7 @@ //glPushMatrix; //glScalef(1.0, 1.0, 1.0); - if not isPaused then + if (not isPaused) and (GameType <> gmtRecord) then MoveCamera; if cStereoMode = smNone then @@ -653,7 +983,7 @@ DrawWorldStereo(0, rmRightEye); // detatch drawing from fbs - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, defaultFrame); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); SetScale(cDefaultZoomLevel); @@ -748,8 +1078,10 @@ exit; {$ELSE} d:= d / 5; - if rm = rmDefault then exit - else if rm = rmLeftEye then d:= -d; + if rm = rmDefault then + exit + else if rm = rmLeftEye then + d:= -d; stereoDepth:= stereoDepth + d; glMatrixMode(GL_PROJECTION); glTranslatef(d, 0, 0); @@ -763,7 +1095,8 @@ rm:= rm; // avoid hint exit; {$ELSE} - if rm = rmDefault then exit; + if rm = rmDefault then + exit; glMatrixMode(GL_PROJECTION); glTranslatef(-stereoDepth, 0, 0); glMatrixMode(GL_MODELVIEW); @@ -772,15 +1105,15 @@ end; procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); -var i, t: LongInt; +var i, t, h: LongInt; r: TSDL_Rect; tdx, tdy: Double; - s: string[15]; + s: shortstring; highlight: Boolean; smallScreenOffset, offsetX, offsetY, screenBottom: LongInt; VertexBuffer: array [0..3] of TVertex2f; begin - if (cReducedQuality and rqNoBackground) = 0 then +if (cReducedQuality and rqNoBackground) = 0 then begin // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine); @@ -792,18 +1125,20 @@ // background ChangeDepth(RM, cStereo_Sky); - if SuddenDeathDmg then Tint(SDTint, SDTint, SDTint, $FF); + if SuddenDeathDmg then + Tint(SDTint, SDTint, SDTint, $FF); DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset); ChangeDepth(RM, -cStereo_Horizon); DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset); - if SuddenDeathDmg then Tint($FF, $FF, $FF, $FF); + if SuddenDeathDmg then + Tint($FF, $FF, $FF, $FF); end; - DrawVisualGears(0); - ChangeDepth(RM, -cStereo_MidDistance); - DrawVisualGears(4); +DrawVisualGears(0); +ChangeDepth(RM, -cStereo_MidDistance); +DrawVisualGears(4); - if (cReducedQuality and rq2DWater) = 0 then +if (cReducedQuality and rq2DWater) = 0 then begin // Waves DrawWater(255, SkyOffset); @@ -816,7 +1151,7 @@ ChangeDepth(RM, -cStereo_Water_distant); DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24); end - else +else DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0); changeDepth(RM, cStereo_Land); @@ -825,6 +1160,209 @@ DrawWater(255, 0); +DrawVisualGears(1); +DrawGears; +DrawVisualGears(6); + +if SuddenDeathDmg then + DrawWater(SDWaterOpacity, 0) +else + DrawWater(WaterOpacity, 0); + + // Waves +ChangeDepth(RM, cStereo_Water_near); +DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12); + +if (cReducedQuality and rq2DWater) = 0 then + begin + //DrawWater(WaterOpacity, - offsetY div 40); + ChangeDepth(RM, cStereo_Water_near); + DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8); + if SuddenDeathDmg then + DrawWater(SDWaterOpacity, - offsetY div 20) + else + DrawWater(WaterOpacity, - offsetY div 20); + ChangeDepth(RM, cStereo_Water_near); + DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2); + if SuddenDeathDmg then + DrawWater(SDWaterOpacity, - offsetY div 10) + else + DrawWater(WaterOpacity, - offsetY div 10); + ChangeDepth(RM, cStereo_Water_near); + DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0); + end + else + DrawWaves(-1, 50, - (cWaveHeight shr 1), 0); + +// everything after this ChangeDepth will be drawn outside the screen +// note: negative parallax gears should last very little for a smooth stereo effect + ChangeDepth(RM, cStereo_Outside); + DrawVisualGears(2); + +// everything after this ResetDepth will be drawn at screen level (depth = 0) +// note: everything that needs to be readable should be on this level + ResetDepth(RM); + DrawVisualGears(3); + +{$WARNINGS OFF} +// Target +if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then + begin + with PHedgehog(CurrentHedgehog)^ do + begin + if CurAmmoType = amBee then + DrawSpriteRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) + else + DrawSpriteRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) + end + end; +{$WARNINGS ON} + +// this scale is used to keep the various widgets at the same dimension at all zoom levels +SetScale(cDefaultZoomLevel); + +// Turn time +{$IFDEF USE_TOUCH_INTERFACE} +offsetX:= cScreenHeight - 13; +{$ELSE} +offsetX:= 48; +{$ENDIF} +offsetY:= cOffsetY; +if ((TurnTimeLeft <> 0) and (TurnTimeLeft < 1000000)) or (ReadyTimeLeft <> 0) then + begin + if ReadyTimeLeft <> 0 then + i:= Succ(Pred(ReadyTimeLeft) div 1000) + else + i:= Succ(Pred(TurnTimeLeft) div 1000); + + if i>99 then + t:= 112 + else if i>9 then + t:= 96 + else + t:= 80; + DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1); + while i > 0 do + begin + dec(t, 32); + DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10); + i:= i div 10 + end; + DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0); + end; + +// Captions +DrawCaptions; + +{$IFDEF USE_TOUCH_INTERFACE} +// Draw buttons Related to the Touch interface +DrawScreenWidget(@arrowLeft); +DrawScreenWidget(@arrowRight); +DrawScreenWidget(@arrowUp); +DrawScreenWidget(@arrowDown); + +DrawScreenWidget(@fireButton); +DrawScreenWidget(@jumpWidget); +DrawScreenWidget(@AMWidget); +DrawScreenWidget(@pauseButton); +DrawScreenWidget(@utilityWidget); +{$ENDIF} + +// Teams Healths +if TeamsCount * 20 > Longword(cScreenHeight) div 7 then // take up less screen on small displays + begin + SetScale(1.5); + smallScreenOffset:= cScreenHeight div 6; + if TeamsCount * 20 > Longword(cScreenHeight) div 5 then + Tint($FF,$FF,$FF,$80); + end +else smallScreenOffset:= 0; +for t:= 0 to Pred(TeamsCount) do + with TeamsArray[t]^ do + if TeamHealth > 0 then + begin + h:= 0; + highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); + + if highlight then + Tint(Clan^.Color shl 8 or $FF); + + // draw name + DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset, NameTagTex); + + // draw flag + DrawTexture(-14, cScreenHeight + DrawHealthY + smallScreenOffset, FlagTex); + + // draw health bar + r.x:= 0; + r.y:= 0; + r.w:= 2 + TeamHealthBarWidth; + r.h:= HealthTex^.h; + DrawTextureFromRect(14, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex); + + // draw health bars right border + inc(r.x, cTeamHealthWidth + 2); + r.w:= 3; + DrawTextureFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex); + + if not highlight and (not hasGone) then + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + begin + inc(h,Hedgehogs[i].Gear^.Health); + if h < TeamHealth then DrawTexture(15 + h*TeamHealthBarWidth div TeamHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture); + end; + + // draw ai kill counter for gfAISurvival + if (GameFlags and gfAISurvival) <> 0 then + begin + DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, AIKillsTex); + end; + + // if highlighted, draw flag and other contents again to keep their colors + // this approach should be faster than drawing all borders one by one tinted or not + if highlight then + begin + if TeamsCount * 20 > Longword(cScreenHeight) div 5 then + Tint($FF,$FF,$FF,$80) + else Tint($FF, $FF, $FF, $FF); + + // draw name + r.x:= 2; + r.y:= 2; + r.w:= NameTagTex^.w - 4; + r.h:= NameTagTex^.h - 4; + DrawTextureFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex); + // draw flag + r.w:= 22; + r.h:= 15; + DrawTextureFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex); + // draw health bar + r.w:= TeamHealthBarWidth + 1; + r.h:= HealthTex^.h - 4; + DrawTextureFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex); + if not hasGone and (TeamHealth > 1) then + begin + Tint(Clan^.Color shl 8 or $FF); + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + begin + inc(h,Hedgehogs[i].Gear^.Health); + if h < TeamHealth then DrawTexture(15 + h*TeamHealthBarWidth div TeamHealth, cScreenHeight + DrawHealthY + smallScreenOffset + 1, SpritesData[sprSlider].Texture); + end; + if TeamsCount * 20 > Longword(cScreenHeight) div 5 then + Tint($FF,$FF,$FF,$80) + else Tint($FF, $FF, $FF, $FF); + end; + end; + end; +if smallScreenOffset <> 0 then + begin + SetScale(cDefaultZoomLevel); + if TeamsCount * 20 > Longword(cScreenHeight) div 5 then + Tint($FF,$FF,$FF,$FF); + end; + // Attack bar if CurrentTeam <> nil then case AttackBar of @@ -847,175 +1385,13 @@ end end; - DrawVisualGears(1); - DrawGears; - DrawVisualGears(6); - - if SuddenDeathDmg then - DrawWater(cSDWaterOpacity, 0) - else - DrawWater(cWaterOpacity, 0); - - // Waves - ChangeDepth(RM, cStereo_Water_near); - DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12); - - if (cReducedQuality and rq2DWater) = 0 then - begin - //DrawWater(cWaterOpacity, - offsetY div 40); - ChangeDepth(RM, cStereo_Water_near); - DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8); - if SuddenDeathDmg then - DrawWater(cSDWaterOpacity, - offsetY div 20) - else - DrawWater(cWaterOpacity, - offsetY div 20); - ChangeDepth(RM, cStereo_Water_near); - DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2); - if SuddenDeathDmg then - DrawWater(cSDWaterOpacity, - offsetY div 10) - else - DrawWater(cWaterOpacity, - offsetY div 10); - ChangeDepth(RM, cStereo_Water_near); - DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0); - end - else - DrawWaves(-1, 50, - (cWaveHeight shr 1), 0); - -// everything after this ChangeDepth will be drawn outside the screen -// note: negative parallax gears should last very little for a smooth stereo effect - ChangeDepth(RM, cStereo_Outside); - DrawVisualGears(2); - -// everything after this ResetDepth will be drawn at screen level (depth = 0) -// note: everything that needs to be readable should be on this level - ResetDepth(RM); - DrawVisualGears(3); - -{$WARNINGS OFF} -// Target -if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then - begin - with PHedgehog(CurrentHedgehog)^ do - begin - if CurAmmoType = amBee then - DrawRotatedF(sprTargetBee, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) - else - DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360) - end - end; -{$WARNINGS ON} - -// this scale is used to keep the various widgets at the same dimension at all zoom levels -SetScale(cDefaultZoomLevel); - -// Turn time -{$IFDEF MOBILE} -offsetX:= cScreenHeight - 13; -{$ELSE} -offsetX:= 48; -{$ENDIF} -offsetY:= cOffsetY; -if ((TurnTimeLeft <> 0) and (TurnTimeLeft < 1000000)) or (ReadyTimeLeft <> 0) then - begin - if ReadyTimeLeft <> 0 then - i:= Succ(Pred(ReadyTimeLeft) div 1000) - else - i:= Succ(Pred(TurnTimeLeft) div 1000); - - if i>99 then t:= 112 - else if i>9 then t:= 96 - else t:= 80; - DrawSprite(sprFrame, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, 1); - while i > 0 do - begin - dec(t, 32); - DrawSprite(sprBigDigit, -(cScreenWidth shr 1) + t + offsetY, cScreenHeight - offsetX, i mod 10); - i:= i div 10 - end; - DrawSprite(sprFrame, -(cScreenWidth shr 1) + t - 4 + offsetY, cScreenHeight - offsetX, 0); - end; - -// Captions -DrawCaptions; - -{$IFDEF ANDROID} -// Draw buttons Related to the Touch interface -DrawTexture(Round(-cScreenWidth*0.5 + cScreenHeight*0.02),Round((cScreenHeight*0.98)-(spritesData[sprFireButton].Height*0.4) ),spritesData[sprFireButton].Texture, 0.4); -{$ENDIF} -// Teams Healths -if TeamsCount * 20 > Longword(cScreenHeight) div 7 then // take up less screen on small displays - begin - SetScale(1.5); - smallScreenOffset:= cScreenHeight div 6; - if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80); - end -else smallScreenOffset:= 0; -for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500); - - if highlight then - Tint(Clan^.Color shl 8 or $FF); - - // draw name - DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY + smallScreenOffset, NameTagTex); - - // draw flag - DrawTexture(-14, cScreenHeight + DrawHealthY + smallScreenOffset, FlagTex); - - // draw health bar - r.x:= 0; - r.y:= 0; - r.w:= 2 + TeamHealthBarWidth; - r.h:= HealthTex^.h; - DrawFromRect(14, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex); - - // draw health bars right border - inc(r.x, cTeamHealthWidth + 2); - r.w:= 3; - DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex); - - // draw ai kill counter for gfAISurvival - if (GameFlags and gfAISurvival) <> 0 then begin - DrawTexture(TeamHealthBarWidth + 22, cScreenHeight + DrawHealthY + smallScreenOffset, - AIKillsTex); - end; - - // if highlighted, draw flag and other contents again to keep their colors - // this approach should be faster than drawing all borders one by one tinted or not - if highlight then - begin - if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80) - else Tint($FF, $FF, $FF, $FF); - - // draw name - r.x:= 2; - r.y:= 2; - r.w:= NameTagTex^.w - 4; - r.h:= NameTagTex^.h - 4; - DrawFromRect(-NameTagTex^.w - 14, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, NameTagTex); - // draw flag - r.w:= 22; - r.h:= 15; - DrawFromRect(-12, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, FlagTex); - // draw health bar - r.w:= TeamHealthBarWidth + 1; - r.h:= HealthTex^.h - 4; - DrawFromRect(16, cScreenHeight + DrawHealthY + smallScreenOffset + 2, @r, HealthTex); - end; - end; -if smallScreenOffset <> 0 then - begin - SetScale(cDefaultZoomLevel); - if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$FF); - end; // Lag alert -if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); +if isInLag then + DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12); // Wind bar -{$IFDEF MOBILE} +{$IFDEF USE_TOUCH_INTERFACE} offsetX:= cScreenHeight - 13; offsetY:= (cScreenWidth shr 1) + 74; {$ELSE} @@ -1024,7 +1400,7 @@ {$ENDIF} DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0); if WindBarWidth > 0 then - begin + begin {$WARNINGS OFF} r.x:= 8 - (RealTicks shr 6) mod 8; {$WARNINGS ON} @@ -1032,7 +1408,7 @@ r.w:= WindBarWidth; r.h:= 13; DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0); - end + end else if WindBarWidth < 0 then begin @@ -1046,102 +1422,122 @@ end; // AmmoMenu -if (AMxShift < AMWidth) or bShowAmmoMenu then ShowAmmoMenu; +if bShowAmmoMenu and ((AMState = AMHidden) or (AMState = AMHiding)) then + begin + if (AMState = AMHidden) then + AMAnimStartTime:= RealTicks + else + AMAnimStartTime:= RealTicks - (AMAnimDuration - (RealTicks - AMAnimStartTime)); + AMState:= AMShowingUp; + end; +if not(bShowAmmoMenu) and ((AMstate = AMShowing) or (AMState = AMShowingUp)) then + begin + if (AMState = AMShowing) then + AMAnimStartTime:= RealTicks + else + AMAnimStartTime:= RealTicks - (AMAnimDuration - (RealTicks - AMAnimStartTime)); + AMState:= AMHiding; + end; + +if bShowAmmoMenu or (AMState = AMHiding) then + ShowAmmoMenu; // Cursor if isCursorVisible and bShowAmmoMenu then - DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); + DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8); // Chat DrawChat; // various captions -if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture); -if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture); +if fastUntilLag then + DrawTextureCentered(0, (cScreenHeight shr 1), SyncTexture); +if isPaused then + DrawTextureCentered(0, (cScreenHeight shr 1), PauseTexture); if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then begin - if (ReadyTimeLeft = 0) and (missionTimer > 0) then dec(missionTimer, Lag); - if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 + if (ReadyTimeLeft = 0) and (missionTimer > 0) then + dec(missionTimer, Lag); + if missionTimer < 0 then + missionTimer:= 0; // avoid subtracting below 0 if missionTex <> nil then - DrawCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); + DrawTextureCentered(0, Min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); end; // fps -{$IFDEF MOBILE} -offsetX:= 8; +{$IFDEF USE_TOUCH_INTERFACE} +offsetX:= pauseButton.frame.y + pauseButton.frame.h + 12; {$ELSE} offsetX:= 10; {$ENDIF} offsetY:= cOffsetY; if (RM = rmDefault) or (RM = rmRightEye) then -begin + begin inc(Frames); if cShowFPS or (GameType = gmtDemo) then inc(CountTicks, Lag); if (GameType = gmtDemo) and (CountTicks >= 1000) then - begin - i:=GameTicks div 1000; + begin + i:= GameTicks div 1000; t:= i mod 60; s:= inttostr(t); - if t < 10 then s:= '0' + s; + if t < 10 then + s:= '0' + s; i:= i div 60; t:= i mod 60; s:= inttostr(t) + ':' + s; - if t < 10 then s:= '0' + s; + if t < 10 then + s:= '0' + s; s:= inttostr(i div 60) + ':' + s; - if timeTexture <> nil then - FreeTexture(timeTexture); - timeTexture:= nil; tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); tmpSurface:= doSurfaceConversion(tmpSurface); + FreeTexture(timeTexture); timeTexture:= Surface2Tex(tmpSurface, false); SDL_FreeSurface(tmpSurface) - end; + end; if timeTexture <> nil then DrawTexture((cScreenWidth shr 1) - 20 - timeTexture^.w - offsetY, offsetX + timeTexture^.h+5, timeTexture); if cShowFPS then - begin + begin if CountTicks >= 1000 then - begin + begin FPS:= Frames; Frames:= 0; CountTicks:= 0; s:= inttostr(FPS) + ' fps'; - if fpsTexture <> nil then - FreeTexture(fpsTexture); - fpsTexture:= nil; tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); tmpSurface:= doSurfaceConversion(tmpSurface); + FreeTexture(fpsTexture); fpsTexture:= Surface2Tex(tmpSurface, false); SDL_FreeSurface(tmpSurface) - end; + end; if fpsTexture <> nil then DrawTexture((cScreenWidth shr 1) - 60 - offsetY, offsetX, fpsTexture); - end; - - if CountTicks >= 1000 then CountTicks:= 0; + end; // lag warning (?) inc(SoundTimerTicks, Lag); end; if SoundTimerTicks >= 50 then - begin - SoundTimerTicks:= 0; - if cVolumeDelta <> 0 then - begin - str(ChangeVolume(cVolumeDelta), s); - AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume) - end - end; +begin + SoundTimerTicks:= 0; + if cVolumeDelta <> 0 then + begin + str(ChangeVolume(cVolumeDelta), s); + AddCaption(Format(trmsg[sidVolume], s), cWhiteColor, capgrpVolume); + end; + if isAudioMuted then + AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume) +end; if GameState = gsConfirm then - DrawCentered(0, (cScreenHeight shr 1), ConfirmTexture); + DrawTextureCentered(0, (cScreenHeight shr 1), ConfirmTexture); if ScreenFade <> sfNone then begin @@ -1179,44 +1575,73 @@ glEnable(GL_TEXTURE_2D); Tint($FF, $FF, $FF, $FF); - if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone + if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then + ScreenFade:= sfNone end end; +{$IFDEF USE_VIDEO_RECORDING} +// during video prerecording draw red blinking circle and text 'rec' +if flagPrerecording then + begin + if recTexture = nil then + begin + s:= 'rec'; + tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fntBig].Handle, Str2PChar(s), cWhiteColorChannels); + tmpSurface:= doSurfaceConversion(tmpSurface); + FreeTexture(recTexture); + recTexture:= Surface2Tex(tmpSurface, false); + SDL_FreeSurface(tmpSurface) + end; + DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); + + // draw red circle + glDisable(GL_TEXTURE_2D); + Tint($FF, $00, $00, Byte(Round(127*(1 + sin(SDL_GetTicks()*0.007))))); + glBegin(GL_POLYGON); + for i:= 0 to 20 do + glVertex2f(-(cScreenWidth shr 1) + 30 + sin(i*2*Pi/20)*10, 35 + cos(i*2*Pi/20)*10); + glEnd(); + Tint($FF, $FF, $FF, $FF); + glEnable(GL_TEXTURE_2D); + end; +{$ENDIF} + SetScale(zoom); // Cursor if isCursorVisible then - begin - if not bShowAmmoMenu then - begin - with CurrentHedgehog^ do - if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then - begin - if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then - DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF); - i:= GetAmmoEntry(CurrentHedgehog^)^.Pos; - with Ammoz[CurAmmoType] do - if PosCount > 1 then - DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); - end; - DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) - end - end; + begin + if not bShowAmmoMenu then + begin + with CurrentHedgehog^ do + if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then + begin + if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then + DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF); + i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos; + with Ammoz[CurAmmoType] do + if PosCount > 1 then + DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i); + end; + DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) + end + end; isFirstFrame:= false end; +var PrevSentPointTime: LongWord = 0; + procedure MoveCamera; -var EdgesDist, wdy, shs,z: LongInt; - PrevSentPointTime: LongWord = 0; +var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt; begin {$IFNDEF MOBILE} -if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus and (GameState <> gsConfirm) then +if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu))) and cHasFocus and (GameState <> gsConfirm) then uCursor.updatePosition(); {$ENDIF} z:= round(200/zoom); -if not PlacingHogs and (FollowGear <> nil) and not isCursorVisible and not bShowAmmoMenu and not fastUntilLag then - if (not autoCameraOn) or ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then +if not PlacingHogs and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and autoCameraOn then + if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then begin FollowGear:= nil; prevPoint:= CursorPoint; @@ -1232,84 +1657,103 @@ end; wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; -if WorldDy < wdy then WorldDy:= wdy; +if WorldDy < wdy then + WorldDy:= wdy; -if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; +if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then + exit; -if AMxShift < AMWidth then +if (AMState = AMShowingUp) or (AMState = AMShowing) then begin -{$IFDEF MOBILE} - if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth; - if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; - if CursorPoint.Y < cScreenHeight - AMyOffset - SlotsNum * AMSlotSize then CursorPoint.Y:= cScreenHeight - AMyOffset - SlotsNum * AMSlotSize; - if CursorPoint.Y > cScreenHeight - AMyOffset then CursorPoint.Y:= cScreenHeight - AMyOffset; +{$IFDEF USE_LANDSCAPE_AMMOMENU} + amNumOffsetX:= 0; + {$IFDEF USE_AM_NUMCOLUMN} + amNumOffsetY:= AMSlotSize; + {$ELSE} + amNumOffsetY:= 0; + {$ENDIF} {$ELSE} - if CursorPoint.X < cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMWidth + AMSlotSize; - if CursorPoint.X > cScreenWidth div 2 + AMxShift - AMxOffset then CursorPoint.X:= cScreenWidth div 2 + AMxShift - AMxOffset; - if CursorPoint.Y > AMyOffset + (SlotsNum + 1) * AMSlotSize then CursorPoint.Y:= AMyOffset + (SlotsNum + 1) * AMSlotSize; - if CursorPoint.Y < AMyOffset + AMSlotSize then CursorPoint.Y:= AMyOffset + AMSlotSize; + amNumOffsetY:= 0; + {$IFDEF USE_AM_NUMCOLUMN} + amNumOffsetX:= AMSlotSize; + {$ELSE} + amNumOffsetX:= 0; + {$ENDIF} + {$ENDIF} + if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left + CursorPoint.X:= AmmoRect.x + amNumOffsetX + 3; + if CursorPoint.X > AmmoRect.x + AmmoRect.w - 3 then//check right + CursorPoint.X:= AmmoRect.x + AmmoRect.w - 3; + if CursorPoint.Y > cScreenHeight - AmmoRect.y -amNumOffsetY - 1 then//check top + CursorPoint.Y:= cScreenHeight - AmmoRect.y - amNumOffsetY - 1; + if CursorPoint.Y < cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5) then//check bottom + CursorPoint.Y:= cScreenHeight - (AmmoRect.y + AmmoRect.h - AMSlotSize - 5); prevPoint:= CursorPoint; //if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); exit end; if isCursorVisible then -begin + begin if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then - begin + begin SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy); PrevSentPointTime:= GameTicks - end; + end; EdgesDist:= cCursorEdgesDist -end + end else EdgesDist:= cGearScrEdgesDist; // this generates the border around the screen that moves the camera when cursor is near it -if isCursorVisible or (FollowGear <> nil) then -begin +if isCursorVisible or ((FollowGear <> nil) and autoCameraOn) then + begin if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then - begin + begin WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist; CursorPoint.X:= - cScreenWidth div 2 + EdgesDist - end + end else if CursorPoint.X > cScreenWidth div 2 - EdgesDist then - begin + begin WorldDx:= WorldDx - CursorPoint.X + cScreenWidth div 2 - EdgesDist; CursorPoint.X:= cScreenWidth div 2 - EdgesDist - end; + end; shs:= min(cScreenHeight div 2 - trunc(cScreenHeight / cScaleFactor) + EdgesDist, cScreenHeight - EdgesDist); if CursorPoint.Y < shs then - begin + begin WorldDy:= WorldDy + CursorPoint.Y - shs; CursorPoint.Y:= shs; - end + end else if (CursorPoint.Y > cScreenHeight - EdgesDist) then - begin + begin WorldDy:= WorldDy + CursorPoint.Y - cScreenHeight + EdgesDist; CursorPoint.Y:= cScreenHeight - EdgesDist - end; -end + end; + end else if cHasFocus then - begin + begin WorldDx:= WorldDx - CursorPoint.X + prevPoint.X; WorldDy:= WorldDy + CursorPoint.Y - prevPoint.Y; CursorPoint.X:= 0; CursorPoint.Y:= cScreenHeight div 2; - end; + end; // this moves the camera according to CursorPoint X and Y prevPoint:= CursorPoint; //if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y); -if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024; -if WorldDy < wdy then WorldDy:= wdy; -if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024; -if WorldDx > 1024 then WorldDx:= 1024; +if WorldDy > LAND_HEIGHT + 1024 then + WorldDy:= LAND_HEIGHT + 1024; +if WorldDy < wdy then + WorldDy:= wdy; +if WorldDx < - LAND_WIDTH - 1024 then + WorldDx:= - LAND_WIDTH - 1024; +if WorldDx > 1024 then + WorldDx:= 1024; end; procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt); @@ -1318,11 +1762,10 @@ r.w:= 32; r.h:= 32; -if time = 0 then time:= 5000; +if time = 0 then + time:= 5000; missionTimer:= time; -if missionTex <> nil then - FreeTexture(missionTex); -missionTex:= nil; +FreeTexture(missionTex); if icon > -1 then begin @@ -1345,12 +1788,13 @@ procedure ShakeCamera(amount: LongInt); begin - if isCursorVisible then exit; - amount:= Max(1, round(amount*zoom/2)); - WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2)); - WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2)); - //CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2)); - //CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2)) +if isCursorVisible then + exit; +amount:= Max(1, round(amount*zoom/2)); +WorldDx:= WorldDx - amount + LongInt(random(1 + amount * 2)); +WorldDy:= WorldDy - amount + LongInt(random(1 + amount * 2)); +//CursorPoint.X:= CursorPoint.X - amount + LongInt(random(1 + amount * 2)); +//CursorPoint.Y:= CursorPoint.Y - amount + LongInt(random(1 + amount * 2)) end; @@ -1358,12 +1802,76 @@ begin if (not cHasFocus) and (GameState <> gsConfirm) then ParseCommand('quit', true); +{$IFDEF MOBILE} +// when created SDL receives an exposure event that calls UndampenAudio at full power, muting audio +exit; +{$ENDIF} + +{$IFDEF USE_VIDEO_RECORDING} +// do not change volume during prerecording as it will affect sound in video file +if not flagPrerecording then +{$ENDIF} + begin + if not cHasFocus then DampenAudio() + else UndampenAudio(); + end; +end; + +procedure SetUtilityWidgetState(ammoType: TAmmoType); +begin +{$IFDEF USE_TOUCH_INTERFACE} +if(ammoType = amNothing)then + ammoType:= CurrentHedgehog^.CurAmmoType; + +if(CurrentHedgehog <> nil)then + if (Ammoz[ammoType].Ammo.Propz and ammoprop_Timerable) <> 0 then + begin + utilityWidget.sprite:= sprTimerButton; + animateWidget(@utilityWidget, true, true); + end + else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then + begin + utilityWidget.sprite:= sprTargetButton; + animateWidget(@utilityWidget, true, true); + end + else if ammoType = amSwitch then + begin + utilityWidget.sprite:= sprTargetButton; + animateWidget(@utilityWidget, true, true); + end + else if utilityWidget.show then + animateWidget(@utilityWidget, true, false); +{$ELSE} +ammoType:= ammoType; // avoid hint +{$ENDIF} +end; + +procedure animateWidget(widget: POnScreenWidget; fade, showWidget: boolean); +begin +with widget^ do + begin + show:= showWidget; + if fade then fadeAnimStart:= RealTicks; + + with moveAnim do + begin + animate:= true; + startTime:= RealTicks; + source.x:= source.x xor target.x; //swap source <-> target + target.x:= source.x xor target.x; + source.x:= source.x xor target.x; + source.y:= source.y xor target.y; + target.y:= source.y xor target.y; + source.y:= source.y xor target.y; + end; + end; end; procedure initModule; begin fpsTexture:= nil; + recTexture:= nil; FollowGear:= nil; WindBarWidth:= 0; bShowAmmoMenu:= false; @@ -1372,6 +1880,7 @@ Frames:= 0; WorldDx:= -512; WorldDy:= -256; + PrevSentPointTime:= 0; FPS:= 0; CountTicks:= 0; @@ -1382,14 +1891,14 @@ missionTex:= nil; cOffsetY:= 0; stereoDepth:= 0; + AMState:= AMHidden; + isFirstFrame:= true; + stereoDepth:= stereoDepth; // avoid hint end; procedure freeModule; begin - stereoDepth:= stereoDepth; // avoid hint - FreeTexture(fpsTexture); - FreeTexture(timeTexture); - FreeTexture(missionTex); + ResetWorldTex(); end; end. diff -r 41b0a9955c47 -r ddcdedd3330b misc/hats_js_anim.xhtml --- a/misc/hats_js_anim.xhtml Thu Nov 24 13:44:30 2011 +0100 +++ b/misc/hats_js_anim.xhtml Sun Oct 28 13:28:23 2012 +0100 @@ -10,7 +10,7 @@ { background: url('http://hedgewars.googlecode.com/hg/share/hedgewars/Data/Themes/Nature/Sky.png') fixed no-repeat bottom left; -moz-background-size: 200%; - background-size: 200%; + background-size: 100% 100%; font-family: sans-serif; } h1 { text-shadow: 0 0 2px white; } @@ -47,6 +47,7 @@ /*var masks = ['2001suit2', '2001suit', '4gsuif', 'AkuAku', 'android', 'angel', 'anzac', 'apple', 'ash', 'Balrog', 'banana', 'Bandit', 'bat', 'beaver', 'beefeater', 'Blanka', 'BlankaToothless', 'BlueCap', 'BlueHair', 'bobby2v', 'bobby', 'Bob', 'BrainSlugMouth', 'BrainSlug', 'britishpithhelmet', 'britmedic', 'britsapper', 'Bub', 'Bunny', 'bushhider', 'charlesdegaulle', 'charmander', 'chef', 'chikorita', 'Chunli', 'clown-copper', 'clown-crossed', 'clown', 'Coonskin3', 'Cororon', 'Cowboy', 'crown', 'cyborg', 'darthvader', 'Deer', 'desertgrenadier01', 'desertgrenadier02', 'desertgrenadier04', 'desertgrenadier05', 'desertgrenadierofficer', 'desertmedic', 'desertsapper1', 'desertsapper2', 'diglett', 'Disguise', 'Dragon', 'dwarf', 'eastertop', 'Elvis', 'Eva_00b', 'Eva_00y', 'Falcon', 'frenchwwigasmask', 'frenchwwihelmet', 'Gasmask', 'Geordi', 'germanwiimedichelmet', 'germanwwihelmetmustache', 'germanwwiipithhelmetdes', 'germanwwitankhelmet', 'Glasses', 'GreenCap', 'GreenHair', 'grenadier1', 'GreyHair', 'Guile', 'hedgehogk', 'HogInTheHat', 'hogpharoah', 'Honda', 'IndianChief', 'infernalhorns', 'InfernalHorns', 'Jason', 'jigglypuff', 'judo', 'junior', 'Ken', 'KirbyMask', 'kiss_criss', 'kiss_frehley', 'kiss_simmons', 'kiss_stanley', 'knight', 'Kululun', 'Ladle', 'lambda', 'Laminaria', 'laurel', 'lemon', 'link', 'lugia', 'Luigi', 'Mario', 'MegaHogX', 'metalband', 'mexicansunbrero', 'mickey_ears', 'Moose', 'mp3', 'mudkip', 'Mummy', 'naruto', 'NinjaFull', 'NinjaStraight', 'NinjaTriangle', 'OldMan', 'OrangeHair', 'orange', 'Pantsu', 'Pig', 'pikachu', 'PinkHair', 'pinksunhat', 'pirate_jack_bandana', 'pirate_jack', 'plainpith', 'Plunger', 'policecap', 'porkey', 'PrincessDaisy', 'PrincessPeach', 'Pumpkin_Hat', 'PurpleHair', 'quotecap', 'Rain', 'Rambo', 'rasta', 'RedCap', 'RedHair', 'RobinHood', 'royalguard', 'RSR', 'Ryu', 'Samurai', 'Samus', 'Santa', 'SauceBoatSilver', 'ShaggyYeti', 'sheep', 'ShortHair_Black', 'ShortHair_Brown', 'ShortHair_Grey', 'ShortHair_Red', 'ShortHair_Yellow', 'Skull', 'Sleepwalker', 'slowpoke', 'Sniper', 'Sonic', 'sovietcomrade2', 'sovietcomrade', 'SparkleSuperFun', 'SparkssHelmet', 'spartan', 'spcartman', 'spidey', 'spkenny', 'spkyle', 'spstan', 'squirtle', 'sth_AmyClassic', 'sth_Amy', 'sth_Eggman', 'sth_Knux', 'sth_Metal', 'sth_Shadow', 'sth_Sonic', 'sth_Super', 'sth_Tails', 'stormcloud', 'stormtrooper', 'StrawHatEyes', 'StrawHatFacial', 'StrawHat', 'Sunglasses', 'SunWukong', 'Teacup', 'Teapot', 'terminatorc', 'Terminator_Glasses', 'thug', 'Toad', 'tophats', 'touhou_chen', 'touhou_marisa', 'touhou_patchouli', 'touhou_remelia', 'touhou_suwako', 'touhou_yukari', 'trenchgrenadier1', 'trenchgrenadier2', 'trenchgrenadier3', 'ushanka', 'vampirichog', 'Vega', 'venom', 'Viking', 'voltorb', 'Wario', 'WhySoSerious', 'WizardHat', 'YellowCap', 'YellowHair', 'Zombi'];*/ var masks = []; var themes = { +"Cave":1, "Golf":1, "Stage":1, "Island":0, diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/default.mode1v3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/default.mode1v3 Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1369 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCProjectFormatConflictsModule + Name + Project Format Conflicts List + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + BundleLoadPath + + MaxInstances + n + Module + XCSnapshotModule + Name + Snapshots Tool + + + BundlePath + /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources + Description + DefaultDescriptionKey + DockingSystemVisible + + Extension + mode1v3 + FavBarConfig + + PBXProjectModuleGUID + 611E0B7211FA8F650077A41E + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.mode1v3 + MajorVersion + 33 + MinorVersion + 0 + Name + Default + Notifications + + OpenEditors + + PerspectiveWidths + + -1 + -1 + + Perspectives + + + ChosenToolbarItems + + active-combo-popup + active-executable-popup + NSToolbarFlexibleSpaceItem + debugger-enable-breakpoints + buildOrClean + build-and-go + clean-target + com.apple.ide.PBXToolbarStopButton + NSToolbarFlexibleSpaceItem + + ControllerClassBaseName + + IconName + WindowOfProjectWithEditor + Identifier + perspective.project + IsVertical + + Layout + + + BecomeActive + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 0867D691FE84028FC02AAC07 + 08FB77AEFE84172EC02AAC07 + 1C37FBAC04509CD000000102 + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 445}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 463}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 586 569 788 504 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 203pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20306471E060097A5F4 + PBXProjectModuleLabel + ftconfig.h + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CE0B20406471E060097A5F4 + PBXProjectModuleLabel + ftconfig.h + _historyCapacity + 0 + bookmark + 619599D11364E6FE00B429B6 + history + + 611E0E5811FA92660077A41E + 619599AE1364E63300B429B6 + 619599C11364E6C400B429B6 + + + SplitCount + 1 + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {580, 211}} + RubberWindowFrame + 586 569 788 504 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 211pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CE0B20506471E060097A5F4 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{0, 216}, {580, 247}} + RubberWindowFrame + 586 569 788 504 0 0 1920 1178 + + Module + XCDetailModule + Proportion + 247pt + + + Proportion + 580pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDetailModule + + TableOfContents + + 619599D21364E6FE00B429B6 + 1CE0B1FE06471DED0097A5F4 + 619599D31364E6FE00B429B6 + 1CE0B20306471E060097A5F4 + 1CE0B20506471E060097A5F4 + + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarConfiguration + xcode.toolbar.config.defaultV3 + + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.morph + IsVertical + 0 + Layout + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + + PBXProjectModuleGUID + 11E0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 186 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 29B97314FDCFA39411CA2CEA + 1C37FABC05509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {186, 337}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 1 + XCSharingToken + com.apple.Xcode.GFSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {203, 355}} + GroupTreeTableConfiguration + + MainColumn + 186 + + RubberWindowFrame + 373 269 690 397 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 100% + + + Name + Morph + PreferredWidth + 300 + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + + TableOfContents + + 11E0B1FE06471DED0097A5F4 + + ToolbarConfiguration + xcode.toolbar.config.default.shortV3 + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' + StatusbarIsVisible + + TimeStamp + 0.0 + ToolbarConfigUserDefaultsMinorVersion + 2 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? + WindowJustification + 5 + WindowOrderList + + 611E0B7311FA8F650077A41E + /Users/vittorio/hedgewars/trunk/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj + + WindowString + 586 569 788 504 0 0 1920 1178 + WindowToolsV3 + + + FirstTimeWindowDisplayed + + Identifier + windowTool.build + IsVertical + + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528F0623707200166675 + PBXProjectModuleLabel + + StatusBarVisibility + + + GeometryConfiguration + + Frame + {{0, 0}, {1145, 432}} + RubberWindowFrame + 1167 248 1145 714 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 432pt + + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build Results + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1011 + + GeometryConfiguration + + Frame + {{0, 437}, {1145, 236}} + RubberWindowFrame + 1167 248 1145 714 0 0 1920 1178 + + Module + PBXBuildResultsModule + Proportion + 236pt + + + Proportion + 673pt + + + Name + Build Results + ServiceClasses + + PBXBuildResultsModule + + StatusbarIsVisible + + TableOfContents + + 611E0B7311FA8F650077A41E + 619599D41364E6FE00B429B6 + 1CD0528F0623707200166675 + XCMainBuildResultsModuleGUID + + ToolbarConfiguration + xcode.toolbar.config.buildV3 + WindowContentMinSize + 486 300 + WindowString + 1167 248 1145 714 0 0 1920 1178 + WindowToolGUID + 611E0B7311FA8F650077A41E + WindowToolIsVisible + + + + Identifier + windowTool.debugger + Layout + + + Dock + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {317, 164}} + {{317, 0}, {377, 164}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {694, 164}} + {{0, 164}, {694, 216}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1C162984064C10D400B95A72 + PBXProjectModuleLabel + Debug - GLUTExamples (Underwater) + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 0}, {694, 380}} + RubberWindowFrame + 321 238 694 422 0 0 1440 878 + + Module + PBXDebugSessionModule + Proportion + 100% + + + Proportion + 100% + + + Name + Debugger + ServiceClasses + + PBXDebugSessionModule + + StatusbarIsVisible + 1 + TableOfContents + + 1CD10A99069EF8BA00B06720 + 1C0AD2AB069F1E9B00FABCE6 + 1C162984064C10D400B95A72 + 1C0AD2AC069F1E9B00FABCE6 + + ToolbarConfiguration + xcode.toolbar.config.debugV3 + WindowString + 321 238 694 422 0 0 1440 878 + WindowToolGUID + 1CD10A99069EF8BA00B06720 + WindowToolIsVisible + 0 + + + Identifier + windowTool.find + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CD0528D0623707200166675 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {781, 167}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 50% + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{8, 0}, {773, 254}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 50% + + + Proportion + 428pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C530D57069F1CE1000CFCEE + 1C530D58069F1CE1000CFCEE + 1C530D59069F1CE1000CFCEE + 1CDD528C0622207200134675 + 1C530D5A069F1CE1000CFCEE + 1CE0B1FE06471DED0097A5F4 + 1CD0528E0623707200166675 + + WindowString + 62 385 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + 0 + + + Identifier + MENUSEPARATOR + + + Identifier + windowTool.debuggerConsole + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAAC065D492600B07095 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {650, 250}} + RubberWindowFrame + 516 632 650 250 0 0 1680 1027 + + Module + PBXDebugCLIModule + Proportion + 209pt + + + Proportion + 209pt + + + Name + Debugger Console + ServiceClasses + + PBXDebugCLIModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAAD065D492600B07095 + 1C78EAAE065D492600B07095 + 1C78EAAC065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.consoleV3 + WindowString + 650 41 650 250 0 0 1280 1002 + WindowToolGUID + 1C78EAAD065D492600B07095 + WindowToolIsVisible + 0 + + + Identifier + windowTool.snapshots + Layout + + + Dock + + + Module + XCSnapshotModule + Proportion + 100% + + + Proportion + 100% + + + Name + Snapshots + ServiceClasses + + XCSnapshotModule + + StatusbarIsVisible + Yes + ToolbarConfiguration + xcode.toolbar.config.snapshots + WindowString + 315 824 300 550 0 0 1440 878 + WindowToolIsVisible + Yes + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.0950012207031 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + Identifier + windowTool.breakpoints + IsVertical + 0 + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 0 + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 3 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + 1 + TableOfContents + + 1CDDB66807F98D9800BB5817 + 1CDDB66907F98D9800BB5817 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpointsV3 + WindowString + 315 424 744 409 0 0 1440 878 + WindowToolGUID + 1CDDB66807F98D9800BB5817 + WindowToolIsVisible + 1 + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimatorV3 + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 100% + + + Proportion + 100% + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.projectFormatConflicts + Layout + + + Dock + + + Module + XCProjectFormatConflictsModule + Proportion + 100% + + + Proportion + 100% + + + Name + Project Format Conflicts + ServiceClasses + + XCProjectFormatConflictsModule + + StatusbarIsVisible + 0 + WindowContentMinSize + 450 300 + WindowString + 50 850 472 307 0 0 1440 877 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {374, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {630, 331}} + MembersFrame + {{0, 105}, {374, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 97 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 385 179 630 352 0 0 1440 878 + + Module + PBXClassBrowserModule + Proportion + 332pt + + + Proportion + 332pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C0AD2AF069F1E9B00FABCE6 + 1C0AD2B0069F1E9B00FABCE6 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 385 179 630 352 0 0 1440 878 + WindowToolGUID + 1C0AD2AF069F1E9B00FABCE6 + WindowToolIsVisible + 0 + + + Identifier + windowTool.refactoring + IncludeInToolsMenu + 0 + Layout + + + Dock + + + BecomeActive + 1 + GeometryConfiguration + + Frame + {0, 0}, {500, 335} + RubberWindowFrame + {0, 0}, {500, 335} + + Module + XCRefactoringModule + Proportion + 100% + + + Proportion + 100% + + + Name + Refactoring + ServiceClasses + + XCRefactoringModule + + WindowString + 200 200 500 356 0 0 1920 1200 + + + + diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/default.pbxuser --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/default.pbxuser Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,165 @@ +// !$*UTF8*$! +{ + 0867D690FE84028FC02AAC07 /* Project object */ = { + activeBuildConfigurationName = Release; + activeSDKPreference = iphoneos4.2; + activeTarget = D2AAC07D0554694100DB518D /* libFreetype */; + addToTargets = ( + D2AAC07D0554694100DB518D /* libFreetype */, + ); + codeSenseManager = 611E0AC211FA8EB70077A41E /* Code sense */; + perUserDictionary = { + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 341, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 301, + 60, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 325379832; + PBXWorkspaceStateSaveDate = 325379832; + }; + perUserProjectItems = { + 611E0E5811FA92660077A41E /* PBXTextBookmark */ = 611E0E5811FA92660077A41E /* PBXTextBookmark */; + 619599AE1364E63300B429B6 /* PBXTextBookmark */ = 619599AE1364E63300B429B6 /* PBXTextBookmark */; + 619599C11364E6C400B429B6 /* PBXTextBookmark */ = 619599C11364E6C400B429B6 /* PBXTextBookmark */; + 619599D11364E6FE00B429B6 /* PBXTextBookmark */ = 619599D11364E6FE00B429B6 /* PBXTextBookmark */; + }; + sourceControlManager = 611E0AC111FA8EB70077A41E /* Source Control */; + userBuildSettings = { + }; + }; + 611E0AC111FA8EB70077A41E /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + repositoryNamesForRoots = { + "" = ""; + }; + }; + }; + 611E0AC211FA8EB70077A41E /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + 611E0AC611FA8F610077A41E /* ftconfig.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {551, 8010}}"; + sepNavSelRange = "{14485, 0}"; + sepNavVisRange = "{14279, 398}"; + sepNavWindowFrame = "{{1172, 58}, {1078, 737}}"; + }; + }; + 611E0AC811FA8F610077A41E /* ftmodule.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {530, 540}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 593}"; + sepNavWindowFrame = "{{846, 195}, {1078, 737}}"; + }; + }; + 611E0B9D11FA8FA50077A41E /* ftbase.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1084, 540}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRange = "{0, 1416}"; + sepNavWindowFrame = "{{130, 223}, {1081, 845}}"; + }; + }; + 611E0BB111FA8FA50077A41E /* ftoutln.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {551, 16755}}"; + sepNavSelRange = "{4755, 0}"; + sepNavVisRange = "{4575, 410}"; + }; + }; + 611E0CC111FA8FA50077A41E /* ttgload.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {829, 32040}}"; + sepNavSelRange = "{52031, 0}"; + sepNavVisRange = "{51255, 1537}"; + sepNavWindowFrame = "{{130, 250}, {888, 818}}"; + }; + }; + 611E0E5811FA92660077A41E /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 611E0AC811FA8F610077A41E /* ftmodule.h */; + name = "ftmodule.h: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 593; + vrLoc = 0; + }; + 619599AE1364E63300B429B6 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 611E0BB111FA8FA50077A41E /* ftoutln.c */; + name = "ftoutln.c: 130"; + rLen = 0; + rLoc = 4755; + rType = 0; + vrLen = 410; + vrLoc = 4575; + }; + 619599C11364E6C400B429B6 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; + name = "ftconfig.h: 351"; + rLen = 0; + rLoc = 14485; + rType = 0; + vrLen = 398; + vrLoc = 14279; + }; + 619599D11364E6FE00B429B6 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; + name = "ftconfig.h: 351"; + rLen = 0; + rLoc = 14485; + rType = 0; + vrLen = 398; + vrLoc = 14279; + }; + D2AAC07D0554694100DB518D /* libFreetype */ = { + activeExec = 0; + }; +} diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/libfreetype/Xcode-iOS/Freetype.xcodeproj/project.pbxproj Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1161 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 611E0B1C11FA8F610077A41E /* ftconfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; }; + 611E0B1D11FA8F610077A41E /* ftheader.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC711FA8F610077A41E /* ftheader.h */; }; + 611E0B1E11FA8F610077A41E /* ftmodule.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC811FA8F610077A41E /* ftmodule.h */; }; + 611E0B1F11FA8F610077A41E /* ftoption.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC911FA8F610077A41E /* ftoption.h */; }; + 611E0B2011FA8F610077A41E /* ftstdlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACA11FA8F610077A41E /* ftstdlib.h */; }; + 611E0B2111FA8F610077A41E /* freetype.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACB11FA8F610077A41E /* freetype.h */; }; + 611E0B2211FA8F610077A41E /* ftadvanc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACC11FA8F610077A41E /* ftadvanc.h */; }; + 611E0B2311FA8F610077A41E /* ftbbox.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACD11FA8F610077A41E /* ftbbox.h */; }; + 611E0B2411FA8F610077A41E /* ftbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACE11FA8F610077A41E /* ftbdf.h */; }; + 611E0B2511FA8F610077A41E /* ftbitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACF11FA8F610077A41E /* ftbitmap.h */; }; + 611E0B2611FA8F610077A41E /* ftcache.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD011FA8F610077A41E /* ftcache.h */; }; + 611E0B2711FA8F610077A41E /* ftchapters.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD111FA8F610077A41E /* ftchapters.h */; }; + 611E0B2811FA8F610077A41E /* ftcid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD211FA8F610077A41E /* ftcid.h */; }; + 611E0B2911FA8F610077A41E /* fterrdef.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD311FA8F610077A41E /* fterrdef.h */; }; + 611E0B2A11FA8F610077A41E /* fterrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD411FA8F610077A41E /* fterrors.h */; }; + 611E0B2B11FA8F610077A41E /* ftgasp.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD511FA8F610077A41E /* ftgasp.h */; }; + 611E0B2C11FA8F610077A41E /* ftglyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD611FA8F610077A41E /* ftglyph.h */; }; + 611E0B2D11FA8F610077A41E /* ftgxval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD711FA8F610077A41E /* ftgxval.h */; }; + 611E0B2E11FA8F610077A41E /* ftgzip.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD811FA8F610077A41E /* ftgzip.h */; }; + 611E0B2F11FA8F610077A41E /* ftimage.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD911FA8F610077A41E /* ftimage.h */; }; + 611E0B3011FA8F610077A41E /* ftincrem.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADA11FA8F610077A41E /* ftincrem.h */; }; + 611E0B3111FA8F610077A41E /* ftlcdfil.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADB11FA8F610077A41E /* ftlcdfil.h */; }; + 611E0B3211FA8F610077A41E /* ftlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADC11FA8F610077A41E /* ftlist.h */; }; + 611E0B3311FA8F610077A41E /* ftlzw.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADD11FA8F610077A41E /* ftlzw.h */; }; + 611E0B3411FA8F610077A41E /* ftmac.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADE11FA8F610077A41E /* ftmac.h */; }; + 611E0B3511FA8F610077A41E /* ftmm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADF11FA8F610077A41E /* ftmm.h */; }; + 611E0B3611FA8F610077A41E /* ftmodapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE011FA8F610077A41E /* ftmodapi.h */; }; + 611E0B3711FA8F610077A41E /* ftmoderr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE111FA8F610077A41E /* ftmoderr.h */; }; + 611E0B3811FA8F610077A41E /* ftotval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE211FA8F610077A41E /* ftotval.h */; }; + 611E0B3911FA8F610077A41E /* ftoutln.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE311FA8F610077A41E /* ftoutln.h */; }; + 611E0B3A11FA8F610077A41E /* ftpfr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE411FA8F610077A41E /* ftpfr.h */; }; + 611E0B3B11FA8F610077A41E /* ftrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE511FA8F610077A41E /* ftrender.h */; }; + 611E0B3C11FA8F610077A41E /* ftsizes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE611FA8F610077A41E /* ftsizes.h */; }; + 611E0B3D11FA8F610077A41E /* ftsnames.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE711FA8F610077A41E /* ftsnames.h */; }; + 611E0B3E11FA8F610077A41E /* ftstroke.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE811FA8F610077A41E /* ftstroke.h */; }; + 611E0B3F11FA8F610077A41E /* ftsynth.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE911FA8F610077A41E /* ftsynth.h */; }; + 611E0B4011FA8F610077A41E /* ftsystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEA11FA8F610077A41E /* ftsystem.h */; }; + 611E0B4111FA8F610077A41E /* fttrigon.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEB11FA8F610077A41E /* fttrigon.h */; }; + 611E0B4211FA8F610077A41E /* fttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEC11FA8F610077A41E /* fttypes.h */; }; + 611E0B4311FA8F610077A41E /* ftwinfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AED11FA8F610077A41E /* ftwinfnt.h */; }; + 611E0B4411FA8F610077A41E /* ftxf86.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEE11FA8F610077A41E /* ftxf86.h */; }; + 611E0B4511FA8F610077A41E /* autohint.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF011FA8F610077A41E /* autohint.h */; }; + 611E0B4611FA8F610077A41E /* ftcalc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF111FA8F610077A41E /* ftcalc.h */; }; + 611E0B4711FA8F610077A41E /* ftdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF211FA8F610077A41E /* ftdebug.h */; }; + 611E0B4811FA8F610077A41E /* ftdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF311FA8F610077A41E /* ftdriver.h */; }; + 611E0B4911FA8F610077A41E /* ftgloadr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF411FA8F610077A41E /* ftgloadr.h */; }; + 611E0B4A11FA8F610077A41E /* ftmemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF511FA8F610077A41E /* ftmemory.h */; }; + 611E0B4B11FA8F610077A41E /* ftobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF611FA8F610077A41E /* ftobjs.h */; }; + 611E0B4C11FA8F610077A41E /* ftpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF711FA8F610077A41E /* ftpic.h */; }; + 611E0B4D11FA8F610077A41E /* ftrfork.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF811FA8F610077A41E /* ftrfork.h */; }; + 611E0B4E11FA8F610077A41E /* ftserv.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF911FA8F610077A41E /* ftserv.h */; }; + 611E0B4F11FA8F610077A41E /* ftstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFA11FA8F610077A41E /* ftstream.h */; }; + 611E0B5011FA8F610077A41E /* fttrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFB11FA8F610077A41E /* fttrace.h */; }; + 611E0B5111FA8F610077A41E /* ftvalid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFC11FA8F610077A41E /* ftvalid.h */; }; + 611E0B5211FA8F610077A41E /* internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFD11FA8F610077A41E /* internal.h */; }; + 611E0B5311FA8F610077A41E /* pcftypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFE11FA8F610077A41E /* pcftypes.h */; }; + 611E0B5411FA8F610077A41E /* psaux.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFF11FA8F610077A41E /* psaux.h */; }; + 611E0B5511FA8F610077A41E /* pshints.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0011FA8F610077A41E /* pshints.h */; }; + 611E0B5611FA8F610077A41E /* svbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0211FA8F610077A41E /* svbdf.h */; }; + 611E0B5711FA8F610077A41E /* svcid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0311FA8F610077A41E /* svcid.h */; }; + 611E0B5811FA8F610077A41E /* svgldict.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0411FA8F610077A41E /* svgldict.h */; }; + 611E0B5911FA8F610077A41E /* svgxval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0511FA8F610077A41E /* svgxval.h */; }; + 611E0B5A11FA8F610077A41E /* svkern.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0611FA8F610077A41E /* svkern.h */; }; + 611E0B5B11FA8F610077A41E /* svmm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0711FA8F610077A41E /* svmm.h */; }; + 611E0B5C11FA8F610077A41E /* svotval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0811FA8F610077A41E /* svotval.h */; }; + 611E0B5D11FA8F610077A41E /* svpfr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0911FA8F610077A41E /* svpfr.h */; }; + 611E0B5E11FA8F610077A41E /* svpostnm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0A11FA8F610077A41E /* svpostnm.h */; }; + 611E0B5F11FA8F610077A41E /* svpscmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0B11FA8F610077A41E /* svpscmap.h */; }; + 611E0B6011FA8F610077A41E /* svpsinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0C11FA8F610077A41E /* svpsinfo.h */; }; + 611E0B6111FA8F610077A41E /* svsfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0D11FA8F610077A41E /* svsfnt.h */; }; + 611E0B6211FA8F610077A41E /* svttcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0E11FA8F610077A41E /* svttcmap.h */; }; + 611E0B6311FA8F610077A41E /* svtteng.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0F11FA8F610077A41E /* svtteng.h */; }; + 611E0B6411FA8F610077A41E /* svttglyf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1011FA8F610077A41E /* svttglyf.h */; }; + 611E0B6511FA8F610077A41E /* svwinfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1111FA8F610077A41E /* svwinfnt.h */; }; + 611E0B6611FA8F610077A41E /* svxf86nm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1211FA8F610077A41E /* svxf86nm.h */; }; + 611E0B6711FA8F610077A41E /* sfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1311FA8F610077A41E /* sfnt.h */; }; + 611E0B6811FA8F610077A41E /* t1types.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1411FA8F610077A41E /* t1types.h */; }; + 611E0B6911FA8F610077A41E /* tttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1511FA8F610077A41E /* tttypes.h */; }; + 611E0B6A11FA8F610077A41E /* t1tables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1611FA8F610077A41E /* t1tables.h */; }; + 611E0B6B11FA8F610077A41E /* ttnameid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1711FA8F610077A41E /* ttnameid.h */; }; + 611E0B6C11FA8F610077A41E /* tttables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1811FA8F610077A41E /* tttables.h */; }; + 611E0B6D11FA8F610077A41E /* tttags.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1911FA8F610077A41E /* tttags.h */; }; + 611E0B6E11FA8F610077A41E /* ttunpat.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1A11FA8F610077A41E /* ttunpat.h */; }; + 611E0B6F11FA8F610077A41E /* ft2build.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1B11FA8F610077A41E /* ft2build.h */; }; + 611E0D0611FA8FA50077A41E /* basepic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9911FA8FA50077A41E /* basepic.c */; }; + 611E0D0711FA8FA50077A41E /* basepic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B9A11FA8FA50077A41E /* basepic.h */; }; + 611E0D0811FA8FA50077A41E /* ftadvanc.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9B11FA8FA50077A41E /* ftadvanc.c */; }; + 611E0D0911FA8FA50077A41E /* ftapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9C11FA8FA50077A41E /* ftapi.c */; }; + 611E0D0A11FA8FA50077A41E /* ftbase.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9D11FA8FA50077A41E /* ftbase.c */; }; + 611E0D0B11FA8FA50077A41E /* ftbase.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B9E11FA8FA50077A41E /* ftbase.h */; }; + 611E0D0C11FA8FA50077A41E /* ftbbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9F11FA8FA50077A41E /* ftbbox.c */; }; + 611E0D0E11FA8FA50077A41E /* ftbitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA111FA8FA50077A41E /* ftbitmap.c */; }; + 611E0D0F11FA8FA50077A41E /* ftcalc.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA211FA8FA50077A41E /* ftcalc.c */; }; + 611E0D1111FA8FA50077A41E /* ftdbgmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA411FA8FA50077A41E /* ftdbgmem.c */; }; + 611E0D1211FA8FA50077A41E /* ftdebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA511FA8FA50077A41E /* ftdebug.c */; }; + 611E0D1511FA8FA50077A41E /* ftgloadr.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA811FA8FA50077A41E /* ftgloadr.c */; }; + 611E0D1611FA8FA50077A41E /* ftglyph.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA911FA8FA50077A41E /* ftglyph.c */; }; + 611E0D1811FA8FA50077A41E /* ftinit.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BAB11FA8FA50077A41E /* ftinit.c */; }; + 611E0D1C11FA8FA50077A41E /* ftobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BAF11FA8FA50077A41E /* ftobjs.c */; }; + 611E0D1E11FA8FA50077A41E /* ftoutln.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB111FA8FA50077A41E /* ftoutln.c */; }; + 611E0D2111FA8FA50077A41E /* ftpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB411FA8FA50077A41E /* ftpic.c */; }; + 611E0D2211FA8FA50077A41E /* ftrfork.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB511FA8FA50077A41E /* ftrfork.c */; }; + 611E0D2311FA8FA50077A41E /* ftsnames.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB611FA8FA50077A41E /* ftsnames.c */; }; + 611E0D2411FA8FA50077A41E /* ftstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB711FA8FA50077A41E /* ftstream.c */; }; + 611E0D2511FA8FA50077A41E /* ftstroke.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB811FA8FA50077A41E /* ftstroke.c */; }; + 611E0D2611FA8FA50077A41E /* ftsynth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB911FA8FA50077A41E /* ftsynth.c */; }; + 611E0D2711FA8FA50077A41E /* ftsystem.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBA11FA8FA50077A41E /* ftsystem.c */; }; + 611E0D2811FA8FA50077A41E /* fttrigon.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBB11FA8FA50077A41E /* fttrigon.c */; }; + 611E0D2A11FA8FA50077A41E /* ftutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBD11FA8FA50077A41E /* ftutil.c */; }; + 611E0D4411FA8FA50077A41E /* cff.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDA11FA8FA50077A41E /* cff.c */; }; + 611E0D4511FA8FA50077A41E /* cffcmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDB11FA8FA50077A41E /* cffcmap.c */; }; + 611E0D4611FA8FA50077A41E /* cffcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDC11FA8FA50077A41E /* cffcmap.h */; }; + 611E0D4711FA8FA50077A41E /* cffdrivr.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDD11FA8FA50077A41E /* cffdrivr.c */; }; + 611E0D4811FA8FA50077A41E /* cffdrivr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDE11FA8FA50077A41E /* cffdrivr.h */; }; + 611E0D4911FA8FA50077A41E /* cfferrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDF11FA8FA50077A41E /* cfferrs.h */; }; + 611E0D4A11FA8FA50077A41E /* cffgload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE011FA8FA50077A41E /* cffgload.c */; }; + 611E0D4B11FA8FA50077A41E /* cffgload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE111FA8FA50077A41E /* cffgload.h */; }; + 611E0D4C11FA8FA50077A41E /* cffload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE211FA8FA50077A41E /* cffload.c */; }; + 611E0D4D11FA8FA50077A41E /* cffload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE311FA8FA50077A41E /* cffload.h */; }; + 611E0D4E11FA8FA50077A41E /* cffobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE411FA8FA50077A41E /* cffobjs.c */; }; + 611E0D4F11FA8FA50077A41E /* cffobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE511FA8FA50077A41E /* cffobjs.h */; }; + 611E0D5011FA8FA50077A41E /* cffparse.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE611FA8FA50077A41E /* cffparse.c */; }; + 611E0D5111FA8FA50077A41E /* cffparse.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE711FA8FA50077A41E /* cffparse.h */; }; + 611E0D5211FA8FA50077A41E /* cffpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE811FA8FA50077A41E /* cffpic.c */; }; + 611E0D5311FA8FA50077A41E /* cffpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE911FA8FA50077A41E /* cffpic.h */; }; + 611E0D5411FA8FA50077A41E /* cfftoken.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BEA11FA8FA50077A41E /* cfftoken.h */; }; + 611E0D5511FA8FA50077A41E /* cfftypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BEB11FA8FA50077A41E /* cfftypes.h */; }; + 611E0DC911FA8FA50077A41E /* pshalgo.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6811FA8FA50077A41E /* pshalgo.c */; }; + 611E0DCA11FA8FA50077A41E /* pshalgo.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6911FA8FA50077A41E /* pshalgo.h */; }; + 611E0DCB11FA8FA50077A41E /* pshglob.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6A11FA8FA50077A41E /* pshglob.c */; }; + 611E0DCC11FA8FA50077A41E /* pshglob.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6B11FA8FA50077A41E /* pshglob.h */; }; + 611E0DCD11FA8FA50077A41E /* pshinter.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6C11FA8FA50077A41E /* pshinter.c */; }; + 611E0DCE11FA8FA50077A41E /* pshmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6D11FA8FA50077A41E /* pshmod.c */; }; + 611E0DCF11FA8FA50077A41E /* pshmod.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6E11FA8FA50077A41E /* pshmod.h */; }; + 611E0DD011FA8FA50077A41E /* pshnterr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6F11FA8FA50077A41E /* pshnterr.h */; }; + 611E0DD111FA8FA50077A41E /* pshpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7011FA8FA50077A41E /* pshpic.c */; }; + 611E0DD211FA8FA50077A41E /* pshpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7111FA8FA50077A41E /* pshpic.h */; }; + 611E0DD311FA8FA50077A41E /* pshrec.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7211FA8FA50077A41E /* pshrec.c */; }; + 611E0DD411FA8FA50077A41E /* pshrec.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7311FA8FA50077A41E /* pshrec.h */; }; + 611E0DD511FA8FA50077A41E /* psmodule.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7511FA8FA50077A41E /* psmodule.c */; }; + 611E0DD611FA8FA50077A41E /* psmodule.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7611FA8FA50077A41E /* psmodule.h */; }; + 611E0DD711FA8FA50077A41E /* psnamerr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7711FA8FA50077A41E /* psnamerr.h */; }; + 611E0DD811FA8FA50077A41E /* psnames.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7811FA8FA50077A41E /* psnames.c */; }; + 611E0DD911FA8FA50077A41E /* pspic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7911FA8FA50077A41E /* pspic.c */; }; + 611E0DDA11FA8FA50077A41E /* pspic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7A11FA8FA50077A41E /* pspic.h */; }; + 611E0DDB11FA8FA50077A41E /* pstables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7B11FA8FA50077A41E /* pstables.h */; }; + 611E0DDC11FA8FA50077A41E /* ftmisc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7D11FA8FA50077A41E /* ftmisc.h */; }; + 611E0DDD11FA8FA50077A41E /* ftraster.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7E11FA8FA50077A41E /* ftraster.c */; }; + 611E0DDE11FA8FA50077A41E /* ftraster.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7F11FA8FA50077A41E /* ftraster.h */; }; + 611E0DDF11FA8FA50077A41E /* ftrend1.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8011FA8FA50077A41E /* ftrend1.c */; }; + 611E0DE011FA8FA50077A41E /* ftrend1.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8111FA8FA50077A41E /* ftrend1.h */; }; + 611E0DE111FA8FA50077A41E /* raster.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8211FA8FA50077A41E /* raster.c */; }; + 611E0DE211FA8FA50077A41E /* rasterrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8311FA8FA50077A41E /* rasterrs.h */; }; + 611E0DE311FA8FA50077A41E /* rastpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8411FA8FA50077A41E /* rastpic.c */; }; + 611E0DE411FA8FA50077A41E /* rastpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8511FA8FA50077A41E /* rastpic.h */; }; + 611E0DE511FA8FA50077A41E /* sfdriver.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8711FA8FA50077A41E /* sfdriver.c */; }; + 611E0DE611FA8FA50077A41E /* sfdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8811FA8FA50077A41E /* sfdriver.h */; }; + 611E0DE711FA8FA50077A41E /* sferrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8911FA8FA50077A41E /* sferrors.h */; }; + 611E0DE811FA8FA50077A41E /* sfnt.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8A11FA8FA50077A41E /* sfnt.c */; }; + 611E0DE911FA8FA50077A41E /* sfntpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8B11FA8FA50077A41E /* sfntpic.c */; }; + 611E0DEA11FA8FA50077A41E /* sfntpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8C11FA8FA50077A41E /* sfntpic.h */; }; + 611E0DEB11FA8FA50077A41E /* sfobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8D11FA8FA50077A41E /* sfobjs.c */; }; + 611E0DEC11FA8FA50077A41E /* sfobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8E11FA8FA50077A41E /* sfobjs.h */; }; + 611E0DED11FA8FA50077A41E /* ttbdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8F11FA8FA50077A41E /* ttbdf.c */; }; + 611E0DEE11FA8FA50077A41E /* ttbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9011FA8FA50077A41E /* ttbdf.h */; }; + 611E0DEF11FA8FA50077A41E /* ttcmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9111FA8FA50077A41E /* ttcmap.c */; }; + 611E0DF011FA8FA50077A41E /* ttcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9211FA8FA50077A41E /* ttcmap.h */; }; + 611E0DF111FA8FA50077A41E /* ttcmapc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9311FA8FA50077A41E /* ttcmapc.h */; }; + 611E0DF211FA8FA50077A41E /* ttkern.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9411FA8FA50077A41E /* ttkern.c */; }; + 611E0DF311FA8FA50077A41E /* ttkern.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9511FA8FA50077A41E /* ttkern.h */; }; + 611E0DF411FA8FA50077A41E /* ttload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9611FA8FA50077A41E /* ttload.c */; }; + 611E0DF511FA8FA50077A41E /* ttload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9711FA8FA50077A41E /* ttload.h */; }; + 611E0DF611FA8FA50077A41E /* ttmtx.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9811FA8FA50077A41E /* ttmtx.c */; }; + 611E0DF711FA8FA50077A41E /* ttmtx.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9911FA8FA50077A41E /* ttmtx.h */; }; + 611E0DF811FA8FA50077A41E /* ttpost.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9A11FA8FA50077A41E /* ttpost.c */; }; + 611E0DF911FA8FA50077A41E /* ttpost.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9B11FA8FA50077A41E /* ttpost.h */; }; + 611E0DFA11FA8FA50077A41E /* ttsbit.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9C11FA8FA50077A41E /* ttsbit.c */; }; + 611E0DFB11FA8FA50077A41E /* ttsbit.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9D11FA8FA50077A41E /* ttsbit.h */; }; + 611E0DFC11FA8FA50077A41E /* ttsbit0.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9E11FA8FA50077A41E /* ttsbit0.c */; }; + 611E0DFD11FA8FA50077A41E /* ftgrays.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA011FA8FA50077A41E /* ftgrays.c */; }; + 611E0DFE11FA8FA50077A41E /* ftgrays.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA111FA8FA50077A41E /* ftgrays.h */; }; + 611E0DFF11FA8FA50077A41E /* ftsmerrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA211FA8FA50077A41E /* ftsmerrs.h */; }; + 611E0E0011FA8FA50077A41E /* ftsmooth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA311FA8FA50077A41E /* ftsmooth.c */; }; + 611E0E0111FA8FA50077A41E /* ftsmooth.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA411FA8FA50077A41E /* ftsmooth.h */; }; + 611E0E0211FA8FA50077A41E /* ftspic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA511FA8FA50077A41E /* ftspic.c */; }; + 611E0E0311FA8FA50077A41E /* ftspic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA611FA8FA50077A41E /* ftspic.h */; }; + 611E0E0411FA8FA50077A41E /* smooth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA711FA8FA50077A41E /* smooth.c */; }; + 611E0E0B11FA8FA50077A41E /* truetype.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CBD11FA8FA50077A41E /* truetype.c */; }; + 611E0E0C11FA8FA50077A41E /* ttdriver.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CBE11FA8FA50077A41E /* ttdriver.c */; }; + 611E0E0D11FA8FA50077A41E /* ttdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CBF11FA8FA50077A41E /* ttdriver.h */; }; + 611E0E0E11FA8FA50077A41E /* tterrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC011FA8FA50077A41E /* tterrors.h */; }; + 611E0E0F11FA8FA50077A41E /* ttgload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC111FA8FA50077A41E /* ttgload.c */; }; + 611E0E1011FA8FA50077A41E /* ttgload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC211FA8FA50077A41E /* ttgload.h */; }; + 611E0E1111FA8FA50077A41E /* ttgxvar.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC311FA8FA50077A41E /* ttgxvar.c */; }; + 611E0E1211FA8FA50077A41E /* ttgxvar.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC411FA8FA50077A41E /* ttgxvar.h */; }; + 611E0E1311FA8FA50077A41E /* ttinterp.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC511FA8FA50077A41E /* ttinterp.c */; }; + 611E0E1411FA8FA50077A41E /* ttinterp.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC611FA8FA50077A41E /* ttinterp.h */; }; + 611E0E1511FA8FA50077A41E /* ttobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC711FA8FA50077A41E /* ttobjs.c */; }; + 611E0E1611FA8FA50077A41E /* ttobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC811FA8FA50077A41E /* ttobjs.h */; }; + 611E0E1711FA8FA50077A41E /* ttpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC911FA8FA50077A41E /* ttpic.c */; }; + 611E0E1811FA8FA50077A41E /* ttpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CCA11FA8FA50077A41E /* ttpic.h */; }; + 611E0E1911FA8FA50077A41E /* ttpload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CCB11FA8FA50077A41E /* ttpload.c */; }; + 611E0E1A11FA8FA50077A41E /* ttpload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CCC11FA8FA50077A41E /* ttpload.h */; }; + AA747D9F0F9514B9006C5449 /* freetype_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */; }; + AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 611E0AC611FA8F610077A41E /* ftconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftconfig.h; sourceTree = ""; }; + 611E0AC711FA8F610077A41E /* ftheader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftheader.h; sourceTree = ""; }; + 611E0AC811FA8F610077A41E /* ftmodule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmodule.h; sourceTree = ""; }; + 611E0AC911FA8F610077A41E /* ftoption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftoption.h; sourceTree = ""; }; + 611E0ACA11FA8F610077A41E /* ftstdlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstdlib.h; sourceTree = ""; }; + 611E0ACB11FA8F610077A41E /* freetype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = freetype.h; sourceTree = ""; }; + 611E0ACC11FA8F610077A41E /* ftadvanc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftadvanc.h; sourceTree = ""; }; + 611E0ACD11FA8F610077A41E /* ftbbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbbox.h; sourceTree = ""; }; + 611E0ACE11FA8F610077A41E /* ftbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbdf.h; sourceTree = ""; }; + 611E0ACF11FA8F610077A41E /* ftbitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbitmap.h; sourceTree = ""; }; + 611E0AD011FA8F610077A41E /* ftcache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcache.h; sourceTree = ""; }; + 611E0AD111FA8F610077A41E /* ftchapters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftchapters.h; sourceTree = ""; }; + 611E0AD211FA8F610077A41E /* ftcid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcid.h; sourceTree = ""; }; + 611E0AD311FA8F610077A41E /* fterrdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fterrdef.h; sourceTree = ""; }; + 611E0AD411FA8F610077A41E /* fterrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fterrors.h; sourceTree = ""; }; + 611E0AD511FA8F610077A41E /* ftgasp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgasp.h; sourceTree = ""; }; + 611E0AD611FA8F610077A41E /* ftglyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftglyph.h; sourceTree = ""; }; + 611E0AD711FA8F610077A41E /* ftgxval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgxval.h; sourceTree = ""; }; + 611E0AD811FA8F610077A41E /* ftgzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgzip.h; sourceTree = ""; }; + 611E0AD911FA8F610077A41E /* ftimage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftimage.h; sourceTree = ""; }; + 611E0ADA11FA8F610077A41E /* ftincrem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftincrem.h; sourceTree = ""; }; + 611E0ADB11FA8F610077A41E /* ftlcdfil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlcdfil.h; sourceTree = ""; }; + 611E0ADC11FA8F610077A41E /* ftlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlist.h; sourceTree = ""; }; + 611E0ADD11FA8F610077A41E /* ftlzw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlzw.h; sourceTree = ""; }; + 611E0ADE11FA8F610077A41E /* ftmac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmac.h; sourceTree = ""; }; + 611E0ADF11FA8F610077A41E /* ftmm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmm.h; sourceTree = ""; }; + 611E0AE011FA8F610077A41E /* ftmodapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmodapi.h; sourceTree = ""; }; + 611E0AE111FA8F610077A41E /* ftmoderr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmoderr.h; sourceTree = ""; }; + 611E0AE211FA8F610077A41E /* ftotval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftotval.h; sourceTree = ""; }; + 611E0AE311FA8F610077A41E /* ftoutln.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftoutln.h; sourceTree = ""; }; + 611E0AE411FA8F610077A41E /* ftpfr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftpfr.h; sourceTree = ""; }; + 611E0AE511FA8F610077A41E /* ftrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrender.h; sourceTree = ""; }; + 611E0AE611FA8F610077A41E /* ftsizes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsizes.h; sourceTree = ""; }; + 611E0AE711FA8F610077A41E /* ftsnames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsnames.h; sourceTree = ""; }; + 611E0AE811FA8F610077A41E /* ftstroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstroke.h; sourceTree = ""; }; + 611E0AE911FA8F610077A41E /* ftsynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsynth.h; sourceTree = ""; }; + 611E0AEA11FA8F610077A41E /* ftsystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsystem.h; sourceTree = ""; }; + 611E0AEB11FA8F610077A41E /* fttrigon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttrigon.h; sourceTree = ""; }; + 611E0AEC11FA8F610077A41E /* fttypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttypes.h; sourceTree = ""; }; + 611E0AED11FA8F610077A41E /* ftwinfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftwinfnt.h; sourceTree = ""; }; + 611E0AEE11FA8F610077A41E /* ftxf86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftxf86.h; sourceTree = ""; }; + 611E0AF011FA8F610077A41E /* autohint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autohint.h; sourceTree = ""; }; + 611E0AF111FA8F610077A41E /* ftcalc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcalc.h; sourceTree = ""; }; + 611E0AF211FA8F610077A41E /* ftdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftdebug.h; sourceTree = ""; }; + 611E0AF311FA8F610077A41E /* ftdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftdriver.h; sourceTree = ""; }; + 611E0AF411FA8F610077A41E /* ftgloadr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgloadr.h; sourceTree = ""; }; + 611E0AF511FA8F610077A41E /* ftmemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmemory.h; sourceTree = ""; }; + 611E0AF611FA8F610077A41E /* ftobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftobjs.h; sourceTree = ""; }; + 611E0AF711FA8F610077A41E /* ftpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftpic.h; sourceTree = ""; }; + 611E0AF811FA8F610077A41E /* ftrfork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrfork.h; sourceTree = ""; }; + 611E0AF911FA8F610077A41E /* ftserv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftserv.h; sourceTree = ""; }; + 611E0AFA11FA8F610077A41E /* ftstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstream.h; sourceTree = ""; }; + 611E0AFB11FA8F610077A41E /* fttrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttrace.h; sourceTree = ""; }; + 611E0AFC11FA8F610077A41E /* ftvalid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftvalid.h; sourceTree = ""; }; + 611E0AFD11FA8F610077A41E /* internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = internal.h; sourceTree = ""; }; + 611E0AFE11FA8F610077A41E /* pcftypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcftypes.h; sourceTree = ""; }; + 611E0AFF11FA8F610077A41E /* psaux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psaux.h; sourceTree = ""; }; + 611E0B0011FA8F610077A41E /* pshints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshints.h; sourceTree = ""; }; + 611E0B0211FA8F610077A41E /* svbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svbdf.h; sourceTree = ""; }; + 611E0B0311FA8F610077A41E /* svcid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svcid.h; sourceTree = ""; }; + 611E0B0411FA8F610077A41E /* svgldict.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svgldict.h; sourceTree = ""; }; + 611E0B0511FA8F610077A41E /* svgxval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svgxval.h; sourceTree = ""; }; + 611E0B0611FA8F610077A41E /* svkern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svkern.h; sourceTree = ""; }; + 611E0B0711FA8F610077A41E /* svmm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svmm.h; sourceTree = ""; }; + 611E0B0811FA8F610077A41E /* svotval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svotval.h; sourceTree = ""; }; + 611E0B0911FA8F610077A41E /* svpfr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpfr.h; sourceTree = ""; }; + 611E0B0A11FA8F610077A41E /* svpostnm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpostnm.h; sourceTree = ""; }; + 611E0B0B11FA8F610077A41E /* svpscmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpscmap.h; sourceTree = ""; }; + 611E0B0C11FA8F610077A41E /* svpsinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpsinfo.h; sourceTree = ""; }; + 611E0B0D11FA8F610077A41E /* svsfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svsfnt.h; sourceTree = ""; }; + 611E0B0E11FA8F610077A41E /* svttcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svttcmap.h; sourceTree = ""; }; + 611E0B0F11FA8F610077A41E /* svtteng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svtteng.h; sourceTree = ""; }; + 611E0B1011FA8F610077A41E /* svttglyf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svttglyf.h; sourceTree = ""; }; + 611E0B1111FA8F610077A41E /* svwinfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svwinfnt.h; sourceTree = ""; }; + 611E0B1211FA8F610077A41E /* svxf86nm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svxf86nm.h; sourceTree = ""; }; + 611E0B1311FA8F610077A41E /* sfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfnt.h; sourceTree = ""; }; + 611E0B1411FA8F610077A41E /* t1types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = t1types.h; sourceTree = ""; }; + 611E0B1511FA8F610077A41E /* tttypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttypes.h; sourceTree = ""; }; + 611E0B1611FA8F610077A41E /* t1tables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = t1tables.h; sourceTree = ""; }; + 611E0B1711FA8F610077A41E /* ttnameid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttnameid.h; sourceTree = ""; }; + 611E0B1811FA8F610077A41E /* tttables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttables.h; sourceTree = ""; }; + 611E0B1911FA8F610077A41E /* tttags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttags.h; sourceTree = ""; }; + 611E0B1A11FA8F610077A41E /* ttunpat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttunpat.h; sourceTree = ""; }; + 611E0B1B11FA8F610077A41E /* ft2build.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ft2build.h; path = ../include/ft2build.h; sourceTree = SOURCE_ROOT; }; + 611E0B9911FA8FA50077A41E /* basepic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = basepic.c; sourceTree = ""; }; + 611E0B9A11FA8FA50077A41E /* basepic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = basepic.h; sourceTree = ""; }; + 611E0B9B11FA8FA50077A41E /* ftadvanc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftadvanc.c; sourceTree = ""; }; + 611E0B9C11FA8FA50077A41E /* ftapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftapi.c; sourceTree = ""; }; + 611E0B9D11FA8FA50077A41E /* ftbase.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbase.c; sourceTree = ""; }; + 611E0B9E11FA8FA50077A41E /* ftbase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbase.h; sourceTree = ""; }; + 611E0B9F11FA8FA50077A41E /* ftbbox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbbox.c; sourceTree = ""; }; + 611E0BA111FA8FA50077A41E /* ftbitmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbitmap.c; sourceTree = ""; }; + 611E0BA211FA8FA50077A41E /* ftcalc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftcalc.c; sourceTree = ""; }; + 611E0BA411FA8FA50077A41E /* ftdbgmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftdbgmem.c; sourceTree = ""; }; + 611E0BA511FA8FA50077A41E /* ftdebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftdebug.c; sourceTree = ""; }; + 611E0BA811FA8FA50077A41E /* ftgloadr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftgloadr.c; sourceTree = ""; }; + 611E0BA911FA8FA50077A41E /* ftglyph.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftglyph.c; sourceTree = ""; }; + 611E0BAB11FA8FA50077A41E /* ftinit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftinit.c; sourceTree = ""; }; + 611E0BAF11FA8FA50077A41E /* ftobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftobjs.c; sourceTree = ""; }; + 611E0BB111FA8FA50077A41E /* ftoutln.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftoutln.c; sourceTree = ""; }; + 611E0BB411FA8FA50077A41E /* ftpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftpic.c; sourceTree = ""; }; + 611E0BB511FA8FA50077A41E /* ftrfork.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftrfork.c; sourceTree = ""; }; + 611E0BB611FA8FA50077A41E /* ftsnames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsnames.c; sourceTree = ""; }; + 611E0BB711FA8FA50077A41E /* ftstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftstream.c; sourceTree = ""; }; + 611E0BB811FA8FA50077A41E /* ftstroke.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftstroke.c; sourceTree = ""; }; + 611E0BB911FA8FA50077A41E /* ftsynth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsynth.c; sourceTree = ""; }; + 611E0BBA11FA8FA50077A41E /* ftsystem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsystem.c; sourceTree = ""; }; + 611E0BBB11FA8FA50077A41E /* fttrigon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fttrigon.c; sourceTree = ""; }; + 611E0BBD11FA8FA50077A41E /* ftutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftutil.c; sourceTree = ""; }; + 611E0BDA11FA8FA50077A41E /* cff.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cff.c; sourceTree = ""; }; + 611E0BDB11FA8FA50077A41E /* cffcmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffcmap.c; sourceTree = ""; }; + 611E0BDC11FA8FA50077A41E /* cffcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffcmap.h; sourceTree = ""; }; + 611E0BDD11FA8FA50077A41E /* cffdrivr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffdrivr.c; sourceTree = ""; }; + 611E0BDE11FA8FA50077A41E /* cffdrivr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffdrivr.h; sourceTree = ""; }; + 611E0BDF11FA8FA50077A41E /* cfferrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfferrs.h; sourceTree = ""; }; + 611E0BE011FA8FA50077A41E /* cffgload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffgload.c; sourceTree = ""; }; + 611E0BE111FA8FA50077A41E /* cffgload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffgload.h; sourceTree = ""; }; + 611E0BE211FA8FA50077A41E /* cffload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffload.c; sourceTree = ""; }; + 611E0BE311FA8FA50077A41E /* cffload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffload.h; sourceTree = ""; }; + 611E0BE411FA8FA50077A41E /* cffobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffobjs.c; sourceTree = ""; }; + 611E0BE511FA8FA50077A41E /* cffobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffobjs.h; sourceTree = ""; }; + 611E0BE611FA8FA50077A41E /* cffparse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffparse.c; sourceTree = ""; }; + 611E0BE711FA8FA50077A41E /* cffparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffparse.h; sourceTree = ""; }; + 611E0BE811FA8FA50077A41E /* cffpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffpic.c; sourceTree = ""; }; + 611E0BE911FA8FA50077A41E /* cffpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffpic.h; sourceTree = ""; }; + 611E0BEA11FA8FA50077A41E /* cfftoken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfftoken.h; sourceTree = ""; }; + 611E0BEB11FA8FA50077A41E /* cfftypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfftypes.h; sourceTree = ""; }; + 611E0C6811FA8FA50077A41E /* pshalgo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshalgo.c; sourceTree = ""; }; + 611E0C6911FA8FA50077A41E /* pshalgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshalgo.h; sourceTree = ""; }; + 611E0C6A11FA8FA50077A41E /* pshglob.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshglob.c; sourceTree = ""; }; + 611E0C6B11FA8FA50077A41E /* pshglob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshglob.h; sourceTree = ""; }; + 611E0C6C11FA8FA50077A41E /* pshinter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshinter.c; sourceTree = ""; }; + 611E0C6D11FA8FA50077A41E /* pshmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshmod.c; sourceTree = ""; }; + 611E0C6E11FA8FA50077A41E /* pshmod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshmod.h; sourceTree = ""; }; + 611E0C6F11FA8FA50077A41E /* pshnterr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshnterr.h; sourceTree = ""; }; + 611E0C7011FA8FA50077A41E /* pshpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshpic.c; sourceTree = ""; }; + 611E0C7111FA8FA50077A41E /* pshpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshpic.h; sourceTree = ""; }; + 611E0C7211FA8FA50077A41E /* pshrec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshrec.c; sourceTree = ""; }; + 611E0C7311FA8FA50077A41E /* pshrec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshrec.h; sourceTree = ""; }; + 611E0C7511FA8FA50077A41E /* psmodule.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psmodule.c; sourceTree = ""; }; + 611E0C7611FA8FA50077A41E /* psmodule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psmodule.h; sourceTree = ""; }; + 611E0C7711FA8FA50077A41E /* psnamerr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psnamerr.h; sourceTree = ""; }; + 611E0C7811FA8FA50077A41E /* psnames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psnames.c; sourceTree = ""; }; + 611E0C7911FA8FA50077A41E /* pspic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pspic.c; sourceTree = ""; }; + 611E0C7A11FA8FA50077A41E /* pspic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pspic.h; sourceTree = ""; }; + 611E0C7B11FA8FA50077A41E /* pstables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pstables.h; sourceTree = ""; }; + 611E0C7D11FA8FA50077A41E /* ftmisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmisc.h; sourceTree = ""; }; + 611E0C7E11FA8FA50077A41E /* ftraster.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftraster.c; sourceTree = ""; }; + 611E0C7F11FA8FA50077A41E /* ftraster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftraster.h; sourceTree = ""; }; + 611E0C8011FA8FA50077A41E /* ftrend1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftrend1.c; sourceTree = ""; }; + 611E0C8111FA8FA50077A41E /* ftrend1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrend1.h; sourceTree = ""; }; + 611E0C8211FA8FA50077A41E /* raster.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raster.c; sourceTree = ""; }; + 611E0C8311FA8FA50077A41E /* rasterrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rasterrs.h; sourceTree = ""; }; + 611E0C8411FA8FA50077A41E /* rastpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rastpic.c; sourceTree = ""; }; + 611E0C8511FA8FA50077A41E /* rastpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rastpic.h; sourceTree = ""; }; + 611E0C8711FA8FA50077A41E /* sfdriver.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfdriver.c; sourceTree = ""; }; + 611E0C8811FA8FA50077A41E /* sfdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfdriver.h; sourceTree = ""; }; + 611E0C8911FA8FA50077A41E /* sferrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sferrors.h; sourceTree = ""; }; + 611E0C8A11FA8FA50077A41E /* sfnt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfnt.c; sourceTree = ""; }; + 611E0C8B11FA8FA50077A41E /* sfntpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfntpic.c; sourceTree = ""; }; + 611E0C8C11FA8FA50077A41E /* sfntpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfntpic.h; sourceTree = ""; }; + 611E0C8D11FA8FA50077A41E /* sfobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfobjs.c; sourceTree = ""; }; + 611E0C8E11FA8FA50077A41E /* sfobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfobjs.h; sourceTree = ""; }; + 611E0C8F11FA8FA50077A41E /* ttbdf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttbdf.c; sourceTree = ""; }; + 611E0C9011FA8FA50077A41E /* ttbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttbdf.h; sourceTree = ""; }; + 611E0C9111FA8FA50077A41E /* ttcmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttcmap.c; sourceTree = ""; }; + 611E0C9211FA8FA50077A41E /* ttcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttcmap.h; sourceTree = ""; }; + 611E0C9311FA8FA50077A41E /* ttcmapc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttcmapc.h; sourceTree = ""; }; + 611E0C9411FA8FA50077A41E /* ttkern.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkern.c; sourceTree = ""; }; + 611E0C9511FA8FA50077A41E /* ttkern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkern.h; sourceTree = ""; }; + 611E0C9611FA8FA50077A41E /* ttload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttload.c; sourceTree = ""; }; + 611E0C9711FA8FA50077A41E /* ttload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttload.h; sourceTree = ""; }; + 611E0C9811FA8FA50077A41E /* ttmtx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttmtx.c; sourceTree = ""; }; + 611E0C9911FA8FA50077A41E /* ttmtx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttmtx.h; sourceTree = ""; }; + 611E0C9A11FA8FA50077A41E /* ttpost.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpost.c; sourceTree = ""; }; + 611E0C9B11FA8FA50077A41E /* ttpost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpost.h; sourceTree = ""; }; + 611E0C9C11FA8FA50077A41E /* ttsbit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttsbit.c; sourceTree = ""; }; + 611E0C9D11FA8FA50077A41E /* ttsbit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttsbit.h; sourceTree = ""; }; + 611E0C9E11FA8FA50077A41E /* ttsbit0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttsbit0.c; sourceTree = ""; }; + 611E0CA011FA8FA50077A41E /* ftgrays.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftgrays.c; sourceTree = ""; }; + 611E0CA111FA8FA50077A41E /* ftgrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgrays.h; sourceTree = ""; }; + 611E0CA211FA8FA50077A41E /* ftsmerrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsmerrs.h; sourceTree = ""; }; + 611E0CA311FA8FA50077A41E /* ftsmooth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsmooth.c; sourceTree = ""; }; + 611E0CA411FA8FA50077A41E /* ftsmooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsmooth.h; sourceTree = ""; }; + 611E0CA511FA8FA50077A41E /* ftspic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftspic.c; sourceTree = ""; }; + 611E0CA611FA8FA50077A41E /* ftspic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftspic.h; sourceTree = ""; }; + 611E0CA711FA8FA50077A41E /* smooth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smooth.c; sourceTree = ""; }; + 611E0CBD11FA8FA50077A41E /* truetype.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = truetype.c; sourceTree = ""; }; + 611E0CBE11FA8FA50077A41E /* ttdriver.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttdriver.c; sourceTree = ""; }; + 611E0CBF11FA8FA50077A41E /* ttdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttdriver.h; sourceTree = ""; }; + 611E0CC011FA8FA50077A41E /* tterrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tterrors.h; sourceTree = ""; }; + 611E0CC111FA8FA50077A41E /* ttgload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttgload.c; sourceTree = ""; }; + 611E0CC211FA8FA50077A41E /* ttgload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttgload.h; sourceTree = ""; }; + 611E0CC311FA8FA50077A41E /* ttgxvar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttgxvar.c; sourceTree = ""; }; + 611E0CC411FA8FA50077A41E /* ttgxvar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttgxvar.h; sourceTree = ""; }; + 611E0CC511FA8FA50077A41E /* ttinterp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttinterp.c; sourceTree = ""; }; + 611E0CC611FA8FA50077A41E /* ttinterp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttinterp.h; sourceTree = ""; }; + 611E0CC711FA8FA50077A41E /* ttobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttobjs.c; sourceTree = ""; }; + 611E0CC811FA8FA50077A41E /* ttobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttobjs.h; sourceTree = ""; }; + 611E0CC911FA8FA50077A41E /* ttpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpic.c; sourceTree = ""; }; + 611E0CCA11FA8FA50077A41E /* ttpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpic.h; sourceTree = ""; }; + 611E0CCB11FA8FA50077A41E /* ttpload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpload.c; sourceTree = ""; }; + 611E0CCC11FA8FA50077A41E /* ttpload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpload.h; sourceTree = ""; }; + AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = freetype_Prefix.pch; sourceTree = SOURCE_ROOT; }; + AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + D2AAC07E0554694100DB518D /* libFreetype.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFreetype.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D2AAC07C0554694100DB518D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 034768DFFF38A50411DB9C8B /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC07E0554694100DB518D /* libFreetype.a */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* freetype */ = { + isa = PBXGroup; + children = ( + 08FB77AEFE84172EC02AAC07 /* Source */, + 32C88DFF0371C24200C91783 /* Public Headers */, + 0867D69AFE84028FC02AAC07 /* Frameworks */, + 034768DFFF38A50411DB9C8B /* Products */, + ); + name = freetype; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AACBBE490F95108600F1A2B1 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 08FB77AEFE84172EC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 611E0B9811FA8FA50077A41E /* base */, + 611E0BD911FA8FA50077A41E /* cff */, + 611E0C6711FA8FA50077A41E /* pshinter */, + 611E0C7411FA8FA50077A41E /* psnames */, + 611E0C7C11FA8FA50077A41E /* raster */, + 611E0C8611FA8FA50077A41E /* sfnt */, + 611E0C9F11FA8FA50077A41E /* smooth */, + 611E0CBC11FA8FA50077A41E /* truetype */, + ); + name = Source; + sourceTree = ""; + }; + 32C88DFF0371C24200C91783 /* Public Headers */ = { + isa = PBXGroup; + children = ( + 611E0AC411FA8F610077A41E /* freetype */, + 611E0B1B11FA8F610077A41E /* ft2build.h */, + AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */, + ); + name = "Public Headers"; + sourceTree = ""; + }; + 611E0AC411FA8F610077A41E /* freetype */ = { + isa = PBXGroup; + children = ( + 611E0AC511FA8F610077A41E /* config */, + 611E0ACB11FA8F610077A41E /* freetype.h */, + 611E0ACC11FA8F610077A41E /* ftadvanc.h */, + 611E0ACD11FA8F610077A41E /* ftbbox.h */, + 611E0ACE11FA8F610077A41E /* ftbdf.h */, + 611E0ACF11FA8F610077A41E /* ftbitmap.h */, + 611E0AD011FA8F610077A41E /* ftcache.h */, + 611E0AD111FA8F610077A41E /* ftchapters.h */, + 611E0AD211FA8F610077A41E /* ftcid.h */, + 611E0AD311FA8F610077A41E /* fterrdef.h */, + 611E0AD411FA8F610077A41E /* fterrors.h */, + 611E0AD511FA8F610077A41E /* ftgasp.h */, + 611E0AD611FA8F610077A41E /* ftglyph.h */, + 611E0AD711FA8F610077A41E /* ftgxval.h */, + 611E0AD811FA8F610077A41E /* ftgzip.h */, + 611E0AD911FA8F610077A41E /* ftimage.h */, + 611E0ADA11FA8F610077A41E /* ftincrem.h */, + 611E0ADB11FA8F610077A41E /* ftlcdfil.h */, + 611E0ADC11FA8F610077A41E /* ftlist.h */, + 611E0ADD11FA8F610077A41E /* ftlzw.h */, + 611E0ADE11FA8F610077A41E /* ftmac.h */, + 611E0ADF11FA8F610077A41E /* ftmm.h */, + 611E0AE011FA8F610077A41E /* ftmodapi.h */, + 611E0AE111FA8F610077A41E /* ftmoderr.h */, + 611E0AE211FA8F610077A41E /* ftotval.h */, + 611E0AE311FA8F610077A41E /* ftoutln.h */, + 611E0AE411FA8F610077A41E /* ftpfr.h */, + 611E0AE511FA8F610077A41E /* ftrender.h */, + 611E0AE611FA8F610077A41E /* ftsizes.h */, + 611E0AE711FA8F610077A41E /* ftsnames.h */, + 611E0AE811FA8F610077A41E /* ftstroke.h */, + 611E0AE911FA8F610077A41E /* ftsynth.h */, + 611E0AEA11FA8F610077A41E /* ftsystem.h */, + 611E0AEB11FA8F610077A41E /* fttrigon.h */, + 611E0AEC11FA8F610077A41E /* fttypes.h */, + 611E0AED11FA8F610077A41E /* ftwinfnt.h */, + 611E0AEE11FA8F610077A41E /* ftxf86.h */, + 611E0AEF11FA8F610077A41E /* internal */, + 611E0B1611FA8F610077A41E /* t1tables.h */, + 611E0B1711FA8F610077A41E /* ttnameid.h */, + 611E0B1811FA8F610077A41E /* tttables.h */, + 611E0B1911FA8F610077A41E /* tttags.h */, + 611E0B1A11FA8F610077A41E /* ttunpat.h */, + ); + name = freetype; + path = ../include/freetype; + sourceTree = SOURCE_ROOT; + }; + 611E0AC511FA8F610077A41E /* config */ = { + isa = PBXGroup; + children = ( + 611E0AC611FA8F610077A41E /* ftconfig.h */, + 611E0AC711FA8F610077A41E /* ftheader.h */, + 611E0AC811FA8F610077A41E /* ftmodule.h */, + 611E0AC911FA8F610077A41E /* ftoption.h */, + 611E0ACA11FA8F610077A41E /* ftstdlib.h */, + ); + path = config; + sourceTree = ""; + }; + 611E0AEF11FA8F610077A41E /* internal */ = { + isa = PBXGroup; + children = ( + 611E0AF011FA8F610077A41E /* autohint.h */, + 611E0AF111FA8F610077A41E /* ftcalc.h */, + 611E0AF211FA8F610077A41E /* ftdebug.h */, + 611E0AF311FA8F610077A41E /* ftdriver.h */, + 611E0AF411FA8F610077A41E /* ftgloadr.h */, + 611E0AF511FA8F610077A41E /* ftmemory.h */, + 611E0AF611FA8F610077A41E /* ftobjs.h */, + 611E0AF711FA8F610077A41E /* ftpic.h */, + 611E0AF811FA8F610077A41E /* ftrfork.h */, + 611E0AF911FA8F610077A41E /* ftserv.h */, + 611E0AFA11FA8F610077A41E /* ftstream.h */, + 611E0AFB11FA8F610077A41E /* fttrace.h */, + 611E0AFC11FA8F610077A41E /* ftvalid.h */, + 611E0AFD11FA8F610077A41E /* internal.h */, + 611E0AFE11FA8F610077A41E /* pcftypes.h */, + 611E0AFF11FA8F610077A41E /* psaux.h */, + 611E0B0011FA8F610077A41E /* pshints.h */, + 611E0B0111FA8F610077A41E /* services */, + 611E0B1311FA8F610077A41E /* sfnt.h */, + 611E0B1411FA8F610077A41E /* t1types.h */, + 611E0B1511FA8F610077A41E /* tttypes.h */, + ); + path = internal; + sourceTree = ""; + }; + 611E0B0111FA8F610077A41E /* services */ = { + isa = PBXGroup; + children = ( + 611E0B0211FA8F610077A41E /* svbdf.h */, + 611E0B0311FA8F610077A41E /* svcid.h */, + 611E0B0411FA8F610077A41E /* svgldict.h */, + 611E0B0511FA8F610077A41E /* svgxval.h */, + 611E0B0611FA8F610077A41E /* svkern.h */, + 611E0B0711FA8F610077A41E /* svmm.h */, + 611E0B0811FA8F610077A41E /* svotval.h */, + 611E0B0911FA8F610077A41E /* svpfr.h */, + 611E0B0A11FA8F610077A41E /* svpostnm.h */, + 611E0B0B11FA8F610077A41E /* svpscmap.h */, + 611E0B0C11FA8F610077A41E /* svpsinfo.h */, + 611E0B0D11FA8F610077A41E /* svsfnt.h */, + 611E0B0E11FA8F610077A41E /* svttcmap.h */, + 611E0B0F11FA8F610077A41E /* svtteng.h */, + 611E0B1011FA8F610077A41E /* svttglyf.h */, + 611E0B1111FA8F610077A41E /* svwinfnt.h */, + 611E0B1211FA8F610077A41E /* svxf86nm.h */, + ); + path = services; + sourceTree = ""; + }; + 611E0B9811FA8FA50077A41E /* base */ = { + isa = PBXGroup; + children = ( + 611E0B9911FA8FA50077A41E /* basepic.c */, + 611E0B9A11FA8FA50077A41E /* basepic.h */, + 611E0B9B11FA8FA50077A41E /* ftadvanc.c */, + 611E0B9C11FA8FA50077A41E /* ftapi.c */, + 611E0B9D11FA8FA50077A41E /* ftbase.c */, + 611E0B9E11FA8FA50077A41E /* ftbase.h */, + 611E0B9F11FA8FA50077A41E /* ftbbox.c */, + 611E0BA111FA8FA50077A41E /* ftbitmap.c */, + 611E0BA211FA8FA50077A41E /* ftcalc.c */, + 611E0BA411FA8FA50077A41E /* ftdbgmem.c */, + 611E0BA511FA8FA50077A41E /* ftdebug.c */, + 611E0BA811FA8FA50077A41E /* ftgloadr.c */, + 611E0BA911FA8FA50077A41E /* ftglyph.c */, + 611E0BAB11FA8FA50077A41E /* ftinit.c */, + 611E0BAF11FA8FA50077A41E /* ftobjs.c */, + 611E0BB111FA8FA50077A41E /* ftoutln.c */, + 611E0BB411FA8FA50077A41E /* ftpic.c */, + 611E0BB511FA8FA50077A41E /* ftrfork.c */, + 611E0BB611FA8FA50077A41E /* ftsnames.c */, + 611E0BB711FA8FA50077A41E /* ftstream.c */, + 611E0BB811FA8FA50077A41E /* ftstroke.c */, + 611E0BB911FA8FA50077A41E /* ftsynth.c */, + 611E0BBA11FA8FA50077A41E /* ftsystem.c */, + 611E0BBB11FA8FA50077A41E /* fttrigon.c */, + 611E0BBD11FA8FA50077A41E /* ftutil.c */, + ); + name = base; + path = ../src/base; + sourceTree = SOURCE_ROOT; + }; + 611E0BD911FA8FA50077A41E /* cff */ = { + isa = PBXGroup; + children = ( + 611E0BDA11FA8FA50077A41E /* cff.c */, + 611E0BDB11FA8FA50077A41E /* cffcmap.c */, + 611E0BDC11FA8FA50077A41E /* cffcmap.h */, + 611E0BDD11FA8FA50077A41E /* cffdrivr.c */, + 611E0BDE11FA8FA50077A41E /* cffdrivr.h */, + 611E0BDF11FA8FA50077A41E /* cfferrs.h */, + 611E0BE011FA8FA50077A41E /* cffgload.c */, + 611E0BE111FA8FA50077A41E /* cffgload.h */, + 611E0BE211FA8FA50077A41E /* cffload.c */, + 611E0BE311FA8FA50077A41E /* cffload.h */, + 611E0BE411FA8FA50077A41E /* cffobjs.c */, + 611E0BE511FA8FA50077A41E /* cffobjs.h */, + 611E0BE611FA8FA50077A41E /* cffparse.c */, + 611E0BE711FA8FA50077A41E /* cffparse.h */, + 611E0BE811FA8FA50077A41E /* cffpic.c */, + 611E0BE911FA8FA50077A41E /* cffpic.h */, + 611E0BEA11FA8FA50077A41E /* cfftoken.h */, + 611E0BEB11FA8FA50077A41E /* cfftypes.h */, + ); + name = cff; + path = ../src/cff; + sourceTree = SOURCE_ROOT; + }; + 611E0C6711FA8FA50077A41E /* pshinter */ = { + isa = PBXGroup; + children = ( + 611E0C6811FA8FA50077A41E /* pshalgo.c */, + 611E0C6911FA8FA50077A41E /* pshalgo.h */, + 611E0C6A11FA8FA50077A41E /* pshglob.c */, + 611E0C6B11FA8FA50077A41E /* pshglob.h */, + 611E0C6C11FA8FA50077A41E /* pshinter.c */, + 611E0C6D11FA8FA50077A41E /* pshmod.c */, + 611E0C6E11FA8FA50077A41E /* pshmod.h */, + 611E0C6F11FA8FA50077A41E /* pshnterr.h */, + 611E0C7011FA8FA50077A41E /* pshpic.c */, + 611E0C7111FA8FA50077A41E /* pshpic.h */, + 611E0C7211FA8FA50077A41E /* pshrec.c */, + 611E0C7311FA8FA50077A41E /* pshrec.h */, + ); + name = pshinter; + path = ../src/pshinter; + sourceTree = SOURCE_ROOT; + }; + 611E0C7411FA8FA50077A41E /* psnames */ = { + isa = PBXGroup; + children = ( + 611E0C7511FA8FA50077A41E /* psmodule.c */, + 611E0C7611FA8FA50077A41E /* psmodule.h */, + 611E0C7711FA8FA50077A41E /* psnamerr.h */, + 611E0C7811FA8FA50077A41E /* psnames.c */, + 611E0C7911FA8FA50077A41E /* pspic.c */, + 611E0C7A11FA8FA50077A41E /* pspic.h */, + 611E0C7B11FA8FA50077A41E /* pstables.h */, + ); + name = psnames; + path = ../src/psnames; + sourceTree = SOURCE_ROOT; + }; + 611E0C7C11FA8FA50077A41E /* raster */ = { + isa = PBXGroup; + children = ( + 611E0C7D11FA8FA50077A41E /* ftmisc.h */, + 611E0C7E11FA8FA50077A41E /* ftraster.c */, + 611E0C7F11FA8FA50077A41E /* ftraster.h */, + 611E0C8011FA8FA50077A41E /* ftrend1.c */, + 611E0C8111FA8FA50077A41E /* ftrend1.h */, + 611E0C8211FA8FA50077A41E /* raster.c */, + 611E0C8311FA8FA50077A41E /* rasterrs.h */, + 611E0C8411FA8FA50077A41E /* rastpic.c */, + 611E0C8511FA8FA50077A41E /* rastpic.h */, + ); + name = raster; + path = ../src/raster; + sourceTree = SOURCE_ROOT; + }; + 611E0C8611FA8FA50077A41E /* sfnt */ = { + isa = PBXGroup; + children = ( + 611E0C8711FA8FA50077A41E /* sfdriver.c */, + 611E0C8811FA8FA50077A41E /* sfdriver.h */, + 611E0C8911FA8FA50077A41E /* sferrors.h */, + 611E0C8A11FA8FA50077A41E /* sfnt.c */, + 611E0C8B11FA8FA50077A41E /* sfntpic.c */, + 611E0C8C11FA8FA50077A41E /* sfntpic.h */, + 611E0C8D11FA8FA50077A41E /* sfobjs.c */, + 611E0C8E11FA8FA50077A41E /* sfobjs.h */, + 611E0C8F11FA8FA50077A41E /* ttbdf.c */, + 611E0C9011FA8FA50077A41E /* ttbdf.h */, + 611E0C9111FA8FA50077A41E /* ttcmap.c */, + 611E0C9211FA8FA50077A41E /* ttcmap.h */, + 611E0C9311FA8FA50077A41E /* ttcmapc.h */, + 611E0C9411FA8FA50077A41E /* ttkern.c */, + 611E0C9511FA8FA50077A41E /* ttkern.h */, + 611E0C9611FA8FA50077A41E /* ttload.c */, + 611E0C9711FA8FA50077A41E /* ttload.h */, + 611E0C9811FA8FA50077A41E /* ttmtx.c */, + 611E0C9911FA8FA50077A41E /* ttmtx.h */, + 611E0C9A11FA8FA50077A41E /* ttpost.c */, + 611E0C9B11FA8FA50077A41E /* ttpost.h */, + 611E0C9C11FA8FA50077A41E /* ttsbit.c */, + 611E0C9D11FA8FA50077A41E /* ttsbit.h */, + 611E0C9E11FA8FA50077A41E /* ttsbit0.c */, + ); + name = sfnt; + path = ../src/sfnt; + sourceTree = SOURCE_ROOT; + }; + 611E0C9F11FA8FA50077A41E /* smooth */ = { + isa = PBXGroup; + children = ( + 611E0CA011FA8FA50077A41E /* ftgrays.c */, + 611E0CA111FA8FA50077A41E /* ftgrays.h */, + 611E0CA211FA8FA50077A41E /* ftsmerrs.h */, + 611E0CA311FA8FA50077A41E /* ftsmooth.c */, + 611E0CA411FA8FA50077A41E /* ftsmooth.h */, + 611E0CA511FA8FA50077A41E /* ftspic.c */, + 611E0CA611FA8FA50077A41E /* ftspic.h */, + 611E0CA711FA8FA50077A41E /* smooth.c */, + ); + name = smooth; + path = ../src/smooth; + sourceTree = SOURCE_ROOT; + }; + 611E0CBC11FA8FA50077A41E /* truetype */ = { + isa = PBXGroup; + children = ( + 611E0CBD11FA8FA50077A41E /* truetype.c */, + 611E0CBE11FA8FA50077A41E /* ttdriver.c */, + 611E0CBF11FA8FA50077A41E /* ttdriver.h */, + 611E0CC011FA8FA50077A41E /* tterrors.h */, + 611E0CC111FA8FA50077A41E /* ttgload.c */, + 611E0CC211FA8FA50077A41E /* ttgload.h */, + 611E0CC311FA8FA50077A41E /* ttgxvar.c */, + 611E0CC411FA8FA50077A41E /* ttgxvar.h */, + 611E0CC511FA8FA50077A41E /* ttinterp.c */, + 611E0CC611FA8FA50077A41E /* ttinterp.h */, + 611E0CC711FA8FA50077A41E /* ttobjs.c */, + 611E0CC811FA8FA50077A41E /* ttobjs.h */, + 611E0CC911FA8FA50077A41E /* ttpic.c */, + 611E0CCA11FA8FA50077A41E /* ttpic.h */, + 611E0CCB11FA8FA50077A41E /* ttpload.c */, + 611E0CCC11FA8FA50077A41E /* ttpload.h */, + ); + name = truetype; + path = ../src/truetype; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC07A0554694100DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + AA747D9F0F9514B9006C5449 /* freetype_Prefix.pch in Headers */, + 611E0B1C11FA8F610077A41E /* ftconfig.h in Headers */, + 611E0B1D11FA8F610077A41E /* ftheader.h in Headers */, + 611E0B1E11FA8F610077A41E /* ftmodule.h in Headers */, + 611E0B1F11FA8F610077A41E /* ftoption.h in Headers */, + 611E0B2011FA8F610077A41E /* ftstdlib.h in Headers */, + 611E0B2111FA8F610077A41E /* freetype.h in Headers */, + 611E0B2211FA8F610077A41E /* ftadvanc.h in Headers */, + 611E0B2311FA8F610077A41E /* ftbbox.h in Headers */, + 611E0B2411FA8F610077A41E /* ftbdf.h in Headers */, + 611E0B2511FA8F610077A41E /* ftbitmap.h in Headers */, + 611E0B2611FA8F610077A41E /* ftcache.h in Headers */, + 611E0B2711FA8F610077A41E /* ftchapters.h in Headers */, + 611E0B2811FA8F610077A41E /* ftcid.h in Headers */, + 611E0B2911FA8F610077A41E /* fterrdef.h in Headers */, + 611E0B2A11FA8F610077A41E /* fterrors.h in Headers */, + 611E0B2B11FA8F610077A41E /* ftgasp.h in Headers */, + 611E0B2C11FA8F610077A41E /* ftglyph.h in Headers */, + 611E0B2D11FA8F610077A41E /* ftgxval.h in Headers */, + 611E0B2E11FA8F610077A41E /* ftgzip.h in Headers */, + 611E0B2F11FA8F610077A41E /* ftimage.h in Headers */, + 611E0B3011FA8F610077A41E /* ftincrem.h in Headers */, + 611E0B3111FA8F610077A41E /* ftlcdfil.h in Headers */, + 611E0B3211FA8F610077A41E /* ftlist.h in Headers */, + 611E0B3311FA8F610077A41E /* ftlzw.h in Headers */, + 611E0B3411FA8F610077A41E /* ftmac.h in Headers */, + 611E0B3511FA8F610077A41E /* ftmm.h in Headers */, + 611E0B3611FA8F610077A41E /* ftmodapi.h in Headers */, + 611E0B3711FA8F610077A41E /* ftmoderr.h in Headers */, + 611E0B3811FA8F610077A41E /* ftotval.h in Headers */, + 611E0B3911FA8F610077A41E /* ftoutln.h in Headers */, + 611E0B3A11FA8F610077A41E /* ftpfr.h in Headers */, + 611E0B3B11FA8F610077A41E /* ftrender.h in Headers */, + 611E0B3C11FA8F610077A41E /* ftsizes.h in Headers */, + 611E0B3D11FA8F610077A41E /* ftsnames.h in Headers */, + 611E0B3E11FA8F610077A41E /* ftstroke.h in Headers */, + 611E0B3F11FA8F610077A41E /* ftsynth.h in Headers */, + 611E0B4011FA8F610077A41E /* ftsystem.h in Headers */, + 611E0B4111FA8F610077A41E /* fttrigon.h in Headers */, + 611E0B4211FA8F610077A41E /* fttypes.h in Headers */, + 611E0B4311FA8F610077A41E /* ftwinfnt.h in Headers */, + 611E0B4411FA8F610077A41E /* ftxf86.h in Headers */, + 611E0B4511FA8F610077A41E /* autohint.h in Headers */, + 611E0B4611FA8F610077A41E /* ftcalc.h in Headers */, + 611E0B4711FA8F610077A41E /* ftdebug.h in Headers */, + 611E0B4811FA8F610077A41E /* ftdriver.h in Headers */, + 611E0B4911FA8F610077A41E /* ftgloadr.h in Headers */, + 611E0B4A11FA8F610077A41E /* ftmemory.h in Headers */, + 611E0B4B11FA8F610077A41E /* ftobjs.h in Headers */, + 611E0B4C11FA8F610077A41E /* ftpic.h in Headers */, + 611E0B4D11FA8F610077A41E /* ftrfork.h in Headers */, + 611E0B4E11FA8F610077A41E /* ftserv.h in Headers */, + 611E0B4F11FA8F610077A41E /* ftstream.h in Headers */, + 611E0B5011FA8F610077A41E /* fttrace.h in Headers */, + 611E0B5111FA8F610077A41E /* ftvalid.h in Headers */, + 611E0B5211FA8F610077A41E /* internal.h in Headers */, + 611E0B5311FA8F610077A41E /* pcftypes.h in Headers */, + 611E0B5411FA8F610077A41E /* psaux.h in Headers */, + 611E0B5511FA8F610077A41E /* pshints.h in Headers */, + 611E0B5611FA8F610077A41E /* svbdf.h in Headers */, + 611E0B5711FA8F610077A41E /* svcid.h in Headers */, + 611E0B5811FA8F610077A41E /* svgldict.h in Headers */, + 611E0B5911FA8F610077A41E /* svgxval.h in Headers */, + 611E0B5A11FA8F610077A41E /* svkern.h in Headers */, + 611E0B5B11FA8F610077A41E /* svmm.h in Headers */, + 611E0B5C11FA8F610077A41E /* svotval.h in Headers */, + 611E0B5D11FA8F610077A41E /* svpfr.h in Headers */, + 611E0B5E11FA8F610077A41E /* svpostnm.h in Headers */, + 611E0B5F11FA8F610077A41E /* svpscmap.h in Headers */, + 611E0B6011FA8F610077A41E /* svpsinfo.h in Headers */, + 611E0B6111FA8F610077A41E /* svsfnt.h in Headers */, + 611E0B6211FA8F610077A41E /* svttcmap.h in Headers */, + 611E0B6311FA8F610077A41E /* svtteng.h in Headers */, + 611E0B6411FA8F610077A41E /* svttglyf.h in Headers */, + 611E0B6511FA8F610077A41E /* svwinfnt.h in Headers */, + 611E0B6611FA8F610077A41E /* svxf86nm.h in Headers */, + 611E0B6711FA8F610077A41E /* sfnt.h in Headers */, + 611E0B6811FA8F610077A41E /* t1types.h in Headers */, + 611E0B6911FA8F610077A41E /* tttypes.h in Headers */, + 611E0B6A11FA8F610077A41E /* t1tables.h in Headers */, + 611E0B6B11FA8F610077A41E /* ttnameid.h in Headers */, + 611E0B6C11FA8F610077A41E /* tttables.h in Headers */, + 611E0B6D11FA8F610077A41E /* tttags.h in Headers */, + 611E0B6E11FA8F610077A41E /* ttunpat.h in Headers */, + 611E0B6F11FA8F610077A41E /* ft2build.h in Headers */, + 611E0D0711FA8FA50077A41E /* basepic.h in Headers */, + 611E0D0B11FA8FA50077A41E /* ftbase.h in Headers */, + 611E0D4611FA8FA50077A41E /* cffcmap.h in Headers */, + 611E0D4811FA8FA50077A41E /* cffdrivr.h in Headers */, + 611E0D4911FA8FA50077A41E /* cfferrs.h in Headers */, + 611E0D4B11FA8FA50077A41E /* cffgload.h in Headers */, + 611E0D4D11FA8FA50077A41E /* cffload.h in Headers */, + 611E0D4F11FA8FA50077A41E /* cffobjs.h in Headers */, + 611E0D5111FA8FA50077A41E /* cffparse.h in Headers */, + 611E0D5311FA8FA50077A41E /* cffpic.h in Headers */, + 611E0D5411FA8FA50077A41E /* cfftoken.h in Headers */, + 611E0D5511FA8FA50077A41E /* cfftypes.h in Headers */, + 611E0DCA11FA8FA50077A41E /* pshalgo.h in Headers */, + 611E0DCC11FA8FA50077A41E /* pshglob.h in Headers */, + 611E0DCF11FA8FA50077A41E /* pshmod.h in Headers */, + 611E0DD011FA8FA50077A41E /* pshnterr.h in Headers */, + 611E0DD211FA8FA50077A41E /* pshpic.h in Headers */, + 611E0DD411FA8FA50077A41E /* pshrec.h in Headers */, + 611E0DD611FA8FA50077A41E /* psmodule.h in Headers */, + 611E0DD711FA8FA50077A41E /* psnamerr.h in Headers */, + 611E0DDA11FA8FA50077A41E /* pspic.h in Headers */, + 611E0DDB11FA8FA50077A41E /* pstables.h in Headers */, + 611E0DDC11FA8FA50077A41E /* ftmisc.h in Headers */, + 611E0DDE11FA8FA50077A41E /* ftraster.h in Headers */, + 611E0DE011FA8FA50077A41E /* ftrend1.h in Headers */, + 611E0DE211FA8FA50077A41E /* rasterrs.h in Headers */, + 611E0DE411FA8FA50077A41E /* rastpic.h in Headers */, + 611E0DE611FA8FA50077A41E /* sfdriver.h in Headers */, + 611E0DE711FA8FA50077A41E /* sferrors.h in Headers */, + 611E0DEA11FA8FA50077A41E /* sfntpic.h in Headers */, + 611E0DEC11FA8FA50077A41E /* sfobjs.h in Headers */, + 611E0DEE11FA8FA50077A41E /* ttbdf.h in Headers */, + 611E0DF011FA8FA50077A41E /* ttcmap.h in Headers */, + 611E0DF111FA8FA50077A41E /* ttcmapc.h in Headers */, + 611E0DF311FA8FA50077A41E /* ttkern.h in Headers */, + 611E0DF511FA8FA50077A41E /* ttload.h in Headers */, + 611E0DF711FA8FA50077A41E /* ttmtx.h in Headers */, + 611E0DF911FA8FA50077A41E /* ttpost.h in Headers */, + 611E0DFB11FA8FA50077A41E /* ttsbit.h in Headers */, + 611E0DFE11FA8FA50077A41E /* ftgrays.h in Headers */, + 611E0DFF11FA8FA50077A41E /* ftsmerrs.h in Headers */, + 611E0E0111FA8FA50077A41E /* ftsmooth.h in Headers */, + 611E0E0311FA8FA50077A41E /* ftspic.h in Headers */, + 611E0E0D11FA8FA50077A41E /* ttdriver.h in Headers */, + 611E0E0E11FA8FA50077A41E /* tterrors.h in Headers */, + 611E0E1011FA8FA50077A41E /* ttgload.h in Headers */, + 611E0E1211FA8FA50077A41E /* ttgxvar.h in Headers */, + 611E0E1411FA8FA50077A41E /* ttinterp.h in Headers */, + 611E0E1611FA8FA50077A41E /* ttobjs.h in Headers */, + 611E0E1811FA8FA50077A41E /* ttpic.h in Headers */, + 611E0E1A11FA8FA50077A41E /* ttpload.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + D2AAC07D0554694100DB518D /* libFreetype */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libFreetype" */; + buildPhases = ( + D2AAC07A0554694100DB518D /* Headers */, + D2AAC07B0554694100DB518D /* Sources */, + D2AAC07C0554694100DB518D /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = libFreetype; + productName = freetype; + productReference = D2AAC07E0554694100DB518D /* libFreetype.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0867D690FE84028FC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Freetype" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 0867D691FE84028FC02AAC07 /* freetype */; + productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2AAC07D0554694100DB518D /* libFreetype */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + D2AAC07B0554694100DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 611E0D0611FA8FA50077A41E /* basepic.c in Sources */, + 611E0D0811FA8FA50077A41E /* ftadvanc.c in Sources */, + 611E0D0911FA8FA50077A41E /* ftapi.c in Sources */, + 611E0D0A11FA8FA50077A41E /* ftbase.c in Sources */, + 611E0D0C11FA8FA50077A41E /* ftbbox.c in Sources */, + 611E0D0E11FA8FA50077A41E /* ftbitmap.c in Sources */, + 611E0D0F11FA8FA50077A41E /* ftcalc.c in Sources */, + 611E0D1111FA8FA50077A41E /* ftdbgmem.c in Sources */, + 611E0D1211FA8FA50077A41E /* ftdebug.c in Sources */, + 611E0D1511FA8FA50077A41E /* ftgloadr.c in Sources */, + 611E0D1611FA8FA50077A41E /* ftglyph.c in Sources */, + 611E0D1811FA8FA50077A41E /* ftinit.c in Sources */, + 611E0D1C11FA8FA50077A41E /* ftobjs.c in Sources */, + 611E0D1E11FA8FA50077A41E /* ftoutln.c in Sources */, + 611E0D2111FA8FA50077A41E /* ftpic.c in Sources */, + 611E0D2211FA8FA50077A41E /* ftrfork.c in Sources */, + 611E0D2311FA8FA50077A41E /* ftsnames.c in Sources */, + 611E0D2411FA8FA50077A41E /* ftstream.c in Sources */, + 611E0D2511FA8FA50077A41E /* ftstroke.c in Sources */, + 611E0D2611FA8FA50077A41E /* ftsynth.c in Sources */, + 611E0D2711FA8FA50077A41E /* ftsystem.c in Sources */, + 611E0D2811FA8FA50077A41E /* fttrigon.c in Sources */, + 611E0D2A11FA8FA50077A41E /* ftutil.c in Sources */, + 611E0D4411FA8FA50077A41E /* cff.c in Sources */, + 611E0D4511FA8FA50077A41E /* cffcmap.c in Sources */, + 611E0D4711FA8FA50077A41E /* cffdrivr.c in Sources */, + 611E0D4A11FA8FA50077A41E /* cffgload.c in Sources */, + 611E0D4C11FA8FA50077A41E /* cffload.c in Sources */, + 611E0D4E11FA8FA50077A41E /* cffobjs.c in Sources */, + 611E0D5011FA8FA50077A41E /* cffparse.c in Sources */, + 611E0D5211FA8FA50077A41E /* cffpic.c in Sources */, + 611E0DC911FA8FA50077A41E /* pshalgo.c in Sources */, + 611E0DCB11FA8FA50077A41E /* pshglob.c in Sources */, + 611E0DCD11FA8FA50077A41E /* pshinter.c in Sources */, + 611E0DCE11FA8FA50077A41E /* pshmod.c in Sources */, + 611E0DD111FA8FA50077A41E /* pshpic.c in Sources */, + 611E0DD311FA8FA50077A41E /* pshrec.c in Sources */, + 611E0DD511FA8FA50077A41E /* psmodule.c in Sources */, + 611E0DD811FA8FA50077A41E /* psnames.c in Sources */, + 611E0DD911FA8FA50077A41E /* pspic.c in Sources */, + 611E0DDD11FA8FA50077A41E /* ftraster.c in Sources */, + 611E0DDF11FA8FA50077A41E /* ftrend1.c in Sources */, + 611E0DE111FA8FA50077A41E /* raster.c in Sources */, + 611E0DE311FA8FA50077A41E /* rastpic.c in Sources */, + 611E0DE511FA8FA50077A41E /* sfdriver.c in Sources */, + 611E0DE811FA8FA50077A41E /* sfnt.c in Sources */, + 611E0DE911FA8FA50077A41E /* sfntpic.c in Sources */, + 611E0DEB11FA8FA50077A41E /* sfobjs.c in Sources */, + 611E0DED11FA8FA50077A41E /* ttbdf.c in Sources */, + 611E0DEF11FA8FA50077A41E /* ttcmap.c in Sources */, + 611E0DF211FA8FA50077A41E /* ttkern.c in Sources */, + 611E0DF411FA8FA50077A41E /* ttload.c in Sources */, + 611E0DF611FA8FA50077A41E /* ttmtx.c in Sources */, + 611E0DF811FA8FA50077A41E /* ttpost.c in Sources */, + 611E0DFA11FA8FA50077A41E /* ttsbit.c in Sources */, + 611E0DFC11FA8FA50077A41E /* ttsbit0.c in Sources */, + 611E0DFD11FA8FA50077A41E /* ftgrays.c in Sources */, + 611E0E0011FA8FA50077A41E /* ftsmooth.c in Sources */, + 611E0E0211FA8FA50077A41E /* ftspic.c in Sources */, + 611E0E0411FA8FA50077A41E /* smooth.c in Sources */, + 611E0E0B11FA8FA50077A41E /* truetype.c in Sources */, + 611E0E0C11FA8FA50077A41E /* ttdriver.c in Sources */, + 611E0E0F11FA8FA50077A41E /* ttgload.c in Sources */, + 611E0E1111FA8FA50077A41E /* ttgxvar.c in Sources */, + 611E0E1311FA8FA50077A41E /* ttinterp.c in Sources */, + 611E0E1511FA8FA50077A41E /* ttobjs.c in Sources */, + 611E0E1711FA8FA50077A41E /* ttpic.c in Sources */, + 611E0E1911FA8FA50077A41E /* ttpload.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB921F08733DC00010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = NO; + DSTROOT = /tmp/freetype.dst; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = freetype_Prefix.pch; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Freetype; + }; + name = Debug; + }; + 1DEB922008733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + DSTROOT = /tmp/freetype.dst; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = freetype_Prefix.pch; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Freetype; + }; + name = Release; + }; + 1DEB922308733DC00010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + DARWIN_NO_CARBON, + FT2_BUILD_LIBRARY, + ); + GCC_THUMB_SUPPORT = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../include\""; + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + OTHER_LDFLAGS = "-ObjC"; + PREBINDING = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 1DEB922408733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_FAST_MATH = YES; + GCC_OPTIMIZATION_LEVEL = s; + GCC_PREPROCESSOR_DEFINITIONS = ( + DARWIN_NO_CARBON, + FT2_BUILD_LIBRARY, + ); + GCC_THUMB_SUPPORT = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../include\""; + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + OTHER_LDFLAGS = "-ObjC"; + PREBINDING = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libFreetype" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB921F08733DC00010E9CD /* Debug */, + 1DEB922008733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Freetype" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB922308733DC00010E9CD /* Debug */, + 1DEB922408733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iOS/Freetype_Prefix.pch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/libfreetype/Xcode-iOS/Freetype_Prefix.pch Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project. +// + +#ifdef __OBJC__ + #import +#endif diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/default.mode1v3 --- a/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/default.mode1v3 Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1369 +0,0 @@ - - - - - ActivePerspectiveName - Project - AllowedModules - - - BundleLoadPath - - MaxInstances - n - Module - PBXSmartGroupTreeModule - Name - Groups and Files Outline View - - - BundleLoadPath - - MaxInstances - n - Module - PBXNavigatorGroup - Name - Editor - - - BundleLoadPath - - MaxInstances - n - Module - XCTaskListModule - Name - Task List - - - BundleLoadPath - - MaxInstances - n - Module - XCDetailModule - Name - File and Smart Group Detail Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXBuildResultsModule - Name - Detailed Build Results Viewer - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXProjectFindModule - Name - Project Batch Find Tool - - - BundleLoadPath - - MaxInstances - n - Module - XCProjectFormatConflictsModule - Name - Project Format Conflicts List - - - BundleLoadPath - - MaxInstances - n - Module - PBXBookmarksModule - Name - Bookmarks Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXClassBrowserModule - Name - Class Browser - - - BundleLoadPath - - MaxInstances - n - Module - PBXCVSModule - Name - Source Code Control Tool - - - BundleLoadPath - - MaxInstances - n - Module - PBXDebugBreakpointsModule - Name - Debug Breakpoints Tool - - - BundleLoadPath - - MaxInstances - n - Module - XCDockableInspector - Name - Inspector - - - BundleLoadPath - - MaxInstances - n - Module - PBXOpenQuicklyModule - Name - Open Quickly Tool - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugSessionModule - Name - Debugger - - - BundleLoadPath - - MaxInstances - 1 - Module - PBXDebugCLIModule - Name - Debug Console - - - BundleLoadPath - - MaxInstances - n - Module - XCSnapshotModule - Name - Snapshots Tool - - - BundlePath - /Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources - Description - DefaultDescriptionKey - DockingSystemVisible - - Extension - mode1v3 - FavBarConfig - - PBXProjectModuleGUID - 611E0B7211FA8F650077A41E - XCBarModuleItemNames - - XCBarModuleItems - - - FirstTimeWindowDisplayed - - Identifier - com.apple.perspectives.project.mode1v3 - MajorVersion - 33 - MinorVersion - 0 - Name - Default - Notifications - - OpenEditors - - PerspectiveWidths - - -1 - -1 - - Perspectives - - - ChosenToolbarItems - - active-combo-popup - active-executable-popup - NSToolbarFlexibleSpaceItem - debugger-enable-breakpoints - buildOrClean - build-and-go - clean-target - com.apple.ide.PBXToolbarStopButton - NSToolbarFlexibleSpaceItem - - ControllerClassBaseName - - IconName - WindowOfProjectWithEditor - Identifier - perspective.project - IsVertical - - Layout - - - BecomeActive - - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 0867D691FE84028FC02AAC07 - 08FB77AEFE84172EC02AAC07 - 1C37FBAC04509CD000000102 - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 445}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 463}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 586 569 788 504 0 0 1920 1178 - - Module - PBXSmartGroupTreeModule - Proportion - 203pt - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20306471E060097A5F4 - PBXProjectModuleLabel - ftconfig.h - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CE0B20406471E060097A5F4 - PBXProjectModuleLabel - ftconfig.h - _historyCapacity - 0 - bookmark - 619599D11364E6FE00B429B6 - history - - 611E0E5811FA92660077A41E - 619599AE1364E63300B429B6 - 619599C11364E6C400B429B6 - - - SplitCount - 1 - - StatusBarVisibility - - - GeometryConfiguration - - Frame - {{0, 0}, {580, 211}} - RubberWindowFrame - 586 569 788 504 0 0 1920 1178 - - Module - PBXNavigatorGroup - Proportion - 211pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CE0B20506471E060097A5F4 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{0, 216}, {580, 247}} - RubberWindowFrame - 586 569 788 504 0 0 1920 1178 - - Module - XCDetailModule - Proportion - 247pt - - - Proportion - 580pt - - - Name - Project - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - XCModuleDock - PBXNavigatorGroup - XCDetailModule - - TableOfContents - - 619599D21364E6FE00B429B6 - 1CE0B1FE06471DED0097A5F4 - 619599D31364E6FE00B429B6 - 1CE0B20306471E060097A5F4 - 1CE0B20506471E060097A5F4 - - ToolbarConfigUserDefaultsMinorVersion - 2 - ToolbarConfiguration - xcode.toolbar.config.defaultV3 - - - ControllerClassBaseName - - IconName - WindowOfProject - Identifier - perspective.morph - IsVertical - 0 - Layout - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C37FBAC04509CD000000102 - 1C37FAAC04509CD000000102 - 1C08E77C0454961000C914BD - 1C37FABC05509CD000000102 - 1C37FABC05539CD112110102 - E2644B35053B69B200211256 - 1C37FABC04509CD000100104 - 1CC0EA4004350EF90044410B - 1CC0EA4004350EF90041110B - - PBXProjectModuleGUID - 11E0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - yes - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 186 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 29B97314FDCFA39411CA2CEA - 1C37FABC05509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {186, 337}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 1 - XCSharingToken - com.apple.Xcode.GFSharingToken - - GeometryConfiguration - - Frame - {{0, 0}, {203, 355}} - GroupTreeTableConfiguration - - MainColumn - 186 - - RubberWindowFrame - 373 269 690 397 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 100% - - - Name - Morph - PreferredWidth - 300 - ServiceClasses - - XCModuleDock - PBXSmartGroupTreeModule - - TableOfContents - - 11E0B1FE06471DED0097A5F4 - - ToolbarConfiguration - xcode.toolbar.config.default.shortV3 - - - PerspectivesBarVisible - - ShelfIsVisible - - SourceDescription - file at '/Developer/Library/PrivateFrameworks/DevToolsInterface.framework/Resources/XCPerspectivesSpecificationMode1.xcperspec' - StatusbarIsVisible - - TimeStamp - 0.0 - ToolbarConfigUserDefaultsMinorVersion - 2 - ToolbarDisplayMode - 1 - ToolbarIsVisible - - ToolbarSizeMode - 1 - Type - Perspectives - UpdateMessage - The Default Workspace in this version of Xcode now includes support to hide and show the detail view (what has been referred to as the "Metro-Morph" feature). You must discard your current Default Workspace settings and update to the latest Default Workspace in order to gain this feature. Do you wish to update to the latest Workspace defaults for project '%@'? - WindowJustification - 5 - WindowOrderList - - 611E0B7311FA8F650077A41E - /Users/vittorio/hedgewars/trunk/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj - - WindowString - 586 569 788 504 0 0 1920 1178 - WindowToolsV3 - - - FirstTimeWindowDisplayed - - Identifier - windowTool.build - IsVertical - - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528F0623707200166675 - PBXProjectModuleLabel - - StatusBarVisibility - - - GeometryConfiguration - - Frame - {{0, 0}, {1145, 432}} - RubberWindowFrame - 1167 248 1145 714 0 0 1920 1178 - - Module - PBXNavigatorGroup - Proportion - 432pt - - - ContentConfiguration - - PBXProjectModuleGUID - XCMainBuildResultsModuleGUID - PBXProjectModuleLabel - Build Results - XCBuildResultsTrigger_Collapse - 1021 - XCBuildResultsTrigger_Open - 1011 - - GeometryConfiguration - - Frame - {{0, 437}, {1145, 236}} - RubberWindowFrame - 1167 248 1145 714 0 0 1920 1178 - - Module - PBXBuildResultsModule - Proportion - 236pt - - - Proportion - 673pt - - - Name - Build Results - ServiceClasses - - PBXBuildResultsModule - - StatusbarIsVisible - - TableOfContents - - 611E0B7311FA8F650077A41E - 619599D41364E6FE00B429B6 - 1CD0528F0623707200166675 - XCMainBuildResultsModuleGUID - - ToolbarConfiguration - xcode.toolbar.config.buildV3 - WindowContentMinSize - 486 300 - WindowString - 1167 248 1145 714 0 0 1920 1178 - WindowToolGUID - 611E0B7311FA8F650077A41E - WindowToolIsVisible - - - - Identifier - windowTool.debugger - Layout - - - Dock - - - ContentConfiguration - - Debugger - - HorizontalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {317, 164}} - {{317, 0}, {377, 164}} - - - VerticalSplitView - - _collapsingFrameDimension - 0.0 - _indexOfCollapsedView - 0 - _percentageOfCollapsedView - 0.0 - isCollapsed - yes - sizes - - {{0, 0}, {694, 164}} - {{0, 164}, {694, 216}} - - - - LauncherConfigVersion - 8 - PBXProjectModuleGUID - 1C162984064C10D400B95A72 - PBXProjectModuleLabel - Debug - GLUTExamples (Underwater) - - GeometryConfiguration - - DebugConsoleDrawerSize - {100, 120} - DebugConsoleVisible - None - DebugConsoleWindowFrame - {{200, 200}, {500, 300}} - DebugSTDIOWindowFrame - {{200, 200}, {500, 300}} - Frame - {{0, 0}, {694, 380}} - RubberWindowFrame - 321 238 694 422 0 0 1440 878 - - Module - PBXDebugSessionModule - Proportion - 100% - - - Proportion - 100% - - - Name - Debugger - ServiceClasses - - PBXDebugSessionModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CD10A99069EF8BA00B06720 - 1C0AD2AB069F1E9B00FABCE6 - 1C162984064C10D400B95A72 - 1C0AD2AC069F1E9B00FABCE6 - - ToolbarConfiguration - xcode.toolbar.config.debugV3 - WindowString - 321 238 694 422 0 0 1440 878 - WindowToolGUID - 1CD10A99069EF8BA00B06720 - WindowToolIsVisible - 0 - - - Identifier - windowTool.find - Layout - - - Dock - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1CDD528C0622207200134675 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1CD0528D0623707200166675 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {781, 167}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXNavigatorGroup - Proportion - 781pt - - - Proportion - 50% - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD0528E0623707200166675 - PBXProjectModuleLabel - Project Find - - GeometryConfiguration - - Frame - {{8, 0}, {773, 254}} - RubberWindowFrame - 62 385 781 470 0 0 1440 878 - - Module - PBXProjectFindModule - Proportion - 50% - - - Proportion - 428pt - - - Name - Project Find - ServiceClasses - - PBXProjectFindModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C530D57069F1CE1000CFCEE - 1C530D58069F1CE1000CFCEE - 1C530D59069F1CE1000CFCEE - 1CDD528C0622207200134675 - 1C530D5A069F1CE1000CFCEE - 1CE0B1FE06471DED0097A5F4 - 1CD0528E0623707200166675 - - WindowString - 62 385 781 470 0 0 1440 878 - WindowToolGUID - 1C530D57069F1CE1000CFCEE - WindowToolIsVisible - 0 - - - Identifier - MENUSEPARATOR - - - Identifier - windowTool.debuggerConsole - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAAC065D492600B07095 - PBXProjectModuleLabel - Debugger Console - - GeometryConfiguration - - Frame - {{0, 0}, {650, 250}} - RubberWindowFrame - 516 632 650 250 0 0 1680 1027 - - Module - PBXDebugCLIModule - Proportion - 209pt - - - Proportion - 209pt - - - Name - Debugger Console - ServiceClasses - - PBXDebugCLIModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAAD065D492600B07095 - 1C78EAAE065D492600B07095 - 1C78EAAC065D492600B07095 - - ToolbarConfiguration - xcode.toolbar.config.consoleV3 - WindowString - 650 41 650 250 0 0 1280 1002 - WindowToolGUID - 1C78EAAD065D492600B07095 - WindowToolIsVisible - 0 - - - Identifier - windowTool.snapshots - Layout - - - Dock - - - Module - XCSnapshotModule - Proportion - 100% - - - Proportion - 100% - - - Name - Snapshots - ServiceClasses - - XCSnapshotModule - - StatusbarIsVisible - Yes - ToolbarConfiguration - xcode.toolbar.config.snapshots - WindowString - 315 824 300 550 0 0 1440 878 - WindowToolIsVisible - Yes - - - Identifier - windowTool.scm - Layout - - - Dock - - - ContentConfiguration - - PBXProjectModuleGUID - 1C78EAB2065D492600B07095 - PBXProjectModuleLabel - <No Editor> - PBXSplitModuleInNavigatorKey - - Split0 - - PBXProjectModuleGUID - 1C78EAB3065D492600B07095 - - SplitCount - 1 - - StatusBarVisibility - 1 - - GeometryConfiguration - - Frame - {{0, 0}, {452, 0}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - - Module - PBXNavigatorGroup - Proportion - 0pt - - - BecomeActive - 1 - ContentConfiguration - - PBXProjectModuleGUID - 1CD052920623707200166675 - PBXProjectModuleLabel - SCM - - GeometryConfiguration - - ConsoleFrame - {{0, 259}, {452, 0}} - Frame - {{0, 7}, {452, 259}} - RubberWindowFrame - 743 379 452 308 0 0 1280 1002 - TableConfiguration - - Status - 30 - FileName - 199 - Path - 197.0950012207031 - - TableFrame - {{0, 0}, {452, 250}} - - Module - PBXCVSModule - Proportion - 262pt - - - Proportion - 266pt - - - Name - SCM - ServiceClasses - - PBXCVSModule - - StatusbarIsVisible - 1 - TableOfContents - - 1C78EAB4065D492600B07095 - 1C78EAB5065D492600B07095 - 1C78EAB2065D492600B07095 - 1CD052920623707200166675 - - ToolbarConfiguration - xcode.toolbar.config.scm - WindowString - 743 379 452 308 0 0 1280 1002 - - - Identifier - windowTool.breakpoints - IsVertical - 0 - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - PBXBottomSmartGroupGIDs - - 1C77FABC04509CD000000102 - - PBXProjectModuleGUID - 1CE0B1FE06471DED0097A5F4 - PBXProjectModuleLabel - Files - PBXProjectStructureProvided - no - PBXSmartGroupTreeModuleColumnData - - PBXSmartGroupTreeModuleColumnWidthsKey - - 168 - - PBXSmartGroupTreeModuleColumnsKey_v4 - - MainColumn - - - PBXSmartGroupTreeModuleOutlineStateKey_v7 - - PBXSmartGroupTreeModuleOutlineStateExpansionKey - - 1C77FABC04509CD000000102 - - PBXSmartGroupTreeModuleOutlineStateSelectionKey - - - 0 - - - PBXSmartGroupTreeModuleOutlineStateVisibleRectKey - {{0, 0}, {168, 350}} - - PBXTopSmartGroupGIDs - - XCIncludePerspectivesSwitch - 0 - - GeometryConfiguration - - Frame - {{0, 0}, {185, 368}} - GroupTreeTableConfiguration - - MainColumn - 168 - - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - PBXSmartGroupTreeModule - Proportion - 185pt - - - ContentConfiguration - - PBXProjectModuleGUID - 1CA1AED706398EBD00589147 - PBXProjectModuleLabel - Detail - - GeometryConfiguration - - Frame - {{190, 0}, {554, 368}} - RubberWindowFrame - 315 424 744 409 0 0 1440 878 - - Module - XCDetailModule - Proportion - 554pt - - - Proportion - 368pt - - - MajorVersion - 3 - MinorVersion - 0 - Name - Breakpoints - ServiceClasses - - PBXSmartGroupTreeModule - XCDetailModule - - StatusbarIsVisible - 1 - TableOfContents - - 1CDDB66807F98D9800BB5817 - 1CDDB66907F98D9800BB5817 - 1CE0B1FE06471DED0097A5F4 - 1CA1AED706398EBD00589147 - - ToolbarConfiguration - xcode.toolbar.config.breakpointsV3 - WindowString - 315 424 744 409 0 0 1440 878 - WindowToolGUID - 1CDDB66807F98D9800BB5817 - WindowToolIsVisible - 1 - - - Identifier - windowTool.debugAnimator - Layout - - - Dock - - - Module - PBXNavigatorGroup - Proportion - 100% - - - Proportion - 100% - - - Name - Debug Visualizer - ServiceClasses - - PBXNavigatorGroup - - StatusbarIsVisible - 1 - ToolbarConfiguration - xcode.toolbar.config.debugAnimatorV3 - WindowString - 100 100 700 500 0 0 1280 1002 - - - Identifier - windowTool.bookmarks - Layout - - - Dock - - - Module - PBXBookmarksModule - Proportion - 100% - - - Proportion - 100% - - - Name - Bookmarks - ServiceClasses - - PBXBookmarksModule - - StatusbarIsVisible - 0 - WindowString - 538 42 401 187 0 0 1280 1002 - - - Identifier - windowTool.projectFormatConflicts - Layout - - - Dock - - - Module - XCProjectFormatConflictsModule - Proportion - 100% - - - Proportion - 100% - - - Name - Project Format Conflicts - ServiceClasses - - XCProjectFormatConflictsModule - - StatusbarIsVisible - 0 - WindowContentMinSize - 450 300 - WindowString - 50 850 472 307 0 0 1440 877 - - - Identifier - windowTool.classBrowser - Layout - - - Dock - - - BecomeActive - 1 - ContentConfiguration - - OptionsSetName - Hierarchy, all classes - PBXProjectModuleGUID - 1CA6456E063B45B4001379D8 - PBXProjectModuleLabel - Class Browser - NSObject - - GeometryConfiguration - - ClassesFrame - {{0, 0}, {374, 96}} - ClassesTreeTableConfiguration - - PBXClassNameColumnIdentifier - 208 - PBXClassBookColumnIdentifier - 22 - - Frame - {{0, 0}, {630, 331}} - MembersFrame - {{0, 105}, {374, 395}} - MembersTreeTableConfiguration - - PBXMemberTypeIconColumnIdentifier - 22 - PBXMemberNameColumnIdentifier - 216 - PBXMemberTypeColumnIdentifier - 97 - PBXMemberBookColumnIdentifier - 22 - - PBXModuleWindowStatusBarHidden2 - 1 - RubberWindowFrame - 385 179 630 352 0 0 1440 878 - - Module - PBXClassBrowserModule - Proportion - 332pt - - - Proportion - 332pt - - - Name - Class Browser - ServiceClasses - - PBXClassBrowserModule - - StatusbarIsVisible - 0 - TableOfContents - - 1C0AD2AF069F1E9B00FABCE6 - 1C0AD2B0069F1E9B00FABCE6 - 1CA6456E063B45B4001379D8 - - ToolbarConfiguration - xcode.toolbar.config.classbrowser - WindowString - 385 179 630 352 0 0 1440 878 - WindowToolGUID - 1C0AD2AF069F1E9B00FABCE6 - WindowToolIsVisible - 0 - - - Identifier - windowTool.refactoring - IncludeInToolsMenu - 0 - Layout - - - Dock - - - BecomeActive - 1 - GeometryConfiguration - - Frame - {0, 0}, {500, 335} - RubberWindowFrame - {0, 0}, {500, 335} - - Module - XCRefactoringModule - Proportion - 100% - - - Proportion - 100% - - - Name - Refactoring - ServiceClasses - - XCRefactoringModule - - WindowString - 200 200 500 356 0 0 1920 1200 - - - - diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/default.pbxuser --- a/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/default.pbxuser Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,165 +0,0 @@ -// !$*UTF8*$! -{ - 0867D690FE84028FC02AAC07 /* Project object */ = { - activeBuildConfigurationName = Release; - activeSDKPreference = iphoneos4.2; - activeTarget = D2AAC07D0554694100DB518D /* libFreetype */; - addToTargets = ( - D2AAC07D0554694100DB518D /* libFreetype */, - ); - codeSenseManager = 611E0AC211FA8EB70077A41E /* Code sense */; - perUserDictionary = { - PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 341, - 20, - 48, - 43, - 43, - 20, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - PBXFileDataSource_Target_ColumnID, - ); - }; - PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 301, - 60, - 20, - 48, - 43, - 43, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXTargetDataSource_PrimaryAttribute, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - ); - }; - PBXPerProjectTemplateStateSaveDate = 325379832; - PBXWorkspaceStateSaveDate = 325379832; - }; - perUserProjectItems = { - 611E0E5811FA92660077A41E /* PBXTextBookmark */ = 611E0E5811FA92660077A41E /* PBXTextBookmark */; - 619599AE1364E63300B429B6 /* PBXTextBookmark */ = 619599AE1364E63300B429B6 /* PBXTextBookmark */; - 619599C11364E6C400B429B6 /* PBXTextBookmark */ = 619599C11364E6C400B429B6 /* PBXTextBookmark */; - 619599D11364E6FE00B429B6 /* PBXTextBookmark */ = 619599D11364E6FE00B429B6 /* PBXTextBookmark */; - }; - sourceControlManager = 611E0AC111FA8EB70077A41E /* Source Control */; - userBuildSettings = { - }; - }; - 611E0AC111FA8EB70077A41E /* Source Control */ = { - isa = PBXSourceControlManager; - fallbackIsa = XCSourceControlManager; - isSCMEnabled = 0; - scmConfiguration = { - repositoryNamesForRoots = { - "" = ""; - }; - }; - }; - 611E0AC211FA8EB70077A41E /* Code sense */ = { - isa = PBXCodeSenseManager; - indexTemplatePath = ""; - }; - 611E0AC611FA8F610077A41E /* ftconfig.h */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {551, 8010}}"; - sepNavSelRange = "{14485, 0}"; - sepNavVisRange = "{14279, 398}"; - sepNavWindowFrame = "{{1172, 58}, {1078, 737}}"; - }; - }; - 611E0AC811FA8F610077A41E /* ftmodule.h */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {530, 540}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRange = "{0, 593}"; - sepNavWindowFrame = "{{846, 195}, {1078, 737}}"; - }; - }; - 611E0B9D11FA8FA50077A41E /* ftbase.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {1084, 540}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRange = "{0, 1416}"; - sepNavWindowFrame = "{{130, 223}, {1081, 845}}"; - }; - }; - 611E0BB111FA8FA50077A41E /* ftoutln.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {551, 16755}}"; - sepNavSelRange = "{4755, 0}"; - sepNavVisRange = "{4575, 410}"; - }; - }; - 611E0CC111FA8FA50077A41E /* ttgload.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {829, 32040}}"; - sepNavSelRange = "{52031, 0}"; - sepNavVisRange = "{51255, 1537}"; - sepNavWindowFrame = "{{130, 250}, {888, 818}}"; - }; - }; - 611E0E5811FA92660077A41E /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 611E0AC811FA8F610077A41E /* ftmodule.h */; - name = "ftmodule.h: 1"; - rLen = 0; - rLoc = 0; - rType = 0; - vrLen = 593; - vrLoc = 0; - }; - 619599AE1364E63300B429B6 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 611E0BB111FA8FA50077A41E /* ftoutln.c */; - name = "ftoutln.c: 130"; - rLen = 0; - rLoc = 4755; - rType = 0; - vrLen = 410; - vrLoc = 4575; - }; - 619599C11364E6C400B429B6 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; - name = "ftconfig.h: 351"; - rLen = 0; - rLoc = 14485; - rType = 0; - vrLen = 398; - vrLoc = 14279; - }; - 619599D11364E6FE00B429B6 /* PBXTextBookmark */ = { - isa = PBXTextBookmark; - fRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; - name = "ftconfig.h: 351"; - rLen = 0; - rLoc = 14485; - rType = 0; - vrLen = 398; - vrLoc = 14279; - }; - D2AAC07D0554694100DB518D /* libFreetype */ = { - activeExec = 0; - }; -} diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/project.pbxproj --- a/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/project.pbxproj Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1161 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 45; - objects = { - -/* Begin PBXBuildFile section */ - 611E0B1C11FA8F610077A41E /* ftconfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC611FA8F610077A41E /* ftconfig.h */; }; - 611E0B1D11FA8F610077A41E /* ftheader.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC711FA8F610077A41E /* ftheader.h */; }; - 611E0B1E11FA8F610077A41E /* ftmodule.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC811FA8F610077A41E /* ftmodule.h */; }; - 611E0B1F11FA8F610077A41E /* ftoption.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AC911FA8F610077A41E /* ftoption.h */; }; - 611E0B2011FA8F610077A41E /* ftstdlib.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACA11FA8F610077A41E /* ftstdlib.h */; }; - 611E0B2111FA8F610077A41E /* freetype.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACB11FA8F610077A41E /* freetype.h */; }; - 611E0B2211FA8F610077A41E /* ftadvanc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACC11FA8F610077A41E /* ftadvanc.h */; }; - 611E0B2311FA8F610077A41E /* ftbbox.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACD11FA8F610077A41E /* ftbbox.h */; }; - 611E0B2411FA8F610077A41E /* ftbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACE11FA8F610077A41E /* ftbdf.h */; }; - 611E0B2511FA8F610077A41E /* ftbitmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ACF11FA8F610077A41E /* ftbitmap.h */; }; - 611E0B2611FA8F610077A41E /* ftcache.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD011FA8F610077A41E /* ftcache.h */; }; - 611E0B2711FA8F610077A41E /* ftchapters.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD111FA8F610077A41E /* ftchapters.h */; }; - 611E0B2811FA8F610077A41E /* ftcid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD211FA8F610077A41E /* ftcid.h */; }; - 611E0B2911FA8F610077A41E /* fterrdef.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD311FA8F610077A41E /* fterrdef.h */; }; - 611E0B2A11FA8F610077A41E /* fterrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD411FA8F610077A41E /* fterrors.h */; }; - 611E0B2B11FA8F610077A41E /* ftgasp.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD511FA8F610077A41E /* ftgasp.h */; }; - 611E0B2C11FA8F610077A41E /* ftglyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD611FA8F610077A41E /* ftglyph.h */; }; - 611E0B2D11FA8F610077A41E /* ftgxval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD711FA8F610077A41E /* ftgxval.h */; }; - 611E0B2E11FA8F610077A41E /* ftgzip.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD811FA8F610077A41E /* ftgzip.h */; }; - 611E0B2F11FA8F610077A41E /* ftimage.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AD911FA8F610077A41E /* ftimage.h */; }; - 611E0B3011FA8F610077A41E /* ftincrem.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADA11FA8F610077A41E /* ftincrem.h */; }; - 611E0B3111FA8F610077A41E /* ftlcdfil.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADB11FA8F610077A41E /* ftlcdfil.h */; }; - 611E0B3211FA8F610077A41E /* ftlist.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADC11FA8F610077A41E /* ftlist.h */; }; - 611E0B3311FA8F610077A41E /* ftlzw.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADD11FA8F610077A41E /* ftlzw.h */; }; - 611E0B3411FA8F610077A41E /* ftmac.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADE11FA8F610077A41E /* ftmac.h */; }; - 611E0B3511FA8F610077A41E /* ftmm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0ADF11FA8F610077A41E /* ftmm.h */; }; - 611E0B3611FA8F610077A41E /* ftmodapi.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE011FA8F610077A41E /* ftmodapi.h */; }; - 611E0B3711FA8F610077A41E /* ftmoderr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE111FA8F610077A41E /* ftmoderr.h */; }; - 611E0B3811FA8F610077A41E /* ftotval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE211FA8F610077A41E /* ftotval.h */; }; - 611E0B3911FA8F610077A41E /* ftoutln.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE311FA8F610077A41E /* ftoutln.h */; }; - 611E0B3A11FA8F610077A41E /* ftpfr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE411FA8F610077A41E /* ftpfr.h */; }; - 611E0B3B11FA8F610077A41E /* ftrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE511FA8F610077A41E /* ftrender.h */; }; - 611E0B3C11FA8F610077A41E /* ftsizes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE611FA8F610077A41E /* ftsizes.h */; }; - 611E0B3D11FA8F610077A41E /* ftsnames.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE711FA8F610077A41E /* ftsnames.h */; }; - 611E0B3E11FA8F610077A41E /* ftstroke.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE811FA8F610077A41E /* ftstroke.h */; }; - 611E0B3F11FA8F610077A41E /* ftsynth.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AE911FA8F610077A41E /* ftsynth.h */; }; - 611E0B4011FA8F610077A41E /* ftsystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEA11FA8F610077A41E /* ftsystem.h */; }; - 611E0B4111FA8F610077A41E /* fttrigon.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEB11FA8F610077A41E /* fttrigon.h */; }; - 611E0B4211FA8F610077A41E /* fttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEC11FA8F610077A41E /* fttypes.h */; }; - 611E0B4311FA8F610077A41E /* ftwinfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AED11FA8F610077A41E /* ftwinfnt.h */; }; - 611E0B4411FA8F610077A41E /* ftxf86.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AEE11FA8F610077A41E /* ftxf86.h */; }; - 611E0B4511FA8F610077A41E /* autohint.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF011FA8F610077A41E /* autohint.h */; }; - 611E0B4611FA8F610077A41E /* ftcalc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF111FA8F610077A41E /* ftcalc.h */; }; - 611E0B4711FA8F610077A41E /* ftdebug.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF211FA8F610077A41E /* ftdebug.h */; }; - 611E0B4811FA8F610077A41E /* ftdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF311FA8F610077A41E /* ftdriver.h */; }; - 611E0B4911FA8F610077A41E /* ftgloadr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF411FA8F610077A41E /* ftgloadr.h */; }; - 611E0B4A11FA8F610077A41E /* ftmemory.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF511FA8F610077A41E /* ftmemory.h */; }; - 611E0B4B11FA8F610077A41E /* ftobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF611FA8F610077A41E /* ftobjs.h */; }; - 611E0B4C11FA8F610077A41E /* ftpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF711FA8F610077A41E /* ftpic.h */; }; - 611E0B4D11FA8F610077A41E /* ftrfork.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF811FA8F610077A41E /* ftrfork.h */; }; - 611E0B4E11FA8F610077A41E /* ftserv.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AF911FA8F610077A41E /* ftserv.h */; }; - 611E0B4F11FA8F610077A41E /* ftstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFA11FA8F610077A41E /* ftstream.h */; }; - 611E0B5011FA8F610077A41E /* fttrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFB11FA8F610077A41E /* fttrace.h */; }; - 611E0B5111FA8F610077A41E /* ftvalid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFC11FA8F610077A41E /* ftvalid.h */; }; - 611E0B5211FA8F610077A41E /* internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFD11FA8F610077A41E /* internal.h */; }; - 611E0B5311FA8F610077A41E /* pcftypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFE11FA8F610077A41E /* pcftypes.h */; }; - 611E0B5411FA8F610077A41E /* psaux.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0AFF11FA8F610077A41E /* psaux.h */; }; - 611E0B5511FA8F610077A41E /* pshints.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0011FA8F610077A41E /* pshints.h */; }; - 611E0B5611FA8F610077A41E /* svbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0211FA8F610077A41E /* svbdf.h */; }; - 611E0B5711FA8F610077A41E /* svcid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0311FA8F610077A41E /* svcid.h */; }; - 611E0B5811FA8F610077A41E /* svgldict.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0411FA8F610077A41E /* svgldict.h */; }; - 611E0B5911FA8F610077A41E /* svgxval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0511FA8F610077A41E /* svgxval.h */; }; - 611E0B5A11FA8F610077A41E /* svkern.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0611FA8F610077A41E /* svkern.h */; }; - 611E0B5B11FA8F610077A41E /* svmm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0711FA8F610077A41E /* svmm.h */; }; - 611E0B5C11FA8F610077A41E /* svotval.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0811FA8F610077A41E /* svotval.h */; }; - 611E0B5D11FA8F610077A41E /* svpfr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0911FA8F610077A41E /* svpfr.h */; }; - 611E0B5E11FA8F610077A41E /* svpostnm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0A11FA8F610077A41E /* svpostnm.h */; }; - 611E0B5F11FA8F610077A41E /* svpscmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0B11FA8F610077A41E /* svpscmap.h */; }; - 611E0B6011FA8F610077A41E /* svpsinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0C11FA8F610077A41E /* svpsinfo.h */; }; - 611E0B6111FA8F610077A41E /* svsfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0D11FA8F610077A41E /* svsfnt.h */; }; - 611E0B6211FA8F610077A41E /* svttcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0E11FA8F610077A41E /* svttcmap.h */; }; - 611E0B6311FA8F610077A41E /* svtteng.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B0F11FA8F610077A41E /* svtteng.h */; }; - 611E0B6411FA8F610077A41E /* svttglyf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1011FA8F610077A41E /* svttglyf.h */; }; - 611E0B6511FA8F610077A41E /* svwinfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1111FA8F610077A41E /* svwinfnt.h */; }; - 611E0B6611FA8F610077A41E /* svxf86nm.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1211FA8F610077A41E /* svxf86nm.h */; }; - 611E0B6711FA8F610077A41E /* sfnt.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1311FA8F610077A41E /* sfnt.h */; }; - 611E0B6811FA8F610077A41E /* t1types.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1411FA8F610077A41E /* t1types.h */; }; - 611E0B6911FA8F610077A41E /* tttypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1511FA8F610077A41E /* tttypes.h */; }; - 611E0B6A11FA8F610077A41E /* t1tables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1611FA8F610077A41E /* t1tables.h */; }; - 611E0B6B11FA8F610077A41E /* ttnameid.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1711FA8F610077A41E /* ttnameid.h */; }; - 611E0B6C11FA8F610077A41E /* tttables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1811FA8F610077A41E /* tttables.h */; }; - 611E0B6D11FA8F610077A41E /* tttags.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1911FA8F610077A41E /* tttags.h */; }; - 611E0B6E11FA8F610077A41E /* ttunpat.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1A11FA8F610077A41E /* ttunpat.h */; }; - 611E0B6F11FA8F610077A41E /* ft2build.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B1B11FA8F610077A41E /* ft2build.h */; }; - 611E0D0611FA8FA50077A41E /* basepic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9911FA8FA50077A41E /* basepic.c */; }; - 611E0D0711FA8FA50077A41E /* basepic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B9A11FA8FA50077A41E /* basepic.h */; }; - 611E0D0811FA8FA50077A41E /* ftadvanc.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9B11FA8FA50077A41E /* ftadvanc.c */; }; - 611E0D0911FA8FA50077A41E /* ftapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9C11FA8FA50077A41E /* ftapi.c */; }; - 611E0D0A11FA8FA50077A41E /* ftbase.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9D11FA8FA50077A41E /* ftbase.c */; }; - 611E0D0B11FA8FA50077A41E /* ftbase.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0B9E11FA8FA50077A41E /* ftbase.h */; }; - 611E0D0C11FA8FA50077A41E /* ftbbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0B9F11FA8FA50077A41E /* ftbbox.c */; }; - 611E0D0E11FA8FA50077A41E /* ftbitmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA111FA8FA50077A41E /* ftbitmap.c */; }; - 611E0D0F11FA8FA50077A41E /* ftcalc.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA211FA8FA50077A41E /* ftcalc.c */; }; - 611E0D1111FA8FA50077A41E /* ftdbgmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA411FA8FA50077A41E /* ftdbgmem.c */; }; - 611E0D1211FA8FA50077A41E /* ftdebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA511FA8FA50077A41E /* ftdebug.c */; }; - 611E0D1511FA8FA50077A41E /* ftgloadr.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA811FA8FA50077A41E /* ftgloadr.c */; }; - 611E0D1611FA8FA50077A41E /* ftglyph.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BA911FA8FA50077A41E /* ftglyph.c */; }; - 611E0D1811FA8FA50077A41E /* ftinit.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BAB11FA8FA50077A41E /* ftinit.c */; }; - 611E0D1C11FA8FA50077A41E /* ftobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BAF11FA8FA50077A41E /* ftobjs.c */; }; - 611E0D1E11FA8FA50077A41E /* ftoutln.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB111FA8FA50077A41E /* ftoutln.c */; }; - 611E0D2111FA8FA50077A41E /* ftpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB411FA8FA50077A41E /* ftpic.c */; }; - 611E0D2211FA8FA50077A41E /* ftrfork.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB511FA8FA50077A41E /* ftrfork.c */; }; - 611E0D2311FA8FA50077A41E /* ftsnames.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB611FA8FA50077A41E /* ftsnames.c */; }; - 611E0D2411FA8FA50077A41E /* ftstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB711FA8FA50077A41E /* ftstream.c */; }; - 611E0D2511FA8FA50077A41E /* ftstroke.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB811FA8FA50077A41E /* ftstroke.c */; }; - 611E0D2611FA8FA50077A41E /* ftsynth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BB911FA8FA50077A41E /* ftsynth.c */; }; - 611E0D2711FA8FA50077A41E /* ftsystem.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBA11FA8FA50077A41E /* ftsystem.c */; }; - 611E0D2811FA8FA50077A41E /* fttrigon.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBB11FA8FA50077A41E /* fttrigon.c */; }; - 611E0D2A11FA8FA50077A41E /* ftutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BBD11FA8FA50077A41E /* ftutil.c */; }; - 611E0D4411FA8FA50077A41E /* cff.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDA11FA8FA50077A41E /* cff.c */; }; - 611E0D4511FA8FA50077A41E /* cffcmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDB11FA8FA50077A41E /* cffcmap.c */; }; - 611E0D4611FA8FA50077A41E /* cffcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDC11FA8FA50077A41E /* cffcmap.h */; }; - 611E0D4711FA8FA50077A41E /* cffdrivr.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BDD11FA8FA50077A41E /* cffdrivr.c */; }; - 611E0D4811FA8FA50077A41E /* cffdrivr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDE11FA8FA50077A41E /* cffdrivr.h */; }; - 611E0D4911FA8FA50077A41E /* cfferrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BDF11FA8FA50077A41E /* cfferrs.h */; }; - 611E0D4A11FA8FA50077A41E /* cffgload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE011FA8FA50077A41E /* cffgload.c */; }; - 611E0D4B11FA8FA50077A41E /* cffgload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE111FA8FA50077A41E /* cffgload.h */; }; - 611E0D4C11FA8FA50077A41E /* cffload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE211FA8FA50077A41E /* cffload.c */; }; - 611E0D4D11FA8FA50077A41E /* cffload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE311FA8FA50077A41E /* cffload.h */; }; - 611E0D4E11FA8FA50077A41E /* cffobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE411FA8FA50077A41E /* cffobjs.c */; }; - 611E0D4F11FA8FA50077A41E /* cffobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE511FA8FA50077A41E /* cffobjs.h */; }; - 611E0D5011FA8FA50077A41E /* cffparse.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE611FA8FA50077A41E /* cffparse.c */; }; - 611E0D5111FA8FA50077A41E /* cffparse.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE711FA8FA50077A41E /* cffparse.h */; }; - 611E0D5211FA8FA50077A41E /* cffpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0BE811FA8FA50077A41E /* cffpic.c */; }; - 611E0D5311FA8FA50077A41E /* cffpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BE911FA8FA50077A41E /* cffpic.h */; }; - 611E0D5411FA8FA50077A41E /* cfftoken.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BEA11FA8FA50077A41E /* cfftoken.h */; }; - 611E0D5511FA8FA50077A41E /* cfftypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0BEB11FA8FA50077A41E /* cfftypes.h */; }; - 611E0DC911FA8FA50077A41E /* pshalgo.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6811FA8FA50077A41E /* pshalgo.c */; }; - 611E0DCA11FA8FA50077A41E /* pshalgo.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6911FA8FA50077A41E /* pshalgo.h */; }; - 611E0DCB11FA8FA50077A41E /* pshglob.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6A11FA8FA50077A41E /* pshglob.c */; }; - 611E0DCC11FA8FA50077A41E /* pshglob.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6B11FA8FA50077A41E /* pshglob.h */; }; - 611E0DCD11FA8FA50077A41E /* pshinter.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6C11FA8FA50077A41E /* pshinter.c */; }; - 611E0DCE11FA8FA50077A41E /* pshmod.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C6D11FA8FA50077A41E /* pshmod.c */; }; - 611E0DCF11FA8FA50077A41E /* pshmod.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6E11FA8FA50077A41E /* pshmod.h */; }; - 611E0DD011FA8FA50077A41E /* pshnterr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C6F11FA8FA50077A41E /* pshnterr.h */; }; - 611E0DD111FA8FA50077A41E /* pshpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7011FA8FA50077A41E /* pshpic.c */; }; - 611E0DD211FA8FA50077A41E /* pshpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7111FA8FA50077A41E /* pshpic.h */; }; - 611E0DD311FA8FA50077A41E /* pshrec.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7211FA8FA50077A41E /* pshrec.c */; }; - 611E0DD411FA8FA50077A41E /* pshrec.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7311FA8FA50077A41E /* pshrec.h */; }; - 611E0DD511FA8FA50077A41E /* psmodule.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7511FA8FA50077A41E /* psmodule.c */; }; - 611E0DD611FA8FA50077A41E /* psmodule.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7611FA8FA50077A41E /* psmodule.h */; }; - 611E0DD711FA8FA50077A41E /* psnamerr.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7711FA8FA50077A41E /* psnamerr.h */; }; - 611E0DD811FA8FA50077A41E /* psnames.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7811FA8FA50077A41E /* psnames.c */; }; - 611E0DD911FA8FA50077A41E /* pspic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7911FA8FA50077A41E /* pspic.c */; }; - 611E0DDA11FA8FA50077A41E /* pspic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7A11FA8FA50077A41E /* pspic.h */; }; - 611E0DDB11FA8FA50077A41E /* pstables.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7B11FA8FA50077A41E /* pstables.h */; }; - 611E0DDC11FA8FA50077A41E /* ftmisc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7D11FA8FA50077A41E /* ftmisc.h */; }; - 611E0DDD11FA8FA50077A41E /* ftraster.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C7E11FA8FA50077A41E /* ftraster.c */; }; - 611E0DDE11FA8FA50077A41E /* ftraster.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C7F11FA8FA50077A41E /* ftraster.h */; }; - 611E0DDF11FA8FA50077A41E /* ftrend1.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8011FA8FA50077A41E /* ftrend1.c */; }; - 611E0DE011FA8FA50077A41E /* ftrend1.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8111FA8FA50077A41E /* ftrend1.h */; }; - 611E0DE111FA8FA50077A41E /* raster.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8211FA8FA50077A41E /* raster.c */; }; - 611E0DE211FA8FA50077A41E /* rasterrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8311FA8FA50077A41E /* rasterrs.h */; }; - 611E0DE311FA8FA50077A41E /* rastpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8411FA8FA50077A41E /* rastpic.c */; }; - 611E0DE411FA8FA50077A41E /* rastpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8511FA8FA50077A41E /* rastpic.h */; }; - 611E0DE511FA8FA50077A41E /* sfdriver.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8711FA8FA50077A41E /* sfdriver.c */; }; - 611E0DE611FA8FA50077A41E /* sfdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8811FA8FA50077A41E /* sfdriver.h */; }; - 611E0DE711FA8FA50077A41E /* sferrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8911FA8FA50077A41E /* sferrors.h */; }; - 611E0DE811FA8FA50077A41E /* sfnt.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8A11FA8FA50077A41E /* sfnt.c */; }; - 611E0DE911FA8FA50077A41E /* sfntpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8B11FA8FA50077A41E /* sfntpic.c */; }; - 611E0DEA11FA8FA50077A41E /* sfntpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8C11FA8FA50077A41E /* sfntpic.h */; }; - 611E0DEB11FA8FA50077A41E /* sfobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8D11FA8FA50077A41E /* sfobjs.c */; }; - 611E0DEC11FA8FA50077A41E /* sfobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C8E11FA8FA50077A41E /* sfobjs.h */; }; - 611E0DED11FA8FA50077A41E /* ttbdf.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C8F11FA8FA50077A41E /* ttbdf.c */; }; - 611E0DEE11FA8FA50077A41E /* ttbdf.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9011FA8FA50077A41E /* ttbdf.h */; }; - 611E0DEF11FA8FA50077A41E /* ttcmap.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9111FA8FA50077A41E /* ttcmap.c */; }; - 611E0DF011FA8FA50077A41E /* ttcmap.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9211FA8FA50077A41E /* ttcmap.h */; }; - 611E0DF111FA8FA50077A41E /* ttcmapc.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9311FA8FA50077A41E /* ttcmapc.h */; }; - 611E0DF211FA8FA50077A41E /* ttkern.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9411FA8FA50077A41E /* ttkern.c */; }; - 611E0DF311FA8FA50077A41E /* ttkern.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9511FA8FA50077A41E /* ttkern.h */; }; - 611E0DF411FA8FA50077A41E /* ttload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9611FA8FA50077A41E /* ttload.c */; }; - 611E0DF511FA8FA50077A41E /* ttload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9711FA8FA50077A41E /* ttload.h */; }; - 611E0DF611FA8FA50077A41E /* ttmtx.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9811FA8FA50077A41E /* ttmtx.c */; }; - 611E0DF711FA8FA50077A41E /* ttmtx.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9911FA8FA50077A41E /* ttmtx.h */; }; - 611E0DF811FA8FA50077A41E /* ttpost.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9A11FA8FA50077A41E /* ttpost.c */; }; - 611E0DF911FA8FA50077A41E /* ttpost.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9B11FA8FA50077A41E /* ttpost.h */; }; - 611E0DFA11FA8FA50077A41E /* ttsbit.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9C11FA8FA50077A41E /* ttsbit.c */; }; - 611E0DFB11FA8FA50077A41E /* ttsbit.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0C9D11FA8FA50077A41E /* ttsbit.h */; }; - 611E0DFC11FA8FA50077A41E /* ttsbit0.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0C9E11FA8FA50077A41E /* ttsbit0.c */; }; - 611E0DFD11FA8FA50077A41E /* ftgrays.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA011FA8FA50077A41E /* ftgrays.c */; }; - 611E0DFE11FA8FA50077A41E /* ftgrays.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA111FA8FA50077A41E /* ftgrays.h */; }; - 611E0DFF11FA8FA50077A41E /* ftsmerrs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA211FA8FA50077A41E /* ftsmerrs.h */; }; - 611E0E0011FA8FA50077A41E /* ftsmooth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA311FA8FA50077A41E /* ftsmooth.c */; }; - 611E0E0111FA8FA50077A41E /* ftsmooth.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA411FA8FA50077A41E /* ftsmooth.h */; }; - 611E0E0211FA8FA50077A41E /* ftspic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA511FA8FA50077A41E /* ftspic.c */; }; - 611E0E0311FA8FA50077A41E /* ftspic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CA611FA8FA50077A41E /* ftspic.h */; }; - 611E0E0411FA8FA50077A41E /* smooth.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CA711FA8FA50077A41E /* smooth.c */; }; - 611E0E0B11FA8FA50077A41E /* truetype.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CBD11FA8FA50077A41E /* truetype.c */; }; - 611E0E0C11FA8FA50077A41E /* ttdriver.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CBE11FA8FA50077A41E /* ttdriver.c */; }; - 611E0E0D11FA8FA50077A41E /* ttdriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CBF11FA8FA50077A41E /* ttdriver.h */; }; - 611E0E0E11FA8FA50077A41E /* tterrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC011FA8FA50077A41E /* tterrors.h */; }; - 611E0E0F11FA8FA50077A41E /* ttgload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC111FA8FA50077A41E /* ttgload.c */; }; - 611E0E1011FA8FA50077A41E /* ttgload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC211FA8FA50077A41E /* ttgload.h */; }; - 611E0E1111FA8FA50077A41E /* ttgxvar.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC311FA8FA50077A41E /* ttgxvar.c */; }; - 611E0E1211FA8FA50077A41E /* ttgxvar.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC411FA8FA50077A41E /* ttgxvar.h */; }; - 611E0E1311FA8FA50077A41E /* ttinterp.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC511FA8FA50077A41E /* ttinterp.c */; }; - 611E0E1411FA8FA50077A41E /* ttinterp.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC611FA8FA50077A41E /* ttinterp.h */; }; - 611E0E1511FA8FA50077A41E /* ttobjs.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC711FA8FA50077A41E /* ttobjs.c */; }; - 611E0E1611FA8FA50077A41E /* ttobjs.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CC811FA8FA50077A41E /* ttobjs.h */; }; - 611E0E1711FA8FA50077A41E /* ttpic.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CC911FA8FA50077A41E /* ttpic.c */; }; - 611E0E1811FA8FA50077A41E /* ttpic.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CCA11FA8FA50077A41E /* ttpic.h */; }; - 611E0E1911FA8FA50077A41E /* ttpload.c in Sources */ = {isa = PBXBuildFile; fileRef = 611E0CCB11FA8FA50077A41E /* ttpload.c */; }; - 611E0E1A11FA8FA50077A41E /* ttpload.h in Headers */ = {isa = PBXBuildFile; fileRef = 611E0CCC11FA8FA50077A41E /* ttpload.h */; }; - AA747D9F0F9514B9006C5449 /* freetype_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */; }; - AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 611E0AC611FA8F610077A41E /* ftconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftconfig.h; sourceTree = ""; }; - 611E0AC711FA8F610077A41E /* ftheader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftheader.h; sourceTree = ""; }; - 611E0AC811FA8F610077A41E /* ftmodule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmodule.h; sourceTree = ""; }; - 611E0AC911FA8F610077A41E /* ftoption.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftoption.h; sourceTree = ""; }; - 611E0ACA11FA8F610077A41E /* ftstdlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstdlib.h; sourceTree = ""; }; - 611E0ACB11FA8F610077A41E /* freetype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = freetype.h; sourceTree = ""; }; - 611E0ACC11FA8F610077A41E /* ftadvanc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftadvanc.h; sourceTree = ""; }; - 611E0ACD11FA8F610077A41E /* ftbbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbbox.h; sourceTree = ""; }; - 611E0ACE11FA8F610077A41E /* ftbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbdf.h; sourceTree = ""; }; - 611E0ACF11FA8F610077A41E /* ftbitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbitmap.h; sourceTree = ""; }; - 611E0AD011FA8F610077A41E /* ftcache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcache.h; sourceTree = ""; }; - 611E0AD111FA8F610077A41E /* ftchapters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftchapters.h; sourceTree = ""; }; - 611E0AD211FA8F610077A41E /* ftcid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcid.h; sourceTree = ""; }; - 611E0AD311FA8F610077A41E /* fterrdef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fterrdef.h; sourceTree = ""; }; - 611E0AD411FA8F610077A41E /* fterrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fterrors.h; sourceTree = ""; }; - 611E0AD511FA8F610077A41E /* ftgasp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgasp.h; sourceTree = ""; }; - 611E0AD611FA8F610077A41E /* ftglyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftglyph.h; sourceTree = ""; }; - 611E0AD711FA8F610077A41E /* ftgxval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgxval.h; sourceTree = ""; }; - 611E0AD811FA8F610077A41E /* ftgzip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgzip.h; sourceTree = ""; }; - 611E0AD911FA8F610077A41E /* ftimage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftimage.h; sourceTree = ""; }; - 611E0ADA11FA8F610077A41E /* ftincrem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftincrem.h; sourceTree = ""; }; - 611E0ADB11FA8F610077A41E /* ftlcdfil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlcdfil.h; sourceTree = ""; }; - 611E0ADC11FA8F610077A41E /* ftlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlist.h; sourceTree = ""; }; - 611E0ADD11FA8F610077A41E /* ftlzw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftlzw.h; sourceTree = ""; }; - 611E0ADE11FA8F610077A41E /* ftmac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmac.h; sourceTree = ""; }; - 611E0ADF11FA8F610077A41E /* ftmm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmm.h; sourceTree = ""; }; - 611E0AE011FA8F610077A41E /* ftmodapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmodapi.h; sourceTree = ""; }; - 611E0AE111FA8F610077A41E /* ftmoderr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmoderr.h; sourceTree = ""; }; - 611E0AE211FA8F610077A41E /* ftotval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftotval.h; sourceTree = ""; }; - 611E0AE311FA8F610077A41E /* ftoutln.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftoutln.h; sourceTree = ""; }; - 611E0AE411FA8F610077A41E /* ftpfr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftpfr.h; sourceTree = ""; }; - 611E0AE511FA8F610077A41E /* ftrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrender.h; sourceTree = ""; }; - 611E0AE611FA8F610077A41E /* ftsizes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsizes.h; sourceTree = ""; }; - 611E0AE711FA8F610077A41E /* ftsnames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsnames.h; sourceTree = ""; }; - 611E0AE811FA8F610077A41E /* ftstroke.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstroke.h; sourceTree = ""; }; - 611E0AE911FA8F610077A41E /* ftsynth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsynth.h; sourceTree = ""; }; - 611E0AEA11FA8F610077A41E /* ftsystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsystem.h; sourceTree = ""; }; - 611E0AEB11FA8F610077A41E /* fttrigon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttrigon.h; sourceTree = ""; }; - 611E0AEC11FA8F610077A41E /* fttypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttypes.h; sourceTree = ""; }; - 611E0AED11FA8F610077A41E /* ftwinfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftwinfnt.h; sourceTree = ""; }; - 611E0AEE11FA8F610077A41E /* ftxf86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftxf86.h; sourceTree = ""; }; - 611E0AF011FA8F610077A41E /* autohint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = autohint.h; sourceTree = ""; }; - 611E0AF111FA8F610077A41E /* ftcalc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftcalc.h; sourceTree = ""; }; - 611E0AF211FA8F610077A41E /* ftdebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftdebug.h; sourceTree = ""; }; - 611E0AF311FA8F610077A41E /* ftdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftdriver.h; sourceTree = ""; }; - 611E0AF411FA8F610077A41E /* ftgloadr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgloadr.h; sourceTree = ""; }; - 611E0AF511FA8F610077A41E /* ftmemory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmemory.h; sourceTree = ""; }; - 611E0AF611FA8F610077A41E /* ftobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftobjs.h; sourceTree = ""; }; - 611E0AF711FA8F610077A41E /* ftpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftpic.h; sourceTree = ""; }; - 611E0AF811FA8F610077A41E /* ftrfork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrfork.h; sourceTree = ""; }; - 611E0AF911FA8F610077A41E /* ftserv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftserv.h; sourceTree = ""; }; - 611E0AFA11FA8F610077A41E /* ftstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftstream.h; sourceTree = ""; }; - 611E0AFB11FA8F610077A41E /* fttrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fttrace.h; sourceTree = ""; }; - 611E0AFC11FA8F610077A41E /* ftvalid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftvalid.h; sourceTree = ""; }; - 611E0AFD11FA8F610077A41E /* internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = internal.h; sourceTree = ""; }; - 611E0AFE11FA8F610077A41E /* pcftypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcftypes.h; sourceTree = ""; }; - 611E0AFF11FA8F610077A41E /* psaux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psaux.h; sourceTree = ""; }; - 611E0B0011FA8F610077A41E /* pshints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshints.h; sourceTree = ""; }; - 611E0B0211FA8F610077A41E /* svbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svbdf.h; sourceTree = ""; }; - 611E0B0311FA8F610077A41E /* svcid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svcid.h; sourceTree = ""; }; - 611E0B0411FA8F610077A41E /* svgldict.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svgldict.h; sourceTree = ""; }; - 611E0B0511FA8F610077A41E /* svgxval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svgxval.h; sourceTree = ""; }; - 611E0B0611FA8F610077A41E /* svkern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svkern.h; sourceTree = ""; }; - 611E0B0711FA8F610077A41E /* svmm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svmm.h; sourceTree = ""; }; - 611E0B0811FA8F610077A41E /* svotval.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svotval.h; sourceTree = ""; }; - 611E0B0911FA8F610077A41E /* svpfr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpfr.h; sourceTree = ""; }; - 611E0B0A11FA8F610077A41E /* svpostnm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpostnm.h; sourceTree = ""; }; - 611E0B0B11FA8F610077A41E /* svpscmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpscmap.h; sourceTree = ""; }; - 611E0B0C11FA8F610077A41E /* svpsinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svpsinfo.h; sourceTree = ""; }; - 611E0B0D11FA8F610077A41E /* svsfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svsfnt.h; sourceTree = ""; }; - 611E0B0E11FA8F610077A41E /* svttcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svttcmap.h; sourceTree = ""; }; - 611E0B0F11FA8F610077A41E /* svtteng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svtteng.h; sourceTree = ""; }; - 611E0B1011FA8F610077A41E /* svttglyf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svttglyf.h; sourceTree = ""; }; - 611E0B1111FA8F610077A41E /* svwinfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svwinfnt.h; sourceTree = ""; }; - 611E0B1211FA8F610077A41E /* svxf86nm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = svxf86nm.h; sourceTree = ""; }; - 611E0B1311FA8F610077A41E /* sfnt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfnt.h; sourceTree = ""; }; - 611E0B1411FA8F610077A41E /* t1types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = t1types.h; sourceTree = ""; }; - 611E0B1511FA8F610077A41E /* tttypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttypes.h; sourceTree = ""; }; - 611E0B1611FA8F610077A41E /* t1tables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = t1tables.h; sourceTree = ""; }; - 611E0B1711FA8F610077A41E /* ttnameid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttnameid.h; sourceTree = ""; }; - 611E0B1811FA8F610077A41E /* tttables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttables.h; sourceTree = ""; }; - 611E0B1911FA8F610077A41E /* tttags.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tttags.h; sourceTree = ""; }; - 611E0B1A11FA8F610077A41E /* ttunpat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttunpat.h; sourceTree = ""; }; - 611E0B1B11FA8F610077A41E /* ft2build.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ft2build.h; path = ../include/ft2build.h; sourceTree = SOURCE_ROOT; }; - 611E0B9911FA8FA50077A41E /* basepic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = basepic.c; sourceTree = ""; }; - 611E0B9A11FA8FA50077A41E /* basepic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = basepic.h; sourceTree = ""; }; - 611E0B9B11FA8FA50077A41E /* ftadvanc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftadvanc.c; sourceTree = ""; }; - 611E0B9C11FA8FA50077A41E /* ftapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftapi.c; sourceTree = ""; }; - 611E0B9D11FA8FA50077A41E /* ftbase.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbase.c; sourceTree = ""; }; - 611E0B9E11FA8FA50077A41E /* ftbase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftbase.h; sourceTree = ""; }; - 611E0B9F11FA8FA50077A41E /* ftbbox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbbox.c; sourceTree = ""; }; - 611E0BA111FA8FA50077A41E /* ftbitmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftbitmap.c; sourceTree = ""; }; - 611E0BA211FA8FA50077A41E /* ftcalc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftcalc.c; sourceTree = ""; }; - 611E0BA411FA8FA50077A41E /* ftdbgmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftdbgmem.c; sourceTree = ""; }; - 611E0BA511FA8FA50077A41E /* ftdebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftdebug.c; sourceTree = ""; }; - 611E0BA811FA8FA50077A41E /* ftgloadr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftgloadr.c; sourceTree = ""; }; - 611E0BA911FA8FA50077A41E /* ftglyph.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftglyph.c; sourceTree = ""; }; - 611E0BAB11FA8FA50077A41E /* ftinit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftinit.c; sourceTree = ""; }; - 611E0BAF11FA8FA50077A41E /* ftobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftobjs.c; sourceTree = ""; }; - 611E0BB111FA8FA50077A41E /* ftoutln.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftoutln.c; sourceTree = ""; }; - 611E0BB411FA8FA50077A41E /* ftpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftpic.c; sourceTree = ""; }; - 611E0BB511FA8FA50077A41E /* ftrfork.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftrfork.c; sourceTree = ""; }; - 611E0BB611FA8FA50077A41E /* ftsnames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsnames.c; sourceTree = ""; }; - 611E0BB711FA8FA50077A41E /* ftstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftstream.c; sourceTree = ""; }; - 611E0BB811FA8FA50077A41E /* ftstroke.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftstroke.c; sourceTree = ""; }; - 611E0BB911FA8FA50077A41E /* ftsynth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsynth.c; sourceTree = ""; }; - 611E0BBA11FA8FA50077A41E /* ftsystem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsystem.c; sourceTree = ""; }; - 611E0BBB11FA8FA50077A41E /* fttrigon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fttrigon.c; sourceTree = ""; }; - 611E0BBD11FA8FA50077A41E /* ftutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftutil.c; sourceTree = ""; }; - 611E0BDA11FA8FA50077A41E /* cff.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cff.c; sourceTree = ""; }; - 611E0BDB11FA8FA50077A41E /* cffcmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffcmap.c; sourceTree = ""; }; - 611E0BDC11FA8FA50077A41E /* cffcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffcmap.h; sourceTree = ""; }; - 611E0BDD11FA8FA50077A41E /* cffdrivr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffdrivr.c; sourceTree = ""; }; - 611E0BDE11FA8FA50077A41E /* cffdrivr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffdrivr.h; sourceTree = ""; }; - 611E0BDF11FA8FA50077A41E /* cfferrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfferrs.h; sourceTree = ""; }; - 611E0BE011FA8FA50077A41E /* cffgload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffgload.c; sourceTree = ""; }; - 611E0BE111FA8FA50077A41E /* cffgload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffgload.h; sourceTree = ""; }; - 611E0BE211FA8FA50077A41E /* cffload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffload.c; sourceTree = ""; }; - 611E0BE311FA8FA50077A41E /* cffload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffload.h; sourceTree = ""; }; - 611E0BE411FA8FA50077A41E /* cffobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffobjs.c; sourceTree = ""; }; - 611E0BE511FA8FA50077A41E /* cffobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffobjs.h; sourceTree = ""; }; - 611E0BE611FA8FA50077A41E /* cffparse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffparse.c; sourceTree = ""; }; - 611E0BE711FA8FA50077A41E /* cffparse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffparse.h; sourceTree = ""; }; - 611E0BE811FA8FA50077A41E /* cffpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cffpic.c; sourceTree = ""; }; - 611E0BE911FA8FA50077A41E /* cffpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cffpic.h; sourceTree = ""; }; - 611E0BEA11FA8FA50077A41E /* cfftoken.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfftoken.h; sourceTree = ""; }; - 611E0BEB11FA8FA50077A41E /* cfftypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cfftypes.h; sourceTree = ""; }; - 611E0C6811FA8FA50077A41E /* pshalgo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshalgo.c; sourceTree = ""; }; - 611E0C6911FA8FA50077A41E /* pshalgo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshalgo.h; sourceTree = ""; }; - 611E0C6A11FA8FA50077A41E /* pshglob.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshglob.c; sourceTree = ""; }; - 611E0C6B11FA8FA50077A41E /* pshglob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshglob.h; sourceTree = ""; }; - 611E0C6C11FA8FA50077A41E /* pshinter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshinter.c; sourceTree = ""; }; - 611E0C6D11FA8FA50077A41E /* pshmod.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshmod.c; sourceTree = ""; }; - 611E0C6E11FA8FA50077A41E /* pshmod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshmod.h; sourceTree = ""; }; - 611E0C6F11FA8FA50077A41E /* pshnterr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshnterr.h; sourceTree = ""; }; - 611E0C7011FA8FA50077A41E /* pshpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshpic.c; sourceTree = ""; }; - 611E0C7111FA8FA50077A41E /* pshpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshpic.h; sourceTree = ""; }; - 611E0C7211FA8FA50077A41E /* pshrec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pshrec.c; sourceTree = ""; }; - 611E0C7311FA8FA50077A41E /* pshrec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pshrec.h; sourceTree = ""; }; - 611E0C7511FA8FA50077A41E /* psmodule.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psmodule.c; sourceTree = ""; }; - 611E0C7611FA8FA50077A41E /* psmodule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psmodule.h; sourceTree = ""; }; - 611E0C7711FA8FA50077A41E /* psnamerr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = psnamerr.h; sourceTree = ""; }; - 611E0C7811FA8FA50077A41E /* psnames.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = psnames.c; sourceTree = ""; }; - 611E0C7911FA8FA50077A41E /* pspic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pspic.c; sourceTree = ""; }; - 611E0C7A11FA8FA50077A41E /* pspic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pspic.h; sourceTree = ""; }; - 611E0C7B11FA8FA50077A41E /* pstables.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pstables.h; sourceTree = ""; }; - 611E0C7D11FA8FA50077A41E /* ftmisc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftmisc.h; sourceTree = ""; }; - 611E0C7E11FA8FA50077A41E /* ftraster.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftraster.c; sourceTree = ""; }; - 611E0C7F11FA8FA50077A41E /* ftraster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftraster.h; sourceTree = ""; }; - 611E0C8011FA8FA50077A41E /* ftrend1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftrend1.c; sourceTree = ""; }; - 611E0C8111FA8FA50077A41E /* ftrend1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftrend1.h; sourceTree = ""; }; - 611E0C8211FA8FA50077A41E /* raster.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raster.c; sourceTree = ""; }; - 611E0C8311FA8FA50077A41E /* rasterrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rasterrs.h; sourceTree = ""; }; - 611E0C8411FA8FA50077A41E /* rastpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rastpic.c; sourceTree = ""; }; - 611E0C8511FA8FA50077A41E /* rastpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rastpic.h; sourceTree = ""; }; - 611E0C8711FA8FA50077A41E /* sfdriver.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfdriver.c; sourceTree = ""; }; - 611E0C8811FA8FA50077A41E /* sfdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfdriver.h; sourceTree = ""; }; - 611E0C8911FA8FA50077A41E /* sferrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sferrors.h; sourceTree = ""; }; - 611E0C8A11FA8FA50077A41E /* sfnt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfnt.c; sourceTree = ""; }; - 611E0C8B11FA8FA50077A41E /* sfntpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfntpic.c; sourceTree = ""; }; - 611E0C8C11FA8FA50077A41E /* sfntpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfntpic.h; sourceTree = ""; }; - 611E0C8D11FA8FA50077A41E /* sfobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sfobjs.c; sourceTree = ""; }; - 611E0C8E11FA8FA50077A41E /* sfobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sfobjs.h; sourceTree = ""; }; - 611E0C8F11FA8FA50077A41E /* ttbdf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttbdf.c; sourceTree = ""; }; - 611E0C9011FA8FA50077A41E /* ttbdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttbdf.h; sourceTree = ""; }; - 611E0C9111FA8FA50077A41E /* ttcmap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttcmap.c; sourceTree = ""; }; - 611E0C9211FA8FA50077A41E /* ttcmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttcmap.h; sourceTree = ""; }; - 611E0C9311FA8FA50077A41E /* ttcmapc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttcmapc.h; sourceTree = ""; }; - 611E0C9411FA8FA50077A41E /* ttkern.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttkern.c; sourceTree = ""; }; - 611E0C9511FA8FA50077A41E /* ttkern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttkern.h; sourceTree = ""; }; - 611E0C9611FA8FA50077A41E /* ttload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttload.c; sourceTree = ""; }; - 611E0C9711FA8FA50077A41E /* ttload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttload.h; sourceTree = ""; }; - 611E0C9811FA8FA50077A41E /* ttmtx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttmtx.c; sourceTree = ""; }; - 611E0C9911FA8FA50077A41E /* ttmtx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttmtx.h; sourceTree = ""; }; - 611E0C9A11FA8FA50077A41E /* ttpost.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpost.c; sourceTree = ""; }; - 611E0C9B11FA8FA50077A41E /* ttpost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpost.h; sourceTree = ""; }; - 611E0C9C11FA8FA50077A41E /* ttsbit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttsbit.c; sourceTree = ""; }; - 611E0C9D11FA8FA50077A41E /* ttsbit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttsbit.h; sourceTree = ""; }; - 611E0C9E11FA8FA50077A41E /* ttsbit0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttsbit0.c; sourceTree = ""; }; - 611E0CA011FA8FA50077A41E /* ftgrays.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftgrays.c; sourceTree = ""; }; - 611E0CA111FA8FA50077A41E /* ftgrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftgrays.h; sourceTree = ""; }; - 611E0CA211FA8FA50077A41E /* ftsmerrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsmerrs.h; sourceTree = ""; }; - 611E0CA311FA8FA50077A41E /* ftsmooth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftsmooth.c; sourceTree = ""; }; - 611E0CA411FA8FA50077A41E /* ftsmooth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftsmooth.h; sourceTree = ""; }; - 611E0CA511FA8FA50077A41E /* ftspic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ftspic.c; sourceTree = ""; }; - 611E0CA611FA8FA50077A41E /* ftspic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ftspic.h; sourceTree = ""; }; - 611E0CA711FA8FA50077A41E /* smooth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = smooth.c; sourceTree = ""; }; - 611E0CBD11FA8FA50077A41E /* truetype.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = truetype.c; sourceTree = ""; }; - 611E0CBE11FA8FA50077A41E /* ttdriver.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttdriver.c; sourceTree = ""; }; - 611E0CBF11FA8FA50077A41E /* ttdriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttdriver.h; sourceTree = ""; }; - 611E0CC011FA8FA50077A41E /* tterrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tterrors.h; sourceTree = ""; }; - 611E0CC111FA8FA50077A41E /* ttgload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttgload.c; sourceTree = ""; }; - 611E0CC211FA8FA50077A41E /* ttgload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttgload.h; sourceTree = ""; }; - 611E0CC311FA8FA50077A41E /* ttgxvar.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttgxvar.c; sourceTree = ""; }; - 611E0CC411FA8FA50077A41E /* ttgxvar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttgxvar.h; sourceTree = ""; }; - 611E0CC511FA8FA50077A41E /* ttinterp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttinterp.c; sourceTree = ""; }; - 611E0CC611FA8FA50077A41E /* ttinterp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttinterp.h; sourceTree = ""; }; - 611E0CC711FA8FA50077A41E /* ttobjs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttobjs.c; sourceTree = ""; }; - 611E0CC811FA8FA50077A41E /* ttobjs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttobjs.h; sourceTree = ""; }; - 611E0CC911FA8FA50077A41E /* ttpic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpic.c; sourceTree = ""; }; - 611E0CCA11FA8FA50077A41E /* ttpic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpic.h; sourceTree = ""; }; - 611E0CCB11FA8FA50077A41E /* ttpload.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttpload.c; sourceTree = ""; }; - 611E0CCC11FA8FA50077A41E /* ttpload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttpload.h; sourceTree = ""; }; - AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = freetype_Prefix.pch; sourceTree = SOURCE_ROOT; }; - AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - D2AAC07E0554694100DB518D /* libFreetype.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFreetype.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - D2AAC07C0554694100DB518D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 034768DFFF38A50411DB9C8B /* Products */ = { - isa = PBXGroup; - children = ( - D2AAC07E0554694100DB518D /* libFreetype.a */, - ); - name = Products; - sourceTree = ""; - }; - 0867D691FE84028FC02AAC07 /* freetype */ = { - isa = PBXGroup; - children = ( - 08FB77AEFE84172EC02AAC07 /* Source */, - 32C88DFF0371C24200C91783 /* Public Headers */, - 0867D69AFE84028FC02AAC07 /* Frameworks */, - 034768DFFF38A50411DB9C8B /* Products */, - ); - name = freetype; - sourceTree = ""; - }; - 0867D69AFE84028FC02AAC07 /* Frameworks */ = { - isa = PBXGroup; - children = ( - AACBBE490F95108600F1A2B1 /* Foundation.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 08FB77AEFE84172EC02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - 611E0B9811FA8FA50077A41E /* base */, - 611E0BD911FA8FA50077A41E /* cff */, - 611E0C6711FA8FA50077A41E /* pshinter */, - 611E0C7411FA8FA50077A41E /* psnames */, - 611E0C7C11FA8FA50077A41E /* raster */, - 611E0C8611FA8FA50077A41E /* sfnt */, - 611E0C9F11FA8FA50077A41E /* smooth */, - 611E0CBC11FA8FA50077A41E /* truetype */, - ); - name = Source; - sourceTree = ""; - }; - 32C88DFF0371C24200C91783 /* Public Headers */ = { - isa = PBXGroup; - children = ( - 611E0AC411FA8F610077A41E /* freetype */, - 611E0B1B11FA8F610077A41E /* ft2build.h */, - AA747D9E0F9514B9006C5449 /* freetype_Prefix.pch */, - ); - name = "Public Headers"; - sourceTree = ""; - }; - 611E0AC411FA8F610077A41E /* freetype */ = { - isa = PBXGroup; - children = ( - 611E0AC511FA8F610077A41E /* config */, - 611E0ACB11FA8F610077A41E /* freetype.h */, - 611E0ACC11FA8F610077A41E /* ftadvanc.h */, - 611E0ACD11FA8F610077A41E /* ftbbox.h */, - 611E0ACE11FA8F610077A41E /* ftbdf.h */, - 611E0ACF11FA8F610077A41E /* ftbitmap.h */, - 611E0AD011FA8F610077A41E /* ftcache.h */, - 611E0AD111FA8F610077A41E /* ftchapters.h */, - 611E0AD211FA8F610077A41E /* ftcid.h */, - 611E0AD311FA8F610077A41E /* fterrdef.h */, - 611E0AD411FA8F610077A41E /* fterrors.h */, - 611E0AD511FA8F610077A41E /* ftgasp.h */, - 611E0AD611FA8F610077A41E /* ftglyph.h */, - 611E0AD711FA8F610077A41E /* ftgxval.h */, - 611E0AD811FA8F610077A41E /* ftgzip.h */, - 611E0AD911FA8F610077A41E /* ftimage.h */, - 611E0ADA11FA8F610077A41E /* ftincrem.h */, - 611E0ADB11FA8F610077A41E /* ftlcdfil.h */, - 611E0ADC11FA8F610077A41E /* ftlist.h */, - 611E0ADD11FA8F610077A41E /* ftlzw.h */, - 611E0ADE11FA8F610077A41E /* ftmac.h */, - 611E0ADF11FA8F610077A41E /* ftmm.h */, - 611E0AE011FA8F610077A41E /* ftmodapi.h */, - 611E0AE111FA8F610077A41E /* ftmoderr.h */, - 611E0AE211FA8F610077A41E /* ftotval.h */, - 611E0AE311FA8F610077A41E /* ftoutln.h */, - 611E0AE411FA8F610077A41E /* ftpfr.h */, - 611E0AE511FA8F610077A41E /* ftrender.h */, - 611E0AE611FA8F610077A41E /* ftsizes.h */, - 611E0AE711FA8F610077A41E /* ftsnames.h */, - 611E0AE811FA8F610077A41E /* ftstroke.h */, - 611E0AE911FA8F610077A41E /* ftsynth.h */, - 611E0AEA11FA8F610077A41E /* ftsystem.h */, - 611E0AEB11FA8F610077A41E /* fttrigon.h */, - 611E0AEC11FA8F610077A41E /* fttypes.h */, - 611E0AED11FA8F610077A41E /* ftwinfnt.h */, - 611E0AEE11FA8F610077A41E /* ftxf86.h */, - 611E0AEF11FA8F610077A41E /* internal */, - 611E0B1611FA8F610077A41E /* t1tables.h */, - 611E0B1711FA8F610077A41E /* ttnameid.h */, - 611E0B1811FA8F610077A41E /* tttables.h */, - 611E0B1911FA8F610077A41E /* tttags.h */, - 611E0B1A11FA8F610077A41E /* ttunpat.h */, - ); - name = freetype; - path = ../include/freetype; - sourceTree = SOURCE_ROOT; - }; - 611E0AC511FA8F610077A41E /* config */ = { - isa = PBXGroup; - children = ( - 611E0AC611FA8F610077A41E /* ftconfig.h */, - 611E0AC711FA8F610077A41E /* ftheader.h */, - 611E0AC811FA8F610077A41E /* ftmodule.h */, - 611E0AC911FA8F610077A41E /* ftoption.h */, - 611E0ACA11FA8F610077A41E /* ftstdlib.h */, - ); - path = config; - sourceTree = ""; - }; - 611E0AEF11FA8F610077A41E /* internal */ = { - isa = PBXGroup; - children = ( - 611E0AF011FA8F610077A41E /* autohint.h */, - 611E0AF111FA8F610077A41E /* ftcalc.h */, - 611E0AF211FA8F610077A41E /* ftdebug.h */, - 611E0AF311FA8F610077A41E /* ftdriver.h */, - 611E0AF411FA8F610077A41E /* ftgloadr.h */, - 611E0AF511FA8F610077A41E /* ftmemory.h */, - 611E0AF611FA8F610077A41E /* ftobjs.h */, - 611E0AF711FA8F610077A41E /* ftpic.h */, - 611E0AF811FA8F610077A41E /* ftrfork.h */, - 611E0AF911FA8F610077A41E /* ftserv.h */, - 611E0AFA11FA8F610077A41E /* ftstream.h */, - 611E0AFB11FA8F610077A41E /* fttrace.h */, - 611E0AFC11FA8F610077A41E /* ftvalid.h */, - 611E0AFD11FA8F610077A41E /* internal.h */, - 611E0AFE11FA8F610077A41E /* pcftypes.h */, - 611E0AFF11FA8F610077A41E /* psaux.h */, - 611E0B0011FA8F610077A41E /* pshints.h */, - 611E0B0111FA8F610077A41E /* services */, - 611E0B1311FA8F610077A41E /* sfnt.h */, - 611E0B1411FA8F610077A41E /* t1types.h */, - 611E0B1511FA8F610077A41E /* tttypes.h */, - ); - path = internal; - sourceTree = ""; - }; - 611E0B0111FA8F610077A41E /* services */ = { - isa = PBXGroup; - children = ( - 611E0B0211FA8F610077A41E /* svbdf.h */, - 611E0B0311FA8F610077A41E /* svcid.h */, - 611E0B0411FA8F610077A41E /* svgldict.h */, - 611E0B0511FA8F610077A41E /* svgxval.h */, - 611E0B0611FA8F610077A41E /* svkern.h */, - 611E0B0711FA8F610077A41E /* svmm.h */, - 611E0B0811FA8F610077A41E /* svotval.h */, - 611E0B0911FA8F610077A41E /* svpfr.h */, - 611E0B0A11FA8F610077A41E /* svpostnm.h */, - 611E0B0B11FA8F610077A41E /* svpscmap.h */, - 611E0B0C11FA8F610077A41E /* svpsinfo.h */, - 611E0B0D11FA8F610077A41E /* svsfnt.h */, - 611E0B0E11FA8F610077A41E /* svttcmap.h */, - 611E0B0F11FA8F610077A41E /* svtteng.h */, - 611E0B1011FA8F610077A41E /* svttglyf.h */, - 611E0B1111FA8F610077A41E /* svwinfnt.h */, - 611E0B1211FA8F610077A41E /* svxf86nm.h */, - ); - path = services; - sourceTree = ""; - }; - 611E0B9811FA8FA50077A41E /* base */ = { - isa = PBXGroup; - children = ( - 611E0B9911FA8FA50077A41E /* basepic.c */, - 611E0B9A11FA8FA50077A41E /* basepic.h */, - 611E0B9B11FA8FA50077A41E /* ftadvanc.c */, - 611E0B9C11FA8FA50077A41E /* ftapi.c */, - 611E0B9D11FA8FA50077A41E /* ftbase.c */, - 611E0B9E11FA8FA50077A41E /* ftbase.h */, - 611E0B9F11FA8FA50077A41E /* ftbbox.c */, - 611E0BA111FA8FA50077A41E /* ftbitmap.c */, - 611E0BA211FA8FA50077A41E /* ftcalc.c */, - 611E0BA411FA8FA50077A41E /* ftdbgmem.c */, - 611E0BA511FA8FA50077A41E /* ftdebug.c */, - 611E0BA811FA8FA50077A41E /* ftgloadr.c */, - 611E0BA911FA8FA50077A41E /* ftglyph.c */, - 611E0BAB11FA8FA50077A41E /* ftinit.c */, - 611E0BAF11FA8FA50077A41E /* ftobjs.c */, - 611E0BB111FA8FA50077A41E /* ftoutln.c */, - 611E0BB411FA8FA50077A41E /* ftpic.c */, - 611E0BB511FA8FA50077A41E /* ftrfork.c */, - 611E0BB611FA8FA50077A41E /* ftsnames.c */, - 611E0BB711FA8FA50077A41E /* ftstream.c */, - 611E0BB811FA8FA50077A41E /* ftstroke.c */, - 611E0BB911FA8FA50077A41E /* ftsynth.c */, - 611E0BBA11FA8FA50077A41E /* ftsystem.c */, - 611E0BBB11FA8FA50077A41E /* fttrigon.c */, - 611E0BBD11FA8FA50077A41E /* ftutil.c */, - ); - name = base; - path = ../src/base; - sourceTree = SOURCE_ROOT; - }; - 611E0BD911FA8FA50077A41E /* cff */ = { - isa = PBXGroup; - children = ( - 611E0BDA11FA8FA50077A41E /* cff.c */, - 611E0BDB11FA8FA50077A41E /* cffcmap.c */, - 611E0BDC11FA8FA50077A41E /* cffcmap.h */, - 611E0BDD11FA8FA50077A41E /* cffdrivr.c */, - 611E0BDE11FA8FA50077A41E /* cffdrivr.h */, - 611E0BDF11FA8FA50077A41E /* cfferrs.h */, - 611E0BE011FA8FA50077A41E /* cffgload.c */, - 611E0BE111FA8FA50077A41E /* cffgload.h */, - 611E0BE211FA8FA50077A41E /* cffload.c */, - 611E0BE311FA8FA50077A41E /* cffload.h */, - 611E0BE411FA8FA50077A41E /* cffobjs.c */, - 611E0BE511FA8FA50077A41E /* cffobjs.h */, - 611E0BE611FA8FA50077A41E /* cffparse.c */, - 611E0BE711FA8FA50077A41E /* cffparse.h */, - 611E0BE811FA8FA50077A41E /* cffpic.c */, - 611E0BE911FA8FA50077A41E /* cffpic.h */, - 611E0BEA11FA8FA50077A41E /* cfftoken.h */, - 611E0BEB11FA8FA50077A41E /* cfftypes.h */, - ); - name = cff; - path = ../src/cff; - sourceTree = SOURCE_ROOT; - }; - 611E0C6711FA8FA50077A41E /* pshinter */ = { - isa = PBXGroup; - children = ( - 611E0C6811FA8FA50077A41E /* pshalgo.c */, - 611E0C6911FA8FA50077A41E /* pshalgo.h */, - 611E0C6A11FA8FA50077A41E /* pshglob.c */, - 611E0C6B11FA8FA50077A41E /* pshglob.h */, - 611E0C6C11FA8FA50077A41E /* pshinter.c */, - 611E0C6D11FA8FA50077A41E /* pshmod.c */, - 611E0C6E11FA8FA50077A41E /* pshmod.h */, - 611E0C6F11FA8FA50077A41E /* pshnterr.h */, - 611E0C7011FA8FA50077A41E /* pshpic.c */, - 611E0C7111FA8FA50077A41E /* pshpic.h */, - 611E0C7211FA8FA50077A41E /* pshrec.c */, - 611E0C7311FA8FA50077A41E /* pshrec.h */, - ); - name = pshinter; - path = ../src/pshinter; - sourceTree = SOURCE_ROOT; - }; - 611E0C7411FA8FA50077A41E /* psnames */ = { - isa = PBXGroup; - children = ( - 611E0C7511FA8FA50077A41E /* psmodule.c */, - 611E0C7611FA8FA50077A41E /* psmodule.h */, - 611E0C7711FA8FA50077A41E /* psnamerr.h */, - 611E0C7811FA8FA50077A41E /* psnames.c */, - 611E0C7911FA8FA50077A41E /* pspic.c */, - 611E0C7A11FA8FA50077A41E /* pspic.h */, - 611E0C7B11FA8FA50077A41E /* pstables.h */, - ); - name = psnames; - path = ../src/psnames; - sourceTree = SOURCE_ROOT; - }; - 611E0C7C11FA8FA50077A41E /* raster */ = { - isa = PBXGroup; - children = ( - 611E0C7D11FA8FA50077A41E /* ftmisc.h */, - 611E0C7E11FA8FA50077A41E /* ftraster.c */, - 611E0C7F11FA8FA50077A41E /* ftraster.h */, - 611E0C8011FA8FA50077A41E /* ftrend1.c */, - 611E0C8111FA8FA50077A41E /* ftrend1.h */, - 611E0C8211FA8FA50077A41E /* raster.c */, - 611E0C8311FA8FA50077A41E /* rasterrs.h */, - 611E0C8411FA8FA50077A41E /* rastpic.c */, - 611E0C8511FA8FA50077A41E /* rastpic.h */, - ); - name = raster; - path = ../src/raster; - sourceTree = SOURCE_ROOT; - }; - 611E0C8611FA8FA50077A41E /* sfnt */ = { - isa = PBXGroup; - children = ( - 611E0C8711FA8FA50077A41E /* sfdriver.c */, - 611E0C8811FA8FA50077A41E /* sfdriver.h */, - 611E0C8911FA8FA50077A41E /* sferrors.h */, - 611E0C8A11FA8FA50077A41E /* sfnt.c */, - 611E0C8B11FA8FA50077A41E /* sfntpic.c */, - 611E0C8C11FA8FA50077A41E /* sfntpic.h */, - 611E0C8D11FA8FA50077A41E /* sfobjs.c */, - 611E0C8E11FA8FA50077A41E /* sfobjs.h */, - 611E0C8F11FA8FA50077A41E /* ttbdf.c */, - 611E0C9011FA8FA50077A41E /* ttbdf.h */, - 611E0C9111FA8FA50077A41E /* ttcmap.c */, - 611E0C9211FA8FA50077A41E /* ttcmap.h */, - 611E0C9311FA8FA50077A41E /* ttcmapc.h */, - 611E0C9411FA8FA50077A41E /* ttkern.c */, - 611E0C9511FA8FA50077A41E /* ttkern.h */, - 611E0C9611FA8FA50077A41E /* ttload.c */, - 611E0C9711FA8FA50077A41E /* ttload.h */, - 611E0C9811FA8FA50077A41E /* ttmtx.c */, - 611E0C9911FA8FA50077A41E /* ttmtx.h */, - 611E0C9A11FA8FA50077A41E /* ttpost.c */, - 611E0C9B11FA8FA50077A41E /* ttpost.h */, - 611E0C9C11FA8FA50077A41E /* ttsbit.c */, - 611E0C9D11FA8FA50077A41E /* ttsbit.h */, - 611E0C9E11FA8FA50077A41E /* ttsbit0.c */, - ); - name = sfnt; - path = ../src/sfnt; - sourceTree = SOURCE_ROOT; - }; - 611E0C9F11FA8FA50077A41E /* smooth */ = { - isa = PBXGroup; - children = ( - 611E0CA011FA8FA50077A41E /* ftgrays.c */, - 611E0CA111FA8FA50077A41E /* ftgrays.h */, - 611E0CA211FA8FA50077A41E /* ftsmerrs.h */, - 611E0CA311FA8FA50077A41E /* ftsmooth.c */, - 611E0CA411FA8FA50077A41E /* ftsmooth.h */, - 611E0CA511FA8FA50077A41E /* ftspic.c */, - 611E0CA611FA8FA50077A41E /* ftspic.h */, - 611E0CA711FA8FA50077A41E /* smooth.c */, - ); - name = smooth; - path = ../src/smooth; - sourceTree = SOURCE_ROOT; - }; - 611E0CBC11FA8FA50077A41E /* truetype */ = { - isa = PBXGroup; - children = ( - 611E0CBD11FA8FA50077A41E /* truetype.c */, - 611E0CBE11FA8FA50077A41E /* ttdriver.c */, - 611E0CBF11FA8FA50077A41E /* ttdriver.h */, - 611E0CC011FA8FA50077A41E /* tterrors.h */, - 611E0CC111FA8FA50077A41E /* ttgload.c */, - 611E0CC211FA8FA50077A41E /* ttgload.h */, - 611E0CC311FA8FA50077A41E /* ttgxvar.c */, - 611E0CC411FA8FA50077A41E /* ttgxvar.h */, - 611E0CC511FA8FA50077A41E /* ttinterp.c */, - 611E0CC611FA8FA50077A41E /* ttinterp.h */, - 611E0CC711FA8FA50077A41E /* ttobjs.c */, - 611E0CC811FA8FA50077A41E /* ttobjs.h */, - 611E0CC911FA8FA50077A41E /* ttpic.c */, - 611E0CCA11FA8FA50077A41E /* ttpic.h */, - 611E0CCB11FA8FA50077A41E /* ttpload.c */, - 611E0CCC11FA8FA50077A41E /* ttpload.h */, - ); - name = truetype; - path = ../src/truetype; - sourceTree = SOURCE_ROOT; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - D2AAC07A0554694100DB518D /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - AA747D9F0F9514B9006C5449 /* freetype_Prefix.pch in Headers */, - 611E0B1C11FA8F610077A41E /* ftconfig.h in Headers */, - 611E0B1D11FA8F610077A41E /* ftheader.h in Headers */, - 611E0B1E11FA8F610077A41E /* ftmodule.h in Headers */, - 611E0B1F11FA8F610077A41E /* ftoption.h in Headers */, - 611E0B2011FA8F610077A41E /* ftstdlib.h in Headers */, - 611E0B2111FA8F610077A41E /* freetype.h in Headers */, - 611E0B2211FA8F610077A41E /* ftadvanc.h in Headers */, - 611E0B2311FA8F610077A41E /* ftbbox.h in Headers */, - 611E0B2411FA8F610077A41E /* ftbdf.h in Headers */, - 611E0B2511FA8F610077A41E /* ftbitmap.h in Headers */, - 611E0B2611FA8F610077A41E /* ftcache.h in Headers */, - 611E0B2711FA8F610077A41E /* ftchapters.h in Headers */, - 611E0B2811FA8F610077A41E /* ftcid.h in Headers */, - 611E0B2911FA8F610077A41E /* fterrdef.h in Headers */, - 611E0B2A11FA8F610077A41E /* fterrors.h in Headers */, - 611E0B2B11FA8F610077A41E /* ftgasp.h in Headers */, - 611E0B2C11FA8F610077A41E /* ftglyph.h in Headers */, - 611E0B2D11FA8F610077A41E /* ftgxval.h in Headers */, - 611E0B2E11FA8F610077A41E /* ftgzip.h in Headers */, - 611E0B2F11FA8F610077A41E /* ftimage.h in Headers */, - 611E0B3011FA8F610077A41E /* ftincrem.h in Headers */, - 611E0B3111FA8F610077A41E /* ftlcdfil.h in Headers */, - 611E0B3211FA8F610077A41E /* ftlist.h in Headers */, - 611E0B3311FA8F610077A41E /* ftlzw.h in Headers */, - 611E0B3411FA8F610077A41E /* ftmac.h in Headers */, - 611E0B3511FA8F610077A41E /* ftmm.h in Headers */, - 611E0B3611FA8F610077A41E /* ftmodapi.h in Headers */, - 611E0B3711FA8F610077A41E /* ftmoderr.h in Headers */, - 611E0B3811FA8F610077A41E /* ftotval.h in Headers */, - 611E0B3911FA8F610077A41E /* ftoutln.h in Headers */, - 611E0B3A11FA8F610077A41E /* ftpfr.h in Headers */, - 611E0B3B11FA8F610077A41E /* ftrender.h in Headers */, - 611E0B3C11FA8F610077A41E /* ftsizes.h in Headers */, - 611E0B3D11FA8F610077A41E /* ftsnames.h in Headers */, - 611E0B3E11FA8F610077A41E /* ftstroke.h in Headers */, - 611E0B3F11FA8F610077A41E /* ftsynth.h in Headers */, - 611E0B4011FA8F610077A41E /* ftsystem.h in Headers */, - 611E0B4111FA8F610077A41E /* fttrigon.h in Headers */, - 611E0B4211FA8F610077A41E /* fttypes.h in Headers */, - 611E0B4311FA8F610077A41E /* ftwinfnt.h in Headers */, - 611E0B4411FA8F610077A41E /* ftxf86.h in Headers */, - 611E0B4511FA8F610077A41E /* autohint.h in Headers */, - 611E0B4611FA8F610077A41E /* ftcalc.h in Headers */, - 611E0B4711FA8F610077A41E /* ftdebug.h in Headers */, - 611E0B4811FA8F610077A41E /* ftdriver.h in Headers */, - 611E0B4911FA8F610077A41E /* ftgloadr.h in Headers */, - 611E0B4A11FA8F610077A41E /* ftmemory.h in Headers */, - 611E0B4B11FA8F610077A41E /* ftobjs.h in Headers */, - 611E0B4C11FA8F610077A41E /* ftpic.h in Headers */, - 611E0B4D11FA8F610077A41E /* ftrfork.h in Headers */, - 611E0B4E11FA8F610077A41E /* ftserv.h in Headers */, - 611E0B4F11FA8F610077A41E /* ftstream.h in Headers */, - 611E0B5011FA8F610077A41E /* fttrace.h in Headers */, - 611E0B5111FA8F610077A41E /* ftvalid.h in Headers */, - 611E0B5211FA8F610077A41E /* internal.h in Headers */, - 611E0B5311FA8F610077A41E /* pcftypes.h in Headers */, - 611E0B5411FA8F610077A41E /* psaux.h in Headers */, - 611E0B5511FA8F610077A41E /* pshints.h in Headers */, - 611E0B5611FA8F610077A41E /* svbdf.h in Headers */, - 611E0B5711FA8F610077A41E /* svcid.h in Headers */, - 611E0B5811FA8F610077A41E /* svgldict.h in Headers */, - 611E0B5911FA8F610077A41E /* svgxval.h in Headers */, - 611E0B5A11FA8F610077A41E /* svkern.h in Headers */, - 611E0B5B11FA8F610077A41E /* svmm.h in Headers */, - 611E0B5C11FA8F610077A41E /* svotval.h in Headers */, - 611E0B5D11FA8F610077A41E /* svpfr.h in Headers */, - 611E0B5E11FA8F610077A41E /* svpostnm.h in Headers */, - 611E0B5F11FA8F610077A41E /* svpscmap.h in Headers */, - 611E0B6011FA8F610077A41E /* svpsinfo.h in Headers */, - 611E0B6111FA8F610077A41E /* svsfnt.h in Headers */, - 611E0B6211FA8F610077A41E /* svttcmap.h in Headers */, - 611E0B6311FA8F610077A41E /* svtteng.h in Headers */, - 611E0B6411FA8F610077A41E /* svttglyf.h in Headers */, - 611E0B6511FA8F610077A41E /* svwinfnt.h in Headers */, - 611E0B6611FA8F610077A41E /* svxf86nm.h in Headers */, - 611E0B6711FA8F610077A41E /* sfnt.h in Headers */, - 611E0B6811FA8F610077A41E /* t1types.h in Headers */, - 611E0B6911FA8F610077A41E /* tttypes.h in Headers */, - 611E0B6A11FA8F610077A41E /* t1tables.h in Headers */, - 611E0B6B11FA8F610077A41E /* ttnameid.h in Headers */, - 611E0B6C11FA8F610077A41E /* tttables.h in Headers */, - 611E0B6D11FA8F610077A41E /* tttags.h in Headers */, - 611E0B6E11FA8F610077A41E /* ttunpat.h in Headers */, - 611E0B6F11FA8F610077A41E /* ft2build.h in Headers */, - 611E0D0711FA8FA50077A41E /* basepic.h in Headers */, - 611E0D0B11FA8FA50077A41E /* ftbase.h in Headers */, - 611E0D4611FA8FA50077A41E /* cffcmap.h in Headers */, - 611E0D4811FA8FA50077A41E /* cffdrivr.h in Headers */, - 611E0D4911FA8FA50077A41E /* cfferrs.h in Headers */, - 611E0D4B11FA8FA50077A41E /* cffgload.h in Headers */, - 611E0D4D11FA8FA50077A41E /* cffload.h in Headers */, - 611E0D4F11FA8FA50077A41E /* cffobjs.h in Headers */, - 611E0D5111FA8FA50077A41E /* cffparse.h in Headers */, - 611E0D5311FA8FA50077A41E /* cffpic.h in Headers */, - 611E0D5411FA8FA50077A41E /* cfftoken.h in Headers */, - 611E0D5511FA8FA50077A41E /* cfftypes.h in Headers */, - 611E0DCA11FA8FA50077A41E /* pshalgo.h in Headers */, - 611E0DCC11FA8FA50077A41E /* pshglob.h in Headers */, - 611E0DCF11FA8FA50077A41E /* pshmod.h in Headers */, - 611E0DD011FA8FA50077A41E /* pshnterr.h in Headers */, - 611E0DD211FA8FA50077A41E /* pshpic.h in Headers */, - 611E0DD411FA8FA50077A41E /* pshrec.h in Headers */, - 611E0DD611FA8FA50077A41E /* psmodule.h in Headers */, - 611E0DD711FA8FA50077A41E /* psnamerr.h in Headers */, - 611E0DDA11FA8FA50077A41E /* pspic.h in Headers */, - 611E0DDB11FA8FA50077A41E /* pstables.h in Headers */, - 611E0DDC11FA8FA50077A41E /* ftmisc.h in Headers */, - 611E0DDE11FA8FA50077A41E /* ftraster.h in Headers */, - 611E0DE011FA8FA50077A41E /* ftrend1.h in Headers */, - 611E0DE211FA8FA50077A41E /* rasterrs.h in Headers */, - 611E0DE411FA8FA50077A41E /* rastpic.h in Headers */, - 611E0DE611FA8FA50077A41E /* sfdriver.h in Headers */, - 611E0DE711FA8FA50077A41E /* sferrors.h in Headers */, - 611E0DEA11FA8FA50077A41E /* sfntpic.h in Headers */, - 611E0DEC11FA8FA50077A41E /* sfobjs.h in Headers */, - 611E0DEE11FA8FA50077A41E /* ttbdf.h in Headers */, - 611E0DF011FA8FA50077A41E /* ttcmap.h in Headers */, - 611E0DF111FA8FA50077A41E /* ttcmapc.h in Headers */, - 611E0DF311FA8FA50077A41E /* ttkern.h in Headers */, - 611E0DF511FA8FA50077A41E /* ttload.h in Headers */, - 611E0DF711FA8FA50077A41E /* ttmtx.h in Headers */, - 611E0DF911FA8FA50077A41E /* ttpost.h in Headers */, - 611E0DFB11FA8FA50077A41E /* ttsbit.h in Headers */, - 611E0DFE11FA8FA50077A41E /* ftgrays.h in Headers */, - 611E0DFF11FA8FA50077A41E /* ftsmerrs.h in Headers */, - 611E0E0111FA8FA50077A41E /* ftsmooth.h in Headers */, - 611E0E0311FA8FA50077A41E /* ftspic.h in Headers */, - 611E0E0D11FA8FA50077A41E /* ttdriver.h in Headers */, - 611E0E0E11FA8FA50077A41E /* tterrors.h in Headers */, - 611E0E1011FA8FA50077A41E /* ttgload.h in Headers */, - 611E0E1211FA8FA50077A41E /* ttgxvar.h in Headers */, - 611E0E1411FA8FA50077A41E /* ttinterp.h in Headers */, - 611E0E1611FA8FA50077A41E /* ttobjs.h in Headers */, - 611E0E1811FA8FA50077A41E /* ttpic.h in Headers */, - 611E0E1A11FA8FA50077A41E /* ttpload.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - D2AAC07D0554694100DB518D /* libFreetype */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libFreetype" */; - buildPhases = ( - D2AAC07A0554694100DB518D /* Headers */, - D2AAC07B0554694100DB518D /* Sources */, - D2AAC07C0554694100DB518D /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = libFreetype; - productName = freetype; - productReference = D2AAC07E0554694100DB518D /* libFreetype.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 0867D690FE84028FC02AAC07 /* Project object */ = { - isa = PBXProject; - buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Freetype" */; - compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 0867D691FE84028FC02AAC07 /* freetype */; - productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - D2AAC07D0554694100DB518D /* libFreetype */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - D2AAC07B0554694100DB518D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 611E0D0611FA8FA50077A41E /* basepic.c in Sources */, - 611E0D0811FA8FA50077A41E /* ftadvanc.c in Sources */, - 611E0D0911FA8FA50077A41E /* ftapi.c in Sources */, - 611E0D0A11FA8FA50077A41E /* ftbase.c in Sources */, - 611E0D0C11FA8FA50077A41E /* ftbbox.c in Sources */, - 611E0D0E11FA8FA50077A41E /* ftbitmap.c in Sources */, - 611E0D0F11FA8FA50077A41E /* ftcalc.c in Sources */, - 611E0D1111FA8FA50077A41E /* ftdbgmem.c in Sources */, - 611E0D1211FA8FA50077A41E /* ftdebug.c in Sources */, - 611E0D1511FA8FA50077A41E /* ftgloadr.c in Sources */, - 611E0D1611FA8FA50077A41E /* ftglyph.c in Sources */, - 611E0D1811FA8FA50077A41E /* ftinit.c in Sources */, - 611E0D1C11FA8FA50077A41E /* ftobjs.c in Sources */, - 611E0D1E11FA8FA50077A41E /* ftoutln.c in Sources */, - 611E0D2111FA8FA50077A41E /* ftpic.c in Sources */, - 611E0D2211FA8FA50077A41E /* ftrfork.c in Sources */, - 611E0D2311FA8FA50077A41E /* ftsnames.c in Sources */, - 611E0D2411FA8FA50077A41E /* ftstream.c in Sources */, - 611E0D2511FA8FA50077A41E /* ftstroke.c in Sources */, - 611E0D2611FA8FA50077A41E /* ftsynth.c in Sources */, - 611E0D2711FA8FA50077A41E /* ftsystem.c in Sources */, - 611E0D2811FA8FA50077A41E /* fttrigon.c in Sources */, - 611E0D2A11FA8FA50077A41E /* ftutil.c in Sources */, - 611E0D4411FA8FA50077A41E /* cff.c in Sources */, - 611E0D4511FA8FA50077A41E /* cffcmap.c in Sources */, - 611E0D4711FA8FA50077A41E /* cffdrivr.c in Sources */, - 611E0D4A11FA8FA50077A41E /* cffgload.c in Sources */, - 611E0D4C11FA8FA50077A41E /* cffload.c in Sources */, - 611E0D4E11FA8FA50077A41E /* cffobjs.c in Sources */, - 611E0D5011FA8FA50077A41E /* cffparse.c in Sources */, - 611E0D5211FA8FA50077A41E /* cffpic.c in Sources */, - 611E0DC911FA8FA50077A41E /* pshalgo.c in Sources */, - 611E0DCB11FA8FA50077A41E /* pshglob.c in Sources */, - 611E0DCD11FA8FA50077A41E /* pshinter.c in Sources */, - 611E0DCE11FA8FA50077A41E /* pshmod.c in Sources */, - 611E0DD111FA8FA50077A41E /* pshpic.c in Sources */, - 611E0DD311FA8FA50077A41E /* pshrec.c in Sources */, - 611E0DD511FA8FA50077A41E /* psmodule.c in Sources */, - 611E0DD811FA8FA50077A41E /* psnames.c in Sources */, - 611E0DD911FA8FA50077A41E /* pspic.c in Sources */, - 611E0DDD11FA8FA50077A41E /* ftraster.c in Sources */, - 611E0DDF11FA8FA50077A41E /* ftrend1.c in Sources */, - 611E0DE111FA8FA50077A41E /* raster.c in Sources */, - 611E0DE311FA8FA50077A41E /* rastpic.c in Sources */, - 611E0DE511FA8FA50077A41E /* sfdriver.c in Sources */, - 611E0DE811FA8FA50077A41E /* sfnt.c in Sources */, - 611E0DE911FA8FA50077A41E /* sfntpic.c in Sources */, - 611E0DEB11FA8FA50077A41E /* sfobjs.c in Sources */, - 611E0DED11FA8FA50077A41E /* ttbdf.c in Sources */, - 611E0DEF11FA8FA50077A41E /* ttcmap.c in Sources */, - 611E0DF211FA8FA50077A41E /* ttkern.c in Sources */, - 611E0DF411FA8FA50077A41E /* ttload.c in Sources */, - 611E0DF611FA8FA50077A41E /* ttmtx.c in Sources */, - 611E0DF811FA8FA50077A41E /* ttpost.c in Sources */, - 611E0DFA11FA8FA50077A41E /* ttsbit.c in Sources */, - 611E0DFC11FA8FA50077A41E /* ttsbit0.c in Sources */, - 611E0DFD11FA8FA50077A41E /* ftgrays.c in Sources */, - 611E0E0011FA8FA50077A41E /* ftsmooth.c in Sources */, - 611E0E0211FA8FA50077A41E /* ftspic.c in Sources */, - 611E0E0411FA8FA50077A41E /* smooth.c in Sources */, - 611E0E0B11FA8FA50077A41E /* truetype.c in Sources */, - 611E0E0C11FA8FA50077A41E /* ttdriver.c in Sources */, - 611E0E0F11FA8FA50077A41E /* ttgload.c in Sources */, - 611E0E1111FA8FA50077A41E /* ttgxvar.c in Sources */, - 611E0E1311FA8FA50077A41E /* ttinterp.c in Sources */, - 611E0E1511FA8FA50077A41E /* ttobjs.c in Sources */, - 611E0E1711FA8FA50077A41E /* ttpic.c in Sources */, - 611E0E1911FA8FA50077A41E /* ttpload.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 1DEB921F08733DC00010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - COPY_PHASE_STRIP = NO; - DSTROOT = /tmp/freetype.dst; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = freetype_Prefix.pch; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = Freetype; - }; - name = Debug; - }; - 1DEB922008733DC00010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - DSTROOT = /tmp/freetype.dst; - GCC_MODEL_TUNING = G5; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = freetype_Prefix.pch; - INSTALL_PATH = /usr/local/lib; - PRODUCT_NAME = Freetype; - }; - name = Release; - }; - 1DEB922308733DC00010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - DARWIN_NO_CARBON, - FT2_BUILD_LIBRARY, - ); - GCC_THUMB_SUPPORT = YES; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../include\""; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; - OTHER_LDFLAGS = "-ObjC"; - PREBINDING = NO; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 1DEB922408733DC00010E9CD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; - GCC_C_LANGUAGE_STANDARD = c99; - GCC_FAST_MATH = YES; - GCC_OPTIMIZATION_LEVEL = s; - GCC_PREPROCESSOR_DEFINITIONS = ( - DARWIN_NO_CARBON, - FT2_BUILD_LIBRARY, - ); - GCC_THUMB_SUPPORT = YES; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = "\"$(SRCROOT)/../include\""; - IPHONEOS_DEPLOYMENT_TARGET = 3.0; - OTHER_LDFLAGS = "-ObjC"; - PREBINDING = NO; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "libFreetype" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB921F08733DC00010E9CD /* Debug */, - 1DEB922008733DC00010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Freetype" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB922308733DC00010E9CD /* Debug */, - 1DEB922408733DC00010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 0867D690FE84028FC02AAC07 /* Project object */; -} diff -r 41b0a9955c47 -r ddcdedd3330b misc/libfreetype/Xcode-iPhoneOS/Freetype_Prefix.pch --- a/misc/libfreetype/Xcode-iPhoneOS/Freetype_Prefix.pch Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project. -// - -#ifdef __OBJC__ - #import -#endif diff -r 41b0a9955c47 -r ddcdedd3330b misc/liblua/CMakeLists.txt --- a/misc/liblua/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/misc/liblua/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -1,19 +1,19 @@ +#this file is included only when system Lua library is not found + file(GLOB lua_src *.c *.h) -set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) + +if(WIN32) + add_definitions(-DLUA_BUILD_AS_DLL) + add_library(lua SHARED ${lua_src}) -IF(APPLE) - set(build_type STATIC) - add_definitions(-DLUA_USE_LINUX) - add_library (lua ${build_type} ${lua_src}) -ENDIF(APPLE) + set(LUA_LIBRARY lua.dll) -IF(WIN32) - set(build_type SHARED) - add_definitions(-DLUA_BUILD_AS_DLL) - add_library (lua ${build_type} ${lua_src}) - - SET_TARGET_PROPERTIES(lua PROPERTIES PREFIX "") - install(TARGETS lua RUNTIME DESTINATION ${target_dir}) + set_target_properties(lua PROPERTIES PREFIX "") + install(TARGETS lua RUNTIME DESTINATION ${target_dir}) +else(WIN32) + add_definitions(-DLUA_USE_LINUX) + add_library(lua STATIC ${lua_src}) + set(LUA_LIBRARY lua) endif(WIN32) diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/Android.mk diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/Xcode/Tremor.xcodeproj/default.mode1v3 diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/Xcode/Tremor.xcodeproj/default.pbxuser diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj --- a/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj Thu Nov 24 13:44:30 2011 +0100 +++ b/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj Sun Oct 28 13:28:23 2012 +0100 @@ -7,77 +7,77 @@ objects = { /* Begin PBXBuildFile section */ - 61958DC31364B72000B429B6 /* asm_arm.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DA61364B72000B429B6 /* asm_arm.h */; }; - 61958DC41364B72000B429B6 /* backends.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DA71364B72000B429B6 /* backends.h */; }; - 61958DC51364B72000B429B6 /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DA81364B72000B429B6 /* block.c */; }; - 61958DC61364B72000B429B6 /* block.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DA91364B72000B429B6 /* block.h */; }; - 61958DC71364B72000B429B6 /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DAA1364B72000B429B6 /* codebook.c */; }; - 61958DC81364B72000B429B6 /* codebook.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DAB1364B72000B429B6 /* codebook.h */; }; - 61958DC91364B72000B429B6 /* codec_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DAC1364B72000B429B6 /* codec_internal.h */; }; - 61958DCA1364B72000B429B6 /* config_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DAD1364B72000B429B6 /* config_types.h */; }; - 61958DCB1364B72000B429B6 /* floor0.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DAE1364B72000B429B6 /* floor0.c */; }; - 61958DCC1364B72000B429B6 /* floor1.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DAF1364B72000B429B6 /* floor1.c */; }; - 61958DCD1364B72000B429B6 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DB01364B72000B429B6 /* info.c */; }; - 61958DCE1364B72000B429B6 /* ivorbiscodec.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB11364B72000B429B6 /* ivorbiscodec.h */; }; - 61958DCF1364B72000B429B6 /* ivorbisfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB21364B72000B429B6 /* ivorbisfile.h */; }; - 61958DD01364B72000B429B6 /* lsp_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB31364B72000B429B6 /* lsp_lookup.h */; }; - 61958DD11364B72000B429B6 /* mapping0.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DB41364B72000B429B6 /* mapping0.c */; }; - 61958DD21364B72000B429B6 /* mdct_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB51364B72000B429B6 /* mdct_lookup.h */; }; - 61958DD31364B72000B429B6 /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DB61364B72000B429B6 /* mdct.c */; }; - 61958DD41364B72000B429B6 /* mdct.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB71364B72000B429B6 /* mdct.h */; }; - 61958DD51364B72000B429B6 /* misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB81364B72000B429B6 /* misc.h */; }; - 61958DD61364B72000B429B6 /* os.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DB91364B72000B429B6 /* os.h */; }; - 61958DD71364B72000B429B6 /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DBA1364B72000B429B6 /* registry.c */; }; - 61958DD81364B72000B429B6 /* registry.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DBB1364B72000B429B6 /* registry.h */; }; - 61958DD91364B72000B429B6 /* res012.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DBC1364B72000B429B6 /* res012.c */; }; - 61958DDA1364B72000B429B6 /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DBD1364B72000B429B6 /* sharedbook.c */; }; - 61958DDB1364B72000B429B6 /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DBE1364B72000B429B6 /* synthesis.c */; }; - 61958DDC1364B72000B429B6 /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DBF1364B72000B429B6 /* vorbisfile.c */; }; - 61958DDD1364B72000B429B6 /* window_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DC01364B72000B429B6 /* window_lookup.h */; }; - 61958DDE1364B72000B429B6 /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = 61958DC11364B72000B429B6 /* window.c */; }; - 61958DDF1364B72000B429B6 /* window.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DC21364B72000B429B6 /* window.h */; }; - 61958DFC1364B84300B429B6 /* os_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958DFB1364B84300B429B6 /* os_types.h */; }; - 61958E0E1364B89700B429B6 /* ogg.h in Headers */ = {isa = PBXBuildFile; fileRef = 61958E0D1364B89700B429B6 /* ogg.h */; }; - 619598391364BDCC00B429B6 /* framing.c in Sources */ = {isa = PBXBuildFile; fileRef = 619598381364BDCC00B429B6 /* framing.c */; }; - 619598411364BE7F00B429B6 /* bitwise.c in Sources */ = {isa = PBXBuildFile; fileRef = 619598401364BE7F00B429B6 /* bitwise.c */; }; + 61DB1809148BA9A9004A67B8 /* asm_arm.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17E7148BA9A9004A67B8 /* asm_arm.h */; }; + 61DB180A148BA9A9004A67B8 /* backends.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17E8148BA9A9004A67B8 /* backends.h */; }; + 61DB180B148BA9A9004A67B8 /* bitwise.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17E9148BA9A9004A67B8 /* bitwise.c */; }; + 61DB180C148BA9A9004A67B8 /* block.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17EA148BA9A9004A67B8 /* block.c */; }; + 61DB180D148BA9A9004A67B8 /* block.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17EB148BA9A9004A67B8 /* block.h */; }; + 61DB180E148BA9A9004A67B8 /* codebook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17EC148BA9A9004A67B8 /* codebook.c */; }; + 61DB180F148BA9A9004A67B8 /* codebook.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17ED148BA9A9004A67B8 /* codebook.h */; }; + 61DB1810148BA9A9004A67B8 /* codec_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17EE148BA9A9004A67B8 /* codec_internal.h */; }; + 61DB1811148BA9A9004A67B8 /* config_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17EF148BA9A9004A67B8 /* config_types.h */; }; + 61DB1812148BA9A9004A67B8 /* floor0.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17F0148BA9A9004A67B8 /* floor0.c */; }; + 61DB1813148BA9A9004A67B8 /* floor1.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17F1148BA9A9004A67B8 /* floor1.c */; }; + 61DB1814148BA9A9004A67B8 /* framing.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17F2148BA9A9004A67B8 /* framing.c */; }; + 61DB1815148BA9A9004A67B8 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17F3148BA9A9004A67B8 /* info.c */; }; + 61DB1816148BA9A9004A67B8 /* ivorbiscodec.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17F4148BA9A9004A67B8 /* ivorbiscodec.h */; }; + 61DB1818148BA9A9004A67B8 /* ivorbisfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17F6148BA9A9004A67B8 /* ivorbisfile.h */; }; + 61DB1819148BA9A9004A67B8 /* lsp_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17F7148BA9A9004A67B8 /* lsp_lookup.h */; }; + 61DB181A148BA9A9004A67B8 /* mapping0.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17F8148BA9A9004A67B8 /* mapping0.c */; }; + 61DB181B148BA9A9004A67B8 /* mdct_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17F9148BA9A9004A67B8 /* mdct_lookup.h */; }; + 61DB181C148BA9A9004A67B8 /* mdct.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB17FA148BA9A9004A67B8 /* mdct.c */; }; + 61DB181D148BA9A9004A67B8 /* mdct.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FB148BA9A9004A67B8 /* mdct.h */; }; + 61DB181E148BA9A9004A67B8 /* misc.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FC148BA9A9004A67B8 /* misc.h */; }; + 61DB181F148BA9A9004A67B8 /* ogg.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FD148BA9A9004A67B8 /* ogg.h */; }; + 61DB1820148BA9A9004A67B8 /* os_types.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FE148BA9A9004A67B8 /* os_types.h */; }; + 61DB1821148BA9A9004A67B8 /* os.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB17FF148BA9A9004A67B8 /* os.h */; }; + 61DB1822148BA9A9004A67B8 /* registry.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1800148BA9A9004A67B8 /* registry.c */; }; + 61DB1823148BA9A9004A67B8 /* registry.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1801148BA9A9004A67B8 /* registry.h */; }; + 61DB1824148BA9A9004A67B8 /* res012.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1802148BA9A9004A67B8 /* res012.c */; }; + 61DB1825148BA9A9004A67B8 /* sharedbook.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1803148BA9A9004A67B8 /* sharedbook.c */; }; + 61DB1826148BA9A9004A67B8 /* synthesis.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1804148BA9A9004A67B8 /* synthesis.c */; }; + 61DB1827148BA9A9004A67B8 /* vorbisfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1805148BA9A9004A67B8 /* vorbisfile.c */; }; + 61DB1828148BA9A9004A67B8 /* window_lookup.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1806148BA9A9004A67B8 /* window_lookup.h */; }; + 61DB1829148BA9A9004A67B8 /* window.c in Sources */ = {isa = PBXBuildFile; fileRef = 61DB1807148BA9A9004A67B8 /* window.c */; }; + 61DB182A148BA9A9004A67B8 /* window.h in Headers */ = {isa = PBXBuildFile; fileRef = 61DB1808148BA9A9004A67B8 /* window.h */; }; AA747D9F0F9514B9006C5449 /* Tremor_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Tremor_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 61958DA61364B72000B429B6 /* asm_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asm_arm.h; path = ../asm_arm.h; sourceTree = SOURCE_ROOT; }; - 61958DA71364B72000B429B6 /* backends.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = backends.h; path = ../backends.h; sourceTree = SOURCE_ROOT; }; - 61958DA81364B72000B429B6 /* block.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = block.c; path = ../block.c; sourceTree = SOURCE_ROOT; }; - 61958DA91364B72000B429B6 /* block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = block.h; path = ../block.h; sourceTree = SOURCE_ROOT; }; - 61958DAA1364B72000B429B6 /* codebook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = codebook.c; path = ../codebook.c; sourceTree = SOURCE_ROOT; }; - 61958DAB1364B72000B429B6 /* codebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codebook.h; path = ../codebook.h; sourceTree = SOURCE_ROOT; }; - 61958DAC1364B72000B429B6 /* codec_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codec_internal.h; path = ../codec_internal.h; sourceTree = SOURCE_ROOT; }; - 61958DAD1364B72000B429B6 /* config_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config_types.h; path = ../config_types.h; sourceTree = SOURCE_ROOT; }; - 61958DAE1364B72000B429B6 /* floor0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor0.c; path = ../floor0.c; sourceTree = SOURCE_ROOT; }; - 61958DAF1364B72000B429B6 /* floor1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor1.c; path = ../floor1.c; sourceTree = SOURCE_ROOT; }; - 61958DB01364B72000B429B6 /* info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = info.c; path = ../info.c; sourceTree = SOURCE_ROOT; }; - 61958DB11364B72000B429B6 /* ivorbiscodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbiscodec.h; path = ../ivorbiscodec.h; sourceTree = SOURCE_ROOT; }; - 61958DB21364B72000B429B6 /* ivorbisfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbisfile.h; path = ../ivorbisfile.h; sourceTree = SOURCE_ROOT; }; - 61958DB31364B72000B429B6 /* lsp_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lsp_lookup.h; path = ../lsp_lookup.h; sourceTree = SOURCE_ROOT; }; - 61958DB41364B72000B429B6 /* mapping0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mapping0.c; path = ../mapping0.c; sourceTree = SOURCE_ROOT; }; - 61958DB51364B72000B429B6 /* mdct_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct_lookup.h; path = ../mdct_lookup.h; sourceTree = SOURCE_ROOT; }; - 61958DB61364B72000B429B6 /* mdct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mdct.c; path = ../mdct.c; sourceTree = SOURCE_ROOT; }; - 61958DB71364B72000B429B6 /* mdct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct.h; path = ../mdct.h; sourceTree = SOURCE_ROOT; }; - 61958DB81364B72000B429B6 /* misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = misc.h; path = ../misc.h; sourceTree = SOURCE_ROOT; }; - 61958DB91364B72000B429B6 /* os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os.h; path = ../os.h; sourceTree = SOURCE_ROOT; }; - 61958DBA1364B72000B429B6 /* registry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = registry.c; path = ../registry.c; sourceTree = SOURCE_ROOT; }; - 61958DBB1364B72000B429B6 /* registry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = registry.h; path = ../registry.h; sourceTree = SOURCE_ROOT; }; - 61958DBC1364B72000B429B6 /* res012.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = res012.c; path = ../res012.c; sourceTree = SOURCE_ROOT; }; - 61958DBD1364B72000B429B6 /* sharedbook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sharedbook.c; path = ../sharedbook.c; sourceTree = SOURCE_ROOT; }; - 61958DBE1364B72000B429B6 /* synthesis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = synthesis.c; path = ../synthesis.c; sourceTree = SOURCE_ROOT; }; - 61958DBF1364B72000B429B6 /* vorbisfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vorbisfile.c; path = ../vorbisfile.c; sourceTree = SOURCE_ROOT; }; - 61958DC01364B72000B429B6 /* window_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window_lookup.h; path = ../window_lookup.h; sourceTree = SOURCE_ROOT; }; - 61958DC11364B72000B429B6 /* window.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = window.c; path = ../window.c; sourceTree = SOURCE_ROOT; }; - 61958DC21364B72000B429B6 /* window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window.h; path = ../window.h; sourceTree = SOURCE_ROOT; }; - 61958DFB1364B84300B429B6 /* os_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os_types.h; path = ../../../../Library/cocos2d/external/Tremor/os_types.h; sourceTree = SOURCE_ROOT; }; - 61958E0D1364B89700B429B6 /* ogg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ogg.h; path = ../ogg.h; sourceTree = SOURCE_ROOT; }; - 619598381364BDCC00B429B6 /* framing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = framing.c; path = ../framing.c; sourceTree = ""; }; - 619598401364BE7F00B429B6 /* bitwise.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bitwise.c; path = ../bitwise.c; sourceTree = ""; }; + 61DB17E7148BA9A9004A67B8 /* asm_arm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = asm_arm.h; path = ../tremor/asm_arm.h; sourceTree = SOURCE_ROOT; }; + 61DB17E8148BA9A9004A67B8 /* backends.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = backends.h; path = ../tremor/backends.h; sourceTree = SOURCE_ROOT; }; + 61DB17E9148BA9A9004A67B8 /* bitwise.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = bitwise.c; path = ../tremor/bitwise.c; sourceTree = SOURCE_ROOT; }; + 61DB17EA148BA9A9004A67B8 /* block.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = block.c; path = ../tremor/block.c; sourceTree = SOURCE_ROOT; }; + 61DB17EB148BA9A9004A67B8 /* block.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = block.h; path = ../tremor/block.h; sourceTree = SOURCE_ROOT; }; + 61DB17EC148BA9A9004A67B8 /* codebook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = codebook.c; path = ../tremor/codebook.c; sourceTree = SOURCE_ROOT; }; + 61DB17ED148BA9A9004A67B8 /* codebook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codebook.h; path = ../tremor/codebook.h; sourceTree = SOURCE_ROOT; }; + 61DB17EE148BA9A9004A67B8 /* codec_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = codec_internal.h; path = ../tremor/codec_internal.h; sourceTree = SOURCE_ROOT; }; + 61DB17EF148BA9A9004A67B8 /* config_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config_types.h; path = ../tremor/config_types.h; sourceTree = SOURCE_ROOT; }; + 61DB17F0148BA9A9004A67B8 /* floor0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor0.c; path = ../tremor/floor0.c; sourceTree = SOURCE_ROOT; }; + 61DB17F1148BA9A9004A67B8 /* floor1.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = floor1.c; path = ../tremor/floor1.c; sourceTree = SOURCE_ROOT; }; + 61DB17F2148BA9A9004A67B8 /* framing.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = framing.c; path = ../tremor/framing.c; sourceTree = SOURCE_ROOT; }; + 61DB17F3148BA9A9004A67B8 /* info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = info.c; path = ../tremor/info.c; sourceTree = SOURCE_ROOT; }; + 61DB17F4148BA9A9004A67B8 /* ivorbiscodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbiscodec.h; path = ../tremor/ivorbiscodec.h; sourceTree = SOURCE_ROOT; }; + 61DB17F6148BA9A9004A67B8 /* ivorbisfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ivorbisfile.h; path = ../tremor/ivorbisfile.h; sourceTree = SOURCE_ROOT; }; + 61DB17F7148BA9A9004A67B8 /* lsp_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lsp_lookup.h; path = ../tremor/lsp_lookup.h; sourceTree = SOURCE_ROOT; }; + 61DB17F8148BA9A9004A67B8 /* mapping0.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mapping0.c; path = ../tremor/mapping0.c; sourceTree = SOURCE_ROOT; }; + 61DB17F9148BA9A9004A67B8 /* mdct_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct_lookup.h; path = ../tremor/mdct_lookup.h; sourceTree = SOURCE_ROOT; }; + 61DB17FA148BA9A9004A67B8 /* mdct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mdct.c; path = ../tremor/mdct.c; sourceTree = SOURCE_ROOT; }; + 61DB17FB148BA9A9004A67B8 /* mdct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdct.h; path = ../tremor/mdct.h; sourceTree = SOURCE_ROOT; }; + 61DB17FC148BA9A9004A67B8 /* misc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = misc.h; path = ../tremor/misc.h; sourceTree = SOURCE_ROOT; }; + 61DB17FD148BA9A9004A67B8 /* ogg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ogg.h; path = ../tremor/ogg.h; sourceTree = SOURCE_ROOT; }; + 61DB17FE148BA9A9004A67B8 /* os_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os_types.h; path = ../tremor/os_types.h; sourceTree = SOURCE_ROOT; }; + 61DB17FF148BA9A9004A67B8 /* os.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = os.h; path = ../tremor/os.h; sourceTree = SOURCE_ROOT; }; + 61DB1800148BA9A9004A67B8 /* registry.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = registry.c; path = ../tremor/registry.c; sourceTree = SOURCE_ROOT; }; + 61DB1801148BA9A9004A67B8 /* registry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = registry.h; path = ../tremor/registry.h; sourceTree = SOURCE_ROOT; }; + 61DB1802148BA9A9004A67B8 /* res012.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = res012.c; path = ../tremor/res012.c; sourceTree = SOURCE_ROOT; }; + 61DB1803148BA9A9004A67B8 /* sharedbook.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sharedbook.c; path = ../tremor/sharedbook.c; sourceTree = SOURCE_ROOT; }; + 61DB1804148BA9A9004A67B8 /* synthesis.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = synthesis.c; path = ../tremor/synthesis.c; sourceTree = SOURCE_ROOT; }; + 61DB1805148BA9A9004A67B8 /* vorbisfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vorbisfile.c; path = ../tremor/vorbisfile.c; sourceTree = SOURCE_ROOT; }; + 61DB1806148BA9A9004A67B8 /* window_lookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window_lookup.h; path = ../tremor/window_lookup.h; sourceTree = SOURCE_ROOT; }; + 61DB1807148BA9A9004A67B8 /* window.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = window.c; path = ../tremor/window.c; sourceTree = SOURCE_ROOT; }; + 61DB1808148BA9A9004A67B8 /* window.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = window.h; path = ../tremor/window.h; sourceTree = SOURCE_ROOT; }; AA747D9E0F9514B9006C5449 /* Tremor_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Tremor_Prefix.pch; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libTremor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libTremor.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -125,39 +125,39 @@ 08FB77AEFE84172EC02AAC07 /* Sources */ = { isa = PBXGroup; children = ( - 619598401364BE7F00B429B6 /* bitwise.c */, - 619598381364BDCC00B429B6 /* framing.c */, - 61958DA61364B72000B429B6 /* asm_arm.h */, - 61958DA71364B72000B429B6 /* backends.h */, - 61958DA81364B72000B429B6 /* block.c */, - 61958DA91364B72000B429B6 /* block.h */, - 61958DAA1364B72000B429B6 /* codebook.c */, - 61958DAB1364B72000B429B6 /* codebook.h */, - 61958DAC1364B72000B429B6 /* codec_internal.h */, - 61958DAD1364B72000B429B6 /* config_types.h */, - 61958DAE1364B72000B429B6 /* floor0.c */, - 61958DAF1364B72000B429B6 /* floor1.c */, - 61958DB01364B72000B429B6 /* info.c */, - 61958DB11364B72000B429B6 /* ivorbiscodec.h */, - 61958DB21364B72000B429B6 /* ivorbisfile.h */, - 61958DB31364B72000B429B6 /* lsp_lookup.h */, - 61958DB41364B72000B429B6 /* mapping0.c */, - 61958DB51364B72000B429B6 /* mdct_lookup.h */, - 61958DB61364B72000B429B6 /* mdct.c */, - 61958DB71364B72000B429B6 /* mdct.h */, - 61958DB81364B72000B429B6 /* misc.h */, - 61958E0D1364B89700B429B6 /* ogg.h */, - 61958DB91364B72000B429B6 /* os.h */, - 61958DFB1364B84300B429B6 /* os_types.h */, - 61958DBA1364B72000B429B6 /* registry.c */, - 61958DBB1364B72000B429B6 /* registry.h */, - 61958DBC1364B72000B429B6 /* res012.c */, - 61958DBD1364B72000B429B6 /* sharedbook.c */, - 61958DBE1364B72000B429B6 /* synthesis.c */, - 61958DBF1364B72000B429B6 /* vorbisfile.c */, - 61958DC01364B72000B429B6 /* window_lookup.h */, - 61958DC11364B72000B429B6 /* window.c */, - 61958DC21364B72000B429B6 /* window.h */, + 61DB17E7148BA9A9004A67B8 /* asm_arm.h */, + 61DB17E8148BA9A9004A67B8 /* backends.h */, + 61DB17E9148BA9A9004A67B8 /* bitwise.c */, + 61DB17EA148BA9A9004A67B8 /* block.c */, + 61DB17EB148BA9A9004A67B8 /* block.h */, + 61DB17EC148BA9A9004A67B8 /* codebook.c */, + 61DB17ED148BA9A9004A67B8 /* codebook.h */, + 61DB17EE148BA9A9004A67B8 /* codec_internal.h */, + 61DB17EF148BA9A9004A67B8 /* config_types.h */, + 61DB17F0148BA9A9004A67B8 /* floor0.c */, + 61DB17F1148BA9A9004A67B8 /* floor1.c */, + 61DB17F2148BA9A9004A67B8 /* framing.c */, + 61DB17F3148BA9A9004A67B8 /* info.c */, + 61DB17F4148BA9A9004A67B8 /* ivorbiscodec.h */, + 61DB17F6148BA9A9004A67B8 /* ivorbisfile.h */, + 61DB17F7148BA9A9004A67B8 /* lsp_lookup.h */, + 61DB17F8148BA9A9004A67B8 /* mapping0.c */, + 61DB17F9148BA9A9004A67B8 /* mdct_lookup.h */, + 61DB17FA148BA9A9004A67B8 /* mdct.c */, + 61DB17FB148BA9A9004A67B8 /* mdct.h */, + 61DB17FC148BA9A9004A67B8 /* misc.h */, + 61DB17FD148BA9A9004A67B8 /* ogg.h */, + 61DB17FE148BA9A9004A67B8 /* os_types.h */, + 61DB17FF148BA9A9004A67B8 /* os.h */, + 61DB1800148BA9A9004A67B8 /* registry.c */, + 61DB1801148BA9A9004A67B8 /* registry.h */, + 61DB1802148BA9A9004A67B8 /* res012.c */, + 61DB1803148BA9A9004A67B8 /* sharedbook.c */, + 61DB1804148BA9A9004A67B8 /* synthesis.c */, + 61DB1805148BA9A9004A67B8 /* vorbisfile.c */, + 61DB1806148BA9A9004A67B8 /* window_lookup.h */, + 61DB1807148BA9A9004A67B8 /* window.c */, + 61DB1808148BA9A9004A67B8 /* window.h */, ); name = Sources; sourceTree = ""; @@ -178,24 +178,24 @@ buildActionMask = 2147483647; files = ( AA747D9F0F9514B9006C5449 /* Tremor_Prefix.pch in Headers */, - 61958DC31364B72000B429B6 /* asm_arm.h in Headers */, - 61958DC41364B72000B429B6 /* backends.h in Headers */, - 61958DC61364B72000B429B6 /* block.h in Headers */, - 61958DC81364B72000B429B6 /* codebook.h in Headers */, - 61958DC91364B72000B429B6 /* codec_internal.h in Headers */, - 61958DCA1364B72000B429B6 /* config_types.h in Headers */, - 61958DCE1364B72000B429B6 /* ivorbiscodec.h in Headers */, - 61958DCF1364B72000B429B6 /* ivorbisfile.h in Headers */, - 61958DD01364B72000B429B6 /* lsp_lookup.h in Headers */, - 61958DD21364B72000B429B6 /* mdct_lookup.h in Headers */, - 61958DD41364B72000B429B6 /* mdct.h in Headers */, - 61958DD51364B72000B429B6 /* misc.h in Headers */, - 61958DD61364B72000B429B6 /* os.h in Headers */, - 61958DD81364B72000B429B6 /* registry.h in Headers */, - 61958DDD1364B72000B429B6 /* window_lookup.h in Headers */, - 61958DDF1364B72000B429B6 /* window.h in Headers */, - 61958DFC1364B84300B429B6 /* os_types.h in Headers */, - 61958E0E1364B89700B429B6 /* ogg.h in Headers */, + 61DB1809148BA9A9004A67B8 /* asm_arm.h in Headers */, + 61DB180A148BA9A9004A67B8 /* backends.h in Headers */, + 61DB180D148BA9A9004A67B8 /* block.h in Headers */, + 61DB180F148BA9A9004A67B8 /* codebook.h in Headers */, + 61DB1810148BA9A9004A67B8 /* codec_internal.h in Headers */, + 61DB1811148BA9A9004A67B8 /* config_types.h in Headers */, + 61DB1816148BA9A9004A67B8 /* ivorbiscodec.h in Headers */, + 61DB1818148BA9A9004A67B8 /* ivorbisfile.h in Headers */, + 61DB1819148BA9A9004A67B8 /* lsp_lookup.h in Headers */, + 61DB181B148BA9A9004A67B8 /* mdct_lookup.h in Headers */, + 61DB181D148BA9A9004A67B8 /* mdct.h in Headers */, + 61DB181E148BA9A9004A67B8 /* misc.h in Headers */, + 61DB181F148BA9A9004A67B8 /* ogg.h in Headers */, + 61DB1820148BA9A9004A67B8 /* os_types.h in Headers */, + 61DB1821148BA9A9004A67B8 /* os.h in Headers */, + 61DB1823148BA9A9004A67B8 /* registry.h in Headers */, + 61DB1828148BA9A9004A67B8 /* window_lookup.h in Headers */, + 61DB182A148BA9A9004A67B8 /* window.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -249,21 +249,21 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 619598411364BE7F00B429B6 /* bitwise.c in Sources */, - 61958DC51364B72000B429B6 /* block.c in Sources */, - 61958DC71364B72000B429B6 /* codebook.c in Sources */, - 619598391364BDCC00B429B6 /* framing.c in Sources */, - 61958DCB1364B72000B429B6 /* floor0.c in Sources */, - 61958DCC1364B72000B429B6 /* floor1.c in Sources */, - 61958DCD1364B72000B429B6 /* info.c in Sources */, - 61958DD11364B72000B429B6 /* mapping0.c in Sources */, - 61958DD31364B72000B429B6 /* mdct.c in Sources */, - 61958DD71364B72000B429B6 /* registry.c in Sources */, - 61958DD91364B72000B429B6 /* res012.c in Sources */, - 61958DDA1364B72000B429B6 /* sharedbook.c in Sources */, - 61958DDB1364B72000B429B6 /* synthesis.c in Sources */, - 61958DDC1364B72000B429B6 /* vorbisfile.c in Sources */, - 61958DDE1364B72000B429B6 /* window.c in Sources */, + 61DB180B148BA9A9004A67B8 /* bitwise.c in Sources */, + 61DB180C148BA9A9004A67B8 /* block.c in Sources */, + 61DB180E148BA9A9004A67B8 /* codebook.c in Sources */, + 61DB1812148BA9A9004A67B8 /* floor0.c in Sources */, + 61DB1813148BA9A9004A67B8 /* floor1.c in Sources */, + 61DB1814148BA9A9004A67B8 /* framing.c in Sources */, + 61DB1815148BA9A9004A67B8 /* info.c in Sources */, + 61DB181A148BA9A9004A67B8 /* mapping0.c in Sources */, + 61DB181C148BA9A9004A67B8 /* mdct.c in Sources */, + 61DB1822148BA9A9004A67B8 /* registry.c in Sources */, + 61DB1824148BA9A9004A67B8 /* res012.c in Sources */, + 61DB1825148BA9A9004A67B8 /* sharedbook.c in Sources */, + 61DB1826148BA9A9004A67B8 /* synthesis.c in Sources */, + 61DB1827148BA9A9004A67B8 /* vorbisfile.c in Sources */, + 61DB1829148BA9A9004A67B8 /* window.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/Xcode/Tremor_Prefix.pch diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/Makefile.am diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/Version_script.in --- a/misc/libtremor/tremor/Version_script.in Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -# -# Export file for libvorbisidec -# -# Only the symbols listed in the global section will be callable from -# applications linking to libvorbisidec. -# - -@PACKAGE@.so.1 -{ - global: - ov_clear; - ov_open; - ov_open_callbacks; - ov_test; - ov_test_callbacks; - ov_test_open; - ov_bitrate; - ov_bitrate_instant; - ov_streams; - ov_seekable; - ov_serialnumber; - ov_raw_total; - ov_pcm_total; - ov_time_total; - ov_raw_seek; - ov_pcm_seek; - ov_pcm_seek_page; - ov_time_seek; - ov_time_seek_page; - ov_raw_tell; - ov_pcm_tell; - ov_time_tell; - ov_info; - ov_comment; - ov_read; - - vorbis_info_init; - vorbis_info_clear; - vorbis_info_blocksize; - vorbis_comment_init; - vorbis_comment_add; - vorbis_comment_add_tag; - vorbis_comment_query; - vorbis_comment_query_count; - vorbis_comment_clear; - - local: - *; -}; diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/autogen.sh diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/backends.h --- a/misc/libtremor/tremor/backends.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: backend and mapping structures - - ********************************************************************/ - -/* this is exposed up here because we need it for static modes. - Lookups for each backend aren't exposed because there's no reason - to do so */ - -#ifndef _vorbis_backend_h_ -#define _vorbis_backend_h_ - -#include "codec_internal.h" - -/* this would all be simpler/shorter with templates, but.... */ -/* Transform backend generic *************************************/ - -/* only mdct right now. Flesh it out more if we ever transcend mdct - in the transform domain */ - -/* Floor backend generic *****************************************/ -typedef struct{ - vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); - vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_mode *, - vorbis_info_floor *); - void (*free_info) (vorbis_info_floor *); - void (*free_look) (vorbis_look_floor *); - void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); - int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, - void *buffer,ogg_int32_t *); -} vorbis_func_floor; - -typedef struct{ - int order; - long rate; - long barkmap; - - int ampbits; - int ampdB; - - int numbooks; /* <= 16 */ - int books[16]; - -} vorbis_info_floor0; - -#define VIF_POSIT 63 -#define VIF_CLASS 16 -#define VIF_PARTS 31 -typedef struct{ - int partitions; /* 0 to 31 */ - int partitionclass[VIF_PARTS]; /* 0 to 15 */ - - int class_dim[VIF_CLASS]; /* 1 to 8 */ - int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1< -#include -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" - -#include "window.h" -#include "registry.h" -#include "misc.h" - -static int ilog(unsigned int v){ - int ret=0; - if(v)--v; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -/* pcm accumulator examples (not exhaustive): - - <-------------- lW ----------------> - <--------------- W ----------------> -: .....|..... _______________ | -: .''' | '''_--- | |\ | -:.....''' |_____--- '''......| | \_______| -:.................|__________________|_______|__|______| - |<------ Sl ------>| > Sr < |endW - |beginSl |endSl | |endSr - |beginW |endlW |beginSr - - - |< lW >| - <--------------- W ----------------> - | | .. ______________ | - | | ' `/ | ---_ | - |___.'___/`. | ---_____| - |_______|__|_______|_________________| - | >|Sl|< |<------ Sr ----->|endW - | | |endSl |beginSr |endSr - |beginW | |endlW - mult[0] |beginSl mult[n] - - <-------------- lW -----------------> - |<--W-->| -: .............. ___ | | -: .''' |`/ \ | | -:.....''' |/`....\|...| -:.........................|___|___|___| - |Sl |Sr |endW - | | |endSr - | |beginSr - | |endSl - |beginSl - |beginW -*/ - -/* block abstraction setup *********************************************/ - -#ifndef WORD_ALIGN -#define WORD_ALIGN 8 -#endif - -int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ - memset(vb,0,sizeof(*vb)); - vb->vd=v; - vb->localalloc=0; - vb->localstore=NULL; - - return(0); -} - -void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ - bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); - if(bytes+vb->localtop>vb->localalloc){ - /* can't just _ogg_realloc... there are outstanding pointers */ - if(vb->localstore){ - struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link)); - vb->totaluse+=vb->localtop; - link->next=vb->reap; - link->ptr=vb->localstore; - vb->reap=link; - } - /* highly conservative */ - vb->localalloc=bytes; - vb->localstore=_ogg_malloc(vb->localalloc); - vb->localtop=0; - } - { - void *ret=(void *)(((char *)vb->localstore)+vb->localtop); - vb->localtop+=bytes; - return ret; - } -} - -/* reap the chain, pull the ripcord */ -void _vorbis_block_ripcord(vorbis_block *vb){ - /* reap the chain */ - struct alloc_chain *reap=vb->reap; - while(reap){ - struct alloc_chain *next=reap->next; - _ogg_free(reap->ptr); - memset(reap,0,sizeof(*reap)); - _ogg_free(reap); - reap=next; - } - /* consolidate storage */ - if(vb->totaluse){ - vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); - vb->localalloc+=vb->totaluse; - vb->totaluse=0; - } - - /* pull the ripcord */ - vb->localtop=0; - vb->reap=NULL; -} - -int vorbis_block_clear(vorbis_block *vb){ - _vorbis_block_ripcord(vb); - if(vb->localstore)_ogg_free(vb->localstore); - - memset(vb,0,sizeof(*vb)); - return(0); -} - -static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ - int i; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - private_state *b=NULL; - - memset(v,0,sizeof(*v)); - b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); - - v->vi=vi; - b->modebits=ilog(ci->modes); - - /* Vorbis I uses only window type 0 */ - b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); - b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); - - /* finish the codebooks */ - if(!ci->fullbooks){ - ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); - for(i=0;ibooks;i++){ - vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); - /* decode codebooks are now standalone after init */ - vorbis_staticbook_destroy(ci->book_param[i]); - ci->book_param[i]=NULL; - } - } - - v->pcm_storage=ci->blocksizes[1]; - v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); - v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); - for(i=0;ichannels;i++) - v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); - - /* all 1 (large block) or 0 (small block) */ - /* explicitly set for the sake of clarity */ - v->lW=0; /* previous window size */ - v->W=0; /* current window size */ - - /* initialize all the mapping/backend lookups */ - b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); - for(i=0;imodes;i++){ - int mapnum=ci->mode_param[i]->mapping; - int maptype=ci->map_type[mapnum]; - b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], - ci->map_param[mapnum]); - } - return(0); -} - -int vorbis_synthesis_restart(vorbis_dsp_state *v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci; - - if(!v->backend_state)return -1; - if(!vi)return -1; - ci=vi->codec_setup; - if(!ci)return -1; - - v->centerW=ci->blocksizes[1]/2; - v->pcm_current=v->centerW; - - v->pcm_returned=-1; - v->granulepos=-1; - v->sequence=-1; - ((private_state *)(v->backend_state))->sample_count=-1; - - return(0); -} - -int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ - _vds_init(v,vi); - vorbis_synthesis_restart(v); - - return(0); -} - -void vorbis_dsp_clear(vorbis_dsp_state *v){ - int i; - if(v){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); - private_state *b=(private_state *)v->backend_state; - - if(v->pcm){ - for(i=0;ichannels;i++) - if(v->pcm[i])_ogg_free(v->pcm[i]); - _ogg_free(v->pcm); - if(v->pcmret)_ogg_free(v->pcmret); - } - - /* free mode lookups; these are actually vorbis_look_mapping structs */ - if(ci){ - for(i=0;imodes;i++){ - int mapnum=ci->mode_param[i]->mapping; - int maptype=ci->map_type[mapnum]; - if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); - } - } - - if(b){ - if(b->mode)_ogg_free(b->mode); - _ogg_free(b); - } - - memset(v,0,sizeof(*v)); - } -} - -/* Unlike in analysis, the window is only partially applied for each - block. The time domain envelope is not yet handled at the point of - calling (as it relies on the previous block). */ - -int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ - vorbis_info *vi=v->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - private_state *b=v->backend_state; - int i,j; - - if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); - - v->lW=v->W; - v->W=vb->W; - v->nW=-1; - - if((v->sequence==-1)|| - (v->sequence+1 != vb->sequence)){ - v->granulepos=-1; /* out of sequence; lose count */ - b->sample_count=-1; - } - - v->sequence=vb->sequence; - - if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly - was called on block */ - int n=ci->blocksizes[v->W]/2; - int n0=ci->blocksizes[0]/2; - int n1=ci->blocksizes[1]/2; - - int thisCenter; - int prevCenter; - - if(v->centerW){ - thisCenter=n1; - prevCenter=0; - }else{ - thisCenter=0; - prevCenter=n1; - } - - /* v->pcm is now used like a two-stage double buffer. We don't want - to have to constantly shift *or* adjust memory usage. Don't - accept a new block until the old is shifted out */ - - /* overlap/add PCM */ - - for(j=0;jchannels;j++){ - /* the overlap/add section */ - if(v->lW){ - if(v->W){ - /* large/large */ - ogg_int32_t *pcm=v->pcm[j]+prevCenter; - ogg_int32_t *p=vb->pcm[j]; - for(i=0;ipcm[j]+prevCenter+n1/2-n0/2; - ogg_int32_t *p=vb->pcm[j]; - for(i=0;iW){ - /* small/large */ - ogg_int32_t *pcm=v->pcm[j]+prevCenter; - ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; - for(i=0;ipcm[j]+prevCenter; - ogg_int32_t *p=vb->pcm[j]; - for(i=0;ipcm[j]+thisCenter; - ogg_int32_t *p=vb->pcm[j]+n; - for(i=0;icenterW) - v->centerW=0; - else - v->centerW=n1; - - /* deal with initial packet state; we do this using the explicit - pcm_returned==-1 flag otherwise we're sensitive to first block - being short or long */ - - if(v->pcm_returned==-1){ - v->pcm_returned=thisCenter; - v->pcm_current=thisCenter; - }else{ - v->pcm_returned=prevCenter; - v->pcm_current=prevCenter+ - ci->blocksizes[v->lW]/4+ - ci->blocksizes[v->W]/4; - } - - } - - /* track the frame number... This is for convenience, but also - making sure our last packet doesn't end with added padding. If - the last packet is partial, the number of samples we'll have to - return will be past the vb->granulepos. - - This is not foolproof! It will be confused if we begin - decoding at the last page after a seek or hole. In that case, - we don't have a starting point to judge where the last frame - is. For this reason, vorbisfile will always try to make sure - it reads the last two marked pages in proper sequence */ - - if(b->sample_count==-1){ - b->sample_count=0; - }else{ - b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; - } - - if(v->granulepos==-1){ - if(vb->granulepos!=-1){ /* only set if we have a position to set to */ - - v->granulepos=vb->granulepos; - - /* is this a short page? */ - if(b->sample_count>v->granulepos){ - /* corner case; if this is both the first and last audio page, - then spec says the end is cut, not beginning */ - if(vb->eofflag){ - /* trim the end */ - /* no preceeding granulepos; assume we started at zero (we'd - have to in a short single-page stream) */ - /* granulepos could be -1 due to a seek, but that would result - in a long coun`t, not short count */ - - v->pcm_current-=(b->sample_count-v->granulepos); - }else{ - /* trim the beginning */ - v->pcm_returned+=(b->sample_count-v->granulepos); - if(v->pcm_returned>v->pcm_current) - v->pcm_returned=v->pcm_current; - } - - } - - } - }else{ - v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; - if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ - - if(v->granulepos>vb->granulepos){ - long extra=v->granulepos-vb->granulepos; - - if(extra) - if(vb->eofflag){ - /* partial last frame. Strip the extra samples off */ - v->pcm_current-=extra; - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - } /* else {Shouldn't happen *unless* the bitstream is out of - spec. Either way, believe the bitstream } */ - v->granulepos=vb->granulepos; - } - } - - /* Update, cleanup */ - - if(vb->eofflag)v->eofflag=1; - return(0); -} - -/* pcm==NULL indicates we just want the pending samples, no more */ -int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ - vorbis_info *vi=v->vi; - if(v->pcm_returned>-1 && v->pcm_returnedpcm_current){ - if(pcm){ - int i; - for(i=0;ichannels;i++) - v->pcmret[i]=v->pcm[i]+v->pcm_returned; - *pcm=v->pcmret; - } - return(v->pcm_current-v->pcm_returned); - } - return(0); -} - -int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){ - if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL); - v->pcm_returned+=bytes; - return(0); -} - diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/block.h --- a/misc/libtremor/tremor/block.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2008 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: shared block functions - - ********************************************************************/ - -#ifndef _V_BLOCK_ -#define _V_BLOCK_ - -#include "ivorbiscodec.h" - -extern void _vorbis_block_ripcord(vorbis_block *vb); -extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); - -#endif diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/codebook.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/codebook.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/codec_internal.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/config_types.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/configure.in diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/floor0.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/floor1.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/framing.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/info.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/ivorbiscodec.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/ivorbisfile.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/lsp_lookup.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/mapping0.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/mdct.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/mdct.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/misc.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/os.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/os_types.h diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/registry.c --- a/misc/libtremor/tremor/registry.c Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: registry for floor, res backends and channel mappings - - ********************************************************************/ - -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "misc.h" - - -/* seems like major overkill now; the backend numbers will grow into - the infrastructure soon enough */ - -extern vorbis_func_floor floor0_exportbundle; -extern vorbis_func_floor floor1_exportbundle; -extern vorbis_func_residue residue0_exportbundle; -extern vorbis_func_residue residue1_exportbundle; -extern vorbis_func_residue residue2_exportbundle; -extern vorbis_func_mapping mapping0_exportbundle; - -vorbis_func_floor *_floor_P[]={ - &floor0_exportbundle, - &floor1_exportbundle, -}; - -vorbis_func_residue *_residue_P[]={ - &residue0_exportbundle, - &residue1_exportbundle, - &residue2_exportbundle, -}; - -vorbis_func_mapping *_mapping_P[]={ - &mapping0_exportbundle, -}; - - - diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/registry.h --- a/misc/libtremor/tremor/registry.h Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: registry for time, floor, res backends and channel mappings - - ********************************************************************/ - -#ifndef _V_REG_H_ -#define _V_REG_H_ - -#define VI_TRANSFORMB 1 -#define VI_WINDOWB 1 -#define VI_TIMEB 1 -#define VI_FLOORB 2 -#define VI_RESB 3 -#define VI_MAPB 1 - -#include "backends.h" - -#if defined(_WIN32) && defined(VORBISDLL_IMPORT) -# define EXTERN __declspec(dllimport) extern -#else -# define EXTERN extern -#endif - -EXTERN vorbis_func_floor *_floor_P[]; -EXTERN vorbis_func_residue *_residue_P[]; -EXTERN vorbis_func_mapping *_mapping_P[]; - -#endif diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/res012.c diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/sharedbook.c --- a/misc/libtremor/tremor/sharedbook.c Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,439 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: basic shared codebook operations - - ********************************************************************/ - -#include -#include -#include -#include "ogg.h" -#include "misc.h" -#include "ivorbiscodec.h" -#include "codebook.h" - -/**** pack/unpack helpers ******************************************/ -int _ilog(unsigned int v){ - int ret=0; - while(v){ - ret++; - v>>=1; - } - return(ret); -} - -/* 32 bit float (not IEEE; nonnormalized mantissa + - biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm - Why not IEEE? It's just not that important here. */ - -#define VQ_FEXP 10 -#define VQ_FMAN 21 -#define VQ_FEXP_BIAS 768 /* bias toward values smaller than 1. */ - -static ogg_int32_t _float32_unpack(long val,int *point){ - long mant=val&0x1fffff; - int sign=val&0x80000000; - long exp =(val&0x7fe00000L)>>VQ_FMAN; - - exp-=(VQ_FMAN-1)+VQ_FEXP_BIAS; - - if(mant){ - while(!(mant&0x40000000)){ - mant<<=1; - exp-=1; - } - - if(sign)mant= -mant; - }else{ - sign=0; - exp=-9999; - } - - *point=exp; - return mant; -} - -/* given a list of word lengths, generate a list of codewords. Works - for length ordered or unordered, always assigns the lowest valued - codewords first. Extended to handle unused entries (length 0) */ -ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ - long i,j,count=0; - ogg_uint32_t marker[33]; - ogg_uint32_t *r=(ogg_uint32_t *)_ogg_malloc((sparsecount?sparsecount:n)*sizeof(*r)); - memset(marker,0,sizeof(marker)); - - for(i=0;i0){ - ogg_uint32_t entry=marker[length]; - - /* when we claim a node for an entry, we also claim the nodes - below it (pruning off the imagined tree that may have dangled - from it) as well as blocking the use of any nodes directly - above for leaves */ - - /* update ourself */ - if(length<32 && (entry>>length)){ - /* error condition; the lengths must specify an overpopulated tree */ - _ogg_free(r); - return(NULL); - } - r[count++]=entry; - - /* Look to see if the next shorter marker points to the node - above. if so, update it and repeat. */ - { - for(j=length;j>0;j--){ - - if(marker[j]&1){ - /* have to jump branches */ - if(j==1) - marker[1]++; - else - marker[j]=marker[j-1]<<1; - break; /* invariant says next upper marker would already - have been moved if it was on the same path */ - } - marker[j]++; - } - } - - /* prune the tree; the implicit invariant says all the longer - markers were dangling from our just-taken node. Dangle them - from our *new* node. */ - for(j=length+1;j<33;j++) - if((marker[j]>>1) == entry){ - entry=marker[j]; - marker[j]=marker[j-1]<<1; - }else - break; - }else - if(sparsecount==0)count++; - } - - /* bitreverse the words because our bitwise packer/unpacker is LSb - endian */ - for(i=0,count=0;i>j)&1; - } - - if(sparsecount){ - if(l[i]) - r[count++]=temp; - }else - r[count++]=temp; - } - - return(r); -} - -/* there might be a straightforward one-line way to do the below - that's portable and totally safe against roundoff, but I haven't - thought of it. Therefore, we opt on the side of caution */ -long _book_maptype1_quantvals(const static_codebook *b){ - /* get us a starting hint, we'll polish it below */ - int bits=_ilog(b->entries); - int vals=b->entries>>((bits-1)*(b->dim-1)/b->dim); - - while(1){ - long acc=1; - long acc1=1; - int i; - for(i=0;idim;i++){ - acc*=vals; - acc1*=vals+1; - } - if(acc<=b->entries && acc1>b->entries){ - return(vals); - }else{ - if(acc>b->entries){ - vals--; - }else{ - vals++; - } - } - } -} - -/* different than what _book_unquantize does for mainline: - we repack the book in a fixed point format that shares the same - binary point. Upon first use, we can shift point if needed */ - -/* we need to deal with two map types: in map type 1, the values are - generated algorithmically (each column of the vector counts through - the values in the quant vector). in map type 2, all the values came - in in an explicit list. Both value lists must be unpacked */ - -ogg_int32_t *_book_unquantize(const static_codebook *b,int n,int *sparsemap, - int *maxpoint){ - long j,k,count=0; - if(b->maptype==1 || b->maptype==2){ - int quantvals; - int minpoint,delpoint; - ogg_int32_t mindel=_float32_unpack(b->q_min,&minpoint); - ogg_int32_t delta=_float32_unpack(b->q_delta,&delpoint); - ogg_int32_t *r=(ogg_int32_t *)_ogg_calloc(n*b->dim,sizeof(*r)); - int *rp=(int *)_ogg_calloc(n*b->dim,sizeof(*rp)); - - *maxpoint=minpoint; - - /* maptype 1 and 2 both use a quantized value vector, but - different sizes */ - switch(b->maptype){ - case 1: - /* most of the time, entries%dimensions == 0, but we need to be - well defined. We define that the possible vales at each - scalar is values == entries/dim. If entries%dim != 0, we'll - have 'too few' values (values*dimentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - ogg_int32_t last=0; - int lastpoint=0; - int indexdiv=1; - for(k=0;kdim;k++){ - int index= (j/indexdiv)%quantvals; - int point=0; - int val=VFLOAT_MULTI(delta,delpoint, - abs(b->quantlist[index]),&point); - - val=VFLOAT_ADD(mindel,minpoint,val,point,&point); - val=VFLOAT_ADD(last,lastpoint,val,point,&point); - - if(b->q_sequencep){ - last=val; - lastpoint=point; - } - - if(sparsemap){ - r[sparsemap[count]*b->dim+k]=val; - rp[sparsemap[count]*b->dim+k]=point; - }else{ - r[count*b->dim+k]=val; - rp[count*b->dim+k]=point; - } - if(*maxpointentries;j++){ - if((sparsemap && b->lengthlist[j]) || !sparsemap){ - ogg_int32_t last=0; - int lastpoint=0; - - for(k=0;kdim;k++){ - int point=0; - int val=VFLOAT_MULTI(delta,delpoint, - abs(b->quantlist[j*b->dim+k]),&point); - - val=VFLOAT_ADD(mindel,minpoint,val,point,&point); - val=VFLOAT_ADD(last,lastpoint,val,point,&point); - - if(b->q_sequencep){ - last=val; - lastpoint=point; - } - - if(sparsemap){ - r[sparsemap[count]*b->dim+k]=val; - rp[sparsemap[count]*b->dim+k]=point; - }else{ - r[count*b->dim+k]=val; - rp[count*b->dim+k]=point; - } - if(*maxpointdim;j++) - if(rp[j]<*maxpoint) - r[j]>>=*maxpoint-rp[j]; - - _ogg_free(rp); - return(r); - } - return(NULL); -} - -void vorbis_staticbook_clear(static_codebook *b){ - if(b->quantlist)_ogg_free(b->quantlist); - if(b->lengthlist)_ogg_free(b->lengthlist); - memset(b,0,sizeof(*b)); - -} - -void vorbis_staticbook_destroy(static_codebook *b){ - vorbis_staticbook_clear(b); - _ogg_free(b); -} - -void vorbis_book_clear(codebook *b){ - /* static book is not cleared; we're likely called on the lookup and - the static codebook belongs to the info struct */ - if(b->valuelist)_ogg_free(b->valuelist); - if(b->codelist)_ogg_free(b->codelist); - - if(b->dec_index)_ogg_free(b->dec_index); - if(b->dec_codelengths)_ogg_free(b->dec_codelengths); - if(b->dec_firsttable)_ogg_free(b->dec_firsttable); - - memset(b,0,sizeof(*b)); -} - -static ogg_uint32_t bitreverse(ogg_uint32_t x){ - x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); - x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); - x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); - x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); - return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); -} - -static int sort32a(const void *a,const void *b){ - return (**(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- - (**(ogg_uint32_t **)a<**(ogg_uint32_t **)b); -} - -/* decode codebook arrangement is more heavily optimized than encode */ -int vorbis_book_init_decode(codebook *c,const static_codebook *s){ - int i,j,n=0,tabn; - int *sortindex; - memset(c,0,sizeof(*c)); - - /* count actually used entries */ - for(i=0;ientries;i++) - if(s->lengthlist[i]>0) - n++; - - c->entries=s->entries; - c->used_entries=n; - c->dim=s->dim; - - if(n>0){ - /* two different remappings go on here. - - First, we collapse the likely sparse codebook down only to - actually represented values/words. This collapsing needs to be - indexed as map-valueless books are used to encode original entry - positions as integers. - - Second, we reorder all vectors, including the entry index above, - by sorted bitreversed codeword to allow treeless decode. */ - - /* perform sort */ - ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); - ogg_uint32_t **codep=(ogg_uint32_t **)alloca(sizeof(*codep)*n); - - if(codes==NULL)goto err_out; - - for(i=0;icodelist=(ogg_uint32_t *)_ogg_malloc(n*sizeof(*c->codelist)); - /* the index is a reverse index */ - for(i=0;icodelist[sortindex[i]]=codes[i]; - _ogg_free(codes); - - - - c->valuelist=_book_unquantize(s,n,sortindex,&c->binarypoint); - c->dec_index=(int *)_ogg_malloc(n*sizeof(*c->dec_index)); - - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0) - c->dec_index[sortindex[n++]]=i; - - c->dec_codelengths=(char *)_ogg_malloc(n*sizeof(*c->dec_codelengths)); - for(n=0,i=0;ientries;i++) - if(s->lengthlist[i]>0) - c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; - - c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ - if(c->dec_firsttablen<5)c->dec_firsttablen=5; - if(c->dec_firsttablen>8)c->dec_firsttablen=8; - - tabn=1<dec_firsttablen; - c->dec_firsttable=(ogg_uint32_t *)_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); - c->dec_maxlength=0; - - for(i=0;idec_maxlengthdec_codelengths[i]) - c->dec_maxlength=c->dec_codelengths[i]; - if(c->dec_codelengths[i]<=c->dec_firsttablen){ - ogg_uint32_t orig=bitreverse(c->codelist[i]); - for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) - c->dec_firsttable[orig|(j<dec_codelengths[i])]=i+1; - } - } - - /* now fill in 'unused' entries in the firsttable with hi/lo search - hints for the non-direct-hits */ - { - ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); - long lo=0,hi=0; - - for(i=0;idec_firsttablen); - if(c->dec_firsttable[bitreverse(word)]==0){ - while((lo+1)codelist[lo+1]<=word)lo++; - while( hi=(c->codelist[hi]&mask))hi++; - - /* we only actually have 15 bits per hint to play with here. - In order to overflow gracefully (nothing breaks, efficiency - just drops), encode as the difference from the extremes. */ - { - unsigned long loval=lo; - unsigned long hival=n-hi; - - if(loval>0x7fff)loval=0x7fff; - if(hival>0x7fff)hival=0x7fff; - c->dec_firsttable[bitreverse(word)]= - 0x80000000UL | (loval<<15) | hival; - } - } - } - } - } - - return(0); - err_out: - vorbis_book_clear(c); - return(-1); -} - diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/synthesis.c --- a/misc/libtremor/tremor/synthesis.c Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: single-block PCM synthesis - last mod: $Id: synthesis.c,v 1.4 2003/03/29 03:07:21 xiphmont Exp $ - - ********************************************************************/ - -#include -#include "ogg.h" -#include "ivorbiscodec.h" -#include "codec_internal.h" -#include "registry.h" -#include "misc.h" -#include "block.h" - -int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){ - vorbis_dsp_state *vd=vb->vd; - private_state *b=(private_state *)vd->backend_state; - vorbis_info *vi=vd->vi; - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - oggpack_buffer *opb=&vb->opb; - int type,mode,i; - - /* first things first. Make sure decode is ready */ - _vorbis_block_ripcord(vb); - oggpack_readinit(opb,op->packet); - - /* Check the packet type */ - if(oggpack_read(opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(opb,b->modebits); - if(mode==-1)return(OV_EBADPACKET); - - vb->mode=mode; - vb->W=ci->mode_param[mode]->blockflag; - if(vb->W){ - vb->lW=oggpack_read(opb,1); - vb->nW=oggpack_read(opb,1); - if(vb->nW==-1) return(OV_EBADPACKET); - }else{ - vb->lW=0; - vb->nW=0; - } - - /* more setup */ - vb->granulepos=op->granulepos; - vb->sequence=op->packetno-3; /* first block is third packet */ - vb->eofflag=op->e_o_s; - - if(decodep){ - /* alloc pcm passback storage */ - vb->pcmend=ci->blocksizes[vb->W]; - vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); - for(i=0;ichannels;i++) - vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); - - /* unpack_header enforces range checking */ - type=ci->map_type[ci->mode_param[mode]->mapping]; - - return(_mapping_P[type]->inverse(vb,b->mode[mode])); - }else{ - /* no pcm */ - vb->pcmend=0; - vb->pcm=NULL; - - return(0); - } -} - -long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ - codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; - oggpack_buffer opb; - int mode; - - oggpack_readinit(&opb,op->packet); - - /* Check the packet type */ - if(oggpack_read(&opb,1)!=0){ - /* Oops. This is not an audio data packet */ - return(OV_ENOTAUDIO); - } - - { - int modebits=0; - int v=ci->modes; - while(v>1){ - modebits++; - v>>=1; - } - - /* read our mode and pre/post windowsize */ - mode=oggpack_read(&opb,modebits); - } - if(mode==-1)return(OV_EBADPACKET); - return(ci->blocksizes[ci->mode_param[mode]->blockflag]); -} - - diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/vorbisfile.c --- a/misc/libtremor/tremor/vorbisfile.c Thu Nov 24 13:44:30 2011 +0100 +++ b/misc/libtremor/tremor/vorbisfile.c Sun Oct 28 13:28:23 2012 +0100 @@ -739,7 +739,8 @@ if(vf->offsets)_ogg_free(vf->offsets); ogg_sync_destroy(vf->oy); - if(vf->datasource)(vf->callbacks.close_func)(vf->datasource); + if(vf->datasource && vf->callbacks.close_func) + (vf->callbacks.close_func)(vf->datasource); memset(vf,0,sizeof(*vf)); } #ifdef DEBUG_LEAKS diff -r 41b0a9955c47 -r ddcdedd3330b misc/libtremor/tremor/window.c --- a/misc/libtremor/tremor/window.c Thu Nov 24 13:44:30 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * - * * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * - * * - ******************************************************************** - - function: window functions - - ********************************************************************/ - -#include -#include -#include "misc.h" -#include "window.h" -#include "window_lookup.h" - -const void *_vorbis_window(int type, int left){ - - switch(type){ - case 0: - - switch(left){ - case 32: - return vwin64; - case 64: - return vwin128; - case 128: - return vwin256; - case 256: - return vwin512; - case 512: - return vwin1024; - case 1024: - return vwin2048; - case 2048: - return vwin4096; - case 4096: - return vwin8192; - default: - return(0); - } - break; - default: - return(0); - } -} - -void _vorbis_apply_window(ogg_int32_t *d,const void *window_p[2], - long *blocksizes, - int lW,int W,int nW){ - - LOOKUP_T *window[2]={window_p[0],window_p[1]}; - long n=blocksizes[W]; - long ln=blocksizes[lW]; - long rn=blocksizes[nW]; - - long leftbegin=n/4-ln/4; - long leftend=leftbegin+ln/2; - - long rightbegin=n/2+n/4-rn/4; - long rightend=rightbegin+rn/2; - - int i,p; - - for(i=0;i loc.txt +# Update locale files - run in Locale +for i in *.lua;do cat ../loc.txt | while read f;do STR=$(echo "$f" | sed 's/loc("//;s/")\s*$//;s/"/\\"/g');MAPS=$(grep -F -l -- "loc(\"${STR}\")" ../*/*/*.lua ../*/*/*/*.lua | sed 's/.*\/\([^\/]*\)\/map.lua/\1/;s/.*Campaign\/\([^\/]*\)\//\1:/;s/.*\///;s/.lua//;s/ /_/g' | xargs | sed 's/ /, /g');C=$(echo $MAPS | sed 's/,/\n/' | wc -l);grep -Fq -- "[\"${STR}\"]" $i;if(($?));then if((C>0));then echo "-- [\"${STR}\"] = \"\", -- $MAPS" >> $i;else echo "-- [\"${STR}\"] = \"\"," >> $i;fi;fi;done;done +# sort - run in Locale +for i in *.lua;do rm temphead temptail templua;cat $i | grep -Ev "}|{" | grep -Ev "^[[:space:]]*$" | sort > templua;echo "locale = {" > temphead;echo " }" > temptail;cat temphead templua temptail > $i;done +# drop unused - run in Locale +cat stub.lua | grep '"] =' | while read f;do PHRASE=$(echo "$f" | sed 's/[^[]*\["//;s/"] =.*//;s/"/\\"/g');CNT=$(grep -Frc "loc(\"$PHRASE\")" ../*/*/*.lua ../*/*/*/*.lua | grep -v ":0" | wc -l);if(($CNT==0));then echo "|$PHRASE|";sed -i "s/.*\[\"$PHRASE\"].*//" *.lua;fi;done diff -r 41b0a9955c47 -r ddcdedd3330b misc/quazip/CMakeLists.txt --- a/misc/quazip/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/misc/quazip/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -1,7 +1,9 @@ set(QT_USE_QTCORE TRUE) find_package(Qt4 REQUIRED) -include(${QT_USE_FILE}) +if(NOT CROSSAPPLE) + include(${QT_USE_FILE}) +endif() file(GLOB SRCS "*.c" "*.cpp") diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/Hedgewars.lnk Binary file misc/winutils/Hedgewars.lnk has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,101 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL.h + * Main include header for the SDL library + */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_audio.h" +#include "SDL_cdrom.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_loadso.h" +#include "SDL_mutex.h" +#include "SDL_rwops.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL.h + * @note As of version 0.5, SDL is loaded dynamically into the application + */ + +/** @name SDL_INIT Flags + * These are the flags which may be passed to SDL_Init() -- you should + * specify the subsystems which you will be using in your application. + */ +/*@{*/ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 +#define SDL_INIT_CDROM 0x00000100 +#define SDL_INIT_JOYSTICK 0x00000200 +#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ +#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ +#define SDL_INIT_EVERYTHING 0x0000FFFF +/*@}*/ + +/** This function loads the SDL dynamically linked library and initializes + * the subsystems specified by 'flags' (and those satisfying dependencies) + * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV) + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** This function initializes specific SDL subsystems */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** This function cleans up specific SDL subsystems */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** This function returns mask of the specified subsystems which have + * been initialized. + * If 'flags' is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** This function cleans up all initialized subsystems and unloads the + * dynamically linked library. You should call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_active.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_active.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,63 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_active.h + * Include file for SDL application focus event handling + */ + +#ifndef _SDL_active_h +#define _SDL_active_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name The available application states */ +/*@{*/ +#define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ +#define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ +#define SDL_APPACTIVE 0x04 /**< The application is active */ +/*@}*/ + +/* Function prototypes */ +/** + * This function returns the current state of the application, which is a + * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and + * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to + * see your application, otherwise it has been iconified or disabled. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_active_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_audio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_audio.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,284 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_audio.h + * Access to the raw audio mixing buffer for the SDL library + */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * When filling in the desired audio spec structure, + * - 'desired->freq' should be the desired audio frequency in samples-per-second. + * - 'desired->format' should be the desired audio format. + * - 'desired->samples' is the desired size of the audio buffer, in samples. + * This number should be a power of two, and may be adjusted by the audio + * driver to a value more suitable for the hardware. Good values seem to + * range between 512 and 8096 inclusive, depending on the application and + * CPU speed. Smaller values yield faster response time, but can lead + * to underflow if the application is doing heavy processing and cannot + * fill the audio buffer in time. A stereo sample consists of both right + * and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: ms = (samples*1000)/freq + * - 'desired->size' is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - 'desired->silence' is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - 'desired->callback' should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * - 'desired->userdata' is passed as the first parameter to your callback + * function. + * + * @note The calculated values in this structure are calculated by SDL_OpenAudio() + * + */ +typedef struct SDL_AudioSpec { + int freq; /**< DSP frequency -- samples per second */ + Uint16 format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in samples (power of 2) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + /** + * This function is called when the audio device needs more data. + * + * @param[out] stream A pointer to the audio data buffer + * @param[in] len The length of the audio buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + */ + void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len); + void *userdata; +} SDL_AudioSpec; + +/** + * @name Audio format flags + * defaults to LSB byte order + */ +/*@{*/ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB + +/** + * @name Native audio byte ordering + */ +/*@{*/ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#endif +/*@}*/ + +/*@}*/ + + +/** A structure to hold a set of audio conversion filters and buffers */ +typedef struct SDL_AudioCVT { + int needed; /**< Set to 1 if conversion possible */ + Uint16 src_format; /**< Source audio format */ + Uint16 dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); + int filter_index; /**< Current audio conversion function */ +} SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * @name Audio Init and Quit + * These functions are used internally, and should not be used unless you + * have a specific need to specify the audio driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/*@{*/ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/*@}*/ + +/** + * This function fills the given character buffer with the name of the + * current audio driver, and returns a pointer to it if the audio driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + * + * @sa SDL_AudioSpec + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); + +typedef enum { + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_audiostatus; + +/** Get the current audio state */ +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); + +/** + * This function pauses and unpauses the audio callback processing. + * It should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); + +/** + * This function loads a WAVE from the data source, automatically freeing + * that source if 'freesrc' is non-zero. For example, to load a WAVE file, + * you could do: + * @code SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); @endcode + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * 'audio_buf' to a malloc()'d buffer containing the audio data, + * and sets 'audio_len' to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/** Compatibility convenience function -- loads a WAV from a file */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the 'cvt' structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * + * @return This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, + Uint16 src_format, Uint8 src_channels, int src_rate, + Uint16 dst_format, Uint8 dst_channels, int dst_rate); + +/** + * Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), + * created an audio buffer cvt->buf, and filled it with cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * The data conversion may expand the size of the audio data, so the buffer + * cvt->buf should be allocated after the cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); + + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); + +/** + * @name Audio Locks + * The lock manipulated by these functions protects the callback function. + * During a LockAudio/UnlockAudio pair, you can be guaranteed that the + * callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +/*@}*/ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_byteorder.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_byteorder.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,29 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_byteorder.h + * @deprecated Use SDL_endian.h instead + */ + +/* DEPRECATED */ +#include "SDL_endian.h" diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_cdrom.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_cdrom.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,202 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_cdrom.h + * This is the CD-audio control API for Simple DirectMedia Layer + */ + +#ifndef _SDL_cdrom_h +#define _SDL_cdrom_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file SDL_cdrom.h + * In order to use these functions, SDL_Init() must have been called + * with the SDL_INIT_CDROM flag. This causes SDL to scan the system + * for CD-ROM drives, and load appropriate drivers. + */ + +/** The maximum number of CD-ROM tracks on a disk */ +#define SDL_MAX_TRACKS 99 + +/** @name Track Types + * The types of CD-ROM track possible + */ +/*@{*/ +#define SDL_AUDIO_TRACK 0x00 +#define SDL_DATA_TRACK 0x04 +/*@}*/ + +/** The possible states which a CD-ROM drive can be in. */ +typedef enum { + CD_TRAYEMPTY, + CD_STOPPED, + CD_PLAYING, + CD_PAUSED, + CD_ERROR = -1 +} CDstatus; + +/** Given a status, returns true if there's a disk in the drive */ +#define CD_INDRIVE(status) ((int)(status) > 0) + +typedef struct SDL_CDtrack { + Uint8 id; /**< Track number */ + Uint8 type; /**< Data or audio track */ + Uint16 unused; + Uint32 length; /**< Length, in frames, of this track */ + Uint32 offset; /**< Offset, in frames, from start of disk */ +} SDL_CDtrack; + +/** This structure is only current as of the last call to SDL_CDStatus() */ +typedef struct SDL_CD { + int id; /**< Private drive identifier */ + CDstatus status; /**< Current drive status */ + + /** The rest of this structure is only valid if there's a CD in drive */ + /*@{*/ + int numtracks; /**< Number of tracks on disk */ + int cur_track; /**< Current track position */ + int cur_frame; /**< Current frame offset within current track */ + SDL_CDtrack track[SDL_MAX_TRACKS+1]; + /*@}*/ +} SDL_CD; + +/** @name Frames / MSF Conversion Functions + * Conversion functions from frames to Minute/Second/Frames and vice versa + */ +/*@{*/ +#define CD_FPS 75 +#define FRAMES_TO_MSF(f, M,S,F) { \ + int value = f; \ + *(F) = value%CD_FPS; \ + value /= CD_FPS; \ + *(S) = value%60; \ + value /= 60; \ + *(M) = value; \ +} +#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) +/*@}*/ + +/* CD-audio API functions: */ + +/** + * Returns the number of CD-ROM drives on the system, or -1 if + * SDL_Init() has not been called with the SDL_INIT_CDROM flag. + */ +extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); + +/** + * Returns a human-readable, system-dependent identifier for the CD-ROM. + * Example: + * - "/dev/cdrom" + * - "E:" + * - "/dev/disk/ide/1/master" + */ +extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); + +/** + * Opens a CD-ROM drive for access. It returns a drive handle on success, + * or NULL if the drive was invalid or busy. This newly opened CD-ROM + * becomes the default CD used when other CD functions are passed a NULL + * CD-ROM handle. + * Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. + */ +extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); + +/** + * This function returns the current status of the given drive. + * If the drive has a CD in it, the table of contents of the CD and current + * play position of the CD will be stored in the SDL_CD structure. + */ +extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); + +/** + * Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' + * tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play + * until the end of the CD. This function will skip data tracks. + * This function should only be called after calling SDL_CDStatus() to + * get track information about the CD. + * For example: + * @code + * // Play entire CD: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + * SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); + * // Play last track: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { + * SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); + * } + * // Play first and second track and 10 seconds of third track: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + * SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); + * @endcode + * + * @return This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, + int start_track, int start_frame, int ntracks, int nframes); + +/** + * Play the given CD starting at 'start' frame for 'length' frames. + * @return It returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); + +/** Pause play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); + +/** Resume play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); + +/** Stop play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); + +/** Eject CD-ROM + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); + +/** Closes the handle for the CD-ROM drive */ +extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_config.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,45 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +#include "SDL_platform.h" + +/* Add any platform that doesn't build using the configure system */ +#if defined(__DREAMCAST__) +#include "SDL_config_dreamcast.h" +#elif defined(__MACOS__) +#include "SDL_config_macos.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__SYMBIAN32__) +#include "SDL_config_symbian.h" /* must be before win32! */ +#elif defined(__WIN32__) +#include "SDL_config_win32.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" +#else +#include "SDL_config_minimal.h" +#endif /* platform config */ + +#endif /* _SDL_config_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_config_win32.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_config_win32.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,183 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_win32_h +#define _SDL_config_win32_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if defined(__GNUC__) || defined(__DMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Enabled for SDL 1.2 (binary compatibility) */ +#define HAVE_LIBC 1 +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#ifndef _WIN32_WCE +#define HAVE_SIGNAL_H 1 +#endif + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#ifndef _WIN32_WCE +#define SDL_AUDIO_DRIVER_DSOUND 1 +#endif +#define SDL_AUDIO_DRIVER_WAVEOUT 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#ifdef _WIN32_WCE +#define SDL_CDROM_DISABLED 1 +#else +#define SDL_CDROM_WIN32 1 +#endif + +/* Enable various input drivers */ +#ifdef _WIN32_WCE +#define SDL_JOYSTICK_DISABLED 1 +#else +#define SDL_JOYSTICK_WINMM 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WIN32 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WIN32 1 + +/* Enable various timer systems */ +#ifdef _WIN32_WCE +#define SDL_TIMER_WINCE 1 +#else +#define SDL_TIMER_WIN32 1 +#endif + +/* Enable various video drivers */ +#ifdef _WIN32_WCE +#define SDL_VIDEO_DRIVER_GAPI 1 +#endif +#ifndef _WIN32_WCE +#define SDL_VIDEO_DRIVER_DDRAW 1 +#endif +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDIB 1 + +/* Enable OpenGL support */ +#ifndef _WIN32_WCE +#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL_WGL 1 +#endif + +/* Disable screensaver */ +#define SDL_VIDEO_DISABLE_SCREENSAVER 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_win32_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_copying.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_copying.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,22 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_cpuinfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_cpuinfo.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,69 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_cpuinfo.h + * CPU feature detection for SDL + */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This function returns true if the CPU has the RDTSC instruction */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** This function returns true if the CPU has MMX features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** This function returns true if the CPU has MMX Ext. features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); + +/** This function returns true if the CPU has 3DNow features */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** This function returns true if the CPU has 3DNow! Ext. features */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); + +/** This function returns true if the CPU has SSE features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** This function returns true if the CPU has SSE2 features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** This function returns true if the CPU has AltiVec features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_endian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_endian.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,214 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_endian.h + * Functions for reading and writing endian-specific values + */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/** @name SDL_ENDIANs + * The two types of endianness + */ +/*@{*/ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/*@}*/ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#else /* __linux __ */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux __ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name SDL_Swap Functions + * Use inline functions for compilers that support them, and static + * functions for those that do not. Because these functions become + * static for compilers that do not support inline functions, this + * header should only be included in files that actually use them. + */ +/*@{*/ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + Uint16 result; + + __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); + return result; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint16 SDL_Swap16(Uint16 x) { + return SDL_static_cast(Uint16, ((x<<8)|(x>>8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); + __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); + __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); + return result; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint32 SDL_Swap32(Uint32 x) { + return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24))); +} +#endif + +#ifdef SDL_HAS_64BIT_TYPE +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + union { + struct { Uint32 a,b; } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} +#else +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif +#else +/* This is mainly to keep compilers from complaining in SDL code. + * If there is no real 64-bit datatype, then compilers will complain about + * the fake 64-bit datatype that SDL provides when it compiles user code. + */ +#define SDL_Swap64(X) (X) +#endif /* SDL_HAS_64BIT_TYPE */ +/*@}*/ + +/** + * @name SDL_SwapLE and SDL_SwapBE Functions + * Byteswap item from the specified endianness to the native endianness + */ +/*@{*/ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#endif +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_error.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_error.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,72 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_error.h + * Simple error message routines for SDL + */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Public functions + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC char * SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); +/*@}*/ + +/** + * @name Private functions + * @internal Private error message function - used internally + */ +/*@{*/ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +typedef enum { + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_events.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_events.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,356 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_events.h + * Include file for SDL event handling + */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_active.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_quit.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name General keyboard/mouse state definitions */ +/*@{*/ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 +/*@}*/ + +/** Event enumerations */ +typedef enum { + SDL_NOEVENT = 0, /**< Unused (do not remove) */ + SDL_ACTIVEEVENT, /**< Application loses/gains visibility */ + SDL_KEYDOWN, /**< Keys pressed */ + SDL_KEYUP, /**< Keys released */ + SDL_MOUSEMOTION, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_JOYAXISMOTION, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_QUIT, /**< User-requested quit */ + SDL_SYSWMEVENT, /**< System specific event */ + SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */ + SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */ + SDL_VIDEORESIZE, /**< User resized video mode */ + SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */ + SDL_EVENT_RESERVED2, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED3, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED4, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED5, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED6, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED7, /**< Reserved for future use.. */ + /** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ + SDL_USEREVENT = 24, + /** This last event is only for bounding internal arrays + * It is the number of bits in the event mask datatype -- Uint32 + */ + SDL_NUMEVENTS = 32 +} SDL_EventType; + +/** @name Predefined event masks */ +/*@{*/ +#define SDL_EVENTMASK(X) (1<<(X)) +typedef enum { + SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), + SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), + SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), + SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| + SDL_EVENTMASK(SDL_KEYUP), + SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), + SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), + SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| + SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| + SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), + SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), + SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), + SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), + SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| + SDL_EVENTMASK(SDL_JOYBALLMOTION)| + SDL_EVENTMASK(SDL_JOYHATMOTION)| + SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| + SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), + SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), + SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) +} SDL_EventMask ; +#define SDL_ALLEVENTS 0xFFFFFFFF +/*@}*/ + +/** Application visibility event structure */ +typedef struct SDL_ActiveEvent { + Uint8 type; /**< SDL_ACTIVEEVENT */ + Uint8 gain; /**< Whether given states were gained or lost (1/0) */ + Uint8 state; /**< A mask of the focus states */ +} SDL_ActiveEvent; + +/** Keyboard event structure */ +typedef struct SDL_KeyboardEvent { + Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ + Uint8 which; /**< The keyboard device index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ + SDL_keysym keysym; +} SDL_KeyboardEvent; + +/** Mouse motion event structure */ +typedef struct SDL_MouseMotionEvent { + Uint8 type; /**< SDL_MOUSEMOTION */ + Uint8 which; /**< The mouse device index */ + Uint8 state; /**< The current button state */ + Uint16 x, y; /**< The X/Y coordinates of the mouse */ + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** Mouse button event structure */ +typedef struct SDL_MouseButtonEvent { + Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ + Uint8 which; /**< The mouse device index */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ + Uint16 x, y; /**< The X/Y coordinates of the mouse at press time */ +} SDL_MouseButtonEvent; + +/** Joystick axis motion event structure */ +typedef struct SDL_JoyAxisEvent { + Uint8 type; /**< SDL_JOYAXISMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 axis; /**< The joystick axis index */ + Sint16 value; /**< The axis value (range: -32768 to 32767) */ +} SDL_JoyAxisEvent; + +/** Joystick trackball motion event structure */ +typedef struct SDL_JoyBallEvent { + Uint8 type; /**< SDL_JOYBALLMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 ball; /**< The joystick trackball index */ + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** Joystick hat position change event structure */ +typedef struct SDL_JoyHatEvent { + Uint8 type; /**< SDL_JOYHATMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value: + * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + * Note that zero means the POV is centered. + */ +} SDL_JoyHatEvent; + +/** Joystick button event structure */ +typedef struct SDL_JoyButtonEvent { + Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ + Uint8 which; /**< The joystick device index */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ +} SDL_JoyButtonEvent; + +/** The "window resized" event + * When you get this event, you are responsible for setting a new video + * mode with the new width and height. + */ +typedef struct SDL_ResizeEvent { + Uint8 type; /**< SDL_VIDEORESIZE */ + int w; /**< New width */ + int h; /**< New height */ +} SDL_ResizeEvent; + +/** The "screen redraw" event */ +typedef struct SDL_ExposeEvent { + Uint8 type; /**< SDL_VIDEOEXPOSE */ +} SDL_ExposeEvent; + +/** The "quit requested" event */ +typedef struct SDL_QuitEvent { + Uint8 type; /**< SDL_QUIT */ +} SDL_QuitEvent; + +/** A user-defined event type */ +typedef struct SDL_UserEvent { + Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ + int code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + +/** If you want to use this event, you should include SDL_syswm.h */ +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; +typedef struct SDL_SysWMEvent { + Uint8 type; + SDL_SysWMmsg *msg; +} SDL_SysWMEvent; + +/** General event structure */ +typedef union SDL_Event { + Uint8 type; + SDL_ActiveEvent active; + SDL_KeyboardEvent key; + SDL_MouseMotionEvent motion; + SDL_MouseButtonEvent button; + SDL_JoyAxisEvent jaxis; + SDL_JoyBallEvent jball; + SDL_JoyHatEvent jhat; + SDL_JoyButtonEvent jbutton; + SDL_ResizeEvent resize; + SDL_ExposeEvent expose; + SDL_QuitEvent quit; + SDL_UserEvent user; + SDL_SysWMEvent syswm; +} SDL_Event; + + +/* Function prototypes */ + +/** Pumps the event loop, gathering events from the input devices. + * This function updates the event queue and internal input device state. + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +typedef enum { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + * the back of the event queue. + * If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + * of the event queue, matching 'mask', will be returned and will not + * be removed from the queue. + * If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + * of the event queue, matching 'mask', will be returned and will be + * removed from the queue. + * + * @return + * This function returns the number of events actually stored, or -1 + * if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, + SDL_eventaction action, Uint32 mask); + +/** Polls for currently pending events, and returns 1 if there are any pending + * events, or 0 if there are none available. If 'event' is not NULL, the next + * event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); + +/** Waits indefinitely for the next available event, returning 1, or 0 if there + * was an error while waiting for events. If 'event' is not NULL, the next + * event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); + +/** Add an event to the event queue. + * This function returns 0 on success, or -1 if the event queue was full + * or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); + +/** @name Event Filtering */ +/*@{*/ +typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); +/** + * This function sets up a filter to process all events before they + * change internal state and are posted to the internal event queue. + * + * The filter is protypted as: + * @code typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); @endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * @warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the SDL_QUITEVENT event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns NULL. + */ +extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); +/*@}*/ + +/** @name Event State */ +/*@{*/ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 +/*@}*/ + +/** +* This function allows you to set the state of processing certain events. +* If 'state' is set to SDL_IGNORE, that event will be automatically dropped +* from the event queue and will not event be filtered. +* If 'state' is set to SDL_ENABLE, that event will be processed normally. +* If 'state' is set to SDL_QUERY, SDL_EventState() will return the +* current processing state of the specified event. +*/ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_getenv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_getenv.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,28 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_getenv.h + * @deprecated Use SDL_stdinc.h instead + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_joystick.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_joystick.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,187 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_joystick.h + * Include file for SDL joystick event handling + */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL_joystick.h + * @note In order to use these functions, SDL_Init() must have been called + * with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + */ + +/** The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* Function prototypes */ +/** + * Count the number of joysticks attached to the system + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); + +/** + * Open a joystick for use. + * + * @param[in] device_index + * The index passed as an argument refers to + * the N'th joystick on the system. This index is the value which will + * identify this joystick in future joystick events. + * + * @return This function returns a joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Returns 1 if the joystick has been opened, or 0 if it has not. + */ +extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); + +/** + * Get the device index of an opened joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); + +/** + * Get the number of general axis controls on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); + +/** + * Get the number of trackballs on a joystick + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); + +/** + * Get the number of POV hats on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); + +/** + * Get the number of buttons on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/** + * Get the current state of an axis control on a joystick + * + * @param[in] axis The axis indices start at index 0. + * + * @return The state is a value ranging from -32768 to 32767. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); + +/** + * @name Hat Positions + * The return value of SDL_JoystickGetHat() is one of the following positions: + */ +/*@{*/ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/*@}*/ + +/** + * Get the current state of a POV hat on a joystick + * + * @param[in] hat The hat indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); + +/** + * Get the ball axis change since the last poll + * + * @param[in] ball The ball indices start at index 0. + * + * @return This returns 0, or -1 if you passed it invalid parameters. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick + * + * @param[in] button The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); + +/** + * Close a joystick previously opened with SDL_JoystickOpen() + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_keyboard.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_keyboard.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,135 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_keyboard.h + * Include file for SDL keyboard event handling + */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keysym.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** Keysym structure + * + * - The scancode is hardware dependent, and should not be used by general + * applications. If no hardware scancode is available, it will be 0. + * + * - The 'unicode' translated character is only available when character + * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, + * this is a UNICODE character corresponding to the keypress. If the + * high 9 bits of the character are 0, then this maps to the equivalent + * ASCII character: + * @code + * char ch; + * if ( (keysym.unicode & 0xFF80) == 0 ) { + * ch = keysym.unicode & 0x7F; + * } else { + * An international character.. + * } + * @endcode + */ +typedef struct SDL_keysym { + Uint8 scancode; /**< hardware specific scancode */ + SDLKey sym; /**< SDL virtual keysym */ + SDLMod mod; /**< current key modifiers */ + Uint16 unicode; /**< translated character */ +} SDL_keysym; + +/** This is the mask which refers to all hotkey bindings */ +#define SDL_ALL_HOTKEYS 0xFFFFFFFF + +/* Function prototypes */ +/** + * Enable/Disable UNICODE translation of keyboard input. + * + * This translation has some overhead, so translation defaults off. + * + * @param[in] enable + * If 'enable' is 1, translation is enabled. + * If 'enable' is 0, translation is disabled. + * If 'enable' is -1, the translation state is not changed. + * + * @return It returns the previous state of keyboard translation. + */ +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); + +#define SDL_DEFAULT_REPEAT_DELAY 500 +#define SDL_DEFAULT_REPEAT_INTERVAL 30 +/** + * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. + * + * @param[in] delay + * 'delay' is the initial delay in ms between the time when a key is + * pressed, and keyboard repeat begins. + * + * @param[in] interval + * 'interval' is the time in ms between keyboard repeat events. + * + * If 'delay' is set to 0, keyboard repeat is disabled. + */ +extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); +extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); + +/** + * Get a snapshot of the current state of the keyboard. + * Returns an array of keystates, indexed by the SDLK_* syms. + * Usage: + * @code + * Uint8 *keystate = SDL_GetKeyState(NULL); + * if ( keystate[SDLK_RETURN] ) //... \ is pressed. + * @endcode + */ +extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); + +/** + * Get the current key modifier state + */ +extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); + +/** + * Set the current key modifier state. + * This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); + +/** + * Get the name of an SDL virtual keysym + */ +extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_keysym.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_keysym.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,326 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_keysym_h +#define _SDL_keysym_h + +/** What we really want is a mapping of every raw key on the keyboard. + * To support international keyboards, we use the range 0xA1 - 0xFF + * as international virtual keycodes. We'll follow in the footsteps of X11... + * @brief The names of the keys + */ +typedef enum { + /** @name ASCII mapped keysyms + * The keyboard syms have been cleverly chosen to map to ASCII + */ + /*@{*/ + SDLK_UNKNOWN = 0, + SDLK_FIRST = 0, + SDLK_BACKSPACE = 8, + SDLK_TAB = 9, + SDLK_CLEAR = 12, + SDLK_RETURN = 13, + SDLK_PAUSE = 19, + SDLK_ESCAPE = 27, + SDLK_SPACE = 32, + SDLK_EXCLAIM = 33, + SDLK_QUOTEDBL = 34, + SDLK_HASH = 35, + SDLK_DOLLAR = 36, + SDLK_AMPERSAND = 38, + SDLK_QUOTE = 39, + SDLK_LEFTPAREN = 40, + SDLK_RIGHTPAREN = 41, + SDLK_ASTERISK = 42, + SDLK_PLUS = 43, + SDLK_COMMA = 44, + SDLK_MINUS = 45, + SDLK_PERIOD = 46, + SDLK_SLASH = 47, + SDLK_0 = 48, + SDLK_1 = 49, + SDLK_2 = 50, + SDLK_3 = 51, + SDLK_4 = 52, + SDLK_5 = 53, + SDLK_6 = 54, + SDLK_7 = 55, + SDLK_8 = 56, + SDLK_9 = 57, + SDLK_COLON = 58, + SDLK_SEMICOLON = 59, + SDLK_LESS = 60, + SDLK_EQUALS = 61, + SDLK_GREATER = 62, + SDLK_QUESTION = 63, + SDLK_AT = 64, + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = 91, + SDLK_BACKSLASH = 92, + SDLK_RIGHTBRACKET = 93, + SDLK_CARET = 94, + SDLK_UNDERSCORE = 95, + SDLK_BACKQUOTE = 96, + SDLK_a = 97, + SDLK_b = 98, + SDLK_c = 99, + SDLK_d = 100, + SDLK_e = 101, + SDLK_f = 102, + SDLK_g = 103, + SDLK_h = 104, + SDLK_i = 105, + SDLK_j = 106, + SDLK_k = 107, + SDLK_l = 108, + SDLK_m = 109, + SDLK_n = 110, + SDLK_o = 111, + SDLK_p = 112, + SDLK_q = 113, + SDLK_r = 114, + SDLK_s = 115, + SDLK_t = 116, + SDLK_u = 117, + SDLK_v = 118, + SDLK_w = 119, + SDLK_x = 120, + SDLK_y = 121, + SDLK_z = 122, + SDLK_DELETE = 127, + /* End of ASCII mapped keysyms */ + /*@}*/ + + /** @name International keyboard syms */ + /*@{*/ + SDLK_WORLD_0 = 160, /* 0xA0 */ + SDLK_WORLD_1 = 161, + SDLK_WORLD_2 = 162, + SDLK_WORLD_3 = 163, + SDLK_WORLD_4 = 164, + SDLK_WORLD_5 = 165, + SDLK_WORLD_6 = 166, + SDLK_WORLD_7 = 167, + SDLK_WORLD_8 = 168, + SDLK_WORLD_9 = 169, + SDLK_WORLD_10 = 170, + SDLK_WORLD_11 = 171, + SDLK_WORLD_12 = 172, + SDLK_WORLD_13 = 173, + SDLK_WORLD_14 = 174, + SDLK_WORLD_15 = 175, + SDLK_WORLD_16 = 176, + SDLK_WORLD_17 = 177, + SDLK_WORLD_18 = 178, + SDLK_WORLD_19 = 179, + SDLK_WORLD_20 = 180, + SDLK_WORLD_21 = 181, + SDLK_WORLD_22 = 182, + SDLK_WORLD_23 = 183, + SDLK_WORLD_24 = 184, + SDLK_WORLD_25 = 185, + SDLK_WORLD_26 = 186, + SDLK_WORLD_27 = 187, + SDLK_WORLD_28 = 188, + SDLK_WORLD_29 = 189, + SDLK_WORLD_30 = 190, + SDLK_WORLD_31 = 191, + SDLK_WORLD_32 = 192, + SDLK_WORLD_33 = 193, + SDLK_WORLD_34 = 194, + SDLK_WORLD_35 = 195, + SDLK_WORLD_36 = 196, + SDLK_WORLD_37 = 197, + SDLK_WORLD_38 = 198, + SDLK_WORLD_39 = 199, + SDLK_WORLD_40 = 200, + SDLK_WORLD_41 = 201, + SDLK_WORLD_42 = 202, + SDLK_WORLD_43 = 203, + SDLK_WORLD_44 = 204, + SDLK_WORLD_45 = 205, + SDLK_WORLD_46 = 206, + SDLK_WORLD_47 = 207, + SDLK_WORLD_48 = 208, + SDLK_WORLD_49 = 209, + SDLK_WORLD_50 = 210, + SDLK_WORLD_51 = 211, + SDLK_WORLD_52 = 212, + SDLK_WORLD_53 = 213, + SDLK_WORLD_54 = 214, + SDLK_WORLD_55 = 215, + SDLK_WORLD_56 = 216, + SDLK_WORLD_57 = 217, + SDLK_WORLD_58 = 218, + SDLK_WORLD_59 = 219, + SDLK_WORLD_60 = 220, + SDLK_WORLD_61 = 221, + SDLK_WORLD_62 = 222, + SDLK_WORLD_63 = 223, + SDLK_WORLD_64 = 224, + SDLK_WORLD_65 = 225, + SDLK_WORLD_66 = 226, + SDLK_WORLD_67 = 227, + SDLK_WORLD_68 = 228, + SDLK_WORLD_69 = 229, + SDLK_WORLD_70 = 230, + SDLK_WORLD_71 = 231, + SDLK_WORLD_72 = 232, + SDLK_WORLD_73 = 233, + SDLK_WORLD_74 = 234, + SDLK_WORLD_75 = 235, + SDLK_WORLD_76 = 236, + SDLK_WORLD_77 = 237, + SDLK_WORLD_78 = 238, + SDLK_WORLD_79 = 239, + SDLK_WORLD_80 = 240, + SDLK_WORLD_81 = 241, + SDLK_WORLD_82 = 242, + SDLK_WORLD_83 = 243, + SDLK_WORLD_84 = 244, + SDLK_WORLD_85 = 245, + SDLK_WORLD_86 = 246, + SDLK_WORLD_87 = 247, + SDLK_WORLD_88 = 248, + SDLK_WORLD_89 = 249, + SDLK_WORLD_90 = 250, + SDLK_WORLD_91 = 251, + SDLK_WORLD_92 = 252, + SDLK_WORLD_93 = 253, + SDLK_WORLD_94 = 254, + SDLK_WORLD_95 = 255, /* 0xFF */ + /*@}*/ + + /** @name Numeric keypad */ + /*@{*/ + SDLK_KP0 = 256, + SDLK_KP1 = 257, + SDLK_KP2 = 258, + SDLK_KP3 = 259, + SDLK_KP4 = 260, + SDLK_KP5 = 261, + SDLK_KP6 = 262, + SDLK_KP7 = 263, + SDLK_KP8 = 264, + SDLK_KP9 = 265, + SDLK_KP_PERIOD = 266, + SDLK_KP_DIVIDE = 267, + SDLK_KP_MULTIPLY = 268, + SDLK_KP_MINUS = 269, + SDLK_KP_PLUS = 270, + SDLK_KP_ENTER = 271, + SDLK_KP_EQUALS = 272, + /*@}*/ + + /** @name Arrows + Home/End pad */ + /*@{*/ + SDLK_UP = 273, + SDLK_DOWN = 274, + SDLK_RIGHT = 275, + SDLK_LEFT = 276, + SDLK_INSERT = 277, + SDLK_HOME = 278, + SDLK_END = 279, + SDLK_PAGEUP = 280, + SDLK_PAGEDOWN = 281, + /*@}*/ + + /** @name Function keys */ + /*@{*/ + SDLK_F1 = 282, + SDLK_F2 = 283, + SDLK_F3 = 284, + SDLK_F4 = 285, + SDLK_F5 = 286, + SDLK_F6 = 287, + SDLK_F7 = 288, + SDLK_F8 = 289, + SDLK_F9 = 290, + SDLK_F10 = 291, + SDLK_F11 = 292, + SDLK_F12 = 293, + SDLK_F13 = 294, + SDLK_F14 = 295, + SDLK_F15 = 296, + /*@}*/ + + /** @name Key state modifier keys */ + /*@{*/ + SDLK_NUMLOCK = 300, + SDLK_CAPSLOCK = 301, + SDLK_SCROLLOCK = 302, + SDLK_RSHIFT = 303, + SDLK_LSHIFT = 304, + SDLK_RCTRL = 305, + SDLK_LCTRL = 306, + SDLK_RALT = 307, + SDLK_LALT = 308, + SDLK_RMETA = 309, + SDLK_LMETA = 310, + SDLK_LSUPER = 311, /**< Left "Windows" key */ + SDLK_RSUPER = 312, /**< Right "Windows" key */ + SDLK_MODE = 313, /**< "Alt Gr" key */ + SDLK_COMPOSE = 314, /**< Multi-key compose key */ + /*@}*/ + + /** @name Miscellaneous function keys */ + /*@{*/ + SDLK_HELP = 315, + SDLK_PRINT = 316, + SDLK_SYSREQ = 317, + SDLK_BREAK = 318, + SDLK_MENU = 319, + SDLK_POWER = 320, /**< Power Macintosh power key */ + SDLK_EURO = 321, /**< Some european keyboards */ + SDLK_UNDO = 322, /**< Atari keyboard has Undo */ + /*@}*/ + + /* Add any other keys here */ + + SDLK_LAST +} SDLKey; + +/** Enumeration of valid key mods (possibly OR'd together) */ +typedef enum { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDLMod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_META (KMOD_LMETA|KMOD_RMETA) + +#endif /* _SDL_keysym_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_loadso.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_loadso.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,78 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_loadso.h + * System dependent library loading routines + */ + +/** @file SDL_loadso.h + * Some things to keep in mind: + * - These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * - Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * - Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); + +/** Unload a shared object from memory */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_main.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,106 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/** @file SDL_main.h + * Redefine main() on Win32 and MacOS so that it is called by winmain.c + */ + +#if defined(__WIN32__) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(__MACOS__) || defined(__MACOSX__) || \ + defined(__SYMBIAN32__) || defined(QWS) + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/** The application's main() function must be called with C linkage, + * and should be declared like this: + * @code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * @endcode + */ +#define main SDL_main + +/** The prototype for the application's main() function */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +/** @name From the SDL library code -- needed for registering the app on Win32 */ +/*@{*/ +#ifdef __WIN32__ + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** This should be called from your WinMain() function, if any */ +extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); +/** This can also be called, but is no longer necessary */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); +/** This can also be called, but is no longer necessary (SDL_Quit calls it) */ +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif +/*@}*/ + +/** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ +/*@{*/ +#if defined(__MACOS__) + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** Forward declaration so we don't need to include QuickDraw.h */ +struct QDGlobals; + +/** This should be called from your main() function, if any */ +extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif +/*@}*/ + +#endif /* Need to redefine main()? */ + +#endif /* _SDL_main_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_mixer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_mixer.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,634 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* $Id$ */ + +#ifndef _SDL_MIXER_H +#define _SDL_MIXER_H + +#include "SDL_types.h" +#include "SDL_rwops.h" +#include "SDL_audio.h" +#include "SDL_endian.h" +#include "SDL_version.h" +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MIXER_MAJOR_VERSION 1 +#define SDL_MIXER_MINOR_VERSION 2 +#define SDL_MIXER_PATCHLEVEL 12 + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL_mixer library. + */ +#define SDL_MIXER_VERSION(X) \ +{ \ + (X)->major = SDL_MIXER_MAJOR_VERSION; \ + (X)->minor = SDL_MIXER_MINOR_VERSION; \ + (X)->patch = SDL_MIXER_PATCHLEVEL; \ +} + +/* Backwards compatibility */ +#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION +#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION +#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL +#define MIX_VERSION(X) SDL_MIXER_VERSION(X) + +/* This function gets the version of the dynamically linked SDL_mixer library. + it should NOT be used to fill a version structure, instead you should + use the SDL_MIXER_VERSION() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void); + +typedef enum +{ + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000004, + MIX_INIT_OGG = 0x00000008, + MIX_INIT_FLUIDSYNTH = 0x00000010 +} MIX_InitFlags; + +/* Loads dynamic libraries and prepares them for use. Flags should be + one or more flags from MIX_InitFlags OR'd together. + It returns the flags successfully initialized, or 0 on failure. + */ +extern DECLSPEC int SDLCALL Mix_Init(int flags); + +/* Unloads libraries loaded with Mix_Init */ +extern DECLSPEC void SDLCALL Mix_Quit(void); + + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 22050 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define MIX_DEFAULT_FORMAT AUDIO_S16LSB +#else +#define MIX_DEFAULT_FORMAT AUDIO_S16MSB +#endif +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME 128 /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct Mix_Chunk { + int allocated; + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The different fading types supported */ +typedef enum { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} Mix_Fading; + +typedef enum { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD, + MUS_FLAC, + MUS_MODPLUG +} Mix_MusicType; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, + int chunksize); + +/* Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + */ +extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); + +/* Load a wave file or a music (.mod .s3m .it .xm) file */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file); + +/* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently) + Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw); + +/* Load a music file from an SDL_RWop object assuming a specific format */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc); + +/* Load a wave file of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem); + +/* Load raw audio data of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len); + +/* Free an audio chunk previously loaded */ +extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk); +extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music); + +/* Get a list of chunk/music decoders that this build of SDL_mixer provides. + This list can change between builds AND runs of the program, if external + libraries that add functionality become available. + You must successfully call Mix_OpenAudio() before calling these functions. + This API is only available in SDL_mixer 1.2.9 and later. + + // usage... + int i; + const int total = Mix_GetNumChunkDecoders(); + for (i = 0; i < total; i++) + printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i)); + + Appearing in this list doesn't promise your specific audio file will + decode...but it's handy to know if you have, say, a functioning Timidity + install. + + These return values are static, read-only data; do not modify or free it. + The pointers remain valid until you call Mix_CloseAudio(). +*/ +extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); +extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); + +/* Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL. +*/ +extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music); + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (*mix_func) + (void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func) + (void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own callback when the music has finished playing. + This callback is only called if the music finishes naturally. + */ +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void)); + +/* Get a pointer to the user data for the current music hook */ +extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); + +/* + * Add your own callback when a channel has finished playing. NULL + * to disable callback. The callback may be called from the mixer's audio + * callback or it could be called as a result of Mix_HaltChannel(), etc. + * do not call SDL_LockAudio() from this callback; you will either be + * inside the audio callback, or SDL_mixer will explicitly lock the audio + * before calling your callback. + */ +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel)); + + +/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ + +#define MIX_CHANNEL_POST -2 + +/* This is the format of a special effect callback: + * + * myeffect(int chan, void *stream, int len, void *udata); + * + * (chan) is the channel number that your effect is affecting. (stream) is + * the buffer of data to work upon. (len) is the size of (stream), and + * (udata) is a user-defined bit of data, which you pass as the last arg of + * Mix_RegisterEffect(), and is passed back unmolested to your callback. + * Your effect changes the contents of (stream) based on whatever parameters + * are significant, or just leaves it be, if you prefer. You can do whatever + * you like to the buffer, though, and it will continue in its changed state + * down the mixing pipeline, through any other effect functions, then finally + * to be mixed with the rest of the channels and music for the final output + * stream. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (*Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); + +/* + * This is a callback that signifies that a channel has finished all its + * loops and has completed playback. This gets called if the buffer + * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + * a channel via Mix_AllocateChannels(), or unregister a callback while + * it's still playing. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (*Mix_EffectDone_t)(int chan, void *udata); + + +/* Register a special effect function. At mixing time, the channel data is + * copied into a buffer and passed through each registered effect function. + * After it passes through all the functions, it is mixed into the final + * output stream. The copy to buffer is performed once, then each effect + * function performs on the output of the previous effect. Understand that + * this extra copy to a buffer is not performed if there are no effects + * registered for a given chunk, which saves CPU cycles, and any given + * effect will be extra cycles, too, so it is crucial that your code run + * fast. Also note that the data that your function is given is in the + * format of the sound device, and not the format you gave to Mix_OpenAudio(), + * although they may in reality be the same. This is an unfortunate but + * necessary speed concern. Use Mix_QuerySpec() to determine if you can + * handle the data before you register your effect, and take appropriate + * actions. + * You may also specify a callback (Mix_EffectDone_t) that is called when + * the channel finishes playing. This gives you a more fine-grained control + * than Mix_ChannelFinished(), in case you need to free effect-specific + * resources, etc. If you don't need this, you can specify NULL. + * You may set the callbacks before or after calling Mix_PlayChannel(). + * Things like Mix_SetPanning() are just internal special effect functions, + * so if you are using that, you've already incurred the overhead of a copy + * to a separate buffer, and that these effects will be in the queue with + * any functions you've registered. The list of registered effects for a + * channel is reset when a chunk finishes playing, so you need to explicitly + * set them with each call to Mix_PlayChannel*(). + * You may also register a special effect function that is to be run after + * final mixing occurs. The rules for these callbacks are identical to those + * in Mix_RegisterEffect, but they are run after all the channels and the + * music have been mixed into a single stream, whereas channel-specific + * effects run on a given channel before any other mixing occurs. These + * global effect callbacks are call "posteffects". Posteffects only have + * their Mix_EffectDone_t function called when they are unregistered (since + * the main output stream is never "done" in the same sense as a channel). + * You must unregister them manually when you've had enough. Your callback + * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + * processing is considered a posteffect. + * + * After all these effects have finished processing, the callback registered + * through Mix_SetPostMix() runs, and then the stream goes to the audio + * device. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + * + * returns zero if error (no such channel), nonzero if added. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, + Mix_EffectDone_t d, void *arg); + + +/* You may not need to call this explicitly, unless you need to stop an + * effect from processing in the middle of a chunk's playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel or effect), nonzero if removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f); + + +/* You may not need to call this explicitly, unless you need to stop all + * effects from processing in the middle of a chunk's playback. Note that + * this will also shut off some internal effect processing, since + * Mix_SetPanning() and others may use this API under the hood. This is + * called internally when a channel completes playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel), nonzero if all effects removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel); + + +#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED" + +/* + * These are the internally-defined mixing effects. They use the same API that + * effects defined in the application use, but are provided here as a + * convenience. Some effects can reduce their quality or use more memory in + * the name of speed; to enable this, make sure the environment variable + * MIX_EFFECTSMAXSPEED (see above) is defined before you call + * Mix_OpenAudio(). + */ + + +/* Set the panning of a channel. The left and right channels are specified + * as integers between 0 and 255, quietest to loudest, respectively. + * + * Technically, this is just individual volume control for a sample with + * two (stereo) channels, so it can be used for more than just panning. + * If you want real panning, call it like this: + * + * Mix_SetPanning(channel, left, 255 - left); + * + * ...which isn't so hard. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the panning will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally, and returns without + * registering the effect function if the audio device is not configured + * for stereo output. Setting both (left) and (right) to 255 causes this + * effect to be unregistered, since that is the data's normal state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if panning effect enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right); + + +/* Set the position of a channel. (angle) is an integer from 0 to 360, that + * specifies the location of the sound in relation to the listener. (angle) + * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). + * Angle 0 is due north, and rotates clockwise as the value increases. + * For efficiency, the precision of this effect may be limited (angles 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. Using 255 does not guarantee that the channel will be + * culled from the mixing process or be completely silent. For efficiency, + * the precision of this effect may be limited (distance 0 through 5 might + * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) + * and (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * If the audio device is configured for mono output, then you won't get + * any effectiveness from the angle; however, distance attenuation on the + * channel will still occur. While this effect will function with stereo + * voices, it makes more sense to use voices with only one channel of sound, + * so when they are mixed through this effect, the positioning will sound + * correct. You can convert them to mono through SDL before giving them to + * the mixer in the first place if you like. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the positioning will be done to the final mixed stream before passing it + * on to the audio device. + * + * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); + + +/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 + * that specifies the location of the sound in relation to the listener. + * Distance 0 is overlapping the listener, and 255 is as far away as possible + * A distance of 255 does not guarantee silence; in such a case, you might + * want to try changing the chunk's volume, or just cull the sample from the + * mixing process with Mix_HaltChannel(). + * For efficiency, the precision of this effect may be limited (distances 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. + * Setting (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the distance attenuation will be done to the final mixed stream before + * passing it on to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance); + + +/* + * !!! FIXME : Haven't implemented, since the effect goes past the + * end of the sound buffer. Will have to think about this. + * --ryan. + */ +#if 0 +/* Causes an echo effect to be mixed into a sound. (echo) is the amount + * of echo to mix. 0 is no echo, 255 is infinite (and probably not + * what you want). + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the reverbing will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. If you specify an echo + * of zero, the effect is unregistered, as the data is already in that state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo); +#endif + +/* Causes a channel to reverse its stereo. This is handy if the user has his + * speakers hooked up backwards, or you would like to have a minor bit of + * psychedelia in your sound code. :) Calling this function with (flip) + * set to non-zero reverses the chunks's usual channels. If (flip) is zero, + * the effect is unregistered. + * + * This uses the Mix_RegisterEffect() API internally, and thus is probably + * more CPU intensive than having the user just plug in his speakers + * correctly. Mix_SetReverseStereo() returns without registering the effect + * function if the audio device is not configured for stereo output. + * + * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used + * on the final mixed stream before sending it on to the audio device (a + * posteffect). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip); + +/* end of effects API. --ryan. */ + + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num); + +/* Channel grouping functions */ + +/* Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + */ +extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag); +/* Assign several consecutive channels to a group */ +extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag); +/* Finds the first available channel in a group of channels, + returning -1 if none are available. + */ +extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag); +/* Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + */ +extern DECLSPEC int SDLCALL Mix_GroupCount(int tag); +/* Finds the "oldest" sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag); +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) +/* The same as above, but the sound is played at most 'ticks' milliseconds */ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); +extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops); + +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ +extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms); +extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position); +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume); + +/* Halt playing of a particular channel */ +extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel); +extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag); +extern DECLSPEC int SDLCALL Mix_HaltMusic(void); + +/* Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +*/ +extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks); + +/* Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + */ +extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms); + +/* Query the fading status of a channel */ +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void); +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which); + +/* Pause/Resume a particular channel */ +extern DECLSPEC void SDLCALL Mix_Pause(int channel); +extern DECLSPEC void SDLCALL Mix_Resume(int channel); +extern DECLSPEC int SDLCALL Mix_Paused(int channel); + +/* Pause/Resume the music stream */ +extern DECLSPEC void SDLCALL Mix_PauseMusic(void); +extern DECLSPEC void SDLCALL Mix_ResumeMusic(void); +extern DECLSPEC void SDLCALL Mix_RewindMusic(void); +extern DECLSPEC int SDLCALL Mix_PausedMusic(void); + +/* Set the current position in the music stream. + This returns 0 if successful, or -1 if it failed or isn't implemented. + This function is only implemented for MOD music formats (set pattern + order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set + position in seconds), at the moment. +*/ +extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern DECLSPEC int SDLCALL Mix_Playing(int channel); +extern DECLSPEC int SDLCALL Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command); + +/* Synchro value is set by MikMod from modules while playing */ +extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value); +extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void); + +/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ +extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); +extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data); + +/* Get the Mix_Chunk currently associated with a mixer channel + Returns NULL if it's an invalid channel, or there's no chunk associated. +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel); + +/* Close the mixer, halting all playing audio */ +extern DECLSPEC void SDLCALL Mix_CloseAudio(void); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_MIXER_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_mouse.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_mouse.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,143 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_mouse.h + * Include file for SDL mouse event handling + */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WMcursor WMcursor; /**< Implementation dependent */ +typedef struct SDL_Cursor { + SDL_Rect area; /**< The area of the mouse cursor */ + Sint16 hot_x, hot_y; /**< The "tip" of the cursor */ + Uint8 *data; /**< B/W cursor data */ + Uint8 *mask; /**< B/W cursor mask */ + Uint8 *save[2]; /**< Place to save cursor area */ + WMcursor *wm_cursor; /**< Window-manager cursor */ +} SDL_Cursor; + +/* Function prototypes */ +/** + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * current mouse cursor position. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * Set the position of the mouse cursor (generates a mouse motion event) + */ +extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); + +/** + * Create a cursor using the specified data and mask (in MSB format). + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * data mask resulting pixel on screen + * 0 1 White + * 1 1 Black + * 0 0 Transparent + * 1 0 Inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_FreeCursor(). + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor + (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); + +/** + * Set the currently active cursor to the specified one. + * If the cursor is currently visible, the change will be immediately + * represented on the display. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); + +/** + * Returns the currently active cursor. + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); + +/** + * Deallocates a cursor created with SDL_CreateCursor(). + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); + +/** + * Toggle whether or not the cursor is shown on the screen. + * The cursor start off displayed, but can be turned off. + * SDL_ShowCursor() returns 1 if the cursor was being displayed + * before the call, or 0 if it was not. You can query the current + * state by passing a 'toggle' value of -1. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/*@{*/ +/** Used as a mask when testing buttons in buttonstate + * Button 1: Left mouse button + * Button 2: Middle mouse button + * Button 3: Right mouse button + * Button 4: Mouse wheel up (may also be a real button) + * Button 5: Mouse wheel down (may also be a real button) + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_WHEELUP 4 +#define SDL_BUTTON_WHEELDOWN 5 +#define SDL_BUTTON_X1 6 +#define SDL_BUTTON_X2 7 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_mutex.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_mutex.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,177 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/** @file SDL_mutex.h + * Functions to provide thread synchronization primitives + * + * @note These are independent of the other SDL routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** This is the timeout value which corresponds to never time out */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Mutex functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** The SDL mutex structure, defined in SDL_mutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** Create a mutex, initialized unlocked */ +extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); + +#define SDL_LockMutex(m) SDL_mutexP(m) +/** Lock the mutex + * @return 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); + +#define SDL_UnlockMutex(m) SDL_mutexV(m) +/** Unlock the mutex + * @return 0, or -1 on error + * + * It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); + +/** Destroy a mutex */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Semaphore functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** The SDL semaphore structure, defined in SDL_sem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** Create a semaphore, initialized with value, returns NULL on failure. */ +extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** Destroy a semaphore */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by sem has a positive count. It then atomically decreases the semaphore + * count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); + +/** Non-blocking variant of SDL_SemWait(). + * @return 0 if the wait succeeds, + * SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); + +/** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if + * the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in + * the allotted time, and -1 on error. + * + * On some platforms this function is implemented by looping with a delay + * of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); + +/** Atomically increases the semaphore's count (not blocking). + * @return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); + +/** Returns the current count of the semaphore */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Condition_variable_functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*@{*/ +/** The SDL condition variable structure, defined in SDL_cond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; +/*@}*/ + +/** Create a condition variable */ +extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); + +/** Destroy a condition variable */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); + +/** Restart one of the threads that are waiting on the condition variable, + * @return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); + +/** Restart all threads that are waiting on the condition variable, + * @return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); + +/** Wait on the condition variable, unlocking the provided mutex. + * The mutex must be locked before entering this function! + * The mutex is re-locked once the condition variable is signaled. + * @return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); + +/** Waits for at most 'ms' milliseconds, and returns 0 if the condition + * variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * On some platforms this function is implemented by looping with a delay + * of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); + +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ + diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_name.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_name.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,11 @@ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_opengl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_opengl.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,6570 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_opengl.h + * This is a simple file to encapsulate the OpenGL API headers + */ + +#include "SDL_config.h" + +#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#if defined(__MACOSX__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#elif defined(__MACOS__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#else +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#endif +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif + +/** @name GLext.h + * This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. + * It is included here because glext.h is not available on some systems. + * If you don't want this version included, simply define "NO_SDL_GLEXT" + */ +/*@{*/ +#ifndef NO_SDL_GLEXT +#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2005/06/20 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 29 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +#ifdef __APPLE__ +typedef long GLintptr; +typedef long GLsizeiptr; +#else +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +#ifdef __APPLE__ +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +#if defined(__APPLE__) +typedef void *GLhandleARB; /* shader object handle */ +#else +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ +/*@}*/ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_platform.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_platform.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,110 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_platform.h + * Try to get a standard set of platform defines + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__BEOS__) +#undef __BEOS__ +#define __BEOS__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(__APPLE__) +#undef __MACOSX__ +#define __MACOSX__ 1 +#elif defined(macintosh) +#undef __MACOS__ +#define __MACOS__ 1 +#endif +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif +#if defined(WIN32) || defined(_WIN32) +#undef __WIN32__ +#define __WIN32__ 1 +#endif + +#endif /* _SDL_platform_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_quit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_quit.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,55 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_quit.h + * Include file for SDL quit event handling + */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** @file SDL_quit.h + * An SDL_QUITEVENT is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate SDL_QUITEVENT events as well. There is no way + * to determine the cause of an SDL_QUITEVENT, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + */ + +/** @file SDL_quit.h + * There are no functions directly affecting the quit event + */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) + +#endif /* _SDL_quit_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_rwops.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_rwops.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,155 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_rwops.h + * This file provides a general interface for SDL to read and write + * data sources. It can easily be extended to files, memory, etc. + */ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the read/write operation structure -- very basic */ + +typedef struct SDL_RWops { + /** Seek to 'offset' relative to whence, one of stdio's whence values: + * SEEK_SET, SEEK_CUR, SEEK_END + * Returns the final offset in the data source. + */ + int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); + + /** Read up to 'maxnum' objects each of size 'size' from the data + * source to the area pointed at by 'ptr'. + * Returns the number of objects read, or -1 if the read failed. + */ + int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); + + /** Write exactly 'num' objects each of size 'objsize' from the area + * pointed at by 'ptr' to data source. + * Returns 'num', or -1 if the write failed. + */ + int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); + + /** Close and free an allocated SDL_FSops structure */ + int (SDLCALL *close)(struct SDL_RWops *context); + + Uint32 type; + union { +#if defined(__WIN32__) && !defined(__SYMBIAN32__) + struct { + int append; + void *h; + struct { + void *data; + int size; + int left; + } buffer; + } win32io; +#endif +#ifdef HAVE_STDIO_H + struct { + int autoclose; + FILE *fp; + } stdio; +#endif + struct { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct { + void *data1; + } unknown; + } hidden; + +} SDL_RWops; + + +/** @name Functions to create SDL_RWops structures from various data sources */ +/*@{*/ + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); +#endif + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); + +/*@}*/ + +/** @name Seek Reference Points */ +/*@{*/ +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ +/*@}*/ + +/** @name Macros to easily read and write from an SDL_RWops structure */ +/*@{*/ +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) +/*@}*/ + +/** @name Read an item of the specified endianness and return in native format */ +/*@{*/ +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); +/*@}*/ + +/** @name Write an item of native format to the specified endianness */ +/*@{*/ +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_stdinc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_stdinc.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,620 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_stdinc.h + * This is a general header that includes C language support + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include +#endif + +/** The number of elements in an array */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/* Use proper C++ casts when compiled as C++ to be compatible with the option + -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#endif + +/** @name Basic data types */ +/*@{*/ +typedef enum { + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +typedef int8_t Sint8; +typedef uint8_t Uint8; +typedef int16_t Sint16; +typedef uint16_t Uint16; +typedef int32_t Sint32; +typedef uint32_t Uint32; + +#ifdef SDL_HAS_64BIT_TYPE +typedef int64_t Sint64; +#ifndef SYMBIAN32_GCCE +typedef uint64_t Uint64; +#endif +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef struct { + Uint32 hi; + Uint32 lo; +} Uint64, Sint64; +#endif + +/*@}*/ + +/** @name Make sure the types really have the right sizes */ +/*@{*/ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] + +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +/*@}*/ + +/** @name Enum Size Check + * Check to make sure enums are the size of ints, for structure packing. + * For both Watcom C/C++ and Borland C/C++ the compiler option that makes + * enums having the size of an int must be enabled. + * This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). + */ +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ +#ifdef __MWERKS__ +#pragma enumsalwaysint on +#endif + +typedef enum { + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +#ifndef __NDS__ +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +/*@}*/ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_MALLOC +#define SDL_malloc malloc +#else +extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); +#endif + +#ifdef HAVE_CALLOC +#define SDL_calloc calloc +#else +extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); +#endif + +#ifdef HAVE_REALLOC +#define SDL_realloc realloc +#else +extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); +#endif + +#ifdef HAVE_FREE +#define SDL_free free +#else +extern DECLSPEC void SDLCALL SDL_free(void *mem); +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) + #pragma alloca +# elif defined(__MRC__) + void *alloca (unsigned); +# else + char *alloca (); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +#ifdef HAVE_GETENV +#define SDL_getenv getenv +#else +extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); +#endif + +#ifdef HAVE_PUTENV +#define SDL_putenv putenv +#else +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); +#endif + +#ifdef HAVE_QSORT +#define SDL_qsort qsort +#else +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, + int (*compare)(const void *, const void *)); +#endif + +#ifdef HAVE_ABS +#define SDL_abs abs +#else +#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) +#endif + +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +#ifdef HAVE_CTYPE_H +#define SDL_isdigit(X) isdigit(X) +#define SDL_isspace(X) isspace(X) +#define SDL_toupper(X) toupper(X) +#define SDL_tolower(X) tolower(X) +#else +#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) +#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) +#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) +#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) +#endif + +#ifdef HAVE_MEMSET +#define SDL_memset memset +#else +extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_memset4(dst, val, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; stosl\n\t" \ + : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memset4 +#define SDL_memset4(dst, val, len) \ +do { \ + unsigned _count = (len); \ + unsigned _n = (_count + 3) / 4; \ + Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ + Uint32 _val = (val); \ + if (len == 0) break; \ + switch (_count % 4) { \ + case 0: do { *_p++ = _val; \ + case 3: *_p++ = _val; \ + case 2: *_p++ = _val; \ + case 1: *_p++ = _val; \ + } while ( --_n ); \ + } \ +} while(0) +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl\n\t" \ + "testb $2,%b4\n\t" \ + "je 1f\n\t" \ + "movsw\n" \ + "1:\ttestb $1,%b4\n\t" \ + "je 2f\n\t" \ + "movsb\n" \ + "2:" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy +#ifdef HAVE_MEMCPY +#define SDL_memcpy memcpy +#elif defined(HAVE_BCOPY) +#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) +#else +extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); +#endif +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy4(dst, src, len) \ +do { \ + int ecx, edi, esi; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl" \ + : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ + : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy4 +#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_revcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + char *dstp = SDL_static_cast(char *, dst); \ + char *srcp = SDL_static_cast(char *, src); \ + int n = (len); \ + if ( n >= 4 ) { \ + __asm__ __volatile__ ( \ + "std\n\t" \ + "rep ; movsl\n\t" \ + "cld\n\t" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (n >> 2), \ + "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ + : "memory" ); \ + } \ + switch (n & 3) { \ + case 3: dstp[2] = srcp[2]; \ + case 2: dstp[1] = srcp[1]; \ + case 1: dstp[0] = srcp[0]; \ + break; \ + default: \ + break; \ + } \ +} while(0) +#endif +#ifndef SDL_revcpy +extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); +#endif + +#ifdef HAVE_MEMMOVE +#define SDL_memmove memmove +#elif defined(HAVE_BCOPY) +#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) +#else +#define SDL_memmove(dst, src, len) \ +do { \ + if ( dst < src ) { \ + SDL_memcpy(dst, src, len); \ + } else { \ + SDL_revcpy(dst, src, len); \ + } \ +} while(0) +#endif + +#ifdef HAVE_MEMCMP +#define SDL_memcmp memcmp +#else +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); +#endif + +#ifdef HAVE_STRLEN +#define SDL_strlen strlen +#else +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); +#endif + +#ifdef HAVE_STRLCPY +#define SDL_strlcpy strlcpy +#else +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRLCAT +#define SDL_strlcat strlcat +#else +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRDUP +#define SDL_strdup strdup +#else +extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); +#endif + +#ifdef HAVE__STRREV +#define SDL_strrev _strrev +#else +extern DECLSPEC char * SDLCALL SDL_strrev(char *string); +#endif + +#ifdef HAVE__STRUPR +#define SDL_strupr _strupr +#else +extern DECLSPEC char * SDLCALL SDL_strupr(char *string); +#endif + +#ifdef HAVE__STRLWR +#define SDL_strlwr _strlwr +#else +extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); +#endif + +#ifdef HAVE_STRCHR +#define SDL_strchr strchr +#elif defined(HAVE_INDEX) +#define SDL_strchr index +#else +extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); +#endif + +#ifdef HAVE_STRRCHR +#define SDL_strrchr strrchr +#elif defined(HAVE_RINDEX) +#define SDL_strrchr rindex +#else +extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); +#endif + +#ifdef HAVE_STRSTR +#define SDL_strstr strstr +#else +extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); +#endif + +#ifdef HAVE_ITOA +#define SDL_itoa itoa +#else +#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) +#endif + +#ifdef HAVE__LTOA +#define SDL_ltoa _ltoa +#else +extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); +#endif + +#ifdef HAVE__UITOA +#define SDL_uitoa _uitoa +#else +#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) +#endif + +#ifdef HAVE__ULTOA +#define SDL_ultoa _ultoa +#else +extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOL +#define SDL_strtol strtol +#else +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOUL +#define SDL_strtoul strtoul +#else +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); +#endif + +#ifdef SDL_HAS_64BIT_TYPE + +#ifdef HAVE__I64TOA +#define SDL_lltoa _i64toa +#else +extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); +#endif + +#ifdef HAVE__UI64TOA +#define SDL_ulltoa _ui64toa +#else +extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOLL +#define SDL_strtoll strtoll +#else +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOULL +#define SDL_strtoull strtoull +#else +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); +#endif + +#endif /* SDL_HAS_64BIT_TYPE */ + +#ifdef HAVE_STRTOD +#define SDL_strtod strtod +#else +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); +#endif + +#ifdef HAVE_ATOI +#define SDL_atoi atoi +#else +#define SDL_atoi(X) SDL_strtol(X, NULL, 0) +#endif + +#ifdef HAVE_ATOF +#define SDL_atof atof +#else +#define SDL_atof(X) SDL_strtod(X, NULL) +#endif + +#ifdef HAVE_STRCMP +#define SDL_strcmp strcmp +#else +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCMP +#define SDL_strncmp strncmp +#else +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_STRCASECMP +#define SDL_strcasecmp strcasecmp +#elif defined(HAVE__STRICMP) +#define SDL_strcasecmp _stricmp +#else +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCASECMP +#define SDL_strncasecmp strncasecmp +#elif defined(HAVE__STRNICMP) +#define SDL_strncasecmp _strnicmp +#else +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_SSCANF +#define SDL_sscanf sscanf +#else +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); +#endif + +#ifdef HAVE_SNPRINTF +#define SDL_snprintf snprintf +#else +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); +#endif + +#ifdef HAVE_VSNPRINTF +#define SDL_vsnprintf vsnprintf +#else +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); +#endif + +/** @name SDL_ICONV Error Codes + * The SDL implementation of iconv() returns these error codes + */ +/*@{*/ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 +/*@}*/ + +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +#define SDL_iconv_t iconv_t +#define SDL_iconv_open iconv_open +#define SDL_iconv_close iconv_close +#else +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +#endif +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); +/** This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_syswm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_syswm.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,226 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_syswm.h + * Include file for SDL custom system window manager hooks + */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL_syswm.h + * Your application has access to a special type of event 'SDL_SYSWMEVENT', + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState() + */ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +typedef struct SDL_SysWMinfo SDL_SysWMinfo; +#else + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +/** These are the various supported subsystems under UNIX */ +typedef enum { + SDL_SYSWM_X11 +} SDL_SYSWM_TYPE; + +/** The UNIX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + XEvent xevent; + } event; +}; + +/** The UNIX custom window manager information structure. + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +typedef struct SDL_SysWMinfo { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + struct { + Display *display; /**< The X11 display */ + Window window; /**< The X11 display window */ + /** These locking functions should be called around + * any X11 functions using the display variable, + * but not the gfxdisplay variable. + * They lock the event thread, so should not be + * called around event functions or from event filters. + */ + /*@{*/ + void (*lock_func)(void); + void (*unlock_func)(void); + /*@}*/ + + /** @name Introduced in SDL 1.0.2 */ + /*@{*/ + Window fswindow; /**< The X11 fullscreen window */ + Window wmwindow; /**< The X11 managed input window */ + /*@}*/ + + /** @name Introduced in SDL 1.2.12 */ + /*@{*/ + Display *gfxdisplay; /**< The X11 display to which rendering is done */ + /*@}*/ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_NANOX) +#include + +/** The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +#define WIN32_LEAN_AND_MEAN +#include + +/** The windows custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ +}; + +/** The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + HWND window; /**< The Win32 display window */ + HGLRC hglrc; /**< The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_RISCOS) + +/** RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /**< The window for the message */ + int pollBlock[64]; +}; + +/** The RISC OS custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int wimpVersion; /**< Wimp version running under */ + int taskHandle; /**< The RISC OS task handle */ + int window; /**< The RISC OS display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_PHOTON) +#include +#include + +/** The QNX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The QNX custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#else + +/** The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The generic custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#endif /* video driver type */ + +#endif /* SDL_PROTOTYPES_ONLY */ + +/* Function prototypes */ +/** + * This function gives you custom hooks into the window manager information. + * It fills the structure pointed to by 'info' with custom information and + * returns 0 if the function is not implemented, 1 if the function is + * implemented and no error occurred, and -1 if the version member of + * the 'info' structure is not filled in or not supported. + * + * You typically use this function like this: + * @code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWMInfo(&info) ) { ... } + * @endcode + */ +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_thread.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_thread.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,115 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/** @file SDL_thread.h + * Header for the SDL thread management routines + * + * @note These are independent of the other SDL routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/** Create a thread */ +#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) +/** + * We compile SDL into a DLL on OS/2. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL.DLL will + * be initialized for those threads, and not the RTL of the calling application! + * To solve this, we make a little hack here. + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL.DLL which uses this API, + * then the RTL of SDL.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#ifndef _WIN32_WCE +#include /* This has _beginthread() and _endthread() defined! */ +#endif + +#ifdef __OS2__ +typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); +typedef void (*pfnSDL_CurrentEndThread)(void); +#else +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#endif + +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); + +#ifdef __OS2__ +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) +#elif defined(_WIN32_WCE) +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) +#else +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) +#endif +#else +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); +#endif + +/** Get the 32-bit thread identifier for the current thread */ +extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); + +/** Get the 32-bit thread identifier for the specified thread, + * equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); + +/** Wait for a thread to finish. + * The return code for the thread function is placed in the area + * pointed to by 'status', if 'status' is not NULL. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); + +/** Forcefully kill a thread without worrying about its state */ +extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_timer.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,125 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/** @file SDL_timer.h + * Header for the SDL time management routines + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the OS scheduler timeslice, in milliseconds */ +#define SDL_TIMESLICE 10 + +/** This is the maximum resolution of the SDL timer on all platforms */ +#define TIMER_RESOLUTION 10 /**< Experimentally determined */ + +/** + * Get the number of milliseconds since the SDL library initialization. + * Note that this value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** Wait a specified number of milliseconds before returning */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** Function prototype for the timer callback function */ +typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); + +/** + * Set a callback to run after the specified number of milliseconds has + * elapsed. The callback function is passed the current timer interval + * and returns the next timer interval. If the returned value is the + * same as the one passed in, the periodic alarm continues, otherwise a + * new alarm is scheduled. If the callback returns 0, the periodic alarm + * is cancelled. + * + * To cancel a currently running timer, call SDL_SetTimer(0, NULL); + * + * The timer callback function may run in a different thread than your + * main code, and so shouldn't call any functions from within itself. + * + * The maximum resolution of this timer is 10 ms, which means that if + * you request a 16 ms timer, your callback will run approximately 20 ms + * later on an unloaded system. If you wanted to set a flag signaling + * a frame update at 30 frames per second (every 33 ms), you might set a + * timer for 30 ms: + * @code SDL_SetTimer((33/10)*10, flag_update); @endcode + * + * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). + * + * Under UNIX, you should not use raise or use SIGALRM and this function + * in the same program, as it is implemented using setitimer(). You also + * should not use this function in multi-threaded applications as signals + * to multi-threaded apps have undefined behavior in some implementations. + * + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); + +/** @name New timer API + * New timer API, supports multiple timers + * Written by Stephane Peter + */ +/*@{*/ + +/** + * Function prototype for the new timer callback function. + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); + +/** Definition of the timer ID type */ +typedef struct _SDL_TimerID *SDL_TimerID; + +/** Add a new timer to the pool of timers already running. + * Returns a timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); + +/** + * Remove one of the multiple timers knowing its ID. + * Returns a boolean value indicating success. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); + +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_types.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_types.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,28 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_types.h + * @deprecated Use SDL_stdinc.h instead. + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_version.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,91 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_version.h + * This header defines the current SDL version + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Version Number + * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + */ +/*@{*/ +#define SDL_MAJOR_VERSION 1 +#define SDL_MINOR_VERSION 2 +#define SDL_PATCHLEVEL 15 +/*@}*/ + +typedef struct SDL_version { + Uint8 major; + Uint8 minor; + Uint8 patch; +} SDL_version; + +/** + * This macro can be used to fill a version structure with the compile-time + * version of the SDL library. + */ +#define SDL_VERSION(X) \ +{ \ + (X)->major = SDL_MAJOR_VERSION; \ + (X)->minor = SDL_MINOR_VERSION; \ + (X)->patch = SDL_PATCHLEVEL; \ +} + +/** This macro turns the version numbers into a numeric value: + * (1,2,3) -> (1203) + * This assumes that there will never be more than 100 patchlevels + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** This is the version number macro for the current SDL version */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** This function gets the version of the dynamically linked SDL library. + * it should NOT be used to fill a version structure, instead you should + * use the SDL_Version() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/SDL_video.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/SDL_video.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,951 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_video.h + * Header file for access to the SDL raw framebuffer window + */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Transparency definitions + * These define alpha as the opacity of a surface + */ +/*@{*/ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/*@}*/ + +/** @name Useful data types */ +/*@{*/ +typedef struct SDL_Rect { + Sint16 x, y; + Uint16 w, h; +} SDL_Rect; + +typedef struct SDL_Color { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 unused; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette { + int ncolors; + SDL_Color *colors; +} SDL_Palette; +/*@}*/ + +/** Everything in the pixel format structure is read-only */ +typedef struct SDL_PixelFormat { + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + + /** RGB color key information */ + Uint32 colorkey; + /** Alpha value information (per-surface alpha) */ + Uint8 alpha; +} SDL_PixelFormat; + +/** This structure should be treated as read-only, except for 'pixels', + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface { + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + Uint16 pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + int offset; /**< Private */ + + /** Hardware-specific surface info */ + struct private_hwdata *hwdata; + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + Uint32 unused1; /**< for binary compatibility */ + + /** Allow recursive locks */ + Uint32 locked; /**< Private */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** format version, bumped at every change to invalidate blit maps */ + unsigned int format_version; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** @name SDL_Surface Flags + * These are the currently supported flags for the SDL_surface + */ +/*@{*/ + +/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ +/*@{*/ +#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */ +#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */ +#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */ +/*@}*/ + +/** Available for SDL_SetVideoMode() */ +/*@{*/ +#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */ +#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */ +#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */ +#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */ +#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */ +#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */ +#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */ +#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ +/*@}*/ + +/** Used internally (read-only) */ +/*@{*/ +#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */ +#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */ +#define SDL_RLEACCELOK 0x00002000 /**< Private flag */ +#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */ +#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */ +#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */ +/*@}*/ + +/*@}*/ + +/** Evaluates to true if the surface needs to be locked before access */ +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) + +/** typedef for private surface blitting functions */ +typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, + struct SDL_Surface *dst, SDL_Rect *dstrect); + + +/** Useful for determining the video hardware capabilities */ +typedef struct SDL_VideoInfo { + Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */ + Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */ + Uint32 UnusedBits1 :6; + Uint32 UnusedBits2 :1; + Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */ + Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */ + Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */ + Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */ + Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */ + Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */ + Uint32 blit_fill :1; /**< Flag: Accelerated color fill */ + Uint32 UnusedBits3 :16; + Uint32 video_mem; /**< The total amount of video memory (in K) */ + SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */ + int current_w; /**< Value: The current video mode width */ + int current_h; /**< Value: The current video mode height */ +} SDL_VideoInfo; + + +/** @name Overlay Formats + * The most common video overlay formats. + * For an explanation of these pixel formats, see: + * http://www.webartz.com/fourcc/indexyuv.htm + * + * For information on the relationship between color spaces, see: + * http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + */ +/*@{*/ +#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */ +#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */ +#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ +#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ +#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ +/*@}*/ + +/** The YUV hardware video overlay */ +typedef struct SDL_Overlay { + Uint32 format; /**< Read-only */ + int w, h; /**< Read-only */ + int planes; /**< Read-only */ + Uint16 *pitches; /**< Read-only */ + Uint8 **pixels; /**< Read-write */ + + /** @name Hardware-specific surface info */ + /*@{*/ + struct private_yuvhwfuncs *hwfuncs; + struct private_yuvhwdata *hwdata; + /*@{*/ + + /** @name Special flags */ + /*@{*/ + Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */ + Uint32 UnusedBits :31; + /*@}*/ +} SDL_Overlay; + + +/** Public enumeration for setting the OpenGL window attributes. */ +typedef enum { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_SWAP_CONTROL +} SDL_GLattr; + +/** @name flags for SDL_SetPalette() */ +/*@{*/ +#define SDL_LOGPAL 0x01 +#define SDL_PHYSPAL 0x02 +/*@}*/ + +/* Function prototypes */ + +/** + * @name Video Init and Quit + * These functions are used internally, and should not be used unless you + * have a specific need to specify the video driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/*@{*/ +/** + * Initializes the video subsystem. Sets up a connection + * to the window manager, etc, and determines the current video mode and + * pixel format, but does not initialize a window or graphics mode. + * Note that event handling is activated by this routine. + * + * If you use both sound and video in your application, you need to call + * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + * you won't be able to set full-screen display modes. + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); +/*@}*/ + +/** + * This function fills the given character buffer with the name of the + * video driver, and returns a pointer to it if the video driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); + +/** + * This function returns a pointer to the current display surface. + * If SDL is doing format conversion on the display surface, this + * function returns the publicly visible surface, not the real video + * surface. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); + +/** + * This function returns a read-only pointer to information about the + * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + * member of the returned structure will contain the pixel format of the + * "best" video mode. + */ +extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); + +/** + * Check to see if a particular video mode is supported. + * It returns 0 if the requested mode is not supported under any bit depth, + * or returns the bits-per-pixel of the closest available mode with the + * given width and height. If this bits-per-pixel is different from the + * one used when setting the video mode, SDL_SetVideoMode() will succeed, + * but will emulate the requested bits-per-pixel with a shadow surface. + * + * The arguments to SDL_VideoModeOK() are the same ones you would pass to + * SDL_SetVideoMode() + */ +extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); + +/** + * Return a pointer to an array of available screen dimensions for the + * given format and video flags, sorted largest to smallest. Returns + * NULL if there are no dimensions available for a particular format, + * or (SDL_Rect **)-1 if any dimension is okay for the given format. + * + * If 'format' is NULL, the mode list will be for the format given + * by SDL_GetVideoInfo()->vfmt + */ +extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); + +/** + * Set up a video mode with the specified width, height and bits-per-pixel. + * + * If 'bpp' is 0, it is treated as the current display bits per pixel. + * + * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + * requested bits-per-pixel, but will return whatever video pixel format is + * available. The default is to emulate the requested pixel format if it + * is not natively available. + * + * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + * video memory, if possible, and you may have to call SDL_LockSurface() + * in order to access the raw framebuffer. Otherwise, the video surface + * will be created in system memory. + * + * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + * updates asynchronously, but you must always lock before accessing pixels. + * SDL will wait for updates to complete before returning from the lock. + * + * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + * that the colors set by SDL_SetColors() will be the colors you get. + * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + * of the colors exactly the way they are requested, and you should look + * at the video surface structure to determine the actual palette. + * If SDL cannot guarantee that the colors you request can be set, + * i.e. if the colormap is shared, then the video surface may be created + * under emulation in system memory, overriding the SDL_HWSURFACE flag. + * + * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + * a fullscreen video mode. The default is to create a windowed mode + * if the current graphics system has a window manager. + * If the SDL library is able to set a fullscreen video mode, this flag + * will be set in the surface that is returned. + * + * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + * two surfaces in video memory and swap between them when you call + * SDL_Flip(). This is usually slower than the normal single-buffering + * scheme, but prevents "tearing" artifacts caused by modifying video + * memory while the monitor is refreshing. It should only be used by + * applications that redraw the entire screen on every update. + * + * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the + * window manager, if any, to resize the window at runtime. When this + * occurs, SDL will send a SDL_VIDEORESIZE event to you application, + * and you must respond to the event by re-calling SDL_SetVideoMode() + * with the requested size (or another size that suits the application). + * + * If SDL_NOFRAME is set in 'flags', the SDL library will create a window + * without any title bar or frame decoration. Fullscreen video modes have + * this flag set automatically. + * + * This function returns the video framebuffer surface, or NULL if it fails. + * + * If you rely on functionality provided by certain video flags, check the + * flags of the returned surface to make sure that functionality is available. + * SDL will fall back to reduced functionality if the exact flags you wanted + * are not available. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode + (int width, int height, int bpp, Uint32 flags); + +/** @name SDL_Update Functions + * These functions should not be called while 'screen' is locked. + */ +/*@{*/ +/** + * Makes sure the given list of rectangles is updated on the given screen. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRects + (SDL_Surface *screen, int numrects, SDL_Rect *rects); +/** + * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + * screen. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRect + (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); +/*@}*/ + +/** + * On hardware that supports double-buffering, this function sets up a flip + * and returns. The hardware will wait for vertical retrace, and then swap + * video buffers before the next video surface blit or lock will return. + * On hardware that doesn not support double-buffering, this is equivalent + * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + * setting the video mode for this function to perform hardware flipping. + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); + +/** + * Set the gamma correction for each of the color channels. + * The gamma values range (approximately) between 0.1 and 10.0 + * + * If this function isn't supported directly by the hardware, it will + * be emulated using gamma ramps, if available. If successful, this + * function returns 0, otherwise it returns -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); + +/** + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * You may pass NULL for any of the channels to leave it unchanged. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); + +/** + * Retrieve the current values of the gamma translation tables. + * + * You must pass in valid pointers to arrays of 256 16-bit quantities. + * Any of the pointers may be NULL to ignore that channel. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/** + * Sets a portion of the colormap for the given 8-bit surface. If 'surface' + * is not a palettized surface, this function does nothing, returning 0. + * If all of the colors were set as passed to SDL_SetColors(), it will + * return 1. If not all the color entries were set exactly as given, + * it will return 0, and you should look at the surface palette to + * determine the actual color palette. + * + * When 'surface' is the surface associated with the current display, the + * display colormap will be updated with the requested colors. If + * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + * will always return 1, and the palette is guaranteed to be set the way + * you desire, even if the window colormap has to be warped or run under + * emulation. + */ +extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, + SDL_Color *colors, int firstcolor, int ncolors); + +/** + * Sets a portion of the colormap for a given 8-bit surface. + * 'flags' is one or both of: + * SDL_LOGPAL -- set logical palette, which controls how blits are mapped + * to/from the surface, + * SDL_PHYSPAL -- set physical palette, which controls how pixels look on + * the screen + * Only screens have physical palettes. Separate change of physical/logical + * palettes is only possible if the screen has SDL_HWPALETTE set. + * + * The return value is 1 if all colours could be set as requested, and 0 + * otherwise. + * + * SDL_SetColors() is equivalent to calling this function with + * flags = (SDL_LOGPAL|SDL_PHYSPAL). + */ +extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, + SDL_Color *colors, int firstcolor, + int ncolors); + +/** + * Maps an RGB triple to an opaque pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b); + +/** + * Maps an RGBA quadruple to a pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a); + +/** + * Maps a pixel value into the RGB components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * const fmt, + Uint8 *r, Uint8 *g, Uint8 *b); + +/** + * Maps a pixel value into the RGBA components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * const fmt, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/** @sa SDL_CreateRGBSurface */ +#define SDL_AllocSurface SDL_CreateRGBSurface +/** + * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * If the function runs out of memory, it will return NULL. + * + * The 'flags' tell what kind of surface to create. + * SDL_SWSURFACE means that the surface should be created in system memory. + * SDL_HWSURFACE means that the surface should be created in video memory, + * with the same format as the display surface. This is useful for surfaces + * that will not change much, to take advantage of hardware acceleration + * when being blitted to the display surface. + * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + * this surface, but you must always lock it before accessing the pixels. + * SDL will wait for current blits to finish before returning from the lock. + * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + * If the hardware supports acceleration of colorkey blits between + * two surfaces in video memory, SDL will try to place the surface in + * video memory. If this isn't possible or if there is no hardware + * acceleration available, the surface will be placed in system memory. + * SDL_SRCALPHA means that the surface will be used for alpha blits and + * if the hardware supports hardware acceleration of alpha blits between + * two surfaces in video memory, to place the surface in video memory + * if possible, otherwise it will be placed in system memory. + * If the surface is created in video memory, blits will be _much_ faster, + * but the surface format must be identical to the video surface format, + * and the only way to access the pixels member of the surface is to use + * the SDL_LockSurface() and SDL_UnlockSurface() calls. + * If the requested surface actually resides in video memory, SDL_HWSURFACE + * will be set in the flags member of the returned surface. If for some + * reason the surface could not be placed in video memory, it will not have + * the SDL_HWSURFACE flag set, and will be created in system memory instead. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +/** @sa SDL_CreateRGBSurface */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); + +/** + * SDL_LockSurface() sets up a surface for directly accessing the pixels. + * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + * to and read from 'surface->pixels', using the pixel format stored in + * 'surface->format'. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. In particular, if the + * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + * will not need to lock the display surface before accessing it. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); + +/** + * Load a surface from a seekable SDL data source (memory or file.) + * If 'freesrc' is non-zero, the source will be closed after being read. + * Returns the new surface, or NULL if there was an error. + * The new surface should be freed with SDL_FreeSurface(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); + +/** Convenience macro -- load a surface from a file */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data source (memory or file.) + * If 'freedst' is non-zero, the source will be closed after being written. + * Returns 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface *surface, SDL_RWops *dst, int freedst); + +/** Convenience macro -- save a surface to a file */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * Sets the color key (transparent pixel) in a blittable surface. + * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + * 'key' will be the transparent pixel in the source image of a blit. + * SDL_RLEACCEL requests RLE acceleration for the surface if present, + * and removes RLE acceleration if absent. + * If 'flag' is 0, this function clears any current color key. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey + (SDL_Surface *surface, Uint32 flag, Uint32 key); + +/** + * This function sets the alpha value for the entire surface, as opposed to + * using the alpha component of each pixel. This value measures the range + * of transparency of the surface, 0 being completely transparent to 255 + * being completely opaque. An 'alpha' value of 255 causes blits to be + * opaque, the source pixels copied to the destination (the default). Note + * that per-surface alpha can be combined with colorkey transparency. + * + * If 'flag' is 0, alpha blending is disabled for the surface. + * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. + * + * The 'alpha' parameter is ignored for surfaces that have an alpha channel. + */ +extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * 'rect' must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + * + * This function is used internally by SDL_DisplayFormat(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); + +/** + * This performs a fast blit from the source surface to the destination + * surface. It assumes that the source and destination rectangles are + * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + * surface (src or dst) is copied. The final blit rectangles are saved + * in 'srcrect' and 'dstrect' after all clipping is performed. + * If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without alpha and colorkey + * are defined as follows: + * + * RGBA->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using alpha-channel). + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value); + * set destination alpha to opaque. + * SDL_SRCALPHA not set: + * copy RGB, set destination alpha to source per-surface alpha value. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * RGBA->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source alpha channel) the RGB values; + * leave destination alpha untouched. [Note: is this correct?] + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value). + * SDL_SRCALPHA not set: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * If either of the surfaces were in video memory, and the blit returns -2, + * the video memory was lost, so it should be reloaded with artwork and + * re-blitted: + * @code + * while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { + * while ( SDL_LockSurface(image) < 0 ) + * Sleep(10); + * -- Write image pixels to image->pixels -- + * SDL_UnlockSurface(image); + * } + * @endcode + * + * This happens under DirectX 5.0 when the system switches away from your + * fullscreen application. The lock will also fail until you have access + * to the video memory again. + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); +/** This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/** + * This function performs a fast fill of the given rectangle with 'color' + * The given rectangle is clipped to the destination surface clip area + * and the final fill rectangle is saved in the passed in pointer. + * If 'dstrect' is NULL, the whole surface will be filled with 'color' + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * This function returns 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/** + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer, suitable for fast + * blitting onto the display surface. It calls SDL_ConvertSurface() + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); + +/** + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer (if possible), + * suitable for fast alpha blitting onto the display surface. + * The new surface will always have an alpha channel. + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name YUV video surface overlay functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** This function creates a video output overlay + * Calling the returned surface an overlay is something of a misnomer because + * the contents of the display surface underneath the area where the overlay + * is shown is undefined - it may be overwritten with the converted YUV data. + */ +extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, + Uint32 format, SDL_Surface *display); + +/** Lock an overlay for direct access, and unlock it when you are done */ +extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); +extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); + +/** Blit a video overlay to the display surface. + * The contents of the video surface underneath the blit destination are + * not defined. + * The width and height of the destination rectangle may be different from + * that of the overlay, but currently only 2x scaling is supported. + */ +extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); + +/** Free a video overlay */ +extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name OpenGL support functions. */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Dynamically load an OpenGL library, or the default one if path is NULL + * + * If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * Get the address of a GL function + */ +extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); + +/** + * Set an attribute of the OpenGL subsystem before intialization. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * Get an attribute of the OpenGL subsystem from the windowing + * interface, such as glX. This is of course different from getting + * the values from SDL's internal OpenGL subsystem, which only + * stores the values you request before initialization. + * + * Developers should track the values they pass into SDL_GL_SetAttribute + * themselves if they want to retrieve these values. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); + +/** + * Swap the OpenGL buffers, if double-buffering is supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); + +/** @name OpenGL Internal Functions + * Internal functions that should not be called unless you have read + * and understood the source code for these functions. + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); +extern DECLSPEC void SDLCALL SDL_GL_Lock(void); +extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); +/*@}*/ + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Window Manager Functions */ +/** These functions allow interaction with the window manager, if any. */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Sets the title and icon text of the display window (UTF-8 encoded) + */ +extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); +/** + * Gets the title and icon text of the display window (UTF-8 encoded) + */ +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); + +/** + * Sets the icon for the display window. + * This function must be called before the first call to SDL_SetVideoMode(). + * It takes an icon surface, and a mask in MSB format. + * If 'mask' is NULL, the entire icon surface will be used as the icon. + */ +extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); + +/** + * This function iconifies the window, and returns 1 if it succeeded. + * If the function succeeds, it generates an SDL_APPACTIVE loss event. + * This function is a noop and returns 0 in non-windowed environments. + */ +extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); + +/** + * Toggle fullscreen mode without changing the contents of the screen. + * If the display surface does not require locking before accessing + * the pixel information, then the memory pointers will not change. + * + * If this function was able to toggle fullscreen mode (change from + * running in a window to fullscreen, or vice-versa), it will return 1. + * If it is not implemented, or fails, it returns 0. + * + * The next call to SDL_SetVideoMode() will set the mode fullscreen + * attribute based on the flags parameter - if SDL_FULLSCREEN is not + * set, then the display will be windowed by default where supported. + * + * This is currently only implemented in the X11 video driver. + */ +extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); + +typedef enum { + SDL_GRAB_QUERY = -1, + SDL_GRAB_OFF = 0, + SDL_GRAB_ON = 1, + SDL_GRAB_FULLSCREEN /**< Used internally */ +} SDL_GrabMode; +/** + * This function allows you to set and query the input grab state of + * the application. It returns the new input grab state. + * + * Grabbing means that the mouse is confined to the application window, + * and nearly all keyboard input is passed directly to the application, + * and not interpreted by a window manager, if any. + */ +extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); + +/*@}*/ + +/** @internal Not in public API at the moment - do not use! */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/begin_code.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/begin_code.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,196 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file begin_code.h + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/** + * @file begin_code.h + * This shouldn't be nested -- included it around code only. + */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +/** + * @def DECLSPEC + * Some compilers use a special export keyword + */ +#ifndef DECLSPEC +# if defined(__BEOS__) || defined(__HAIKU__) +# if defined(__GNUC__) +# define DECLSPEC +# else +# define DECLSPEC __declspec(export) +# endif +# elif defined(__WIN32__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef __WATCOMC__ +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# elif defined (__GNUC__) && __GNUC__ < 4 +# /* Added support for GCC-EMX = 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/** + * @def SDLCALL + * By default SDL uses the C calling convention + */ +#ifndef SDLCALL +# if defined(__WIN32__) && !defined(__GNUC__) +# define SDLCALL __cdecl +# elif defined(__OS2__) +# if defined (__GNUC__) && __GNUC__ < 4 +# /* Added support for GCC-EMX +#include "libavutil/samplefmt.h" +#include "libavutil/avutil.h" +#include "libavutil/cpu.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" + +#include "libavcodec/version.h" +/** + * @defgroup libavc Encoding/Decoding Library + * @{ + * + * @defgroup lavc_decoding Decoding + * @{ + * @} + * + * @defgroup lavc_encoding Encoding + * @{ + * @} + * + * @defgroup lavc_codec Codecs + * @{ + * @defgroup lavc_codec_native Native Codecs + * @{ + * @} + * @defgroup lavc_codec_wrappers External library wrappers + * @{ + * @} + * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge + * @{ + * @} + * @} + * @defgroup lavc_internal Internal + * @{ + * @} + * @} + * + */ + +/** + * @defgroup lavc_core Core functions/structures. + * @ingroup libavc + * + * Basic definitions, functions for querying libavcodec capabilities, + * allocating core structures, etc. + * @{ + */ + + +/** + * Identify the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of a existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs. + * + * After adding new codec IDs, do not forget to add an entry to the codec + * descriptor list and bump libavcodec minor version. + */ +enum AVCodecID { + AV_CODEC_ID_NONE, + + /* video codecs */ + AV_CODEC_ID_MPEG1VIDEO, + AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + AV_CODEC_ID_MPEG2VIDEO_XVMC, + AV_CODEC_ID_H261, + AV_CODEC_ID_H263, + AV_CODEC_ID_RV10, + AV_CODEC_ID_RV20, + AV_CODEC_ID_MJPEG, + AV_CODEC_ID_MJPEGB, + AV_CODEC_ID_LJPEG, + AV_CODEC_ID_SP5X, + AV_CODEC_ID_JPEGLS, + AV_CODEC_ID_MPEG4, + AV_CODEC_ID_RAWVIDEO, + AV_CODEC_ID_MSMPEG4V1, + AV_CODEC_ID_MSMPEG4V2, + AV_CODEC_ID_MSMPEG4V3, + AV_CODEC_ID_WMV1, + AV_CODEC_ID_WMV2, + AV_CODEC_ID_H263P, + AV_CODEC_ID_H263I, + AV_CODEC_ID_FLV1, + AV_CODEC_ID_SVQ1, + AV_CODEC_ID_SVQ3, + AV_CODEC_ID_DVVIDEO, + AV_CODEC_ID_HUFFYUV, + AV_CODEC_ID_CYUV, + AV_CODEC_ID_H264, + AV_CODEC_ID_INDEO3, + AV_CODEC_ID_VP3, + AV_CODEC_ID_THEORA, + AV_CODEC_ID_ASV1, + AV_CODEC_ID_ASV2, + AV_CODEC_ID_FFV1, + AV_CODEC_ID_4XM, + AV_CODEC_ID_VCR1, + AV_CODEC_ID_CLJR, + AV_CODEC_ID_MDEC, + AV_CODEC_ID_ROQ, + AV_CODEC_ID_INTERPLAY_VIDEO, + AV_CODEC_ID_XAN_WC3, + AV_CODEC_ID_XAN_WC4, + AV_CODEC_ID_RPZA, + AV_CODEC_ID_CINEPAK, + AV_CODEC_ID_WS_VQA, + AV_CODEC_ID_MSRLE, + AV_CODEC_ID_MSVIDEO1, + AV_CODEC_ID_IDCIN, + AV_CODEC_ID_8BPS, + AV_CODEC_ID_SMC, + AV_CODEC_ID_FLIC, + AV_CODEC_ID_TRUEMOTION1, + AV_CODEC_ID_VMDVIDEO, + AV_CODEC_ID_MSZH, + AV_CODEC_ID_ZLIB, + AV_CODEC_ID_QTRLE, + AV_CODEC_ID_SNOW, + AV_CODEC_ID_TSCC, + AV_CODEC_ID_ULTI, + AV_CODEC_ID_QDRAW, + AV_CODEC_ID_VIXL, + AV_CODEC_ID_QPEG, + AV_CODEC_ID_PNG, + AV_CODEC_ID_PPM, + AV_CODEC_ID_PBM, + AV_CODEC_ID_PGM, + AV_CODEC_ID_PGMYUV, + AV_CODEC_ID_PAM, + AV_CODEC_ID_FFVHUFF, + AV_CODEC_ID_RV30, + AV_CODEC_ID_RV40, + AV_CODEC_ID_VC1, + AV_CODEC_ID_WMV3, + AV_CODEC_ID_LOCO, + AV_CODEC_ID_WNV1, + AV_CODEC_ID_AASC, + AV_CODEC_ID_INDEO2, + AV_CODEC_ID_FRAPS, + AV_CODEC_ID_TRUEMOTION2, + AV_CODEC_ID_BMP, + AV_CODEC_ID_CSCD, + AV_CODEC_ID_MMVIDEO, + AV_CODEC_ID_ZMBV, + AV_CODEC_ID_AVS, + AV_CODEC_ID_SMACKVIDEO, + AV_CODEC_ID_NUV, + AV_CODEC_ID_KMVC, + AV_CODEC_ID_FLASHSV, + AV_CODEC_ID_CAVS, + AV_CODEC_ID_JPEG2000, + AV_CODEC_ID_VMNC, + AV_CODEC_ID_VP5, + AV_CODEC_ID_VP6, + AV_CODEC_ID_VP6F, + AV_CODEC_ID_TARGA, + AV_CODEC_ID_DSICINVIDEO, + AV_CODEC_ID_TIERTEXSEQVIDEO, + AV_CODEC_ID_TIFF, + AV_CODEC_ID_GIF, + AV_CODEC_ID_DXA, + AV_CODEC_ID_DNXHD, + AV_CODEC_ID_THP, + AV_CODEC_ID_SGI, + AV_CODEC_ID_C93, + AV_CODEC_ID_BETHSOFTVID, + AV_CODEC_ID_PTX, + AV_CODEC_ID_TXD, + AV_CODEC_ID_VP6A, + AV_CODEC_ID_AMV, + AV_CODEC_ID_VB, + AV_CODEC_ID_PCX, + AV_CODEC_ID_SUNRAST, + AV_CODEC_ID_INDEO4, + AV_CODEC_ID_INDEO5, + AV_CODEC_ID_MIMIC, + AV_CODEC_ID_RL2, + AV_CODEC_ID_ESCAPE124, + AV_CODEC_ID_DIRAC, + AV_CODEC_ID_BFI, + AV_CODEC_ID_CMV, + AV_CODEC_ID_MOTIONPIXELS, + AV_CODEC_ID_TGV, + AV_CODEC_ID_TGQ, + AV_CODEC_ID_TQI, + AV_CODEC_ID_AURA, + AV_CODEC_ID_AURA2, + AV_CODEC_ID_V210X, + AV_CODEC_ID_TMV, + AV_CODEC_ID_V210, + AV_CODEC_ID_DPX, + AV_CODEC_ID_MAD, + AV_CODEC_ID_FRWU, + AV_CODEC_ID_FLASHSV2, + AV_CODEC_ID_CDGRAPHICS, + AV_CODEC_ID_R210, + AV_CODEC_ID_ANM, + AV_CODEC_ID_BINKVIDEO, + AV_CODEC_ID_IFF_ILBM, + AV_CODEC_ID_IFF_BYTERUN1, + AV_CODEC_ID_KGV1, + AV_CODEC_ID_YOP, + AV_CODEC_ID_VP8, + AV_CODEC_ID_PICTOR, + AV_CODEC_ID_ANSI, + AV_CODEC_ID_A64_MULTI, + AV_CODEC_ID_A64_MULTI5, + AV_CODEC_ID_R10K, + AV_CODEC_ID_MXPEG, + AV_CODEC_ID_LAGARITH, + AV_CODEC_ID_PRORES, + AV_CODEC_ID_JV, + AV_CODEC_ID_DFA, + AV_CODEC_ID_WMV3IMAGE, + AV_CODEC_ID_VC1IMAGE, + AV_CODEC_ID_UTVIDEO, + AV_CODEC_ID_BMV_VIDEO, + AV_CODEC_ID_VBLE, + AV_CODEC_ID_DXTORY, + AV_CODEC_ID_V410, + AV_CODEC_ID_XWD, + AV_CODEC_ID_CDXL, + AV_CODEC_ID_XBM, + AV_CODEC_ID_ZEROCODEC, + AV_CODEC_ID_MSS1, + AV_CODEC_ID_MSA1, + AV_CODEC_ID_TSCC2, + AV_CODEC_ID_MTS2, + AV_CODEC_ID_CLLC, + AV_CODEC_ID_MSS2, + + /* various PCM "codecs" */ + AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs + AV_CODEC_ID_PCM_S16LE = 0x10000, + AV_CODEC_ID_PCM_S16BE, + AV_CODEC_ID_PCM_U16LE, + AV_CODEC_ID_PCM_U16BE, + AV_CODEC_ID_PCM_S8, + AV_CODEC_ID_PCM_U8, + AV_CODEC_ID_PCM_MULAW, + AV_CODEC_ID_PCM_ALAW, + AV_CODEC_ID_PCM_S32LE, + AV_CODEC_ID_PCM_S32BE, + AV_CODEC_ID_PCM_U32LE, + AV_CODEC_ID_PCM_U32BE, + AV_CODEC_ID_PCM_S24LE, + AV_CODEC_ID_PCM_S24BE, + AV_CODEC_ID_PCM_U24LE, + AV_CODEC_ID_PCM_U24BE, + AV_CODEC_ID_PCM_S24DAUD, + AV_CODEC_ID_PCM_ZORK, + AV_CODEC_ID_PCM_S16LE_PLANAR, + AV_CODEC_ID_PCM_DVD, + AV_CODEC_ID_PCM_F32BE, + AV_CODEC_ID_PCM_F32LE, + AV_CODEC_ID_PCM_F64BE, + AV_CODEC_ID_PCM_F64LE, + AV_CODEC_ID_PCM_BLURAY, + AV_CODEC_ID_PCM_LXF, + AV_CODEC_ID_S302M, + AV_CODEC_ID_PCM_S8_PLANAR, + + /* various ADPCM codecs */ + AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, + AV_CODEC_ID_ADPCM_IMA_WAV, + AV_CODEC_ID_ADPCM_IMA_DK3, + AV_CODEC_ID_ADPCM_IMA_DK4, + AV_CODEC_ID_ADPCM_IMA_WS, + AV_CODEC_ID_ADPCM_IMA_SMJPEG, + AV_CODEC_ID_ADPCM_MS, + AV_CODEC_ID_ADPCM_4XM, + AV_CODEC_ID_ADPCM_XA, + AV_CODEC_ID_ADPCM_ADX, + AV_CODEC_ID_ADPCM_EA, + AV_CODEC_ID_ADPCM_G726, + AV_CODEC_ID_ADPCM_CT, + AV_CODEC_ID_ADPCM_SWF, + AV_CODEC_ID_ADPCM_YAMAHA, + AV_CODEC_ID_ADPCM_SBPRO_4, + AV_CODEC_ID_ADPCM_SBPRO_3, + AV_CODEC_ID_ADPCM_SBPRO_2, + AV_CODEC_ID_ADPCM_THP, + AV_CODEC_ID_ADPCM_IMA_AMV, + AV_CODEC_ID_ADPCM_EA_R1, + AV_CODEC_ID_ADPCM_EA_R3, + AV_CODEC_ID_ADPCM_EA_R2, + AV_CODEC_ID_ADPCM_IMA_EA_SEAD, + AV_CODEC_ID_ADPCM_IMA_EA_EACS, + AV_CODEC_ID_ADPCM_EA_XAS, + AV_CODEC_ID_ADPCM_EA_MAXIS_XA, + AV_CODEC_ID_ADPCM_IMA_ISS, + AV_CODEC_ID_ADPCM_G722, + AV_CODEC_ID_ADPCM_IMA_APC, + + /* AMR */ + AV_CODEC_ID_AMR_NB = 0x12000, + AV_CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + AV_CODEC_ID_RA_144 = 0x13000, + AV_CODEC_ID_RA_288, + + /* various DPCM codecs */ + AV_CODEC_ID_ROQ_DPCM = 0x14000, + AV_CODEC_ID_INTERPLAY_DPCM, + AV_CODEC_ID_XAN_DPCM, + AV_CODEC_ID_SOL_DPCM, + + /* audio codecs */ + AV_CODEC_ID_MP2 = 0x15000, + AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + AV_CODEC_ID_AAC, + AV_CODEC_ID_AC3, + AV_CODEC_ID_DTS, + AV_CODEC_ID_VORBIS, + AV_CODEC_ID_DVAUDIO, + AV_CODEC_ID_WMAV1, + AV_CODEC_ID_WMAV2, + AV_CODEC_ID_MACE3, + AV_CODEC_ID_MACE6, + AV_CODEC_ID_VMDAUDIO, + AV_CODEC_ID_FLAC, + AV_CODEC_ID_MP3ADU, + AV_CODEC_ID_MP3ON4, + AV_CODEC_ID_SHORTEN, + AV_CODEC_ID_ALAC, + AV_CODEC_ID_WESTWOOD_SND1, + AV_CODEC_ID_GSM, ///< as in Berlin toast format + AV_CODEC_ID_QDM2, + AV_CODEC_ID_COOK, + AV_CODEC_ID_TRUESPEECH, + AV_CODEC_ID_TTA, + AV_CODEC_ID_SMACKAUDIO, + AV_CODEC_ID_QCELP, + AV_CODEC_ID_WAVPACK, + AV_CODEC_ID_DSICINAUDIO, + AV_CODEC_ID_IMC, + AV_CODEC_ID_MUSEPACK7, + AV_CODEC_ID_MLP, + AV_CODEC_ID_GSM_MS, /* as found in WAV */ + AV_CODEC_ID_ATRAC3, + AV_CODEC_ID_VOXWARE, + AV_CODEC_ID_APE, + AV_CODEC_ID_NELLYMOSER, + AV_CODEC_ID_MUSEPACK8, + AV_CODEC_ID_SPEEX, + AV_CODEC_ID_WMAVOICE, + AV_CODEC_ID_WMAPRO, + AV_CODEC_ID_WMALOSSLESS, + AV_CODEC_ID_ATRAC3P, + AV_CODEC_ID_EAC3, + AV_CODEC_ID_SIPR, + AV_CODEC_ID_MP1, + AV_CODEC_ID_TWINVQ, + AV_CODEC_ID_TRUEHD, + AV_CODEC_ID_MP4ALS, + AV_CODEC_ID_ATRAC1, + AV_CODEC_ID_BINKAUDIO_RDFT, + AV_CODEC_ID_BINKAUDIO_DCT, + AV_CODEC_ID_AAC_LATM, + AV_CODEC_ID_QDMC, + AV_CODEC_ID_CELT, + AV_CODEC_ID_G723_1, + AV_CODEC_ID_G729, + AV_CODEC_ID_8SVX_EXP, + AV_CODEC_ID_8SVX_FIB, + AV_CODEC_ID_BMV_AUDIO, + AV_CODEC_ID_RALF, + AV_CODEC_ID_IAC, + AV_CODEC_ID_ILBC, + AV_CODEC_ID_OPUS, + + /* subtitle codecs */ + AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. + AV_CODEC_ID_DVD_SUBTITLE = 0x17000, + AV_CODEC_ID_DVB_SUBTITLE, + AV_CODEC_ID_TEXT, ///< raw UTF-8 text + AV_CODEC_ID_XSUB, + AV_CODEC_ID_SSA, + AV_CODEC_ID_MOV_TEXT, + AV_CODEC_ID_HDMV_PGS_SUBTITLE, + AV_CODEC_ID_DVB_TELETEXT, + AV_CODEC_ID_SRT, + + /* other specific kind of codecs (generally used for attachments) */ + AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. + AV_CODEC_ID_TTF = 0x18000, + + AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it + + AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ + AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems + * stream (only used by libavformat) */ + AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. + +#if FF_API_CODEC_ID +#include "old_codec_ids.h" +#endif +}; + +#if FF_API_CODEC_ID +#define CodecID AVCodecID +#endif + +/** + * This struct describes the properties of a single codec described by an + * AVCodecID. + * @see avcodec_get_descriptor() + */ +typedef struct AVCodecDescriptor { + enum AVCodecID id; + enum AVMediaType type; + /** + * Name of the codec described by this descriptor. It is non-empty and + * unique for each codec descriptor. It should contain alphanumeric + * characters and '_' only. + */ + const char *name; + /** + * A more descriptive name for this codec. May be NULL. + */ + const char *long_name; + /** + * Codec properties, a combination of AV_CODEC_PROP_* flags. + */ + int props; +} AVCodecDescriptor; + +/** + * Codec uses only intra compression. + * Video codecs only. + */ +#define AV_CODEC_PROP_INTRA_ONLY (1 << 0) +/** + * Codec supports lossy compression. Audio and video codecs only. + * @note a codec may support both lossy and lossless + * compression modes + */ +#define AV_CODEC_PROP_LOSSY (1 << 1) +/** + * Codec supports lossless compression. Audio and video codecs only. + */ +#define AV_CODEC_PROP_LOSSLESS (1 << 2) + +#if FF_API_OLD_DECODE_AUDIO +/* in bytes */ +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio +#endif + +/** + * @ingroup lavc_decoding + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
    + * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + */ +#define FF_INPUT_BUFFER_PADDING_SIZE 8 + +/** + * @ingroup lavc_encoding + * minimum encoding buffer size + * Used to avoid some checks during header writing. + */ +#define FF_MIN_BUFFER_SIZE 16384 + + +/** + * @ingroup lavc_encoding + * motion estimation type. + */ +enum Motion_Est_ID { + ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, ///< enhanced predictive zonal search + ME_X1, ///< reserved for experiments + ME_HEX, ///< hexagon based search + ME_UMH, ///< uneven multi-hexagon search + ME_ITER, ///< iterative search + ME_TESA, ///< transformed exhaustive search algorithm +}; + +/** + * @ingroup lavc_decoding + */ +enum AVDiscard{ + /* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). */ + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + +enum AVColorPrimaries{ + AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED = 2, + AVCOL_PRI_BT470M = 4, + AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above + AVCOL_PRI_FILM = 8, + AVCOL_PRI_NB , ///< Not part of ABI +}; + +enum AVColorTransferCharacteristic{ + AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED = 2, + AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG + AVCOL_TRC_SMPTE240M = 7, + AVCOL_TRC_NB , ///< Not part of ABI +}; + +enum AVColorSpace{ + AVCOL_SPC_RGB = 0, + AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED = 2, + AVCOL_SPC_FCC = 4, + AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M = 7, + AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 + AVCOL_SPC_NB , ///< Not part of ABI +}; + +enum AVColorRange{ + AVCOL_RANGE_UNSPECIFIED = 0, + AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges + AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges + AVCOL_RANGE_NB , ///< Not part of ABI +}; + +/** + * X X 3 4 X X are luma samples, + * 1 2 1-6 are possible chroma positions + * X X 5 6 X 0 is undefined/unknown position + */ +enum AVChromaLocation{ + AVCHROMA_LOC_UNSPECIFIED = 0, + AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default + AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263 + AVCHROMA_LOC_TOPLEFT = 3, ///< DV + AVCHROMA_LOC_TOP = 4, + AVCHROMA_LOC_BOTTOMLEFT = 5, + AVCHROMA_LOC_BOTTOM = 6, + AVCHROMA_LOC_NB , ///< Not part of ABI +}; + +enum AVAudioServiceType { + AV_AUDIO_SERVICE_TYPE_MAIN = 0, + AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, + AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, + AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, + AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, + AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, + AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, + AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, + AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, + AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI +}; + +/** + * @ingroup lavc_encoding + */ +typedef struct RcOverride{ + int start_frame; + int end_frame; + int qscale; // If this is 0 then quality_factor will be used instead. + float quality_factor; +} RcOverride; + +#define FF_MAX_B_FRAMES 16 + +/* encoding support + These flags can be passed in AVCodecContext.flags before initialization. + Note: Not everything is supported yet. +*/ + +#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. +#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. +#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#define CODEC_FLAG_GMC 0x0020 ///< Use GMC. +#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +/** + * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if + * this is not set the input will be copied. + */ +#define CODEC_FLAG_INPUT_PRESERVED 0x0100 +#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. +#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. +#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. +#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. +#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random + location instead of only at frame boundaries. */ +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. +#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. +#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. +#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. +#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). +/* Fx : Flag for h263+ extra options */ +#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction +#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation +#define CODEC_FLAG_CLOSED_GOP 0x80000000 +#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. +#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. +#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. +#if FF_API_MPV_GLOBAL_OPTS +#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. +#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. +#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. +#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping +#endif +#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. + +/* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independent Segment Decoding */ +/* /Fx */ +/* codec capabilities */ + +#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. +/** + * Codec uses get_buffer() for allocating buffers and supports custom allocators. + * If not set, it might not use get_buffer() at all or use operations that + * assume the buffer was allocated by avcodec_default_get_buffer. + */ +#define CODEC_CAP_DR1 0x0002 +#define CODEC_CAP_TRUNCATED 0x0008 +/* Codec can export data for HW decoding (XvMC). */ +#define CODEC_CAP_HWACCEL 0x0010 +/** + * Encoder or decoder requires flushing with NULL input at the end in order to + * give the complete and correct output. + * + * NOTE: If this flag is not set, the codec is guaranteed to never be fed with + * with NULL data. The user can still send NULL data to the public encode + * or decode function, but libavcodec will not pass it along to the codec + * unless this flag is set. + * + * Decoders: + * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. + * + * Encoders: + * The encoder needs to be fed with NULL data at the end of encoding until the + * encoder no longer returns data. + * + * NOTE: For encoders implementing the AVCodec.encode2() function, setting this + * flag also means that the encoder must set the pts and duration for + * each output packet. If this flag is not set, the pts and duration will + * be determined by libavcodec from the input frame. + */ +#define CODEC_CAP_DELAY 0x0020 +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define CODEC_CAP_SMALL_LAST_FRAME 0x0040 +/** + * Codec can export data for HW decoding (VDPAU). + */ +#define CODEC_CAP_HWACCEL_VDPAU 0x0080 +/** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carring such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + */ +#define CODEC_CAP_SUBFRAMES 0x0100 +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define CODEC_CAP_EXPERIMENTAL 0x0200 +/** + * Codec should fill in channel configuration and samplerate instead of container + */ +#define CODEC_CAP_CHANNEL_CONF 0x0400 +/** + * Codec is able to deal with negative linesizes + */ +#define CODEC_CAP_NEG_LINESIZES 0x0800 +/** + * Codec supports frame-level multithreading. + */ +#define CODEC_CAP_FRAME_THREADS 0x1000 +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define CODEC_CAP_SLICE_THREADS 0x2000 +/** + * Codec supports changed parameters at any point. + */ +#define CODEC_CAP_PARAM_CHANGE 0x4000 +/** + * Codec supports avctx->thread_count == 0 (auto). + */ +#define CODEC_CAP_AUTO_THREADS 0x8000 +/** + * Audio encoder supports receiving a different number of samples in each call. + */ +#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000 + +//The following defines may change, don't expect compatibility if you use them. +#define MB_TYPE_INTRA4x4 0x0001 +#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific +#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific +#define MB_TYPE_16x16 0x0008 +#define MB_TYPE_16x8 0x0010 +#define MB_TYPE_8x16 0x0020 +#define MB_TYPE_8x8 0x0040 +#define MB_TYPE_INTERLACED 0x0080 +#define MB_TYPE_DIRECT2 0x0100 //FIXME +#define MB_TYPE_ACPRED 0x0200 +#define MB_TYPE_GMC 0x0400 +#define MB_TYPE_SKIP 0x0800 +#define MB_TYPE_P0L0 0x1000 +#define MB_TYPE_P1L0 0x2000 +#define MB_TYPE_P0L1 0x4000 +#define MB_TYPE_P1L1 0x8000 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) +#define MB_TYPE_QUANT 0x00010000 +#define MB_TYPE_CBP 0x00020000 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +/** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + */ +typedef struct AVPanScan{ + /** + * id + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t position[3][2]; +}AVPanScan; + +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 +#define FF_QSCALE_TYPE_H264 2 +#define FF_QSCALE_TYPE_VP56 3 + +#define FF_BUFFER_TYPE_INTERNAL 1 +#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) +#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. +#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. + +#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). +#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. +#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. +#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). + +/** + * @defgroup lavc_packet AVPacket + * + * Types and functions for working with AVPacket. + * @{ + */ +enum AVPacketSideDataType { + AV_PKT_DATA_PALETTE, + AV_PKT_DATA_NEW_EXTRADATA, + + /** + * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: + * @code + * u32le param_flags + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) + * s32le channel_count + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) + * u64le channel_layout + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) + * s32le sample_rate + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) + * s32le width + * s32le height + * @endcode + */ + AV_PKT_DATA_PARAM_CHANGE, + + /** + * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of + * structures with info about macroblocks relevant to splitting the + * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). + * That is, it does not necessarily contain info about all macroblocks, + * as long as the distance between macroblocks in the info is smaller + * than the target payload size. + * Each MB info structure is 12 bytes, and is laid out as follows: + * @code + * u32le bit offset from the start of the packet + * u8 current quantizer at the start of the macroblock + * u8 GOB number + * u16le macroblock address within the GOB + * u8 horizontal MV predictor + * u8 vertical MV predictor + * u8 horizontal MV predictor for block number 3 + * u8 vertical MV predictor for block number 3 + * @endcode + */ + AV_PKT_DATA_H263_MB_INFO, +}; + +typedef struct AVPacket { + /** + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + */ + int64_t pts; + /** + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + */ + int64_t dts; + uint8_t *data; + int size; + int stream_index; + /** + * A combination of AV_PKT_FLAG values + */ + int flags; + /** + * Additional packet data that can be provided by the container. + * Packet can contain several types of side information. + */ + struct { + uint8_t *data; + int size; + enum AVPacketSideDataType type; + } *side_data; + int side_data_elems; + + /** + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + */ + int duration; + void (*destruct)(struct AVPacket *); + void *priv; + int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * Time difference in AVStream->time_base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current packet. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; +} AVPacket; +#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe +#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted + +enum AVSideDataParamChangeFlags { + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, +}; +/** + * @} + */ + +/** + * Audio Video Frame. + * New fields can be added to the end of AVFRAME with minor version + * bumps. Removal, reordering and changes to existing fields require + * a major version bump. + * sizeof(AVFrame) must not be used outside libav*. + */ +typedef struct AVFrame { +#define AV_NUM_DATA_POINTERS 8 + /** + * pointer to the picture/channel planes. + * This might be different from the first allocated byte + * - encoding: Set by user + * - decoding: set by AVCodecContext.get_buffer() + */ + uint8_t *data[AV_NUM_DATA_POINTERS]; + + /** + * Size, in bytes, of the data for each picture/channel plane. + * + * For audio, only linesize[0] may be set. For planar audio, each channel + * plane must be the same size. + * + * - encoding: Set by user + * - decoding: set by AVCodecContext.get_buffer() + */ + int linesize[AV_NUM_DATA_POINTERS]; + + /** + * pointers to the data planes/channels. + * + * For video, this should simply point to data[]. + * + * For planar audio, each channel has a separate data pointer, and + * linesize[0] contains the size of each channel buffer. + * For packed audio, there is just one data pointer, and linesize[0] + * contains the total size of the buffer for all channels. + * + * Note: Both data and extended_data will always be set by get_buffer(), + * but for planar audio with more channels that can fit in data, + * extended_data must be used by the decoder in order to access all + * channels. + * + * encoding: set by user + * decoding: set by AVCodecContext.get_buffer() + */ + uint8_t **extended_data; + + /** + * width and height of the video frame + * - encoding: unused + * - decoding: Read by user. + */ + int width, height; + + /** + * number of audio samples (per channel) described by this frame + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + int nb_samples; + + /** + * format of the frame, -1 if unknown or unset + * Values correspond to enum AVPixelFormat for video frames, + * enum AVSampleFormat for audio) + * - encoding: unused + * - decoding: Read by user. + */ + int format; + + /** + * 1 -> keyframe, 0-> not + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int key_frame; + + /** + * Picture type of the frame, see ?_TYPE below. + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + */ + enum AVPictureType pict_type; + + /** + * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer. + * This isn't used by libavcodec unless the default get/release_buffer() is used. + * - encoding: + * - decoding: + */ + uint8_t *base[AV_NUM_DATA_POINTERS]; + + /** + * sample aspect ratio for the video frame, 0/1 if unknown/unspecified + * - encoding: unused + * - decoding: Read by user. + */ + AVRational sample_aspect_ratio; + + /** + * presentation timestamp in time_base units (time when frame should be shown to user) + * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + int64_t pts; + + /** + * reordered pts from the last AVPacket that has been input into the decoder + * - encoding: unused + * - decoding: Read by user. + */ + int64_t pkt_pts; + + /** + * dts from the last AVPacket that has been input into the decoder + * - encoding: unused + * - decoding: Read by user. + */ + int64_t pkt_dts; + + /** + * picture number in bitstream order + * - encoding: set by + * - decoding: Set by libavcodec. + */ + int coded_picture_number; + /** + * picture number in display order + * - encoding: set by + * - decoding: Set by libavcodec. + */ + int display_picture_number; + + /** + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) + * - encoding: Set by libavcodec. for coded_picture (and set by user for input). + * - decoding: Set by libavcodec. + */ + int quality; + + /** + * is this picture used as reference + * The values for this are the same as the MpegEncContext.picture_structure + * variable, that is 1->top field, 2->bottom field, 3->frame/both fields. + * Set to 4 for delayed, non-reference frames. + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + */ + int reference; + + /** + * QP table + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int8_t *qscale_table; + /** + * QP store stride + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int qstride; + + /** + * + */ + int qscale_type; + + /** + * mbskip_table[mb]>=1 if MB didn't change + * stride= mb_width = (width+15)>>4 + * - encoding: unused + * - decoding: Set by libavcodec. + */ + uint8_t *mbskip_table; + + /** + * motion vector table + * @code + * example: + * int mv_sample_log2= 4 - motion_subsample_log2; + * int mb_width= (width+15)>>4; + * int mv_stride= (mb_width << mv_sample_log2) + 1; + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y]; + * @endcode + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t (*motion_val[2])[2]; + + /** + * macroblock type table + * mb_type_base + mb_width + 2 + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + uint32_t *mb_type; + + /** + * DCT coefficients + * - encoding: unused + * - decoding: Set by libavcodec. + */ + short *dct_coeff; + + /** + * motion reference frame index + * the order in which these are stored can depend on the codec. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int8_t *ref_index[2]; + + /** + * for some private data of the user + * - encoding: unused + * - decoding: Set by user. + */ + void *opaque; + + /** + * error + * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[AV_NUM_DATA_POINTERS]; + + /** + * type of the buffer (to keep track of who has to deallocate data[*]) + * - encoding: Set by the one who allocates it. + * - decoding: Set by the one who allocates it. + * Note: User allocated (direct rendering) & internal buffers cannot coexist currently. + */ + int type; + + /** + * When decoding, this signals how much the picture must be delayed. + * extra_delay = repeat_pict / (2*fps) + * - encoding: unused + * - decoding: Set by libavcodec. + */ + int repeat_pict; + + /** + * The content of the picture is interlaced. + * - encoding: Set by user. + * - decoding: Set by libavcodec. (default 0) + */ + int interlaced_frame; + + /** + * If the content is interlaced, is top field displayed first. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int top_field_first; + + /** + * Tell user application that palette has changed from previous frame. + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by libavcodec. (default 0). + */ + int palette_has_changed; + + /** + * codec suggestion on buffer type if != 0 + * - encoding: unused + * - decoding: Set by libavcodec. (before get_buffer() call)). + */ + int buffer_hints; + + /** + * Pan scan. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + AVPanScan *pan_scan; + + /** + * reordered opaque 64bit (generally an integer or a double precision float + * PTS but can be anything). + * The user sets AVCodecContext.reordered_opaque to represent the input at + * that time, + * the decoder reorders values as needed and sets AVFrame.reordered_opaque + * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque + * @deprecated in favor of pkt_pts + * - encoding: unused + * - decoding: Read by user. + */ + int64_t reordered_opaque; + + /** + * hardware accelerator private data (Libav-allocated) + * - encoding: unused + * - decoding: Set by libavcodec + */ + void *hwaccel_picture_private; + + /** + * the AVCodecContext which ff_thread_get_buffer() was last called on + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + struct AVCodecContext *owner; + + /** + * used by multithreading to store frame-specific info + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + void *thread_opaque; + + /** + * log2 of the size of the block which a single vector in motion_val represents: + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2) + * - encoding: unused + * - decoding: Set by libavcodec. + */ + uint8_t motion_subsample_log2; + + /** + * Sample rate of the audio data. + * + * - encoding: unused + * - decoding: set by get_buffer() + */ + int sample_rate; + + /** + * Channel layout of the audio data. + * + * - encoding: unused + * - decoding: set by get_buffer() + */ + uint64_t channel_layout; +} AVFrame; + +struct AVCodecInternal; + +enum AVFieldOrder { + AV_FIELD_UNKNOWN, + AV_FIELD_PROGRESSIVE, + AV_FIELD_TT, //< Top coded_first, top displayed first + AV_FIELD_BB, //< Bottom coded first, bottom displayed first + AV_FIELD_TB, //< Top coded first, bottom displayed first + AV_FIELD_BT, //< Bottom coded first, top displayed first +}; + +/** + * main external API structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVCodecContext) must not be used outside libav*. + */ +typedef struct AVCodecContext { + /** + * information on struct for av_log + * - set by avcodec_alloc_context3 + */ + const AVClass *av_class; + int log_level_offset; + + enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ + const struct AVCodec *codec; + char codec_name[32]; + enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ + + /** + * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * A demuxer should set this to what is stored in the field used to identify the codec. + * If there are multiple such fields in a container then the demuxer should choose the one + * which maximizes the information about the used codec. + * If the codec tag field in a container is larger than 32 bits then the demuxer should + * remap the longer ID to 32 bits with a table or other structure. Alternatively a new + * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated + * first. + * - encoding: Set by user, if not then the default based on codec_id will be used. + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int codec_tag; + + /** + * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * - encoding: unused + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int stream_codec_tag; + +#if FF_API_SUB_ID + /** + * @deprecated this field is unused + */ + attribute_deprecated int sub_id; +#endif + + void *priv_data; + + /** + * Private context used for internal data. + * + * Unlike priv_data, this is not codec-specific. It is used in general + * libavcodec functions. + */ + struct AVCodecInternal *internal; + + /** + * Private data of the user, can be used to carry app specific stuff. + * - encoding: Set by user. + * - decoding: Set by user. + */ + void *opaque; + + /** + * the average bitrate + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + */ + int bit_rate; + + /** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + */ + int bit_rate_tolerance; + + /** + * Global quality for codecs which cannot change it per frame. + * This should be proportional to MPEG-1/2/4 qscale. + * - encoding: Set by user. + * - decoding: unused + */ + int global_quality; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int compression_level; +#define FF_COMPRESSION_DEFAULT -1 + + /** + * CODEC_FLAG_*. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags; + + /** + * CODEC_FLAG2_* + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags2; + + /** + * some codecs need / can use extradata like Huffman tables. + * mjpeg: Huffman tables + * rv10: additional flags + * mpeg4: global headers (they can be in the bitstream or here) + * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * than extradata_size to avoid prolems if it is read with the bitstream reader. + * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * - encoding: Set/allocated/freed by libavcodec. + * - decoding: Set/allocated/freed by user. + */ + uint8_t *extradata; + int extradata_size; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identically 1. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + AVRational time_base; + + /** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + */ + int ticks_per_frame; + + /** + * Encoder delay. + * + * Video: + * Number of frames the decoded output will be delayed relative to the + * encoded input. + * + * Audio: + * For encoding, this is the number of "priming" samples added to the + * beginning of the stream. The decoded output will be delayed by this + * many samples relative to the input to the encoder. Note that this + * field is purely informational and does not directly affect the pts + * output by the encoder, which should always be based on the actual + * presentation time, including any delay. + * For decoding, this is the number of samples the decoder needs to + * output before the decoder's output is valid. When seeking, you should + * start decoding this many samples prior to your desired seek point. + * + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int delay; + + + /* video only */ + /** + * picture width / height. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + * Note: For compatibility it is possible to set this instead of + * coded_width/height before decoding. + */ + int width, height; + + /** + * Bitstream width / height, may be different from width/height. + * - encoding: unused + * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. + */ + int coded_width, coded_height; + +#define FF_ASPECT_EXTENDED 15 + + /** + * the number of pictures in a group of pictures, or 0 for intra_only + * - encoding: Set by user. + * - decoding: unused + */ + int gop_size; + + /** + * Pixel format, see AV_PIX_FMT_xxx. + * May be set by the demuxer if known from headers. + * May be overriden by the decoder if it knows better. + * - encoding: Set by user. + * - decoding: Set by user if known, overridden by libavcodec if known + */ + enum AVPixelFormat pix_fmt; + + /** + * Motion estimation algorithm used for video coding. + * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), + * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] + * - encoding: MUST be set by user. + * - decoding: unused + */ + int me_method; + + /** + * If non NULL, 'draw_horiz_band' is called by the libavcodec + * decoder to draw a horizontal band. It improves cache usage. Not + * all codecs can do that. You must check the codec capabilities + * beforehand. + * When multithreading is used, it may be called from multiple threads + * at the same time; threads might draw different parts of the same AVFrame, + * or multiple AVFrames, and there is no guarantee that slices will be drawn + * in order. + * The function is also used by hardware acceleration APIs. + * It is called at least once during frame decoding to pass + * the data needed for hardware render. + * In that mode instead of pixel data, AVFrame points to + * a structure specific to the acceleration API. The application + * reads the structure and can change some fields to indicate progress + * or mark state. + * - encoding: unused + * - decoding: Set by user. + * @param height the height of the slice + * @param y the y position of the slice + * @param type 1->top field, 2->bottom field, 3->frame + * @param offset offset into the AVFrame.data from which the slice should be read + */ + void (*draw_horiz_band)(struct AVCodecContext *s, + const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], + int y, int type, int height); + + /** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. + * The first is always the native one. + * @return the chosen format + * - encoding: unused + * - decoding: Set by user, if not set the native format will be chosen. + */ + enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt); + + /** + * maximum number of B-frames between non-B-frames + * Note: The output will be delayed by max_b_frames+1 relative to the input. + * - encoding: Set by user. + * - decoding: unused + */ + int max_b_frames; + + /** + * qscale factor between IP and B-frames + * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_factor; + + /** obsolete FIXME remove */ + int rc_strategy; +#define FF_RC_STRATEGY_XVID 1 + + int b_frame_strategy; + +#if FF_API_MPV_GLOBAL_OPTS + /** + * luma single coefficient elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + attribute_deprecated int luma_elim_threshold; + + /** + * chroma single coeff elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + attribute_deprecated int chroma_elim_threshold; +#endif + + /** + * qscale offset between IP and B-frames + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_offset; + + /** + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int has_b_frames; + + /** + * 0-> h263 quant 1-> mpeg quant + * - encoding: Set by user. + * - decoding: unused + */ + int mpeg_quant; + + /** + * qscale factor between P and I-frames + * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_factor; + + /** + * qscale offset between P and I-frames + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_offset; + + /** + * luminance masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float lumi_masking; + + /** + * temporary complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float temporal_cplx_masking; + + /** + * spatial complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float spatial_cplx_masking; + + /** + * p block masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float p_masking; + + /** + * darkness masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float dark_masking; + + /** + * slice count + * - encoding: Set by libavcodec. + * - decoding: Set by user (or 0). + */ + int slice_count; + /** + * prediction method (needed for huffyuv) + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_method; +#define FF_PRED_LEFT 0 +#define FF_PRED_PLANE 1 +#define FF_PRED_MEDIAN 2 + + /** + * slice offsets in the frame in bytes + * - encoding: Set/allocated by libavcodec. + * - decoding: Set/allocated by user (or NULL). + */ + int *slice_offset; + + /** + * sample aspect ratio (0 if unknown) + * That is the width of a pixel divided by the height of the pixel. + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + AVRational sample_aspect_ratio; + + /** + * motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_cmp; + /** + * subpixel motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_sub_cmp; + /** + * macroblock comparison function (not supported yet) + * - encoding: Set by user. + * - decoding: unused + */ + int mb_cmp; + /** + * interlaced DCT comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int ildct_cmp; +#define FF_CMP_SAD 0 +#define FF_CMP_SSE 1 +#define FF_CMP_SATD 2 +#define FF_CMP_DCT 3 +#define FF_CMP_PSNR 4 +#define FF_CMP_BIT 5 +#define FF_CMP_RD 6 +#define FF_CMP_ZERO 7 +#define FF_CMP_VSAD 8 +#define FF_CMP_VSSE 9 +#define FF_CMP_NSSE 10 +#define FF_CMP_W53 11 +#define FF_CMP_W97 12 +#define FF_CMP_DCTMAX 13 +#define FF_CMP_DCT264 14 +#define FF_CMP_CHROMA 256 + + /** + * ME diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int dia_size; + + /** + * amount of previous MV predictors (2a+1 x 2a+1 square) + * - encoding: Set by user. + * - decoding: unused + */ + int last_predictor_count; + + /** + * prepass for motion estimation + * - encoding: Set by user. + * - decoding: unused + */ + int pre_me; + + /** + * motion estimation prepass comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_pre_cmp; + + /** + * ME prepass diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int pre_dia_size; + + /** + * subpel ME quality + * - encoding: Set by user. + * - decoding: unused + */ + int me_subpel_quality; + + /** + * DTG active format information (additional aspect ratio + * information only used in DVB MPEG-2 transport streams) + * 0 if not set. + * + * - encoding: unused + * - decoding: Set by decoder. + */ + int dtg_active_format; +#define FF_DTG_AFD_SAME 8 +#define FF_DTG_AFD_4_3 9 +#define FF_DTG_AFD_16_9 10 +#define FF_DTG_AFD_14_9 11 +#define FF_DTG_AFD_4_3_SP_14_9 13 +#define FF_DTG_AFD_16_9_SP_14_9 14 +#define FF_DTG_AFD_SP_4_3 15 + + /** + * maximum motion estimation search range in subpel units + * If 0 then no limit. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_range; + + /** + * intra quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int intra_quant_bias; +#define FF_DEFAULT_QUANT_BIAS 999999 + + /** + * inter quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int inter_quant_bias; + +#if FF_API_COLOR_TABLE_ID + /** + * color table ID + * - encoding: unused + * - decoding: Which clrtable should be used for 8bit RGB images. + * Tables have to be stored somewhere. FIXME + */ + attribute_deprecated int color_table_id; +#endif + + /** + * slice flags + * - encoding: unused + * - decoding: Set by user. + */ + int slice_flags; +#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display +#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics) +#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) + + /** + * XVideo Motion Acceleration + * - encoding: forbidden + * - decoding: set by decoder + */ + int xvmc_acceleration; + + /** + * macroblock decision mode + * - encoding: Set by user. + * - decoding: unused + */ + int mb_decision; +#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp +#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits +#define FF_MB_DECISION_RD 2 ///< rate distortion + + /** + * custom intra quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + */ + uint16_t *intra_matrix; + + /** + * custom inter quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + */ + uint16_t *inter_matrix; + + /** + * scene change detection threshold + * 0 is default, larger means fewer detected scene changes. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_threshold; + + /** + * noise reduction strength + * - encoding: Set by user. + * - decoding: unused + */ + int noise_reduction; + +#if FF_API_INTER_THRESHOLD + /** + * @deprecated this field is unused + */ + attribute_deprecated int inter_threshold; +#endif + +#if FF_API_MPV_GLOBAL_OPTS + /** + * @deprecated use mpegvideo private options instead + */ + attribute_deprecated int quantizer_noise_shaping; +#endif + + /** + * Motion estimation threshold below which no motion estimation is + * performed, but instead the user specified motion vectors are used. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_threshold; + + /** + * Macroblock threshold below which the user specified macroblock types will be used. + * - encoding: Set by user. + * - decoding: unused + */ + int mb_threshold; + + /** + * precision of the intra DC coefficient - 8 + * - encoding: Set by user. + * - decoding: unused + */ + int intra_dc_precision; + + /** + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_top; + + /** + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_bottom; + + /** + * Border processing masking, raises the quantizer for mbs on the borders + * of the picture. + * - encoding: Set by user. + * - decoding: unused + */ + float border_masking; + + /** + * minimum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmin; + + /** + * maximum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmax; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_penalty_compensation; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int bidir_refine; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int brd_scale; + + /** + * minimum GOP size + * - encoding: Set by user. + * - decoding: unused + */ + int keyint_min; + + /** + * number of reference frames + * - encoding: Set by user. + * - decoding: Set by lavc. + */ + int refs; + + /** + * chroma qp offset from luma + * - encoding: Set by user. + * - decoding: unused + */ + int chromaoffset; + + /** + * Multiplied by qscale for each frame and added to scene_change_score. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_factor; + + /** + * + * Note: Value depends upon the compare function used for fullpel ME. + * - encoding: Set by user. + * - decoding: unused + */ + int mv0_threshold; + + /** + * Adjust sensitivity of b_frame_strategy 1. + * - encoding: Set by user. + * - decoding: unused + */ + int b_sensitivity; + + /** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorPrimaries color_primaries; + + /** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorTransferCharacteristic color_trc; + + /** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorSpace colorspace; + + /** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorRange color_range; + + /** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVChromaLocation chroma_sample_location; + + /** + * Number of slices. + * Indicates number of picture subdivisions. Used for parallelized + * decoding. + * - encoding: Set by user + * - decoding: unused + */ + int slices; + + /** Field order + * - encoding: set by libavcodec + * - decoding: Set by libavcodec + */ + enum AVFieldOrder field_order; + + /* audio only */ + int sample_rate; ///< samples per second + int channels; ///< number of audio channels + + /** + * audio sample format + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum AVSampleFormat sample_fmt; ///< sample format + + /* The following data should not be initialized. */ + /** + * Samples per packet, initialized when calling 'init'. + */ + int frame_size; + + /** + * Frame counter, set by libavcodec. + * + * - decoding: total number of frames returned from the decoder so far. + * - encoding: total number of frames passed to the encoder so far. + * + * @note the counter is not incremented if encoding/decoding resulted in + * an error. + */ + int frame_number; + + /** + * number of bytes per packet if constant and known or 0 + * Used by some WAV based audio codecs. + */ + int block_align; + + /** + * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + */ + int cutoff; + +#if FF_API_REQUEST_CHANNELS + /** + * Decoder should decode to this many channels if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + * @deprecated Deprecated in favor of request_channel_layout. + */ + int request_channels; +#endif + + /** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + uint64_t channel_layout; + + /** + * Request decoder to use this channel layout if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + */ + uint64_t request_channel_layout; + + /** + * Type of service that the audio stream conveys. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum AVAudioServiceType audio_service_type; + + /** + * Used to request a sample format from the decoder. + * - encoding: unused. + * - decoding: Set by user. + */ + enum AVSampleFormat request_sample_fmt; + + /** + * Called at the beginning of each frame to get a buffer for it. + * + * The function will set AVFrame.data[], AVFrame.linesize[]. + * AVFrame.extended_data[] must also be set, but it should be the same as + * AVFrame.data[] except for planar audio with more channels than can fit + * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as + * many data pointers as it can hold. + * + * if CODEC_CAP_DR1 is not set then get_buffer() must call + * avcodec_default_get_buffer() instead of providing buffers allocated by + * some other means. + * + * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't + * need it. avcodec_default_get_buffer() aligns the output buffer properly, + * but if get_buffer() is overridden then alignment considerations should + * be taken into account. + * + * @see avcodec_default_get_buffer() + * + * Video: + * + * If pic.reference is set then the frame will be read later by libavcodec. + * avcodec_align_dimensions2() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * + * If frame multithreading is used and thread_safe_callbacks is set, + * it may be called from a different thread, but not from more than one at + * once. Does not need to be reentrant. + * + * @see release_buffer(), reget_buffer() + * @see avcodec_align_dimensions2() + * + * Audio: + * + * Decoders request a buffer of a particular size by setting + * AVFrame.nb_samples prior to calling get_buffer(). The decoder may, + * however, utilize only part of the buffer by setting AVFrame.nb_samples + * to a smaller value in the output frame. + * + * Decoders cannot use the buffer after returning from + * avcodec_decode_audio4(), so they will not call release_buffer(), as it + * is assumed to be released immediately upon return. + * + * As a convenience, av_samples_get_buffer_size() and + * av_samples_fill_arrays() in libavutil may be used by custom get_buffer() + * functions to find the required data size and to fill data pointers and + * linesize. In AVFrame.linesize, only linesize[0] may be set for audio + * since all planes must be the same size. + * + * @see av_samples_get_buffer_size(), av_samples_fill_arrays() + * + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called to release buffers which were allocated with get_buffer. + * A released buffer can be reused in get_buffer(). + * pic.data[*] must be set to NULL. + * May be called from a different thread if frame multithreading is used, + * but not by more than one thread at once, so does not need to be reentrant. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called at the beginning of a frame to get cr buffer for it. + * Buffer type (size, hints) must be the same. libavcodec won't check it. + * libavcodec will pass previous buffer in pic, function should return + * same buffer or new buffer with old frame "painted" into it. + * If pic.data[0] == NULL must behave like get_buffer(). + * if CODEC_CAP_DR1 is not set then reget_buffer() must call + * avcodec_default_reget_buffer() instead of providing buffers allocated by + * some other means. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); + + + /* - encoding parameters */ + float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) + float qblur; ///< amount of qscale smoothing over time (0.0-1.0) + + /** + * minimum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmin; + + /** + * maximum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmax; + + /** + * maximum quantizer difference between frames + * - encoding: Set by user. + * - decoding: unused + */ + int max_qdiff; + + /** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_qsquish; + + float rc_qmod_amp; + int rc_qmod_freq; + + /** + * decoder bitstream buffer size + * - encoding: Set by user. + * - decoding: unused + */ + int rc_buffer_size; + + /** + * ratecontrol override, see RcOverride + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + int rc_override_count; + RcOverride *rc_override; + + /** + * rate control equation + * - encoding: Set by user + * - decoding: unused + */ + const char *rc_eq; + + /** + * maximum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_max_rate; + + /** + * minimum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_min_rate; + + float rc_buffer_aggressivity; + + /** + * initial complexity for pass1 ratecontrol + * - encoding: Set by user. + * - decoding: unused + */ + float rc_initial_cplx; + + /** + * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_max_available_vbv_use; + + /** + * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_min_vbv_overflow_use; + + /** + * Number of bits which should be loaded into the rc buffer before decoding starts. + * - encoding: Set by user. + * - decoding: unused + */ + int rc_initial_buffer_occupancy; + +#define FF_CODER_TYPE_VLC 0 +#define FF_CODER_TYPE_AC 1 +#define FF_CODER_TYPE_RAW 2 +#define FF_CODER_TYPE_RLE 3 +#define FF_CODER_TYPE_DEFLATE 4 + /** + * coder type + * - encoding: Set by user. + * - decoding: unused + */ + int coder_type; + + /** + * context model + * - encoding: Set by user. + * - decoding: unused + */ + int context_model; + + /** + * minimum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmin; + + /** + * maximum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmax; + + /** + * frame skip threshold + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_threshold; + + /** + * frame skip factor + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_factor; + + /** + * frame skip exponent + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_exp; + + /** + * frame skip comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_cmp; + + /** + * trellis RD quantization + * - encoding: Set by user. + * - decoding: unused + */ + int trellis; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_prediction_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_prediction_order; + + /** + * GOP timecode frame start number, in non drop frame format + * - encoding: Set by user. + * - decoding: unused + */ + int64_t timecode_frame_start; + + /* The RTP callback: This function is called */ + /* every time the encoder has a packet to send. */ + /* It depends on the encoder if the data starts */ + /* with a Start Code (it should). H.263 does. */ + /* mb_nb contains the number of macroblocks */ + /* encoded in the RTP payload. */ + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); + + int rtp_payload_size; /* The size of the RTP payload: the coder will */ + /* do its best to deliver a chunk with size */ + /* below rtp_payload_size, the chunk will start */ + /* with a start code on some codecs like H.263. */ + /* This doesn't take account of any particular */ + /* headers inside the transmitted RTP payload. */ + + /* statistics, used for 2-pass encoding */ + int mv_bits; + int header_bits; + int i_tex_bits; + int p_tex_bits; + int i_count; + int p_count; + int skip_count; + int misc_bits; + + /** + * number of bits used for the previously encoded frame + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int frame_bits; + + /** + * pass1 encoding statistics output buffer + * - encoding: Set by libavcodec. + * - decoding: unused + */ + char *stats_out; + + /** + * pass2 encoding statistics input buffer + * Concatenated stuff from stats_out of pass1 should be placed here. + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + char *stats_in; + + /** + * Work around bugs in encoders which sometimes cannot be detected automatically. + * - encoding: Set by user + * - decoding: Set by user + */ + int workaround_bugs; +#define FF_BUG_AUTODETECT 1 ///< autodetection +#define FF_BUG_OLD_MSMPEG4 2 +#define FF_BUG_XVID_ILACE 4 +#define FF_BUG_UMP4 8 +#define FF_BUG_NO_PADDING 16 +#define FF_BUG_AMV 32 +#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. +#define FF_BUG_QPEL_CHROMA 64 +#define FF_BUG_STD_QPEL 128 +#define FF_BUG_QPEL_CHROMA2 256 +#define FF_BUG_DIRECT_BLOCKSIZE 512 +#define FF_BUG_EDGE 1024 +#define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 +#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. +#define FF_BUG_TRUNCATED 16384 + + /** + * strictly follow the standard (MPEG4, ...). + * - encoding: Set by user. + * - decoding: Set by user. + * Setting this to STRICT or higher means the encoder and decoder will + * generally do stupid things, whereas setting it to unofficial or lower + * will mean the encoder might produce output that is not supported by all + * spec-compliant decoders. Decoders don't differentiate between normal, + * unofficial and experimental (that is, they always try to decode things + * when they can) unless they are explicitly asked to behave stupidly + * (=strictly conform to the specs) + */ + int strict_std_compliance; +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + + /** + * error concealment flags + * - encoding: unused + * - decoding: Set by user. + */ + int error_concealment; +#define FF_EC_GUESS_MVS 1 +#define FF_EC_DEBLOCK 2 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug; +#define FF_DEBUG_PICT_INFO 1 +#define FF_DEBUG_RC 2 +#define FF_DEBUG_BITSTREAM 4 +#define FF_DEBUG_MB_TYPE 8 +#define FF_DEBUG_QP 16 +#define FF_DEBUG_MV 32 +#define FF_DEBUG_DCT_COEFF 0x00000040 +#define FF_DEBUG_SKIP 0x00000080 +#define FF_DEBUG_STARTCODE 0x00000100 +#define FF_DEBUG_PTS 0x00000200 +#define FF_DEBUG_ER 0x00000400 +#define FF_DEBUG_MMCO 0x00000800 +#define FF_DEBUG_BUGS 0x00001000 +#define FF_DEBUG_VIS_QP 0x00002000 +#define FF_DEBUG_VIS_MB_TYPE 0x00004000 +#define FF_DEBUG_BUFFERS 0x00008000 +#define FF_DEBUG_THREADS 0x00010000 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug_mv; +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames + + /** + * Error recognition; may misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int err_recognition; +#define AV_EF_CRCCHECK (1<<0) +#define AV_EF_BITSTREAM (1<<1) +#define AV_EF_BUFFER (1<<2) +#define AV_EF_EXPLODE (1<<3) + + /** + * opaque 64bit number (generally a PTS) that will be reordered and + * output in AVFrame.reordered_opaque + * @deprecated in favor of pkt_pts + * - encoding: unused + * - decoding: Set by user. + */ + int64_t reordered_opaque; + + /** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + */ + struct AVHWAccel *hwaccel; + + /** + * Hardware accelerator context. + * For some hardware accelerators, a global context needs to be + * provided by the user. In that case, this holds display-dependent + * data Libav cannot instantiate itself. Please refer to the + * Libav HW accelerator documentation to know how to fill this + * is. e.g. for VA API, this is a struct vaapi_context. + * - encoding: unused + * - decoding: Set by user + */ + void *hwaccel_context; + + /** + * error + * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[AV_NUM_DATA_POINTERS]; + + /** + * DCT algorithm, see FF_DCT_* below + * - encoding: Set by user. + * - decoding: unused + */ + int dct_algo; +#define FF_DCT_AUTO 0 +#define FF_DCT_FASTINT 1 +#define FF_DCT_INT 2 +#define FF_DCT_MMX 3 +#define FF_DCT_ALTIVEC 5 +#define FF_DCT_FAAN 6 + + /** + * IDCT algorithm, see FF_IDCT_* below. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int idct_algo; +#define FF_IDCT_AUTO 0 +#define FF_IDCT_INT 1 +#define FF_IDCT_SIMPLE 2 +#define FF_IDCT_SIMPLEMMX 3 +#if FF_API_LIBMPEG2 +#define FF_IDCT_LIBMPEG2MMX 4 +#endif +#if FF_API_MMI +#define FF_IDCT_MMI 5 +#endif +#define FF_IDCT_ARM 7 +#define FF_IDCT_ALTIVEC 8 +#define FF_IDCT_SH4 9 +#define FF_IDCT_SIMPLEARM 10 +#define FF_IDCT_H264 11 +#define FF_IDCT_VP3 12 +#define FF_IDCT_IPP 13 +#define FF_IDCT_XVIDMMX 14 +#define FF_IDCT_CAVS 15 +#define FF_IDCT_SIMPLEARMV5TE 16 +#define FF_IDCT_SIMPLEARMV6 17 +#define FF_IDCT_SIMPLEVIS 18 +#define FF_IDCT_WMV2 19 +#define FF_IDCT_FAAN 20 +#define FF_IDCT_EA 21 +#define FF_IDCT_SIMPLENEON 22 +#define FF_IDCT_SIMPLEALPHA 23 +#define FF_IDCT_BINK 24 + +#if FF_API_DSP_MASK + /** + * Unused. + * @deprecated use av_set_cpu_flags_mask() instead. + */ + attribute_deprecated unsigned dsp_mask; +#endif + + /** + * bits per sample/pixel from the demuxer (needed for huffyuv). + * - encoding: Set by libavcodec. + * - decoding: Set by user. + */ + int bits_per_coded_sample; + + /** + * Bits per sample/pixel of internal libavcodec pixel/sample format. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int bits_per_raw_sample; + + /** + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. + */ + attribute_deprecated int lowres; + + /** + * the picture in the bitstream + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + AVFrame *coded_frame; + + /** + * thread count + * is used to decide how many independent tasks should be passed to execute() + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_count; + + /** + * Which multithreading methods to use. + * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, + * so clients which cannot provide future frames should not use it. + * + * - encoding: Set by user, otherwise the default is used. + * - decoding: Set by user, otherwise the default is used. + */ + int thread_type; +#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once +#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once + + /** + * Which multithreading methods are in use by the codec. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int active_thread_type; + + /** + * Set by the client if its custom get_buffer() callback can be called + * synchronously from another thread, which allows faster multithreaded decoding. + * draw_horiz_band() will be called from other threads regardless of this setting. + * Ignored if the default get_buffer() is used. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_safe_callbacks; + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * @param count the number of things to execute + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. + * @param c context passed also to func + * @param count the number of things to execute + * @param arg2 argument passed unchanged to func + * @param ret return values of executed functions, must have space for "count" values. May be NULL. + * @param func function that will be called count times, with jobnr from 0 to count-1. + * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no + * two instances of func executing at the same time will have the same threadnr. + * @return always 0 currently, but code should handle a future improvement where when any call to func + * returns < 0 no further calls to func may be done and < 0 is returned. + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); + + /** + * thread opaque + * Can be used by execute() to store some per AVCodecContext stuff. + * - encoding: set by execute() + * - decoding: set by execute() + */ + void *thread_opaque; + + /** + * noise vs. sse weight for the nsse comparsion function + * - encoding: Set by user. + * - decoding: unused + */ + int nsse_weight; + + /** + * profile + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int profile; +#define FF_PROFILE_UNKNOWN -99 +#define FF_PROFILE_RESERVED -100 + +#define FF_PROFILE_AAC_MAIN 0 +#define FF_PROFILE_AAC_LOW 1 +#define FF_PROFILE_AAC_SSR 2 +#define FF_PROFILE_AAC_LTP 3 +#define FF_PROFILE_AAC_HE 4 +#define FF_PROFILE_AAC_HE_V2 28 +#define FF_PROFILE_AAC_LD 22 +#define FF_PROFILE_AAC_ELD 38 + +#define FF_PROFILE_DTS 20 +#define FF_PROFILE_DTS_ES 30 +#define FF_PROFILE_DTS_96_24 40 +#define FF_PROFILE_DTS_HD_HRA 50 +#define FF_PROFILE_DTS_HD_MA 60 + +#define FF_PROFILE_MPEG2_422 0 +#define FF_PROFILE_MPEG2_HIGH 1 +#define FF_PROFILE_MPEG2_SS 2 +#define FF_PROFILE_MPEG2_SNR_SCALABLE 3 +#define FF_PROFILE_MPEG2_MAIN 4 +#define FF_PROFILE_MPEG2_SIMPLE 5 + +#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag +#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag + +#define FF_PROFILE_H264_BASELINE 66 +#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED) +#define FF_PROFILE_H264_MAIN 77 +#define FF_PROFILE_H264_EXTENDED 88 +#define FF_PROFILE_H264_HIGH 100 +#define FF_PROFILE_H264_HIGH_10 110 +#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_HIGH_422 122 +#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_HIGH_444 144 +#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 +#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_CAVLC_444 44 + +#define FF_PROFILE_VC1_SIMPLE 0 +#define FF_PROFILE_VC1_MAIN 1 +#define FF_PROFILE_VC1_COMPLEX 2 +#define FF_PROFILE_VC1_ADVANCED 3 + +#define FF_PROFILE_MPEG4_SIMPLE 0 +#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1 +#define FF_PROFILE_MPEG4_CORE 2 +#define FF_PROFILE_MPEG4_MAIN 3 +#define FF_PROFILE_MPEG4_N_BIT 4 +#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5 +#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 +#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 +#define FF_PROFILE_MPEG4_HYBRID 8 +#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 +#define FF_PROFILE_MPEG4_CORE_SCALABLE 10 +#define FF_PROFILE_MPEG4_ADVANCED_CODING 11 +#define FF_PROFILE_MPEG4_ADVANCED_CORE 12 +#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 +#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 +#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 + + /** + * level + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int level; +#define FF_LEVEL_UNKNOWN -99 + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_loop_filter; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_idct; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_frame; + + /** + * Header containing style information for text subtitles. + * For SUBTITLE_ASS subtitle type, it should contain the whole ASS + * [Script Info] and [V4+ Styles] section, plus the [Events] line and + * the Format line following. It shouldn't include any Dialogue line. + * - encoding: Set/allocated/freed by user (before avcodec_open2()) + * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) + */ + uint8_t *subtitle_header; + int subtitle_header_size; + + /** + * Simulates errors in the bitstream to test error concealment. + * - encoding: Set by user. + * - decoding: unused + */ + int error_rate; + + /** + * Current packet as passed into the decoder, to avoid having + * to pass the packet into every function. Currently only valid + * inside lavc and get/release_buffer callbacks. + * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts + * - encoding: unused + */ + AVPacket *pkt; + + /** + * VBV delay coded in the last frame (in periods of a 27 MHz clock). + * Used for compliant TS muxing. + * - encoding: Set by libavcodec. + * - decoding: unused. + */ + uint64_t vbv_delay; +} AVCodecContext; + +/** + * AVProfile. + */ +typedef struct AVProfile { + int profile; + const char *name; ///< short name for the profile +} AVProfile; + +typedef struct AVCodecDefault AVCodecDefault; + +struct AVSubtitle; + +/** + * AVCodec. + */ +typedef struct AVCodec { + /** + * Name of the codec implementation. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + * This is the primary way to find a codec from the user perspective. + */ + const char *name; + /** + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; + enum AVMediaType type; + enum AVCodecID id; + /** + * Codec capabilities. + * see CODEC_CAP_* + */ + int capabilities; + const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} + const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 + const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 + const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder + const AVClass *priv_class; ///< AVClass for the private context + const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + int priv_data_size; + struct AVCodec *next; + /** + * @name Frame-level threading support functions + * @{ + */ + /** + * If defined, called on thread contexts when they are created. + * If the codec allocates writable tables in init(), re-allocate them here. + * priv_data will be set to a copy of the original. + */ + int (*init_thread_copy)(AVCodecContext *); + /** + * Copy necessary context variables from a previous thread context to the current one. + * If not defined, the next thread will start automatically; otherwise, the codec + * must call ff_thread_finish_setup(). + * + * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. + */ + int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); + /** @} */ + + /** + * Private codec-specific defaults. + */ + const AVCodecDefault *defaults; + + /** + * Initialize codec static data, called from avcodec_register(). + */ + void (*init_static_data)(struct AVCodec *codec); + + int (*init)(AVCodecContext *); + int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, + const struct AVSubtitle *sub); + /** + * Encode data to an AVPacket. + * + * @param avctx codec context + * @param avpkt output AVPacket (may contain a user-provided buffer) + * @param[in] frame AVFrame containing the raw data to be encoded + * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in avpkt. + * @return 0 on success, negative error code on failure + */ + int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, + int *got_packet_ptr); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); + int (*close)(AVCodecContext *); + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(AVCodecContext *); +} AVCodec; + +/** + * AVHWAccel. + */ +typedef struct AVHWAccel { + /** + * Name of the hardware accelerated codec. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + */ + const char *name; + + /** + * Type of codec implemented by the hardware accelerator. + * + * See AVMEDIA_TYPE_xxx + */ + enum AVMediaType type; + + /** + * Codec implemented by the hardware accelerator. + * + * See AV_CODEC_ID_xxx + */ + enum AVCodecID id; + + /** + * Supported pixel format. + * + * Only hardware accelerated formats are supported here. + */ + enum AVPixelFormat pix_fmt; + + /** + * Hardware accelerated codec capabilities. + * see FF_HWACCEL_CODEC_CAP_* + */ + int capabilities; + + struct AVHWAccel *next; + + /** + * Called at the beginning of each frame or field picture. + * + * Meaningful frame information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * Note that buf can be NULL along with buf_size set to 0. + * Otherwise, this means the whole frame is available at this point. + * + * @param avctx the codec context + * @param buf the frame data buffer base + * @param buf_size the size of the frame in bytes + * @return zero if successful, a negative value otherwise + */ + int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Callback for each slice. + * + * Meaningful slice information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * @param avctx the codec context + * @param buf the slice data buffer base + * @param buf_size the size of the slice in bytes + * @return zero if successful, a negative value otherwise + */ + int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Called at the end of each frame or field picture. + * + * The whole picture is parsed at this point and can now be sent + * to the hardware accelerator. This function is mandatory. + * + * @param avctx the codec context + * @return zero if successful, a negative value otherwise + */ + int (*end_frame)(AVCodecContext *avctx); + + /** + * Size of HW accelerator private data. + * + * Private data is allocated with av_mallocz() before + * AVCodecContext.get_buffer() and deallocated after + * AVCodecContext.release_buffer(). + */ + int priv_data_size; +} AVHWAccel; + +/** + * @defgroup lavc_picture AVPicture + * + * Functions for working with AVPicture + * @{ + */ + +/** + * four components are given, that's all. + * the last component is alpha + */ +typedef struct AVPicture { + uint8_t *data[AV_NUM_DATA_POINTERS]; + int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line +} AVPicture; + +/** + * @} + */ + +#define AVPALETTE_SIZE 1024 +#define AVPALETTE_COUNT 256 + +enum AVSubtitleType { + SUBTITLE_NONE, + + SUBTITLE_BITMAP, ///< A bitmap, pict will be set + + /** + * Plain text, the text field must be set by the decoder and is + * authoritative. ass and pict fields may contain approximations. + */ + SUBTITLE_TEXT, + + /** + * Formatted text, the ass field must be set by the decoder and is + * authoritative. pict and text fields may contain approximations. + */ + SUBTITLE_ASS, +}; + +typedef struct AVSubtitleRect { + int x; ///< top left corner of pict, undefined when pict is not set + int y; ///< top left corner of pict, undefined when pict is not set + int w; ///< width of pict, undefined when pict is not set + int h; ///< height of pict, undefined when pict is not set + int nb_colors; ///< number of colors in pict, undefined when pict is not set + + /** + * data+linesize for the bitmap of this subtitle. + * can be set for text/ass as well once they where rendered + */ + AVPicture pict; + enum AVSubtitleType type; + + char *text; ///< 0 terminated plain UTF-8 text + + /** + * 0 terminated ASS/SSA compatible event line. + * The pressentation of this is unaffected by the other values in this + * struct. + */ + char *ass; +} AVSubtitleRect; + +typedef struct AVSubtitle { + uint16_t format; /* 0 = graphics */ + uint32_t start_display_time; /* relative to packet pts, in ms */ + uint32_t end_display_time; /* relative to packet pts, in ms */ + unsigned num_rects; + AVSubtitleRect **rects; + int64_t pts; ///< Same as packet pts, in AV_TIME_BASE +} AVSubtitle; + +/** + * If c is NULL, returns the first registered codec, + * if c is non-NULL, returns the next registered codec after c, + * or NULL if c is the last one. + */ +AVCodec *av_codec_next(const AVCodec *c); + +/** + * Return the LIBAVCODEC_VERSION_INT constant. + */ +unsigned avcodec_version(void); + +/** + * Return the libavcodec build-time configuration. + */ +const char *avcodec_configuration(void); + +/** + * Return the libavcodec license. + */ +const char *avcodec_license(void); + +/** + * Register the codec codec and initialize libavcodec. + * + * @warning either this function or avcodec_register_all() must be called + * before any other libavcodec functions. + * + * @see avcodec_register_all() + */ +void avcodec_register(AVCodec *codec); + +/** + * Register all the codecs, parsers and bitstream filters which were enabled at + * configuration time. If you do not call this function you can select exactly + * which formats you want to support, by using the individual registration + * functions. + * + * @see avcodec_register + * @see av_register_codec_parser + * @see av_register_bitstream_filter + */ +void avcodec_register_all(void); + +/** + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct can be deallocated by calling avcodec_close() on it followed + * by av_free(). + * + * @param codec if non-NULL, allocate private data and initialize defaults + * for the given codec. It is illegal to then call avcodec_open2() + * with a different codec. + * If NULL, then the codec-specific defaults won't be initialized, + * which may result in suboptimal default settings (this is + * important mainly for encoders, e.g. libx264). + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + */ +AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); + +/** + * Set the fields of the given AVCodecContext to default values corresponding + * to the given codec (defaults may be codec-dependent). + * + * Do not call this function if a non-NULL codec has been passed + * to avcodec_alloc_context3() that allocated this AVCodecContext. + * If codec is non-NULL, it is illegal to call avcodec_open2() with a + * different codec on this AVCodecContext. + */ +int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); + +/** + * Get the AVClass for AVCodecContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *avcodec_get_class(void); + +/** + * Copy the settings of the source AVCodecContext into the destination + * AVCodecContext. The resulting destination codec context will be + * unopened, i.e. you are required to call avcodec_open2() before you + * can use this AVCodecContext to decode/encode video/audio data. + * + * @param dest target codec context, should be initialized with + * avcodec_alloc_context3(), but otherwise uninitialized + * @param src source codec context + * @return AVERROR() on error (e.g. memory allocation error), 0 on success + */ +int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); + +/** + * Allocate an AVFrame and set its fields to default values. The resulting + * struct must be freed using avcodec_free_frame(). + * + * @return An AVFrame filled with default values or NULL on failure. + * @see avcodec_get_frame_defaults + */ +AVFrame *avcodec_alloc_frame(void); + +/** + * Set the fields of the given AVFrame to default values. + * + * @param frame The AVFrame of which the fields should be set to default values. + */ +void avcodec_get_frame_defaults(AVFrame *frame); + +/** + * Free the frame and any dynamically allocated objects in it, + * e.g. extended_data. + * + * @param frame frame to be freed. The pointer will be set to NULL. + * + * @warning this function does NOT free the data buffers themselves + * (it does not know how, since they might have been allocated with + * a custom get_buffer()). + */ +void avcodec_free_frame(AVFrame **frame); + +/** + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated with avcodec_alloc_context3(). + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * av_dict_set(&opts, "b", "2.5M", 0); + * codec = avcodec_find_decoder(AV_CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context3(codec); + * + * if (avcodec_open2(context, codec, opts) < 0) + * exit(1); + * @endcode + * + * @param avctx The context to initialize. + * @param codec The codec to open this context for. If a non-NULL codec has been + * previously passed to avcodec_alloc_context3() or + * avcodec_get_context_defaults3() for this context, then this + * parameter MUST be either NULL or equal to the previously passed + * codec. + * @param options A dictionary filled with AVCodecContext and codec-private options. + * On return this object will be filled with options that were not found. + * + * @return zero on success, a negative value on error + * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), + * av_dict_set(), av_opt_find(). + */ +int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); + +/** + * Close a given AVCodecContext and free all the data associated with it + * (but not the AVCodecContext itself). + * + * Calling this function on an AVCodecContext that hasn't been opened will free + * the codec-specific data allocated in avcodec_alloc_context3() / + * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will + * do nothing. + */ +int avcodec_close(AVCodecContext *avctx); + +/** + * Free all allocated data in the given subtitle struct. + * + * @param sub AVSubtitle to free. + */ +void avsubtitle_free(AVSubtitle *sub); + +/** + * @} + */ + +/** + * @addtogroup lavc_packet + * @{ + */ + +/** + * Default packet destructor. + */ +void av_destruct_packet(AVPacket *pkt); + +/** + * Initialize optional fields of a packet with default values. + * + * Note, this does not touch the data and size members, which have to be + * initialized separately. + * + * @param pkt packet + */ +void av_init_packet(AVPacket *pkt); + +/** + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + */ +int av_new_packet(AVPacket *pkt, int size); + +/** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** + * Increase packet size, correctly zeroing padding + * + * @param pkt packet + * @param grow_by number of bytes by which to increase the size of the packet + */ +int av_grow_packet(AVPacket *pkt, int grow_by); + +/** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + */ +int av_dup_packet(AVPacket *pkt); + +/** + * Free a packet. + * + * @param pkt packet to free + */ +void av_free_packet(AVPacket *pkt); + +/** + * Allocate new information of a packet. + * + * @param pkt packet + * @param type side information type + * @param size side information size + * @return pointer to fresh allocated data or NULL otherwise + */ +uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int size); + +/** + * Shrink the already allocated side data buffer + * + * @param pkt packet + * @param type side information type + * @param size new side information size + * @return 0 on success, < 0 on failure + */ +int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int size); + +/** + * Get side information from packet. + * + * @param pkt packet + * @param type desired side information type + * @param size pointer for side information size to store (optional) + * @return pointer to data if present or NULL otherwise + */ +uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int *size); + +/** + * @} + */ + +/** + * @addtogroup lavc_decoding + * @{ + */ + +/** + * Find a registered decoder with a matching codec ID. + * + * @param id AVCodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder(enum AVCodecID id); + +/** + * Find a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder_by_name(const char *name); + +int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); +void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); +int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); + +/** + * Return the amount of padding in pixels which the get_buffer callback must + * provide around the edge of the image for codecs which do not have the + * CODEC_FLAG_EMU_EDGE flag. + * + * @return Required padding in pixels. + */ +unsigned avcodec_get_edge_width(void); + +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you do not use any horizontal + * padding. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); + +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you also ensure that all + * line sizes are a multiple of the respective linesize_align[i]. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, + int linesize_align[AV_NUM_DATA_POINTERS]); + +#if FF_API_OLD_DECODE_AUDIO +/** + * Wrapper function which calls avcodec_decode_audio4. + * + * @deprecated Use avcodec_decode_audio4 instead. + * + * Decode the audio frame of size avpkt->size from avpkt->data into samples. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. In this case, + * avcodec_decode_audio3 has to be called again with an AVPacket that contains + * the remaining data in order to decode the second frame etc. + * If no frame + * could be outputted, frame_size_ptr is zero. Otherwise, it is the + * decompressed frame size in bytes. + * + * @warning You must set frame_size_ptr to the allocated size of the + * output buffer before calling avcodec_decode_audio3(). + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @warning You must not provide a custom get_buffer() when using + * avcodec_decode_audio3(). Doing so will override it with + * avcodec_default_get_buffer. Use avcodec_decode_audio4() instead, + * which does allow the application to provide a custom get_buffer(). + * + * @note You might have to align the input buffer avpkt->data and output buffer + * samples. The alignment requirements depend on the CPU: On some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum and + * samples should be 16 byte aligned unless the CPU doesn't need it + * (AltiVec and SSE do). + * + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. + * + * @param avctx the codec context + * @param[out] samples the output buffer, sample type in avctx->sample_fmt + * If the sample format is planar, each channel plane will + * be the same size, with no padding between channels. + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] avpkt The input AVPacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields. + * All decoders are designed to use the least fields possible though. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame data was decompressed (used) from the input AVPacket. + */ +attribute_deprecated int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + AVPacket *avpkt); +#endif + +/** + * Decode the audio frame of size avpkt->size from avpkt->data into frame. + * + * Some decoders may support multiple frames in a single AVPacket. Such + * decoders would then just decode the first frame. In this case, + * avcodec_decode_audio4 has to be called again with an AVPacket containing + * the remaining data in order to decode the second frame, etc... + * Even if no frames are returned, the packet needs to be fed to the decoder + * with remaining data until it is completely consumed or an error occurs. + * + * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE + * larger than the actual read bytes because some optimized bitstream + * readers read 32 or 64 bits at once and could read over the end. + * + * @note You might have to align the input buffer. The alignment requirements + * depend on the CPU and the decoder. + * + * @param avctx the codec context + * @param[out] frame The AVFrame in which to store decoded audio samples. + * Decoders request a buffer of a particular size by setting + * AVFrame.nb_samples prior to calling get_buffer(). The + * decoder may, however, only utilize part of the buffer by + * setting AVFrame.nb_samples to a smaller value in the + * output frame. + * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is + * non-zero. + * @param[in] avpkt The input AVPacket containing the input buffer. + * At least avpkt->data and avpkt->size should be set. Some + * decoders might also require additional fields to be set. + * @return A negative error code is returned if an error occurred during + * decoding, otherwise the number of bytes consumed from the input + * AVPacket is returned. + */ +int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *avpkt); + +/** + * Decode the video frame of size avpkt->size from avpkt->data into picture. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer avpkt->data. + * The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum. + * + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * Use avcodec_alloc_frame to get an AVFrame, the codec will + * allocate memory for the actual bitmap. + * with default get/release_buffer(), the decoder frees/reuses the bitmap as it sees fit. + * with overridden get/release_buffer() (needs CODEC_CAP_DR1) the user decides into what buffer the decoder + * decodes and the decoder tells the user once it does not need the data anymore, + * the user app can at this point free/reuse/keep the memory as it sees fit. + * + * @param[in] avpkt The input AVpacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields like + * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least + * fields possible. + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + AVPacket *avpkt); + +/** + * Decode a subtitle message. + * Return a negative value on error, otherwise return the number of bytes used. + * If no subtitle could be decompressed, got_sub_ptr is zero. + * Otherwise, the subtitle is stored in *sub. + * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for + * simplicity, because the performance difference is expect to be negligible + * and reusing a get_buffer written for video codecs would probably perform badly + * due to a potentially very different allocation pattern. + * + * @param avctx the codec context + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be + freed with avsubtitle_free if *got_sub_ptr is set. + * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. + * @param[in] avpkt The input AVPacket containing the input buffer. + */ +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + AVPacket *avpkt); + +/** + * @defgroup lavc_parsing Frame parsing + * @{ + */ + +typedef struct AVCodecParserContext { + void *priv_data; + struct AVCodecParser *parser; + int64_t frame_offset; /* offset of the current frame */ + int64_t cur_offset; /* current offset + (incremented by each av_parser_parse()) */ + int64_t next_frame_offset; /* offset of the next frame */ + /* video info */ + int pict_type; /* XXX: Put it back in AVCodecContext. */ + /** + * This field is used for proper frame duration computation in lavf. + * It signals, how much longer the frame duration of the current frame + * is compared to normal frame duration. + * + * frame_duration = (1 + repeat_pict) * time_base + * + * It is used by codecs like H.264 to display telecined material. + */ + int repeat_pict; /* XXX: Put it back in AVCodecContext. */ + int64_t pts; /* pts of the current frame */ + int64_t dts; /* dts of the current frame */ + + /* private data */ + int64_t last_pts; + int64_t last_dts; + int fetch_timestamp; + +#define AV_PARSER_PTS_NB 4 + int cur_frame_start_index; + int64_t cur_frame_offset[AV_PARSER_PTS_NB]; + int64_t cur_frame_pts[AV_PARSER_PTS_NB]; + int64_t cur_frame_dts[AV_PARSER_PTS_NB]; + + int flags; +#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 +#define PARSER_FLAG_ONCE 0x0002 +/// Set if the parser has a valid file offset +#define PARSER_FLAG_FETCHED_OFFSET 0x0004 + + int64_t offset; ///< byte offset from starting packet start + int64_t cur_frame_end[AV_PARSER_PTS_NB]; + + /** + * Set by parser to 1 for key frames and 0 for non-key frames. + * It is initialized to -1, so if the parser doesn't set this flag, + * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames + * will be used. + */ + int key_frame; + + /** + * Time difference in stream time base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current frame. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; + + // Timestamp generation support: + /** + * Synchronization point for start of timestamp generation. + * + * Set to >0 for sync point, 0 for no sync point and <0 for undefined + * (default). + * + * For example, this corresponds to presence of H.264 buffering period + * SEI message. + */ + int dts_sync_point; + + /** + * Offset of the current timestamp against last timestamp sync point in + * units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain a valid timestamp offset. + * + * Note that the timestamp of sync point has usually a nonzero + * dts_ref_dts_delta, which refers to the previous sync point. Offset of + * the next frame after timestamp sync point will be usually 1. + * + * For example, this corresponds to H.264 cpb_removal_delay. + */ + int dts_ref_dts_delta; + + /** + * Presentation delay of current frame in units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain valid non-negative timestamp delta (presentation time of a frame + * must not lie in the past). + * + * This delay represents the difference between decoding and presentation + * time of the frame. + * + * For example, this corresponds to H.264 dpb_output_delay. + */ + int pts_dts_delta; + + /** + * Position of the packet in file. + * + * Analogous to cur_frame_pts/dts + */ + int64_t cur_frame_pos[AV_PARSER_PTS_NB]; + + /** + * Byte position of currently parsed frame in stream. + */ + int64_t pos; + + /** + * Previous frame byte position. + */ + int64_t last_pos; + + /** + * Duration of the current frame. + * For audio, this is in units of 1 / AVCodecContext.sample_rate. + * For all other types, this is in units of AVCodecContext.time_base. + */ + int duration; +} AVCodecParserContext; + +typedef struct AVCodecParser { + int codec_ids[5]; /* several codec IDs are permitted */ + int priv_data_size; + int (*parser_init)(AVCodecParserContext *s); + int (*parser_parse)(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size); + void (*parser_close)(AVCodecParserContext *s); + int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); + struct AVCodecParser *next; +} AVCodecParser; + +AVCodecParser *av_parser_next(AVCodecParser *c); + +void av_register_codec_parser(AVCodecParser *parser); +AVCodecParserContext *av_parser_init(int codec_id); + +/** + * Parse a packet. + * + * @param s parser context. + * @param avctx codec context. + * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. + * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. + * @param buf input buffer. + * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). + * @param pts input presentation timestamp. + * @param dts input decoding timestamp. + * @param pos input byte position in stream. + * @return the number of bytes of the input bitstream used. + * + * Example: + * @code + * while(in_len){ + * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, + * in_data, in_len, + * pts, dts, pos); + * in_data += len; + * in_len -= len; + * + * if(size) + * decode_frame(data, size); + * } + * @endcode + */ +int av_parser_parse2(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts, + int64_t pos); + +int av_parser_change(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_parser_close(AVCodecParserContext *s); + +/** + * @} + * @} + */ + +/** + * @addtogroup lavc_encoding + * @{ + */ + +/** + * Find a registered encoder with a matching codec ID. + * + * @param id AVCodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder(enum AVCodecID id); + +/** + * Find a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder_by_name(const char *name); + +#if FF_API_OLD_ENCODE_AUDIO +/** + * Encode an audio frame from samples into buf. + * + * @deprecated Use avcodec_encode_audio2 instead. + * + * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. + * However, for codecs with avctx->frame_size equal to 0 (e.g. PCM) the user + * will know how much space is needed because it depends on the value passed + * in buf_size as described below. In that case a lower value can be used. + * + * @param avctx the codec context + * @param[out] buf the output buffer + * @param[in] buf_size the output buffer size + * @param[in] samples the input buffer containing the samples + * The number of samples read from this buffer is frame_size*channels, + * both of which are defined in avctx. + * For codecs which have avctx->frame_size equal to 0 (e.g. PCM) the number of + * samples read from samples is equal to: + * buf_size * 8 / (avctx->channels * av_get_bits_per_sample(avctx->codec_id)) + * This also implies that av_get_bits_per_sample() must not return 0 for these + * codecs. + * @return On error a negative value is returned, on success zero or the number + * of bytes used to encode the data read from the input buffer. + */ +int attribute_deprecated avcodec_encode_audio(AVCodecContext *avctx, + uint8_t *buf, int buf_size, + const short *samples); +#endif + +/** + * Encode a frame of audio. + * + * Takes input samples from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay, split, and combine input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. + * + * If this function fails or produces no output, avpkt will be + * freed using av_free_packet() (i.e. avpkt->destruct will be + * called to free the user supplied buffer). + * @param[in] frame AVFrame containing the raw audio data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame + * can have any number of samples. + * If it is not set, frame->nb_samples must be equal to + * avctx->frame_size for all frames except the last. + * The final frame may be smaller than avctx->frame_size. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + +#if FF_API_OLD_ENCODE_VIDEO +/** + * @deprecated use avcodec_encode_video2() instead. + * + * Encode a video frame from pict into buf. + * The input picture should be + * stored using a specific format, namely avctx.pix_fmt. + * + * @param avctx the codec context + * @param[out] buf the output buffer for the bitstream of encoded frame + * @param[in] buf_size the size of the output buffer in bytes + * @param[in] pict the input picture to encode + * @return On error a negative value is returned, on success zero or the number + * of bytes used from the output buffer. + */ +attribute_deprecated +int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVFrame *pict); +#endif + +/** + * Encode a frame of video. + * + * Takes input raw video data from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay and reorder input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. The returned data (if any) belongs to the + * caller, he is responsible for freeing it. + * + * If this function fails or produces no output, avpkt will be + * freed using av_free_packet() (i.e. avpkt->destruct will be + * called to free the user supplied buffer). + * @param[in] frame AVFrame containing the raw video data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub); + + +/** + * @} + */ + +#if FF_API_AVCODEC_RESAMPLE +/** + * @defgroup lavc_resample Audio resampling + * @ingroup libavc + * @deprecated use libavresample instead + * + * @{ + */ +struct ReSampleContext; +struct AVResampleContext; + +typedef struct ReSampleContext ReSampleContext; + +/** + * Initialize audio resampling context. + * + * @param output_channels number of output channels + * @param input_channels number of input channels + * @param output_rate output sample rate + * @param input_rate input sample rate + * @param sample_fmt_out requested output sample format + * @param sample_fmt_in input sample format + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff frequency + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear if 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + * @return allocated ReSampleContext, NULL if error occurred + */ +attribute_deprecated +ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, + int output_rate, int input_rate, + enum AVSampleFormat sample_fmt_out, + enum AVSampleFormat sample_fmt_in, + int filter_length, int log2_phase_count, + int linear, double cutoff); + +attribute_deprecated +int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); + +/** + * Free resample context. + * + * @param s a non-NULL pointer to a resample context previously + * created with av_audio_resample_init() + */ +attribute_deprecated +void audio_resample_close(ReSampleContext *s); + + +/** + * Initialize an audio resampler. + * Note, if either rate is not an integer then simply scale both rates up so they are. + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + */ +attribute_deprecated +struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); + +/** + * Resample an array of samples using a previously configured context. + * @param src an array of unconsumed samples + * @param consumed the number of samples of src which have been consumed are returned here + * @param src_size the number of unconsumed samples available + * @param dst_size the amount of space in samples available in dst + * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. + * @return the number of samples written in dst or -1 if an error occurred + */ +attribute_deprecated +int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); + + +/** + * Compensate samplerate/timestamp drift. The compensation is done by changing + * the resampler parameters, so no audible clicks or similar distortions occur + * @param compensation_distance distance in output samples over which the compensation should be performed + * @param sample_delta number of output samples which should be output less + * + * example: av_resample_compensate(c, 10, 500) + * here instead of 510 samples only 500 samples would be output + * + * note, due to rounding the actual compensation might be slightly different, + * especially if the compensation_distance is large and the in_rate used during init is small + */ +attribute_deprecated +void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); +attribute_deprecated +void av_resample_close(struct AVResampleContext *c); + +/** + * @} + */ +#endif + +/** + * @addtogroup lavc_picture + * @{ + */ + +/** + * Allocate memory for a picture. Call avpicture_free() to free it. + * + * @see avpicture_fill() + * + * @param picture the picture to be filled in + * @param pix_fmt the format of the picture + * @param width the width of the picture + * @param height the height of the picture + * @return zero if successful, a negative value if not + */ +int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Free a picture previously allocated by avpicture_alloc(). + * The data buffer used by the AVPicture is freed, but the AVPicture structure + * itself is not. + * + * @param picture the AVPicture to be freed + */ +void avpicture_free(AVPicture *picture); + +/** + * Fill in the AVPicture fields. + * The fields of the given AVPicture are filled in by using the 'ptr' address + * which points to the image data buffer. Depending on the specified picture + * format, one or multiple image data pointers and line sizes will be set. + * If a planar format is specified, several pointers will be set pointing to + * the different picture planes and the line sizes of the different planes + * will be stored in the lines_sizes array. + * Call with ptr == NULL to get the required size for the ptr buffer. + * + * To allocate the buffer and fill in the AVPicture fields in one call, + * use avpicture_alloc(). + * + * @param picture AVPicture whose fields are to be filled in + * @param ptr Buffer which will contain or contains the actual image data + * @param pix_fmt The format in which the picture data is stored. + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return size of the image data in bytes + */ +int avpicture_fill(AVPicture *picture, uint8_t *ptr, + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Copy pixel data from an AVPicture into a buffer. + * The data is stored compactly, without any gaps for alignment or padding + * which may be applied by avpicture_fill(). + * + * @see avpicture_get_size() + * + * @param[in] src AVPicture containing image data + * @param[in] pix_fmt The format in which the picture data is stored. + * @param[in] width the width of the image in pixels. + * @param[in] height the height of the image in pixels. + * @param[out] dest A buffer into which picture data will be copied. + * @param[in] dest_size The size of 'dest'. + * @return The number of bytes written to dest, or a negative value (error code) on error. + */ +int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, + int width, int height, + unsigned char *dest, int dest_size); + +/** + * Calculate the size in bytes that a picture of the given width and height + * would occupy if stored in the given picture format. + * Note that this returns the size of a compact representation as generated + * by avpicture_layout(), which can be smaller than the size required for e.g. + * avpicture_fill(). + * + * @param pix_fmt the given picture format + * @param width the width of the image + * @param height the height of the image + * @return Image data size in bytes or -1 on error (e.g. too large dimensions). + */ +int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); + +/** + * deinterlace - if not supported return -1 + */ +int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int width, int height); +/** + * Copy image src to dst. Wraps av_picture_data_copy() above. + */ +void av_picture_copy(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Crop image top and left side. + */ +int av_picture_crop(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int top_band, int left_band); + +/** + * Pad image. + */ +int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, + int padtop, int padbottom, int padleft, int padright, int *color); + +/** + * @} + */ + +/** + * @defgroup lavc_misc Utility functions + * @ingroup libavc + * + * Miscellaneous utility functions related to both encoding and decoding + * (or neither). + * @{ + */ + +/** + * @defgroup lavc_misc_pixfmt Pixel formats + * + * Functions for working with pixel formats. + * @{ + */ + +void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift); + +/** + * Return a value representing the fourCC code associated to the + * pixel format pix_fmt, or 0 if no associated fourCC code can be + * found. + */ +unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt); + +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ + +/** + * Compute what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * avcodec_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur. + */ +int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, + int has_alpha); + +#if FF_API_FIND_BEST_PIX_FMT +/** + * @deprecated use avcodec_find_best_pix_fmt2() instead. + * + * Find the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * pix_fmt_mask parameter. + * + * @code + * src_pix_fmt = AV_PIX_FMT_YUV420P; + * pix_fmt_mask = (1 << AV_PIX_FMT_YUV422P) || (1 << AV_PIX_FMT_RGB24); + * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); + * @endcode + * + * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + */ +attribute_deprecated +enum AVPixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum AVPixelFormat src_pix_fmt, + int has_alpha, int *loss_ptr); +#endif /* FF_API_FIND_BEST_PIX_FMT */ + +/** + * Find the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt2() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * pix_fmt_list parameter. + * + * + * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + */ +enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list, + enum AVPixelFormat src_pix_fmt, + int has_alpha, int *loss_ptr); + +enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt); + +/** + * @} + */ + +void avcodec_set_dimensions(AVCodecContext *s, int width, int height); + +/** + * Put a string representing the codec tag codec_tag in buf. + * + * @param buf_size size in bytes of buf + * @return the length of the string that would have been generated if + * enough space had been available, excluding the trailing null + */ +size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); + +void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); + +/** + * Return a name for the specified profile, if available. + * + * @param codec the codec that is searched for the given profile + * @param profile the profile value for which a name is requested + * @return A name for the profile if found, NULL otherwise. + */ +const char *av_get_profile_name(const AVCodec *codec, int profile); + +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); +int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); +//FIXME func typedef + +/** + * Fill audio frame data and linesize. + * AVFrame extended_data channel pointers are allocated if necessary for + * planar audio. + * + * @param frame the AVFrame + * frame->nb_samples must be set prior to calling the + * function. This function fills in frame->data, + * frame->extended_data, frame->linesize[0]. + * @param nb_channels channel count + * @param sample_fmt sample format + * @param buf buffer to use for frame data + * @param buf_size size of buffer + * @param align plane size sample alignment (0 = default) + * @return 0 on success, negative error code on failure + */ +int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, + enum AVSampleFormat sample_fmt, const uint8_t *buf, + int buf_size, int align); + +/** + * Flush buffers, should be called when seeking or when switching to a different stream. + */ +void avcodec_flush_buffers(AVCodecContext *avctx); + +void avcodec_default_free_buffers(AVCodecContext *s); + +/** + * Return codec bits per sample. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_bits_per_sample(enum AVCodecID codec_id); + +/** + * Return codec bits per sample. + * Only return non-zero if the bits per sample is exactly correct, not an + * approximation. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_exact_bits_per_sample(enum AVCodecID codec_id); + +/** + * Return audio frame duration. + * + * @param avctx codec context + * @param frame_bytes size of the frame, or 0 if unknown + * @return frame duration, in samples, if known. 0 if not able to + * determine. + */ +int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); + + +typedef struct AVBitStreamFilterContext { + void *priv_data; + struct AVBitStreamFilter *filter; + AVCodecParserContext *parser; + struct AVBitStreamFilterContext *next; +} AVBitStreamFilterContext; + + +typedef struct AVBitStreamFilter { + const char *name; + int priv_data_size; + int (*filter)(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); + void (*close)(AVBitStreamFilterContext *bsfc); + struct AVBitStreamFilter *next; +} AVBitStreamFilter; + +void av_register_bitstream_filter(AVBitStreamFilter *bsf); +AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); +int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); + +AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); + +/* memory */ + +/** + * Reallocate the given block if it is not large enough, otherwise do nothing. + * + * @see av_realloc + */ +void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Allocate a buffer, reusing the given one if large enough. + * + * Contrary to av_fast_realloc the current buffer contents might not be + * preserved and on error the old buffer is freed, thus no special + * handling to avoid memleaks is necessary. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + */ +void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Allocate a buffer with padding, reusing the given one if large enough. + * + * Same behaviour av_fast_malloc but the buffer has additional + * FF_INPUT_PADDING_SIZE at the end which will always memset to 0. + * + */ +void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Encode extradata length to a buffer. Used by xiph codecs. + * + * @param s buffer to write to; must be at least (v/255+1) bytes long + * @param v size of extradata in bytes + * @return number of bytes written to the buffer. + */ +unsigned int av_xiphlacing(unsigned char *s, unsigned int v); + +/** + * Log a generic warning message about a missing feature. This function is + * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] feature string containing the name of the missing feature + * @param[in] want_sample indicates if samples are wanted which exhibit this feature. + * If want_sample is non-zero, additional verbage will be added to the log + * message which tells the user how to report samples to the development + * mailing list. + */ +void av_log_missing_feature(void *avc, const char *feature, int want_sample); + +/** + * Log a generic warning message asking for a sample. This function is + * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] msg string containing an optional message, or NULL if no message + */ +void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3); + +/** + * Register the hardware accelerator hwaccel. + */ +void av_register_hwaccel(AVHWAccel *hwaccel); + +/** + * If hwaccel is NULL, returns the first registered hardware accelerator, + * if hwaccel is non-NULL, returns the next registered hardware accelerator + * after hwaccel, or NULL if hwaccel is the last one. + */ +AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); + + +/** + * Lock operation used by lockmgr + */ +enum AVLockOp { + AV_LOCK_CREATE, ///< Create a mutex + AV_LOCK_OBTAIN, ///< Lock the mutex + AV_LOCK_RELEASE, ///< Unlock the mutex + AV_LOCK_DESTROY, ///< Free mutex resources +}; + +/** + * Register a user provided lock manager supporting the operations + * specified by AVLockOp. mutex points to a (void *) where the + * lockmgr should store/get a pointer to a user allocated mutex. It's + * NULL upon AV_LOCK_CREATE and != NULL for all other ops. + * + * @param cb User defined callback. Note: Libav may invoke calls to this + * callback during the call to av_lockmgr_register(). + * Thus, the application must be prepared to handle that. + * If cb is set to NULL the lockmgr will be unregistered. + * Also note that during unregistration the previously registered + * lockmgr callback may also be invoked. + */ +int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); + +/** + * Get the type of the given codec. + */ +enum AVMediaType avcodec_get_type(enum AVCodecID codec_id); + +/** + * @return a positive value if s is open (i.e. avcodec_open2() was called on it + * with no corresponding avcodec_close()), 0 otherwise. + */ +int avcodec_is_open(AVCodecContext *s); + +/** + * @return a non-zero number if codec is an encoder, zero otherwise + */ +int av_codec_is_encoder(const AVCodec *codec); + +/** + * @return a non-zero number if codec is a decoder, zero otherwise + */ +int av_codec_is_decoder(const AVCodec *codec); + +/** + * @return descriptor for given codec ID or NULL if no descriptor exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id); + +/** + * Iterate over all codec descriptors known to libavcodec. + * + * @param prev previous descriptor. NULL to get the first descriptor. + * + * @return next descriptor or NULL after the last descriptor + */ +const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); + +/** + * @return codec descriptor with the given name or NULL if no such descriptor + * exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); + +/** + * @} + */ + +#endif /* AVCODEC_AVCODEC_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/avfft.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/avfft.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,116 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVFFT_H +#define AVCODEC_AVFFT_H + +/** + * @file + * @ingroup lavc_fft + * FFT functions + */ + +/** + * @defgroup lavc_fft FFT functions + * @ingroup lavc_misc + * + * @{ + */ + +typedef float FFTSample; + +typedef struct FFTComplex { + FFTSample re, im; +} FFTComplex; + +typedef struct FFTContext FFTContext; + +/** + * Set up a complex FFT. + * @param nbits log2 of the length of the input array + * @param inverse if 0 perform the forward transform, if 1 perform the inverse + */ +FFTContext *av_fft_init(int nbits, int inverse); + +/** + * Do the permutation needed BEFORE calling ff_fft_calc(). + */ +void av_fft_permute(FFTContext *s, FFTComplex *z); + +/** + * Do a complex FFT with the parameters defined in av_fft_init(). The + * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + */ +void av_fft_calc(FFTContext *s, FFTComplex *z); + +void av_fft_end(FFTContext *s); + +FFTContext *av_mdct_init(int nbits, int inverse, double scale); +void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_end(FFTContext *s); + +/* Real Discrete Fourier Transform */ + +enum RDFTransformType { + DFT_R2C, + IDFT_C2R, + IDFT_R2C, + DFT_C2R, +}; + +typedef struct RDFTContext RDFTContext; + +/** + * Set up a real FFT. + * @param nbits log2 of the length of the input array + * @param trans the type of transform + */ +RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); +void av_rdft_calc(RDFTContext *s, FFTSample *data); +void av_rdft_end(RDFTContext *s); + +/* Discrete Cosine Transform */ + +typedef struct DCTContext DCTContext; + +enum DCTTransformType { + DCT_II = 0, + DCT_III, + DCT_I, + DST_I, +}; + +/** + * Set up DCT. + * @param nbits size of the input array: + * (1 << nbits) for DCT-II, DCT-III and DST-I + * (1 << nbits) + 1 for DCT-I + * + * @note the first element of the input of DST-I is ignored + */ +DCTContext *av_dct_init(int nbits, enum DCTTransformType type); +void av_dct_calc(DCTContext *s, FFTSample *data); +void av_dct_end (DCTContext *s); + +/** + * @} + */ + +#endif /* AVCODEC_AVFFT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/dxva2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/dxva2.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,88 @@ +/* + * DXVA2 HW acceleration + * + * copyright (c) 2009 Laurent Aimar + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DXVA_H +#define AVCODEC_DXVA_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_dxva2 + * Public libavcodec DXVA2 header. + */ + +#include + +#include +#include + +/** + * @defgroup lavc_codec_hwaccel_dxva2 DXVA2 + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards + +/** + * This structure is used to provides the necessary configurations and data + * to the DXVA2 Libav HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct dxva_context { + /** + * DXVA2 decoder object + */ + IDirectXVideoDecoder *decoder; + + /** + * DXVA2 configuration used to create the decoder + */ + const DXVA2_ConfigPictureDecode *cfg; + + /** + * The number of surface in the surface array + */ + unsigned surface_count; + + /** + * The array of Direct3D surfaces used to create the decoder + */ + LPDIRECT3DSURFACE9 *surface; + + /** + * A bit field configuring the workarounds needed for using the decoder + */ + uint64_t workaround; + + /** + * Private to the Libav AVHWAccel implementation + */ + unsigned report_id; +}; + +/** + * @} + */ + +#endif /* AVCODEC_DXVA_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/old_codec_ids.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/old_codec_ids.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,366 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_OLD_CODEC_IDS_H +#define AVCODEC_OLD_CODEC_IDS_H + +/* + * This header exists to prevent new codec IDs from being accidentally added to + * the deprecated list. + * Do not include it directly. It will be removed on next major bump + * + * Do not add new items to this list. Use the AVCodecID enum instead. + */ + + CODEC_ID_NONE = AV_CODEC_ID_NONE, + + /* video codecs */ + CODEC_ID_MPEG1VIDEO, + CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, + CODEC_ID_H263, + CODEC_ID_RV10, + CODEC_ID_RV20, + CODEC_ID_MJPEG, + CODEC_ID_MJPEGB, + CODEC_ID_LJPEG, + CODEC_ID_SP5X, + CODEC_ID_JPEGLS, + CODEC_ID_MPEG4, + CODEC_ID_RAWVIDEO, + CODEC_ID_MSMPEG4V1, + CODEC_ID_MSMPEG4V2, + CODEC_ID_MSMPEG4V3, + CODEC_ID_WMV1, + CODEC_ID_WMV2, + CODEC_ID_H263P, + CODEC_ID_H263I, + CODEC_ID_FLV1, + CODEC_ID_SVQ1, + CODEC_ID_SVQ3, + CODEC_ID_DVVIDEO, + CODEC_ID_HUFFYUV, + CODEC_ID_CYUV, + CODEC_ID_H264, + CODEC_ID_INDEO3, + CODEC_ID_VP3, + CODEC_ID_THEORA, + CODEC_ID_ASV1, + CODEC_ID_ASV2, + CODEC_ID_FFV1, + CODEC_ID_4XM, + CODEC_ID_VCR1, + CODEC_ID_CLJR, + CODEC_ID_MDEC, + CODEC_ID_ROQ, + CODEC_ID_INTERPLAY_VIDEO, + CODEC_ID_XAN_WC3, + CODEC_ID_XAN_WC4, + CODEC_ID_RPZA, + CODEC_ID_CINEPAK, + CODEC_ID_WS_VQA, + CODEC_ID_MSRLE, + CODEC_ID_MSVIDEO1, + CODEC_ID_IDCIN, + CODEC_ID_8BPS, + CODEC_ID_SMC, + CODEC_ID_FLIC, + CODEC_ID_TRUEMOTION1, + CODEC_ID_VMDVIDEO, + CODEC_ID_MSZH, + CODEC_ID_ZLIB, + CODEC_ID_QTRLE, + CODEC_ID_SNOW, + CODEC_ID_TSCC, + CODEC_ID_ULTI, + CODEC_ID_QDRAW, + CODEC_ID_VIXL, + CODEC_ID_QPEG, + CODEC_ID_PNG, + CODEC_ID_PPM, + CODEC_ID_PBM, + CODEC_ID_PGM, + CODEC_ID_PGMYUV, + CODEC_ID_PAM, + CODEC_ID_FFVHUFF, + CODEC_ID_RV30, + CODEC_ID_RV40, + CODEC_ID_VC1, + CODEC_ID_WMV3, + CODEC_ID_LOCO, + CODEC_ID_WNV1, + CODEC_ID_AASC, + CODEC_ID_INDEO2, + CODEC_ID_FRAPS, + CODEC_ID_TRUEMOTION2, + CODEC_ID_BMP, + CODEC_ID_CSCD, + CODEC_ID_MMVIDEO, + CODEC_ID_ZMBV, + CODEC_ID_AVS, + CODEC_ID_SMACKVIDEO, + CODEC_ID_NUV, + CODEC_ID_KMVC, + CODEC_ID_FLASHSV, + CODEC_ID_CAVS, + CODEC_ID_JPEG2000, + CODEC_ID_VMNC, + CODEC_ID_VP5, + CODEC_ID_VP6, + CODEC_ID_VP6F, + CODEC_ID_TARGA, + CODEC_ID_DSICINVIDEO, + CODEC_ID_TIERTEXSEQVIDEO, + CODEC_ID_TIFF, + CODEC_ID_GIF, + CODEC_ID_DXA, + CODEC_ID_DNXHD, + CODEC_ID_THP, + CODEC_ID_SGI, + CODEC_ID_C93, + CODEC_ID_BETHSOFTVID, + CODEC_ID_PTX, + CODEC_ID_TXD, + CODEC_ID_VP6A, + CODEC_ID_AMV, + CODEC_ID_VB, + CODEC_ID_PCX, + CODEC_ID_SUNRAST, + CODEC_ID_INDEO4, + CODEC_ID_INDEO5, + CODEC_ID_MIMIC, + CODEC_ID_RL2, + CODEC_ID_ESCAPE124, + CODEC_ID_DIRAC, + CODEC_ID_BFI, + CODEC_ID_CMV, + CODEC_ID_MOTIONPIXELS, + CODEC_ID_TGV, + CODEC_ID_TGQ, + CODEC_ID_TQI, + CODEC_ID_AURA, + CODEC_ID_AURA2, + CODEC_ID_V210X, + CODEC_ID_TMV, + CODEC_ID_V210, + CODEC_ID_DPX, + CODEC_ID_MAD, + CODEC_ID_FRWU, + CODEC_ID_FLASHSV2, + CODEC_ID_CDGRAPHICS, + CODEC_ID_R210, + CODEC_ID_ANM, + CODEC_ID_BINKVIDEO, + CODEC_ID_IFF_ILBM, + CODEC_ID_IFF_BYTERUN1, + CODEC_ID_KGV1, + CODEC_ID_YOP, + CODEC_ID_VP8, + CODEC_ID_PICTOR, + CODEC_ID_ANSI, + CODEC_ID_A64_MULTI, + CODEC_ID_A64_MULTI5, + CODEC_ID_R10K, + CODEC_ID_MXPEG, + CODEC_ID_LAGARITH, + CODEC_ID_PRORES, + CODEC_ID_JV, + CODEC_ID_DFA, + CODEC_ID_WMV3IMAGE, + CODEC_ID_VC1IMAGE, + CODEC_ID_UTVIDEO, + CODEC_ID_BMV_VIDEO, + CODEC_ID_VBLE, + CODEC_ID_DXTORY, + CODEC_ID_V410, + CODEC_ID_XWD, + CODEC_ID_CDXL, + CODEC_ID_XBM, + CODEC_ID_ZEROCODEC, + CODEC_ID_MSS1, + CODEC_ID_MSA1, + CODEC_ID_TSCC2, + CODEC_ID_MTS2, + CODEC_ID_CLLC, + + /* various PCM "codecs" */ + CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs + CODEC_ID_PCM_S16LE = 0x10000, + CODEC_ID_PCM_S16BE, + CODEC_ID_PCM_U16LE, + CODEC_ID_PCM_U16BE, + CODEC_ID_PCM_S8, + CODEC_ID_PCM_U8, + CODEC_ID_PCM_MULAW, + CODEC_ID_PCM_ALAW, + CODEC_ID_PCM_S32LE, + CODEC_ID_PCM_S32BE, + CODEC_ID_PCM_U32LE, + CODEC_ID_PCM_U32BE, + CODEC_ID_PCM_S24LE, + CODEC_ID_PCM_S24BE, + CODEC_ID_PCM_U24LE, + CODEC_ID_PCM_U24BE, + CODEC_ID_PCM_S24DAUD, + CODEC_ID_PCM_ZORK, + CODEC_ID_PCM_S16LE_PLANAR, + CODEC_ID_PCM_DVD, + CODEC_ID_PCM_F32BE, + CODEC_ID_PCM_F32LE, + CODEC_ID_PCM_F64BE, + CODEC_ID_PCM_F64LE, + CODEC_ID_PCM_BLURAY, + CODEC_ID_PCM_LXF, + CODEC_ID_S302M, + CODEC_ID_PCM_S8_PLANAR, + + /* various ADPCM codecs */ + CODEC_ID_ADPCM_IMA_QT = 0x11000, + CODEC_ID_ADPCM_IMA_WAV, + CODEC_ID_ADPCM_IMA_DK3, + CODEC_ID_ADPCM_IMA_DK4, + CODEC_ID_ADPCM_IMA_WS, + CODEC_ID_ADPCM_IMA_SMJPEG, + CODEC_ID_ADPCM_MS, + CODEC_ID_ADPCM_4XM, + CODEC_ID_ADPCM_XA, + CODEC_ID_ADPCM_ADX, + CODEC_ID_ADPCM_EA, + CODEC_ID_ADPCM_G726, + CODEC_ID_ADPCM_CT, + CODEC_ID_ADPCM_SWF, + CODEC_ID_ADPCM_YAMAHA, + CODEC_ID_ADPCM_SBPRO_4, + CODEC_ID_ADPCM_SBPRO_3, + CODEC_ID_ADPCM_SBPRO_2, + CODEC_ID_ADPCM_THP, + CODEC_ID_ADPCM_IMA_AMV, + CODEC_ID_ADPCM_EA_R1, + CODEC_ID_ADPCM_EA_R3, + CODEC_ID_ADPCM_EA_R2, + CODEC_ID_ADPCM_IMA_EA_SEAD, + CODEC_ID_ADPCM_IMA_EA_EACS, + CODEC_ID_ADPCM_EA_XAS, + CODEC_ID_ADPCM_EA_MAXIS_XA, + CODEC_ID_ADPCM_IMA_ISS, + CODEC_ID_ADPCM_G722, + CODEC_ID_ADPCM_IMA_APC, + + /* AMR */ + CODEC_ID_AMR_NB = 0x12000, + CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + CODEC_ID_RA_144 = 0x13000, + CODEC_ID_RA_288, + + /* various DPCM codecs */ + CODEC_ID_ROQ_DPCM = 0x14000, + CODEC_ID_INTERPLAY_DPCM, + CODEC_ID_XAN_DPCM, + CODEC_ID_SOL_DPCM, + + /* audio codecs */ + CODEC_ID_MP2 = 0x15000, + CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + CODEC_ID_AAC, + CODEC_ID_AC3, + CODEC_ID_DTS, + CODEC_ID_VORBIS, + CODEC_ID_DVAUDIO, + CODEC_ID_WMAV1, + CODEC_ID_WMAV2, + CODEC_ID_MACE3, + CODEC_ID_MACE6, + CODEC_ID_VMDAUDIO, + CODEC_ID_FLAC, + CODEC_ID_MP3ADU, + CODEC_ID_MP3ON4, + CODEC_ID_SHORTEN, + CODEC_ID_ALAC, + CODEC_ID_WESTWOOD_SND1, + CODEC_ID_GSM, ///< as in Berlin toast format + CODEC_ID_QDM2, + CODEC_ID_COOK, + CODEC_ID_TRUESPEECH, + CODEC_ID_TTA, + CODEC_ID_SMACKAUDIO, + CODEC_ID_QCELP, + CODEC_ID_WAVPACK, + CODEC_ID_DSICINAUDIO, + CODEC_ID_IMC, + CODEC_ID_MUSEPACK7, + CODEC_ID_MLP, + CODEC_ID_GSM_MS, /* as found in WAV */ + CODEC_ID_ATRAC3, + CODEC_ID_VOXWARE, + CODEC_ID_APE, + CODEC_ID_NELLYMOSER, + CODEC_ID_MUSEPACK8, + CODEC_ID_SPEEX, + CODEC_ID_WMAVOICE, + CODEC_ID_WMAPRO, + CODEC_ID_WMALOSSLESS, + CODEC_ID_ATRAC3P, + CODEC_ID_EAC3, + CODEC_ID_SIPR, + CODEC_ID_MP1, + CODEC_ID_TWINVQ, + CODEC_ID_TRUEHD, + CODEC_ID_MP4ALS, + CODEC_ID_ATRAC1, + CODEC_ID_BINKAUDIO_RDFT, + CODEC_ID_BINKAUDIO_DCT, + CODEC_ID_AAC_LATM, + CODEC_ID_QDMC, + CODEC_ID_CELT, + CODEC_ID_G723_1, + CODEC_ID_G729, + CODEC_ID_8SVX_EXP, + CODEC_ID_8SVX_FIB, + CODEC_ID_BMV_AUDIO, + CODEC_ID_RALF, + CODEC_ID_IAC, + CODEC_ID_ILBC, + + /* subtitle codecs */ + CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. + CODEC_ID_DVD_SUBTITLE = 0x17000, + CODEC_ID_DVB_SUBTITLE, + CODEC_ID_TEXT, ///< raw UTF-8 text + CODEC_ID_XSUB, + CODEC_ID_SSA, + CODEC_ID_MOV_TEXT, + CODEC_ID_HDMV_PGS_SUBTITLE, + CODEC_ID_DVB_TELETEXT, + CODEC_ID_SRT, + + /* other specific kind of codecs (generally used for attachments) */ + CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. + CODEC_ID_TTF = 0x18000, + + CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it + + CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ + CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems + * stream (only used by libavformat) */ + CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. + +#endif /* AVCODEC_OLD_CODEC_IDS_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/vaapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/vaapi.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,173 @@ +/* + * Video Acceleration API (shared data between Libav and the video player) + * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 + * + * Copyright (C) 2008-2009 Splitted-Desktop Systems + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VAAPI_H +#define AVCODEC_VAAPI_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vaapi + * Public libavcodec VA API header. + */ + +#include + +/** + * @defgroup lavc_codec_hwaccel_vaapi VA API Decoding + * @ingroup lavc_codec_hwaccel + * @{ + */ + +/** + * This structure is used to share data between the Libav library and + * the client video application. + * This shall be zero-allocated and available as + * AVCodecContext.hwaccel_context. All user members can be set once + * during initialization or through each AVCodecContext.get_buffer() + * function call. In any case, they must be valid prior to calling + * decoding functions. + */ +struct vaapi_context { + /** + * Window system dependent data + * + * - encoding: unused + * - decoding: Set by user + */ + void *display; + + /** + * Configuration ID + * + * - encoding: unused + * - decoding: Set by user + */ + uint32_t config_id; + + /** + * Context ID (video decode pipeline) + * + * - encoding: unused + * - decoding: Set by user + */ + uint32_t context_id; + + /** + * VAPictureParameterBuffer ID + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t pic_param_buf_id; + + /** + * VAIQMatrixBuffer ID + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t iq_matrix_buf_id; + + /** + * VABitPlaneBuffer ID (for VC-1 decoding) + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t bitplane_buf_id; + + /** + * Slice parameter/data buffer IDs + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t *slice_buf_ids; + + /** + * Number of effective slice buffer IDs to send to the HW + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int n_slice_buf_ids; + + /** + * Size of pre-allocated slice_buf_ids + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_buf_ids_alloc; + + /** + * Pointer to VASliceParameterBuffers + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + void *slice_params; + + /** + * Size of a VASliceParameterBuffer element + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_param_size; + + /** + * Size of pre-allocated slice_params + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_params_alloc; + + /** + * Number of slices currently filled in + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_count; + + /** + * Pointer to slice data buffer base + * - encoding: unused + * - decoding: Set by libavcodec + */ + const uint8_t *slice_data; + + /** + * Current size of slice data + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t slice_data_size; +}; + +/* @} */ + +#endif /* AVCODEC_VAAPI_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/vda.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/vda.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,217 @@ +/* + * VDA HW acceleration + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDA_H +#define AVCODEC_VDA_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vda + * Public libavcodec VDA header. + */ + +#include "libavcodec/version.h" + +#if FF_API_VDA_ASYNC +#include +#endif + +#include + +// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes +// http://openradar.appspot.com/8026390 +#undef __GNUC_STDC_INLINE__ + +#define Picture QuickdrawPicture +#include +#undef Picture + +/** + * @defgroup lavc_codec_hwaccel_vda VDA + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#if FF_API_VDA_ASYNC +/** + * This structure is used to store decoded frame information and data. + * + * @deprecated Use synchronous decoding mode. + */ +typedef struct vda_frame { + /** + * The PTS of the frame. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + int64_t pts; + + /** + * The CoreVideo buffer that contains the decoded data. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + CVPixelBufferRef cv_buffer; + + /** + * A pointer to the next frame. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + struct vda_frame *next_frame; +} vda_frame; +#endif + +/** + * This structure is used to provide the necessary configurations and data + * to the VDA Libav HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct vda_context { + /** + * VDA decoder object. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + VDADecoder decoder; + + /** + * The Core Video pixel buffer that contains the current image data. + * + * encoding: unused + * decoding: Set by libavcodec. Unset by user. + */ + CVPixelBufferRef cv_buffer; + + /** + * Use the hardware decoder in synchronous mode. + * + * encoding: unused + * decoding: Set by user. + */ + int use_sync_decoding; + +#if FF_API_VDA_ASYNC + /** + * VDA frames queue ordered by presentation timestamp. + * + * @deprecated Use synchronous decoding mode. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + vda_frame *queue; + + /** + * Mutex for locking queue operations. + * + * @deprecated Use synchronous decoding mode. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + pthread_mutex_t queue_mutex; +#endif + + /** + * The frame width. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int width; + + /** + * The frame height. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int height; + + /** + * The frame format. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int format; + + /** + * The pixel format for output image buffers. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + OSType cv_pix_fmt_type; + + /** + * The current bitstream buffer. + */ + uint8_t *priv_bitstream; + + /** + * The current size of the bitstream. + */ + int priv_bitstream_size; + + /** + * The reference size used for fast reallocation. + */ + int priv_allocated_size; +}; + +/** Create the video decoder. */ +int ff_vda_create_decoder(struct vda_context *vda_ctx, + uint8_t *extradata, + int extradata_size); + +/** Destroy the video decoder. */ +int ff_vda_destroy_decoder(struct vda_context *vda_ctx); + +#if FF_API_VDA_ASYNC +/** + * Return the top frame of the queue. + * + * @deprecated Use synchronous decoding mode. + */ +vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx); + +/** + * Release the given frame. + * + * @deprecated Use synchronous decoding mode. + */ +void ff_vda_release_vda_frame(vda_frame *frame); +#endif + +/** + * @} + */ + +#endif /* AVCODEC_VDA_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/vdpau.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/vdpau.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,94 @@ +/* + * The Video Decode and Presentation API for UNIX (VDPAU) is used for + * hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1. + * + * Copyright (C) 2008 NVIDIA + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDPAU_H +#define AVCODEC_VDPAU_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vdpau + * Public libavcodec VDPAU header. + */ + + +/** + * @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer + * @ingroup lavc_codec_hwaccel + * + * VDPAU hardware acceleration has two modules + * - VDPAU decoding + * - VDPAU presentation + * + * The VDPAU decoding module parses all headers using Libav + * parsing mechanisms and uses VDPAU for the actual decoding. + * + * As per the current implementation, the actual decoding + * and rendering (API calls) are done as part of the VDPAU + * presentation (vo_vdpau.c) module. + * + * @{ + */ + +#include +#include + +/** @brief The videoSurface is used for rendering. */ +#define FF_VDPAU_STATE_USED_FOR_RENDER 1 + +/** + * @brief The videoSurface is needed for reference/prediction. + * The codec manipulates this. + */ +#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2 + +/** + * @brief This structure is used as a callback between the Libav + * decoder (vd_) and presentation (vo_) module. + * This is used for defining a video frame containing surface, + * picture parameter, bitstream information etc which are passed + * between the Libav decoder and its clients. + */ +struct vdpau_render_state { + VdpVideoSurface surface; ///< Used as rendered surface, never changed. + + int state; ///< Holds FF_VDPAU_STATE_* values. + + /** picture parameter information for all supported codecs */ + union VdpPictureInfo { + VdpPictureInfoH264 h264; + VdpPictureInfoMPEG1Or2 mpeg; + VdpPictureInfoVC1 vc1; + VdpPictureInfoMPEG4Part2 mpeg4; + } info; + + /** Describe size/location of the compressed video data. + Set to 0 when freeing bitstream_buffers. */ + int bitstream_buffers_allocated; + int bitstream_buffers_used; + /** The user is responsible for freeing this buffer using av_freep(). */ + VdpBitstreamBuffer *bitstream_buffers; +}; + +/* @}*/ + +#endif /* AVCODEC_VDPAU_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/version.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,95 @@ +/* + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VERSION_H +#define AVCODEC_VERSION_H + +/** + * @file + * @ingroup libavc + * Libavcodec version macros. + */ + +#define LIBAVCODEC_VERSION_MAJOR 54 +#define LIBAVCODEC_VERSION_MINOR 31 +#define LIBAVCODEC_VERSION_MICRO 0 + +#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT + +#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_REQUEST_CHANNELS +#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_OLD_DECODE_AUDIO +#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_OLD_ENCODE_AUDIO +#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_OLD_ENCODE_VIDEO +#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_MPV_GLOBAL_OPTS +#define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_COLOR_TABLE_ID +#define FF_API_COLOR_TABLE_ID (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_INTER_THRESHOLD +#define FF_API_INTER_THRESHOLD (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_SUB_ID +#define FF_API_SUB_ID (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_DSP_MASK +#define FF_API_DSP_MASK (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_FIND_BEST_PIX_FMT +#define FF_API_FIND_BEST_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_CODEC_ID +#define FF_API_CODEC_ID (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_VDA_ASYNC +#define FF_API_VDA_ASYNC (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_AVCODEC_RESAMPLE +#define FF_API_AVCODEC_RESAMPLE (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_LIBMPEG2 +#define FF_API_LIBMPEG2 (LIBAVCODEC_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_MMI +#define FF_API_MMI (LIBAVCODEC_VERSION_MAJOR < 55) +#endif + +#endif /* AVCODEC_VERSION_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavcodec/xvmc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavcodec/xvmc.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2003 Ivan Kalvachev + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_XVMC_H +#define AVCODEC_XVMC_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_xvmc + * Public libavcodec XvMC header. + */ + +#include + +#include "avcodec.h" + +/** + * @defgroup lavc_codec_hwaccel_xvmc XvMC + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct + the number is 1337 speak for the letters IDCT MCo (motion compensation) */ + +struct xvmc_pix_fmt { + /** The field contains the special constant value AV_XVMC_ID. + It is used as a test that the application correctly uses the API, + and that there is no corruption caused by pixel routines. + - application - set during initialization + - libavcodec - unchanged + */ + int xvmc_id; + + /** Pointer to the block array allocated by XvMCCreateBlocks(). + The array has to be freed by XvMCDestroyBlocks(). + Each group of 64 values represents one data block of differential + pixel information (in MoCo mode) or coefficients for IDCT. + - application - set the pointer during initialization + - libavcodec - fills coefficients/pixel data into the array + */ + short* data_blocks; + + /** Pointer to the macroblock description array allocated by + XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks(). + - application - set the pointer during initialization + - libavcodec - fills description data into the array + */ + XvMCMacroBlock* mv_blocks; + + /** Number of macroblock descriptions that can be stored in the mv_blocks + array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_mv_blocks; + + /** Number of blocks that can be stored at once in the data_blocks array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_data_blocks; + + /** Indicate that the hardware would interpret data_blocks as IDCT + coefficients and perform IDCT on them. + - application - set during initialization + - libavcodec - unchanged + */ + int idct; + + /** In MoCo mode it indicates that intra macroblocks are assumed to be in + unsigned format; same as the XVMC_INTRA_UNSIGNED flag. + - application - set during initialization + - libavcodec - unchanged + */ + int unsigned_intra; + + /** Pointer to the surface allocated by XvMCCreateSurface(). + It has to be freed by XvMCDestroySurface() on application exit. + It identifies the frame and its state on the video hardware. + - application - set during initialization + - libavcodec - unchanged + */ + XvMCSurface* p_surface; + +/** Set by the decoder before calling ff_draw_horiz_band(), + needed by the XvMCRenderSurface function. */ +//@{ + /** Pointer to the surface used as past reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_past_surface; + + /** Pointer to the surface used as future reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_future_surface; + + /** top/bottom field or frame + - application - unchanged + - libavcodec - set + */ + unsigned int picture_structure; + + /** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence + - application - unchanged + - libavcodec - set + */ + unsigned int flags; +//}@ + + /** Number of macroblock descriptions in the mv_blocks array + that have already been passed to the hardware. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may increment it + with filled_mb_block_num or zero both. + - libavcodec - unchanged + */ + int start_mv_blocks_num; + + /** Number of new macroblock descriptions in the mv_blocks array (after + start_mv_blocks_num) that are filled by libavcodec and have to be + passed to the hardware. + - application - zeroes it on get_buffer() or after successful + ff_draw_horiz_band(). + - libavcodec - increment with one of each stored MB + */ + int filled_mv_blocks_num; + + /** Number of the next free data block; one data block consists of + 64 short values in the data_blocks array. + All blocks before this one have already been claimed by placing their + position into the corresponding block description structure field, + that are part of the mv_blocks array. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may zero it together + with start_mb_blocks_num. + - libavcodec - each decoded macroblock increases it by the number + of coded blocks it contains. + */ + int next_free_data_block_num; +}; + +/** + * @} + */ + +#endif /* AVCODEC_XVMC_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavformat/avformat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavformat/avformat.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1740 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_AVFORMAT_H +#define AVFORMAT_AVFORMAT_H + +/** + * @file + * @ingroup libavf + * Main libavformat public API header + */ + +/** + * @defgroup libavf I/O and Muxing/Demuxing Library + * @{ + * + * Libavformat (lavf) is a library for dealing with various media container + * formats. Its main two purposes are demuxing - i.e. splitting a media file + * into component streams, and the reverse process of muxing - writing supplied + * data in a specified container format. It also has an @ref lavf_io + * "I/O module" which supports a number of protocols for accessing the data (e.g. + * file, tcp, http and others). Before using lavf, you need to call + * av_register_all() to register all compiled muxers, demuxers and protocols. + * Unless you are absolutely sure you won't use libavformat's network + * capabilities, you should also call avformat_network_init(). + * + * A supported input format is described by an AVInputFormat struct, conversely + * an output format is described by AVOutputFormat. You can iterate over all + * registered input/output formats using the av_iformat_next() / + * av_oformat_next() functions. The protocols layer is not part of the public + * API, so you can only get the names of supported protocols with the + * avio_enum_protocols() function. + * + * Main lavf structure used for both muxing and demuxing is AVFormatContext, + * which exports all information about the file being read or written. As with + * most Libav structures, its size is not part of public ABI, so it cannot be + * allocated on stack or directly with av_malloc(). To create an + * AVFormatContext, use avformat_alloc_context() (some functions, like + * avformat_open_input() might do that for you). + * + * Most importantly an AVFormatContext contains: + * @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat + * "output" format. It is either autodetected or set by user for input; + * always set by user for output. + * @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all + * elementary streams stored in the file. AVStreams are typically referred to + * using their index in this array. + * @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or + * set by user for input, always set by user for output (unless you are dealing + * with an AVFMT_NOFILE format). + * + * @section lavf_options Passing options to (de)muxers + * Lavf allows to configure muxers and demuxers using the @ref avoptions + * mechanism. Generic (format-independent) libavformat options are provided by + * AVFormatContext, they can be examined from a user program by calling + * av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass + * from avformat_get_class()). Private (format-specific) options are provided by + * AVFormatContext.priv_data if and only if AVInputFormat.priv_class / + * AVOutputFormat.priv_class of the corresponding format struct is non-NULL. + * Further options may be provided by the @ref AVFormatContext.pb "I/O context", + * if its AVClass is non-NULL, and the protocols layer. See the discussion on + * nesting in @ref avoptions documentation to learn how to access those. + * + * @defgroup lavf_decoding Demuxing + * @{ + * Demuxers read a media file and split it into chunks of data (@em packets). A + * @ref AVPacket "packet" contains one or more encoded frames which belongs to a + * single elementary stream. In the lavf API this process is represented by the + * avformat_open_input() function for opening a file, av_read_frame() for + * reading a single packet and finally avformat_close_input(), which does the + * cleanup. + * + * @section lavf_decoding_open Opening a media file + * The minimum information required to open a file is its URL or filename, which + * is passed to avformat_open_input(), as in the following code: + * @code + * const char *url = "in.mp3"; + * AVFormatContext *s = NULL; + * int ret = avformat_open_input(&s, url, NULL, NULL); + * if (ret < 0) + * abort(); + * @endcode + * The above code attempts to allocate an AVFormatContext, open the + * specified file (autodetecting the format) and read the header, exporting the + * information stored there into s. Some formats do not have a header or do not + * store enough information there, so it is recommended that you call the + * avformat_find_stream_info() function which tries to read and decode a few + * frames to find missing information. + * + * In some cases you might want to preallocate an AVFormatContext yourself with + * avformat_alloc_context() and do some tweaking on it before passing it to + * avformat_open_input(). One such case is when you want to use custom functions + * for reading input data instead of lavf internal I/O layer. + * To do that, create your own AVIOContext with avio_alloc_context(), passing + * your reading callbacks to it. Then set the @em pb field of your + * AVFormatContext to newly created AVIOContext. + * + * Since the format of the opened file is in general not known until after + * avformat_open_input() has returned, it is not possible to set demuxer private + * options on a preallocated context. Instead, the options should be passed to + * avformat_open_input() wrapped in an AVDictionary: + * @code + * AVDictionary *options = NULL; + * av_dict_set(&options, "video_size", "640x480", 0); + * av_dict_set(&options, "pixel_format", "rgb24", 0); + * + * if (avformat_open_input(&s, url, NULL, &options) < 0) + * abort(); + * av_dict_free(&options); + * @endcode + * This code passes the private options 'video_size' and 'pixel_format' to the + * demuxer. They would be necessary for e.g. the rawvideo demuxer, since it + * cannot know how to interpret raw video data otherwise. If the format turns + * out to be something different than raw video, those options will not be + * recognized by the demuxer and therefore will not be applied. Such unrecognized + * options are then returned in the options dictionary (recognized options are + * consumed). The calling program can handle such unrecognized options as it + * wishes, e.g. + * @code + * AVDictionaryEntry *e; + * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); + * abort(); + * } + * @endcode + * + * After you have finished reading the file, you must close it with + * avformat_close_input(). It will free everything associated with the file. + * + * @section lavf_decoding_read Reading from an opened file + * Reading data from an opened AVFormatContext is done by repeatedly calling + * av_read_frame() on it. Each call, if successful, will return an AVPacket + * containing encoded data for one AVStream, identified by + * AVPacket.stream_index. This packet may be passed straight into the libavcodec + * decoding functions avcodec_decode_video2(), avcodec_decode_audio4() or + * avcodec_decode_subtitle2() if the caller wishes to decode the data. + * + * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be + * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for + * pts/dts, 0 for duration) if the stream does not provide them. The timing + * information will be in AVStream.time_base units, i.e. it has to be + * multiplied by the timebase to convert them to seconds. + * + * The packet data belongs to the demuxer and is invalid after the next call to + * av_read_frame(). The user must free the packet with av_free_packet() before + * calling av_read_frame() again or closing the file. + * + * @section lavf_decoding_seek Seeking + * @} + * + * @defgroup lavf_encoding Muxing + * @{ + * @} + * + * @defgroup lavf_io I/O Read/Write + * @{ + * @} + * + * @defgroup lavf_codec Demuxers + * @{ + * @defgroup lavf_codec_native Native Demuxers + * @{ + * @} + * @defgroup lavf_codec_wrappers External library wrappers + * @{ + * @} + * @} + * @defgroup lavf_protos I/O Protocols + * @{ + * @} + * @defgroup lavf_internal Internal + * @{ + * @} + * @} + * + */ + +#include +#include /* FILE */ +#include "libavcodec/avcodec.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "avio.h" +#include "libavformat/version.h" + +#if FF_API_AV_GETTIME +#include "libavutil/time.h" +#endif + +struct AVFormatContext; + + +/** + * @defgroup metadata_api Public Metadata API + * @{ + * @ingroup libavf + * The metadata API allows libavformat to export metadata tags to a client + * application when demuxing. Conversely it allows a client application to + * set metadata when muxing. + * + * Metadata is exported or set as pairs of key/value strings in the 'metadata' + * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs + * using the @ref lavu_dict "AVDictionary" API. Like all strings in Libav, + * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata + * exported by demuxers isn't checked to be valid UTF-8 in most cases. + * + * Important concepts to keep in mind: + * - Keys are unique; there can never be 2 tags with the same key. This is + * also meant semantically, i.e., a demuxer should not knowingly produce + * several keys that are literally different but semantically identical. + * E.g., key=Author5, key=Author6. In this example, all authors must be + * placed in the same tag. + * - Metadata is flat, not hierarchical; there are no subtags. If you + * want to store, e.g., the email address of the child of producer Alice + * and actor Bob, that could have key=alice_and_bobs_childs_email_address. + * - Several modifiers can be applied to the tag name. This is done by + * appending a dash character ('-') and the modifier name in the order + * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. + * - language -- a tag whose value is localized for a particular language + * is appended with the ISO 639-2/B 3-letter language code. + * For example: Author-ger=Michael, Author-eng=Mike + * The original/default language is in the unqualified "Author" tag. + * A demuxer should set a default if it sets any translated tag. + * - sorting -- a modified version of a tag that should be used for + * sorting will have '-sort' appended. E.g. artist="The Beatles", + * artist-sort="Beatles, The". + * + * - Demuxers attempt to export metadata in a generic format, however tags + * with no generic equivalents are left as they are stored in the container. + * Follows a list of generic tag names: + * + @verbatim + album -- name of the set this work belongs to + album_artist -- main creator of the set/album, if different from artist. + e.g. "Various Artists" for compilation albums. + artist -- main creator of the work + comment -- any additional description of the file. + composer -- who composed the work, if different from artist. + copyright -- name of copyright holder. + creation_time-- date when the file was created, preferably in ISO 8601. + date -- date when the work was created, preferably in ISO 8601. + disc -- number of a subset, e.g. disc in a multi-disc collection. + encoder -- name/settings of the software/hardware that produced the file. + encoded_by -- person/group who created the file. + filename -- original name of the file. + genre -- . + language -- main language in which the work is performed, preferably + in ISO 639-2 format. Multiple languages can be specified by + separating them with commas. + performer -- artist who performed the work, if different from artist. + E.g for "Also sprach Zarathustra", artist would be "Richard + Strauss" and performer "London Philharmonic Orchestra". + publisher -- name of the label/publisher. + service_name -- name of the service in broadcasting (channel name). + service_provider -- name of the service provider in broadcasting. + title -- name of the work. + track -- number of this work in the set, can be in form current/total. + variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @endverbatim + * + * Look in the examples section for an application example how to use the Metadata API. + * + * @} + */ + +/* packet functions */ + + +/** + * Allocate and read the payload of a packet and initialize its + * fields with default values. + * + * @param pkt packet + * @param size desired payload size + * @return >0 (read size) if OK, AVERROR_xxx otherwise + */ +int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); + + +/** + * Read data and append it to the current content of the AVPacket. + * If pkt->size is 0 this is identical to av_get_packet. + * Note that this uses av_grow_packet and thus involves a realloc + * which is inefficient. Thus this function should only be used + * when there is no reasonable way to know (an upper bound of) + * the final size. + * + * @param pkt packet + * @param size amount of data to read + * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data + * will not be lost even if an error occurs. + */ +int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); + +/*************************************************/ +/* fractional numbers for exact pts handling */ + +/** + * The exact value of the fractional number is: 'val + num / den'. + * num is assumed to be 0 <= num < den. + */ +typedef struct AVFrac { + int64_t val, num, den; +} AVFrac; + +/*************************************************/ +/* input/output formats */ + +struct AVCodecTag; + +/** + * This structure contains the data a format has to probe a file. + */ +typedef struct AVProbeData { + const char *filename; + unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */ + int buf_size; /**< Size of buf except extra allocated bytes */ +} AVProbeData; + +#define AVPROBE_SCORE_MAX 100 ///< maximum score, half of that is used for file-extension-based detection +#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer + +/// Demuxer will use avio_open, no opened file should be provided by the caller. +#define AVFMT_NOFILE 0x0001 +#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ +#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ +#define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for + raw picture data. */ +#define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ +#define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ +#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ +#define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */ +#define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ +#define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ +#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ +#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ +#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ +#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ +#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */ +#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly + increasing timestamps, but they must + still be monotonic */ + +/** + * @addtogroup lavf_encoding + * @{ + */ +typedef struct AVOutputFormat { + const char *name; + /** + * Descriptive name for the format, meant to be more human-readable + * than name. You should use the NULL_IF_CONFIG_SMALL() macro + * to define it. + */ + const char *long_name; + const char *mime_type; + const char *extensions; /**< comma-separated filename extensions */ + /* output support */ + enum AVCodecID audio_codec; /**< default audio codec */ + enum AVCodecID video_codec; /**< default video codec */ + enum AVCodecID subtitle_codec; /**< default subtitle codec */ + /** + * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, + * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, + * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, + * AVFMT_TS_NONSTRICT + */ + int flags; + + /** + * List of supported codec_id-codec_tag pairs, ordered by "better + * choice first". The arrays are all terminated by AV_CODEC_ID_NONE. + */ + const struct AVCodecTag * const *codec_tag; + + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVOutputFormat *next; + /** + * size of private data so that it can be allocated in the wrapper + */ + int priv_data_size; + + int (*write_header)(struct AVFormatContext *); + /** + * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, + * pkt can be NULL in order to flush data buffered in the muxer. + * When flushing, return 0 if there still is more data to flush, + * or 1 if everything was flushed and there is no more buffered + * data. + */ + int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); + int (*write_trailer)(struct AVFormatContext *); + /** + * Currently only used to set pixel format if not YUV420P. + */ + int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, + AVPacket *in, int flush); + /** + * Test if the given codec can be stored in this container. + * + * @return 1 if the codec is supported, 0 if it is not. + * A negative number if unknown. + */ + int (*query_codec)(enum AVCodecID id, int std_compliance); +} AVOutputFormat; +/** + * @} + */ + +/** + * @addtogroup lavf_decoding + * @{ + */ +typedef struct AVInputFormat { + /** + * A comma separated list of short names for the format. New names + * may be appended with a minor bump. + */ + const char *name; + + /** + * Descriptive name for the format, meant to be more human-readable + * than name. You should use the NULL_IF_CONFIG_SMALL() macro + * to define it. + */ + const char *long_name; + + /** + * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, + * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. + */ + int flags; + + /** + * If extensions are defined, then no probe is done. You should + * usually not use extension format guessing because it is not + * reliable enough + */ + const char *extensions; + + const struct AVCodecTag * const *codec_tag; + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVInputFormat *next; + + /** + * Raw demuxers store their codec ID here. + */ + int raw_codec_id; + + /** + * Size of private data so that it can be allocated in the wrapper. + */ + int priv_data_size; + + /** + * Tell if a given file has a chance of being parsed as this format. + * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes + * big so you do not have to check for that unless you need more. + */ + int (*read_probe)(AVProbeData *); + + /** + * Read the format header and initialize the AVFormatContext + * structure. Return 0 if OK. Only used in raw format right + * now. 'avformat_new_stream' should be called to create new streams. + */ + int (*read_header)(struct AVFormatContext *); + + /** + * Read one packet and put it in 'pkt'. pts and flags are also + * set. 'avformat_new_stream' can be called only if the flag + * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a + * background thread). + * @return 0 on success, < 0 on error. + * When returning an error, pkt must not have been allocated + * or must be freed before returning + */ + int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); + + /** + * Close the stream. The AVFormatContext and AVStreams are not + * freed by this function + */ + int (*read_close)(struct AVFormatContext *); + + /** + * Seek to a given timestamp relative to the frames in + * stream component stream_index. + * @param stream_index Must not be -1. + * @param flags Selects which direction should be preferred if no exact + * match is available. + * @return >= 0 on success (but not necessarily the new offset) + */ + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp, int flags); + + /** + * Get the next timestamp in stream[stream_index].time_base units. + * @return the timestamp or AV_NOPTS_VALUE if an error occurred + */ + int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit); + + /** + * Start/resume playing - only meaningful if using a network-based format + * (RTSP). + */ + int (*read_play)(struct AVFormatContext *); + + /** + * Pause playing - only meaningful if using a network-based format + * (RTSP). + */ + int (*read_pause)(struct AVFormatContext *); + + /** + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + */ + int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); +} AVInputFormat; +/** + * @} + */ + +enum AVStreamParseType { + AVSTREAM_PARSE_NONE, + AVSTREAM_PARSE_FULL, /**< full parsing and repack */ + AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ + AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */ + AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */ +}; + +typedef struct AVIndexEntry { + int64_t pos; + int64_t timestamp; +#define AVINDEX_KEYFRAME 0x0001 + int flags:2; + int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment). + int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ +} AVIndexEntry; + +#define AV_DISPOSITION_DEFAULT 0x0001 +#define AV_DISPOSITION_DUB 0x0002 +#define AV_DISPOSITION_ORIGINAL 0x0004 +#define AV_DISPOSITION_COMMENT 0x0008 +#define AV_DISPOSITION_LYRICS 0x0010 +#define AV_DISPOSITION_KARAOKE 0x0020 + +/** + * Track should be used during playback by default. + * Useful for subtitle track that should be displayed + * even when user did not explicitly ask for subtitles. + */ +#define AV_DISPOSITION_FORCED 0x0040 +#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */ +#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ +#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ +/** + * The stream is stored in the file as an attached picture/"cover art" (e.g. + * APIC frame in ID3v2). The single packet associated with it will be returned + * among the first few packets read from the file unless seeking takes place. + * It can also be accessed at any time in AVStream.attached_pic. + */ +#define AV_DISPOSITION_ATTACHED_PIC 0x0400 + +/** + * Stream structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVStream) must not be used outside libav*. + */ +typedef struct AVStream { + int index; /**< stream index in AVFormatContext */ + /** + * Format-specific stream ID. + * decoding: set by libavformat + * encoding: set by the user + */ + int id; + /** + * Codec context associated with this stream. Allocated and freed by + * libavformat. + * + * - decoding: The demuxer exports codec information stored in the headers + * here. + * - encoding: The user sets codec information, the muxer writes it to the + * output. Mandatory fields as specified in AVCodecContext + * documentation must be set even if this AVCodecContext is + * not actually used for encoding. + */ + AVCodecContext *codec; +#if FF_API_R_FRAME_RATE + /** + * Real base framerate of the stream. + * This is the lowest framerate with which all timestamps can be + * represented accurately (it is the least common multiple of all + * framerates in the stream). Note, this value is just a guess! + * For example, if the time base is 1/90000 and all frames have either + * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. + */ + AVRational r_frame_rate; +#endif + void *priv_data; + + /** + * encoding: pts generation when outputting stream + */ + struct AVFrac pts; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. + * + * decoding: set by libavformat + * encoding: set by libavformat in avformat_write_header. The muxer may use the + * user-provided value of @ref AVCodecContext.time_base "codec->time_base" + * as a hint. + */ + AVRational time_base; + + /** + * Decoding: pts of the first frame of the stream, in stream time base. + * Only set this if you are absolutely 100% sure that the value you set + * it to really is the pts of the first frame. + * This may be undefined (AV_NOPTS_VALUE). + */ + int64_t start_time; + + /** + * Decoding: duration of the stream, in stream time base. + * If a source file does not specify a duration, but does specify + * a bitrate, this value will be estimated from bitrate and file size. + */ + int64_t duration; + + int64_t nb_frames; ///< number of frames in this stream if known or 0 + + int disposition; /**< AV_DISPOSITION_* bit field */ + + enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. + + /** + * sample aspect ratio (0 if unknown) + * - encoding: Set by user. + * - decoding: Set by libavformat. + */ + AVRational sample_aspect_ratio; + + AVDictionary *metadata; + + /** + * Average framerate + */ + AVRational avg_frame_rate; + + /** + * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet + * will contain the attached picture. + * + * decoding: set by libavformat, must not be modified by the caller. + * encoding: unused + */ + AVPacket attached_pic; + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + /** + * Stream information used internally by av_find_stream_info() + */ +#define MAX_STD_TIMEBASES (60*12+5) + struct { +#if FF_API_R_FRAME_RATE + int64_t last_dts; + int64_t duration_gcd; + int duration_count; + double duration_error[MAX_STD_TIMEBASES]; +#endif + int nb_decoded_frames; + int found_decoder; + + /** + * Those are used for average framerate estimation. + */ + int64_t fps_first_dts; + int fps_first_dts_idx; + int64_t fps_last_dts; + int fps_last_dts_idx; + + } *info; + + int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ + + // Timestamp generation support: + /** + * Timestamp corresponding to the last dts sync point. + * + * Initialized when AVCodecParserContext.dts_sync_point >= 0 and + * a DTS is received from the underlying container. Otherwise set to + * AV_NOPTS_VALUE by default. + */ + int64_t reference_dts; + int64_t first_dts; + int64_t cur_dts; + int64_t last_IP_pts; + int last_IP_duration; + + /** + * Number of packets to buffer for codec probing + */ +#define MAX_PROBE_PACKETS 2500 + int probe_packets; + + /** + * Number of frames that have been demuxed during av_find_stream_info() + */ + int codec_info_nb_frames; + + /* av_read_frame() support */ + enum AVStreamParseType need_parsing; + struct AVCodecParserContext *parser; + + /** + * last packet in packet_buffer for this stream when muxing. + */ + struct AVPacketList *last_in_packet_buffer; + AVProbeData probe_data; +#define MAX_REORDER_DELAY 16 + int64_t pts_buffer[MAX_REORDER_DELAY+1]; + + AVIndexEntry *index_entries; /**< Only used if the format does not + support seeking natively. */ + int nb_index_entries; + unsigned int index_entries_allocated_size; +} AVStream; + +#define AV_PROGRAM_RUNNING 1 + +/** + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVProgram) must not be used outside libav*. + */ +typedef struct AVProgram { + int id; + int flags; + enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller + unsigned int *stream_index; + unsigned int nb_stream_indexes; + AVDictionary *metadata; +} AVProgram; + +#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present + (streams are added dynamically) */ + +typedef struct AVChapter { + int id; ///< unique ID to identify the chapter + AVRational time_base; ///< time base in which the start/end timestamps are specified + int64_t start, end; ///< chapter start/end time in time_base units + AVDictionary *metadata; +} AVChapter; + +/** + * Format I/O context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVFormatContext) must not be used outside libav*, use + * avformat_alloc_context() to create an AVFormatContext. + */ +typedef struct AVFormatContext { + /** + * A class for logging and AVOptions. Set by avformat_alloc_context(). + * Exports (de)muxer private options if they exist. + */ + const AVClass *av_class; + + /** + * Can only be iformat or oformat, not both at the same time. + * + * decoding: set by avformat_open_input(). + * encoding: set by the user. + */ + struct AVInputFormat *iformat; + struct AVOutputFormat *oformat; + + /** + * Format private data. This is an AVOptions-enabled struct + * if and only if iformat/oformat.priv_class is not NULL. + */ + void *priv_data; + + /** + * I/O context. + * + * decoding: either set by the user before avformat_open_input() (then + * the user must close it manually) or set by avformat_open_input(). + * encoding: set by the user. + * + * Do NOT set this field if AVFMT_NOFILE flag is set in + * iformat/oformat.flags. In such a case, the (de)muxer will handle + * I/O in some other way and this field will be NULL. + */ + AVIOContext *pb; + + /* stream info */ + int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ + + /** + * A list of all streams in the file. New streams are created with + * avformat_new_stream(). + * + * decoding: streams are created by libavformat in avformat_open_input(). + * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also + * appear in av_read_frame(). + * encoding: streams are created by the user before avformat_write_header(). + */ + unsigned int nb_streams; + AVStream **streams; + + char filename[1024]; /**< input or output filename */ + + /** + * Decoding: position of the first frame of the component, in + * AV_TIME_BASE fractional seconds. NEVER set this value directly: + * It is deduced from the AVStream values. + */ + int64_t start_time; + + /** + * Decoding: duration of the stream, in AV_TIME_BASE fractional + * seconds. Only set this value if you know none of the individual stream + * durations and also do not set any of them. This is deduced from the + * AVStream values if not set. + */ + int64_t duration; + + /** + * Decoding: total stream bitrate in bit/s, 0 if not + * available. Never set it directly if the file_size and the + * duration are known as Libav can compute it automatically. + */ + int bit_rate; + + unsigned int packet_size; + int max_delay; + + int flags; +#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. +#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. +#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. +#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS +#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container +#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled +#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible +#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. +#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted + + /** + * decoding: size of data to probe; encoding: unused. + */ + unsigned int probesize; + + /** + * decoding: maximum time (in AV_TIME_BASE units) during which the input should + * be analyzed in avformat_find_stream_info(). + */ + int max_analyze_duration; + + const uint8_t *key; + int keylen; + + unsigned int nb_programs; + AVProgram **programs; + + /** + * Forced video codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID video_codec_id; + + /** + * Forced audio codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID audio_codec_id; + + /** + * Forced subtitle codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID subtitle_codec_id; + + /** + * Maximum amount of memory in bytes to use for the index of each stream. + * If the index exceeds this size, entries will be discarded as + * needed to maintain a smaller size. This can lead to slower or less + * accurate seeking (depends on demuxer). + * Demuxers for which a full in-memory index is mandatory will ignore + * this. + * muxing : unused + * demuxing: set by user + */ + unsigned int max_index_size; + + /** + * Maximum amount of memory in bytes to use for buffering frames + * obtained from realtime capture devices. + */ + unsigned int max_picture_buffer; + + unsigned int nb_chapters; + AVChapter **chapters; + + AVDictionary *metadata; + + /** + * Start time of the stream in real world time, in microseconds + * since the unix epoch (00:00 1st January 1970). That is, pts=0 + * in the stream was captured at this real world time. + * - encoding: Set by user. + * - decoding: Unused. + */ + int64_t start_time_realtime; + + /** + * decoding: number of frames used to probe fps + */ + int fps_probe_size; + + /** + * Error recognition; higher values will detect more errors but may + * misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int error_recognition; + + /** + * Custom interrupt callbacks for the I/O layer. + * + * decoding: set by the user before avformat_open_input(). + * encoding: set by the user before avformat_write_header() + * (mainly useful for AVFMT_NOFILE formats). The callback + * should also be passed to avio_open2() if it's used to + * open the file. + */ + AVIOInterruptCB interrupt_callback; + + /** + * Flags to enable debugging. + */ + int debug; +#define FF_FDEBUG_TS 0x0001 + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + /** + * This buffer is only needed when packets were already buffered but + * not decoded, for example to get the codec parameters in MPEG + * streams. + */ + struct AVPacketList *packet_buffer; + struct AVPacketList *packet_buffer_end; + + /* av_seek_frame() support */ + int64_t data_offset; /**< offset of the first packet */ + + /** + * Raw packets from the demuxer, prior to parsing and decoding. + * This buffer is used for buffering packets until the codec can + * be identified, as parsing cannot be done without knowing the + * codec. + */ + struct AVPacketList *raw_packet_buffer; + struct AVPacketList *raw_packet_buffer_end; + /** + * Packets split by the parser get queued here. + */ + struct AVPacketList *parse_queue; + struct AVPacketList *parse_queue_end; + /** + * Remaining size available for raw_packet_buffer, in bytes. + */ +#define RAW_PACKET_BUFFER_SIZE 2500000 + int raw_packet_buffer_remaining_size; +} AVFormatContext; + +typedef struct AVPacketList { + AVPacket pkt; + struct AVPacketList *next; +} AVPacketList; + + +/** + * @defgroup lavf_core Core functions + * @ingroup libavf + * + * Functions for querying libavformat capabilities, allocating core structures, + * etc. + * @{ + */ + +/** + * Return the LIBAVFORMAT_VERSION_INT constant. + */ +unsigned avformat_version(void); + +/** + * Return the libavformat build-time configuration. + */ +const char *avformat_configuration(void); + +/** + * Return the libavformat license. + */ +const char *avformat_license(void); + +/** + * Initialize libavformat and register all the muxers, demuxers and + * protocols. If you do not call this function, then you can select + * exactly which formats you want to support. + * + * @see av_register_input_format() + * @see av_register_output_format() + * @see av_register_protocol() + */ +void av_register_all(void); + +void av_register_input_format(AVInputFormat *format); +void av_register_output_format(AVOutputFormat *format); + +/** + * Do global initialization of network components. This is optional, + * but recommended, since it avoids the overhead of implicitly + * doing the setup for each session. + * + * Calling this function will become mandatory if using network + * protocols at some major version bump. + */ +int avformat_network_init(void); + +/** + * Undo the initialization done by avformat_network_init. + */ +int avformat_network_deinit(void); + +/** + * If f is NULL, returns the first registered input format, + * if f is non-NULL, returns the next registered input format after f + * or NULL if f is the last one. + */ +AVInputFormat *av_iformat_next(AVInputFormat *f); + +/** + * If f is NULL, returns the first registered output format, + * if f is non-NULL, returns the next registered output format after f + * or NULL if f is the last one. + */ +AVOutputFormat *av_oformat_next(AVOutputFormat *f); + +/** + * Allocate an AVFormatContext. + * avformat_free_context() can be used to free the context and everything + * allocated by the framework within it. + */ +AVFormatContext *avformat_alloc_context(void); + +/** + * Free an AVFormatContext and all its streams. + * @param s context to free + */ +void avformat_free_context(AVFormatContext *s); + +/** + * Get the AVClass for AVFormatContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *avformat_get_class(void); + +/** + * Add a new stream to a media file. + * + * When demuxing, it is called by the demuxer in read_header(). If the + * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also + * be called in read_packet(). + * + * When muxing, should be called by the user before avformat_write_header(). + * + * @param c If non-NULL, the AVCodecContext corresponding to the new stream + * will be initialized to use this codec. This is needed for e.g. codec-specific + * defaults to be set, so codec should be provided if it is known. + * + * @return newly created stream or NULL on error. + */ +AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c); + +AVProgram *av_new_program(AVFormatContext *s, int id); + +/** + * @} + */ + + +/** + * @addtogroup lavf_decoding + * @{ + */ + +/** + * Find AVInputFormat based on the short name of the input format. + */ +AVInputFormat *av_find_input_format(const char *short_name); + +/** + * Guess the file format. + * + * @param is_opened Whether the file is already opened; determines whether + * demuxers with or without AVFMT_NOFILE are probed. + */ +AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); + +/** + * Guess the file format. + * + * @param is_opened Whether the file is already opened; determines whether + * demuxers with or without AVFMT_NOFILE are probed. + * @param score_max A probe score larger that this is required to accept a + * detection, the variable is set to the actual detection + * score afterwards. + * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended + * to retry with a larger probe buffer. + */ +AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); + +/** + * Probe a bytestream to determine the input format. Each time a probe returns + * with a score that is too low, the probe buffer size is increased and another + * attempt is made. When the maximum probe size is reached, the input format + * with the highest score is returned. + * + * @param pb the bytestream to probe + * @param fmt the input format is put here + * @param filename the filename of the stream + * @param logctx the log context + * @param offset the offset within the bytestream to probe from + * @param max_probe_size the maximum probe buffer size (zero for default) + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, + const char *filename, void *logctx, + unsigned int offset, unsigned int max_probe_size); + +/** + * Open an input stream and read the header. The codecs are not opened. + * The stream must be closed with av_close_input_file(). + * + * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). + * May be a pointer to NULL, in which case an AVFormatContext is allocated by this + * function and written into ps. + * Note that a user-supplied AVFormatContext will be freed on failure. + * @param filename Name of the stream to open. + * @param fmt If non-NULL, this parameter forces a specific input format. + * Otherwise the format is autodetected. + * @param options A dictionary filled with AVFormatContext and demuxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, a negative AVERROR on failure. + * + * @note If you want to use custom IO, preallocate the format context and set its pb field. + */ +int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); + +/** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real framerate in case of MPEG-2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @param options If non-NULL, an ic.nb_streams long array of pointers to + * dictionaries, where i-th member contains options for + * codec corresponding to i-th stream. + * On return each dictionary will be filled with options that were not found. + * @return >=0 if OK, AVERROR_xxx on error + * + * @note this function isn't guaranteed to open all the codecs, so + * options being non-empty at return is a perfectly normal behavior. + * + * @todo Let the user decide somehow what information is needed so that + * we do not waste time getting stuff the user does not need. + */ +int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); + +/** + * Find the "best" stream in the file. + * The best stream is determined according to various heuristics as the most + * likely to be what the user expects. + * If the decoder parameter is non-NULL, av_find_best_stream will find the + * default decoder for the stream's codec; streams for which no decoder can + * be found are ignored. + * + * @param ic media file handle + * @param type stream type: video, audio, subtitles, etc. + * @param wanted_stream_nb user-requested stream number, + * or -1 for automatic selection + * @param related_stream try to find a stream related (eg. in the same + * program) to this one, or -1 if none + * @param decoder_ret if non-NULL, returns the decoder for the + * selected stream + * @param flags flags; none are currently defined + * @return the non-negative stream number in case of success, + * AVERROR_STREAM_NOT_FOUND if no stream with the requested type + * could be found, + * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder + * @note If av_find_best_stream returns successfully and decoder_ret is not + * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. + */ +int av_find_best_stream(AVFormatContext *ic, + enum AVMediaType type, + int wanted_stream_nb, + int related_stream, + AVCodec **decoder_ret, + int flags); + +#if FF_API_READ_PACKET +/** + * @deprecated use AVFMT_FLAG_NOFILLIN | AVFMT_FLAG_NOPARSE to read raw + * unprocessed packets + * + * Read a transport packet from a media file. + * + * This function is obsolete and should never be used. + * Use av_read_frame() instead. + * + * @param s media file handle + * @param pkt is filled + * @return 0 if OK, AVERROR_xxx on error + */ +attribute_deprecated +int av_read_packet(AVFormatContext *s, AVPacket *pkt); +#endif + +/** + * Return the next frame of a stream. + * This function returns what is stored in the file, and does not validate + * that what is there are valid frames for the decoder. It will split what is + * stored in the file into frames and return one for each call. It will not + * omit invalid data between valid frames so as to give the decoder the maximum + * information possible for decoding. + * + * The returned packet is valid + * until the next av_read_frame() or until av_close_input_file() and + * must be freed with av_free_packet. For video, the packet contains + * exactly one frame. For audio, it contains an integer number of + * frames if each frame has a known fixed size (e.g. PCM or ADPCM + * data). If the audio frames have a variable size (e.g. MPEG audio), + * then it contains one frame. + * + * pkt->pts, pkt->dts and pkt->duration are always set to correct + * values in AVStream.time_base units (and guessed if the format cannot + * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format + * has B-frames, so it is better to rely on pkt->dts if you do not + * decompress the payload. + * + * @return 0 if OK, < 0 on error or end of file + */ +int av_read_frame(AVFormatContext *s, AVPacket *pkt); + +/** + * Seek to the keyframe at timestamp. + * 'timestamp' in 'stream_index'. + * @param stream_index If stream_index is (-1), a default + * stream is selected, and timestamp is automatically converted + * from AV_TIME_BASE units to the stream specific time_base. + * @param timestamp Timestamp in AVStream.time_base units + * or, if no stream is specified, in AV_TIME_BASE units. + * @param flags flags which select direction and seeking mode + * @return >= 0 on success + */ +int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, + int flags); + +/** + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + * + * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and + * are the file position (this may not be supported by all demuxers). + * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames + * in the stream with stream_index (this may not be supported by all demuxers). + * Otherwise all timestamps are in units of the stream selected by stream_index + * or if stream_index is -1, in AV_TIME_BASE units. + * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as + * keyframes (this may not be supported by all demuxers). + * + * @param stream_index index of the stream which is used as time base reference + * @param min_ts smallest acceptable timestamp + * @param ts target timestamp + * @param max_ts largest acceptable timestamp + * @param flags flags + * @return >=0 on success, error code otherwise + * + * @note This is part of the new seek API which is still under construction. + * Thus do not use this yet. It may change at any time, do not expect + * ABI compatibility yet! + */ +int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); + +/** + * Start playing a network-based stream (e.g. RTSP stream) at the + * current position. + */ +int av_read_play(AVFormatContext *s); + +/** + * Pause a network-based stream (e.g. RTSP stream). + * + * Use av_read_play() to resume it. + */ +int av_read_pause(AVFormatContext *s); + +#if FF_API_CLOSE_INPUT_FILE +/** + * @deprecated use avformat_close_input() + * Close a media file (but not its codecs). + * + * @param s media file handle + */ +attribute_deprecated +void av_close_input_file(AVFormatContext *s); +#endif + +/** + * Close an opened input AVFormatContext. Free it and all its contents + * and set *s to NULL. + */ +void avformat_close_input(AVFormatContext **s); +/** + * @} + */ + +#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward +#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes +#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes +#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number + +/** + * @addtogroup lavf_encoding + * @{ + */ +/** + * Allocate the stream private data and write the stream header to + * an output media file. + * + * @param s Media file handle, must be allocated with avformat_alloc_context(). + * Its oformat field must be set to the desired output format; + * Its pb field must be set to an already openened AVIOContext. + * @param options An AVDictionary filled with AVFormatContext and muxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, negative AVERROR on failure. + * + * @see av_opt_find, av_dict_set, avio_open, av_oformat_next. + */ +int avformat_write_header(AVFormatContext *s, AVDictionary **options); + +/** + * Write a packet to an output media file. + * + * The packet shall contain one audio or video frame. + * The packet must be correctly interleaved according to the container + * specification, if not then av_interleaved_write_frame must be used. + * + * @param s media file handle + * @param pkt The packet, which contains the stream_index, buf/buf_size, + * dts/pts, ... + * This can be NULL (at any time, not just at the end), in + * order to immediately flush data buffered within the muxer, + * for muxers that buffer up data internally before writing it + * to the output. + * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush + */ +int av_write_frame(AVFormatContext *s, AVPacket *pkt); + +/** + * Write a packet to an output media file ensuring correct interleaving. + * + * The packet must contain one audio or video frame. + * If the packets are already correctly interleaved, the application should + * call av_write_frame() instead as it is slightly faster. It is also important + * to keep in mind that completely non-interleaved input will need huge amounts + * of memory to interleave with this, so it is preferable to interleave at the + * demuxer level. + * + * @param s media file handle + * @param pkt The packet containing the data to be written. Libavformat takes + * ownership of the data and will free it when it sees fit using the packet's + * This can be NULL (at any time, not just at the end), to flush the + * interleaving queues. + * @ref AVPacket.destruct "destruct" field. The caller must not access the data + * after this function returns, as it may already be freed. + * Packet's @ref AVPacket.stream_index "stream_index" field must be set to the + * index of the corresponding stream in @ref AVFormatContext.streams + * "s.streams". + * It is very strongly recommended that timing information (@ref AVPacket.pts + * "pts", @ref AVPacket.dts "dts" @ref AVPacket.duration "duration") is set to + * correct values. + * + * @return 0 on success, a negative AVERROR on error. + */ +int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); + +#if FF_API_INTERLEAVE_PACKET +/** + * @deprecated this function was never meant to be called by the user + * programs. + */ +attribute_deprecated +int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, + AVPacket *pkt, int flush); +#endif + +/** + * Write the stream trailer to an output media file and free the + * file private data. + * + * May only be called after a successful call to avformat_write_header. + * + * @param s media file handle + * @return 0 if OK, AVERROR_xxx on error + */ +int av_write_trailer(AVFormatContext *s); + +/** + * Return the output format in the list of registered output formats + * which best matches the provided parameters, or return NULL if + * there is no match. + * + * @param short_name if non-NULL checks if short_name matches with the + * names of the registered formats + * @param filename if non-NULL checks if filename terminates with the + * extensions of the registered formats + * @param mime_type if non-NULL checks if mime_type matches with the + * MIME type of the registered formats + */ +AVOutputFormat *av_guess_format(const char *short_name, + const char *filename, + const char *mime_type); + +/** + * Guess the codec ID based upon muxer and filename. + */ +enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, + const char *filename, const char *mime_type, + enum AVMediaType type); + +/** + * @} + */ + + +/** + * @defgroup lavf_misc Utility functions + * @ingroup libavf + * @{ + * + * Miscelaneous utility functions related to both muxing and demuxing + * (or neither). + */ + +/** + * Send a nice hexadecimal dump of a buffer to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 + */ +void av_hex_dump(FILE *f, const uint8_t *buf, int size); + +/** + * Send a nice hexadecimal dump of a buffer to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 + */ +void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size); + +/** + * Send a nice dump of a packet to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param pkt packet to dump + * @param dump_payload True if the payload must be displayed, too. + * @param st AVStream that the packet belongs to + */ +void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); + + +/** + * Send a nice dump of a packet to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param pkt packet to dump + * @param dump_payload True if the payload must be displayed, too. + * @param st AVStream that the packet belongs to + */ +void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, + AVStream *st); + +/** + * Get the AVCodecID for the given codec tag tag. + * If no codec id is found returns AV_CODEC_ID_NONE. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ +enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); + +/** + * Get the codec tag for the given codec id id. + * If no codec tag is found returns 0. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ +unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id); + +int av_find_default_stream_index(AVFormatContext *s); + +/** + * Get the index for a specific timestamp. + * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond + * to the timestamp which is <= the requested one, if backward + * is 0, then it will be >= + * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise + * @return < 0 if no such timestamp could be found + */ +int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); + +/** + * Add an index entry into a sorted list. Update the entry if the list + * already contains it. + * + * @param timestamp timestamp in the time base of the given stream + */ +int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, + int size, int distance, int flags); + + +/** + * Split a URL string into components. + * + * The pointers to buffers for storing individual components may be null, + * in order to ignore that component. Buffers for components not found are + * set to empty strings. If the port is not found, it is set to a negative + * value. + * + * @param proto the buffer for the protocol + * @param proto_size the size of the proto buffer + * @param authorization the buffer for the authorization + * @param authorization_size the size of the authorization buffer + * @param hostname the buffer for the host name + * @param hostname_size the size of the hostname buffer + * @param port_ptr a pointer to store the port number in + * @param path the buffer for the path + * @param path_size the size of the path buffer + * @param url the URL to split + */ +void av_url_split(char *proto, int proto_size, + char *authorization, int authorization_size, + char *hostname, int hostname_size, + int *port_ptr, + char *path, int path_size, + const char *url); + + +void av_dump_format(AVFormatContext *ic, + int index, + const char *url, + int is_output); + +/** + * Return in 'buf' the path with '%d' replaced by a number. + * + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path numbered sequence string + * @param number frame number + * @return 0 if OK, -1 on format error + */ +int av_get_frame_filename(char *buf, int buf_size, + const char *path, int number); + +/** + * Check whether filename actually is a numbered sequence generator. + * + * @param filename possible numbered sequence string + * @return 1 if a valid numbered sequence string, 0 otherwise + */ +int av_filename_number_test(const char *filename); + +/** + * Generate an SDP for an RTP session. + * + * @param ac array of AVFormatContexts describing the RTP streams. If the + * array is composed by only one context, such context can contain + * multiple AVStreams (one AVStream per RTP stream). Otherwise, + * all the contexts in the array (an AVCodecContext per RTP stream) + * must contain only one AVStream. + * @param n_files number of AVCodecContexts contained in ac + * @param buf buffer where the SDP will be stored (must be allocated by + * the caller) + * @param size the size of the buffer + * @return 0 if OK, AVERROR_xxx on error + */ +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); + +/** + * Return a positive value if the given filename has one of the given + * extensions, 0 otherwise. + * + * @param extensions a comma-separated list of filename extensions + */ +int av_match_ext(const char *filename, const char *extensions); + +/** + * Test if the given container can store a codec. + * + * @param std_compliance standards compliance level, one of FF_COMPLIANCE_* + * + * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. + * A negative number if this information is not available. + */ +int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); + +/** + * @defgroup riff_fourcc RIFF FourCCs + * @{ + * Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are + * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the + * following code: + * @code + * uint32_t tag = MKTAG('H', '2', '6', '4'); + * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 }; + * enum AVCodecID id = av_codec_get_id(table, tag); + * @endcode + */ +/** + * @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID. + */ +const struct AVCodecTag *avformat_get_riff_video_tags(void); +/** + * @return the table mapping RIFF FourCCs for audio to AVCodecID. + */ +const struct AVCodecTag *avformat_get_riff_audio_tags(void); +/** + * @} + */ + +/** + * @} + */ + +#endif /* AVFORMAT_AVFORMAT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavformat/avio.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavformat/avio.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,433 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVFORMAT_AVIO_H +#define AVFORMAT_AVIO_H + +/** + * @file + * @ingroup lavf_io + * Buffered I/O operations + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "libavformat/version.h" + + +#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ + +/** + * Callback for checking whether to abort blocking functions. + * AVERROR_EXIT is returned in this case by the interrupted + * function. During blocking operations, callback is called with + * opaque as parameter. If the callback returns 1, the + * blocking operation will be aborted. + * + * No members can be added to this struct without a major bump, if + * new elements have been added after this struct in AVFormatContext + * or AVIOContext. + */ +typedef struct AVIOInterruptCB { + int (*callback)(void*); + void *opaque; +} AVIOInterruptCB; + +/** + * Bytestream IO Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVIOContext) must not be used outside libav*. + * + * @note None of the function pointers in AVIOContext should be called + * directly, they should only be set by the client application + * when implementing custom I/O. Normally these are set to the + * function pointers specified in avio_alloc_context() + */ +typedef struct AVIOContext { + /** + * A class for private options. + * + * If this AVIOContext is created by avio_open2(), av_class is set and + * passes the options down to protocols. + * + * If this AVIOContext is manually allocated, then av_class may be set by + * the caller. + * + * warning -- this field can be NULL, be sure to not pass this AVIOContext + * to any av_opt_* functions in that case. + */ + const AVClass *av_class; + unsigned char *buffer; /**< Start of the buffer. */ + int buffer_size; /**< Maximum buffer size */ + unsigned char *buf_ptr; /**< Current position in the buffer */ + unsigned char *buf_end; /**< End of the data, may be less than + buffer+buffer_size if the read function returned + less data than requested, e.g. for streams where + no more data has been received yet. */ + void *opaque; /**< A private pointer, passed to the read/write/seek/... + functions. */ + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); + int64_t (*seek)(void *opaque, int64_t offset, int whence); + int64_t pos; /**< position in the file of the current buffer */ + int must_flush; /**< true if the next seek should flush */ + int eof_reached; /**< true if eof reached */ + int write_flag; /**< true if open for writing */ + int max_packet_size; + unsigned long checksum; + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); + int error; /**< contains the error code or 0 if no error happened */ + /** + * Pause or resume playback for network streaming protocols - e.g. MMS. + */ + int (*read_pause)(void *opaque, int pause); + /** + * Seek to a given timestamp in stream with the specified stream_index. + * Needed for some network streaming protocols which don't support seeking + * to byte position. + */ + int64_t (*read_seek)(void *opaque, int stream_index, + int64_t timestamp, int flags); + /** + * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. + */ + int seekable; +} AVIOContext; + +/* unbuffered I/O */ + +/** + * Return AVIO_FLAG_* access flags corresponding to the access permissions + * of the resource in url, or a negative value corresponding to an + * AVERROR code in case of failure. The returned access flags are + * masked by the value in flags. + * + * @note This function is intrinsically unsafe, in the sense that the + * checked resource may change its existence or permission status from + * one call to another. Thus you should not trust the returned value, + * unless you are sure that no other processes are accessing the + * checked resource. + */ +int avio_check(const char *url, int flags); + +/** + * Allocate and initialize an AVIOContext for buffered I/O. It must be later + * freed with av_free(). + * + * @param buffer Memory block for input/output operations via AVIOContext. + * The buffer must be allocated with av_malloc() and friends. + * @param buffer_size The buffer size is very important for performance. + * For protocols with fixed blocksize it should be set to this blocksize. + * For others a typical size is a cache page, e.g. 4kb. + * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise. + * @param opaque An opaque pointer to user-specific data. + * @param read_packet A function for refilling the buffer, may be NULL. + * @param write_packet A function for writing the buffer contents, may be NULL. + * @param seek A function for seeking to specified byte position, may be NULL. + * + * @return Allocated AVIOContext or NULL on failure. + */ +AVIOContext *avio_alloc_context( + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)); + +void avio_w8(AVIOContext *s, int b); +void avio_write(AVIOContext *s, const unsigned char *buf, int size); +void avio_wl64(AVIOContext *s, uint64_t val); +void avio_wb64(AVIOContext *s, uint64_t val); +void avio_wl32(AVIOContext *s, unsigned int val); +void avio_wb32(AVIOContext *s, unsigned int val); +void avio_wl24(AVIOContext *s, unsigned int val); +void avio_wb24(AVIOContext *s, unsigned int val); +void avio_wl16(AVIOContext *s, unsigned int val); +void avio_wb16(AVIOContext *s, unsigned int val); + +/** + * Write a NULL-terminated string. + * @return number of bytes written. + */ +int avio_put_str(AVIOContext *s, const char *str); + +/** + * Convert an UTF-8 string to UTF-16LE and write it. + * @return number of bytes written. + */ +int avio_put_str16le(AVIOContext *s, const char *str); + +/** + * Passing this as the "whence" parameter to a seek function causes it to + * return the filesize without seeking anywhere. Supporting this is optional. + * If it is not supported then the seek function will return <0. + */ +#define AVSEEK_SIZE 0x10000 + +/** + * Oring this flag as into the "whence" parameter to a seek function causes it to + * seek by any means (like reopening and linear reading) or other normally unreasonble + * means that can be extreemly slow. + * This may be ignored by the seek code. + */ +#define AVSEEK_FORCE 0x20000 + +/** + * fseek() equivalent for AVIOContext. + * @return new position or AVERROR. + */ +int64_t avio_seek(AVIOContext *s, int64_t offset, int whence); + +/** + * Skip given number of bytes forward + * @return new position or AVERROR. + */ +static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset) +{ + return avio_seek(s, offset, SEEK_CUR); +} + +/** + * ftell() equivalent for AVIOContext. + * @return position or AVERROR. + */ +static av_always_inline int64_t avio_tell(AVIOContext *s) +{ + return avio_seek(s, 0, SEEK_CUR); +} + +/** + * Get the filesize. + * @return filesize or AVERROR + */ +int64_t avio_size(AVIOContext *s); + +/** @warning currently size is limited */ +int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); + +void avio_flush(AVIOContext *s); + + +/** + * Read size bytes from AVIOContext into buf. + * @return number of bytes read or AVERROR + */ +int avio_read(AVIOContext *s, unsigned char *buf, int size); + +/** + * @name Functions for reading from AVIOContext + * @{ + * + * @note return 0 if EOF, so you cannot use it if EOF handling is + * necessary + */ +int avio_r8 (AVIOContext *s); +unsigned int avio_rl16(AVIOContext *s); +unsigned int avio_rl24(AVIOContext *s); +unsigned int avio_rl32(AVIOContext *s); +uint64_t avio_rl64(AVIOContext *s); +unsigned int avio_rb16(AVIOContext *s); +unsigned int avio_rb24(AVIOContext *s); +unsigned int avio_rb32(AVIOContext *s); +uint64_t avio_rb64(AVIOContext *s); +/** + * @} + */ + +/** + * Read a string from pb into buf. The reading will terminate when either + * a NULL character was encountered, maxlen bytes have been read, or nothing + * more can be read from pb. The result is guaranteed to be NULL-terminated, it + * will be truncated if buf is too small. + * Note that the string is not interpreted or validated in any way, it + * might get truncated in the middle of a sequence for multi-byte encodings. + * + * @return number of bytes read (is always <= maxlen). + * If reading ends on EOF or error, the return value will be one more than + * bytes actually read. + */ +int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); + +/** + * Read a UTF-16 string from pb and convert it to UTF-8. + * The reading will terminate when either a null or invalid character was + * encountered or maxlen bytes have been read. + * @return number of bytes read (is always <= maxlen) + */ +int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); +int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); + + +/** + * @name URL open modes + * The flags argument to avio_open must be one of the following + * constants, optionally ORed with other flags. + * @{ + */ +#define AVIO_FLAG_READ 1 /**< read-only */ +#define AVIO_FLAG_WRITE 2 /**< write-only */ +#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */ +/** + * @} + */ + +/** + * Use non-blocking mode. + * If this flag is set, operations on the context will return + * AVERROR(EAGAIN) if they can not be performed immediately. + * If this flag is not set, operations on the context will never return + * AVERROR(EAGAIN). + * Note that this flag does not affect the opening/connecting of the + * context. Connecting a protocol will always block if necessary (e.g. on + * network protocols) but never hang (e.g. on busy devices). + * Warning: non-blocking protocols is work-in-progress; this flag may be + * silently ignored. + */ +#define AVIO_FLAG_NONBLOCK 8 + +/** + * Create and initialize a AVIOContext for accessing the + * resource indicated by url. + * @note When the resource indicated by url has been opened in + * read+write mode, the AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int avio_open(AVIOContext **s, const char *url, int flags); + +/** + * Create and initialize a AVIOContext for accessing the + * resource indicated by url. + * @note When the resource indicated by url has been opened in + * read+write mode, the AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @param flags flags which control how the resource indicated by url + * is to be opened + * @param int_cb an interrupt callback to be used at the protocols level + * @param options A dictionary filled with protocol-private options. On return + * this parameter will be destroyed and replaced with a dict containing options + * that were not found. May be NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int avio_open2(AVIOContext **s, const char *url, int flags, + const AVIOInterruptCB *int_cb, AVDictionary **options); + +/** + * Close the resource accessed by the AVIOContext s and free it. + * This function can only be used if s was opened by avio_open(). + * + * The internal buffer is automatically flushed before closing the + * resource. + * + * @return 0 on success, an AVERROR < 0 on error. + * @see avio_closep + */ +int avio_close(AVIOContext *s); + +/** + * Close the resource accessed by the AVIOContext *s, free it + * and set the pointer pointing to it to NULL. + * This function can only be used if s was opened by avio_open(). + * + * The internal buffer is automatically flushed before closing the + * resource. + * + * @return 0 on success, an AVERROR < 0 on error. + * @see avio_close + */ +int avio_closep(AVIOContext **s); + + +/** + * Open a write only memory stream. + * + * @param s new IO context + * @return zero if no error. + */ +int avio_open_dyn_buf(AVIOContext **s); + +/** + * Return the written size and a pointer to the buffer. The buffer + * must be freed with av_free(). + * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. + * + * @param s IO context + * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + */ +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); + +/** + * Iterate through names of available protocols. + * + * @param opaque A private pointer representing current protocol. + * It must be a pointer to NULL on first iteration and will + * be updated by successive calls to avio_enum_protocols. + * @param output If set to 1, iterate over output protocols, + * otherwise over input protocols. + * + * @return A static string containing the name of current protocol or NULL + */ +const char *avio_enum_protocols(void **opaque, int output); + +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ +int avio_pause(AVIOContext *h, int pause); + +/** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + */ +int64_t avio_seek_time(AVIOContext *h, int stream_index, + int64_t timestamp, int flags); + +#endif /* AVFORMAT_AVIO_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavformat/version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavformat/version.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,71 @@ +/* + * Version macros. + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_VERSION_H +#define AVFORMAT_VERSION_H + +/** + * @file + * @ingroup libavf + * Libavformat version macros + */ + +#include "libavutil/avutil.h" + +#define LIBAVFORMAT_VERSION_MAJOR 54 +#define LIBAVFORMAT_VERSION_MINOR 19 +#define LIBAVFORMAT_VERSION_MICRO 0 + +#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ + LIBAVFORMAT_VERSION_MINOR, \ + LIBAVFORMAT_VERSION_MICRO) +#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \ + LIBAVFORMAT_VERSION_MINOR, \ + LIBAVFORMAT_VERSION_MICRO) +#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT + +#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_CLOSE_INPUT_FILE +#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_APPLEHTTP_PROTO +#define FF_API_APPLEHTTP_PROTO (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_READ_PACKET +#define FF_API_READ_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_INTERLEAVE_PACKET +#define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_AV_GETTIME +#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif +#ifndef FF_API_R_FRAME_RATE +#define FF_API_R_FRAME_RATE (LIBAVFORMAT_VERSION_MAJOR < 55) +#endif + +#endif /* AVFORMAT_VERSION_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/adler32.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/adler32.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,43 @@ +/* + * copyright (c) 2006 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_ADLER32_H +#define AVUTIL_ADLER32_H + +#include +#include "attributes.h" + +/** + * @ingroup lavu_crypto + * Calculate the Adler32 checksum of a buffer. + * + * Passing the return value to a subsequent av_adler32_update() call + * allows the checksum of multiple buffers to be calculated as though + * they were concatenated. + * + * @param adler initial checksum value + * @param buf pointer to input buffer + * @param len size of input buffer + * @return updated checksum + */ +unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, + unsigned int len) av_pure; + +#endif /* AVUTIL_ADLER32_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/aes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/aes.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,67 @@ +/* + * copyright (c) 2007 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AES_H +#define AVUTIL_AES_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_aes AES + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_aes_size; +#endif + +struct AVAES; + +/** + * Allocate an AVAES context. + */ +struct AVAES *av_aes_alloc(void); + +/** + * Initialize an AVAES context. + * @param key_bits 128, 192 or 256 + * @param decrypt 0 for encryption, 1 for decryption + */ +int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * @param count number of 16 byte blocks + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_AES_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/attributes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/attributes.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,122 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Macro definitions for various function/variable attributes + */ + +#ifndef AVUTIL_ATTRIBUTES_H +#define AVUTIL_ATTRIBUTES_H + +#ifdef __GNUC__ +# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) +#else +# define AV_GCC_VERSION_AT_LEAST(x,y) 0 +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_always_inline __attribute__((always_inline)) inline +#elif defined(_MSC_VER) +# define av_always_inline __forceinline +#else +# define av_always_inline inline +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_noinline __attribute__((noinline)) +#else +# define av_noinline +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_pure __attribute__((pure)) +#else +# define av_pure +#endif + +#if AV_GCC_VERSION_AT_LEAST(2,6) +# define av_const __attribute__((const)) +#else +# define av_const +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,3) +# define av_cold __attribute__((cold)) +#else +# define av_cold +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,1) +# define av_flatten __attribute__((flatten)) +#else +# define av_flatten +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_deprecated __attribute__((deprecated)) +#else +# define attribute_deprecated +#endif + +#if defined(__GNUC__) +# define av_unused __attribute__((unused)) +#else +# define av_unused +#endif + +/** + * Mark a variable as used and prevent the compiler from optimizing it + * away. This is useful for variables accessed only from inline + * assembler without the compiler being aware. + */ +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_used __attribute__((used)) +#else +# define av_used +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,3) +# define av_alias __attribute__((may_alias)) +#else +# define av_alias +#endif + +#if defined(__GNUC__) && !defined(__ICC) +# define av_uninit(x) x=x +#else +# define av_uninit(x) x +#endif + +#ifdef __GNUC__ +# define av_builtin_constant_p __builtin_constant_p +# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) +#else +# define av_builtin_constant_p(x) 0 +# define av_printf_format(fmtpos, attrpos) +#endif + +#if AV_GCC_VERSION_AT_LEAST(2,5) +# define av_noreturn __attribute__((noreturn)) +#else +# define av_noreturn +#endif + +#endif /* AVUTIL_ATTRIBUTES_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/audio_fifo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/audio_fifo.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,146 @@ +/* + * Audio FIFO + * Copyright (c) 2012 Justin Ruggles + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Audio FIFO Buffer + */ + +#ifndef AVUTIL_AUDIO_FIFO_H +#define AVUTIL_AUDIO_FIFO_H + +#include "avutil.h" +#include "fifo.h" +#include "samplefmt.h" + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * Context for an Audio FIFO Buffer. + * + * - Operates at the sample level rather than the byte level. + * - Supports multiple channels with either planar or packed sample format. + * - Automatic reallocation when writing to a full buffer. + */ +typedef struct AVAudioFifo AVAudioFifo; + +/** + * Free an AVAudioFifo. + * + * @param af AVAudioFifo to free + */ +void av_audio_fifo_free(AVAudioFifo *af); + +/** + * Allocate an AVAudioFifo. + * + * @param sample_fmt sample format + * @param channels number of channels + * @param nb_samples initial allocation size, in samples + * @return newly allocated AVAudioFifo, or NULL on error + */ +AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, + int nb_samples); + +/** + * Reallocate an AVAudioFifo. + * + * @param af AVAudioFifo to reallocate + * @param nb_samples new allocation size, in samples + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples); + +/** + * Write data to an AVAudioFifo. + * + * The AVAudioFifo will be reallocated automatically if the available space + * is less than nb_samples. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to write to + * @param data audio data plane pointers + * @param nb_samples number of samples to write + * @return number of samples actually written, or negative AVERROR + * code on failure. + */ +int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Read data from an AVAudioFifo. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to read from + * @param data audio data plane pointers + * @param nb_samples number of samples to read + * @return number of samples actually read, or negative AVERROR code + * on failure. + */ +int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Drain data from an AVAudioFifo. + * + * Removes the data without reading it. + * + * @param af AVAudioFifo to drain + * @param nb_samples number of samples to drain + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples); + +/** + * Reset the AVAudioFifo buffer. + * + * This empties all data in the buffer. + * + * @param af AVAudioFifo to reset + */ +void av_audio_fifo_reset(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for reading. + * + * @param af the AVAudioFifo to query + * @return number of samples available for reading + */ +int av_audio_fifo_size(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for writing. + * + * @param af the AVAudioFifo to query + * @return number of samples available for writing + */ +int av_audio_fifo_space(AVAudioFifo *af); + +/** + * @} + */ + +#endif /* AVUTIL_AUDIO_FIFO_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/audioconvert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/audioconvert.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2006 Michael Niedermayer + * Copyright (c) 2008 Peter Ross + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AUDIOCONVERT_H +#define AVUTIL_AUDIOCONVERT_H + +#include + +/** + * @file + * audio conversion routines + */ + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup channel_masks Audio channel masks + * @{ + */ +#define AV_CH_FRONT_LEFT 0x00000001 +#define AV_CH_FRONT_RIGHT 0x00000002 +#define AV_CH_FRONT_CENTER 0x00000004 +#define AV_CH_LOW_FREQUENCY 0x00000008 +#define AV_CH_BACK_LEFT 0x00000010 +#define AV_CH_BACK_RIGHT 0x00000020 +#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 +#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 +#define AV_CH_BACK_CENTER 0x00000100 +#define AV_CH_SIDE_LEFT 0x00000200 +#define AV_CH_SIDE_RIGHT 0x00000400 +#define AV_CH_TOP_CENTER 0x00000800 +#define AV_CH_TOP_FRONT_LEFT 0x00001000 +#define AV_CH_TOP_FRONT_CENTER 0x00002000 +#define AV_CH_TOP_FRONT_RIGHT 0x00004000 +#define AV_CH_TOP_BACK_LEFT 0x00008000 +#define AV_CH_TOP_BACK_CENTER 0x00010000 +#define AV_CH_TOP_BACK_RIGHT 0x00020000 +#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. +#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. +#define AV_CH_WIDE_LEFT 0x0000000080000000ULL +#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL +#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL +#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL +#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL + +/** Channel mask value used for AVCodecContext.request_channel_layout + to indicate that the user requests the channel order of the decoder output + to be the native codec channel order. */ +#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL + +/** + * @} + * @defgroup channel_mask_c Audio channel convenience macros + * @{ + * */ +#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) +#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) + +enum AVMatrixEncoding { + AV_MATRIX_ENCODING_NONE, + AV_MATRIX_ENCODING_DOLBY, + AV_MATRIX_ENCODING_DPLII, + AV_MATRIX_ENCODING_NB +}; + +/** + * @} + */ + +/** + * Return a channel layout id that matches name, or 0 if no match is found. + * + * name can be one or several of the following notations, + * separated by '+' or '|': + * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0, + * 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix); + * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC, + * SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR); + * - a number of channels, in decimal, optionally followed by 'c', yielding + * the default channel layout for that number of channels (@see + * av_get_default_channel_layout); + * - a channel layout mask, in hexadecimal starting with "0x" (see the + * AV_CH_* macros). + * + * Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7" + */ +uint64_t av_get_channel_layout(const char *name); + +/** + * Return a description of a channel layout. + * If nb_channels is <= 0, it is guessed from the channel_layout. + * + * @param buf put here the string containing the channel layout + * @param buf_size size in bytes of the buffer + */ +void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout); + +/** + * Return the number of channels in the channel layout. + */ +int av_get_channel_layout_nb_channels(uint64_t channel_layout); + +/** + * Return default channel layout for a given number of channels. + */ +uint64_t av_get_default_channel_layout(int nb_channels); + +/** + * Get the index of a channel in channel_layout. + * + * @param channel a channel layout describing exactly one channel which must be + * present in channel_layout. + * + * @return index of channel in channel_layout on success, a negative AVERROR + * on error. + */ +int av_get_channel_layout_channel_index(uint64_t channel_layout, + uint64_t channel); + +/** + * Get the channel with the given index in channel_layout. + */ +uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); + +/** + * Get the name of a given channel. + * + * @return channel name on success, NULL on error. + */ +const char *av_get_channel_name(uint64_t channel); + +/** + * @} + */ + +#endif /* AVUTIL_AUDIOCONVERT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/avassert.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/avassert.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,66 @@ +/* + * copyright (c) 2010 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * simple assert() macros that are a bit more flexible than ISO C assert(). + * @author Michael Niedermayer + */ + +#ifndef AVUTIL_AVASSERT_H +#define AVUTIL_AVASSERT_H + +#include +#include "avutil.h" +#include "log.h" + +/** + * assert() equivalent, that is always enabled. + */ +#define av_assert0(cond) do { \ + if (!(cond)) { \ + av_log(NULL, AV_LOG_FATAL, "Assertion %s failed at %s:%d\n", \ + AV_STRINGIFY(cond), __FILE__, __LINE__); \ + abort(); \ + } \ +} while (0) + + +/** + * assert() equivalent, that does not lie in speed critical code. + * These asserts() thus can be enabled without fearing speedloss. + */ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0 +#define av_assert1(cond) av_assert0(cond) +#else +#define av_assert1(cond) ((void)0) +#endif + + +/** + * assert() equivalent, that does lie in speed critical code. + */ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 +#define av_assert2(cond) av_assert0(cond) +#else +#define av_assert2(cond) ((void)0) +#endif + +#endif /* AVUTIL_AVASSERT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/avconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/avconfig.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,6 @@ +/* Generated by ffconf */ +#ifndef AVUTIL_AVCONFIG_H +#define AVUTIL_AVCONFIG_H +#define AV_HAVE_BIGENDIAN 0 +#define AV_HAVE_FAST_UNALIGNED 1 +#endif /* AVUTIL_AVCONFIG_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/avstring.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/avstring.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2007 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AVSTRING_H +#define AVUTIL_AVSTRING_H + +#include +#include "attributes.h" + +/** + * @addtogroup lavu_string + * @{ + */ + +/** + * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to + * the address of the first character in str after the prefix. + * + * @param str input string + * @param pfx prefix to test + * @param ptr updated if the prefix is matched inside str + * @return non-zero if the prefix matches, zero otherwise + */ +int av_strstart(const char *str, const char *pfx, const char **ptr); + +/** + * Return non-zero if pfx is a prefix of str independent of case. If + * it is, *ptr is set to the address of the first character in str + * after the prefix. + * + * @param str input string + * @param pfx prefix to test + * @param ptr updated if the prefix is matched inside str + * @return non-zero if the prefix matches, zero otherwise + */ +int av_stristart(const char *str, const char *pfx, const char **ptr); + +/** + * Locate the first case-independent occurrence in the string haystack + * of the string needle. A zero-length string needle is considered to + * match at the start of haystack. + * + * This function is a case-insensitive version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_stristr(const char *haystack, const char *needle); + +/** + * Copy the string src to dst, but no more than size - 1 bytes, and + * null-terminate dst. + * + * This function is the same as BSD strlcpy(). + * + * @param dst destination buffer + * @param src source string + * @param size size of destination buffer + * @return the length of src + * + * @warning since the return value is the length of src, src absolutely + * _must_ be a properly 0-terminated string, otherwise this will read beyond + * the end of the buffer and possibly crash. + */ +size_t av_strlcpy(char *dst, const char *src, size_t size); + +/** + * Append the string src to the string dst, but to a total length of + * no more than size - 1 bytes, and null-terminate dst. + * + * This function is similar to BSD strlcat(), but differs when + * size <= strlen(dst). + * + * @param dst destination buffer + * @param src source string + * @param size size of destination buffer + * @return the total length of src and dst + * + * @warning since the return value use the length of src and dst, these + * absolutely _must_ be a properly 0-terminated strings, otherwise this + * will read beyond the end of the buffer and possibly crash. + */ +size_t av_strlcat(char *dst, const char *src, size_t size); + +/** + * Append output to a string, according to a format. Never write out of + * the destination buffer, and always put a terminating 0 within + * the buffer. + * @param dst destination buffer (string to which the output is + * appended) + * @param size total size of the destination buffer + * @param fmt printf-compatible format string, specifying how the + * following parameters are used + * @return the length of the string that would have been generated + * if enough space had been available + */ +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); + +/** + * Convert a number to a av_malloced string. + */ +char *av_d2str(double d); + +/** + * Unescape the given string until a non escaped terminating char, + * and return the token corresponding to the unescaped string. + * + * The normal \ and ' escaping is supported. Leading and trailing + * whitespaces are removed, unless they are escaped with '\' or are + * enclosed between ''. + * + * @param buf the buffer to parse, buf will be updated to point to the + * terminating char + * @param term a 0-terminated list of terminating chars + * @return the malloced unescaped string, which must be av_freed by + * the user, NULL in case of allocation failure + */ +char *av_get_token(const char **buf, const char *term); + +/** + * Locale-independent conversion of ASCII characters to uppercase. + */ +static inline int av_toupper(int c) +{ + if (c >= 'a' && c <= 'z') + c ^= 0x20; + return c; +} + +/** + * Locale-independent conversion of ASCII characters to lowercase. + */ +static inline int av_tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + c ^= 0x20; + return c; +} + +/* + * Locale-independent case-insensitive compare. + * @note This means only ASCII-range characters are case-insensitive + */ +int av_strcasecmp(const char *a, const char *b); + +/** + * Locale-independent case-insensitive compare. + * @note This means only ASCII-range characters are case-insensitive + */ +int av_strncasecmp(const char *a, const char *b, size_t n); + +/** + * @} + */ + +#endif /* AVUTIL_AVSTRING_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/avutil.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/avutil.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,274 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AVUTIL_H +#define AVUTIL_AVUTIL_H + +/** + * @file + * external API header + */ + +/** + * @mainpage + * + * @section libav_intro Introduction + * + * This document describes the usage of the different libraries + * provided by Libav. + * + * @li @ref libavc "libavcodec" encoding/decoding library + * @li @subpage libavfilter graph based frame editing library + * @li @ref libavf "libavformat" I/O and muxing/demuxing library + * @li @ref lavd "libavdevice" special devices muxing/demuxing library + * @li @ref lavu "libavutil" common utility library + * @li @subpage libswscale color conversion and scaling library + */ + +/** + * @defgroup lavu Common utility functions + * + * @brief + * libavutil contains the code shared across all the other Libav + * libraries + * + * @note In order to use the functions provided by avutil you must include + * the specific header. + * + * @{ + * + * @defgroup lavu_crypto Crypto and Hashing + * + * @{ + * @} + * + * @defgroup lavu_math Maths + * @{ + * + * @} + * + * @defgroup lavu_string String Manipulation + * + * @{ + * + * @} + * + * @defgroup lavu_mem Memory Management + * + * @{ + * + * @} + * + * @defgroup lavu_data Data Structures + * @{ + * + * @} + * + * @defgroup lavu_audio Audio related + * + * @{ + * + * @} + * + * @defgroup lavu_error Error Codes + * + * @{ + * + * @} + * + * @defgroup lavu_misc Other + * + * @{ + * + * @defgroup lavu_internal Internal + * + * Not exported functions, for internal usage only + * + * @{ + * + * @} + */ + + +/** + * @defgroup preproc_misc Preprocessor String Macros + * + * String manipulation macros + * + * @{ + */ + +#define AV_STRINGIFY(s) AV_TOSTRING(s) +#define AV_TOSTRING(s) #s + +#define AV_GLUE(a, b) a ## b +#define AV_JOIN(a, b) AV_GLUE(a, b) + +#define AV_PRAGMA(s) _Pragma(#s) + +/** + * @} + */ + +/** + * @defgroup version_utils Library Version Macros + * + * Useful to check and match library version in order to maintain + * backward compatibility. + * + * @{ + */ + +#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) +#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c +#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) + +/** + * @} + */ + +/** + * @addtogroup lavu_ver + * @{ + */ + +/** + * Return the LIBAVUTIL_VERSION_INT constant. + */ +unsigned avutil_version(void); + +/** + * Return the libavutil build-time configuration. + */ +const char *avutil_configuration(void); + +/** + * Return the libavutil license. + */ +const char *avutil_license(void); + +/** + * @} + */ + +/** + * @addtogroup lavu_media Media Type + * @brief Media Type + */ + +enum AVMediaType { + AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA + AVMEDIA_TYPE_VIDEO, + AVMEDIA_TYPE_AUDIO, + AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous + AVMEDIA_TYPE_SUBTITLE, + AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse + AVMEDIA_TYPE_NB +}; + +/** + * @defgroup lavu_const Constants + * @{ + * + * @defgroup lavu_enc Encoding specific + * + * @note those definition should move to avcodec + * @{ + */ + +#define FF_LAMBDA_SHIFT 7 +#define FF_LAMBDA_SCALE (1< + +/** + * @defgroup lavu_base64 Base64 + * @ingroup lavu_crypto + * @{ + */ + + +/** + * Decode a base64-encoded string. + * + * @param out buffer for decoded data + * @param in null-terminated input string + * @param out_size size in bytes of the out buffer, must be at + * least 3/4 of the length of in + * @return number of bytes written, or a negative value in case of + * invalid input + */ +int av_base64_decode(uint8_t *out, const char *in, int out_size); + +/** + * Encode data to base64 and null-terminate. + * + * @param out buffer for encoded data + * @param out_size size in bytes of the output buffer, must be at + * least AV_BASE64_SIZE(in_size) + * @param in_size size in bytes of the 'in' buffer + * @return 'out' or NULL in case of error + */ +char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); + +/** + * Calculate the output size needed to base64-encode x bytes. + */ +#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1) + + /** + * @} + */ + +#endif /* AVUTIL_BASE64_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/blowfish.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/blowfish.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,76 @@ +/* + * Blowfish algorithm + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_BLOWFISH_H +#define AVUTIL_BLOWFISH_H + +#include + +/** + * @defgroup lavu_blowfish Blowfish + * @ingroup lavu_crypto + * @{ + */ + +#define AV_BF_ROUNDS 16 + +typedef struct AVBlowfish { + uint32_t p[AV_BF_ROUNDS + 2]; + uint32_t s[4][256]; +} AVBlowfish; + +/** + * Initialize an AVBlowfish context. + * + * @param ctx an AVBlowfish context + * @param key a key + * @param key_len length of the key + */ +void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVBlowfish context + * @param xl left four bytes halves of input to be encrypted + * @param xr right four bytes halves of input to be encrypted + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr, + int decrypt); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVBlowfish context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_BLOWFISH_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/bswap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/bswap.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,109 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * byte swapping routines + */ + +#ifndef AVUTIL_BSWAP_H +#define AVUTIL_BSWAP_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/bswap.h" +#elif ARCH_AVR32 +# include "avr32/bswap.h" +#elif ARCH_BFIN +# include "bfin/bswap.h" +#elif ARCH_SH4 +# include "sh4/bswap.h" +#elif ARCH_X86 +# include "x86/bswap.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) +#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) +#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) + +#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) + +#ifndef av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) +{ + x= (x>>8) | (x<<8); + return x; +} +#endif + +#ifndef av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) +{ + return AV_BSWAP32C(x); +} +#endif + +#ifndef av_bswap64 +static inline uint64_t av_const av_bswap64(uint64_t x) +{ + return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32); +} +#endif + +// be2ne ... big-endian to native-endian +// le2ne ... little-endian to native-endian + +#if AV_HAVE_BIGENDIAN +#define av_be2ne16(x) (x) +#define av_be2ne32(x) (x) +#define av_be2ne64(x) (x) +#define av_le2ne16(x) av_bswap16(x) +#define av_le2ne32(x) av_bswap32(x) +#define av_le2ne64(x) av_bswap64(x) +#define AV_BE2NEC(s, x) (x) +#define AV_LE2NEC(s, x) AV_BSWAPC(s, x) +#else +#define av_be2ne16(x) av_bswap16(x) +#define av_be2ne32(x) av_bswap32(x) +#define av_be2ne64(x) av_bswap64(x) +#define av_le2ne16(x) (x) +#define av_le2ne32(x) (x) +#define av_le2ne64(x) (x) +#define AV_BE2NEC(s, x) AV_BSWAPC(s, x) +#define AV_LE2NEC(s, x) (x) +#endif + +#define AV_BE2NE16C(x) AV_BE2NEC(16, x) +#define AV_BE2NE32C(x) AV_BE2NEC(32, x) +#define AV_BE2NE64C(x) AV_BE2NEC(64, x) +#define AV_LE2NE16C(x) AV_LE2NEC(16, x) +#define AV_LE2NE32C(x) AV_LE2NEC(32, x) +#define AV_LE2NE64C(x) AV_LE2NEC(64, x) + +#endif /* AVUTIL_BSWAP_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/common.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/common.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,405 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * common internal and external API header + */ + +#ifndef AVUTIL_COMMON_H +#define AVUTIL_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "attributes.h" +#include "version.h" +#include "libavutil/avconfig.h" + +#if AV_HAVE_BIGENDIAN +# define AV_NE(be, le) (be) +#else +# define AV_NE(be, le) (le) +#endif + +//rounded division & shift +#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) +/* assume b>0 */ +#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) +#define FFSIGN(a) ((a) > 0 ? 1 : -1) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) + +/* misc math functions */ + +#if FF_API_AV_REVERSE +extern attribute_deprecated const uint8_t av_reverse[256]; +#endif + +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +# include "intmath.h" +#endif + +/* Pull in unguarded fallback defines at the end of this file. */ +#include "common.h" + +#ifndef av_log2 +av_const int av_log2(unsigned v); +#endif + +#ifndef av_log2_16bit +av_const int av_log2_16bit(unsigned v); +#endif + +/** + * Clip a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static av_always_inline av_const int av_clip_c(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** + * Clip a signed integer value into the 0-255 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const uint8_t av_clip_uint8_c(int a) +{ + if (a&(~0xFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -128,127 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int8_t av_clip_int8_c(int a) +{ + if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; + else return a; +} + +/** + * Clip a signed integer value into the 0-65535 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const uint16_t av_clip_uint16_c(int a) +{ + if (a&(~0xFFFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -32768,32767 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int16_t av_clip_int16_c(int a) +{ + if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; + else return a; +} + +/** + * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) +{ + if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; + else return a; +} + +/** + * Clip a signed integer to an unsigned power of two range. + * @param a value to clip + * @param p bit position to clip at + * @return clipped value + */ +static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) +{ + if (a & ~((1<> 31 & ((1< amax) return amax; + else return a; +} + +/** Compute ceil(log2(x)). + * @param x value used to compute ceil(log2(x)) + * @return computed ceiling of log2(x) + */ +static av_always_inline av_const int av_ceil_log2_c(int x) +{ + return av_log2((x - 1) << 1); +} + +/** + * Count number of bits set to one in x + * @param x value to count bits of + * @return the number of bits set to one in x + */ +static av_always_inline av_const int av_popcount_c(uint32_t x) +{ + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0F0F0F0F; + x += x >> 8; + return (x + (x >> 16)) & 0x3F; +} + +/** + * Count number of bits set to one in x + * @param x value to count bits of + * @return the number of bits set to one in x + */ +static av_always_inline av_const int av_popcount64_c(uint64_t x) +{ + return av_popcount(x) + av_popcount(x >> 32); +} + +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) + +/** + * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_BYTE Expression reading one byte from the input. + * Evaluated up to 7 times (4 for the currently + * assigned Unicode range). With a memory buffer + * input, this could be *ptr++. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF8(val, GET_BYTE, ERROR)\ + val= GET_BYTE;\ + {\ + int ones= 7 - av_log2(val ^ 255);\ + if(ones==1)\ + ERROR\ + val&= 127>>ones;\ + while(--ones > 0){\ + int tmp= GET_BYTE - 128;\ + if(tmp>>6)\ + ERROR\ + val= (val<<6) + tmp;\ + }\ + } + +/** + * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_16BIT Expression returning two bytes of UTF-16 data converted + * to native byte order. Evaluated one or two times. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF16(val, GET_16BIT, ERROR)\ + val = GET_16BIT;\ + {\ + unsigned int hi = val - 0xD800;\ + if (hi < 0x800) {\ + val = GET_16BIT - 0xDC00;\ + if (val > 0x3FFU || hi > 0x3FFU)\ + ERROR\ + val += (hi<<10) + 0x10000;\ + }\ + }\ + +/** + * @def PUT_UTF8(val, tmp, PUT_BYTE) + * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). + * @param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If + * val is given as a function it is executed only once. + * @param tmp is a temporary variable and should be of type uint8_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_BYTE. + * @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. + * It could be a function or a statement, and uses tmp as the input byte. + * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be + * executed up to 4 times for values in the valid UTF-8 range and up to + * 7 times in the general case, depending on the length of the converted + * Unicode character. + */ +#define PUT_UTF8(val, tmp, PUT_BYTE)\ + {\ + int bytes, shift;\ + uint32_t in = val;\ + if (in < 0x80) {\ + tmp = in;\ + PUT_BYTE\ + } else {\ + bytes = (av_log2(in) + 4) / 5;\ + shift = (bytes - 1) * 6;\ + tmp = (256 - (256 >> bytes)) | (in >> shift);\ + PUT_BYTE\ + while (shift >= 6) {\ + shift -= 6;\ + tmp = 0x80 | ((in >> shift) & 0x3f);\ + PUT_BYTE\ + }\ + }\ + } + +/** + * @def PUT_UTF16(val, tmp, PUT_16BIT) + * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). + * @param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If + * val is given as a function it is executed only once. + * @param tmp is a temporary variable and should be of type uint16_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_16BIT. + * @param PUT_16BIT writes the converted UTF-16 data to any proper destination + * in desired endianness. It could be a function or a statement, and uses tmp + * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" + * PUT_BYTE will be executed 1 or 2 times depending on input character. + */ +#define PUT_UTF16(val, tmp, PUT_16BIT)\ + {\ + uint32_t in = val;\ + if (in < 0x10000) {\ + tmp = in;\ + PUT_16BIT\ + } else {\ + tmp = 0xD800 | ((in - 0x10000) >> 10);\ + PUT_16BIT\ + tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ + PUT_16BIT\ + }\ + }\ + + + +#include "mem.h" + +#ifdef HAVE_AV_CONFIG_H +# include "internal.h" +#endif /* HAVE_AV_CONFIG_H */ + +#endif /* AVUTIL_COMMON_H */ + +/* + * The following definitions are outside the multiple inclusion guard + * to ensure they are immediately available in intmath.h. + */ + +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clip_uintp2 +# define av_clip_uintp2 av_clip_uintp2_c +#endif +#ifndef av_sat_add32 +# define av_sat_add32 av_sat_add32_c +#endif +#ifndef av_sat_dadd32 +# define av_sat_dadd32 av_sat_dadd32_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif +#ifndef av_popcount +# define av_popcount av_popcount_c +#endif +#ifndef av_popcount64 +# define av_popcount64 av_popcount64_c +#endif diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/cpu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/cpu.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CPU_H +#define AVUTIL_CPU_H + +#include "version.h" + +#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ + + /* lower 16 bits - CPU features */ +#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX +#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext +#if LIBAVUTIL_VERSION_MAJOR < 52 +#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext +#endif +#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW +#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions +#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions +#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster +#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt +#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions +#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster +#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions +#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower +#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions +#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions +#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used +#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions +#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions +#define AV_CPU_FLAG_CMOV 0x1000 ///< i686 cmov + +#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard + +#define AV_CPU_FLAG_ARMV5TE (1 << 0) +#define AV_CPU_FLAG_ARMV6 (1 << 1) +#define AV_CPU_FLAG_ARMV6T2 (1 << 2) +#define AV_CPU_FLAG_VFP (1 << 3) +#define AV_CPU_FLAG_VFPV3 (1 << 4) +#define AV_CPU_FLAG_NEON (1 << 5) + +/** + * Return the flags which specify extensions supported by the CPU. + */ +int av_get_cpu_flags(void); + +/** + * Set a mask on flags returned by av_get_cpu_flags(). + * This function is mainly useful for testing. + * + * @warning this function is not thread safe. + */ +void av_set_cpu_flags_mask(int mask); + +/** + * Parse CPU flags from a string. + * + * @return a combination of AV_CPU_* flags, negative on error. + */ +int av_parse_cpu_flags(const char *s); + +/* The following CPU-specific functions shall not be called directly. */ +int ff_get_cpu_flags_arm(void); +int ff_get_cpu_flags_ppc(void); +int ff_get_cpu_flags_x86(void); + +#endif /* AVUTIL_CPU_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/crc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/crc.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,43 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CRC_H +#define AVUTIL_CRC_H + +#include +#include +#include "attributes.h" + +typedef uint32_t AVCRC; + +typedef enum { + AV_CRC_8_ATM, + AV_CRC_16_ANSI, + AV_CRC_16_CCITT, + AV_CRC_32_IEEE, + AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ + AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */ +}AVCRCId; + +int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size); +const AVCRC *av_crc_get_table(AVCRCId crc_id); +uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure; + +#endif /* AVUTIL_CRC_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/dict.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/dict.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,129 @@ +/* + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Public dictionary API. + */ + +#ifndef AVUTIL_DICT_H +#define AVUTIL_DICT_H + +/** + * @addtogroup lavu_dict AVDictionary + * @ingroup lavu_data + * + * @brief Simple key:value store + * + * @{ + * Dictionaries are used for storing key:value pairs. To create + * an AVDictionary, simply pass an address of a NULL pointer to + * av_dict_set(). NULL can be used as an empty dictionary wherever + * a pointer to an AVDictionary is required. + * Use av_dict_get() to retrieve an entry or iterate over all + * entries and finally av_dict_free() to free the dictionary + * and all its contents. + * + * @code + * AVDictionary *d = NULL; // "create" an empty dictionary + * av_dict_set(&d, "foo", "bar", 0); // add an entry + * + * char *k = av_strdup("key"); // if your strings are already allocated, + * char *v = av_strdup("value"); // you can avoid copying them like this + * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + * + * AVDictionaryEntry *t = NULL; + * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { + * <....> // iterate over all entries in d + * } + * + * av_dict_free(&d); + * @endcode + * + */ + +#define AV_DICT_MATCH_CASE 1 +#define AV_DICT_IGNORE_SUFFIX 2 +#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been + allocated with av_malloc() and children. */ +#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been + allocated with av_malloc() and chilren. */ +#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. +#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no + delimiter is added, the strings are simply concatenated. */ + +typedef struct AVDictionaryEntry { + char *key; + char *value; +} AVDictionaryEntry; + +typedef struct AVDictionary AVDictionary; + +/** + * Get a dictionary entry with matching key. + * + * @param prev Set to the previous matching element to find the next. + * If set to NULL the first matching element is returned. + * @param flags Allows case as well as suffix-insensitive comparisons. + * @return Found entry or NULL, changing key or value leads to undefined behavior. + */ +AVDictionaryEntry * +av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); + +/** + * Get number of entries in dictionary. + * + * @param m dictionary + * @return number of entries in dictionary + */ +int av_dict_count(const AVDictionary *m); + +/** + * Set the given entry in *pm, overwriting an existing entry. + * + * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL + * a dictionary struct is allocated and put in *pm. + * @param key entry key to add to *pm (will be av_strduped depending on flags) + * @param value entry value to add to *pm (will be av_strduped depending on flags). + * Passing a NULL value will cause an existing entry to be deleted. + * @return >= 0 on success otherwise an error code <0 + */ +int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); + +/** + * Copy entries from one AVDictionary struct into another. + * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, + * this function will allocate a struct for you and put it in *dst + * @param src pointer to source AVDictionary struct + * @param flags flags to use when setting entries in *dst + * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag + */ +void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); + +/** + * Free all the memory allocated for an AVDictionary struct + * and all keys and values. + */ +void av_dict_free(AVDictionary **m); + +/** + * @} + */ + +#endif /* AVUTIL_DICT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/error.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/error.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,83 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * error code definitions + */ + +#ifndef AVUTIL_ERROR_H +#define AVUTIL_ERROR_H + +#include +#include +#include "avutil.h" + +/** + * @addtogroup lavu_error + * + * @{ + */ + + +/* error handling */ +#if EDOM > 0 +#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. +#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. +#else +/* Some platforms have E* and errno already negated. */ +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif + +#define AVERROR_BSF_NOT_FOUND (-0x39acbd08) ///< Bitstream filter not found +#define AVERROR_DECODER_NOT_FOUND (-0x3cbabb08) ///< Decoder not found +#define AVERROR_DEMUXER_NOT_FOUND (-0x32babb08) ///< Demuxer not found +#define AVERROR_ENCODER_NOT_FOUND (-0x3cb1ba08) ///< Encoder not found +#define AVERROR_EOF (-0x5fb9b0bb) ///< End of file +#define AVERROR_EXIT (-0x2bb6a7bb) ///< Immediate exit was requested; the called function should not be restarted +#define AVERROR_FILTER_NOT_FOUND (-0x33b6b908) ///< Filter not found +#define AVERROR_INVALIDDATA (-0x3ebbb1b7) ///< Invalid data found when processing input +#define AVERROR_MUXER_NOT_FOUND (-0x27aab208) ///< Muxer not found +#define AVERROR_OPTION_NOT_FOUND (-0x2bafb008) ///< Option not found +#define AVERROR_PATCHWELCOME (-0x3aa8beb0) ///< Not yet implemented in Libav, patches welcome +#define AVERROR_PROTOCOL_NOT_FOUND (-0x30adaf08) ///< Protocol not found +#define AVERROR_STREAM_NOT_FOUND (-0x2dabac08) ///< Stream not found +#define AVERROR_BUG (-0x5fb8aabe) ///< Bug detected, please report the issue +#define AVERROR_UNKNOWN (-0x31b4b1ab) ///< Unknown error, typically from an external library +#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it. + +/** + * Put a description of the AVERROR code errnum in errbuf. + * In case of failure the global variable errno is set to indicate the + * error. Even in case of failure av_strerror() will print a generic + * error message indicating the errnum provided to errbuf. + * + * @param errnum error code to describe + * @param errbuf buffer to which description is written + * @param errbuf_size the size in bytes of errbuf + * @return 0 on success, a negative value if a description for errnum + * cannot be found + */ +int av_strerror(int errnum, char *errbuf, size_t errbuf_size); + +/** + * @} + */ + +#endif /* AVUTIL_ERROR_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/eval.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/eval.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2002 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * simple arithmetic expression evaluator + */ + +#ifndef AVUTIL_EVAL_H +#define AVUTIL_EVAL_H + +#include "avutil.h" + +typedef struct AVExpr AVExpr; + +/** + * Parse and evaluate an expression. + * Note, this is significantly slower than av_expr_eval(). + * + * @param res a pointer to a double where is put the result value of + * the expression, or NAN in case of error + * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" + * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0} + * @param const_values a zero terminated array of values for the identifiers from const_names + * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers + * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument + * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers + * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments + * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 + * @param log_ctx parent logging context + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_expr_parse_and_eval(double *res, const char *s, + const char * const *const_names, const double *const_values, + const char * const *func1_names, double (* const *funcs1)(void *, double), + const char * const *func2_names, double (* const *funcs2)(void *, double, double), + void *opaque, int log_offset, void *log_ctx); + +/** + * Parse an expression. + * + * @param expr a pointer where is put an AVExpr containing the parsed + * value in case of successful parsing, or NULL otherwise. + * The pointed to AVExpr must be freed with av_expr_free() by the user + * when it is not needed anymore. + * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" + * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0} + * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers + * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument + * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers + * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments + * @param log_ctx parent logging context + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_expr_parse(AVExpr **expr, const char *s, + const char * const *const_names, + const char * const *func1_names, double (* const *funcs1)(void *, double), + const char * const *func2_names, double (* const *funcs2)(void *, double, double), + int log_offset, void *log_ctx); + +/** + * Evaluate a previously parsed expression. + * + * @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names + * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 + * @return the value of the expression + */ +double av_expr_eval(AVExpr *e, const double *const_values, void *opaque); + +/** + * Free a parsed expression previously created with av_expr_parse(). + */ +void av_expr_free(AVExpr *e); + +/** + * Parse the string in numstr and return its value as a double. If + * the string is empty, contains only whitespaces, or does not contain + * an initial substring that has the expected syntax for a + * floating-point number, no conversion is performed. In this case, + * returns a value of zero and the value returned in tail is the value + * of numstr. + * + * @param numstr a string representing a number, may contain one of + * the International System number postfixes, for example 'K', 'M', + * 'G'. If 'i' is appended after the postfix, powers of 2 are used + * instead of powers of 10. The 'B' postfix multiplies the value for + * 8, and can be appended after another postfix or used alone. This + * allows using for example 'KB', 'MiB', 'G' and 'B' as postfix. + * @param tail if non-NULL puts here the pointer to the char next + * after the last parsed character + */ +double av_strtod(const char *numstr, char **tail); + +#endif /* AVUTIL_EVAL_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/fifo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/fifo.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,142 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * a very simple circular buffer FIFO implementation + */ + +#ifndef AVUTIL_FIFO_H +#define AVUTIL_FIFO_H + +#include +#include "avutil.h" +#include "attributes.h" + +typedef struct AVFifoBuffer { + uint8_t *buffer; + uint8_t *rptr, *wptr, *end; + uint32_t rndx, wndx; +} AVFifoBuffer; + +/** + * Initialize an AVFifoBuffer. + * @param size of FIFO + * @return AVFifoBuffer or NULL in case of memory allocation failure + */ +AVFifoBuffer *av_fifo_alloc(unsigned int size); + +/** + * Free an AVFifoBuffer. + * @param f AVFifoBuffer to free + */ +void av_fifo_free(AVFifoBuffer *f); + +/** + * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. + * @param f AVFifoBuffer to reset + */ +void av_fifo_reset(AVFifoBuffer *f); + +/** + * Return the amount of data in bytes in the AVFifoBuffer, that is the + * amount of data you can read from it. + * @param f AVFifoBuffer to read from + * @return size + */ +int av_fifo_size(AVFifoBuffer *f); + +/** + * Return the amount of space in bytes in the AVFifoBuffer, that is the + * amount of data you can write into it. + * @param f AVFifoBuffer to write into + * @return size + */ +int av_fifo_space(AVFifoBuffer *f); + +/** + * Feed data from an AVFifoBuffer to a user-supplied callback. + * @param f AVFifoBuffer to read from + * @param buf_size number of bytes to read + * @param func generic read function + * @param dest data destination + */ +int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); + +/** + * Feed data from a user-supplied callback to an AVFifoBuffer. + * @param f AVFifoBuffer to write to + * @param src data source; non-const since it may be used as a + * modifiable context by the function defined in func + * @param size number of bytes to write + * @param func generic write function; the first parameter is src, + * the second is dest_buf, the third is dest_buf_size. + * func must return the number of bytes written to dest_buf, or <= 0 to + * indicate no more data available to write. + * If func is NULL, src is interpreted as a simple byte array for source data. + * @return the number of bytes written to the FIFO + */ +int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); + +/** + * Resize an AVFifoBuffer. + * @param f AVFifoBuffer to resize + * @param size new AVFifoBuffer size in bytes + * @return <0 for failure, >=0 otherwise + */ +int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); + +/** + * Read and discard the specified amount of data from an AVFifoBuffer. + * @param f AVFifoBuffer to read from + * @param size amount of data to read in bytes + */ +void av_fifo_drain(AVFifoBuffer *f, int size); + +/** + * Return a pointer to the data stored in a FIFO buffer at a certain offset. + * The FIFO buffer is not modified. + * + * @param f AVFifoBuffer to peek at, f must be non-NULL + * @param offs an offset in bytes, its absolute value must be less + * than the used buffer size or the returned pointer will + * point outside to the buffer data. + * The used buffer size can be checked with av_fifo_size(). + */ +static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) +{ + uint8_t *ptr = f->rptr + offs; + if (ptr >= f->end) + ptr = f->buffer + (ptr - f->end); + else if (ptr < f->buffer) + ptr = f->end - (f->buffer - ptr); + return ptr; +} + +#if FF_API_AV_FIFO_PEEK +/** + * @deprecated Use av_fifo_peek2() instead. + */ +attribute_deprecated +static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs) +{ + return *av_fifo_peek2(f, offs); +} +#endif + +#endif /* AVUTIL_FIFO_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/file.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/file.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,54 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FILE_H +#define AVUTIL_FILE_H + +#include + +#include "avutil.h" + +/** + * @file + * Misc file utilities. + */ + +/** + * Read the file with name filename, and put its content in a newly + * allocated buffer or map it with mmap() when available. + * In case of success set *bufptr to the read or mmapped buffer, and + * *size to the size in bytes of the buffer in *bufptr. + * The returned buffer must be released with av_file_unmap(). + * + * @param log_offset loglevel offset used for logging + * @param log_ctx context used for logging + * @return a non negative number in case of success, a negative value + * corresponding to an AVERROR error code in case of failure + */ +int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, + int log_offset, void *log_ctx); + +/** + * Unmap or free the buffer bufptr created by av_file_map(). + * + * @param size size in bytes of bufptr, must be the same as returned + * by av_file_map() + */ +void av_file_unmap(uint8_t *bufptr, size_t size); + +#endif /* AVUTIL_FILE_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/imgutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/imgutils.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,138 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_IMGUTILS_H +#define AVUTIL_IMGUTILS_H + +/** + * @file + * misc image utilities + * + * @addtogroup lavu_picture + * @{ + */ + +#include "avutil.h" +#include "pixdesc.h" + +/** + * Compute the max pixel step for each plane of an image with a + * format described by pixdesc. + * + * The pixel step is the distance in bytes between the first byte of + * the group of bytes which describe a pixel component and the first + * byte of the successive group in the same plane for the same + * component. + * + * @param max_pixsteps an array which is filled with the max pixel step + * for each plane. Since a plane may contain different pixel + * components, the computed max_pixsteps[plane] is relative to the + * component in the plane with the max pixel step. + * @param max_pixstep_comps an array which is filled with the component + * for each plane which has the max pixel step. May be NULL. + */ +void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc); + +/** + * Compute the size of an image line with format pix_fmt and width + * width for the plane plane. + * + * @return the computed size in bytes + */ +int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane); + +/** + * Fill plane linesizes for an image with pixel format pix_fmt and + * width width. + * + * @param linesizes array to be filled with the linesize for each plane + * @return >= 0 in case of success, a negative error code otherwise + */ +int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width); + +/** + * Fill plane data pointers for an image with pixel format pix_fmt and + * height height. + * + * @param data pointers array to be filled with the pointer for each image plane + * @param ptr the pointer to a buffer which will contain the image + * @param linesizes the array containing the linesize for each + * plane, should be filled by av_image_fill_linesizes() + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]); + +/** + * Allocate an image with size w and h and pixel format pix_fmt, and + * fill pointers and linesizes accordingly. + * The allocated image buffer has to be freed by using + * av_freep(&pointers[0]). + * + * @param align the value to use for buffer size alignment + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_alloc(uint8_t *pointers[4], int linesizes[4], + int w, int h, enum AVPixelFormat pix_fmt, int align); + +/** + * Copy image plane from src to dst. + * That is, copy "height" number of lines of "bytewidth" bytes each. + * The first byte of each successive line is separated by *_linesize + * bytes. + * + * @param dst_linesize linesize for the image plane in dst + * @param src_linesize linesize for the image plane in src + */ +void av_image_copy_plane(uint8_t *dst, int dst_linesize, + const uint8_t *src, int src_linesize, + int bytewidth, int height); + +/** + * Copy image in src_data to dst_data. + * + * @param dst_linesizes linesizes for the image in dst_data + * @param src_linesizes linesizes for the image in src_data + */ +void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], + const uint8_t *src_data[4], const int src_linesizes[4], + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Check if the given dimension of an image is valid, meaning that all + * bytes of the image can be addressed with a signed int. + * + * @param w the width of the picture + * @param h the height of the picture + * @param log_offset the offset to sum to the log level for logging with log_ctx + * @param log_ctx the parent logging context, it may be NULL + * @return >= 0 if valid, a negative error code otherwise + */ +int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); + +int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); + +/** + * @} + */ + + +#endif /* AVUTIL_IMGUTILS_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/intfloat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/intfloat.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_H +#define AVUTIL_INTFLOAT_H + +#include +#include "attributes.h" + +union av_intfloat32 { + uint32_t i; + float f; +}; + +union av_intfloat64 { + uint64_t i; + double f; +}; + +/** + * Reinterpret a 32-bit integer as a float. + */ +static av_always_inline float av_int2float(uint32_t i) +{ + union av_intfloat32 v; + v.i = i; + return v.f; +} + +/** + * Reinterpret a float as a 32-bit integer. + */ +static av_always_inline uint32_t av_float2int(float f) +{ + union av_intfloat32 v; + v.f = f; + return v.i; +} + +/** + * Reinterpret a 64-bit integer as a double. + */ +static av_always_inline double av_int2double(uint64_t i) +{ + union av_intfloat64 v; + v.i = i; + return v.f; +} + +/** + * Reinterpret a double as a 64-bit integer. + */ +static av_always_inline uint64_t av_double2int(double f) +{ + union av_intfloat64 v; + v.f = f; + return v.i; +} + +#endif /* AVUTIL_INTFLOAT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/intfloat_readwrite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/intfloat_readwrite.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,40 @@ +/* + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_READWRITE_H +#define AVUTIL_INTFLOAT_READWRITE_H + +#include +#include "attributes.h" + +/* IEEE 80 bits extended float */ +typedef struct AVExtFloat { + uint8_t exponent[2]; + uint8_t mantissa[8]; +} AVExtFloat; + +attribute_deprecated double av_int2dbl(int64_t v) av_const; +attribute_deprecated float av_int2flt(int32_t v) av_const; +attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const; +attribute_deprecated int64_t av_dbl2int(double d) av_const; +attribute_deprecated int32_t av_flt2int(float d) av_const; +attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const; + +#endif /* AVUTIL_INTFLOAT_READWRITE_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/intreadwrite.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/intreadwrite.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,522 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTREADWRITE_H +#define AVUTIL_INTREADWRITE_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" +#include "bswap.h" + +typedef union { + uint64_t u64; + uint32_t u32[2]; + uint16_t u16[4]; + uint8_t u8 [8]; + double f64; + float f32[2]; +} av_alias av_alias64; + +typedef union { + uint32_t u32; + uint16_t u16[2]; + uint8_t u8 [4]; + float f32; +} av_alias av_alias32; + +typedef union { + uint16_t u16; + uint8_t u8 [2]; +} av_alias av_alias16; + +/* + * Arch-specific headers can provide any combination of + * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. + * Preprocessor symbols must be defined, even if these are implemented + * as inline functions. + */ + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/intreadwrite.h" +#elif ARCH_AVR32 +# include "avr32/intreadwrite.h" +#elif ARCH_MIPS +# include "mips/intreadwrite.h" +#elif ARCH_PPC +# include "ppc/intreadwrite.h" +#elif ARCH_TOMI +# include "tomi/intreadwrite.h" +#elif ARCH_X86 +# include "x86/intreadwrite.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +/* + * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. + */ + +#if AV_HAVE_BIGENDIAN + +# if defined(AV_RN16) && !defined(AV_RB16) +# define AV_RB16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RB16) +# define AV_RN16(p) AV_RB16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WB16) +# define AV_WB16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WB16) +# define AV_WN16(p, v) AV_WB16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RB24) +# define AV_RB24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RB24) +# define AV_RN24(p) AV_RB24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WB24) +# define AV_WB24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WB24) +# define AV_WN24(p, v) AV_WB24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RB32) +# define AV_RB32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RB32) +# define AV_RN32(p) AV_RB32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WB32) +# define AV_WB32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WB32) +# define AV_WN32(p, v) AV_WB32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RB64) +# define AV_RB64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RB64) +# define AV_RN64(p) AV_RB64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WB64) +# define AV_WB64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WB64) +# define AV_WN64(p, v) AV_WB64(p, v) +# endif + +#else /* AV_HAVE_BIGENDIAN */ + +# if defined(AV_RN16) && !defined(AV_RL16) +# define AV_RL16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RL16) +# define AV_RN16(p) AV_RL16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WL16) +# define AV_WL16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WL16) +# define AV_WN16(p, v) AV_WL16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RL24) +# define AV_RL24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RL24) +# define AV_RN24(p) AV_RL24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WL24) +# define AV_WL24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WL24) +# define AV_WN24(p, v) AV_WL24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RL32) +# define AV_RL32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RL32) +# define AV_RN32(p) AV_RL32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WL32) +# define AV_WL32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WL32) +# define AV_WN32(p, v) AV_WL32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RL64) +# define AV_RL64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RL64) +# define AV_RN64(p) AV_RL64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WL64) +# define AV_WL64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WL64) +# define AV_WN64(p, v) AV_WL64(p, v) +# endif + +#endif /* !AV_HAVE_BIGENDIAN */ + +/* + * Define AV_[RW]N helper macros to simplify definitions not provided + * by per-arch headers. + */ + +#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) + +union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; +union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; +union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; + +# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) +# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) + +#elif defined(__DECC) + +# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) +# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) + +#elif AV_HAVE_FAST_UNALIGNED + +# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) +# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#else + +#ifndef AV_RB16 +# define AV_RB16(x) \ + ((((const uint8_t*)(x))[0] << 8) | \ + ((const uint8_t*)(x))[1]) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RL16 +# define AV_RL16(x) \ + ((((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RB32 +# define AV_RB32(x) \ + (((uint32_t)((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RL32 +# define AV_RL32(x) \ + (((uint32_t)((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RB64 +# define AV_RB64(x) \ + (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ + ((uint8_t*)(p))[5] = (d)>>16; \ + ((uint8_t*)(p))[4] = (d)>>24; \ + ((uint8_t*)(p))[3] = (d)>>32; \ + ((uint8_t*)(p))[2] = (d)>>40; \ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; \ + } while(0) +#endif + +#ifndef AV_RL64 +# define AV_RL64(x) \ + (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ + (uint64_t)((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + ((uint8_t*)(p))[4] = (d)>>32; \ + ((uint8_t*)(p))[5] = (d)>>40; \ + ((uint8_t*)(p))[6] = (d)>>48; \ + ((uint8_t*)(p))[7] = (d)>>56; \ + } while(0) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RN(s, p) AV_RB##s(p) +# define AV_WN(s, p, v) AV_WB##s(p, v) +#else +# define AV_RN(s, p) AV_RL##s(p) +# define AV_WN(s, p, v) AV_WL##s(p, v) +#endif + +#endif /* HAVE_FAST_UNALIGNED */ + +#ifndef AV_RN16 +# define AV_RN16(p) AV_RN(16, p) +#endif + +#ifndef AV_RN32 +# define AV_RN32(p) AV_RN(32, p) +#endif + +#ifndef AV_RN64 +# define AV_RN64(p) AV_RN(64, p) +#endif + +#ifndef AV_WN16 +# define AV_WN16(p, v) AV_WN(16, p, v) +#endif + +#ifndef AV_WN32 +# define AV_WN32(p, v) AV_WN(32, p, v) +#endif + +#ifndef AV_WN64 +# define AV_WN64(p, v) AV_WN(64, p, v) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RB(s, p) AV_RN##s(p) +# define AV_WB(s, p, v) AV_WN##s(p, v) +# define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) +#else +# define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) +# define AV_RL(s, p) AV_RN##s(p) +# define AV_WL(s, p, v) AV_WN##s(p, v) +#endif + +#define AV_RB8(x) (((const uint8_t*)(x))[0]) +#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + +#define AV_RL8(x) AV_RB8(x) +#define AV_WL8(p, d) AV_WB8(p, d) + +#ifndef AV_RB16 +# define AV_RB16(p) AV_RB(16, p) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, v) AV_WB(16, p, v) +#endif + +#ifndef AV_RL16 +# define AV_RL16(p) AV_RL(16, p) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, v) AV_WL(16, p, v) +#endif + +#ifndef AV_RB32 +# define AV_RB32(p) AV_RB(32, p) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, v) AV_WB(32, p, v) +#endif + +#ifndef AV_RL32 +# define AV_RL32(p) AV_RL(32, p) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, v) AV_WL(32, p, v) +#endif + +#ifndef AV_RB64 +# define AV_RB64(p) AV_RB(64, p) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, v) AV_WB(64, p, v) +#endif + +#ifndef AV_RL64 +# define AV_RL64(p) AV_RL(64, p) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, v) AV_WL(64, p, v) +#endif + +#ifndef AV_RB24 +# define AV_RB24(x) \ + ((((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#endif +#ifndef AV_WB24 +# define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; \ + } while(0) +#endif + +#ifndef AV_RL24 +# define AV_RL24(x) \ + ((((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL24 +# define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + } while(0) +#endif + +/* + * The AV_[RW]NA macros access naturally aligned data + * in a type-safe way. + */ + +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#ifndef AV_RN16A +# define AV_RN16A(p) AV_RNA(16, p) +#endif + +#ifndef AV_RN32A +# define AV_RN32A(p) AV_RNA(32, p) +#endif + +#ifndef AV_RN64A +# define AV_RN64A(p) AV_RNA(64, p) +#endif + +#ifndef AV_WN16A +# define AV_WN16A(p, v) AV_WNA(16, p, v) +#endif + +#ifndef AV_WN32A +# define AV_WN32A(p, v) AV_WNA(32, p, v) +#endif + +#ifndef AV_WN64A +# define AV_WN64A(p, v) AV_WNA(64, p, v) +#endif + +/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be + * naturally aligned. They may be implemented using MMX, + * so emms_c() must be called before using any float code + * afterwards. + */ + +#define AV_COPY(n, d, s) \ + (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) + +#ifndef AV_COPY16 +# define AV_COPY16(d, s) AV_COPY(16, d, s) +#endif + +#ifndef AV_COPY32 +# define AV_COPY32(d, s) AV_COPY(32, d, s) +#endif + +#ifndef AV_COPY64 +# define AV_COPY64(d, s) AV_COPY(64, d, s) +#endif + +#ifndef AV_COPY128 +# define AV_COPY128(d, s) \ + do { \ + AV_COPY64(d, s); \ + AV_COPY64((char*)(d)+8, (char*)(s)+8); \ + } while(0) +#endif + +#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) + +#ifndef AV_SWAP64 +# define AV_SWAP64(a, b) AV_SWAP(64, a, b) +#endif + +#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) + +#ifndef AV_ZERO16 +# define AV_ZERO16(d) AV_ZERO(16, d) +#endif + +#ifndef AV_ZERO32 +# define AV_ZERO32(d) AV_ZERO(32, d) +#endif + +#ifndef AV_ZERO64 +# define AV_ZERO64(d) AV_ZERO(64, d) +#endif + +#ifndef AV_ZERO128 +# define AV_ZERO128(d) \ + do { \ + AV_ZERO64(d); \ + AV_ZERO64((char*)(d)+8); \ + } while(0) +#endif + +#endif /* AVUTIL_INTREADWRITE_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/lfg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/lfg.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,62 @@ +/* + * Lagged Fibonacci PRNG + * Copyright (c) 2008 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LFG_H +#define AVUTIL_LFG_H + +typedef struct AVLFG { + unsigned int state[64]; + int index; +} AVLFG; + +void av_lfg_init(AVLFG *c, unsigned int seed); + +/** + * Get the next random unsigned 32-bit number using an ALFG. + * + * Please also consider a simple LCG like state= state*1664525+1013904223, + * it may be good enough and faster for your specific use case. + */ +static inline unsigned int av_lfg_get(AVLFG *c){ + c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63]; + return c->state[c->index++ & 63]; +} + +/** + * Get the next random unsigned 32-bit number using a MLFG. + * + * Please also consider av_lfg_get() above, it is faster. + */ +static inline unsigned int av_mlfg_get(AVLFG *c){ + unsigned int a= c->state[(c->index-55) & 63]; + unsigned int b= c->state[(c->index-24) & 63]; + return c->state[c->index++ & 63] = 2*a*b+a+b; +} + +/** + * Get the next two numbers generated by a Box-Muller Gaussian + * generator using the random numbers issued by lfg. + * + * @param out array where the two generated numbers are placed + */ +void av_bmg_get(AVLFG *lfg, double out[2]); + +#endif /* AVUTIL_LFG_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/log.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,172 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LOG_H +#define AVUTIL_LOG_H + +#include +#include "avutil.h" +#include "attributes.h" + +/** + * Describe the class of an AVClass context structure. That is an + * arbitrary struct of which the first field is a pointer to an + * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). + */ +typedef struct AVClass { + /** + * The name of the class; usually it is the same name as the + * context structure type to which the AVClass is associated. + */ + const char* class_name; + + /** + * A pointer to a function which returns the name of a context + * instance ctx associated with the class. + */ + const char* (*item_name)(void* ctx); + + /** + * a pointer to the first option specified in the class if any or NULL + * + * @see av_set_default_options() + */ + const struct AVOption *option; + + /** + * LIBAVUTIL_VERSION with which this structure was created. + * This is used to allow fields to be added without requiring major + * version bumps everywhere. + */ + + int version; + + /** + * Offset in the structure where log_level_offset is stored. + * 0 means there is no such variable + */ + int log_level_offset_offset; + + /** + * Offset in the structure where a pointer to the parent context for loging is stored. + * for example a decoder that uses eval.c could pass its AVCodecContext to eval as such + * parent context. And a av_log() implementation could then display the parent context + * can be NULL of course + */ + int parent_log_context_offset; + + /** + * Return next AVOptions-enabled child or NULL + */ + void* (*child_next)(void *obj, void *prev); + + /** + * Return an AVClass corresponding to next potential + * AVOptions-enabled child. + * + * The difference between child_next and this is that + * child_next iterates over _already existing_ objects, while + * child_class_next iterates over _all possible_ children. + */ + const struct AVClass* (*child_class_next)(const struct AVClass *prev); +} AVClass; + +/* av_log API */ + +#define AV_LOG_QUIET -8 + +/** + * Something went really wrong and we will crash now. + */ +#define AV_LOG_PANIC 0 + +/** + * Something went wrong and recovery is not possible. + * For example, no header was found for a format which depends + * on headers or an illegal combination of parameters is used. + */ +#define AV_LOG_FATAL 8 + +/** + * Something went wrong and cannot losslessly be recovered. + * However, not all future data is affected. + */ +#define AV_LOG_ERROR 16 + +/** + * Something somehow does not look correct. This may or may not + * lead to problems. An example would be the use of '-vstrict -2'. + */ +#define AV_LOG_WARNING 24 + +#define AV_LOG_INFO 32 +#define AV_LOG_VERBOSE 40 + +/** + * Stuff which is only useful for libav* developers. + */ +#define AV_LOG_DEBUG 48 + +/** + * Send the specified message to the log if the level is less than or equal + * to the current av_log_level. By default, all logging messages are sent to + * stderr. This behavior can be altered by setting a different av_vlog callback + * function. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param fmt The format string (printf-compatible) that specifies how + * subsequent arguments are converted to output. + * @see av_vlog + */ +void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); + +void av_vlog(void *avcl, int level, const char *fmt, va_list); +int av_log_get_level(void); +void av_log_set_level(int); +void av_log_set_callback(void (*)(void*, int, const char*, va_list)); +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +const char* av_default_item_name(void* ctx); + +/** + * av_dlog macros + * Useful to print debug messages that shouldn't get compiled in normally. + */ + +#ifdef DEBUG +# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) +#else +# define av_dlog(pctx, ...) +#endif + +/** + * Skip repeated messages, this requires the user app to use av_log() instead of + * (f)printf as the 2 would otherwise interfere and lead to + * "Last message repeated x times" messages below (f)printf messages with some + * bad luck. + * Also to receive the last, "last repeated" line if any, the user app must + * call av_log(NULL, AV_LOG_QUIET, ""); at the end + */ +#define AV_LOG_SKIP_REPEATED 1 +void av_log_set_flags(int arg); + +#endif /* AVUTIL_LOG_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/lzo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/lzo.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,77 @@ +/* + * LZO 1x decompression + * copyright (c) 2006 Reimar Doeffinger + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LZO_H +#define AVUTIL_LZO_H + +/** + * @defgroup lavu_lzo LZO + * @ingroup lavu_crypto + * + * @{ + */ + +#include + +/** @name Error flags returned by av_lzo1x_decode + * @{ */ +/// end of the input buffer reached before decoding finished +#define AV_LZO_INPUT_DEPLETED 1 +/// decoded data did not fit into output buffer +#define AV_LZO_OUTPUT_FULL 2 +/// a reference to previously decoded data was wrong +#define AV_LZO_INVALID_BACKPTR 4 +/// a non-specific error in the compressed bitstream +#define AV_LZO_ERROR 8 +/** @} */ + +#define AV_LZO_INPUT_PADDING 8 +#define AV_LZO_OUTPUT_PADDING 12 + +/** + * @brief Decodes LZO 1x compressed data. + * @param out output buffer + * @param outlen size of output buffer, number of bytes left are returned here + * @param in input buffer + * @param inlen size of input buffer, number of bytes left are returned here + * @return 0 on success, otherwise a combination of the error flags above + * + * Make sure all buffers are appropriately padded, in must provide + * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. + */ +int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); + +/** + * @brief deliberately overlapping memcpy implementation + * @param dst destination buffer; must be padded with 12 additional bytes + * @param back how many bytes back we start (the initial size of the overlapping window) + * @param cnt number of bytes to copy, must be >= 0 + * + * cnt > back is valid, this will copy the bytes we just copied, + * thus creating a repeating pattern with a period length of back. + */ +void av_memcpy_backptr(uint8_t *dst, int back, int cnt); + +/** + * @} + */ + +#endif /* AVUTIL_LZO_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/mathematics.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/mathematics.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,111 @@ +/* + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MATHEMATICS_H +#define AVUTIL_MATHEMATICS_H + +#include +#include +#include "attributes.h" +#include "rational.h" +#include "intfloat.h" + +#ifndef M_LOG2_10 +#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ +#endif +#ifndef M_PHI +#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ +#endif +#ifndef NAN +#define NAN av_int2float(0x7fc00000) +#endif +#ifndef INFINITY +#define INFINITY av_int2float(0x7f800000) +#endif + +/** + * @addtogroup lavu_math + * @{ + */ + + +enum AVRounding { + AV_ROUND_ZERO = 0, ///< Round toward zero. + AV_ROUND_INF = 1, ///< Round away from zero. + AV_ROUND_DOWN = 2, ///< Round toward -infinity. + AV_ROUND_UP = 3, ///< Round toward +infinity. + AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. +}; + +/** + * Return the greatest common divisor of a and b. + * If both a and b are 0 or either or both are <0 then behavior is + * undefined. + */ +int64_t av_const av_gcd(int64_t a, int64_t b); + +/** + * Rescale a 64-bit integer with rounding to nearest. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; + +/** + * Rescale a 64-bit integer with specified rounding. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; + +/** + * Rescale a 64-bit integer by 2 rational numbers. + */ +int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; + +/** + * Rescale a 64-bit integer by 2 rational numbers with specified rounding. + */ +int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, + enum AVRounding) av_const; + +/** + * Compare 2 timestamps each in its own timebases. + * The result of the function is undefined if one of the timestamps + * is outside the int64_t range when represented in the others timebase. + * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position + */ +int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); + +/** + * Compare 2 integers modulo mod. + * That is we compare integers a and b for which only the least + * significant log2(mod) bits are known. + * + * @param mod must be a power of 2 + * @return a negative value if a is smaller than b + * a positive value if a is greater than b + * 0 if a equals b + */ +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); + +/** + * @} + */ + +#endif /* AVUTIL_MATHEMATICS_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/md5.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/md5.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,51 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MD5_H +#define AVUTIL_MD5_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_md5 MD5 + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_md5_size; +#endif + +struct AVMD5; + +struct AVMD5 *av_md5_alloc(void); +void av_md5_init(struct AVMD5 *ctx); +void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); +void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); +void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); + +/** + * @} + */ + +#endif /* AVUTIL_MD5_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/mem.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/mem.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,171 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * memory handling functions + */ + +#ifndef AVUTIL_MEM_H +#define AVUTIL_MEM_H + +#include + +#include "attributes.h" +#include "avutil.h" + +/** + * @addtogroup lavu_mem + * @{ + */ + + +#if defined(__ICC) && __ICC < 1200 || defined(__SUNPRO_C) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v +#elif defined(__TI_COMPILER_VERSION__) + #define DECLARE_ALIGNED(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + t __attribute__((aligned(n))) v + #define DECLARE_ASM_CONST(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + static const t __attribute__((aligned(n))) v +#elif defined(__GNUC__) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v +#elif defined(_MSC_VER) + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v +#else + #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) + #define av_malloc_attrib __attribute__((__malloc__)) +#else + #define av_malloc_attrib +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,3) + #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) +#else + #define av_alloc_size(...) +#endif + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU). + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + */ +void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); + +/** + * Helper function to allocate a block of size * nmemb bytes with + * using av_malloc() + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_malloc() + */ +av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) +{ + if (size <= 0 || nmemb >= INT_MAX / size) + return NULL; + return av_malloc(nmemb * size); +} + +/** + * Allocate or reallocate a block of memory. + * If ptr is NULL and size > 0, allocate a new block. If + * size is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + * @see av_fast_realloc() + */ +void *av_realloc(void *ptr, size_t size) av_alloc_size(2); + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc(). + * @param ptr Pointer to the memory block which should be freed. + * @note ptr = NULL is explicitly allowed. + * @note It is recommended that you use av_freep() instead. + * @see av_freep() + */ +void av_free(void *ptr); + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * zero all the bytes of the block. + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot be allocated. + * @see av_malloc() + */ +void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); + +/** + * Helper function to allocate a block of size * nmemb bytes with + * using av_mallocz() + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + * @see av_malloc_array() + */ +av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) +{ + if (size <= 0 || nmemb >= INT_MAX / size) + return NULL; + return av_mallocz(nmemb * size); +} + +/** + * Duplicate the string s. + * @param s string to be duplicated + * @return Pointer to a newly allocated string containing a + * copy of s or NULL if the string cannot be allocated. + */ +char *av_strdup(const char *s) av_malloc_attrib; + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set the pointer pointing to it to NULL. + * @param ptr Pointer to the pointer to the memory block which should + * be freed. + * @see av_free() + */ +void av_freep(void *ptr); + +/** + * @} + */ + +#endif /* AVUTIL_MEM_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/old_pix_fmts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/old_pix_fmts.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,128 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_OLD_PIX_FMTS_H +#define AVUTIL_OLD_PIX_FMTS_H + +/* + * This header exists to prevent new pixel formats from being accidentally added + * to the deprecated list. + * Do not include it directly. It will be removed on next major bump + * + * Do not add new items to this list. Use the AVPixelFormat enum instead. + */ + PIX_FMT_NONE = AV_PIX_FMT_NONE, + PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr + PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... + PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... + PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) + PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) + PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) + PIX_FMT_GRAY8, ///< Y , 8bpp + PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette + PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range + PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range + PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range + PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 + PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 + PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) + PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) + PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) + PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) + PIX_FMT_NV21, ///< as above, but U and V bytes are swapped + + PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... + PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... + PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... + PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... + + PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian + PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian + PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) + PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range + PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) + PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian + + PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian + PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian + PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 + PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 + + PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian + PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian + PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 + PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 + + PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers + PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers + PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + + PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer + + PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 + PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 + PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 + PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 + PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha + PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian + PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_VDA_VLD, ///< hardware decoding through VDA + PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp + PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian + PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian + PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian + PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian + PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian + PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian + PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + +#endif /* AVUTIL_OLD_PIX_FMTS_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/opt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/opt.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,592 @@ +/* + * AVOptions + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_OPT_H +#define AVUTIL_OPT_H + +/** + * @file + * AVOptions + */ + +#include "rational.h" +#include "avutil.h" +#include "dict.h" +#include "log.h" + +/** + * @defgroup avoptions AVOptions + * @ingroup lavu_data + * @{ + * AVOptions provide a generic system to declare options on arbitrary structs + * ("objects"). An option can have a help text, a type and a range of possible + * values. Options may then be enumerated, read and written to. + * + * @section avoptions_implement Implementing AVOptions + * This section describes how to add AVOptions capabilities to a struct. + * + * All AVOptions-related information is stored in an AVClass. Therefore + * the first member of the struct must be a pointer to an AVClass describing it. + * The option field of the AVClass must be set to a NULL-terminated static array + * of AVOptions. Each AVOption must have a non-empty name, a type, a default + * value and for number-type AVOptions also a range of allowed values. It must + * also declare an offset in bytes from the start of the struct, where the field + * associated with this AVOption is located. Other fields in the AVOption struct + * should also be set when applicable, but are not required. + * + * The following example illustrates an AVOptions-enabled struct: + * @code + * typedef struct test_struct { + * AVClass *class; + * int int_opt; + * char *str_opt; + * uint8_t *bin_opt; + * int bin_len; + * } test_struct; + * + * static const AVOption options[] = { + * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt), + * AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX }, + * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt), + * AV_OPT_TYPE_STRING }, + * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt), + * AV_OPT_TYPE_BINARY }, + * { NULL }, + * }; + * + * static const AVClass test_class = { + * .class_name = "test class", + * .item_name = av_default_item_name, + * .option = options, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * @endcode + * + * Next, when allocating your struct, you must ensure that the AVClass pointer + * is set to the correct value. Then, av_opt_set_defaults() must be called to + * initialize defaults. After that the struct is ready to be used with the + * AVOptions API. + * + * When cleaning up, you may use the av_opt_free() function to automatically + * free all the allocated string and binary options. + * + * Continuing with the above example: + * + * @code + * test_struct *alloc_test_struct(void) + * { + * test_struct *ret = av_malloc(sizeof(*ret)); + * ret->class = &test_class; + * av_opt_set_defaults(ret); + * return ret; + * } + * void free_test_struct(test_struct **foo) + * { + * av_opt_free(*foo); + * av_freep(foo); + * } + * @endcode + * + * @subsection avoptions_implement_nesting Nesting + * It may happen that an AVOptions-enabled struct contains another + * AVOptions-enabled struct as a member (e.g. AVCodecContext in + * libavcodec exports generic options, while its priv_data field exports + * codec-specific options). In such a case, it is possible to set up the + * parent struct to export a child's options. To do that, simply + * implement AVClass.child_next() and AVClass.child_class_next() in the + * parent struct's AVClass. + * Assuming that the test_struct from above now also contains a + * child_struct field: + * + * @code + * typedef struct child_struct { + * AVClass *class; + * int flags_opt; + * } child_struct; + * static const AVOption child_opts[] = { + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX }, + * { NULL }, + * }; + * static const AVClass child_class = { + * .class_name = "child class", + * .item_name = av_default_item_name, + * .option = child_opts, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * + * void *child_next(void *obj, void *prev) + * { + * test_struct *t = obj; + * if (!prev && t->child_struct) + * return t->child_struct; + * return NULL + * } + * const AVClass child_class_next(const AVClass *prev) + * { + * return prev ? NULL : &child_class; + * } + * @endcode + * Putting child_next() and child_class_next() as defined above into + * test_class will now make child_struct's options accessible through + * test_struct (again, proper setup as described above needs to be done on + * child_struct right after it is created). + * + * From the above example it might not be clear why both child_next() + * and child_class_next() are needed. The distinction is that child_next() + * iterates over actually existing objects, while child_class_next() + * iterates over all possible child classes. E.g. if an AVCodecContext + * was initialized to use a codec which has private options, then its + * child_next() will return AVCodecContext.priv_data and finish + * iterating. OTOH child_class_next() on AVCodecContext.av_class will + * iterate over all available codecs with private options. + * + * @subsection avoptions_implement_named_constants Named constants + * It is possible to create named constants for options. Simply set the unit + * field of the option the constants should apply to to a string and + * create the constants themselves as options of type AV_OPT_TYPE_CONST + * with their unit field set to the same string. + * Their default_val field should contain the value of the named + * constant. + * For example, to add some named constants for the test_flags option + * above, put the following into the child_opts array: + * @code + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" }, + * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" }, + * @endcode + * + * @section avoptions_use Using AVOptions + * This section deals with accessing options in an AVOptions-enabled struct. + * Such structs in Libav are e.g. AVCodecContext in libavcodec or + * AVFormatContext in libavformat. + * + * @subsection avoptions_use_examine Examining AVOptions + * The basic functions for examining options are av_opt_next(), which iterates + * over all options defined for one object, and av_opt_find(), which searches + * for an option with the given name. + * + * The situation is more complicated with nesting. An AVOptions-enabled struct + * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag + * to av_opt_find() will make the function search children recursively. + * + * For enumerating there are basically two cases. The first is when you want to + * get all options that may potentially exist on the struct and its children + * (e.g. when constructing documentation). In that case you should call + * av_opt_child_class_next() recursively on the parent struct's AVClass. The + * second case is when you have an already initialized struct with all its + * children and you want to get all options that can be actually written or read + * from it. In that case you should call av_opt_child_next() recursively (and + * av_opt_next() on each result). + * + * @subsection avoptions_use_get_set Reading and writing AVOptions + * When setting options, you often have a string read directly from the + * user. In such a case, simply passing it to av_opt_set() is enough. For + * non-string type options, av_opt_set() will parse the string according to the + * option type. + * + * Similarly av_opt_get() will read any option type and convert it to a string + * which will be returned. Do not forget that the string is allocated, so you + * have to free it with av_free(). + * + * In some cases it may be more convenient to put all options into an + * AVDictionary and call av_opt_set_dict() on it. A specific case of this + * are the format/codec open functions in lavf/lavc which take a dictionary + * filled with option as a parameter. This allows to set some options + * that cannot be set otherwise, since e.g. the input file format is not known + * before the file is actually opened. + */ + +enum AVOptionType{ + AV_OPT_TYPE_FLAGS, + AV_OPT_TYPE_INT, + AV_OPT_TYPE_INT64, + AV_OPT_TYPE_DOUBLE, + AV_OPT_TYPE_FLOAT, + AV_OPT_TYPE_STRING, + AV_OPT_TYPE_RATIONAL, + AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + AV_OPT_TYPE_CONST = 128, +#if FF_API_OLD_AVOPTIONS + FF_OPT_TYPE_FLAGS = 0, + FF_OPT_TYPE_INT, + FF_OPT_TYPE_INT64, + FF_OPT_TYPE_DOUBLE, + FF_OPT_TYPE_FLOAT, + FF_OPT_TYPE_STRING, + FF_OPT_TYPE_RATIONAL, + FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + FF_OPT_TYPE_CONST=128, +#endif +}; + +/** + * AVOption + */ +typedef struct AVOption { + const char *name; + + /** + * short English help text + * @todo What about other languages? + */ + const char *help; + + /** + * The offset relative to the context structure where the option + * value is stored. It should be 0 for named constants. + */ + int offset; + enum AVOptionType type; + + /** + * the default value for scalar options + */ + union { + int64_t i64; + double dbl; + const char *str; + /* TODO those are unused now */ + AVRational q; + } default_val; + double min; ///< minimum valid value for the option + double max; ///< maximum valid value for the option + + int flags; +#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding +#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding +#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... +#define AV_OPT_FLAG_AUDIO_PARAM 8 +#define AV_OPT_FLAG_VIDEO_PARAM 16 +#define AV_OPT_FLAG_SUBTITLE_PARAM 32 +//FIXME think about enc-audio, ... style flags + + /** + * The logical unit to which the option belongs. Non-constant + * options and corresponding named constants share the same + * unit. May be NULL. + */ + const char *unit; +} AVOption; + +#if FF_API_FIND_OPT +/** + * Look for an option in obj. Look only for the options which + * have the flags set as specified in mask and flags (that is, + * for which it is the case that opt->flags & mask == flags). + * + * @param[in] obj a pointer to a struct whose first element is a + * pointer to an AVClass + * @param[in] name the name of the option to look for + * @param[in] unit the unit of the option to look for, or any if NULL + * @return a pointer to the option found, or NULL if no option + * has been found + * + * @deprecated use av_opt_find. + */ +attribute_deprecated +const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags); +#endif + +#if FF_API_OLD_AVOPTIONS +/** + * Set the field of obj with the given name to value. + * + * @param[in] obj A struct whose first element is a pointer to an + * AVClass. + * @param[in] name the name of the field to set + * @param[in] val The value to set. If the field is not of a string + * type, then the given string is parsed. + * SI postfixes and some named scalars are supported. + * If the field is of a numeric type, it has to be a numeric or named + * scalar. Behavior with more than one scalar and +- infix operators + * is undefined. + * If the field is of a flags type, it has to be a sequence of numeric + * scalars or named flags separated by '+' or '-'. Prefixing a flag + * with '+' causes it to be set without affecting the other flags; + * similarly, '-' unsets a flag. + * @param[out] o_out if non-NULL put here a pointer to the AVOption + * found + * @param alloc this parameter is currently ignored + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR_OPTION_NOT_FOUND if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid + * @deprecated use av_opt_set() + */ +attribute_deprecated +int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out); + +attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n); +attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n); +attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n); + +attribute_deprecated double av_get_double(void *obj, const char *name, const AVOption **o_out); +attribute_deprecated AVRational av_get_q(void *obj, const char *name, const AVOption **o_out); +attribute_deprecated int64_t av_get_int(void *obj, const char *name, const AVOption **o_out); +attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len); +attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last); +#endif + +/** + * Show the obj options. + * + * @param req_flags requested flags for the options to show. Show only the + * options for which it is opt->flags & req_flags. + * @param rej_flags rejected flags for the options to show. Show only the + * options for which it is !(opt->flags & req_flags). + * @param av_log_obj log context to use for showing the options + */ +int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); + +/** + * Set the values of all AVOption fields to their default values. + * + * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) + */ +void av_opt_set_defaults(void *s); + +#if FF_API_OLD_AVOPTIONS +attribute_deprecated +void av_opt_set_defaults2(void *s, int mask, int flags); +#endif + +/** + * Parse the key/value pairs list in opts. For each key/value pair + * found, stores the value in the field in ctx that is named like the + * key. ctx must be an AVClass context, storing is done using + * AVOptions. + * + * @param key_val_sep a 0-terminated list of characters used to + * separate key from value + * @param pairs_sep a 0-terminated list of characters used to separate + * two pairs from each other + * @return the number of successfully set key/value pairs, or a negative + * value corresponding to an AVERROR code in case of error: + * AVERROR(EINVAL) if opts cannot be parsed, + * the error code issued by av_set_string3() if a key/value pair + * cannot be set + */ +int av_set_options_string(void *ctx, const char *opts, + const char *key_val_sep, const char *pairs_sep); + +/** + * Free all string and binary options in obj. + */ +void av_opt_free(void *obj); + +/** + * Check whether a particular flag is set in a flags field. + * + * @param field_name the name of the flag field option + * @param flag_name the name of the flag to check + * @return non-zero if the flag is set, zero if the flag isn't set, + * isn't of the right type, or the flags field doesn't exist. + */ +int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name); + +/* + * Set all the options from a given dictionary on an object. + * + * @param obj a struct whose first element is a pointer to AVClass + * @param options options to process. This dictionary will be freed and replaced + * by a new one containing all options not found in obj. + * Of course this new dictionary needs to be freed by caller + * with av_dict_free(). + * + * @return 0 on success, a negative AVERROR if some option was found in obj, + * but could not be set. + * + * @see av_dict_copy() + */ +int av_opt_set_dict(void *obj, struct AVDictionary **options); + +/** + * @defgroup opt_eval_funcs Evaluating option strings + * @{ + * This group of functions can be used to evaluate option strings + * and get numbers out of them. They do the same thing as av_opt_set(), + * except the result is written into the caller-supplied pointer. + * + * @param obj a struct whose first element is a pointer to AVClass. + * @param o an option for which the string is to be evaluated. + * @param val string to be evaluated. + * @param *_out value of the string will be written here. + * + * @return 0 on success, a negative number on failure. + */ +int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); +int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); +int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); +int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); +int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); +int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); +/** + * @} + */ + +#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the + given object first. */ +/** + * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass + * instead of a required pointer to a struct containing AVClass. This is + * useful for searching for options without needing to allocate the corresponding + * object. + */ +#define AV_OPT_SEARCH_FAKE_OBJ 0x0002 + +/** + * Look for an option in an object. Consider only options which + * have all the specified flags set. + * + * @param[in] obj A pointer to a struct whose first element is a + * pointer to an AVClass. + * Alternatively a double pointer to an AVClass, if + * AV_OPT_SEARCH_FAKE_OBJ search flag is set. + * @param[in] name The name of the option to look for. + * @param[in] unit When searching for named constants, name of the unit + * it belongs to. + * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * + * @return A pointer to the option found, or NULL if no option + * was found. + * + * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable + * directly with av_set_string3(). Use special calls which take an options + * AVDictionary (e.g. avformat_open_input()) to set options found with this + * flag. + */ +const AVOption *av_opt_find(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags); + +/** + * Look for an option in an object. Consider only options which + * have all the specified flags set. + * + * @param[in] obj A pointer to a struct whose first element is a + * pointer to an AVClass. + * Alternatively a double pointer to an AVClass, if + * AV_OPT_SEARCH_FAKE_OBJ search flag is set. + * @param[in] name The name of the option to look for. + * @param[in] unit When searching for named constants, name of the unit + * it belongs to. + * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * @param[out] target_obj if non-NULL, an object to which the option belongs will be + * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present + * in search_flags. This parameter is ignored if search_flags contain + * AV_OPT_SEARCH_FAKE_OBJ. + * + * @return A pointer to the option found, or NULL if no option + * was found. + */ +const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags, void **target_obj); + +/** + * Iterate over all AVOptions belonging to obj. + * + * @param obj an AVOptions-enabled struct or a double pointer to an + * AVClass describing it. + * @param prev result of the previous call to av_opt_next() on this object + * or NULL + * @return next AVOption or NULL + */ +const AVOption *av_opt_next(void *obj, const AVOption *prev); + +/** + * Iterate over AVOptions-enabled children of obj. + * + * @param prev result of a previous call to this function or NULL + * @return next AVOptions-enabled child or NULL + */ +void *av_opt_child_next(void *obj, void *prev); + +/** + * Iterate over potential AVOptions-enabled children of parent. + * + * @param prev result of a previous call to this function or NULL + * @return AVClass corresponding to next potential child or NULL + */ +const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); + +/** + * @defgroup opt_set_funcs Option setting functions + * @{ + * Those functions set the field of obj with the given name to value. + * + * @param[in] obj A struct whose first element is a pointer to an AVClass. + * @param[in] name the name of the field to set + * @param[in] val The value to set. In case of av_opt_set() if the field is not + * of a string type, then the given string is parsed. + * SI postfixes and some named scalars are supported. + * If the field is of a numeric type, it has to be a numeric or named + * scalar. Behavior with more than one scalar and +- infix operators + * is undefined. + * If the field is of a flags type, it has to be a sequence of numeric + * scalars or named flags separated by '+' or '-'. Prefixing a flag + * with '+' causes it to be set without affecting the other flags; + * similarly, '-' unsets a flag. + * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be set on a child of obj. + * + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR_OPTION_NOT_FOUND if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid + */ +int av_opt_set (void *obj, const char *name, const char *val, int search_flags); +int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags); +int av_opt_set_double(void *obj, const char *name, double val, int search_flags); +int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags); +int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags); +/** + * @} + */ + +/** + * @defgroup opt_get_funcs Option getting functions + * @{ + * Those functions get a value of the option with the given name from an object. + * + * @param[in] obj a struct whose first element is a pointer to an AVClass. + * @param[in] name name of the option to get. + * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be found in a child of obj. + * @param[out] out_val value of the option will be written here + * @return 0 on success, a negative error code otherwise + */ +/** + * @note the returned string will av_malloc()ed and must be av_free()ed by the caller + */ +int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val); +int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val); +int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val); +int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val); +/** + * @} + * @} + */ + +#endif /* AVUTIL_OPT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/parseutils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/parseutils.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,124 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PARSEUTILS_H +#define AVUTIL_PARSEUTILS_H + +#include + +#include "rational.h" + +/** + * @file + * misc parsing utilities + */ + +/** + * Parse str and put in width_ptr and height_ptr the detected values. + * + * @param[in,out] width_ptr pointer to the variable which will contain the detected + * width value + * @param[in,out] height_ptr pointer to the variable which will contain the detected + * height value + * @param[in] str the string to parse: it has to be a string in the format + * width x height or a valid video size abbreviation. + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str); + +/** + * Parse str and store the detected values in *rate. + * + * @param[in,out] rate pointer to the AVRational which will contain the detected + * frame rate + * @param[in] str the string to parse: it has to be a string in the format + * rate_num / rate_den, a float number or a valid video rate abbreviation + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_rate(AVRational *rate, const char *str); + +/** + * Put the RGBA values that correspond to color_string in rgba_color. + * + * @param color_string a string specifying a color. It can be the name of + * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, + * possibly followed by "@" and a string representing the alpha + * component. + * The alpha component may be a string composed by "0x" followed by an + * hexadecimal number or a decimal number between 0.0 and 1.0, which + * represents the opacity value (0x00/0.0 means completely transparent, + * 0xff/1.0 completely opaque). + * If the alpha component is not specified then 0xff is assumed. + * The string "random" will result in a random color. + * @param slen length of the initial part of color_string containing the + * color. It can be set to -1 if color_string is a null terminated string + * containing nothing else than the color. + * @return >= 0 in case of success, a negative value in case of + * failure (for example if color_string cannot be parsed). + */ +int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, + void *log_ctx); + +/** + * Parse timestr and return in *time a corresponding number of + * microseconds. + * + * @param timeval puts here the number of microseconds corresponding + * to the string in timestr. If the string represents a duration, it + * is the number of microseconds contained in the time interval. If + * the string is a date, is the number of microseconds since 1st of + * January, 1970 up to the time of the parsed date. If timestr cannot + * be successfully parsed, set *time to INT64_MIN. + + * @param timestr a string representing a date or a duration. + * - If a date the syntax is: + * @code + * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z] + * now + * @endcode + * If the value is "now" it takes the current time. + * Time is local time unless Z is appended, in which case it is + * interpreted as UTC. + * If the year-month-day part is not specified it takes the current + * year-month-day. + * - If a duration the syntax is: + * @code + * [-]HH[:MM[:SS[.m...]]] + * [-]S+[.m...] + * @endcode + * @param duration flag which tells how to interpret timestr, if not + * zero timestr is interpreted as a duration, otherwise as a date + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_parse_time(int64_t *timeval, const char *timestr, int duration); + +/** + * Attempt to find a specific tag in a URL. + * + * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. + * Return 1 if found. + */ +int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); + +/** + * Convert the decomposed UTC time in tm to a time_t value. + */ +time_t av_timegm(struct tm *tm); + +#endif /* AVUTIL_PARSEUTILS_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/pixdesc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/pixdesc.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,206 @@ +/* + * pixel format descriptor + * Copyright (c) 2009 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PIXDESC_H +#define AVUTIL_PIXDESC_H + +#include +#include "pixfmt.h" + +typedef struct AVComponentDescriptor{ + uint16_t plane :2; ///< which of the 4 planes contains the component + + /** + * Number of elements between 2 horizontally consecutive pixels minus 1. + * Elements are bits for bitstream formats, bytes otherwise. + */ + uint16_t step_minus1 :3; + + /** + * Number of elements before the component of the first pixel plus 1. + * Elements are bits for bitstream formats, bytes otherwise. + */ + uint16_t offset_plus1 :3; + uint16_t shift :3; ///< number of least significant bits that must be shifted away to get the value + uint16_t depth_minus1 :4; ///< number of bits in the component minus 1 +}AVComponentDescriptor; + +/** + * Descriptor that unambiguously describes how the bits of a pixel are + * stored in the up to 4 data planes of an image. It also stores the + * subsampling factors and number of components. + * + * @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV + * and all the YUV variants) AVPixFmtDescriptor just stores how values + * are stored not what these values represent. + */ +typedef struct AVPixFmtDescriptor{ + const char *name; + uint8_t nb_components; ///< The number of components each pixel has, (1-4) + + /** + * Amount to shift the luma width right to find the chroma width. + * For YV12 this is 1 for example. + * chroma_width = -((-luma_width) >> log2_chroma_w) + * The note above is needed to ensure rounding up. + * This value only refers to the chroma components. + */ + uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w) + + /** + * Amount to shift the luma height right to find the chroma height. + * For YV12 this is 1 for example. + * chroma_height= -((-luma_height) >> log2_chroma_h) + * The note above is needed to ensure rounding up. + * This value only refers to the chroma components. + */ + uint8_t log2_chroma_h; + uint8_t flags; + + /** + * Parameters that describe how pixels are packed. If the format + * has chroma components, they must be stored in comp[1] and + * comp[2]. + */ + AVComponentDescriptor comp[4]; +}AVPixFmtDescriptor; + +#define PIX_FMT_BE 1 ///< Pixel format is big-endian. +#define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette. +#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end. +#define PIX_FMT_HWACCEL 8 ///< Pixel format is an HW accelerated format. +#define PIX_FMT_PLANAR 16 ///< At least one pixel component is not in the first data plane +#define PIX_FMT_RGB 32 ///< The pixel format contains RGB-like data (as opposed to YUV/grayscale) +/** + * The pixel format is "pseudo-paletted". This means that Libav treats it as + * paletted internally, but the palette is generated by the decoder and is not + * stored in the file. + */ +#define PIX_FMT_PSEUDOPAL 64 + +#if FF_API_PIX_FMT_DESC +/** + * The array of all the pixel format descriptors. + */ +extern const AVPixFmtDescriptor av_pix_fmt_descriptors[]; +#endif + +/** + * Read a line from an image, and write the values of the + * pixel format component c to dst. + * + * @param data the array containing the pointers to the planes of the image + * @param linesize the array containing the linesizes of the image + * @param desc the pixel format descriptor for the image + * @param x the horizontal coordinate of the first pixel to read + * @param y the vertical coordinate of the first pixel to read + * @param w the width of the line to read, that is the number of + * values to write to dst + * @param read_pal_component if not zero and the format is a paletted + * format writes the values corresponding to the palette + * component c in data[1] to dst, rather than the palette indexes in + * data[0]. The behavior is undefined if the format is not paletted. + */ +void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component); + +/** + * Write the values from src to the pixel format component c of an + * image line. + * + * @param src array containing the values to write + * @param data the array containing the pointers to the planes of the + * image to write into. It is supposed to be zeroed. + * @param linesize the array containing the linesizes of the image + * @param desc the pixel format descriptor for the image + * @param x the horizontal coordinate of the first pixel to write + * @param y the vertical coordinate of the first pixel to write + * @param w the width of the line to write, that is the number of + * values to write to the image line + */ +void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w); + +/** + * Return the pixel format corresponding to name. + * + * If there is no pixel format with name name, then looks for a + * pixel format with the name corresponding to the native endian + * format of name. + * For example in a little-endian system, first looks for "gray16", + * then for "gray16le". + * + * Finally if no pixel format has been found, returns PIX_FMT_NONE. + */ +enum AVPixelFormat av_get_pix_fmt(const char *name); + +/** + * Return the short name for a pixel format, NULL in case pix_fmt is + * unknown. + * + * @see av_get_pix_fmt(), av_get_pix_fmt_string() + */ +const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt); + +/** + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * + * @param buf the buffer where to write the string + * @param buf_size the size of buf + * @param pix_fmt the number of the pixel format to print the + * corresponding info string, or a negative value to print the + * corresponding header. + */ +char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt); + +/** + * Return the number of bits per pixel used by the pixel format + * described by pixdesc. + * + * The returned number of bits refers to the number of bits actually + * used for storing the pixel information, that is padding bits are + * not counted. + */ +int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc); + +/** + * @return a pixel format descriptor for provided pixel format or NULL if + * this pixel format is unknown. + */ +const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt); + +/** + * Iterate over all pixel format descriptors known to libavutil. + * + * @param prev previous descriptor. NULL to get the first descriptor. + * + * @return next descriptor or NULL after the last descriptor + */ +const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev); + +/** + * @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc + * is not a valid pointer to a pixel format descriptor. + */ +enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc); + +#endif /* AVUTIL_PIXDESC_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/pixfmt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/pixfmt.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,240 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PIXFMT_H +#define AVUTIL_PIXFMT_H + +/** + * @file + * pixel format definitions + * + */ + +#include "libavutil/avconfig.h" +#include "libavutil/version.h" + +/** + * Pixel format. + * + * @note + * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA + * color is put together as: + * (A << 24) | (R << 16) | (G << 8) | B + * This is stored as BGRA on little-endian CPU architectures and ARGB on + * big-endian CPUs. + * + * @par + * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized + * image data is stored in AVFrame.data[0]. The palette is transported in + * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is + * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is + * also endian-specific). Note also that the individual RGB palette + * components stored in AVFrame.data[1] should be in the range 0..255. + * This is important as many custom PAL8 video codecs that were designed + * to run on the IBM VGA graphics adapter use 6-bit palette components. + * + * @par + * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like + * for pal8. This palette is filled in automatically by the function + * allocating the picture. + * + * @note + * make sure that all newly added big endian formats have pix_fmt&1==1 + * and that all newly added little endian formats have pix_fmt&1==0 + * this allows simpler detection of big vs little endian. + */ +enum AVPixelFormat { + AV_PIX_FMT_NONE = -1, + AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + AV_PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr + AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... + AV_PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... + AV_PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + AV_PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) + AV_PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) + AV_PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) + AV_PIX_FMT_GRAY8, ///< Y , 8bpp + AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb + AV_PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette + AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range + AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range + AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range + AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing + AV_PIX_FMT_XVMC_MPEG2_IDCT, + AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 + AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 + AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) + AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) + AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) + AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) + AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) + AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swapped + + AV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... + AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... + AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... + AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... + + AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian + AV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian + AV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) + AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range + AV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) + AV_PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + AV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian + + AV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian + AV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian + AV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 + AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 + + AV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian + AV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian + AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 + AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 + + AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers + AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers + AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + + AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer + + AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 + AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 + AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 + AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 + AV_PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha + AV_PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian + AV_PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian + AV_PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + AV_PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_VDA_VLD, ///< hardware decoding through VDA + AV_PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp + AV_PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian + AV_PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian + AV_PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian + AV_PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian + AV_PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian + AV_PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian + AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples) + AV_PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples) + AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + +#if FF_API_PIX_FMT +#include "old_pix_fmts.h" +#endif +}; + +#if AV_HAVE_BIGENDIAN +# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##be +#else +# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##le +#endif + +#define AV_PIX_FMT_RGB32 AV_PIX_FMT_NE(ARGB, BGRA) +#define AV_PIX_FMT_RGB32_1 AV_PIX_FMT_NE(RGBA, ABGR) +#define AV_PIX_FMT_BGR32 AV_PIX_FMT_NE(ABGR, RGBA) +#define AV_PIX_FMT_BGR32_1 AV_PIX_FMT_NE(BGRA, ARGB) + +#define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE) +#define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE) +#define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE) +#define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE) +#define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE) +#define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE) +#define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE) +#define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE) +#define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE) + +#define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE) +#define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE) +#define AV_PIX_FMT_YUV444P9 AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE) +#define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE) +#define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE) +#define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE) +#define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE) +#define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) +#define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) + +#define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) +#define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) +#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE) + +#if FF_API_PIX_FMT +#define PixelFormat AVPixelFormat + +#define PIX_FMT_NE(be, le) AV_PIX_FMT_NE(be, le) + +#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32 +#define PIX_FMT_RGB32_1 AV_PIX_FMT_RGB32_1 +#define PIX_FMT_BGR32 AV_PIX_FMT_BGR32 +#define PIX_FMT_BGR32_1 AV_PIX_FMT_BGR32_1 + +#define PIX_FMT_GRAY16 AV_PIX_FMT_GRAY16 +#define PIX_FMT_RGB48 AV_PIX_FMT_RGB48 +#define PIX_FMT_RGB565 AV_PIX_FMT_RGB565 +#define PIX_FMT_RGB555 AV_PIX_FMT_RGB555 +#define PIX_FMT_RGB444 AV_PIX_FMT_RGB444 +#define PIX_FMT_BGR48 AV_PIX_FMT_BGR48 +#define PIX_FMT_BGR565 AV_PIX_FMT_BGR565 +#define PIX_FMT_BGR555 AV_PIX_FMT_BGR555 +#define PIX_FMT_BGR444 AV_PIX_FMT_BGR444 + +#define PIX_FMT_YUV420P9 AV_PIX_FMT_YUV420P9 +#define PIX_FMT_YUV422P9 AV_PIX_FMT_YUV422P9 +#define PIX_FMT_YUV444P9 AV_PIX_FMT_YUV444P9 +#define PIX_FMT_YUV420P10 AV_PIX_FMT_YUV420P10 +#define PIX_FMT_YUV422P10 AV_PIX_FMT_YUV422P10 +#define PIX_FMT_YUV444P10 AV_PIX_FMT_YUV444P10 +#define PIX_FMT_YUV420P16 AV_PIX_FMT_YUV420P16 +#define PIX_FMT_YUV422P16 AV_PIX_FMT_YUV422P16 +#define PIX_FMT_YUV444P16 AV_PIX_FMT_YUV444P16 + +#define PIX_FMT_GBRP9 AV_PIX_FMT_GBRP9 +#define PIX_FMT_GBRP10 AV_PIX_FMT_GBRP10 +#define PIX_FMT_GBRP16 AV_PIX_FMT_GBRP16 +#endif + +#endif /* AVUTIL_PIXFMT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/random_seed.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/random_seed.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009 Baptiste Coudurier + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_RANDOM_SEED_H +#define AVUTIL_RANDOM_SEED_H + +#include +/** + * @addtogroup lavu_crypto + * @{ + */ + +/** + * Get random data. + * + * This function can be called repeatedly to generate more random bits + * as needed. It is generally quite slow, and usually used to seed a + * PRNG. As it uses /dev/urandom and /dev/random, the quality of the + * returned random data depends on the platform. + */ +uint32_t av_get_random_seed(void); + +/** + * @} + */ + +#endif /* AVUTIL_RANDOM_SEED_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/rational.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/rational.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,155 @@ +/* + * rational numbers + * Copyright (c) 2003 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * rational numbers + * @author Michael Niedermayer + */ + +#ifndef AVUTIL_RATIONAL_H +#define AVUTIL_RATIONAL_H + +#include +#include +#include "attributes.h" + +/** + * @addtogroup lavu_math + * @{ + */ + +/** + * rational number numerator/denominator + */ +typedef struct AVRational{ + int num; ///< numerator + int den; ///< denominator +} AVRational; + +/** + * Compare two rationals. + * @param a first rational + * @param b second rational + * @return 0 if a==b, 1 if a>b, -1 if a>63)|1; + else if(b.den && a.den) return 0; + else if(a.num && b.num) return (a.num>>31) - (b.num>>31); + else return INT_MIN; +} + +/** + * Convert rational to double. + * @param a rational to convert + * @return (double) a + */ +static inline double av_q2d(AVRational a){ + return a.num / (double) a.den; +} + +/** + * Reduce a fraction. + * This is useful for framerate calculations. + * @param dst_num destination numerator + * @param dst_den destination denominator + * @param num source numerator + * @param den source denominator + * @param max the maximum allowed for dst_num & dst_den + * @return 1 if exact, 0 otherwise + */ +int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max); + +/** + * Multiply two rationals. + * @param b first rational + * @param c second rational + * @return b*c + */ +AVRational av_mul_q(AVRational b, AVRational c) av_const; + +/** + * Divide one rational by another. + * @param b first rational + * @param c second rational + * @return b/c + */ +AVRational av_div_q(AVRational b, AVRational c) av_const; + +/** + * Add two rationals. + * @param b first rational + * @param c second rational + * @return b+c + */ +AVRational av_add_q(AVRational b, AVRational c) av_const; + +/** + * Subtract one rational from another. + * @param b first rational + * @param c second rational + * @return b-c + */ +AVRational av_sub_q(AVRational b, AVRational c) av_const; + +/** + * Invert a rational. + * @param q value + * @return 1 / q + */ +static av_always_inline AVRational av_inv_q(AVRational q) +{ + AVRational r = { q.den, q.num }; + return r; +} + +/** + * Convert a double precision floating point number to a rational. + * inf is expressed as {1,0} or {-1,0} depending on the sign. + * + * @param d double to convert + * @param max the maximum allowed numerator and denominator + * @return (AVRational) d + */ +AVRational av_d2q(double d, int max) av_const; + +/** + * @return 1 if q1 is nearer to q than q2, -1 if q2 is nearer + * than q1, 0 if they have the same distance. + */ +int av_nearer_q(AVRational q, AVRational q1, AVRational q2); + +/** + * Find the nearest value in q_list to q. + * @param q_list an array of rationals terminated by {0, 0} + * @return the index of the nearest value found in the array + */ +int av_find_nearest_q_idx(AVRational q, const AVRational* q_list); + +/** + * @} + */ + +#endif /* AVUTIL_RATIONAL_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/samplefmt.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/samplefmt.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,228 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_SAMPLEFMT_H +#define AVUTIL_SAMPLEFMT_H + +#include + +#include "avutil.h" +#include "attributes.h" + +/** + * Audio Sample Formats + * + * @par + * The data described by the sample format is always in native-endian order. + * Sample values can be expressed by native C types, hence the lack of a signed + * 24-bit sample format even though it is a common raw audio data format. + * + * @par + * The floating-point formats are based on full volume being in the range + * [-1.0, 1.0]. Any values outside this range are beyond full volume level. + * + * @par + * The data layout as used in av_samples_fill_arrays() and elsewhere in Libav + * (such as AVFrame in libavcodec) is as follows: + * + * For planar sample formats, each audio channel is in a separate data plane, + * and linesize is the buffer size, in bytes, for a single plane. All data + * planes must be the same size. For packed sample formats, only the first data + * plane is used, and samples for each channel are interleaved. In this case, + * linesize is the buffer size, in bytes, for the 1 plane. + */ +enum AVSampleFormat { + AV_SAMPLE_FMT_NONE = -1, + AV_SAMPLE_FMT_U8, ///< unsigned 8 bits + AV_SAMPLE_FMT_S16, ///< signed 16 bits + AV_SAMPLE_FMT_S32, ///< signed 32 bits + AV_SAMPLE_FMT_FLT, ///< float + AV_SAMPLE_FMT_DBL, ///< double + + AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar + AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar + AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar + AV_SAMPLE_FMT_FLTP, ///< float, planar + AV_SAMPLE_FMT_DBLP, ///< double, planar + + AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically +}; + +/** + * Return the name of sample_fmt, or NULL if sample_fmt is not + * recognized. + */ +const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); + +/** + * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE + * on error. + */ +enum AVSampleFormat av_get_sample_fmt(const char *name); + +/** + * Get the packed alternative form of the given sample format. + * + * If the passed sample_fmt is already in packed format, the format returned is + * the same as the input. + * + * @return the packed alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt); + +/** + * Get the planar alternative form of the given sample format. + * + * If the passed sample_fmt is already in planar format, the format returned is + * the same as the input. + * + * @return the planar alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); + +/** + * Generate a string corresponding to the sample format with + * sample_fmt, or a header if sample_fmt is negative. + * + * @param buf the buffer where to write the string + * @param buf_size the size of buf + * @param sample_fmt the number of the sample format to print the + * corresponding info string, or a negative value to print the + * corresponding header. + * @return the pointer to the filled buffer or NULL if sample_fmt is + * unknown or in case of other errors + */ +char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); + +#if FF_API_GET_BITS_PER_SAMPLE_FMT +/** + * @deprecated Use av_get_bytes_per_sample() instead. + */ +attribute_deprecated +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); +#endif + +/** + * Return number of bytes per sample. + * + * @param sample_fmt the sample format + * @return number of bytes per sample or zero if unknown for the given + * sample format + */ +int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); + +/** + * Check if the sample format is planar. + * + * @param sample_fmt the sample format to inspect + * @return 1 if the sample format is planar, 0 if it is interleaved + */ +int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt); + +/** + * Get the required buffer size for the given audio parameters. + * + * @param[out] linesize calculated linesize, may be NULL + * @param nb_channels the number of channels + * @param nb_samples the number of samples in a single channel + * @param sample_fmt the sample format + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return required buffer size, or negative error code on failure + */ +int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, + enum AVSampleFormat sample_fmt, int align); + +/** + * Fill channel data pointers and linesize for samples with sample + * format sample_fmt. + * + * The pointers array is filled with the pointers to the samples data: + * for planar, set the start point of each channel's data within the buffer, + * for packed, set the start point of the entire buffer only. + * + * The linesize array is filled with the aligned size of each channel's data + * buffer for planar layout, or the aligned size of the buffer for all channels + * for packed layout. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param[out] audio_data array to be filled with the pointer for each channel + * @param[out] linesize calculated linesize, may be NULL + * @param buf the pointer to a buffer containing the samples + * @param nb_channels the number of channels + * @param nb_samples the number of samples in a single channel + * @param sample_fmt the sample format + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return 0 on success or a negative error code on failure + */ +int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, + const uint8_t *buf, + int nb_channels, int nb_samples, + enum AVSampleFormat sample_fmt, int align); + +/** + * Allocate a samples buffer for nb_samples samples, and fill data pointers and + * linesize accordingly. + * The allocated samples buffer can be freed by using av_freep(&audio_data[0]) + * Allocated data will be initialized to silence. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param[out] audio_data array to be filled with the pointer for each channel + * @param[out] linesize aligned size for audio buffer(s), may be NULL + * @param nb_channels number of audio channels + * @param nb_samples number of samples per channel + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return 0 on success or a negative error code on failure + * @see av_samples_fill_arrays() + */ +int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, + int nb_samples, enum AVSampleFormat sample_fmt, int align); + +/** + * Copy samples from src to dst. + * + * @param dst destination array of pointers to data planes + * @param src source array of pointers to data planes + * @param dst_offset offset in samples at which the data will be written to dst + * @param src_offset offset in samples at which the data will be read from src + * @param nb_samples number of samples to be copied + * @param nb_channels number of audio channels + * @param sample_fmt audio sample format + */ +int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, + int src_offset, int nb_samples, int nb_channels, + enum AVSampleFormat sample_fmt); + +/** + * Fill an audio buffer with silence. + * + * @param audio_data array of pointers to data planes + * @param offset offset in samples at which to start filling + * @param nb_samples number of samples to fill + * @param nb_channels number of audio channels + * @param sample_fmt audio sample format + */ +int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, + int nb_channels, enum AVSampleFormat sample_fmt); + +#endif /* AVUTIL_SAMPLEFMT_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/sha.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/sha.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_SHA_H +#define AVUTIL_SHA_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_sha SHA + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_sha_size; +#endif + +struct AVSHA; + +/** + * Allocate an AVSHA context. + */ +struct AVSHA *av_sha_alloc(void); + +/** + * Initialize SHA-1 or SHA-2 hashing. + * + * @param context pointer to the function context (of size av_sha_size) + * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits) + * @return zero if initialization succeeded, -1 otherwise + */ +int av_sha_init(struct AVSHA* context, int bits); + +/** + * Update hash value. + * + * @param context hash function context + * @param data input data to update hash with + * @param len input data length + */ +void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len); + +/** + * Finish hashing and output digest value. + * + * @param context hash function context + * @param digest buffer where output digest value is stored + */ +void av_sha_final(struct AVSHA* context, uint8_t *digest); + +/** + * @} + */ + +#endif /* AVUTIL_SHA_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/time.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/time.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,39 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TIME_H +#define AVUTIL_TIME_H + +#include + +/** + * Get the current time in microseconds. + */ +int64_t av_gettime(void); + +/** + * Sleep for a period of time. Although the duration is expressed in + * microseconds, the actual delay may be rounded to the precision of the + * system timer. + * + * @param usec Number of microseconds to sleep. + * @return zero on success or (negative) error code. + */ +int av_usleep(unsigned usec); + +#endif /* AVUTIL_TIME_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/version.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,93 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_VERSION_H +#define AVUTIL_VERSION_H + +#include "avutil.h" + +/** + * @file + * @ingroup lavu + * Libavutil version macros + */ + +/** + * @defgroup lavu_ver Version and Build diagnostics + * + * Macros and function useful to check at compiletime and at runtime + * which version of libavutil is in use. + * + * @{ + */ + +#define LIBAVUTIL_VERSION_MAJOR 51 +#define LIBAVUTIL_VERSION_MINOR 45 +#define LIBAVUTIL_VERSION_MICRO 0 + +#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT + +#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) + +/** + * @} + * + * @defgroup depr_guards Deprecation guards + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + * + * @{ + */ + +#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT +#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_FIND_OPT +#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_AV_FIFO_PEEK +#define FF_API_AV_FIFO_PEEK (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_OLD_AVOPTIONS +#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_PIX_FMT +#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_CONTEXT_SIZE +#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_PIX_FMT_DESC +#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 52) +#endif +#ifndef FF_API_AV_REVERSE +#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 52) +#endif + +/** + * @} + */ + +#endif /* AVUTIL_VERSION_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/libavutil/xtea.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/libavutil/xtea.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,61 @@ +/* + * A 32-bit implementation of the XTEA algorithm + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_XTEA_H +#define AVUTIL_XTEA_H + +#include + +/** + * @defgroup lavu_xtea XTEA + * @ingroup lavu_crypto + * @{ + */ + +typedef struct AVXTEA { + uint32_t key[16]; +} AVXTEA; + +/** + * Initialize an AVXTEA context. + * + * @param ctx an AVXTEA context + * @param key a key of 16 bytes used for encryption/decryption + */ +void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVXTEA context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_xtea_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_XTEA_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/png.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/png.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,2674 @@ + +/* png.h - header file for PNG reference library + * + * libpng version 1.5.13 - September 27, 2012 + * Copyright (c) 1998-2012 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license (See LICENSE, below) + * + * Authors and maintainers: + * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat + * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger + * libpng versions 0.97, January 1998, through 1.5.13 - September 27, 2012: Glenn + * See also "Contributing Authors", below. + * + * Note about libpng version numbers: + * + * Due to various miscommunications, unforeseen code incompatibilities + * and occasional factors outside the authors' control, version numbering + * on the library has not always been consistent and straightforward. + * The following table summarizes matters since version 0.89c, which was + * the first widely used release: + * + * source png.h png.h shared-lib + * version string int version + * ------- ------ ----- ---------- + * 0.89c "1.0 beta 3" 0.89 89 1.0.89 + * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] + * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] + * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] + * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] + * 0.97c 0.97 97 2.0.97 + * 0.98 0.98 98 2.0.98 + * 0.99 0.99 98 2.0.99 + * 0.99a-m 0.99 99 2.0.99 + * 1.00 1.00 100 2.1.0 [100 should be 10000] + * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] + * 1.0.1 png.h string is 10001 2.1.0 + * 1.0.1a-e identical to the 10002 from here on, the shared library + * 1.0.2 source version) 10002 is 2.V where V is the source code + * 1.0.2a-b 10003 version, except as noted. + * 1.0.3 10003 + * 1.0.3a-d 10004 + * 1.0.4 10004 + * 1.0.4a-f 10005 + * 1.0.5 (+ 2 patches) 10005 + * 1.0.5a-d 10006 + * 1.0.5e-r 10100 (not source compatible) + * 1.0.5s-v 10006 (not binary compatible) + * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) + * 1.0.6d-f 10007 (still binary incompatible) + * 1.0.6g 10007 + * 1.0.6h 10007 10.6h (testing xy.z so-numbering) + * 1.0.6i 10007 10.6i + * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) + * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) + * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) + * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) + * 1.0.7 1 10007 (still compatible) + * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 + * 1.0.8rc1 1 10008 2.1.0.8rc1 + * 1.0.8 1 10008 2.1.0.8 + * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 + * 1.0.9rc1 1 10009 2.1.0.9rc1 + * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 + * 1.0.9rc2 1 10009 2.1.0.9rc2 + * 1.0.9 1 10009 2.1.0.9 + * 1.0.10beta1 1 10010 2.1.0.10beta1 + * 1.0.10rc1 1 10010 2.1.0.10rc1 + * 1.0.10 1 10010 2.1.0.10 + * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 + * 1.0.11rc1 1 10011 2.1.0.11rc1 + * 1.0.11 1 10011 2.1.0.11 + * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 + * 1.0.12rc1 2 10012 2.1.0.12rc1 + * 1.0.12 2 10012 2.1.0.12 + * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) + * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 + * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 + * 1.2.0rc1 3 10200 3.1.2.0rc1 + * 1.2.0 3 10200 3.1.2.0 + * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 + * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 + * 1.2.1 3 10201 3.1.2.1 + * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 + * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 + * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 + * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 + * 1.0.13 10 10013 10.so.0.1.0.13 + * 1.2.2 12 10202 12.so.0.1.2.2 + * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 + * 1.2.3 12 10203 12.so.0.1.2.3 + * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 + * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 + * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 + * 1.0.14 10 10014 10.so.0.1.0.14 + * 1.2.4 13 10204 12.so.0.1.2.4 + * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 + * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 + * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 + * 1.0.15 10 10015 10.so.0.1.0.15 + * 1.2.5 13 10205 12.so.0.1.2.5 + * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 + * 1.0.16 10 10016 10.so.0.1.0.16 + * 1.2.6 13 10206 12.so.0.1.2.6 + * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 + * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 + * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 + * 1.0.17 10 10017 12.so.0.1.0.17 + * 1.2.7 13 10207 12.so.0.1.2.7 + * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 + * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 + * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 + * 1.0.18 10 10018 12.so.0.1.0.18 + * 1.2.8 13 10208 12.so.0.1.2.8 + * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 + * 1.2.9beta4-11 13 10209 12.so.0.9[.0] + * 1.2.9rc1 13 10209 12.so.0.9[.0] + * 1.2.9 13 10209 12.so.0.9[.0] + * 1.2.10beta1-7 13 10210 12.so.0.10[.0] + * 1.2.10rc1-2 13 10210 12.so.0.10[.0] + * 1.2.10 13 10210 12.so.0.10[.0] + * 1.4.0beta1-5 14 10400 14.so.0.0[.0] + * 1.2.11beta1-4 13 10211 12.so.0.11[.0] + * 1.4.0beta7-8 14 10400 14.so.0.0[.0] + * 1.2.11 13 10211 12.so.0.11[.0] + * 1.2.12 13 10212 12.so.0.12[.0] + * 1.4.0beta9-14 14 10400 14.so.0.0[.0] + * 1.2.13 13 10213 12.so.0.13[.0] + * 1.4.0beta15-36 14 10400 14.so.0.0[.0] + * 1.4.0beta37-87 14 10400 14.so.14.0[.0] + * 1.4.0rc01 14 10400 14.so.14.0[.0] + * 1.4.0beta88-109 14 10400 14.so.14.0[.0] + * 1.4.0rc02-08 14 10400 14.so.14.0[.0] + * 1.4.0 14 10400 14.so.14.0[.0] + * 1.4.1beta01-03 14 10401 14.so.14.1[.0] + * 1.4.1rc01 14 10401 14.so.14.1[.0] + * 1.4.1beta04-12 14 10401 14.so.14.1[.0] + * 1.4.1 14 10401 14.so.14.1[.0] + * 1.4.2 14 10402 14.so.14.2[.0] + * 1.4.3 14 10403 14.so.14.3[.0] + * 1.4.4 14 10404 14.so.14.4[.0] + * 1.5.0beta01-58 15 10500 15.so.15.0[.0] + * 1.5.0rc01-07 15 10500 15.so.15.0[.0] + * 1.5.0 15 10500 15.so.15.0[.0] + * 1.5.1beta01-11 15 10501 15.so.15.1[.0] + * 1.5.1rc01-02 15 10501 15.so.15.1[.0] + * 1.5.1 15 10501 15.so.15.1[.0] + * 1.5.2beta01-03 15 10502 15.so.15.2[.0] + * 1.5.2rc01-03 15 10502 15.so.15.2[.0] + * 1.5.2 15 10502 15.so.15.2[.0] + * 1.5.3beta01-10 15 10503 15.so.15.3[.0] + * 1.5.3rc01-02 15 10503 15.so.15.3[.0] + * 1.5.3beta11 15 10503 15.so.15.3[.0] + * 1.5.3 [omitted] + * 1.5.4beta01-08 15 10504 15.so.15.4[.0] + * 1.5.4rc01 15 10504 15.so.15.4[.0] + * 1.5.4 15 10504 15.so.15.4[.0] + * 1.5.5beta01-08 15 10505 15.so.15.5[.0] + * 1.5.5rc01 15 10505 15.so.15.5[.0] + * 1.5.5 15 10505 15.so.15.5[.0] + * 1.5.6beta01-07 15 10506 15.so.15.6[.0] + * 1.5.6rc01-03 15 10506 15.so.15.6[.0] + * 1.5.6 15 10506 15.so.15.6[.0] + * 1.5.7beta01-05 15 10507 15.so.15.7[.0] + * 1.5.7rc01-03 15 10507 15.so.15.7[.0] + * 1.5.7 15 10507 15.so.15.7[.0] + * 1.5.8beta01 15 10508 15.so.15.8[.0] + * 1.5.8rc01 15 10508 15.so.15.8[.0] + * 1.5.8 15 10508 15.so.15.8[.0] + * 1.5.9beta01-02 15 10509 15.so.15.9[.0] + * 1.5.9rc01 15 10509 15.so.15.9[.0] + * 1.5.9 15 10509 15.so.15.9[.0] + * 1.5.10beta01-05 15 10510 15.so.15.10[.0] + * 1.5.10 15 10510 15.so.15.10[.0] + * 1.5.11beta01 15 10511 15.so.15.11[.0] + * 1.5.11rc01-05 15 10511 15.so.15.11[.0] + * 1.5.11 15 10511 15.so.15.11[.0] + * 1.5.12 15 10512 15.so.15.12[.0] + * 1.5.13beta01-02 15 10513 15.so.15.13[.0] + * 1.5.13rc01 15 10513 15.so.15.13[.0] + * 1.5.13 15 10513 15.so.15.13[.0] + * + * Henceforth the source version will match the shared-library major + * and minor numbers; the shared-library major version number will be + * used for changes in backward compatibility, as it is intended. The + * PNG_LIBPNG_VER macro, which is not used within libpng but is available + * for applications, is an unsigned integer of the form xyyzz corresponding + * to the source version x.y.z (leading zeros in y and z). Beta versions + * were given the previous public release number plus a letter, until + * version 1.0.6j; from then on they were given the upcoming public + * release number plus "betaNN" or "rcNN". + * + * Binary incompatibility exists only when applications make direct access + * to the info_ptr or png_ptr members through png.h, and the compiled + * application is loaded with a different version of the library. + * + * DLLNUM will change each time there are forward or backward changes + * in binary compatibility (e.g., when a new feature is added). + * + * See libpng-manual.txt or libpng.3 for more information. The PNG + * specification is available as a W3C Recommendation and as an ISO + * Specification, +# endif + + /* Need the time information for converting tIME chunks, it + * defines struct tm: + */ +# ifdef PNG_CONVERT_tIME_SUPPORTED + /* "time.h" functions are not supported on all operating systems */ +# include +# endif +# endif + +/* Machine specific configuration. */ +# include "pngconf.h" +#endif + +/* + * Added at libpng-1.2.8 + * + * Ref MSDN: Private as priority over Special + * VS_FF_PRIVATEBUILD File *was not* built using standard release + * procedures. If this value is given, the StringFileInfo block must + * contain a PrivateBuild string. + * + * VS_FF_SPECIALBUILD File *was* built by the original company using + * standard release procedures but is a variation of the standard + * file of the same version number. If this value is given, the + * StringFileInfo block must contain a SpecialBuild string. + */ + +#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ +# define PNG_LIBPNG_BUILD_TYPE \ + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) +#else +# ifdef PNG_LIBPNG_SPECIALBUILD +# define PNG_LIBPNG_BUILD_TYPE \ + (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) +# else +# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) +# endif +#endif + +#ifndef PNG_VERSION_INFO_ONLY + +/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Version information for C files, stored in png.c. This had better match + * the version above. + */ +#define png_libpng_ver png_get_header_ver(NULL) + +/* This file is arranged in several sections: + * + * 1. Any configuration options that can be specified by for the application + * code when it is built. (Build time configuration is in pnglibconf.h) + * 2. Type definitions (base types are defined in pngconf.h), structure + * definitions. + * 3. Exported library functions. + * + * The library source code has additional files (principally pngpriv.h) that + * allow configuration of the library. + */ +/* Section 1: run time configuration + * See pnglibconf.h for build time configuration + * + * Run time configuration allows the application to choose between + * implementations of certain arithmetic APIs. The default is set + * at build time and recorded in pnglibconf.h, but it is safe to + * override these (and only these) settings. Note that this won't + * change what the library does, only application code, and the + * settings can (and probably should) be made on a per-file basis + * by setting the #defines before including png.h + * + * Use macros to read integers from PNG data or use the exported + * functions? + * PNG_USE_READ_MACROS: use the macros (see below) Note that + * the macros evaluate their argument multiple times. + * PNG_NO_USE_READ_MACROS: call the relevant library function. + * + * Use the alternative algorithm for compositing alpha samples that + * does not use division? + * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' + * algorithm. + * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. + * + * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is + * false? + * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error + * APIs to png_warning. + * Otherwise the calls are mapped to png_error. + */ + +/* Section 2: type definitions, including structures and compile time + * constants. + * See pngconf.h for base types that vary by machine/system + */ + +/* This triggers a compiler error in png.c, if png.c and png.h + * do not agree upon the version number. + */ +typedef char* png_libpng_version_1_5_13; + +/* Three color definitions. The order of the red, green, and blue, (and the + * exact size) is not important, although the size of the fields need to + * be png_byte or png_uint_16 (as defined below). + */ +typedef struct png_color_struct +{ + png_byte red; + png_byte green; + png_byte blue; +} png_color; +typedef png_color FAR * png_colorp; +typedef PNG_CONST png_color FAR * png_const_colorp; +typedef png_color FAR * FAR * png_colorpp; + +typedef struct png_color_16_struct +{ + png_byte index; /* used for palette files */ + png_uint_16 red; /* for use in red green blue files */ + png_uint_16 green; + png_uint_16 blue; + png_uint_16 gray; /* for use in grayscale files */ +} png_color_16; +typedef png_color_16 FAR * png_color_16p; +typedef PNG_CONST png_color_16 FAR * png_const_color_16p; +typedef png_color_16 FAR * FAR * png_color_16pp; + +typedef struct png_color_8_struct +{ + png_byte red; /* for use in red green blue files */ + png_byte green; + png_byte blue; + png_byte gray; /* for use in grayscale files */ + png_byte alpha; /* for alpha channel files */ +} png_color_8; +typedef png_color_8 FAR * png_color_8p; +typedef PNG_CONST png_color_8 FAR * png_const_color_8p; +typedef png_color_8 FAR * FAR * png_color_8pp; + +/* + * The following two structures are used for the in-core representation + * of sPLT chunks. + */ +typedef struct png_sPLT_entry_struct +{ + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + png_uint_16 alpha; + png_uint_16 frequency; +} png_sPLT_entry; +typedef png_sPLT_entry FAR * png_sPLT_entryp; +typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp; +typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; + +/* When the depth of the sPLT palette is 8 bits, the color and alpha samples + * occupy the LSB of their respective members, and the MSB of each member + * is zero-filled. The frequency member always occupies the full 16 bits. + */ + +typedef struct png_sPLT_struct +{ + png_charp name; /* palette name */ + png_byte depth; /* depth of palette samples */ + png_sPLT_entryp entries; /* palette entries */ + png_int_32 nentries; /* number of palette entries */ +} png_sPLT_t; +typedef png_sPLT_t FAR * png_sPLT_tp; +typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp; +typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; + +#ifdef PNG_TEXT_SUPPORTED +/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, + * and whether that contents is compressed or not. The "key" field + * points to a regular zero-terminated C string. The "text" fields can be a + * regular C string, an empty string, or a NULL pointer. + * However, the structure returned by png_get_text() will always contain + * the "text" field as a regular zero-terminated C string (possibly + * empty), never a NULL pointer, so it can be safely used in printf() and + * other string-handling functions. Note that the "itxt_length", "lang", and + * "lang_key" members of the structure only exist when the library is built + * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by + * default without iTXt support. Also note that when iTXt *is* supported, + * the "lang" and "lang_key" fields contain NULL pointers when the + * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or + * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the + * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" + * which is always 0 or 1, or its "compression method" which is always 0. + */ +typedef struct png_text_struct +{ + int compression; /* compression value: + -1: tEXt, none + 0: zTXt, deflate + 1: iTXt, none + 2: iTXt, deflate */ + png_charp key; /* keyword, 1-79 character description of "text" */ + png_charp text; /* comment, may be an empty string (ie "") + or a NULL pointer */ + png_size_t text_length; /* length of the text string */ + png_size_t itxt_length; /* length of the itxt string */ + png_charp lang; /* language code, 0-79 characters + or a NULL pointer */ + png_charp lang_key; /* keyword translated UTF-8 string, 0 or more + chars or a NULL pointer */ +} png_text; +typedef png_text FAR * png_textp; +typedef PNG_CONST png_text FAR * png_const_textp; +typedef png_text FAR * FAR * png_textpp; +#endif + +/* Supported compression types for text in PNG files (tEXt, and zTXt). + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ +#define PNG_TEXT_COMPRESSION_NONE_WR -3 +#define PNG_TEXT_COMPRESSION_zTXt_WR -2 +#define PNG_TEXT_COMPRESSION_NONE -1 +#define PNG_TEXT_COMPRESSION_zTXt 0 +#define PNG_ITXT_COMPRESSION_NONE 1 +#define PNG_ITXT_COMPRESSION_zTXt 2 +#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ + +/* png_time is a way to hold the time in an machine independent way. + * Two conversions are provided, both from time_t and struct tm. There + * is no portable way to convert to either of these structures, as far + * as I know. If you know of a portable way, send it to me. As a side + * note - PNG has always been Year 2000 compliant! + */ +typedef struct png_time_struct +{ + png_uint_16 year; /* full year, as in, 1995 */ + png_byte month; /* month of year, 1 - 12 */ + png_byte day; /* day of month, 1 - 31 */ + png_byte hour; /* hour of day, 0 - 23 */ + png_byte minute; /* minute of hour, 0 - 59 */ + png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ +} png_time; +typedef png_time FAR * png_timep; +typedef PNG_CONST png_time FAR * png_const_timep; +typedef png_time FAR * FAR * png_timepp; + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) +/* png_unknown_chunk is a structure to hold queued chunks for which there is + * no specific support. The idea is that we can use this to queue + * up private chunks for output even though the library doesn't actually + * know about their semantics. + */ +typedef struct png_unknown_chunk_t +{ + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* libpng-using applications should NOT directly modify this byte. */ + png_byte location; /* mode of operation at read time */ +} + + +png_unknown_chunk; +typedef png_unknown_chunk FAR * png_unknown_chunkp; +typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp; +typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; +#endif + +/* Values for the unknown chunk location byte */ + +#define PNG_HAVE_IHDR 0x01 +#define PNG_HAVE_PLTE 0x02 +#define PNG_AFTER_IDAT 0x08 + +/* The complete definition of png_info has, as of libpng-1.5.0, + * been moved into a separate header file that is not accessible to + * applications. Read libpng-manual.txt or libpng.3 for more info. + */ +typedef struct png_info_def png_info; +typedef png_info FAR * png_infop; +typedef PNG_CONST png_info FAR * png_const_infop; +typedef png_info FAR * FAR * png_infopp; + +/* Maximum positive integer used in PNG is (2^31)-1 */ +#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) +#define PNG_UINT_32_MAX ((png_uint_32)(-1)) +#define PNG_SIZE_MAX ((png_size_t)(-1)) + +/* These are constants for fixed point values encoded in the + * PNG specification manner (x100000) + */ +#define PNG_FP_1 100000 +#define PNG_FP_HALF 50000 +#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) +#define PNG_FP_MIN (-PNG_FP_MAX) + +/* These describe the color_type field in png_info. */ +/* color type masks */ +#define PNG_COLOR_MASK_PALETTE 1 +#define PNG_COLOR_MASK_COLOR 2 +#define PNG_COLOR_MASK_ALPHA 4 + +/* color types. Note that not all combinations are legal */ +#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) +#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) +#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) +#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) +/* aliases */ +#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA +#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA + +/* This is for compression type. PNG 1.0-1.2 only define the single type. */ +#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ +#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE + +/* This is for filter type. PNG 1.0-1.2 only define the single type. */ +#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ +#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ +#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE + +/* These are for the interlacing type. These values should NOT be changed. */ +#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ +#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ +#define PNG_INTERLACE_LAST 2 /* Not a valid value */ + +/* These are for the oFFs chunk. These values should NOT be changed. */ +#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ +#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ +#define PNG_OFFSET_LAST 2 /* Not a valid value */ + +/* These are for the pCAL chunk. These values should NOT be changed. */ +#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ +#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ +#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ +#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ +#define PNG_EQUATION_LAST 4 /* Not a valid value */ + +/* These are for the sCAL chunk. These values should NOT be changed. */ +#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ +#define PNG_SCALE_METER 1 /* meters per pixel */ +#define PNG_SCALE_RADIAN 2 /* radians per pixel */ +#define PNG_SCALE_LAST 3 /* Not a valid value */ + +/* These are for the pHYs chunk. These values should NOT be changed. */ +#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ +#define PNG_RESOLUTION_METER 1 /* pixels/meter */ +#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ + +/* These are for the sRGB chunk. These values should NOT be changed. */ +#define PNG_sRGB_INTENT_PERCEPTUAL 0 +#define PNG_sRGB_INTENT_RELATIVE 1 +#define PNG_sRGB_INTENT_SATURATION 2 +#define PNG_sRGB_INTENT_ABSOLUTE 3 +#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ + +/* This is for text chunks */ +#define PNG_KEYWORD_MAX_LENGTH 79 + +/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ +#define PNG_MAX_PALETTE_LENGTH 256 + +/* These determine if an ancillary chunk's data has been successfully read + * from the PNG header, or if the application has filled in the corresponding + * data in the info_struct to be written into the output file. The values + * of the PNG_INFO_ defines should NOT be changed. + */ +#define PNG_INFO_gAMA 0x0001 +#define PNG_INFO_sBIT 0x0002 +#define PNG_INFO_cHRM 0x0004 +#define PNG_INFO_PLTE 0x0008 +#define PNG_INFO_tRNS 0x0010 +#define PNG_INFO_bKGD 0x0020 +#define PNG_INFO_hIST 0x0040 +#define PNG_INFO_pHYs 0x0080 +#define PNG_INFO_oFFs 0x0100 +#define PNG_INFO_tIME 0x0200 +#define PNG_INFO_pCAL 0x0400 +#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ + +/* This is used for the transformation routines, as some of them + * change these values for the row. It also should enable using + * the routines for other purposes. + */ +typedef struct png_row_info_struct +{ + png_uint_32 width; /* width of row */ + png_size_t rowbytes; /* number of bytes in row */ + png_byte color_type; /* color type of row */ + png_byte bit_depth; /* bit depth of row */ + png_byte channels; /* number of channels (1, 2, 3, or 4) */ + png_byte pixel_depth; /* bits per pixel (depth * channels) */ +} png_row_info; + +typedef png_row_info FAR * png_row_infop; +typedef png_row_info FAR * FAR * png_row_infopp; + +/* The complete definition of png_struct has, as of libpng-1.5.0, + * been moved into a separate header file that is not accessible to + * applications. Read libpng-manual.txt or libpng.3 for more info. + */ +typedef struct png_struct_def png_struct; +typedef PNG_CONST png_struct FAR * png_const_structp; +typedef png_struct FAR * png_structp; + +/* These are the function types for the I/O functions and for the functions + * that allow the user to override the default I/O functions with his or her + * own. The png_error_ptr type should match that of user-supplied warning + * and error functions, while the png_rw_ptr type should match that of the + * user read/write data functions. Note that the 'write' function must not + * modify the buffer it is passed. The 'read' function, on the other hand, is + * expected to return the read data in the buffer. + */ +typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); +typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); +typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); +typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, + int)); +typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, + int)); + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); +typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); + +/* The following callback receives png_uint_32 row_number, int pass for the + * png_bytep data of the row. When transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, + png_uint_32, int)); +#endif + +#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) +typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, + png_bytep)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, + png_unknown_chunkp)); +#endif +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED +typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); +#endif + +#ifdef PNG_SETJMP_SUPPORTED +/* This must match the function definition in , and the application + * must include this before png.h to obtain the definition of jmp_buf. The + * function is required to be PNG_NORETURN, but this is not checked. If the + * function does return the application will crash via an abort() or similar + * system level call. + * + * If you get a warning here while building the library you may need to make + * changes to ensure that pnglibconf.h records the calling convention used by + * your compiler. This may be very difficult - try using a different compiler + * to build the library! + */ +PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); +#endif + +/* Transform masks for the high-level interface */ +#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ +#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ +#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ +#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ +#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ +#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ +#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ +#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ +#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ +#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ +#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ +#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ +/* Added to libpng-1.4.0 */ +#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ +/* Added to libpng-1.5.4 */ +#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ +#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ + +/* Flags for MNG supported features */ +#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 +#define PNG_FLAG_MNG_FILTER_64 0x04 +#define PNG_ALL_MNG_FEATURES 0x05 + +/* NOTE: prior to 1.5 these functions had no 'API' style declaration, + * this allowed the zlib default functions to be used on Windows + * platforms. In 1.5 the zlib default malloc (which just calls malloc and + * ignores the first argument) should be completely compatible with the + * following. + */ +typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, + png_alloc_size_t)); +typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); + +typedef png_struct FAR * FAR * png_structpp; + +/* Section 3: exported functions + * Here are the function definitions most commonly used. This is not + * the place to find out how to use libpng. See libpng-manual.txt for the + * full explanation, see example.c for the summary. This just provides + * a simple one line description of the use of each function. + * + * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in + * pngconf.h and in the *.dfn files in the scripts directory. + * + * PNG_EXPORT(ordinal, type, name, (args)); + * + * ordinal: ordinal that is used while building + * *.def files. The ordinal value is only + * relevant when preprocessing png.h with + * the *.dfn files for building symbol table + * entries, and are removed by pngconf.h. + * type: return type of the function + * name: function name + * args: function arguments, with types + * + * When we wish to append attributes to a function prototype we use + * the PNG_EXPORTA() macro instead. + * + * PNG_EXPORTA(ordinal, type, name, (args), attributes); + * + * ordinal, type, name, and args: same as in PNG_EXPORT(). + * attributes: function attributes + */ + +/* Returns the version number of the library */ +PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); + +/* Tell lib we have already handled the first magic bytes. + * Handling more than 8 bytes from the beginning of the file is an error. + */ +PNG_EXPORT(2, void, png_set_sig_bytes, (png_structp png_ptr, int num_bytes)); + +/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a + * PNG file. Returns zero if the supplied bytes match the 8-byte PNG + * signature, and non-zero otherwise. Having num_to_check == 0 or + * start > 7 will always fail (ie return non-zero). + */ +PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, + png_size_t num_to_check)); + +/* Simple signature checking function. This is the same as calling + * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). + */ +#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) + +/* Allocate and initialize png_ptr struct for reading, and any other memory. */ +PNG_EXPORTA(4, png_structp, png_create_read_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warn_fn), + PNG_ALLOCATED); + +/* Allocate and initialize png_ptr struct for writing, and any other memory */ +PNG_EXPORTA(5, png_structp, png_create_write_struct, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn), + PNG_ALLOCATED); + +PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, + (png_const_structp png_ptr)); + +PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr, + png_size_t size)); + +/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp + * match up. + */ +#ifdef PNG_SETJMP_SUPPORTED +/* This function returns the jmp_buf built in to *png_ptr. It must be + * supplied with an appropriate 'longjmp' function to use on that jmp_buf + * unless the default error function is overridden in which case NULL is + * acceptable. The size of the jmp_buf is checked against the actual size + * allocated by the library - the call will return NULL on a mismatch + * indicating an ABI mismatch. + */ +PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structp png_ptr, + png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); +# define png_jmpbuf(png_ptr) \ + (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf))) +#else +# define png_jmpbuf(png_ptr) \ + (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) +#endif +/* This function should be used by libpng applications in place of + * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it + * will use it; otherwise it will call PNG_ABORT(). This function was + * added in libpng-1.5.0. + */ +PNG_EXPORTA(9, void, png_longjmp, (png_structp png_ptr, int val), + PNG_NORETURN); + +#ifdef PNG_READ_SUPPORTED +/* Reset the compression stream */ +PNG_EXPORT(10, int, png_reset_zstream, (png_structp png_ptr)); +#endif + +/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ +#ifdef PNG_USER_MEM_SUPPORTED +PNG_EXPORTA(11, png_structp, png_create_read_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); +PNG_EXPORTA(12, png_structp, png_create_write_struct_2, + (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warn_fn, + png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), + PNG_ALLOCATED); +#endif + +/* Write the PNG file signature. */ +PNG_EXPORT(13, void, png_write_sig, (png_structp png_ptr)); + +/* Write a PNG chunk - size, type, (optional) data, CRC. */ +PNG_EXPORT(14, void, png_write_chunk, (png_structp png_ptr, png_const_bytep + chunk_name, png_const_bytep data, png_size_t length)); + +/* Write the start of a PNG chunk - length and chunk name. */ +PNG_EXPORT(15, void, png_write_chunk_start, (png_structp png_ptr, + png_const_bytep chunk_name, png_uint_32 length)); + +/* Write the data of a PNG chunk started with png_write_chunk_start(). */ +PNG_EXPORT(16, void, png_write_chunk_data, (png_structp png_ptr, + png_const_bytep data, png_size_t length)); + +/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ +PNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr)); + +/* Allocate and initialize the info structure */ +PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr), + PNG_ALLOCATED); + +PNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr, + png_size_t png_info_struct_size)); + +/* Writes all the PNG information before the image. */ +PNG_EXPORT(20, void, png_write_info_before_PLTE, + (png_structp png_ptr, png_infop info_ptr)); +PNG_EXPORT(21, void, png_write_info, + (png_structp png_ptr, png_infop info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the information before the actual image data. */ +PNG_EXPORT(22, void, png_read_info, + (png_structp png_ptr, png_infop info_ptr)); +#endif + +#ifdef PNG_TIME_RFC1123_SUPPORTED +PNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123, + (png_structp png_ptr, + png_const_timep ptime)); +#endif + +#ifdef PNG_CONVERT_tIME_SUPPORTED +/* Convert from a struct tm to png_time */ +PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, + PNG_CONST struct tm FAR * ttime)); + +/* Convert from time_t to png_time. Uses gmtime() */ +PNG_EXPORT(25, void, png_convert_from_time_t, + (png_timep ptime, time_t ttime)); +#endif /* PNG_CONVERT_tIME_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ +PNG_EXPORT(26, void, png_set_expand, (png_structp png_ptr)); +PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structp png_ptr)); +PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr)); +PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion + * of a tRNS chunk if present. + */ +PNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) +/* Use blue, green, red order for pixels. */ +PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* Expand the grayscale to 24-bit RGB if necessary. */ +PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* Reduce RGB to grayscale. */ +#define PNG_ERROR_ACTION_NONE 1 +#define PNG_ERROR_ACTION_WARN 2 +#define PNG_ERROR_ACTION_ERROR 3 +#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ + +PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr, + int error_action, double red, double green)) +PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr, + int error_action, png_fixed_point red, png_fixed_point green)) + +PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp + png_ptr)); +#endif + +#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED +PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, + png_colorp palette)); +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED +/* How the alpha channel is interpreted - this affects how the color channels of + * a PNG file are returned when an alpha channel, or tRNS chunk in a palette + * file, is present. + * + * This has no effect on the way pixels are written into a PNG output + * datastream. The color samples in a PNG datastream are never premultiplied + * with the alpha samples. + * + * The default is to return data according to the PNG specification: the alpha + * channel is a linear measure of the contribution of the pixel to the + * corresponding composited pixel. The gamma encoded color channels must be + * scaled according to the contribution and to do this it is necessary to undo + * the encoding, scale the color values, perform the composition and reencode + * the values. This is the 'PNG' mode. + * + * The alternative is to 'associate' the alpha with the color information by + * storing color channel values that have been scaled by the alpha. The + * advantage is that the color channels can be resampled (the image can be + * scaled) in this form. The disadvantage is that normal practice is to store + * linear, not (gamma) encoded, values and this requires 16-bit channels for + * still images rather than the 8-bit channels that are just about sufficient if + * gamma encoding is used. In addition all non-transparent pixel values, + * including completely opaque ones, must be gamma encoded to produce the final + * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the + * latter being the two common names for associated alpha color channels.) + * + * Since it is not necessary to perform arithmetic on opaque color values so + * long as they are not to be resampled and are in the final color space it is + * possible to optimize the handling of alpha by storing the opaque pixels in + * the PNG format (adjusted for the output color space) while storing partially + * opaque pixels in the standard, linear, format. The accuracy required for + * standard alpha composition is relatively low, because the pixels are + * isolated, therefore typically the accuracy loss in storing 8-bit linear + * values is acceptable. (This is not true if the alpha channel is used to + * simulate transparency over large areas - use 16 bits or the PNG mode in + * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is + * treated as opaque only if the alpha value is equal to the maximum value. + * + * The final choice is to gamma encode the alpha channel as well. This is + * broken because, in practice, no implementation that uses this choice + * correctly undoes the encoding before handling alpha composition. Use this + * choice only if other serious errors in the software or hardware you use + * mandate it; the typical serious error is for dark halos to appear around + * opaque areas of the composited PNG image because of arithmetic overflow. + * + * The API function png_set_alpha_mode specifies which of these choices to use + * with an enumerated 'mode' value and the gamma of the required output: + */ +#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ +#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ +#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ +#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ +#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ +#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ + +PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode, + double output_gamma)) +PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr, + int mode, png_fixed_point output_gamma)) +#endif + +#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) +/* The output_gamma value is a screen gamma in libpng terminology: it expresses + * how to decode the output values, not how they are encoded. The values used + * correspond to the normal numbers used to describe the overall gamma of a + * computer display system; for example 2.2 for an sRGB conformant system. The + * values are scaled by 100000 in the _fixed version of the API (so 220000 for + * sRGB.) + * + * The inverse of the value is always used to provide a default for the PNG file + * encoding if it has no gAMA chunk and if png_set_gamma() has not been called + * to override the PNG gamma information. + * + * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode + * opaque pixels however pixels with lower alpha values are not encoded, + * regardless of the output gamma setting. + * + * When the standard Porter Duff handling is requested with mode 1 the output + * encoding is set to be linear and the output_gamma value is only relevant + * as a default for input data that has no gamma information. The linear output + * encoding will be overridden if png_set_gamma() is called - the results may be + * highly unexpected! + * + * The following numbers are derived from the sRGB standard and the research + * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of + * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing + * correction required to take account of any differences in the color + * environment of the original scene and the intended display environment; the + * value expresses how to *decode* the image for display, not how the original + * data was *encoded*. + * + * sRGB provides a peg for the PNG standard by defining a viewing environment. + * sRGB itself, and earlier TV standards, actually use a more complex transform + * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is + * limited to simple power laws.) By saying that an image for direct display on + * an sRGB conformant system should be stored with a gAMA chunk value of 45455 + * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification + * makes it possible to derive values for other display systems and + * environments. + * + * The Mac value is deduced from the sRGB based on an assumption that the actual + * extra viewing correction used in early Mac display systems was implemented as + * a power 1.45 lookup table. + * + * Any system where a programmable lookup table is used or where the behavior of + * the final display device characteristics can be changed requires system + * specific code to obtain the current characteristic. However this can be + * difficult and most PNG gamma correction only requires an approximate value. + * + * By default, if png_set_alpha_mode() is not called, libpng assumes that all + * values are unencoded, linear, values and that the output device also has a + * linear characteristic. This is only very rarely correct - it is invariably + * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the + * default if you don't know what the right answer is! + * + * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS + * 10.6) which used a correction table to implement a somewhat lower gamma on an + * otherwise sRGB system. + * + * Both these values are reserved (not simple gamma values) in order to allow + * more precise correction internally in the future. + * + * NOTE: the following values can be passed to either the fixed or floating + * point APIs, but the floating point API will also accept floating point + * values. + */ +#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ +#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ +#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ +#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ +#endif + +/* The following are examples of calls to png_set_alpha_mode to achieve the + * required overall gamma correction and, where necessary, alpha + * premultiplication. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * This is the default libpng handling of the alpha channel - it is not + * pre-multiplied into the color components. In addition the call states + * that the output is for a sRGB system and causes all PNG files without gAMA + * chunks to be assumed to be encoded using sRGB. + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * In this case the output is assumed to be something like an sRGB conformant + * display preceeded by a power-law lookup table of power 1.45. This is how + * early Mac systems behaved. + * + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); + * This is the classic Jim Blinn approach and will work in academic + * environments where everything is done by the book. It has the shortcoming + * of assuming that input PNG data with no gamma information is linear - this + * is unlikely to be correct unless the PNG files where generated locally. + * Most of the time the output precision will be so low as to show + * significant banding in dark areas of the image. + * + * png_set_expand_16(pp); + * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); + * This is a somewhat more realistic Jim Blinn inspired approach. PNG files + * are assumed to have the sRGB encoding if not marked with a gamma value and + * the output is always 16 bits per component. This permits accurate scaling + * and processing of the data. If you know that your input PNG files were + * generated locally you might need to replace PNG_DEFAULT_sRGB with the + * correct value for your system. + * + * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); + * If you just need to composite the PNG image onto an existing background + * and if you control the code that does this you can use the optimization + * setting. In this case you just copy completely opaque pixels to the + * output. For pixels that are not completely transparent (you just skip + * those) you do the composition math using png_composite or png_composite_16 + * below then encode the resultant 8-bit or 16-bit values to match the output + * encoding. + * + * Other cases + * If neither the PNG nor the standard linear encoding work for you because + * of the software or hardware you use then you have a big problem. The PNG + * case will probably result in halos around the image. The linear encoding + * will probably result in a washed out, too bright, image (it's actually too + * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably + * substantially reduce the halos. Alternatively try: + * + * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); + * This option will also reduce the halos, but there will be slight dark + * halos round the opaque parts of the image where the background is light. + * In the OPTIMIZED mode the halos will be light halos where the background + * is dark. Take your pick - the halos are unavoidable unless you can get + * your hardware/software fixed! (The OPTIMIZED approach is slightly + * faster.) + * + * When the default gamma of PNG files doesn't match the output gamma. + * If you have PNG files with no gamma information png_set_alpha_mode allows + * you to provide a default gamma, but it also sets the ouput gamma to the + * matching value. If you know your PNG files have a gamma that doesn't + * match the output you can take advantage of the fact that + * png_set_alpha_mode always sets the output gamma but only sets the PNG + * default if it is not already set: + * + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); + * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); + * The first call sets both the default and the output gamma values, the + * second call overrides the output gamma without changing the default. This + * is easier than achieving the same effect with png_set_gamma. You must use + * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will + * fire if more than one call to png_set_alpha_mode and png_set_background is + * made in the same read operation, however multiple calls with PNG_ALPHA_PNG + * are ignored. + */ + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +PNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) +PNG_EXPORT(37, void, png_set_swap_alpha, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ + defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) +PNG_EXPORT(38, void, png_set_invert_alpha, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ +PNG_EXPORT(39, void, png_set_filler, (png_structp png_ptr, png_uint_32 filler, + int flags)); +/* The values of the PNG_FILLER_ defines should NOT be changed */ +# define PNG_FILLER_BEFORE 0 +# define PNG_FILLER_AFTER 1 +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +PNG_EXPORT(40, void, png_set_add_alpha, + (png_structp png_ptr, png_uint_32 filler, + int flags)); +#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ + +#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) +/* Swap bytes in 16-bit depth files. */ +PNG_EXPORT(41, void, png_set_swap, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ +PNG_EXPORT(42, void, png_set_packing, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ + defined(PNG_WRITE_PACKSWAP_SUPPORTED) +/* Swap packing order of pixels in bytes. */ +PNG_EXPORT(43, void, png_set_packswap, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) +/* Converts files to legal bit depths. */ +PNG_EXPORT(44, void, png_set_shift, (png_structp png_ptr, png_const_color_8p + true_bits)); +#endif + +#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ + defined(PNG_WRITE_INTERLACING_SUPPORTED) +/* Have the code handle the interlacing. Returns the number of passes. + * MUST be called before png_read_update_info or png_start_read_image, + * otherwise it will not have the desired effect. Note that it is still + * necessary to call png_read_row or png_read_rows png_get_image_height + * times for each pass. +*/ +PNG_EXPORT(45, int, png_set_interlace_handling, (png_structp png_ptr)); +#endif + +#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) +/* Invert monochrome files */ +PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* Handle alpha and tRNS by replacing with a background color. Prior to + * libpng-1.5.4 this API must not be called before the PNG file header has been + * read. Doing so will result in unexpected behavior and possible warnings or + * errors if the PNG file contains a bKGD chunk. + */ +PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, double background_gamma)) +PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr, + png_const_color_16p background_color, int background_gamma_code, + int need_expand, png_fixed_point background_gamma)) +#endif +#ifdef PNG_READ_BACKGROUND_SUPPORTED +# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 +# define PNG_BACKGROUND_GAMMA_SCREEN 1 +# define PNG_BACKGROUND_GAMMA_FILE 2 +# define PNG_BACKGROUND_GAMMA_UNIQUE 3 +#endif + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED +/* Scale a 16-bit depth file down to 8-bit, accurately. */ +PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED +#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ +/* Strip the second byte of information from a 16-bit depth file. */ +PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr)); +#endif + +#ifdef PNG_READ_QUANTIZE_SUPPORTED +/* Turn on quantizing, and reduce the palette to the number of colors + * available. + */ +PNG_EXPORT(49, void, png_set_quantize, + (png_structp png_ptr, png_colorp palette, + int num_palette, int maximum_colors, png_const_uint_16p histogram, + int full_quantize)); +#endif + +#ifdef PNG_READ_GAMMA_SUPPORTED +/* The threshold on gamma processing is configurable but hard-wired into the + * library. The following is the floating point variant. + */ +#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) + +/* Handle gamma correction. Screen_gamma=(display_exponent). + * NOTE: this API simply sets the screen and file gamma values. It will + * therefore override the value for gamma in a PNG file if it is called after + * the file header has been read - use with care - call before reading the PNG + * file for best results! + * + * These routines accept the same gamma values as png_set_alpha_mode (described + * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either + * API (floating point or fixed.) Notice, however, that the 'file_gamma' value + * is the inverse of a 'screen gamma' value. + */ +PNG_FP_EXPORT(50, void, png_set_gamma, + (png_structp png_ptr, double screen_gamma, + double override_file_gamma)) +PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr, + png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) +#endif + +#ifdef PNG_WRITE_FLUSH_SUPPORTED +/* Set how many lines between output flushes - 0 for no flushing */ +PNG_EXPORT(51, void, png_set_flush, (png_structp png_ptr, int nrows)); +/* Flush the current PNG output buffer */ +PNG_EXPORT(52, void, png_write_flush, (png_structp png_ptr)); +#endif + +/* Optional update palette with requested transformations */ +PNG_EXPORT(53, void, png_start_read_image, (png_structp png_ptr)); + +/* Optional call to update the users info structure */ +PNG_EXPORT(54, void, png_read_update_info, + (png_structp png_ptr, png_infop info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read one or more rows of image data. */ +PNG_EXPORT(55, void, png_read_rows, (png_structp png_ptr, png_bytepp row, + png_bytepp display_row, png_uint_32 num_rows)); +#endif + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read a row of data. */ +PNG_EXPORT(56, void, png_read_row, (png_structp png_ptr, png_bytep row, + png_bytep display_row)); +#endif + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the whole image into memory at once. */ +PNG_EXPORT(57, void, png_read_image, (png_structp png_ptr, png_bytepp image)); +#endif + +/* Write a row of image data */ +PNG_EXPORT(58, void, png_write_row, + (png_structp png_ptr, png_const_bytep row)); + +/* Write a few rows of image data: (*row) is not written; however, the type + * is declared as writeable to maintain compatibility with previous versions + * of libpng and to allow the 'display_row' array from read_rows to be passed + * unchanged to write_rows. + */ +PNG_EXPORT(59, void, png_write_rows, (png_structp png_ptr, png_bytepp row, + png_uint_32 num_rows)); + +/* Write the image data */ +PNG_EXPORT(60, void, png_write_image, + (png_structp png_ptr, png_bytepp image)); + +/* Write the end of the PNG file. */ +PNG_EXPORT(61, void, png_write_end, + (png_structp png_ptr, png_infop info_ptr)); + +#ifdef PNG_SEQUENTIAL_READ_SUPPORTED +/* Read the end of the PNG file. */ +PNG_EXPORT(62, void, png_read_end, (png_structp png_ptr, png_infop info_ptr)); +#endif + +/* Free any memory associated with the png_info_struct */ +PNG_EXPORT(63, void, png_destroy_info_struct, (png_structp png_ptr, + png_infopp info_ptr_ptr)); + +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); + +/* Free any memory associated with the png_struct and the png_info_structs */ +PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, + png_infopp info_ptr_ptr)); + +/* Set the libpng method of handling chunk CRC errors */ +PNG_EXPORT(66, void, png_set_crc_action, + (png_structp png_ptr, int crit_action, int ancil_action)); + +/* Values for png_set_crc_action() say how to handle CRC errors in + * ancillary and critical chunks, and whether to use the data contained + * therein. Note that it is impossible to "discard" data in a critical + * chunk. For versions prior to 0.90, the action was always error/quit, + * whereas in version 0.90 and later, the action for CRC errors in ancillary + * chunks is warn/discard. These values should NOT be changed. + * + * value action:critical action:ancillary + */ +#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ +#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ +#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ +#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ +#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ +#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ + +/* These functions give the user control over the scan-line filtering in + * libpng and the compression methods used by zlib. These functions are + * mainly useful for testing, as the defaults should work with most users. + * Those users who are tight on memory or want faster performance at the + * expense of compression can modify them. See the compression library + * header file (zlib.h) for an explination of the compression functions. + */ + +/* Set the filtering method(s) used by libpng. Currently, the only valid + * value for "method" is 0. + */ +PNG_EXPORT(67, void, png_set_filter, + (png_structp png_ptr, int method, int filters)); + +/* Flags for png_set_filter() to say which filters to use. The flags + * are chosen so that they don't conflict with real filter types + * below, in case they are supplied instead of the #defined constants. + * These values should NOT be changed. + */ +#define PNG_NO_FILTERS 0x00 +#define PNG_FILTER_NONE 0x08 +#define PNG_FILTER_SUB 0x10 +#define PNG_FILTER_UP 0x20 +#define PNG_FILTER_AVG 0x40 +#define PNG_FILTER_PAETH 0x80 +#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ + PNG_FILTER_AVG | PNG_FILTER_PAETH) + +/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. + * These defines should NOT be changed. + */ +#define PNG_FILTER_VALUE_NONE 0 +#define PNG_FILTER_VALUE_SUB 1 +#define PNG_FILTER_VALUE_UP 2 +#define PNG_FILTER_VALUE_AVG 3 +#define PNG_FILTER_VALUE_PAETH 4 +#define PNG_FILTER_VALUE_LAST 5 + +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ +/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ + * defines, either the default (minimum-sum-of-absolute-differences), or + * the experimental method (weighted-minimum-sum-of-absolute-differences). + * + * Weights are factors >= 1.0, indicating how important it is to keep the + * filter type consistent between rows. Larger numbers mean the current + * filter is that many times as likely to be the same as the "num_weights" + * previous filters. This is cumulative for each previous row with a weight. + * There needs to be "num_weights" values in "filter_weights", or it can be + * NULL if the weights aren't being specified. Weights have no influence on + * the selection of the first row filter. Well chosen weights can (in theory) + * improve the compression for a given image. + * + * Costs are factors >= 1.0 indicating the relative decoding costs of a + * filter type. Higher costs indicate more decoding expense, and are + * therefore less likely to be selected over a filter with lower computational + * costs. There needs to be a value in "filter_costs" for each valid filter + * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't + * setting the costs. Costs try to improve the speed of decompression without + * unduly increasing the compressed image size. + * + * A negative weight or cost indicates the default value is to be used, and + * values in the range [0.0, 1.0) indicate the value is to remain unchanged. + * The default values for both weights and costs are currently 1.0, but may + * change if good general weighting/cost heuristics can be found. If both + * the weights and costs are set to 1.0, this degenerates the WEIGHTED method + * to the UNWEIGHTED method, but with added encoding time/computation. + */ +PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr, + int heuristic_method, int num_weights, png_const_doublep filter_weights, + png_const_doublep filter_costs)) +PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, + (png_structp png_ptr, + int heuristic_method, int num_weights, png_const_fixed_point_p + filter_weights, png_const_fixed_point_p filter_costs)) +#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ + +/* Heuristic used for row filter selection. These defines should NOT be + * changed. + */ +#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ +#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ +#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ +#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ + +#ifdef PNG_WRITE_SUPPORTED +/* Set the library compression level. Currently, valid values range from + * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 + * (0 - no compression, 9 - "maximal" compression). Note that tests have + * shown that zlib compression levels 3-6 usually perform as well as level 9 + * for PNG images, and do considerably fewer caclulations. In the future, + * these values may not correspond directly to the zlib compression levels. + */ +PNG_EXPORT(69, void, png_set_compression_level, + (png_structp png_ptr, int level)); + +PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr, + int mem_level)); + +PNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr, + int strategy)); + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr, + int window_bits)); + +PNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr, + int method)); +#endif + +#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED +/* Also set zlib parameters for compressing non-IDAT chunks */ +PNG_EXPORT(222, void, png_set_text_compression_level, + (png_structp png_ptr, int level)); + +PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structp png_ptr, + int mem_level)); + +PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structp png_ptr, + int strategy)); + +/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a + * smaller value of window_bits if it can do so safely. + */ +PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structp + png_ptr, int window_bits)); + +PNG_EXPORT(226, void, png_set_text_compression_method, (png_structp png_ptr, + int method)); +#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ + +/* These next functions are called for input/output, memory, and error + * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, + * and call standard C I/O routines such as fread(), fwrite(), and + * fprintf(). These functions can be made to use other I/O routines + * at run time for those applications that need to handle I/O in a + * different manner by calling png_set_???_fn(). See libpng-manual.txt for + * more information. + */ + +#ifdef PNG_STDIO_SUPPORTED +/* Initialize the input/output for the PNG file to the default functions. */ +PNG_EXPORT(74, void, png_init_io, (png_structp png_ptr, png_FILE_p fp)); +#endif + +/* Replace the (error and abort), and warning functions with user + * supplied functions. If no messages are to be printed you must still + * write and use replacement functions. The replacement error_fn should + * still do a longjmp to the last setjmp location if you are using this + * method of error handling. If error_fn or warning_fn is NULL, the + * default function will be used. + */ + +PNG_EXPORT(75, void, png_set_error_fn, + (png_structp png_ptr, png_voidp error_ptr, + png_error_ptr error_fn, png_error_ptr warning_fn)); + +/* Return the user pointer associated with the error functions */ +PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr)); + +/* Replace the default data output functions with a user supplied one(s). + * If buffered output is not used, then output_flush_fn can be set to NULL. + * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time + * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. + */ +PNG_EXPORT(77, void, png_set_write_fn, (png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); + +/* Replace the default data input function with a user supplied one. */ +PNG_EXPORT(78, void, png_set_read_fn, (png_structp png_ptr, png_voidp io_ptr, + png_rw_ptr read_data_fn)); + +/* Return the user pointer associated with the I/O functions */ +PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_structp png_ptr)); + +PNG_EXPORT(80, void, png_set_read_status_fn, (png_structp png_ptr, + png_read_status_ptr read_row_fn)); + +PNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr, + png_write_status_ptr write_row_fn)); + +#ifdef PNG_USER_MEM_SUPPORTED +/* Replace the default memory allocation functions with user supplied one(s). */ +PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr, + png_malloc_ptr malloc_fn, png_free_ptr free_fn)); +/* Return the user pointer associated with the memory functions */ +PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr)); +#endif + +#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structp png_ptr, + png_user_transform_ptr read_user_transform_fn)); +#endif + +#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED +PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr, + png_user_transform_ptr write_user_transform_fn)); +#endif + +#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED +PNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr, + png_voidp user_transform_ptr, int user_transform_depth, + int user_transform_channels)); +/* Return the user pointer associated with the user transform functions */ +PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, + (png_const_structp png_ptr)); +#endif + +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED +/* Return information about the row currently being processed. Note that these + * APIs do not fail but will return unexpected results if called outside a user + * transform callback. Also note that when transforming an interlaced image the + * row number is the row number within the sub-image of the interlace pass, so + * the value will increase to the height of the sub-image (not the full image) + * then reset to 0 for the next pass. + * + * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to + * find the output pixel (x,y) given an interlaced sub-image pixel + * (row,col,pass). (See below for these macros.) + */ +PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp)); +PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp)); +#endif + +#ifdef PNG_USER_CHUNKS_SUPPORTED +PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr, + png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); +PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr)); +#endif + +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED +/* Sets the function callbacks for the push reader, and a pointer to a + * user-defined structure available to the callback functions. + */ +PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr, + png_voidp progressive_ptr, png_progressive_info_ptr info_fn, + png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); + +/* Returns the user pointer associated with the push read functions */ +PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr)); + +/* Function to be called when data becomes available */ +PNG_EXPORT(92, void, png_process_data, + (png_structp png_ptr, png_infop info_ptr, + png_bytep buffer, png_size_t buffer_size)); + +/* A function which may be called *only* within png_process_data to stop the + * processing of any more data. The function returns the number of bytes + * remaining, excluding any that libpng has cached internally. A subsequent + * call to png_process_data must supply these bytes again. If the argument + * 'save' is set to true the routine will first save all the pending data and + * will always return 0. + */ +PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save)); + +/* A function which may be called *only* outside (after) a call to + * png_process_data. It returns the number of bytes of data to skip in the + * input. Normally it will return 0, but if it returns a non-zero value the + * application must skip than number of bytes of input data and pass the + * following data to the next call to png_process_data. + */ +PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp)); + +#ifdef PNG_READ_INTERLACING_SUPPORTED +/* Function that combines rows. 'new_row' is a flag that should come from + * the callback and be non-NULL if anything needs to be done; the library + * stores its own version of the new data internally and ignores the passed + * in value. + */ +PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr, + png_bytep old_row, png_const_bytep new_row)); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ +#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ + +PNG_EXPORTA(94, png_voidp, png_malloc, + (png_structp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED); +/* Added at libpng version 1.4.0 */ +PNG_EXPORTA(95, png_voidp, png_calloc, + (png_structp png_ptr, png_alloc_size_t size), + PNG_ALLOCATED); + +/* Added at libpng version 1.2.4 */ +PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_structp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); + +/* Frees a pointer allocated by png_malloc() */ +PNG_EXPORT(97, void, png_free, (png_structp png_ptr, png_voidp ptr)); + +/* Free data that was allocated internally */ +PNG_EXPORT(98, void, png_free_data, + (png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); + +/* Reassign responsibility for freeing existing data, whether allocated + * by libpng or by the application */ +PNG_EXPORT(99, void, png_data_freer, + (png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)); + +/* Assignments for png_data_freer */ +#define PNG_DESTROY_WILL_FREE_DATA 1 +#define PNG_SET_WILL_FREE_DATA 1 +#define PNG_USER_WILL_FREE_DATA 2 +/* Flags for png_ptr->free_me and info_ptr->free_me */ +#define PNG_FREE_HIST 0x0008 +#define PNG_FREE_ICCP 0x0010 +#define PNG_FREE_SPLT 0x0020 +#define PNG_FREE_ROWS 0x0040 +#define PNG_FREE_PCAL 0x0080 +#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_UNKN 0x0200 +#define PNG_FREE_LIST 0x0400 +#define PNG_FREE_PLTE 0x1000 +#define PNG_FREE_TRNS 0x2000 +#define PNG_FREE_TEXT 0x4000 +#define PNG_FREE_ALL 0x7fff +#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ + +#ifdef PNG_USER_MEM_SUPPORTED +PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr, + png_alloc_size_t size), PNG_ALLOCATED); +PNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr)); +#endif + +#ifdef PNG_ERROR_TEXT_SUPPORTED +/* Fatal error in PNG image of libpng - can't continue */ +PNG_EXPORTA(102, void, png_error, + (png_structp png_ptr, png_const_charp error_message), + PNG_NORETURN); + +/* The same, but the chunk name is prepended to the error string. */ +PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr, + png_const_charp error_message), PNG_NORETURN); + +#else +/* Fatal error in PNG image of libpng - can't continue */ +PNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN); +#endif + +#ifdef PNG_WARNINGS_SUPPORTED +/* Non-fatal error in libpng. Can continue, but may have a problem. */ +PNG_EXPORT(105, void, png_warning, (png_structp png_ptr, + png_const_charp warning_message)); + +/* Non-fatal error in libpng, chunk name is prepended to message. */ +PNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr, + png_const_charp warning_message)); +#endif + +#ifdef PNG_BENIGN_ERRORS_SUPPORTED +/* Benign error in libpng. Can continue, but may have a problem. + * User can choose whether to handle as a fatal error or as a warning. */ +# undef png_benign_error +PNG_EXPORT(107, void, png_benign_error, (png_structp png_ptr, + png_const_charp warning_message)); + +/* Same, chunk name is prepended to message. */ +# undef png_chunk_benign_error +PNG_EXPORT(108, void, png_chunk_benign_error, (png_structp png_ptr, + png_const_charp warning_message)); + +PNG_EXPORT(109, void, png_set_benign_errors, + (png_structp png_ptr, int allowed)); +#else +# ifdef PNG_ALLOW_BENIGN_ERRORS +# define png_benign_error png_warning +# define png_chunk_benign_error png_chunk_warning +# else +# define png_benign_error png_error +# define png_chunk_benign_error png_chunk_error +# endif +#endif + +/* The png_set_ functions are for storing values in the png_info_struct. + * Similarly, the png_get_ calls are used to read values from the + * png_info_struct, either storing the parameters in the passed variables, or + * setting pointers into the png_info_struct where the data is stored. The + * png_get_ functions return a non-zero value if the data was available + * in info_ptr, or return zero and do not change any of the parameters if the + * data was not available. + * + * These functions should be used instead of directly accessing png_info + * to avoid problems with future changes in the size and internal layout of + * png_info_struct. + */ +/* Returns "flag" if chunk data is valid in info_ptr. */ +PNG_EXPORT(110, png_uint_32, png_get_valid, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_uint_32 flag)); + +/* Returns number of bytes needed to hold a transformed row. */ +PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +#ifdef PNG_INFO_IMAGE_SUPPORTED +/* Returns row_pointers, which is an array of pointers to scanlines that was + * returned from png_read_png(). + */ +PNG_EXPORT(112, png_bytepp, png_get_rows, + (png_const_structp png_ptr, png_const_infop info_ptr)); +/* Set row_pointers, which is an array of pointers to scanlines for use + * by png_write_png(). + */ +PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers)); +#endif + +/* Returns number of color channels in image. */ +PNG_EXPORT(114, png_byte, png_get_channels, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +#ifdef PNG_EASY_ACCESS_SUPPORTED +/* Returns image width in pixels. */ +PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image height in pixels. */ +PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image bit_depth. */ +PNG_EXPORT(117, png_byte, png_get_bit_depth, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +/* Returns image color_type. */ +PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image filter_type. */ +PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image interlace_type. */ +PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image compression_type. */ +PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr, + png_const_infop info_ptr)); + +/* Returns image resolution in pixels per meter, from pHYs chunk data. */ +PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, + (png_const_structp png_ptr, png_const_infop info_ptr)); +PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, + (png_const_structp png_ptr, png_const_infop info_ptr)); +PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +/* Returns pixel aspect ratio, computed from pHYs chunk data. */ +PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, + (png_const_structp png_ptr, png_const_infop info_ptr)) +PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, + (png_const_structp png_ptr, png_const_infop info_ptr)) + +/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ +PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, + (png_const_structp png_ptr, png_const_infop info_ptr)); +PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, + (png_const_structp png_ptr, png_const_infop info_ptr)); +PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, + (png_const_structp png_ptr, png_const_infop info_ptr)); +PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +#endif /* PNG_EASY_ACCESS_SUPPORTED */ + +/* Returns pointer to signature string read from PNG header */ +PNG_EXPORT(130, png_const_bytep, png_get_signature, + (png_const_structp png_ptr, png_infop info_ptr)); + +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(131, png_uint_32, png_get_bKGD, + (png_const_structp png_ptr, png_infop info_ptr, + png_color_16p *background)); +#endif + +#ifdef PNG_bKGD_SUPPORTED +PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr, + png_const_color_16p background)); +#endif + +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr, + png_const_infop info_ptr, double *white_x, double *white_y, double *red_x, + double *red_y, double *green_x, double *green_y, double *blue_x, + double *blue_y)) +PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr, + png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z, + double *green_X, double *green_Y, double *green_Z, double *blue_X, + double *blue_Y, double *blue_Z)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */ +PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, + (png_const_structp png_ptr, + png_const_infop info_ptr, png_fixed_point *int_white_x, + png_fixed_point *int_white_y, png_fixed_point *int_red_x, + png_fixed_point *int_red_y, png_fixed_point *int_green_x, + png_fixed_point *int_green_y, png_fixed_point *int_blue_x, + png_fixed_point *int_blue_y)) +#endif +PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, + (png_structp png_ptr, png_const_infop info_ptr, + png_fixed_point *int_red_X, png_fixed_point *int_red_Y, + png_fixed_point *int_red_Z, png_fixed_point *int_green_X, + png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, + png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, + png_fixed_point *int_blue_Z)) +#endif + +#ifdef PNG_cHRM_SUPPORTED +PNG_FP_EXPORT(135, void, png_set_cHRM, + (png_structp png_ptr, png_infop info_ptr, + double white_x, double white_y, double red_x, double red_y, double green_x, + double green_y, double blue_x, double blue_y)) +PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr, + png_infop info_ptr, double red_X, double red_Y, double red_Z, + double green_X, double green_Y, double green_Z, double blue_X, + double blue_Y, double blue_Z)) +PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_white_x, + png_fixed_point int_white_y, png_fixed_point int_red_x, + png_fixed_point int_red_y, png_fixed_point int_green_x, + png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)) +PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, + png_fixed_point int_red_Z, png_fixed_point int_green_X, + png_fixed_point int_green_Y, png_fixed_point int_green_Z, + png_fixed_point int_blue_X, png_fixed_point int_blue_Y, + png_fixed_point int_blue_Z)) +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, + (png_const_structp png_ptr, png_const_infop info_ptr, + double *file_gamma)) +PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_fixed_point *int_file_gamma)) +#endif + +#ifdef PNG_gAMA_SUPPORTED +PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr, + png_infop info_ptr, double file_gamma)) +PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr, + png_infop info_ptr, png_fixed_point int_file_gamma)) +#endif + +#ifdef PNG_hIST_SUPPORTED +PNG_EXPORT(141, png_uint_32, png_get_hIST, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_uint_16p *hist)); +#endif + +#ifdef PNG_hIST_SUPPORTED +PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr, + png_infop info_ptr, png_const_uint_16p hist)); +#endif + +PNG_EXPORT(143, png_uint_32, png_get_IHDR, + (png_structp png_ptr, png_infop info_ptr, + png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, + int *interlace_method, int *compression_method, int *filter_method)); + +PNG_EXPORT(144, void, png_set_IHDR, + (png_structp png_ptr, png_infop info_ptr, + png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, + int interlace_method, int compression_method, int filter_method)); + +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(145, png_uint_32, png_get_oFFs, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); +#endif + +#ifdef PNG_oFFs_SUPPORTED +PNG_EXPORT(146, void, png_set_oFFs, + (png_structp png_ptr, png_infop info_ptr, + png_int_32 offset_x, png_int_32 offset_y, int unit_type)); +#endif + +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(147, png_uint_32, png_get_pCAL, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, + int *nparams, + png_charp *units, png_charpp *params)); +#endif + +#ifdef PNG_pCAL_SUPPORTED +PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr, + png_infop info_ptr, + png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, + int nparams, png_const_charp units, png_charpp params)); +#endif + +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(149, png_uint_32, png_get_pHYs, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); +#endif + +#ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(150, void, png_set_pHYs, + (png_structp png_ptr, png_infop info_ptr, + png_uint_32 res_x, png_uint_32 res_y, int unit_type)); +#endif + +PNG_EXPORT(151, png_uint_32, png_get_PLTE, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_colorp *palette, int *num_palette)); + +PNG_EXPORT(152, void, png_set_PLTE, + (png_structp png_ptr, png_infop info_ptr, + png_const_colorp palette, int num_palette)); + +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(153, png_uint_32, png_get_sBIT, + (png_const_structp png_ptr, png_infop info_ptr, + png_color_8p *sig_bit)); +#endif + +#ifdef PNG_sBIT_SUPPORTED +PNG_EXPORT(154, void, png_set_sBIT, + (png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit)); +#endif + +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr, + png_const_infop info_ptr, int *file_srgb_intent)); +#endif + +#ifdef PNG_sRGB_SUPPORTED +PNG_EXPORT(156, void, png_set_sRGB, + (png_structp png_ptr, png_infop info_ptr, int srgb_intent)); +PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr, + png_infop info_ptr, int srgb_intent)); +#endif + +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(158, png_uint_32, png_get_iCCP, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_charpp name, int *compression_type, png_bytepp profile, + png_uint_32 *proflen)); +#endif + +#ifdef PNG_iCCP_SUPPORTED +PNG_EXPORT(159, void, png_set_iCCP, + (png_structp png_ptr, png_infop info_ptr, + png_const_charp name, int compression_type, png_const_bytep profile, + png_uint_32 proflen)); +#endif + +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(160, png_uint_32, png_get_sPLT, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_sPLT_tpp entries)); +#endif + +#ifdef PNG_sPLT_SUPPORTED +PNG_EXPORT(161, void, png_set_sPLT, + (png_structp png_ptr, png_infop info_ptr, + png_const_sPLT_tp entries, int nentries)); +#endif + +#ifdef PNG_TEXT_SUPPORTED +/* png_get_text also returns the number of text chunks in *num_text */ +PNG_EXPORT(162, png_uint_32, png_get_text, + (png_const_structp png_ptr, png_const_infop info_ptr, + png_textp *text_ptr, int *num_text)); +#endif + +/* Note while png_set_text() will accept a structure whose text, + * language, and translated keywords are NULL pointers, the structure + * returned by png_get_text will always contain regular + * zero-terminated C strings. They might be empty strings but + * they will never be NULL pointers. + */ + +#ifdef PNG_TEXT_SUPPORTED +PNG_EXPORT(163, void, png_set_text, + (png_structp png_ptr, png_infop info_ptr, + png_const_textp text_ptr, int num_text)); +#endif + +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(164, png_uint_32, png_get_tIME, + (png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)); +#endif + +#ifdef PNG_tIME_SUPPORTED +PNG_EXPORT(165, void, png_set_tIME, + (png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)); +#endif + +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(166, png_uint_32, png_get_tRNS, + (png_const_structp png_ptr, png_infop info_ptr, + png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); +#endif + +#ifdef PNG_tRNS_SUPPORTED +PNG_EXPORT(167, void, png_set_tRNS, + (png_structp png_ptr, png_infop info_ptr, + png_const_bytep trans_alpha, int num_trans, + png_const_color_16p trans_color)); +#endif + +#ifdef PNG_sCAL_SUPPORTED +PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, + (png_const_structp png_ptr, png_const_infop info_ptr, + int *unit, double *width, double *height)) +#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED +/* NOTE: this API is currently implemented using floating point arithmetic, + * consequently it can only be used on systems with floating point support. + * In any case the range of values supported by png_fixed_point is small and it + * is highly recommended that png_get_sCAL_s be used instead. + */ +PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, + (png_structp png_ptr, png_const_infop info_ptr, int *unit, + png_fixed_point *width, + png_fixed_point *height)) +#endif +PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, + (png_const_structp png_ptr, png_const_infop info_ptr, + int *unit, png_charpp swidth, png_charpp sheight)); + +PNG_FP_EXPORT(170, void, png_set_sCAL, + (png_structp png_ptr, png_infop info_ptr, + int unit, double width, double height)) +PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr, + png_infop info_ptr, int unit, png_fixed_point width, + png_fixed_point height)) +PNG_EXPORT(171, void, png_set_sCAL_s, + (png_structp png_ptr, png_infop info_ptr, + int unit, png_const_charp swidth, png_const_charp sheight)); +#endif /* PNG_sCAL_SUPPORTED */ + +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +/* Provide a list of chunks and how they are to be handled, if the built-in + handling or default unknown chunk handling is not desired. Any chunks not + listed will be handled in the default manner. The IHDR and IEND chunks + must not be listed. Because this turns off the default handling for chunks + that would otherwise be recognized the behavior of libpng transformations may + well become incorrect! + keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior + = 1: PNG_HANDLE_CHUNK_NEVER: do not keep + = 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy + = 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy +*/ +PNG_EXPORT(172, void, png_set_keep_unknown_chunks, + (png_structp png_ptr, int keep, + png_const_bytep chunk_list, int num_chunks)); + +/* The handling code is returned; the result is therefore true (non-zero) if + * special handling is required, false for the default handling. + */ +PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr, + png_const_bytep chunk_name)); +#endif +#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED +PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr, + png_infop info_ptr, png_const_unknown_chunkp unknowns, + int num_unknowns)); +PNG_EXPORT(175, void, png_set_unknown_chunk_location, + (png_structp png_ptr, png_infop info_ptr, int chunk, int location)); +PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr, + png_const_infop info_ptr, png_unknown_chunkpp entries)); +#endif + +/* Png_free_data() will turn off the "valid" flag for anything it frees. + * If you need to turn it off for a chunk that your application has freed, + * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); + */ +PNG_EXPORT(177, void, png_set_invalid, + (png_structp png_ptr, png_infop info_ptr, int mask)); + +#ifdef PNG_INFO_IMAGE_SUPPORTED +/* The "params" pointer is currently not used and is for future expansion. */ +PNG_EXPORT(178, void, png_read_png, (png_structp png_ptr, png_infop info_ptr, + int transforms, png_voidp params)); +PNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr, + int transforms, png_voidp params)); +#endif + +PNG_EXPORT(180, png_const_charp, png_get_copyright, + (png_const_structp png_ptr)); +PNG_EXPORT(181, png_const_charp, png_get_header_ver, + (png_const_structp png_ptr)); +PNG_EXPORT(182, png_const_charp, png_get_header_version, + (png_const_structp png_ptr)); +PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, + (png_const_structp png_ptr)); + +#ifdef PNG_MNG_FEATURES_SUPPORTED +PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr, + png_uint_32 mng_features_permitted)); +#endif + +/* For use in png_set_keep_unknown, added to version 1.2.6 */ +#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 +#define PNG_HANDLE_CHUNK_NEVER 1 +#define PNG_HANDLE_CHUNK_IF_SAFE 2 +#define PNG_HANDLE_CHUNK_ALWAYS 3 + +/* Strip the prepended error numbers ("#nnn ") from error and warning + * messages before passing them to the error or warning handler. + */ +#ifdef PNG_ERROR_NUMBERS_SUPPORTED +PNG_EXPORT(185, void, png_set_strip_error_numbers, + (png_structp png_ptr, + png_uint_32 strip_mode)); +#endif + +/* Added in libpng-1.2.6 */ +#ifdef PNG_SET_USER_LIMITS_SUPPORTED +PNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr, + png_uint_32 user_width_max, png_uint_32 user_height_max)); +PNG_EXPORT(187, png_uint_32, png_get_user_width_max, + (png_const_structp png_ptr)); +PNG_EXPORT(188, png_uint_32, png_get_user_height_max, + (png_const_structp png_ptr)); +/* Added in libpng-1.4.0 */ +PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr, + png_uint_32 user_chunk_cache_max)); +PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, + (png_const_structp png_ptr)); +/* Added in libpng-1.4.1 */ +PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr, + png_alloc_size_t user_chunk_cache_max)); +PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, + (png_const_structp png_ptr)); +#endif + +#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) +PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, + (png_const_structp png_ptr, png_const_infop info_ptr)); + +PNG_FP_EXPORT(196, float, png_get_x_offset_inches, + (png_const_structp png_ptr, png_const_infop info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, + (png_structp png_ptr, png_const_infop info_ptr)) +#endif + +PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr, + png_const_infop info_ptr)) +#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ +PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, + (png_structp png_ptr, png_const_infop info_ptr)) +#endif + +# ifdef PNG_pHYs_SUPPORTED +PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structp png_ptr, + png_const_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, + int *unit_type)); +# endif /* PNG_pHYs_SUPPORTED */ +#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ + +/* Added in libpng-1.4.0 */ +#ifdef PNG_IO_STATE_SUPPORTED +PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_structp png_ptr)); + +PNG_EXPORTA(200, png_const_bytep, png_get_io_chunk_name, + (png_structp png_ptr), PNG_DEPRECATED); +PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, + (png_const_structp png_ptr)); + +/* The flags returned by png_get_io_state() are the following: */ +# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ +# define PNG_IO_READING 0x0001 /* currently reading */ +# define PNG_IO_WRITING 0x0002 /* currently writing */ +# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ +# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ +# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ +# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ +# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ +# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ +#endif /* ?PNG_IO_STATE_SUPPORTED */ + +/* Interlace support. The following macros are always defined so that if + * libpng interlace handling is turned off the macros may be used to handle + * interlaced images within the application. + */ +#define PNG_INTERLACE_ADAM7_PASSES 7 + +/* Two macros to return the first row and first column of the original, + * full, image which appears in a given pass. 'pass' is in the range 0 + * to 6 and the result is in the range 0 to 7. + */ +#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) + +/* A macro to return the offset between pixels in the output row for a pair of + * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that + * follows. Note that ROW_OFFSET is the offset from one row to the next whereas + * COL_OFFSET is from one column to the next, within a row. + */ +#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) +#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) + +/* Two macros to help evaluate the number of rows or columns in each + * pass. This is expressed as a shift - effectively log2 of the number or + * rows or columns in each 8x8 tile of the original image. + */ +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) + +/* Hence two macros to determine the number of rows or columns in a given + * pass of an image given its height or width. In fact these macros may + * return non-zero even though the sub-image is empty, because the other + * dimension may be empty for a small image. + */ +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) + +/* For the reader row callbacks (both progressive and sequential) it is + * necessary to find the row in the output image given a row in an interlaced + * image, so two more macros: + */ +#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ + (((yIn)<>(((7-(off))-(pass))<<2)) & 0xF) | \ + ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) + +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED +/* With these routines we avoid an integer divide, which will be slower on + * most machines. However, it does take more operations than the corresponding + * divide method, so it may be slower on a few RISC systems. There are two + * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. + * + * Note that the rounding factors are NOT supposed to be the same! 128 and + * 32768 are correct for the NODIV code; 127 and 32767 are correct for the + * standard method. + * + * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] + */ + + /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ + +# define png_composite(composite, fg, alpha, bg) \ + { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ + * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 \ + - (png_uint_16)(alpha)) + 128); \ + (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } + +# define png_composite_16(composite, fg, alpha, bg) \ + { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ + * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(65535 \ + - (png_uint_32)(alpha)) + 32768); \ + (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } + +#else /* Standard method using integer division */ + +# define png_composite(composite, fg, alpha, bg) \ + (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + 127) / 255) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ + 32767) / 65535) +#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ + +#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); +PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); +PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); +#endif + +PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_structp png_ptr, + png_const_bytep buf)); +/* No png_get_int_16 -- may be added if there's a real need for it. */ + +/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); +#endif +#ifdef PNG_SAVE_INT_32_SUPPORTED +PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); +#endif + +/* Place a 16-bit number into a buffer in PNG byte order. + * The parameter is declared unsigned int, not png_uint_16, + * just to avoid potential problems on pre-ANSI C compilers. + */ +#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED +PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); +/* No png_save_int_16 -- may be added if there's a real need for it. */ +#endif + +#ifdef PNG_USE_READ_MACROS +/* Inline macros to do direct reads of bytes from the input buffer. + * The png_get_int_32() routine assumes we are using two's complement + * format for negative values, which is almost certainly true. + */ +# define png_get_uint_32(buf) \ + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) + + /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the + * function) incorrectly returned a value of type png_uint_32. + */ +# define png_get_uint_16(buf) \ + ((png_uint_16) \ + (((unsigned int)(*(buf)) << 8) + \ + ((unsigned int)(*((buf) + 1))))) + +# define png_get_int_32(buf) \ + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ + : (png_int_32)png_get_uint_32(buf))) +#endif + +#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ + defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) +PNG_EXPORT(234, void, png_set_check_for_invalid_index, (png_structp png_ptr, + int allowed)); +#endif + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and project + * defs + */ + +/* The last ordinal number (this is the *last* one already used; the next + * one to use is one more than this.) Maintainer, remember to add an entry to + * scripts/symbols.def as well. + */ +#ifdef PNG_EXPORT_LAST_ORDINAL + PNG_EXPORT_LAST_ORDINAL(234); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* PNG_VERSION_INFO_ONLY */ +/* Do not put anything past this line */ +#endif /* PNG_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/pngconf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/pngconf.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,598 @@ + +/* pngconf.h - machine configurable file for libpng + * + * libpng version 1.5.13 - September 27, 2012 + * + * Copyright (c) 1998-2012 Glenn Randers-Pehrson + * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) + * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + */ + +/* Any machine specific code is near the front of this file, so if you + * are configuring libpng for a machine, you may want to read the section + * starting here down to where it starts to typedef png_color, png_text, + * and png_info. + */ + +#ifndef PNGCONF_H +#define PNGCONF_H + +#ifndef PNG_BUILDING_SYMBOL_TABLE +/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C + * definition file for machine specific limits, this may impact the + * correctness of the definitions below (see uses of INT_MAX). + */ +# ifndef PNG_NO_LIMITS_H +# include +# endif + +/* For the memory copy APIs (i.e. the standard definitions of these), + * because this file defines png_memcpy and so on the base APIs must + * be defined here. + */ +# ifdef BSD +# include +# else +# include +# endif + +/* For png_FILE_p - this provides the standard definition of a + * FILE + */ +# ifdef PNG_STDIO_SUPPORTED +# include +# endif +#endif + +/* This controls optimization of the reading of 16 and 32 bit values + * from PNG files. It can be set on a per-app-file basis - it + * just changes whether a macro is used when the function is called. + * The library builder sets the default; if read functions are not + * built into the library the macro implementation is forced on. + */ +#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED +# define PNG_USE_READ_MACROS +#endif +#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) +# if PNG_DEFAULT_READ_MACROS +# define PNG_USE_READ_MACROS +# endif +#endif + +/* COMPILER SPECIFIC OPTIONS. + * + * These options are provided so that a variety of difficult compilers + * can be used. Some are fixed at build time (e.g. PNG_API_RULE + * below) but still have compiler specific implementations, others + * may be changed on a per-file basis when compiling against libpng. + */ + +/* The PNGARG macro protects us against machines that don't have function + * prototypes (ie K&R style headers). If your compiler does not handle + * function prototypes, define this macro and use the included ansi2knr. + * I've always been able to use _NO_PROTO as the indicator, but you may + * need to drag the empty declaration out in front of here, or change the + * ifdef to suit your own needs. + */ +#ifndef PNGARG + +# ifdef OF /* zlib prototype munger */ +# define PNGARG(arglist) OF(arglist) +# else + +# ifdef _NO_PROTO +# define PNGARG(arglist) () +# else +# define PNGARG(arglist) arglist +# endif /* _NO_PROTO */ + +# endif /* OF */ + +#endif /* PNGARG */ + +/* Function calling conventions. + * ============================= + * Normally it is not necessary to specify to the compiler how to call + * a function - it just does it - however on x86 systems derived from + * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems + * and some others) there are multiple ways to call a function and the + * default can be changed on the compiler command line. For this reason + * libpng specifies the calling convention of every exported function and + * every function called via a user supplied function pointer. This is + * done in this file by defining the following macros: + * + * PNGAPI Calling convention for exported functions. + * PNGCBAPI Calling convention for user provided (callback) functions. + * PNGCAPI Calling convention used by the ANSI-C library (required + * for longjmp callbacks and sometimes used internally to + * specify the calling convention for zlib). + * + * These macros should never be overridden. If it is necessary to + * change calling convention in a private build this can be done + * by setting PNG_API_RULE (which defaults to 0) to one of the values + * below to select the correct 'API' variants. + * + * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. + * This is correct in every known environment. + * PNG_API_RULE=1 Use the operating system convention for PNGAPI and + * the 'C' calling convention (from PNGCAPI) for + * callbacks (PNGCBAPI). This is no longer required + * in any known environment - if it has to be used + * please post an explanation of the problem to the + * libpng mailing list. + * + * These cases only differ if the operating system does not use the C + * calling convention, at present this just means the above cases + * (x86 DOS/Windows sytems) and, even then, this does not apply to + * Cygwin running on those systems. + * + * Note that the value must be defined in pnglibconf.h so that what + * the application uses to call the library matches the conventions + * set when building the library. + */ + +/* Symbol export + * ============= + * When building a shared library it is almost always necessary to tell + * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' + * is used to mark the symbols. On some systems these symbols can be + * extracted at link time and need no special processing by the compiler, + * on other systems the symbols are flagged by the compiler and just + * the declaration requires a special tag applied (unfortunately) in a + * compiler dependent way. Some systems can do either. + * + * A small number of older systems also require a symbol from a DLL to + * be flagged to the program that calls it. This is a problem because + * we do not know in the header file included by application code that + * the symbol will come from a shared library, as opposed to a statically + * linked one. For this reason the application must tell us by setting + * the magic flag PNG_USE_DLL to turn on the special processing before + * it includes png.h. + * + * Four additional macros are used to make this happen: + * + * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from + * the build or imported if PNG_USE_DLL is set - compiler + * and system specific. + * + * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to + * 'type', compiler specific. + * + * PNG_DLL_EXPORT Set to the magic to use during a libpng build to + * make a symbol exported from the DLL. Not used in the + * public header files; see pngpriv.h for how it is used + * in the libpng build. + * + * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come + * from a DLL - used to define PNG_IMPEXP when + * PNG_USE_DLL is set. + */ + +/* System specific discovery. + * ========================== + * This code is used at build time to find PNG_IMPEXP, the API settings + * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL + * import processing is possible. On Windows/x86 systems it also sets + * compiler-specific macros to the values required to change the calling + * conventions of the various functions. + */ +#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ + defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ + ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ + defined(_M_X64) || defined(_M_IA64) ) + /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes + * builds under Cygwin or MinGW. Also includes Watcom builds but these need + * special treatment because they are not compatible with GCC or Visual C + * because of different calling conventions. + */ +# if PNG_API_RULE == 2 + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! + */ +# define PNGCAPI __watcall +# endif + +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# define PNGCAPI __cdecl +# if PNG_API_RULE == 1 +# define PNGAPI __stdcall +# endif +# else + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. + */ +# ifndef PNGCAPI +# define PNGCAPI _cdecl +# endif +# if PNG_API_RULE == 1 && !defined(PNGAPI) +# define PNGAPI _stdcall +# endif +# endif /* compiler/api */ + /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ + +# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) + ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed +# endif + +# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ + (defined(__BORLANDC__) && __BORLANDC__ < 0x500) + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ +# ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP +# endif +# define PNG_DLL_EXPORT __export +# else /* newer compiler */ +# define PNG_DLL_EXPORT __declspec(dllexport) +# ifndef PNG_DLL_IMPORT +# define PNG_DLL_IMPORT __declspec(dllimport) +# endif +# endif /* compiler */ + +#else /* !Windows/x86 */ +# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) +# define PNGAPI _System +# else /* !Windows/x86 && !OS/2 */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ +# endif /* other system, !OS/2 */ +#endif /* !Windows/x86 */ + +/* Now do all the defaulting . */ +#ifndef PNGCAPI +# define PNGCAPI +#endif +#ifndef PNGCBAPI +# define PNGCBAPI PNGCAPI +#endif +#ifndef PNGAPI +# define PNGAPI PNGCAPI +#endif + +/* PNG_IMPEXP may be set on the compilation system command line or (if not set) + * then in an internal header file when building the library, otherwise (when + * using the library) it is set here. + */ +#ifndef PNG_IMPEXP +# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) + /* This forces use of a DLL, disallowing static linking */ +# define PNG_IMPEXP PNG_DLL_IMPORT +# endif + +# ifndef PNG_IMPEXP +# define PNG_IMPEXP +# endif +#endif + +/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat + * 'attributes' as a storage class - the attributes go at the start of the + * function definition, and attributes are always appended regardless of the + * compiler. This considerably simplifies these macros but may cause problems + * if any compilers both need function attributes and fail to handle them as + * a storage class (this is unlikely.) + */ +#ifndef PNG_FUNCTION +# define PNG_FUNCTION(type, name, args, attributes) attributes type name args +#endif + +#ifndef PNG_EXPORT_TYPE +# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type +#endif + + /* The ordinal value is only relevant when preprocessing png.h for symbol + * table entries, so we discard it here. See the .dfn files in the + * scripts directory. + */ +#ifndef PNG_EXPORTA + +# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ + PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ + extern attributes) +#endif + +/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, + * so make something non-empty to satisfy the requirement: + */ +#define PNG_EMPTY /*empty list*/ + +#define PNG_EXPORT(ordinal, type, name, args)\ + PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) + +/* Use PNG_REMOVED to comment out a removed interface. */ +#ifndef PNG_REMOVED +# define PNG_REMOVED(ordinal, type, name, args, attributes) +#endif + +#ifndef PNG_CALLBACK +# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) +#endif + +/* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. + * + * Added at libpng-1.2.41. + */ + +#ifndef PNG_NO_PEDANTIC_WARNINGS +# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED +# define PNG_PEDANTIC_WARNINGS_SUPPORTED +# endif +#endif + +#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED + /* Support for compiler specific function attributes. These are used + * so that where compiler support is available incorrect use of API + * functions in png.h will generate compiler warnings. Added at libpng + * version 1.2.41. + */ +# if defined(__GNUC__) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) +# endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __attribute__((__noreturn__)) +# endif +# if __GNUC__ >= 3 +# ifndef PNG_ALLOCATED +# define PNG_ALLOCATED __attribute__((__malloc__)) +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __attribute__((__deprecated__)) +# endif +# ifndef PNG_PRIVATE +# if 0 /* Doesn't work so we use deprecated instead*/ +# define PNG_PRIVATE \ + __attribute__((warning("This function is not exported by libpng."))) +# else +# define PNG_PRIVATE \ + __attribute__((__deprecated__)) +# endif +# endif +# endif /* __GNUC__ >= 3 */ +# endif /* __GNUC__ */ + +# if defined(_MSC_VER) && (_MSC_VER >= 1300) +# ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* not supported */ +# endif +# ifndef PNG_NORETURN +# define PNG_NORETURN __declspec(noreturn) +# endif +# ifndef PNG_ALLOCATED +# if (_MSC_VER >= 1400) +# define PNG_ALLOCATED __declspec(restrict) +# endif +# endif +# ifndef PNG_DEPRECATED +# define PNG_DEPRECATED __declspec(deprecated) +# endif +# ifndef PNG_PRIVATE +# define PNG_PRIVATE __declspec(deprecated) +# endif +# endif /* _MSC_VER */ +#endif /* PNG_PEDANTIC_WARNINGS */ + +#ifndef PNG_DEPRECATED +# define PNG_DEPRECATED /* Use of this function is deprecated */ +#endif +#ifndef PNG_USE_RESULT +# define PNG_USE_RESULT /* The result of this function must be checked */ +#endif +#ifndef PNG_NORETURN +# define PNG_NORETURN /* This function does not return */ +#endif +#ifndef PNG_ALLOCATED +# define PNG_ALLOCATED /* The result of the function is new memory */ +#endif +#ifndef PNG_PRIVATE +# define PNG_PRIVATE /* This is a private libpng function */ +#endif +#ifndef PNG_FP_EXPORT /* A floating point API. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define PNG_FP_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No floating point APIs */ +# define PNG_FP_EXPORT(ordinal, type, name, args) +# endif +#endif +#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ +# ifdef PNG_FIXED_POINT_SUPPORTED +# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ + PNG_EXPORT(ordinal, type, name, args); +# else /* No fixed point APIs */ +# define PNG_FIXED_EXPORT(ordinal, type, name, args) +# endif +#endif + +/* The following uses const char * instead of char * for error + * and warning message functions, so some compilers won't complain. + * If you do not want to use const, define PNG_NO_CONST here. + * + * This should not change how the APIs are called, so it can be done + * on a per-file basis in the application. + */ +#ifndef PNG_CONST +# ifndef PNG_NO_CONST +# define PNG_CONST const +# else +# define PNG_CONST +# endif +#endif + +/* Some typedefs to get us started. These should be safe on most of the + * common platforms. The typedefs should be at least as large as the + * numbers suggest (a png_uint_32 must be at least 32 bits long), but they + * don't have to be exactly that size. Some compilers dislike passing + * unsigned shorts as function parameters, so you may be better off using + * unsigned int for png_uint_16. + */ + +#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL) +typedef unsigned int png_uint_32; +typedef int png_int_32; +#else +typedef unsigned long png_uint_32; +typedef long png_int_32; +#endif +typedef unsigned short png_uint_16; +typedef short png_int_16; +typedef unsigned char png_byte; + +#ifdef PNG_NO_SIZE_T +typedef unsigned int png_size_t; +#else +typedef size_t png_size_t; +#endif +#define png_sizeof(x) (sizeof (x)) + +/* The following is needed for medium model support. It cannot be in the + * pngpriv.h header. Needs modification for other compilers besides + * MSC. Model independent support declares all arrays and pointers to be + * large using the far keyword. The zlib version used must also support + * model independent data. As of version zlib 1.0.4, the necessary changes + * have been made in zlib. The USE_FAR_KEYWORD define triggers other + * changes that are needed. (Tim Wegner) + */ + +/* Separate compiler dependencies (problem here is that zlib.h always + * defines FAR. (SJT) + */ +#ifdef __BORLANDC__ +# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) +# define LDATA 1 +# else +# define LDATA 0 +# endif + /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ +# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) +# define PNG_MAX_MALLOC_64K /* only used in build */ +# if (LDATA != 1) +# ifndef FAR +# define FAR __far +# endif +# define USE_FAR_KEYWORD +# endif /* LDATA != 1 */ + /* Possibly useful for moving data out of default segment. + * Uncomment it if you want. Could also define FARDATA as + * const if your compiler supports it. (SJT) +# define FARDATA FAR + */ +# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ +#endif /* __BORLANDC__ */ + + +/* Suggest testing for specific compiler first before testing for + * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, + * making reliance oncertain keywords suspect. (SJT) + */ + +/* MSC Medium model */ +#ifdef FAR +# ifdef M_I86MM +# define USE_FAR_KEYWORD +# define FARDATA FAR +# include +# endif +#endif + +/* SJT: default case */ +#ifndef FAR +# define FAR +#endif + +/* At this point FAR is always defined */ +#ifndef FARDATA +# define FARDATA +#endif + +/* Typedef for floating-point numbers that are converted + * to fixed-point with a multiple of 100,000, e.g., gamma + */ +typedef png_int_32 png_fixed_point; + +/* Add typedefs for pointers */ +typedef void FAR * png_voidp; +typedef PNG_CONST void FAR * png_const_voidp; +typedef png_byte FAR * png_bytep; +typedef PNG_CONST png_byte FAR * png_const_bytep; +typedef png_uint_32 FAR * png_uint_32p; +typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p; +typedef png_int_32 FAR * png_int_32p; +typedef PNG_CONST png_int_32 FAR * png_const_int_32p; +typedef png_uint_16 FAR * png_uint_16p; +typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p; +typedef png_int_16 FAR * png_int_16p; +typedef PNG_CONST png_int_16 FAR * png_const_int_16p; +typedef char FAR * png_charp; +typedef PNG_CONST char FAR * png_const_charp; +typedef png_fixed_point FAR * png_fixed_point_p; +typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p; +typedef png_size_t FAR * png_size_tp; +typedef PNG_CONST png_size_t FAR * png_const_size_tp; + +#ifdef PNG_STDIO_SUPPORTED +typedef FILE * png_FILE_p; +#endif + +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * png_doublep; +typedef PNG_CONST double FAR * png_const_doublep; +#endif + +/* Pointers to pointers; i.e. arrays */ +typedef png_byte FAR * FAR * png_bytepp; +typedef png_uint_32 FAR * FAR * png_uint_32pp; +typedef png_int_32 FAR * FAR * png_int_32pp; +typedef png_uint_16 FAR * FAR * png_uint_16pp; +typedef png_int_16 FAR * FAR * png_int_16pp; +typedef PNG_CONST char FAR * FAR * png_const_charpp; +typedef char FAR * FAR * png_charpp; +typedef png_fixed_point FAR * FAR * png_fixed_point_pp; +#ifdef PNG_FLOATING_POINT_SUPPORTED +typedef double FAR * FAR * png_doublepp; +#endif + +/* Pointers to pointers to pointers; i.e., pointer to array */ +typedef char FAR * FAR * FAR * png_charppp; + +/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, + * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32 + * to png_alloc_size_t are not necessary; in fact, it is recommended + * not to use them at all so that the compiler can complain when something + * turns out to be problematic. + * Casts in the other direction (from png_alloc_size_t to png_size_t or + * png_uint_32) should be explicitly applied; however, we do not expect + * to encounter practical situations that require such conversions. + */ +#if defined(__TURBOC__) && !defined(__FLAT__) + typedef unsigned long png_alloc_size_t; +#else +# if defined(_MSC_VER) && defined(MAXSEG_64K) + typedef unsigned long png_alloc_size_t; +# else + /* This is an attempt to detect an old Windows system where (int) is + * actually 16 bits, in that case png_malloc must have an argument with a + * bigger size to accomodate the requirements of the library. + */ +# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \ + (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) + typedef DWORD png_alloc_size_t; +# else + typedef png_size_t png_alloc_size_t; +# endif +# endif +#endif + +#endif /* PNGCONF_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/zconf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/zconf.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,428 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2010 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + * Even better than compiling with -DZ_PREFIX would be to use configure to set + * this permanently in zconf.h using "./configure --zprefix". + */ +#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ + +/* all linked symbols */ +# define _dist_code z__dist_code +# define _length_code z__length_code +# define _tr_align z__tr_align +# define _tr_flush_block z__tr_flush_block +# define _tr_init z__tr_init +# define _tr_stored_block z__tr_stored_block +# define _tr_tally z__tr_tally +# define adler32 z_adler32 +# define adler32_combine z_adler32_combine +# define adler32_combine64 z_adler32_combine64 +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define crc32 z_crc32 +# define crc32_combine z_crc32_combine +# define crc32_combine64 z_crc32_combine64 +# define deflate z_deflate +# define deflateBound z_deflateBound +# define deflateCopy z_deflateCopy +# define deflateEnd z_deflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateInit_ z_deflateInit_ +# define deflateParams z_deflateParams +# define deflatePrime z_deflatePrime +# define deflateReset z_deflateReset +# define deflateSetDictionary z_deflateSetDictionary +# define deflateSetHeader z_deflateSetHeader +# define deflateTune z_deflateTune +# define deflate_copyright z_deflate_copyright +# define get_crc_table z_get_crc_table +# define gz_error z_gz_error +# define gz_intmax z_gz_intmax +# define gz_strwinerror z_gz_strwinerror +# define gzbuffer z_gzbuffer +# define gzclearerr z_gzclearerr +# define gzclose z_gzclose +# define gzclose_r z_gzclose_r +# define gzclose_w z_gzclose_w +# define gzdirect z_gzdirect +# define gzdopen z_gzdopen +# define gzeof z_gzeof +# define gzerror z_gzerror +# define gzflush z_gzflush +# define gzgetc z_gzgetc +# define gzgets z_gzgets +# define gzoffset z_gzoffset +# define gzoffset64 z_gzoffset64 +# define gzopen z_gzopen +# define gzopen64 z_gzopen64 +# define gzprintf z_gzprintf +# define gzputc z_gzputc +# define gzputs z_gzputs +# define gzread z_gzread +# define gzrewind z_gzrewind +# define gzseek z_gzseek +# define gzseek64 z_gzseek64 +# define gzsetparams z_gzsetparams +# define gztell z_gztell +# define gztell64 z_gztell64 +# define gzungetc z_gzungetc +# define gzwrite z_gzwrite +# define inflate z_inflate +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define inflateBackInit_ z_inflateBackInit_ +# define inflateCopy z_inflateCopy +# define inflateEnd z_inflateEnd +# define inflateGetHeader z_inflateGetHeader +# define inflateInit2_ z_inflateInit2_ +# define inflateInit_ z_inflateInit_ +# define inflateMark z_inflateMark +# define inflatePrime z_inflatePrime +# define inflateReset z_inflateReset +# define inflateReset2 z_inflateReset2 +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateUndermine z_inflateUndermine +# define inflate_copyright z_inflate_copyright +# define inflate_fast z_inflate_fast +# define inflate_table z_inflate_table +# define uncompress z_uncompress +# define zError z_zError +# define zcalloc z_zcalloc +# define zcfree z_zcfree +# define zlibCompileFlags z_zlibCompileFlags +# define zlibVersion z_zlibVersion + +/* all zlib typedefs in zlib.h and zconf.h */ +# define Byte z_Byte +# define Bytef z_Bytef +# define alloc_func z_alloc_func +# define charf z_charf +# define free_func z_free_func +# define gzFile z_gzFile +# define gz_header z_gz_header +# define gz_headerp z_gz_headerp +# define in_func z_in_func +# define intf z_intf +# define out_func z_out_func +# define uInt z_uInt +# define uIntf z_uIntf +# define uLong z_uLong +# define uLongf z_uLongf +# define voidp z_voidp +# define voidpc z_voidpc +# define voidpf z_voidpf + +/* all zlib structs in zlib.h and zconf.h */ +# define gz_header_s z_gz_header_s +# define internal_state z_internal_state + +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +# define Z_HAVE_UNISTD_H +#endif + +#ifdef STDC +# include /* for off_t */ +#endif + +/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and + * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even + * though the former does not conform to the LFS document), but considering + * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as + * equivalently requesting no 64-bit operations + */ +#if -_LARGEFILE64_SOURCE - -1 == 1 +# undef _LARGEFILE64_SOURCE +#endif + +#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# ifndef z_off_t +# define z_off_t off_t +# endif +#endif + +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif + +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +# define z_off64_t off64_t +#else +# define z_off64_t z_off_t +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) + #pragma map(deflateInit_,"DEIN") + #pragma map(deflateInit2_,"DEIN2") + #pragma map(deflateEnd,"DEEND") + #pragma map(deflateBound,"DEBND") + #pragma map(inflateInit_,"ININ") + #pragma map(inflateInit2_,"ININ2") + #pragma map(inflateEnd,"INEND") + #pragma map(inflateSync,"INSY") + #pragma map(inflateSetDictionary,"INSEDI") + #pragma map(compressBound,"CMBND") + #pragma map(inflate_table,"INTABL") + #pragma map(inflate_fast,"INFA") + #pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/include/zlib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/include/zlib.h Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,1613 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.5, April 19th, 2010 + + Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.5" +#define ZLIB_VERNUM 0x1250 +#define ZLIB_VER_MAJOR 1 +#define ZLIB_VER_MINOR 2 +#define ZLIB_VER_REVISION 5 +#define ZLIB_VER_SUBREVISION 0 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed data. + This version of the library supports only one compression method (deflation) + but other algorithms will be added later and will have the same stream + interface. + + Compression can be done in a single step if the buffers are large enough, + or can be done by repeated calls of the compression function. In the latter + case, the application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never crash + even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has dropped + to zero. It must update next_out and avail_out when avail_out has dropped + to zero. The application must initialize zalloc, zfree and opaque before + calling the init function. All other fields are set by the compression + library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this if + the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers + returned by zalloc for objects of exactly 65536 bytes *must* have their + offset normalized to zero. The default allocation function provided by this + library ensures this (see zutil.c). To reduce memory requirements and avoid + any allocation of 64K objects, at the expense of compression ratio, compile + the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or progress + reports. After compression, total_in holds the total size of the + uncompressed data and may be saved for use in the decompressor (particularly + if the decompressor wants to decompress everything in a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +#define Z_TREES 6 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is not + compatible with the zlib.h header file used by the application. This check + is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. If + zalloc and zfree are set to Z_NULL, deflateInit updates them to use default + allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at all + (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION + requests a default compromise between speed and compression (currently + equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if level is not a valid compression level, or + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). msg is set to null + if there is no error message. deflateInit does not perform any compression: + this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). Some + output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating avail_in or avail_out accordingly; avail_out should + never be zero before the call. The application can consume the compressed + output when it wants, for example when the output buffer is full (avail_out + == 0), or after each call of deflate(). If deflate returns Z_OK and with + zero avail_out, it must be called again after making room in the output + buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumulate before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In + particular avail_in is zero after the call if enough output space has been + provided before the call.) Flushing may degrade compression for some + compression algorithms and so it should be used only when necessary. This + completes the current deflate block and follows it with an empty stored block + that is three bits plus filler bits to the next byte, followed by four bytes + (00 00 ff ff). + + If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the + output buffer, but the output is not aligned to a byte boundary. All of the + input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. + This completes the current deflate block and follows it with an empty fixed + codes block that is 10 bits long. This assures that enough bytes are output + in order for the decompressor to finish the block before the empty fixed code + block. + + If flush is set to Z_BLOCK, a deflate block is completed and emitted, as + for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to + seven bits of the current block are held to be written as the next byte after + the next deflate block is completed. In this case, the decompressor may not + be provided enough bits at this point in order to complete decompression of + the data provided so far to the compressor. It may need to wait for the next + block to be emitted. This is for advanced applications that need to control + the emission of deflate blocks. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there was + enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the stream + are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least the + value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect the + compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, msg + may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the + exact value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit() does not process any header information -- that is deferred + until inflate() is called. +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing will + resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there is + no more input data or no more space in the output buffer (see below about + the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming more + output, and updating the next_* and avail_* values accordingly. The + application can consume the uncompressed output when it wants, for example + when the output buffer is full (avail_out == 0), or after each call of + inflate(). If inflate returns Z_OK and with zero avail_out, it must be + called again after making room in the output buffer because there might be + more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, + Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() + stop if and when it gets to the next deflate block boundary. When decoding + the zlib or gzip format, this will cause inflate() to return immediately + after the header and before the first block. When doing a raw inflate, + inflate() will go ahead and process the first block, and will return when it + gets to the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 if + inflate() is currently decoding the last block in the deflate stream, plus + 128 if inflate() returned immediately after decoding an end-of-block code or + decoding the complete header up to just before the first byte of the deflate + stream. The end-of-block will not be indicated until all of the uncompressed + data from that block has been written to strm->next_out. The number of + unused bits may in general be greater than seven, except when bit 7 of + data_type is set, in which case the number of unused bits will be less than + eight. data_type is set as noted here every time inflate() returns for all + flush options, and so can be used to determine the amount of currently + consumed input in bits. + + The Z_TREES option behaves as Z_BLOCK does, but it also returns when the + end of each deflate block header is reached, before any actual data in that + block is decoded. This allows the caller to determine the length of the + deflate block header for later use in random access within a deflate block. + 256 is added to the value of strm->data_type when inflate() returns + immediately after reaching the end of the deflate block header. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step (a + single call of inflate), the parameter flush should be set to Z_FINISH. In + this case all pending input is processed and all pending output is flushed; + avail_out must be large enough to hold all the uncompressed data. (The size + of the uncompressed data may have been saved by the compressor for this + purpose.) The next operation on this stream must be inflateEnd to deallocate + the decompression state. The use of Z_FINISH is never required, but can be + used to inform inflate that a faster approach may be used for the single + inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK or Z_TREES is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() can decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically, if requested when + initializing with inflateInit2(). Any information contained in the gzip + header is not retained, so applications that need that information should + instead use raw inflate, see inflateInit2() below, or inflateBack() and + perform their own processing of the gzip header and trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may + then call inflateSync() to look for a good compression block if a partial + recovery of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any pending + output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by the + caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), no + header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but is + slow and reduces compression ratio; memLevel=9 uses maximum memory for + optimal speed. The default value is 8. See zconf.h for total memory usage + as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as + fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The + strategy parameter only affects the compression ratio but not the + correctness of the compressed output even if it is not set appropriately. + Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler + decoder for special applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid + method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is + incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + set to null if there is no error message. deflateInit2 does not perform any + compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any call + of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size + provided in deflateInit or deflateInit2. Thus the strings most likely to be + useful should be put at the end of the dictionary, not at the front. In + addition, the current implementation of deflate will use at most the window + size minus 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and can + consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. The + stream will keep the same compression level and any other attributes that + may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different strategy. + If the compression level is changed, the input available so far is + compressed with the old level (and may be flushed); the new level will take + effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to be + compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if + strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() or + deflateInit2(), and after deflateSetHeader(), if used. This would be used + to allocate an output buffer for deflation in a single pass, and so would be + called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the bits + leftover from a previous deflate stream when appending to it. As such, this + function can only be used for raw deflate, and must be used before the first + deflate() call after a deflateInit2() or deflateReset(). bits must be less + than or equal to 16, and that many of the least significant bits of value + will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be zero to request that inflate use the window size in + the zlib header of the compressed stream. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a + crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller, or Z_STREAM_ERROR if the parameters are + invalid, such as a null pointer to the structure. msg is set to null if + there is no error message. inflateInit2 does not perform any decompression + apart from possibly reading the zlib header if present: actual decompression + will be done by inflate(). (So next_in and avail_in may be modified, but + next_out and avail_out are unused and unchanged.) The current implementation + of inflateInit2() does not process any header information -- that is + deferred until inflate() is called. +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been + found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the + success case, the application may save the current current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being Z_NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. The + stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL). +*/ + +ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, + int windowBits)); +/* + This function is the same as inflateReset, but it also permits changing + the wrap and window size requests. The windowBits parameter is interpreted + the same as it is for inflateInit2. + + inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being Z_NULL), or if + the windowBits parameter is invalid. +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + If bits is negative, then the input stream bit buffer is emptied. Then + inflatePrime() can be called again to put bits in the buffer. This is used + to clear out bits leftover after feeding inflate a block description prior + to feeding inflate codes. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +/* + This function returns two values, one in the lower 16 bits of the return + value, and the other in the remaining upper bits, obtained by shifting the + return value down 16 bits. If the upper value is -1 and the lower value is + zero, then inflate() is currently decoding information outside of a block. + If the upper value is -1 and the lower value is non-zero, then inflate is in + the middle of a stored block, with the lower value equaling the number of + bytes from the input remaining to copy. If the upper value is not -1, then + it is the number of bits back from the current bit position in the input of + the code (literal or length/distance pair) currently being processed. In + that case the lower value is the number of bytes already emitted for that + code. + + A code is being processed if inflate is waiting for more input to complete + decoding of the code, or if it has completed decoding but is waiting for + more output space to write the literal or match data. + + inflateMark() is used to mark locations in the input data for random + access, which may be at bit positions, and to note those cases where the + output of a code may span boundaries of random access blocks. The current + location in the input stream can be determined from avail_in and data_type + as noted in the description for the Z_BLOCK flush parameter for inflate. + + inflateMark returns the value noted above or -1 << 16 if the provided + source stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be + used to force inflate() to return immediately after header processing is + complete and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When any + of extra, name, or comment are not Z_NULL and the respective field is not + present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not be + allocated, or Z_VERSION_ERROR if the version of the library does not match + the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free the + allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects only + the raw deflate stream to decompress. This is different from the normal + behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format error + in the deflate stream (in which case strm->msg is set to indicate the nature + of the error), or Z_STREAM_ERROR if the stream was not properly initialized. + In the case of Z_BUF_ERROR, an input or output error can be distinguished + using strm->next_in which will be Z_NULL only if in() returned an error. If + strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning + non-zero. (in() will always be called before out(), so strm->next_in is + assured to be defined if out() returns non-zero.) Note that inflateBack() + cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the basic + stream-oriented functions. To simplify the interface, some default options + are assumed (compression level and memory usage, standard memory allocation + functions). The source code of these utility functions can be modified if + you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before a + compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total size + of the destination buffer, which must be large enough to hold the entire + uncompressed data. (The size of the uncompressed data must have been saved + previously by the compressor and transmitted to the decompressor by some + mechanism outside the scope of this compression library.) Upon exit, destLen + is the actual size of the uncompressed buffer. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + + /* gzip file access functions */ + +/* + This library supports reading and writing files in gzip (.gz) format with + an interface similar to that of stdio, using the functions that start with + "gz". The gzip format is different from the zlib format. gzip is a gzip + wrapper, documented in RFC 1952, wrapped around a deflate stream. +*/ + +typedef voidp gzFile; /* opaque gzip file descriptor */ + +/* +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); + + Opens a gzip (.gz) file for reading or writing. The mode parameter is as + in fopen ("rb" or "wb") but can also include a compression level ("wb9") or + a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only + compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' + for fixed code compression as in "wb9F". (See the description of + deflateInit2 for more information about the strategy parameter.) Also "a" + can be used instead of "w" to request that the gzip stream that will be + written be appended to the file. "+" will result in an error, since reading + and writing to the same gzip file is not supported. + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened, if there was + insufficient memory to allocate the gzFile state, or if an invalid mode was + specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). + errno can be checked to determine if the reason gzopen failed was that the + file could not be opened. +*/ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen associates a gzFile with the file descriptor fd. File descriptors + are obtained from calls like open, dup, creat, pipe or fileno (if the file + has been previously opened with fopen). The mode parameter is as in gzopen. + + The next call of gzclose on the returned gzFile will also close the file + descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor + fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, + mode);. The duplicated descriptor should be saved to avoid a leak, since + gzdopen does not close fd if it fails. + + gzdopen returns NULL if there was insufficient memory to allocate the + gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not + provided, or '+' was provided), or if fd is -1. The file descriptor is not + used until the next gz* read, write, seek, or close operation, so gzdopen + will not detect if fd is invalid (unless fd is -1). +*/ + +ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +/* + Set the internal buffer size used by this library's functions. The + default buffer size is 8192 bytes. This function must be called after + gzopen() or gzdopen(), and before any other calls that read or write the + file. The buffer memory allocation is always deferred to the first read or + write. Two buffers are allocated, either both of the specified size when + writing, or one of the specified size and the other twice that size when + reading. A larger buffer size of, for example, 64K or 128K bytes will + noticeably increase the speed of decompression (reading). + + The new buffer size also affects the maximum length for gzprintf(). + + gzbuffer() returns 0 on success, or -1 on failure, such as being called + too late. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. If + the input file was not in gzip format, gzread copies the given number of + bytes into the buffer. + + After reaching the end of a gzip stream in the input, gzread will continue + to read, looking for another gzip stream, or failing that, reading the rest + of the input file directly without decompression. The entire input file + will be read if gzread is called until it returns less than the requested + len. + + gzread returns the number of uncompressed bytes actually read, less than + len for end of file, or -1 for error. +*/ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes written or 0 in case of + error. +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the arguments to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written, or 0 in case of error. The number of + uncompressed bytes written is limited to 8191, or one less than the buffer + size given to gzbuffer(). The caller should assure that this limit is not + exceeded. If it is exceeded, then gzprintf() will return an error (0) with + nothing written. In this case, there may also be a buffer overflow with + unpredictable consequences, which is possible only if zlib was compiled with + the insecure functions sprintf() or vsprintf() because the secure snprintf() + or vsnprintf() functions were not available. This can be determined using + zlibCompileFlags(). +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or a + newline character is read and transferred to buf, or an end-of-file + condition is encountered. If any characters are read or if len == 1, the + string is terminated with a null character. If no characters are read due + to an end-of-file or len < 1, then the buffer is left untouched. + + gzgets returns buf which is a null-terminated string, or it returns NULL + for end-of-file or in case of error. If there was an error, the contents at + buf are indeterminate. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. gzputc + returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte or -1 + in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read as the first character + on the next read. At least one character of push-back is allowed. + gzungetc() returns the character pushed, or -1 on failure. gzungetc() will + fail if c is -1, and may fail if a character has been pushed but not read + yet. If gzungetc is used immediately after gzopen or gzdopen, at least the + output buffer size of pushed characters is allowed. (See gzbuffer above.) + The pushed character will be discarded if the stream is repositioned with + gzseek() or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter flush + is as in the deflate() function. The return value is the zlib error number + (see function gzerror below). gzflush is only permitted when writing. + + If the flush parameter is Z_FINISH, the remaining data is written and the + gzip stream is completed in the output. If gzwrite() is called again, a new + gzip stream will be started in the output. gzread() is able to read such + concatented gzip streams. + + gzflush should be called only when strictly necessary because it will + degrade compression if called too often. +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); + + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); + + Returns the starting position for the next gzread or gzwrite on the given + compressed file. This position represents a number of bytes in the + uncompressed data stream, and is zero when starting, even if appending or + reading a gzip stream from the middle of a file using gzdopen(). + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +/* +ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); + + Returns the current offset in the file being read or written. This offset + includes the count of bytes that precede the gzip stream, for example when + appending or when using gzdopen() for reading. When reading, the offset + does not include as yet unused buffered input. This information can be used + for a progress indicator. On error, gzoffset() returns -1. +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns true (1) if the end-of-file indicator has been set while reading, + false (0) otherwise. Note that the end-of-file indicator is set only if the + read tried to go past the end of the input, but came up short. Therefore, + just like feof(), gzeof() may return false even if there is no more data to + read, in the event that the last read request was for the exact number of + bytes remaining in the input file. This will happen if the input file size + is an exact multiple of the buffer size. + + If gzeof() returns true, then the read functions will return no more data, + unless the end-of-file indicator is reset by gzclearerr() and the input file + has grown since the previous end of file was detected. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns true (1) if file is being copied directly while reading, or false + (0) if file is a gzip stream being decompressed. This state can change from + false to true while reading the input file if the end of a gzip stream is + reached, but is followed by data that is not another gzip stream. + + If the input file is empty, gzdirect() will return true, since the input + does not contain a gzip stream. + + If gzdirect() is used immediately after gzopen() or gzdopen() it will + cause buffers to be allocated to allow reading the file to determine if it + is a gzip file. Therefore if gzbuffer() is used, it should be called before + gzdirect(). +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file and + deallocates the (de)compression state. Note that once file is closed, you + cannot call gzerror with file, since its structures have been deallocated. + gzclose must not be called more than once on the same file, just as free + must not be called more than once on the same allocation. + + gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a + file operation error, or Z_OK on success. +*/ + +ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +/* + Same as gzclose(), but gzclose_r() is only for use when reading, and + gzclose_w() is only for use when writing or appending. The advantage to + using these instead of gzclose() is that they avoid linking in zlib + compression or decompression code that is not used when only reading or only + writing respectively. If gzclose() is used, then both compression and + decompression code will be included the application when linking to a static + zlib library. +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the given + compressed file. errnum is set to zlib error number. If an error occurred + in the file system and not in the compression library, errnum is set to + Z_ERRNO and the application may consult errno to get the exact error code. + + The application must not modify the returned string. Future calls to + this function may invalidate the previously returned string. If file is + closed, then the string previously returned by gzerror will no longer be + available. + + gzerror() should be used to distinguish errors from end-of-file for those + functions above that do not distinguish those cases in their return values. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the compression + library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is Z_NULL, this function returns the + required initial value for the checksum. + + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. + + Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); + + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is Z_NULL, this function returns the required + initial value for the for the crc. Pre- and post-conditioning (one's + complement) is performed within this function so it shouldn't be done by the + application. + + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +/* +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + +/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or + * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if + * both are true, the application gets the *64 functions, and the regular + * functions are changed to 64 bits) -- in case these are set on systems + * without large file support, _LFS64_LARGEFILE must also be true + */ +#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); + ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); +#endif + +#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 +# define gzopen gzopen64 +# define gzseek gzseek64 +# define gztell gztell64 +# define gzoffset gzoffset64 +# define adler32_combine adler32_combine64 +# define crc32_combine crc32_combine64 +# ifdef _LARGEFILE64_SOURCE + ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); +# endif +#else + ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); + ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); + ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); + ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); + ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); + ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); +#endif + +/* hack for buggy compilers */ +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; +#endif + +/* undocumented functions */ +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); +ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libSDL.dll.a Binary file misc/winutils/lib/libSDL.dll.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libSDL.la --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/winutils/lib/libSDL.la Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,41 @@ +# libSDL.la - a libtool library file +# Generated by ltmain.sh (GNU libtool) 2.2.6 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='../bin/SDL.dll' + +# Names of this library. +library_names='libSDL.dll.a' + +# The name of the static archive. +old_library='libSDL.a' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='' + +# Libraries that this one depends upon. +dependency_libs=' -luser32 -lgdi32 -lwinmm -ldxguid' + +# Names of additional weak libraries provided by this library +weak_library_names='' + +# Version information for libSDL. +current=11 +age=11 +revision=3 + +# Is this an already installed library? +installed=yes + +# Should we warn about portability when linking against -modules? +shouldnotlink=no + +# Files to dlopen/dlpreopen +dlopen='' +dlpreopen='' + +# Directory that this library needs to be installed in: +libdir='/usr/local/lib' diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libSDL_mixer.dll.a Binary file misc/winutils/lib/libSDL_mixer.dll.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libSDLmain.a Binary file misc/winutils/lib/libSDLmain.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libavcodec.dll.a Binary file misc/winutils/lib/libavcodec.dll.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libavformat.dll.a Binary file misc/winutils/lib/libavformat.dll.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b misc/winutils/lib/libavutil.dll.a Binary file misc/winutils/lib/libavutil.dll.a has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/CMakeLists.txt --- a/project_files/Android-build/CMakeLists.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/CMakeLists.txt Sun Oct 28 13:28:23 2012 +0100 @@ -16,7 +16,10 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA ################################################################################### -find_program(ANT ant) +find_program(ANT ant DOC "Path to the java package creator: ant") +if(NOT EXISTS ${ANT}) + MESSAGE(FATAL_ERROR "Couldn't detect the Ant build tool") +endif() if(NOT ANDROID_NDK) find_path(ANDROID_NDK ndk-build) @@ -28,8 +31,22 @@ MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory") endif() +if(NOT ANDROID_NDK_TOOLCHAINDIR) + set(toolchainbase "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt") + find_path(ANDROID_NDK_TOOLCHAINDIR arm-linux-androideabi + "${toolchainbase}/linux-x86" + "${toolchainbase}/windows") +endif() + +if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}") + MESSAGE(STATUS "Detected the Android NDK toolchain at: ${ANDROID_NDK_TOOLCHAINDIR}") +else () + MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK toolchain directory: ${ANDROID_NDK_TOOLCHAINDIR}") +endif() + if(NOT ANDROID_SDK)#Check if its defined at the cmdline - find_path(ANDROID_SDK adb ) #assume they've added platform-tools to their path + find_program(ANDROID_SDK adb) #assume they've added platform-tools to their path + get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) get_filename_component(ANDROID_SDK "${ANDROID_SDK}" PATH) set(ANDROID_SDK "${ANDROID_SDK}" CACHE PATH "Path to the android sdk" FORCE) endif() @@ -41,9 +58,11 @@ endif() if( NOT FPC_DIR) - find_path(FPC_DIR ppcrossarm) + find_program(FPC_DIR ppcrossarm) get_filename_component(FPC_DIR "${FPC_DIR}" PATH) - set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE) + if(IS_DIRECTORY "${FPC_DIR}") + set(FPC_DIR "${FPC_DIR}" CACHE PATH "Path to fpc dir used in the android port" FORCE) + endif() endif() if( IS_DIRECTORY "${FPC_DIR}") @@ -55,48 +74,44 @@ set(SDL_DIR /home/richard/Downloads/android-project) -set(ANDROID_SDK_API_LVL 8) +set(ANDROID_SDK_API_LVL 14) set(ANDROID_NDK_API_LVL 5) -MESSAGE(STATUS "Creating android scripts and configuration files") +MESSAGE(STATUS "Creating Makefile.android...") + +configure_file(Templates/Makefile.android .) -configure_file(Templates/complete_build.sh .) -configure_file(Templates/default.properties SDL-android-project/) -configure_file(Templates/local.properties SDL-android-project/) -configure_file(Templates/Makefile.android .) -configure_file(Templates/pushToDevice.sh .) +find_program(ANDROID_EXEC NAMES android android.bat PATHS "${ANDROID_SDK}/platform-tools" "${ANDROID_SDK}/tools") +if(ANDROID_EXEC) + exec_program(${ANDROID_EXEC} + ARGS "update project" + "--path ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project" + "--target android-${ANDROID_SDK_API_LVL}" + OUTPUT_VARIABLE androidoutput + ) + MESSAGE(STATUS "Updating android project config...\n" ${androidoutput}) +else() + MESSAGE(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.") +endif() -if(SDL_DIR_TEMP_DISABLE) - MESSAGE("Moving Android port of SDL to the proper directories") - set(DirsToCopy - SDL - SDL_image - SDL_mixer - SDL_ttf - jpeg - png - mikmod - ) - foreach(DIR ${DirsToCopy}) - exec_program( - ${CMAKE_COMMAND} - ARGS -E copy_directory - ${SDL_DIR}/jni/${DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/${DIR} - ) - MESSAGE(STATUS "Moved ${DIR}") - endforeach(DIR) - exec_program(${HGCOMMAND} - ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp - ) - exec_program(${HGCOMMAND} - ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp - ) - exec_program(${HGCOMMAND} - ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.c - ) +exec_program(${HGCOMMAND} + ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp + OUTPUT_VARIABLE dontcare +) +exec_program(${HGCOMMAND} + ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/main/android/SDL_android_main.cpp + OUTPUT_VARIABLE dontcare +) +exec_program(${HGCOMMAND} + ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/file/SDL_rwops.c + OUTPUT_VARIABLE dontcare +) +exec_program(${HGCOMMAND} + ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_mixer/Android.mk + OUTPUT_VARIABLE dontcare +) +exec_program(${HGCOMMAND} + ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL_ttf/Android.mk + OUTPUT_VARIABLE dontcare +) - exec_program(${HGCOMMAND} - ARGS revert ${CMAKE_CURRENT_SOURCE_DIR}/SDL-android-project/jni/SDL/src/video/android/SDL_androidtouch.h - ) -endif(SDL_DIR_TEMP_DISABLE) diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/AndroidManifest.xml --- a/project_files/Android-build/SDL-android-project/AndroidManifest.xml Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/AndroidManifest.xml Sun Oct 28 13:28:23 2012 +0100 @@ -1,16 +1,15 @@ - + android:versionCode="8" + android:installLocation="preferExternal" android:versionName="0.2"> + + android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> @@ -30,8 +29,8 @@ - + android:screenOrientation='landscape' + android:launchMode="singleTop"/> @@ -48,7 +47,8 @@ + android:screenOrientation='landscape' + android:windowSoftInputMode="stateUnchanged"> diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/ant.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/ant.properties Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked in Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowdown.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowdown.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowleft.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowleft.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowright.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowright.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowup.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/arrowup.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/backjump.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/backjump.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/firebutton.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/firebutton.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/forwardjump.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/forwardjump.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/pause.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/Buttons/pause.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/TARDIS.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/TARDIS.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Graphics/slider.png Binary file project_files/Android-build/SDL-android-project/assets/Data/Graphics/slider.png has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/assets/Data/Locale/en.txt --- a/project_files/Android-build/SDL-android-project/assets/Data/Locale/en.txt Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/assets/Data/Locale/en.txt Sun Oct 28 13:28:23 2012 +0100 @@ -53,9 +53,10 @@ 00:50=Drill Strike 00:51=Mudball 00:52=No weapon selected -00:53=TARDIS +00:53=TimeBox 00:54=Structure 00:55=Land Spray +00:56=Freezer 01:00=Let's fight! 01:01=Round draw @@ -448,6 +449,7 @@ 03:52=UNUSED 03:53=Type 40 03:54=Build something +03:55=Utility ; Weapon Descriptions (use | as line breaks) 04:00=Attack your enemies using a simple grenade.|It will explode once its timer reaches zero.|1-5: Set grenade's timer|Attack: Hold to throw with more power @@ -491,7 +493,7 @@ 04:38=The sniper rifle can be the most devastating weapon|in your whole arsenal, however it's very ineffective|at close quarters. The damage dealt increases with|the distance to its target.|Attack: Shoot (twice) 04:39=Fly to other parts of the map using the flying|saucer. This hard to master utility is able to|take you to almost any position on the battlefield.|Attack: Activate|Up/Left/Right: Apply force in one direction|Long Jump: Drop grenades or similar weapons 04:40=Set some ground on fire using this bottle filled|with (soon to be) burning liquid.|Attack: Hold to shoot with more power -04:41=The evidence nature might even top the flying|saucer. Birdy can carry your hog around and|drop eggs on your enemies!|Attack: Activate and drop eggs|Up/Left/Right: Flap in one direction +04:41=The evidence nature might even top the flying|saucer. Birdy can carry your hog around and|drop eggs on your enemies!|Be quick, as using Birdy eats into your turn|time!|Attack: Activate and drop eggs|Up/Left/Right: Flap in one direction 04:42=This portable portal device is capable|of instantly transporting you, your enemies,|or your weaponry between two points on the|terrain.|Use it wisely and your campaign will be a...|HUGE SUCCESS!|Attack: Shoot a portal|Switch: Cycle portal colours 04:43=Make your musical debut an explosive success!|Drop a piano from the heavens, but beware...|someone needs to play it, and that may cost you|your life!|Cursor: Select target region|F1-F9: Play the piano 04:44=This isn't just cheese, it's biological warfare!|It won't cause an huge amount of damage once|the timer reaches zero but it will definitely|poison anyone unlucky to touch the smell!|1-5: Set grenade's timer|Attack: Hold to throw with more power @@ -500,6 +502,12 @@ 04:47=Double the fun with two spiky, sneaky, sticky mines.|Set up a chain reaction or defend yourself (or both!)|Attack: Hold to shoot with more power (twice) 04:48=Why should the moles get all the abuse?|Wacking a hog can be just as fun! A good|blow from this hammer will shave off one|third of a hog's health and plunge them|underground.|Attack: Activate 04:49=Resurrect your friends!|But beware that this also resurrects your foes.|Attack: Keep attack pressed to resurrect slowly|Up: Accelerate resurrection +04:50=Is someone hiding underground?|Dig them out with a drill strike!|Timer controls how far it will dig. +04:51=Get in a free shot by hurling a ball of mud.|Stings a bit, and knocks hogs back. +04:52=UNUSED +04:53=Go on an adventure through time and space,|while leaving your comrades to fight on alone.|Be prepared to return at any time,|or for Sudden Death or if they are all defeated.|Disclaimer. Does not function in Sudden Death,|if you are alone, or if you are a King. +04:54=INCOMPLETE +04:55=Spray a stream of sticky flakes.|Build bridges, bury enemies, seal off tunnels.|Be careful you don't get any on you! ; Game goal strings 05:00=Game Modes diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/build.xml --- a/project_files/Android-build/SDL-android-project/build.xml Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/build.xml Sun Oct 28 13:28:23 2012 +0100 @@ -1,67 +1,85 @@ - + - + It contains the path to the SDK. It should *NOT* be checked into + Version Control Systems. --> + - - + + + - + This contains project specific properties such as project target, and library + dependencies. Lower level build properties are stored in ant.properties + (or in .classpath for Eclipse projects). + + This file is an integral part of the build system for your + application and should be checked into Version Control Systems. --> + - - - - - - - - + + + + + + - - + + diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp --- a/project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/core/android/SDL_android.cpp Sun Oct 28 13:28:23 2012 +0100 @@ -1,30 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ - -#define org_hedgewars_hedgeroid org_hedgewars_hedgeroid - #include "SDL_config.h" #include "SDL_stdinc.h" +#ifdef __ANDROID__ + #include "SDL_android.h" extern "C" { @@ -33,7 +31,15 @@ #include "../../video/android/SDL_androidtouch.h" #include "../../video/android/SDL_androidvideo.h" -/* Impelemented in audio/android/SDL_androidaudio.c */ +#include +#define LOG_TAG "SDL_android" +//#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) +//#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +#define LOGI(...) do {} while (false) +#define LOGE(...) do {} while (false) + + +/* Implemented in audio/android/SDL_androidaudio.c */ extern void Android_RunAudioThread(); } // C @@ -49,6 +55,7 @@ *******************************************************************************/ static JNIEnv* mEnv = NULL; static JNIEnv* mAudioEnv = NULL; +static JavaVM* mJavaVM; // Main activity static jclass mActivityClass; @@ -63,7 +70,7 @@ // Accelerometer data storage static float fLastAccelerometer[3]; - +static bool bHasNewData; /******************************************************************************* Functions called by JNI @@ -72,6 +79,14 @@ // Library init extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv *env; + mJavaVM = vm; + LOGI("JNI_OnLoad called"); + if (mJavaVM->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) { + LOGE("Failed to get the environment using GetEnv()"); + return -1; + } + return JNI_VERSION_1_4; } @@ -81,7 +96,7 @@ __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()"); mEnv = env; - mActivityClass = cls; + mActivityClass = (jclass)env->NewGlobalRef(cls); midCreateGLContext = mEnv->GetStaticMethodID(mActivityClass, "createGLContext","(II)Z"); @@ -96,10 +111,13 @@ midAudioQuit = mEnv->GetStaticMethodID(mActivityClass, "audioQuit", "()V"); + bHasNewData = false; + if(!midCreateGLContext || !midFlipBuffers || !midAudioInit || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly"); } + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init() finished!"); } // Resize @@ -140,7 +158,8 @@ { fLastAccelerometer[0] = x; fLastAccelerometer[1] = y; - fLastAccelerometer[2] = z; + fLastAccelerometer[2] = z; + bHasNewData = true; } // Quit @@ -151,6 +170,26 @@ SDL_SendQuit(); } +// Pause +extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_nativePause( + JNIEnv* env, jclass cls) +{ + if (Android_Window) { + SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); + SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); + } +} + +// Resume +extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_nativeResume( + JNIEnv* env, jclass cls) +{ + if (Android_Window) { + SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); + SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0); + } +} + extern "C" void Java_org_hedgewars_hedgeroid_SDLActivity_nativeRunAudioThread( JNIEnv* env, jclass cls) { @@ -188,12 +227,20 @@ } } -extern "C" void Android_JNI_GetAccelerometerValues(float values[3]) +extern "C" SDL_bool Android_JNI_GetAccelerometerValues(float values[3]) { int i; - for (i = 0; i < 3; ++i) { - values[i] = fLastAccelerometer[i]; + SDL_bool retval = SDL_FALSE; + + if (bHasNewData) { + for (i = 0; i < 3; ++i) { + values[i] = fLastAccelerometer[i]; + } + bHasNewData = false; + retval = SDL_TRUE; } + + return retval; } // @@ -208,29 +255,48 @@ { int audioBufferFrames; + int status; + JNIEnv *env; + static bool isAttached = false; + status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4); + if(status < 0) { + LOGE("callback_handler: failed to get JNI environment, assuming native thread"); + status = mJavaVM->AttachCurrentThread(&env, NULL); + if(status < 0) { + LOGE("callback_handler: failed to attach current thread"); + return 0; + } + isAttached = true; + } + + __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device"); audioBuffer16Bit = is16Bit; audioBufferStereo = channelCount > 1; - audioBuffer = mEnv->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames); + audioBuffer = env->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames); if (audioBuffer == NULL) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!"); return 0; } - audioBuffer = mEnv->NewGlobalRef(audioBuffer); + audioBuffer = env->NewGlobalRef(audioBuffer); jboolean isCopy = JNI_FALSE; if (audioBuffer16Bit) { - audioBufferPinned = mEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy); - audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer); + audioBufferPinned = env->GetShortArrayElements((jshortArray)audioBuffer, &isCopy); + audioBufferFrames = env->GetArrayLength((jshortArray)audioBuffer); } else { - audioBufferPinned = mEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy); - audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer); + audioBufferPinned = env->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy); + audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer); } if (audioBufferStereo) { audioBufferFrames /= 2; } + + if (isAttached) { + mJavaVM->DetachCurrentThread(); + } return audioBufferFrames; } @@ -255,13 +321,334 @@ extern "C" void Android_JNI_CloseAudioDevice() { - mEnv->CallStaticVoidMethod(mActivityClass, midAudioQuit); + int status; + JNIEnv *env; + static bool isAttached = false; + status = mJavaVM->GetEnv((void **) &env, JNI_VERSION_1_4); + if(status < 0) { + LOGE("callback_handler: failed to get JNI environment, assuming native thread"); + status = mJavaVM->AttachCurrentThread(&env, NULL); + if(status < 0) { + LOGE("callback_handler: failed to attach current thread"); + return; + } + isAttached = true; + } + + env->CallStaticVoidMethod(mActivityClass, midAudioQuit); if (audioBuffer) { - mEnv->DeleteGlobalRef(audioBuffer); + env->DeleteGlobalRef(audioBuffer); audioBuffer = NULL; audioBufferPinned = NULL; } + + if (isAttached) { + mJavaVM->DetachCurrentThread(); + } +} + +// Test for an exception and call SDL_SetError with its detail if one occurs +static bool Android_JNI_ExceptionOccurred() +{ + jthrowable exception = mEnv->ExceptionOccurred(); + if (exception != NULL) { + jmethodID mid; + + // Until this happens most JNI operations have undefined behaviour + mEnv->ExceptionClear(); + + jclass exceptionClass = mEnv->GetObjectClass(exception); + jclass classClass = mEnv->FindClass("java/lang/Class"); + + mid = mEnv->GetMethodID(classClass, "getName", "()Ljava/lang/String;"); + jstring exceptionName = (jstring)mEnv->CallObjectMethod(exceptionClass, mid); + const char* exceptionNameUTF8 = mEnv->GetStringUTFChars(exceptionName, 0); + + mid = mEnv->GetMethodID(exceptionClass, "getMessage", "()Ljava/lang/String;"); + jstring exceptionMessage = (jstring)mEnv->CallObjectMethod(exception, mid); + + if (exceptionMessage != NULL) { + const char* exceptionMessageUTF8 = mEnv->GetStringUTFChars( + exceptionMessage, 0); + SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8); + mEnv->ReleaseStringUTFChars(exceptionMessage, exceptionMessageUTF8); + mEnv->DeleteLocalRef(exceptionMessage); + } else { + SDL_SetError("%s", exceptionNameUTF8); + } + + mEnv->ReleaseStringUTFChars(exceptionName, exceptionNameUTF8); + mEnv->DeleteLocalRef(exceptionName); + mEnv->DeleteLocalRef(classClass); + mEnv->DeleteLocalRef(exceptionClass); + mEnv->DeleteLocalRef(exception); + + return true; + } + + return false; +} + +static int Android_JNI_FileOpen(SDL_RWops* ctx) +{ + int result = 0; + + jmethodID mid; + jobject context; + jobject assetManager; + jobject inputStream; + jclass channels; + jobject readableByteChannel; + jstring fileNameJString; + + bool allocatedLocalFrame = false; + + if (mEnv->PushLocalFrame(16) < 0) { + SDL_SetError("Failed to allocate enough JVM local references"); + goto failure; + } else { + allocatedLocalFrame = true; + } + + fileNameJString = (jstring)ctx->hidden.androidio.fileName; + + // context = SDLActivity.getContext(); + mid = mEnv->GetStaticMethodID(mActivityClass, + "getContext","()Landroid/content/Context;"); + context = mEnv->CallStaticObjectMethod(mActivityClass, mid); + + // assetManager = context.getAssets(); + mid = mEnv->GetMethodID(mEnv->GetObjectClass(context), + "getAssets", "()Landroid/content/res/AssetManager;"); + assetManager = mEnv->CallObjectMethod(context, mid); + + // inputStream = assetManager.open(); + mid = mEnv->GetMethodID(mEnv->GetObjectClass(assetManager), + "open", "(Ljava/lang/String;)Ljava/io/InputStream;"); + inputStream = mEnv->CallObjectMethod(assetManager, mid, fileNameJString); + if (Android_JNI_ExceptionOccurred()) { + goto failure; + } + + ctx->hidden.androidio.inputStream = inputStream; + ctx->hidden.androidio.inputStreamRef = mEnv->NewGlobalRef(inputStream); + + // Despite all the visible documentation on [Asset]InputStream claiming + // that the .available() method is not guaranteed to return the entire file + // size, comments in /samples//ApiDemos/src/com/example/ ... + // android/apis/content/ReadAsset.java imply that Android's + // AssetInputStream.available() /will/ always return the total file size + + // size = inputStream.available(); + mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream), + "available", "()I"); + ctx->hidden.androidio.size = mEnv->CallIntMethod(inputStream, mid); + if (Android_JNI_ExceptionOccurred()) { + goto failure; + } + + // readableByteChannel = Channels.newChannel(inputStream); + channels = mEnv->FindClass("java/nio/channels/Channels"); + mid = mEnv->GetStaticMethodID(channels, + "newChannel", + "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;"); + readableByteChannel = mEnv->CallStaticObjectMethod( + channels, mid, inputStream); + if (Android_JNI_ExceptionOccurred()) { + goto failure; + } + + ctx->hidden.androidio.readableByteChannel = readableByteChannel; + ctx->hidden.androidio.readableByteChannelRef = + mEnv->NewGlobalRef(readableByteChannel); + + // Store .read id for reading purposes + mid = mEnv->GetMethodID(mEnv->GetObjectClass(readableByteChannel), + "read", "(Ljava/nio/ByteBuffer;)I"); + ctx->hidden.androidio.readMethod = mid; + + ctx->hidden.androidio.position = 0; + + if (false) { +failure: + result = -1; + + mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef); + + if(ctx->hidden.androidio.inputStreamRef != NULL) { + mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef); + } + } + + if (allocatedLocalFrame) { + mEnv->PopLocalFrame(NULL); + } + + return result; } +extern "C" int Android_JNI_FileOpen(SDL_RWops* ctx, + const char* fileName, const char*) +{ + if (!ctx) { + return -1; + } + + jstring fileNameJString = mEnv->NewStringUTF(fileName); + ctx->hidden.androidio.fileName = fileNameJString; + ctx->hidden.androidio.fileNameRef = mEnv->NewGlobalRef(fileNameJString); + ctx->hidden.androidio.inputStreamRef = NULL; + mEnv->DeleteLocalRef(fileNameJString); + + return Android_JNI_FileOpen(ctx); +} + +extern "C" size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, + size_t size, size_t maxnum) +{ + int bytesRemaining = size * maxnum; + int bytesRead = 0; + + jobject readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannel; + jmethodID readMethod = (jmethodID)ctx->hidden.androidio.readMethod; + jobject byteBuffer = mEnv->NewDirectByteBuffer(buffer, bytesRemaining); + + while (bytesRemaining > 0) { + // result = readableByteChannel.read(...); + int result = mEnv->CallIntMethod(readableByteChannel, readMethod, byteBuffer); + + if (Android_JNI_ExceptionOccurred()) { + mEnv->DeleteLocalRef(byteBuffer); + return 0; + } + + if (result < 0) { + break; + } + + bytesRemaining -= result; + bytesRead += result; + ctx->hidden.androidio.position += result; + } + + mEnv->DeleteLocalRef(byteBuffer); + + return bytesRead / size; +} + +extern "C" size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, + size_t size, size_t num) +{ + SDL_SetError("Cannot write to Android package filesystem"); + return 0; +} + +static int Android_JNI_FileClose(SDL_RWops* ctx, bool release) +{ + int result = 0; + + if (ctx) { + if (release) { + mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.fileNameRef); + } + + jobject inputStream = (jobject)ctx->hidden.androidio.inputStream; + + // inputStream.close(); + jmethodID mid = mEnv->GetMethodID(mEnv->GetObjectClass(inputStream), + "close", "()V"); + mEnv->CallVoidMethod(inputStream, mid); + mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.inputStreamRef); + mEnv->DeleteGlobalRef((jobject)ctx->hidden.androidio.readableByteChannelRef); + if (Android_JNI_ExceptionOccurred()) { + result = -1; + } + + if (release) { + SDL_FreeRW(ctx); + } + } + + return result; +} + + +extern "C" long Android_JNI_FileSeek(SDL_RWops* ctx, long offset, int whence) +{ + long newPosition; + + switch (whence) { + case RW_SEEK_SET: + newPosition = offset; + break; + case RW_SEEK_CUR: + newPosition = ctx->hidden.androidio.position + offset; + break; + case RW_SEEK_END: + newPosition = ctx->hidden.androidio.size + offset; + break; + default: + SDL_SetError("Unknown value for 'whence'"); + return -1; + } + if (newPosition < 0) { + newPosition = 0; + } + if (newPosition > ctx->hidden.androidio.size) { + newPosition = ctx->hidden.androidio.size; + } + + long movement = newPosition - ctx->hidden.androidio.position; + jobject inputStream = (jobject)ctx->hidden.androidio.inputStream; + + if (movement > 0) { + unsigned char buffer[1024]; + + // The easy case where we're seeking forwards + while (movement > 0) { + long amount = (long) sizeof (buffer); + if (amount > movement) { + amount = movement; + } + size_t result = Android_JNI_FileRead(ctx, buffer, 1, amount); + + if (result <= 0) { + // Failed to read/skip the required amount, so fail + return -1; + } + + movement -= result; + } + } else if (movement < 0) { + // We can't seek backwards so we have to reopen the file and seek + // forwards which obviously isn't very efficient + Android_JNI_FileClose(ctx, false); + Android_JNI_FileOpen(ctx); + Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET); + } + + ctx->hidden.androidio.position = newPosition; + + return ctx->hidden.androidio.position; +} + +extern "C" int Android_JNI_FileClose(SDL_RWops* ctx) +{ + return Android_JNI_FileClose(ctx, true); +} + +extern "C" int Android_JNI_getDensity(){ + jmethodID mid; + jint density; + //SDLActivity.getDensity() + mid = mEnv->GetStaticMethodID(mActivityClass, "getDensity", "()I"); + if(!mid) return 160; + density = mEnv->CallStaticFloatMethod(mActivityClass, mid); + return density; + +} + +#endif /* __ANDROID__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/jni/SDL/src/file/SDL_rwops.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/file/SDL_rwops.c Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,678 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* This file provides a general interface for SDL to read and write + data sources. It can easily be extended to files, memory, etc. +*/ + +#include "SDL_endian.h" +#include "SDL_rwops.h" + +#ifdef __APPLE__ +#include "cocoa/SDL_rwopsbundlesupport.h" +#endif /* __APPLE__ */ + +#ifdef ANDROID +#include "../core/android/SDL_android.h" +#include +#endif + +#ifdef __NDS__ +/* include libfat headers for fatInitDefault(). */ +#include +#endif /* __NDS__ */ + +#ifdef __WIN32__ + +/* Functions to read/write Win32 API file pointers */ +/* Will not use it on WinCE because stdio is buffered, it means + faster, and all stdio functions anyway are embedded in coredll.dll - + the main wince dll*/ + +#include "../core/windows/SDL_windows.h" + +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER 0xFFFFFFFF +#endif + +#define READAHEAD_BUFFER_SIZE 1024 + +static int SDLCALL +windows_file_open(SDL_RWops * context, const char *filename, const char *mode) +{ +#ifndef _WIN32_WCE + UINT old_error_mode; +#endif + HANDLE h; + DWORD r_right, w_right; + DWORD must_exist, truncate; + int a_mode; + + if (!context) + return -1; /* failed (invalid call) */ + + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ + context->hidden.windowsio.buffer.data = NULL; + context->hidden.windowsio.buffer.size = 0; + context->hidden.windowsio.buffer.left = 0; + + /* "r" = reading, file must exist */ + /* "w" = writing, truncate existing, file may not exist */ + /* "r+"= reading or writing, file must exist */ + /* "a" = writing, append file may not exist */ + /* "a+"= append + read, file may not exist */ + /* "w+" = read, write, truncate. file may not exist */ + + must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; + truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; + r_right = (SDL_strchr(mode, '+') != NULL + || must_exist) ? GENERIC_READ : 0; + a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; + w_right = (a_mode || SDL_strchr(mode, '+') + || truncate) ? GENERIC_WRITE : 0; + + if (!r_right && !w_right) /* inconsistent mode */ + return -1; /* failed (invalid call) */ + + context->hidden.windowsio.buffer.data = + (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); + if (!context->hidden.windowsio.buffer.data) { + SDL_OutOfMemory(); + return -1; + } +#ifdef _WIN32_WCE + { + LPTSTR tstr = WIN_UTF8ToString(filename); + h = CreateFile(tstr, (w_right | r_right), + (w_right) ? 0 : FILE_SHARE_READ, NULL, + (must_exist | truncate | a_mode), + FILE_ATTRIBUTE_NORMAL, NULL); + SDL_free(tstr); + } +#else + /* Do not open a dialog box if failure */ + old_error_mode = + SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); + + { + LPTSTR tstr = WIN_UTF8ToString(filename); + h = CreateFile(tstr, (w_right | r_right), + (w_right) ? 0 : FILE_SHARE_READ, NULL, + (must_exist | truncate | a_mode), + FILE_ATTRIBUTE_NORMAL, NULL); + SDL_free(tstr); + } + + /* restore old behavior */ + SetErrorMode(old_error_mode); +#endif /* _WIN32_WCE */ + + if (h == INVALID_HANDLE_VALUE) { + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; + SDL_SetError("Couldn't open %s", filename); + return -2; /* failed (CreateFile) */ + } + context->hidden.windowsio.h = h; + context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE; + + return 0; /* ok */ +} + +static long SDLCALL +windows_file_seek(SDL_RWops * context, long offset, int whence) +{ + DWORD windowswhence; + long file_pos; + + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + SDL_SetError("windows_file_seek: invalid context/file not opened"); + return -1; + } + + /* FIXME: We may be able to satisfy the seek within buffered data */ + if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) { + offset -= (long)context->hidden.windowsio.buffer.left; + } + context->hidden.windowsio.buffer.left = 0; + + switch (whence) { + case RW_SEEK_SET: + windowswhence = FILE_BEGIN; + break; + case RW_SEEK_CUR: + windowswhence = FILE_CURRENT; + break; + case RW_SEEK_END: + windowswhence = FILE_END; + break; + default: + SDL_SetError("windows_file_seek: Unknown value for 'whence'"); + return -1; + } + + file_pos = + SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence); + + if (file_pos != INVALID_SET_FILE_POINTER) + return file_pos; /* success */ + + SDL_Error(SDL_EFSEEK); + return -1; /* error */ +} + +static size_t SDLCALL +windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +{ + size_t total_need; + size_t total_read = 0; + size_t read_ahead; + DWORD byte_read; + + total_need = size * maxnum; + + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE + || !total_need) + return 0; + + if (context->hidden.windowsio.buffer.left > 0) { + void *data = (char *) context->hidden.windowsio.buffer.data + + context->hidden.windowsio.buffer.size - + context->hidden.windowsio.buffer.left; + read_ahead = + SDL_min(total_need, context->hidden.windowsio.buffer.left); + SDL_memcpy(ptr, data, read_ahead); + context->hidden.windowsio.buffer.left -= read_ahead; + + if (read_ahead == total_need) { + return maxnum; + } + ptr = (char *) ptr + read_ahead; + total_need -= read_ahead; + total_read += read_ahead; + } + + if (total_need < READAHEAD_BUFFER_SIZE) { + if (!ReadFile + (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, + READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { + SDL_Error(SDL_EFREAD); + return 0; + } + read_ahead = SDL_min(total_need, (int) byte_read); + SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead); + context->hidden.windowsio.buffer.size = byte_read; + context->hidden.windowsio.buffer.left = byte_read - read_ahead; + total_read += read_ahead; + } else { + if (!ReadFile + (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { + SDL_Error(SDL_EFREAD); + return 0; + } + total_read += byte_read; + } + return (total_read / size); +} + +static size_t SDLCALL +windows_file_write(SDL_RWops * context, const void *ptr, size_t size, + size_t num) +{ + + size_t total_bytes; + DWORD byte_written; + size_t nwritten; + + total_bytes = size * num; + + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE + || total_bytes <= 0 || !size) + return 0; + + if (context->hidden.windowsio.buffer.left) { + SetFilePointer(context->hidden.windowsio.h, + -(LONG)context->hidden.windowsio.buffer.left, NULL, + FILE_CURRENT); + context->hidden.windowsio.buffer.left = 0; + } + + /* if in append mode, we must go to the EOF before write */ + if (context->hidden.windowsio.append) { + if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) == + INVALID_SET_FILE_POINTER) { + SDL_Error(SDL_EFWRITE); + return 0; + } + } + + if (!WriteFile + (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { + SDL_Error(SDL_EFWRITE); + return 0; + } + + nwritten = byte_written / size; + return nwritten; +} + +static int SDLCALL +windows_file_close(SDL_RWops * context) +{ + + if (context) { + if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) { + CloseHandle(context->hidden.windowsio.h); + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ + } + if (context->hidden.windowsio.buffer.data) { + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; + } + SDL_FreeRW(context); + } + return (0); +} +#endif /* __WIN32__ */ + +#ifdef HAVE_STDIO_H + +/* Functions to read/write stdio file pointers */ + +static long SDLCALL +stdio_seek(SDL_RWops * context, long offset, int whence) +{ + if (fseek(context->hidden.stdio.fp, offset, whence) == 0) { + return (ftell(context->hidden.stdio.fp)); + } else { + SDL_Error(SDL_EFSEEK); + return (-1); + } +} + +static size_t SDLCALL +stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +{ + size_t nread; + + nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); + if (nread == 0 && ferror(context->hidden.stdio.fp)) { + SDL_Error(SDL_EFREAD); + } + return (nread); +} + +static size_t SDLCALL +stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) +{ + size_t nwrote; + + nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); + if (nwrote == 0 && ferror(context->hidden.stdio.fp)) { + SDL_Error(SDL_EFWRITE); + } + return (nwrote); +} + +static int SDLCALL +stdio_close(SDL_RWops * context) +{ + int status = 0; + if (context) { + if (context->hidden.stdio.autoclose) { + /* WARNING: Check the return value here! */ + if (fclose(context->hidden.stdio.fp) != 0) { + SDL_Error(SDL_EFWRITE); + status = -1; + } + } + SDL_FreeRW(context); + } + return status; +} +#endif /* !HAVE_STDIO_H */ + +/* Functions to read/write memory pointers */ + +static long SDLCALL +mem_seek(SDL_RWops * context, long offset, int whence) +{ + Uint8 *newpos; + + switch (whence) { + case RW_SEEK_SET: + newpos = context->hidden.mem.base + offset; + break; + case RW_SEEK_CUR: + newpos = context->hidden.mem.here + offset; + break; + case RW_SEEK_END: + newpos = context->hidden.mem.stop + offset; + break; + default: + SDL_SetError("Unknown value for 'whence'"); + return (-1); + } + if (newpos < context->hidden.mem.base) { + newpos = context->hidden.mem.base; + } + if (newpos > context->hidden.mem.stop) { + newpos = context->hidden.mem.stop; + } + context->hidden.mem.here = newpos; + return (long)(context->hidden.mem.here - context->hidden.mem.base); +} + +static size_t SDLCALL +mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +{ + size_t total_bytes; + size_t mem_available; + + total_bytes = (maxnum * size); + if ((maxnum <= 0) || (size <= 0) + || ((total_bytes / maxnum) != (size_t) size)) { + return 0; + } + + mem_available = (context->hidden.mem.stop - context->hidden.mem.here); + if (total_bytes > mem_available) { + total_bytes = mem_available; + } + + SDL_memcpy(ptr, context->hidden.mem.here, total_bytes); + context->hidden.mem.here += total_bytes; + + return (total_bytes / size); +} + +static size_t SDLCALL +mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) +{ + if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) { + num = (context->hidden.mem.stop - context->hidden.mem.here) / size; + } + SDL_memcpy(context->hidden.mem.here, ptr, num * size); + context->hidden.mem.here += num * size; + return (num); +} + +static size_t SDLCALL +mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) +{ + SDL_SetError("Can't write to read-only memory"); + return (-1); +} + +static int SDLCALL +mem_close(SDL_RWops * context) +{ + if (context) { + SDL_FreeRW(context); + } + return (0); +} + + +/* Functions to create SDL_RWops structures from various data sources */ + +SDL_RWops * +SDL_RWFromFile(const char *file, const char *mode) +{ + SDL_RWops *rwops = NULL; +#ifdef HAVE_STDIO_H + FILE *fp = NULL; +#endif + if (!file || !*file || !mode || !*mode) { + SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); + return NULL; + } +#if defined(ANDROIDXELI) //Xeli: dont use the android assets, TODO create fallback system + rwops = SDL_AllocRW(); + if (!rwops) + return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ + if (Android_JNI_FileOpen(rwops, file, mode) < 0) { + SDL_FreeRW(rwops); + return NULL; + } + rwops->seek = Android_JNI_FileSeek; + rwops->read = Android_JNI_FileRead; + rwops->write = Android_JNI_FileWrite; + rwops->close = Android_JNI_FileClose; + +#elif defined(__WIN32__) + rwops = SDL_AllocRW(); + if (!rwops) + return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ + if (windows_file_open(rwops, file, mode) < 0) { + SDL_FreeRW(rwops); + return NULL; + } + rwops->seek = windows_file_seek; + rwops->read = windows_file_read; + rwops->write = windows_file_write; + rwops->close = windows_file_close; + +#elif HAVE_STDIO_H + #ifdef __APPLE__ + fp = SDL_OpenFPFromBundleOrFallback(file, mode); + #else + fp = fopen(file, mode); + #endif + if (fp == NULL) { + SDL_SetError("Couldn't open %s", file); + } else { + rwops = SDL_RWFromFP(fp, 1); + } +#else + SDL_SetError("SDL not compiled with stdio support"); +#endif /* !HAVE_STDIO_H */ + + return (rwops); +} + +#ifdef HAVE_STDIO_H +SDL_RWops * +SDL_RWFromFP(FILE * fp, SDL_bool autoclose) +{ + SDL_RWops *rwops = NULL; + +#if 0 +/*#ifdef __NDS__*/ + /* set it up so we can use stdio file function */ + fatInitDefault(); + printf("called fatInitDefault()"); +#endif /* __NDS__ */ + + rwops = SDL_AllocRW(); + if (rwops != NULL) { + rwops->seek = stdio_seek; + rwops->read = stdio_read; + rwops->write = stdio_write; + rwops->close = stdio_close; + rwops->hidden.stdio.fp = fp; + rwops->hidden.stdio.autoclose = autoclose; + } + return (rwops); +} +#else +SDL_RWops * +SDL_RWFromFP(void * fp, SDL_bool autoclose) +{ + SDL_SetError("SDL not compiled with stdio support"); + return NULL; +} +#endif /* HAVE_STDIO_H */ + +SDL_RWops * +SDL_RWFromMem(void *mem, int size) +{ + SDL_RWops *rwops; + + rwops = SDL_AllocRW(); + if (rwops != NULL) { + rwops->seek = mem_seek; + rwops->read = mem_read; + rwops->write = mem_write; + rwops->close = mem_close; + rwops->hidden.mem.base = (Uint8 *) mem; + rwops->hidden.mem.here = rwops->hidden.mem.base; + rwops->hidden.mem.stop = rwops->hidden.mem.base + size; + } + return (rwops); +} + +SDL_RWops * +SDL_RWFromConstMem(const void *mem, int size) +{ + SDL_RWops *rwops; + + rwops = SDL_AllocRW(); + if (rwops != NULL) { + rwops->seek = mem_seek; + rwops->read = mem_read; + rwops->write = mem_writeconst; + rwops->close = mem_close; + rwops->hidden.mem.base = (Uint8 *) mem; + rwops->hidden.mem.here = rwops->hidden.mem.base; + rwops->hidden.mem.stop = rwops->hidden.mem.base + size; + } + return (rwops); +} + +SDL_RWops * +SDL_AllocRW(void) +{ + SDL_RWops *area; + + area = (SDL_RWops *) SDL_malloc(sizeof *area); + if (area == NULL) { + SDL_OutOfMemory(); + } + return (area); +} + +void +SDL_FreeRW(SDL_RWops * area) +{ + SDL_free(area); +} + +/* Functions for dynamically reading and writing endian-specific values */ + +Uint16 +SDL_ReadLE16(SDL_RWops * src) +{ + Uint16 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE16(value)); +} + +Uint16 +SDL_ReadBE16(SDL_RWops * src) +{ + Uint16 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE16(value)); +} + +Uint32 +SDL_ReadLE32(SDL_RWops * src) +{ + Uint32 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE32(value)); +} + +Uint32 +SDL_ReadBE32(SDL_RWops * src) +{ + Uint32 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE32(value)); +} + +Uint64 +SDL_ReadLE64(SDL_RWops * src) +{ + Uint64 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapLE64(value)); +} + +Uint64 +SDL_ReadBE64(SDL_RWops * src) +{ + Uint64 value; + + SDL_RWread(src, &value, (sizeof value), 1); + return (SDL_SwapBE64(value)); +} + +size_t +SDL_WriteLE16(SDL_RWops * dst, Uint16 value) +{ + value = SDL_SwapLE16(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +size_t +SDL_WriteBE16(SDL_RWops * dst, Uint16 value) +{ + value = SDL_SwapBE16(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +size_t +SDL_WriteLE32(SDL_RWops * dst, Uint32 value) +{ + value = SDL_SwapLE32(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +size_t +SDL_WriteBE32(SDL_RWops * dst, Uint32 value) +{ + value = SDL_SwapBE32(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +size_t +SDL_WriteLE64(SDL_RWops * dst, Uint64 value) +{ + value = SDL_SwapLE64(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +size_t +SDL_WriteBE64(SDL_RWops * dst, Uint64 value) +{ + value = SDL_SwapBE64(value); + return (SDL_RWwrite(dst, &value, (sizeof value), 1)); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidkeyboard.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/jni/SDL/src/video/android/SDL_androidkeyboard.c Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,185 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_ANDROID + +#include + +#include "../../events/SDL_events_c.h" + +#include "SDL_androidkeyboard.h" +#include "SDL_keycode.h" + + +void Android_InitKeyboard() +{ + SDL_Keycode keymap[SDL_NUM_SCANCODES]; + + /* Add default scancode to key mapping */ + SDL_GetDefaultKeymap(keymap); + SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); +} + +static SDL_Scancode Android_Keycodes[] = { + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */ + SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */ + SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENDCALL */ + SDL_SCANCODE_0, /* AKEYCODE_0 */ + SDL_SCANCODE_1, /* AKEYCODE_1 */ + SDL_SCANCODE_2, /* AKEYCODE_2 */ + SDL_SCANCODE_3, /* AKEYCODE_3 */ + SDL_SCANCODE_4, /* AKEYCODE_4 */ + SDL_SCANCODE_5, /* AKEYCODE_5 */ + SDL_SCANCODE_6, /* AKEYCODE_6 */ + SDL_SCANCODE_7, /* AKEYCODE_7 */ + SDL_SCANCODE_8, /* AKEYCODE_8 */ + SDL_SCANCODE_9, /* AKEYCODE_9 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_STAR */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_POUND */ + SDL_SCANCODE_UP, /* AKEYCODE_DPAD_UP */ + SDL_SCANCODE_DOWN, /* AKEYCODE_DPAD_DOWN */ + SDL_SCANCODE_LEFT, /* AKEYCODE_DPAD_LEFT */ + SDL_SCANCODE_RIGHT, /* AKEYCODE_DPAD_RIGHT */ + SDL_SCANCODE_SELECT, /* AKEYCODE_DPAD_CENTER */ + SDL_SCANCODE_VOLUMEUP, /* AKEYCODE_VOLUME_UP */ + SDL_SCANCODE_VOLUMEDOWN, /* AKEYCODE_VOLUME_DOWN */ + SDL_SCANCODE_POWER, /* AKEYCODE_POWER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CAMERA */ + SDL_SCANCODE_CLEAR, /* AKEYCODE_CLEAR */ + SDL_SCANCODE_A, /* AKEYCODE_A */ + SDL_SCANCODE_B, /* AKEYCODE_B */ + SDL_SCANCODE_C, /* AKEYCODE_C */ + SDL_SCANCODE_D, /* AKEYCODE_D */ + SDL_SCANCODE_E, /* AKEYCODE_E */ + SDL_SCANCODE_F, /* AKEYCODE_F */ + SDL_SCANCODE_G, /* AKEYCODE_G */ + SDL_SCANCODE_H, /* AKEYCODE_H */ + SDL_SCANCODE_I, /* AKEYCODE_I */ + SDL_SCANCODE_J, /* AKEYCODE_J */ + SDL_SCANCODE_K, /* AKEYCODE_K */ + SDL_SCANCODE_L, /* AKEYCODE_L */ + SDL_SCANCODE_M, /* AKEYCODE_M */ + SDL_SCANCODE_N, /* AKEYCODE_N */ + SDL_SCANCODE_O, /* AKEYCODE_O */ + SDL_SCANCODE_P, /* AKEYCODE_P */ + SDL_SCANCODE_Q, /* AKEYCODE_Q */ + SDL_SCANCODE_R, /* AKEYCODE_R */ + SDL_SCANCODE_S, /* AKEYCODE_S */ + SDL_SCANCODE_T, /* AKEYCODE_T */ + SDL_SCANCODE_U, /* AKEYCODE_U */ + SDL_SCANCODE_V, /* AKEYCODE_V */ + SDL_SCANCODE_W, /* AKEYCODE_W */ + SDL_SCANCODE_X, /* AKEYCODE_X */ + SDL_SCANCODE_Y, /* AKEYCODE_Y */ + SDL_SCANCODE_Z, /* AKEYCODE_Z */ + SDL_SCANCODE_COMMA, /* AKEYCODE_COMMA */ + SDL_SCANCODE_PERIOD, /* AKEYCODE_PERIOD */ + SDL_SCANCODE_LALT, /* AKEYCODE_ALT_LEFT */ + SDL_SCANCODE_RALT, /* AKEYCODE_ALT_RIGHT */ + SDL_SCANCODE_LSHIFT, /* AKEYCODE_SHIFT_LEFT */ + SDL_SCANCODE_RSHIFT, /* AKEYCODE_SHIFT_RIGHT */ + SDL_SCANCODE_TAB, /* AKEYCODE_TAB */ + SDL_SCANCODE_SPACE, /* AKEYCODE_SPACE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SYM */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_EXPLORER */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_ENVELOPE */ + SDL_SCANCODE_RETURN, /* AKEYCODE_ENTER */ + SDL_SCANCODE_BACKSPACE, /* AKEYCODE_DEL */ + SDL_SCANCODE_GRAVE, /* AKEYCODE_GRAVE */ + SDL_SCANCODE_MINUS, /* AKEYCODE_MINUS */ + SDL_SCANCODE_EQUALS, /* AKEYCODE_EQUALS */ + SDL_SCANCODE_LEFTBRACKET, /* AKEYCODE_LEFT_BRACKET */ + SDL_SCANCODE_RIGHTBRACKET, /* AKEYCODE_RIGHT_BRACKET */ + SDL_SCANCODE_BACKSLASH, /* AKEYCODE_BACKSLASH */ + SDL_SCANCODE_SEMICOLON, /* AKEYCODE_SEMICOLON */ + SDL_SCANCODE_APOSTROPHE, /* AKEYCODE_APOSTROPHE */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SLASH */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_AT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NUM */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_HEADSETHOOK */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_FOCUS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PLUS */ + SDL_SCANCODE_MENU, /* AKEYCODE_MENU */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_NOTIFICATION */ + SDL_SCANCODE_AC_SEARCH, /* AKEYCODE_SEARCH */ + SDL_SCANCODE_AUDIOPLAY, /* AKEYCODE_MEDIA_PLAY_PAUSE */ + SDL_SCANCODE_AUDIOSTOP, /* AKEYCODE_MEDIA_STOP */ + SDL_SCANCODE_AUDIONEXT, /* AKEYCODE_MEDIA_NEXT */ + SDL_SCANCODE_AUDIOPREV, /* AKEYCODE_MEDIA_PREVIOUS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_REWIND */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_MEDIA_FAST_FORWARD */ + SDL_SCANCODE_MUTE, /* AKEYCODE_MUTE */ + SDL_SCANCODE_PAGEUP, /* AKEYCODE_PAGE_UP */ + SDL_SCANCODE_PAGEDOWN, /* AKEYCODE_PAGE_DOWN */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_PICTSYMBOLS */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SWITCH_CHARSET */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_A */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_B */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_C */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_X */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Y */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_Z */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R1 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_L2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_R2 */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBL */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_THUMBR */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_START */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_SELECT */ + SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */ +}; + +static SDL_Scancode +TranslateKeycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(Android_Keycodes)) { + scancode = Android_Keycodes[keycode]; + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode); + } + __android_log_print(ANDROID_LOG_INFO, "SDLXELI", "keycode %d scancode %d", keycode, scancode); + return scancode; +} + +int +Android_OnKeyDown(int keycode) +{ + return SDL_SendKeyboardKey(SDL_PRESSED, TranslateKeycode(keycode)); +} + +int +Android_OnKeyUp(int keycode) +{ + return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode)); +} + +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + +/* vi: set ts=4 sw=4 expandtab: */ diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/jni/SDL_mixer/Android.mk --- a/project_files/Android-build/SDL-android-project/jni/SDL_mixer/Android.mk Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/jni/SDL_mixer/Android.mk Sun Oct 28 13:28:23 2012 +0100 @@ -5,14 +5,14 @@ LOCAL_MODULE := SDL_mixer LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/../../../../../misc/libtremor \ - $(LOCAL_PATH)/.. \ + $(LOCAL_PATH)/../../../../../misc/libtremor \ + $(LOCAL_PATH)/.. \ $(LOCAL_PATH)/../SDL/include \ $(LOCAL_PATH)/../mikmod/include \ LOCAL_CFLAGS := -DWAV_MUSIC -DOGG_MUSIC -DOGG_USE_TREMOR -DMOD_MUSIC -LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c %/fluidsynth.c, $(wildcard $(LOCAL_PATH)/*.c))) +LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) LOCAL_SHARED_LIBRARIES := SDL mikmod LOCAL_STATIC_LIBRARIES := tremor diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/jni/SDL_ttf/Android.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/jni/SDL_ttf/Android.mk Sun Oct 28 13:28:23 2012 +0100 @@ -0,0 +1,17 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := SDL_ttf + +LOCAL_CFLAGS := -I$(LOCAL_PATH)/../SDL/include -I$(LOCAL_PATH)/../../../../../misc/libfreetype/include + +LOCAL_SRC_FILES := SDL_ttf.c + +LOCAL_SHARED_LIBRARIES := SDL + +LOCAL_STATIC_LIBRARIES := freetype + +LOCAL_LDLIBS := -lz + +include $(BUILD_SHARED_LIBRARY) diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/libs/android-support-v13.jar Binary file project_files/Android-build/SDL-android-project/libs/android-support-v13.jar has changed diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/res/layout/background.xml --- a/project_files/Android-build/SDL-android-project/res/layout/background.xml Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/res/layout/background.xml Sun Oct 28 13:28:23 2012 +0100 @@ -3,6 +3,6 @@ \ No newline at end of file diff -r 41b0a9955c47 -r ddcdedd3330b project_files/Android-build/SDL-android-project/res/layout/download_confirmdialog.xml --- a/project_files/Android-build/SDL-android-project/res/layout/download_confirmdialog.xml Thu Nov 24 13:44:30 2011 +0100 +++ b/project_files/Android-build/SDL-android-project/res/layout/download_confirmdialog.xml Sun Oct 28 13:28:23 2012 +0100 @@ -2,7 +2,7 @@