# HG changeset patch # User koda # Date 1356407122 -3600 # Node ID aaefa587e2771fd504099d0c3ec0428d85d68866 # Parent d24257910f8dd300610d5ae297ca16b28a6b21b9# Parent 03684c6676649233ac2bcc30694ecce373983968 update branch with default diff -r d24257910f8d -r aaefa587e277 .hgignore --- a/.hgignore Sun Dec 02 00:03:16 2012 +0100 +++ b/.hgignore Tue Dec 25 04:45:22 2012 +0100 @@ -30,6 +30,7 @@ glob:misc/liblua/Xcode/build/ glob:misc/libfreetype/Xcode/build/ glob:misc/libfreetype/Xcode-iOS/build/ +glob:misc/physfs/Xcode/build/ glob:moc_*.cxx_parameters relre:^release\/ glob:*.log @@ -57,4 +58,5 @@ glob:hedgewars-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release glob:*.depends glob:tools/build_windows_koda.bat +glob:share/hedgewars/Data/misc/hwengine.desktop diff -r d24257910f8d -r aaefa587e277 CMakeLists.txt --- a/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,19 +1,20 @@ project(hedgewars) #initialise cmake environment -cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) -cmake_policy(VERSION 2.6) -FOREACH(hwpolicy CMP0003 CMP0012 CMP0017) - IF(POLICY ${hwpolicy}) - CMAKE_POLICY(SET ${hwpolicy} NEW) - ENDIF() -ENDFOREACH() +cmake_minimum_required(VERSION 2.6.0) +foreach(hwpolicy CMP0003 CMP0012 CMP0017) + if(POLICY ${hwpolicy}) + cmake_policy(SET ${hwpolicy} NEW) + endif() +endforeach() #use available modules, fallback to ours if not present (CMP0017 helps) set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules") -#set some default values -option(NOREVISION "Build Hedgewars without revision information" OFF) +#usually this is set at release time +option(NOREVISION "Build Hedgewars without revision information [default: off]" OFF) + +#set other 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) @@ -25,39 +26,40 @@ option(ANDROID "Enable Android build [default: off]" OFF) option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF) -option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF) option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF) +set(FPFLAGS "" CACHE STRING "Additional Freepascal flags" FORCE) +set(GHFLAGS "" CACHE STRING "Additional Haskell flags" FORCE) #detect Mercurial revision (if present) -IF(NOT NOREVISION) +if(NOT NOREVISION) set(default_build_type "DEBUG") set(version_suffix "-development_version") set(HW_DEV true) - FIND_PROGRAM(HGCOMMAND hg) - IF(HGCOMMAND AND (EXISTS ${CMAKE_SOURCE_DIR}/.hg)) + find_program(HGCOMMAND hg) + if(HGCOMMAND AND (EXISTS ${CMAKE_SOURCE_DIR}/.hg)) execute_process(COMMAND ${HGCOMMAND} identify -in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE internal_version ERROR_QUIET ) #check local repo status - STRING(REGEX REPLACE "[^+]" "" HGCHANGED ${internal_version}) + string(REGEX REPLACE "[^+]" "" HGCHANGED ${internal_version}) - STRING(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version}) - STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version}) + string(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version}) + string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version}) - MESSAGE(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}") - IF(HGCHANGED) + message(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}") + if(HGCHANGED) MESSAGE(WARNING "Notice: you have uncommitted changes in your repository") - ENDIF() + endif() set(version_suffix "-${revision_number}${HGCHANGED}") - ENDIF() -ELSE(NOT NOREVISION) + endif() +else(NOT NOREVISION) set(default_build_type "RELEASE") set(HWDEV false) - MESSAGE(STATUS "Building distributable version") -ENDIF(NOT NOREVISION) + message(STATUS "Building distributable version") +endif(NOT NOREVISION) #versioning @@ -79,19 +81,35 @@ endif() -#bundle .app setup -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") +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +if(UNIX AND NOT APPLE) + set(target_binary_install_dir "bin") + set(target_library_install_dir "lib") + if(DEFINED DATA_INSTALL_DIR) + set(SHAREPATH "${DATA_INSTALL_DIR}") + else() + set(SHAREPATH "share/hedgewars/") + endif() else() - set(target_dir "bin") + set(target_binary_install_dir "./") + + if(APPLE) + set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/") + set(SHAREPATH "../Resources/") + set(target_library_install_dir "../Frameworks/") + else() + if(WIN32) + set(target_library_install_dir "./") + set(SHAREPATH "./") + set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/") + link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin") + endif(WIN32) + endif() endif() + if(APPLE) set(CMAKE_FIND_FRAMEWORK "FIRST") @@ -120,12 +138,12 @@ endif() #lower systems don't have enough processing power anyway - if (minimum_macosx_version LESS "10.4") + if (minimum_macosx_version VERSION_LESS "10.4") message(FATAL_ERROR "Hedgewars is not supported on Mac OS X pre-10.4") 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") + if(current_macosx_version VERSION_EQUAL "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") @@ -135,7 +153,7 @@ #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(current_macosx_version VERSION_LESS "10.6") if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") set(CMAKE_OSX_ARCHITECTURES "ppc7400") else() @@ -148,8 +166,8 @@ #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") + if(NOT ${minimum_macosx_version} VERSION_EQUAL ${current_macosx_version}) + if(minimum_macosx_version VERSION_EQUAL "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") @@ -164,8 +182,10 @@ #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 C compiler: ${CMAKE_C_COMPILER}") - message(STATUS "Target system: Mac OS X ${minimum_macosx_version} for architecture(s): ${CMAKE_OSX_ARCHITECTURES}") + #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3 + if(NOT NOVIDEOREC AND ${minimum_macosx_version} VERSION_LESS "10.6") + set(WARNING "Video recording support before OS X 10.6 is experimental") + endif() endif(APPLE) @@ -173,7 +193,7 @@ 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) + set (CMAKE_BUILD_TYPE ${default_build_type} CACHE STRING "Choose the build type, options are: Debug Release." FORCE) message (STATUS "Unknown build type, using default (${default_build_type})") endif () else (CMAKE_BUILD_TYPE) @@ -198,45 +218,39 @@ #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") + set(cmake_version "${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}") + if(cmake_version VERSION_LESS "2.8") + message(WARNING "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() -set(pascal_flags ${fpflags_parsed} "-vm4079,4080,4081" "-B" "-FE../bin" "-Cs2000000" "-vewnq" "-dDEBUGFILE" ${pascal_flags}) +set(pascal_flags ${fpflags_parsed} # user flags + "-vm4079,4080,4081" # fpc output format + "-B" # compile all units + "-FE${PROJECT_BINARY_DIR}/bin" # fpc output directory + "-Fl${PROJECT_BINARY_DIR}/bin" # fpc linking directory + "-Cs2000000" # stack size + "-vewnq" # fpc output verbosity + "-dDEBUGFILE" # macro for engine output + ${pascal_flags} # adding to list + ) set(haskell_flags "-O2" ${ghflags_parsed} ${haskell_flags}) #get BUILD_TYPE and enable/disable optimisation +message(STATUS "Using ${CMAKE_BUILD_TYPE} configuration") 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(pascal_flags "-Os" "-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/) -else() - set(SHAREPATH share/hedgewars/) -endif() -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) -if(WIN32) - set(CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/misc/winutils/") - link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin") -endif(WIN32) - - #Haskell compiler discovery (for server and engine in c) if((NOT NOSERVER) OR NOPASCAL) if(GHC) @@ -277,8 +291,12 @@ endif() -#physfs library +#physfs library (static on unix, dll on win32) add_subdirectory(misc/physfs) +if(NOT WIN32) + set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags}) +endif() + #frontend library add_subdirectory(project_files/frontlib) @@ -331,6 +349,7 @@ 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_NSIS_EXECUTABLES_DIRECTORY "${target_binary_install_dir}") set(CPACK_GENERATOR "ZIP;NSIS") set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hedgewars") else(WIN32 AND NOT UNIX) diff -r d24257910f8d -r aaefa587e277 INSTALL --- a/INSTALL Sun Dec 02 00:03:16 2012 +0100 +++ b/INSTALL Tue Dec 25 04:45:22 2012 +0100 @@ -1,13 +1,14 @@ To compile and install you need: - - Qt >= 4.5 - - FreePascal >= 2.2.4 + - CMake >= 2.6.0 + - FreePascal >= 2.2.0 + - Qt >= 4.5.0 - SDL >= 1.2.5 - SDL_net >= 1.2.5 - SDL_mixer >= 1.2 - SDL_image >= 1.2 - SDL_ttf >= 2.0 - - CMake >= 2.6.0 - Lua >= 5.1.0 + - Physfs >= 2.1 For server: - Glasgow Haskell Compiler >= 6.10 - bytestring-show package @@ -16,6 +17,11 @@ For videorecording: - FFmpeg or LibAV - GLUT (when SDL < 2) +For compressed screenshots: + - libpng + +Lua will be automatically built if not found. + 1. Configure: $ cmake . @@ -23,8 +29,12 @@ $ cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="install_prefix" \ -DDATA_INSTALL_DIR="data_dir" -DNOSERVER=1 . -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" +Add -DNOSERVER=0 to compile net server (remember to check out the additional +dependencies with the hedgewars-server.cabal configuration file. If you have +Qt installed but it is not found, you can set it up with +-DQT_QMAKE_EXECUTABLE="path_to_qmake". +To get a glimpse of the main configuration options, you may use this command +`cat CMakeLists.txt | grep option` 2. Compile: $ make @@ -34,3 +44,4 @@ That's all! Enjoy! + diff -r d24257910f8d -r aaefa587e277 QTfrontend/AutoUpdater.h --- a/QTfrontend/AutoUpdater.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/AutoUpdater.h Tue Dec 25 04:45:22 2012 +0100 @@ -11,6 +11,7 @@ virtual ~AutoUpdater(); virtual void checkForUpdates() = 0; + virtual void checkForUpdatesNow() = 0; }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -11,15 +11,16 @@ set(QT_USE_QTMAIN TRUE) find_package(Qt4 REQUIRED) -if (NOT CROSSAPPLE) - include(${QT_USE_FILE}) -endif() +include(${QT_USE_FILE}) find_package(SDL REQUIRED) #video in SDLInteraction find_package(SDL_mixer REQUIRED) #audio in SDLInteraction find_package(SDL_net REQUIRED) #network frontlib if(NOT NOVIDEOREC) find_package(FFMPEG) + if(${FFMPEG_FOUND}) + add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) + endif() endif() include_directories(.) @@ -35,30 +36,24 @@ include_directories(${FFMPEG_INCLUDE_DIR}) include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/src) include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/extras) -include_directories(${CMAKE_SOURCE_DIR}/project_files/frontlib) if(UNIX) # HACK: in freebsd cannot find iconv.h included via SDL.h include_directories("/usr/local/include") endif(UNIX) - -if(WIN32 AND NOT UNIX) - set(HEDGEWARS_BINDIR ".") - set(HEDGEWARS_DATADIR "../share/") - add_definitions(-DUSE_XFIRE) +#directory for resources, relative to the one above on certain platforms/configurations +if(DEFINED DATA_INSTALL_DIR OR WIN32 OR APPLE) + set(HEDGEWARS_DATADIR ${SHAREPATH}) else() - set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}) - if(DEFINED DATA_INSTALL_DIR) - set(HEDGEWARS_DATADIR ${DATA_INSTALL_DIR}) - else() - set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/) - endif() - #only the cocoa version of qt supports building 64 bit apps - if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA)) - message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X") - endif() + set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/${SHAREPATH}/) endif() +#only the cocoa version of qt supports building 64 bit apps +if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA)) + message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X") +endif() +#endif() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp) file(GLOB NetCpp net/*.cpp) @@ -66,10 +61,6 @@ 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} @@ -97,9 +88,9 @@ if(MINGW) # resource compilation for mingw add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o - COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR} - -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) + COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR} + -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc + -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) else(MINGW) set(hwfr_src ${hwfr_src} hedgewars.rc) @@ -138,15 +129,26 @@ set(hwfr_rez hedgewars.qrc) +if(${BUILD_ENGINE_LIBRARY}) + add_definitions(-DHWLIBRARY=1) + set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(HW_LINK_LIBS ${hwlibname} ${HW_LINK_LIBS}) +endif() + qt4_add_resources(hwfr_rez_src ${hwfr_rez}) qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs}) -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}) - +if(APPLE) + find_library(iokit_framework NAMES IOKit) + set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS}) + set(hwfr_src ${hwfr_src} CocoaInitializer.mm + InstallController.cpp + M3Panel.mm + M3InstallController.m + NSWorkspace_RBAdditions.m + ) if(NOT NOAUTOUPDATE) find_package(Sparkle) if(SPARKLE_FOUND) @@ -157,28 +159,33 @@ endif() endif() -if(LIBENGINE) +#when debugging, always prompt a console to see fronted messages +#TODO: check it doesn't interfere on UNIX +if(CMAKE_BUILD_TYPE MATCHES "RELEASE") + set(console_access "WIN32") +endif(CMAKE_BUILD_TYPE MATCHES "RELEASE") +if(${LIBENGINE}) add_definitions(-DHWLIBRARY) set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS}) link_directories(${EXECUTABLE_OUTPUT_PATH}) endif() - -add_executable(hedgewars WIN32 +add_executable(hedgewars ${console_access} ${hwfr_src} ${hwfr_moc_srcs} ${hwfr_hdrs} ${hwfr_rez_src} ) +if((UNIX AND NOT APPLE) AND ${LIBENGINE}) + set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}") +endif() set(HW_LINK_LIBS physfs - frontlib ${QT_LIBRARIES} ${SDL_LIBRARY} ${SDLMIXER_LIBRARY} - ${SDLNET_LIBRARY} ${FFMPEG_LIBRARIES} ${HW_LINK_LIBS} ) @@ -197,13 +204,8 @@ ) endif() - -if (CROSSAPPLE) - -else() - target_link_libraries(hedgewars ${HW_LINK_LIBS}) -endif() +target_link_libraries(hedgewars ${HW_LINK_LIBS}) -install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) +install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir}) diff -r d24257910f8d -r aaefa587e277 QTfrontend/binds.cpp --- a/QTfrontend/binds.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/binds.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -66,5 +66,7 @@ {"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:")}, +#ifdef VIDEOREC {"record", "r", QT_TRANSLATE_NOOP("binds", "record"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Record video:")} +#endif }; diff -r d24257910f8d -r aaefa587e277 QTfrontend/binds.h --- a/QTfrontend/binds.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/binds.h Tue Dec 25 04:45:22 2012 +0100 @@ -21,7 +21,11 @@ #include +#ifdef VIDEOREC #define BINDS_NUMBER 46 +#else +#define BINDS_NUMBER 45 +#endif struct BindAction { diff -r d24257910f8d -r aaefa587e277 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/game.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -56,7 +56,7 @@ switch (gameType) { case gtDemo: - // for video recording we need demo anyway + // for video recording we need demo anyway emit HaveRecord(rtNeither, demo); break; case gtNet: @@ -314,23 +314,43 @@ { QStringList arguments; QRect resolution = config->vid_Resolution(); - arguments << cfgdir->absolutePath(); - arguments << QString::number(resolution.width()); - arguments << QString::number(resolution.height()); - arguments << QString::number(config->bitDepth()); // bpp + QString nick = config->netNick().toUtf8().toBase64(); + + arguments << "--internal"; //Must be passed as first argument + arguments << "--port"; arguments << QString("%1").arg(ipc_port); - arguments << (config->vid_Fullscreen() ? "1" : "0"); - arguments << (config->isSoundEnabled() ? "1" : "0"); - arguments << (config->isMusicEnabled() ? "1" : "0"); - arguments << QString::number(config->volume()); // sound volume - arguments << QString::number(config->timerInterval()); + arguments << "--prefix"; arguments << datadir->absolutePath(); - arguments << (config->isShowFPSEnabled() ? "1" : "0"); - arguments << (config->isAltDamageEnabled() ? "1" : "0"); - arguments << config->netNick().toUtf8().toBase64(); + arguments << "--user-prefix"; + arguments << cfgdir->absolutePath(); + arguments << "--locale"; + arguments << tr("en.txt"); + arguments << "--frame-interval"; + arguments << QString::number(config->timerInterval()); + arguments << "--volume"; + arguments << QString::number(config->volume()); + arguments << "--width"; + arguments << QString::number(resolution.width()); + arguments << "--height"; + arguments << QString::number(resolution.height()); + arguments << "--raw-quality"; arguments << QString::number(config->translateQuality()); + arguments << "--stereo"; arguments << QString::number(config->stereoMode()); - arguments << tr("en.txt"); + if (config->vid_Fullscreen()) + arguments << "--fullscreen"; + if (config->isShowFPSEnabled()) + arguments << "--showfps"; + if (config->isAltDamageEnabled()) + arguments << "--altdmg"; + if (!config->isSoundEnabled()) + arguments << "--nosound"; + if (!config->isMusicEnabled()) + arguments << "--nomusic"; + if (!nick.isEmpty()) { + arguments << "--nick"; + arguments << nick; + } return arguments; } diff -r d24257910f8d -r aaefa587e277 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/gameuiconfig.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -44,17 +44,21 @@ GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName) - : QSettings(fileName, QSettings::IniFormat) + : QSettings(fileName, QSettings::IniFormat, FormWidgets) { Form = FormWidgets; - connect(Form->ui.pageOptions->CBEnableFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool))); + setIniCodec("UTF-8"); + + connect(Form->ui.pageOptions->CBFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool))); //Form->resize(value("frontend/width", 640).toUInt(), value("frontend/height", 450).toUInt()); resizeToConfigValues(); reloadValues(); +#ifdef VIDEOREC reloadVideosValues(); +#endif } void GameUIConfig::reloadValues(void) @@ -77,11 +81,11 @@ Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt()); Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt()); - 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()); - Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("frontend/music", true).toBool()); + Form->ui.pageOptions->CBFrontendEffects->setChecked(value("frontend/effects", true).toBool()); + Form->ui.pageOptions->CBSound->setChecked(value("audio/sound", true).toBool()); + Form->ui.pageOptions->CBFrontendSound->setChecked(value("frontend/sound", true).toBool()); + Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool()); + Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool()); Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt()); QString netNick = value("net/nick", "").toString(); @@ -92,11 +96,13 @@ Form->ui.pageOptions->editNetPassword->installEventFilter(this); int passLength = value("net/passwordlength", 0).toInt(); - setNetPasswordLength(passLength); - if (savePwd == false) { - Form->ui.pageOptions->editNetPassword->setEnabled(savePwd); + if (!savePwd) { + Form->ui.pageOptions->editNetPassword->setEnabled(false); Form->ui.pageOptions->editNetPassword->setText(""); - setNetPasswordLength(0); + setNetPasswordLength(0); + } else + { + setNetPasswordLength(passLength); } delete netHost; @@ -124,10 +130,6 @@ 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) @@ -137,26 +139,34 @@ 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(); + // one pass with default values + Form->ui.pageOptions->setDefaultOptions(); + + // then load user configuration + Form->ui.pageOptions->framerateBox->setCurrentIndex( + Form->ui.pageOptions->framerateBox->findData( + value("videorec/framerate", rec_Framerate()).toString() + " fps", + Qt::MatchExactly) ); + Form->ui.pageOptions->bitrateBox->setValue(value("videorec/bitrate", rec_Bitrate()).toUInt()); + bool useGameRes = value("videorec/usegameres",Form->ui.pageOptions->checkUseGameRes->isChecked()).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())); + Form->ui.pageOptions->widthEdit->setText(QString::number(res.width())); + Form->ui.pageOptions->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.pageOptions->widthEdit->setText(value("videorec/width","800").toString()); + Form->ui.pageOptions->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(), + Form->ui.pageOptions->checkUseGameRes->setChecked(useGameRes); + Form->ui.pageOptions->checkRecordAudio->setChecked( + value("videorec/audio",Form->ui.pageOptions->checkRecordAudio->isChecked()).toBool() ); + if (!Form->ui.pageOptions->tryCodecs(value("videorec/format","no").toString(), value("videorec/videocodec","no").toString(), value("videorec/audiocodec","no").toString())) - Form->ui.pageVideos->setDefaultCodecs(); + Form->ui.pageOptions->setDefaultCodecs(); } QStringList GameUIConfig::GetTeamsList() @@ -175,7 +185,16 @@ void GameUIConfig::resizeToConfigValues() { - Form->resize(value("frontend/width", 800).toUInt(), value("frontend/height", 600).toUInt()); + // fill 2/3 of the screen desktop + const QRect deskSize = QApplication::desktop()->screenGeometry(-1); + Form->resize(value("frontend/width", qMin(qMax(deskSize.width()*2/3,800),deskSize.width())).toUInt(), + value("frontend/height", qMin(qMax(deskSize.height()*2/3,600),deskSize.height())).toUInt()); + + // move the window to the center of the screen + QPoint center = QApplication::desktop()->availableGeometry(-1).center(); + center.setX(center.x() - (Form->width()/2)); + center.setY(center.y() - (Form->height()/2)); + Form->move(center); } void GameUIConfig::SaveOptions() @@ -210,11 +229,13 @@ setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); setValue("net/nick", netNick()); - if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) - { - setValue("net/passwordhash", netPasswordHash()); - setValue("net/passwordlength", netPasswordLength()); + if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) { + setPasswordHash(netPasswordHash()); } + else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) { + clearPasswordHash(); + } + setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked()); setValue("net/ip", *netHost); setValue("net/port", netPort); @@ -268,7 +289,7 @@ setValue(QString("colors/color%1").arg(i), model->item(i)->data()); } - Form->gameSettings->sync(); + sync(); } void GameUIConfig::SaveVideosOptions() @@ -277,14 +298,20 @@ setValue("videorec/format", AVFormat()); setValue("videorec/videocodec", videoCodec()); setValue("videorec/audiocodec", audioCodec()); - setValue("videorec/fps", rec_Framerate()); + setValue("videorec/framerate", 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/usegameres", Form->ui.pageOptions->checkUseGameRes->isChecked()); setValue("videorec/audio", recordAudio()); - Form->gameSettings->sync(); + sync(); +} + +void GameUIConfig::setValue(const QString &key, const QVariant &value) +{ + //qDebug() << "[settings]" << key << value; + QSettings::setValue(key, value); } QString GameUIConfig::language() @@ -370,20 +397,20 @@ bool GameUIConfig::isSoundEnabled() { - return Form->ui.pageOptions->CBEnableSound->isChecked(); + return Form->ui.pageOptions->CBSound->isChecked(); } bool GameUIConfig::isFrontendSoundEnabled() { - return Form->ui.pageOptions->CBEnableFrontendSound->isChecked(); + return Form->ui.pageOptions->CBFrontendSound->isChecked(); } bool GameUIConfig::isMusicEnabled() { - return Form->ui.pageOptions->CBEnableMusic->isChecked(); + return Form->ui.pageOptions->CBMusic->isChecked(); } bool GameUIConfig::isFrontendMusicEnabled() { - return Form->ui.pageOptions->CBEnableFrontendMusic->isChecked(); + return Form->ui.pageOptions->CBFrontendMusic->isChecked(); } bool GameUIConfig::isShowFPSEnabled() @@ -418,11 +445,6 @@ return 35 - Form->ui.pageOptions->fpsedit->value(); } -quint8 GameUIConfig::bitDepth() -{ - return depth; -} - QString GameUIConfig::netNick() { return Form->ui.pageOptions->editNetNick->text(); @@ -445,7 +467,41 @@ bool GameUIConfig::netPasswordIsValid() { - return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '\0')); + return (netPasswordLength() == 0 || Form->ui.pageOptions->editNetPassword->text() != QString(netPasswordLength(), '*')); +} + +void GameUIConfig::clearPasswordHash() +{ + setValue("net/passwordhash", QString()); + setValue("net/passwordlength", 0); + setValue("net/savepassword", false); //changes the savepassword value to false in order to not let the user save an empty password in PAGE_SETUP + reloadValues(); //reloads the values of PAGE_SETUP +} + +void GameUIConfig::setPasswordHash(const QString & passwordhash) +{ + setValue("net/passwordhash", passwordhash); + setValue("net/passwordlength", passwordhash.size()/4); + setNetPasswordLength(passwordhash.size()/4); //the hash.size() is divided by 4 let PAGE_SETUP use a reasonable number of stars to display the PW +} + +QString GameUIConfig::passwordHash() +{ + return value("net/passwordhash").toString(); +} + +void GameUIConfig::clearTempHash() +{ + setTempHash(QString()); +} + +void GameUIConfig::setTempHash(const QString & temphash) +{ + this->temphash = temphash; +} + +QString GameUIConfig::tempHash() { + return this->temphash; } // When hedgewars launches, the password field is set with null characters. If the user tries to edit the field and there are such characters, then clear the field @@ -470,7 +526,7 @@ { if (passwordLength > 0) { - Form->ui.pageOptions->editNetPassword->setText(QString(passwordLength, '\0')); + Form->ui.pageOptions->editNetPassword->setText(QString(passwordLength, '*')); } else { @@ -485,40 +541,43 @@ QString GameUIConfig::AVFormat() { - return Form->ui.pageVideos->format(); + return Form->ui.pageOptions->format(); } QString GameUIConfig::videoCodec() { - return Form->ui.pageVideos->videoCodec(); + return Form->ui.pageOptions->videoCodec(); } QString GameUIConfig::audioCodec() { - return Form->ui.pageVideos->audioCodec(); + return Form->ui.pageOptions->audioCodec(); } QRect GameUIConfig::rec_Resolution() { - if (Form->ui.pageVideos->checkUseGameRes->isChecked()) + if (Form->ui.pageOptions->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()); + res.setWidth(Form->ui.pageOptions->widthEdit->text().toUInt()); + res.setHeight(Form->ui.pageOptions->heightEdit->text().toUInt()); return res; } int GameUIConfig::rec_Framerate() { - return Form->ui.pageVideos->framerateBox->value(); + // remove the "fps" label + QString fpsText = Form->ui.pageOptions->framerateBox->currentText(); + QStringList fpsList = fpsText.split(" "); + return fpsList.first().toInt(); } int GameUIConfig::rec_Bitrate() { - return Form->ui.pageVideos->bitrateBox->value(); + return Form->ui.pageOptions->bitrateBox->value(); } bool GameUIConfig::recordAudio() { - return Form->ui.pageVideos->checkRecordAudio->isChecked(); + return Form->ui.pageOptions->checkRecordAudio->isChecked(); } diff -r d24257910f8d -r aaefa587e277 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/gameuiconfig.h Tue Dec 25 04:45:22 2012 +0100 @@ -48,16 +48,22 @@ bool appendDateTimeToRecordName(); quint8 volume(); quint8 timerInterval(); - quint8 bitDepth(); QString netNick(); QByteArray netPasswordHash(); int netPasswordLength(); + void clearPasswordHash(); + void setPasswordHash(const QString & passwordhash); + QString passwordHash(); + void clearTempHash(); + void setTempHash(const QString & temphash); + QString tempHash(); void setNetPasswordLength(int passwordLength); bool isReducedQuality() const; bool isFrontendEffects() const; bool isFrontendFullscreen() const; void resizeToConfigValues(); quint32 stereoMode() const; + void setValue(const QString & key, const QVariant & value); QString AVFormat(); QString videoCodec(); @@ -85,7 +91,7 @@ private: bool netPasswordIsValid(); bool eventFilter(QObject *object, QEvent *event); - quint8 depth; + QString temphash; }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/hedgewars.qrc Tue Dec 25 04:45:22 2012 +0100 @@ -44,6 +44,7 @@ res/HedgewarsTitle.png res/LocalPlay.png res/NetworkPlay.png + res/NetworkPlayDisabled.png res/Settings.png res/dropdown.png res/new.png @@ -145,5 +146,6 @@ res/chat/serveradmin_gray.png res/chat/lamp_off.png res/chat/ingame.png + res/html/about.html diff -r d24257910f8d -r aaefa587e277 QTfrontend/hwconsts.cpp.in --- a/QTfrontend/hwconsts.cpp.in Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/hwconsts.cpp.in Tue Dec 25 04:45:22 2012 +0100 @@ -22,10 +22,9 @@ QString * cProtoVer = new QString("${HEDGEWARS_PROTO_VER}"); QString * cDataDir = new QString("${HEDGEWARS_DATADIR}"); -QString * cConfigDir = new QString(""); QString * cVersionString = new QString("${HEDGEWARS_VERSION}"); -QDir * bindir = new QDir("${HEDGEWARS_BINDIR}"); +QDir * bindir = new QDir(); QDir * cfgdir = new QDir(); QDir * datadir = new QDir(); diff -r d24257910f8d -r aaefa587e277 QTfrontend/hwconsts.h --- a/QTfrontend/hwconsts.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/hwconsts.h Tue Dec 25 04:45:22 2012 +0100 @@ -26,7 +26,6 @@ extern QString * cProtoVer; extern QString * cVersionString; extern QString * cDataDir; -extern QString * cConfigDir; extern QDir * bindir; extern QDir * cfgdir; @@ -63,40 +62,40 @@ #define HEDGEHOGS_PER_TEAM 8 -#define AMMOLINE_DEFAULT_QT "93919294221991210322351110012010000002111101010111110101" -#define AMMOLINE_DEFAULT_PROB "04050405416006555465544647765766666661555101011154110101" -#define AMMOLINE_DEFAULT_DELAY "00000000000002055000000400070040000000002200000006000000" -#define AMMOLINE_DEFAULT_CRATE "13111103121111111231141111111111111112111111011111110101" +#define AMMOLINE_DEFAULT_QT "9391929422199121032235111001201000000211110101011111101" +#define AMMOLINE_DEFAULT_PROB "0405040541600655546554464776576666666155510101115411101" +#define AMMOLINE_DEFAULT_DELAY "0000000000000205500000040007004000000000220000000600000" +#define AMMOLINE_DEFAULT_CRATE "1311110312111111123114111111111111111211111101111111101" -#define AMMOLINE_CRAZY_QT "99999999999999999929999999999999992999999999099999920909" -#define AMMOLINE_CRAZY_PROB "11111101111111111111111111111111111111111111011111110101" -#define AMMOLINE_CRAZY_DELAY "00000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_CRAZY_CRATE "13111103121111111231141111111111111112111101011111110101" +#define AMMOLINE_CRAZY_QT "9999999999999999992999999999999999299999999909999992909" +#define AMMOLINE_CRAZY_PROB "1111110111111111111111111111111111111111111101111111101" +#define AMMOLINE_CRAZY_DELAY "0000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_CRAZY_CRATE "1311110312111111123114111111111111111211110101111111101" -#define AMMOLINE_PROMODE_QT "90900090000000000000090000000000000000000000000000000000" -#define AMMOLINE_PROMODE_PROB "00000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_PROMODE_DELAY "00000000000002055000000400070040000000002000000000000002" -#define AMMOLINE_PROMODE_CRATE "11111111111111111111111111111111111111111001011111110101" +#define AMMOLINE_PROMODE_QT "9090009000000000000009000000000000000000000000000000000" +#define AMMOLINE_PROMODE_PROB "0000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_PROMODE_DELAY "0000000000000205500000040007004000000000200000000000002" +#define AMMOLINE_PROMODE_CRATE "1111111111111111111111111111111111111111100101111111101" -#define AMMOLINE_SHOPPA_QT "00000099000000000000000000000000000000000000000000000000" -#define AMMOLINE_SHOPPA_PROB "44444100442444022101121212224220000000020004000100110001" -#define AMMOLINE_SHOPPA_DELAY "00000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_SHOPPA_CRATE "11111111111111111111111111111111111111111011011111110001" +#define AMMOLINE_SHOPPA_QT "0000009900000000000000000000000000000000000000000000000" +#define AMMOLINE_SHOPPA_PROB "4444410044244402210112121222422000000002000400010011001" +#define AMMOLINE_SHOPPA_DELAY "0000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_SHOPPA_CRATE "1111111111111111111111111111111111111111101101111111001" -#define AMMOLINE_CLEAN_QT "10100090000100000110000000000000000000000000000010000000" -#define AMMOLINE_CLEAN_PROB "04050405416006555465544647765766666661555101011154110101" -#define AMMOLINE_CLEAN_DELAY "00000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_CLEAN_CRATE "13111103121111111231141111111111111112111111011111110101" +#define AMMOLINE_CLEAN_QT "1010009000010000011000000000000000000000000000001000000" +#define AMMOLINE_CLEAN_PROB "0405040541600655546554464776576666666155510101115411101" +#define AMMOLINE_CLEAN_DELAY "0000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_CLEAN_CRATE "1311110312111111123114111111111111111211111101111111101" -#define AMMOLINE_MINES_QT "00000099000900000003000000000000000000000000000000000000" -#define AMMOLINE_MINES_PROB "00000000000000000000000000000000000000000000000000000000" -#define AMMOLINE_MINES_DELAY "00000000000002055000000400070040000000002000000006000000" -#define AMMOLINE_MINES_CRATE "11111111111111111111111111111111111111111111011111110101" +#define AMMOLINE_MINES_QT "0000009900090000000300000000000000000000000000000000000" +#define AMMOLINE_MINES_PROB "0000000000000000000000000000000000000000000000000000000" +#define AMMOLINE_MINES_DELAY "0000000000000205500000040007004000000000200000000600000" +#define AMMOLINE_MINES_CRATE "1111111111111111111111111111111111111111111101111111101" -#define AMMOLINE_PORTALS_QT "90000090020000000021000000000000001100000900000000000000" -#define AMMOLINE_PORTALS_PROB "04050405416006555465544647765766666661555101011154110101" -#define AMMOLINE_PORTALS_DELAY "00000000000002055000000400070040000000002000000006000000" -#define AMMOLINE_PORTALS_CRATE "13111103121111111231141111111111111112111111011111110101" +#define AMMOLINE_PORTALS_QT "9000009002000000002100000000000000110000090000000000000" +#define AMMOLINE_PORTALS_PROB "0405040541600655546554464776576666666155510101115411101" +#define AMMOLINE_PORTALS_DELAY "0000000000000205500000040007004000000000200000000600000" +#define AMMOLINE_PORTALS_CRATE "1311110312111111123114111111111111111211111101111111101" //Different seasons; assigned to season (int) #define SEASON_NONE 0 diff -r d24257910f8d -r aaefa587e277 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/hwform.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include #include @@ -73,7 +75,6 @@ #include "pagefeedback.h" #include "pagenetserver.h" #include "pagedrawmap.h" -#include "pagenettype.h" #include "pagegamestats.h" #include "pageplayrecord.h" #include "pagedata.h" @@ -96,6 +97,19 @@ #include "playerslistmodel.h" #include "DataManager.h" +#include "AutoUpdater.h" + +#ifdef Q_WS_WIN +#define WINVER 0x0500 +#include +#else +#include +#include +#endif + +#ifdef Q_WS_MAC +#include +#endif #ifdef __APPLE__ #include "M3Panel.h" @@ -111,7 +125,6 @@ QString playerHash; GameUIConfig* HWForm::config = NULL; -QSettings* HWForm::gameSettings = NULL; HWForm::HWForm(QWidget *parent, QString styleSheet) : QMainWindow(parent) @@ -127,10 +140,6 @@ #ifdef USE_XFIRE xfire_init(); #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().toUtf8(), QCryptographicHash::Md5).toHex()); - this->setStyleSheet(styleSheet); ui.setupUi(this); setMinimumSize(760, 580); @@ -139,21 +148,38 @@ ui.pageOptions->CBResolution->addItems(SDLInteraction::instance().getResolutions()); - config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); + config = new GameUIConfig(this, "physfs://hedgewars.ini"); + frontendEffects = config->value("frontend/effects", true).toBool(); + playerHash = QString(QCryptographicHash::hash(config->value("net/nick","").toString().toUtf8(), QCryptographicHash::Md5).toHex()); + + ui.pageRoomsList->setSettings(config); + ui.pageNetGame->chatWidget->setSettings(config); + ui.pageRoomsList->chatWidget->setSettings(config); +#ifdef VIDEOREC + ui.pageVideos->init(config); + ui.pageOptions->setConfig(config); +#endif - ui.pageVideos->init(config); +#ifdef __APPLE__ + AutoUpdater* updater = NULL; + if (config->isAutoUpdateEnabled()) + { +#ifdef __APPLE__ +#ifdef SPARKLE_ENABLED + updater = new SparkleAutoUpdater(); +#endif +#endif + if (updater) + { + updater->checkForUpdates(); + delete updater; + } + } +#endif #ifdef __APPLE__ panel = new M3Panel; -#ifdef SPARKLE_ENABLED - AutoUpdater* updater; - - updater = new SparkleAutoUpdater(); - if (updater && config->isAutoUpdateEnabled()) - updater->checkForUpdates(); -#endif - QShortcut *hideFrontend = new QShortcut(QKeySequence("Ctrl+M"), this); connect (hideFrontend, SIGNAL(activated()), this, SLOT(showMinimized())); #else @@ -190,9 +216,6 @@ connect(ui.pageMain->BtnFeedback, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnFeedback, ID_PAGE_FEEDBACK); - connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); - pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); - connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO); @@ -291,8 +314,8 @@ // this, SLOT(GoBack())); // executed third - connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); - connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); + connect(ui.pageMain->BtnNetLocal, SIGNAL(clicked()), this, SLOT(GoToNet())); + connect(ui.pageMain->BtnNetOfficial, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); connect(ui.pageConnecting, SIGNAL(cancelConnection()), this, SLOT(GoBack())); @@ -439,23 +462,27 @@ } } -void HWForm::UpdateTeamsLists(const QStringList* editable_teams) +void HWForm::UpdateTeamsLists() { - QStringList teamslist; - if(editable_teams) - { - teamslist =* editable_teams; - } - else - { - teamslist = config->GetTeamsList(); - } + QStringList teamslist = config->GetTeamsList(); if(teamslist.empty()) { - HWTeam defaultTeam(tr("DefaultTeam")); + QString currentNickName = config->value("net/nick","").toString().toUtf8(); + QString teamName; + + if (currentNickName.isEmpty()) + { + teamName = tr("DefaultTeam"); + } + else + { + teamName = tr("%1's Team").arg(currentNickName); + } + + HWTeam defaultTeam(teamName); defaultTeam.saveToFile(); - teamslist.push_back(tr("DefaultTeam")); + teamslist.push_back(teamName); } ui.pageOptions->CBTeamName->clear(); @@ -531,6 +558,67 @@ #ifdef USE_XFIRE updateXfire(); #endif + + QString openPrefix = "Debug: (PAGE_OPENED: "; + QString openSuffix = ")"; + QString closePrefix = "Debug: (PAGE_LEFT: "; + QString closeSuffix = ")"; + + switch (lastid) { //Print the id of the page we're leaving + case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + default : qDebug("%sUNKNOWN PAGE%s", qPrintable(closePrefix), qPrintable(closeSuffix)); break; + } //end switch(lastid) + switch (id) { //Print the id of the opened page + case ID_PAGE_SETUP_TEAM : qDebug("%sPAGE_SETUP_TEAM%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_SETUP : qDebug("%sPAGE_SETUP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_MULTIPLAYER : qDebug("%sPAGE_MULTIPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_DEMOS : qDebug("%sPAGE_DEMOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_NET : qDebug("%sPAGE_NET%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_NETGAME : qDebug("%sPAGE_NETGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_INFO : qDebug("%sPAGE_INFO%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_MAIN : qDebug("%sPAGE_MAIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_GAMESTATS : qDebug("%sPAGE_GAMESTATS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_SINGLEPLAYER : qDebug("%sPAGE_SINGLEPLAYER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_TRAINING : qDebug("%sPAGE_TRAINING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_SELECTWEAPON : qDebug("%sPAGE_SELECTWEAPON%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_NETSERVER : qDebug("%sPAGE_NETSERVER%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_INGAME : qDebug("%sPAGE_INGAME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_ROOMSLIST : qDebug("%sPAGE_ROOMSLIST%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_CONNECTING : qDebug("%sPAGE_CONNECTING%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_SCHEME : qDebug("%sPAGE_SCHEME%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_ADMIN : qDebug("%sPAGE_ADMIN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_CAMPAIGN : qDebug("%sPAGE_CAMPAIGN%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_DRAWMAP : qDebug("%sPAGE_DRAWMAP%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_DATADOWNLOAD : qDebug("%sPAGE_DATADOWNLOAD%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_FEEDBACK : qDebug("%sPAGE_FEEDBACK%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case ID_PAGE_VIDEOS : qDebug("%sPAGE_VIDEOS%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + case MAX_PAGE : qDebug("%sMAX_PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + default : qDebug("%sUNKNOWN PAGE%s", qPrintable(openPrefix), qPrintable(openSuffix)); break; + } //end switch(id) + if (id == ID_PAGE_DATADOWNLOAD) { ui.pageDataDownload->fetchList(); @@ -612,14 +700,9 @@ ui.pageOptions->setTeamOptionsEnabled(true); } - if (id == ID_PAGE_SETUP) + if (id == ID_PAGE_FEEDBACK) { - config->reloadValues(); - } - - if (id == ID_PAGE_VIDEOS ) - { - config->reloadVideosValues(); + ui.pageFeedback->LoadCaptchaImage(); } } @@ -636,8 +719,8 @@ /* 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. + 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) @@ -695,8 +778,8 @@ animationOldSlide->start(QAbstractAnimation::DeleteWhenStopped); animationNewSlide->start(QAbstractAnimation::DeleteWhenStopped); - /* 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(); + /* 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 } @@ -965,37 +1048,78 @@ void HWForm::NetPassword(const QString & nick) { - int passLength = config->value("net/passwordlength", 0).toInt(); - QString hash = config->value("net/passwordhash", "").toString(); + //Get hashes + QString hash = config->passwordHash(); + QString temphash = config->tempHash(); + + //Check them - // If the password is blank, ask the user to enter one in - if (passLength == 0) - { - 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; - } - - 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; + if (temphash.isEmpty() && hash.isEmpty()) { //If the user enters a registered nick with no password, sends a bogus hash + hwnet->SendPasswordHash("THISISNOHASH"); + } + else if (temphash.isEmpty()) { //Send saved hash as default + hwnet->SendPasswordHash(hash); + } + else { //Send the hash + hwnet->SendPasswordHash(temphash); } - hwnet->SendPasswordHash(hash); + //Remove temporary hash from config + config->clearTempHash(); +} + +void HWForm::NetNickRegistered(const QString & nick) +{ + //Get hashes + QString hash = config->passwordHash(); + QString temphash = config->tempHash(); + + if (hash.isEmpty()) { + if (temphash.isEmpty()) { //If the user enters a registered nick with no password + QString suppliedpass; + while (suppliedpass.isEmpty()) { + QInputDialog nickRegedDialog(this); + nickRegedDialog.setWindowModality(Qt::WindowModal); + nickRegedDialog.setInputMode(QInputDialog::TextInput); + nickRegedDialog.setWindowTitle(tr("Hedgewars - Nick registered")); + nickRegedDialog.setLabelText(tr("This nick is registered, and you haven't specified a password.\n\nIf this nick isn't yours, please register your own nick at www.hedgewars.org\n\nPassword:")); + nickRegedDialog.setTextEchoMode(QLineEdit::Password); + nickRegedDialog.exec(); + + suppliedpass = nickRegedDialog.textValue(); + + if (nickRegedDialog.result() == QDialog::Rejected) { + config->clearPasswordHash(); + config->clearTempHash(); + GoBack(); + return; + } + temphash = QCryptographicHash::hash(suppliedpass.toUtf8(), QCryptographicHash::Md5).toHex(); + config->setTempHash(temphash); + } + } + } + NetPassword(nick); +} + +void HWForm::NetNickNotRegistered(const QString & nick) +{ + QMessageBox noRegMsg(this); + noRegMsg.setIcon(QMessageBox::Information); + noRegMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Nick not registered")); + noRegMsg.setWindowModality(Qt::WindowModal); + noRegMsg.setText(tr("Your nickname is not registered.\nTo prevent someone else from using it,\nplease register it at www.hedgewars.org")); + + if (!config->passwordHash().isEmpty()) + { + config->clearPasswordHash(); + noRegMsg.setText(noRegMsg.text()+tr("\n\nYour password wasn't saved either.")); + } + if (!config->tempHash().isEmpty()) + { + config->clearTempHash(); + } + noRegMsg.exec(); } void HWForm::NetNickTaken(const QString & nick) @@ -1005,7 +1129,12 @@ if (!ok || newNick.isEmpty()) { - ForcedDisconnect(tr("No nickname supplied.")); + //ForcedDisconnect(tr("No nickname supplied.")); + bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); + GoBack(); + if (retry) { + NetConnectOfficialServer(); + } return; } @@ -1020,8 +1149,39 @@ void HWForm::NetAuthFailed() { // Set the password blank if case the user tries to join and enter his password again - config->setValue("net/passwordlength", 0); - config->setNetPasswordLength(0); + config->clearTempHash(); + + //Try to login again + bool retry = RetryDialog(tr("Hedgewars - Wrong password"), tr("You entered a wrong password.")); + GoBack(); + + config->clearPasswordHash(); + config->clearTempHash(); + if (retry) { + NetConnectOfficialServer(); + } +} + +bool HWForm::RetryDialog(const QString & title, const QString & label) +{ + QMessageBox retryMsg(this); + retryMsg.setIcon(QMessageBox::Warning); + retryMsg.setWindowTitle(title); + retryMsg.setText(label); + retryMsg.setWindowModality(Qt::WindowModal); + + retryMsg.addButton(QMessageBox::Cancel); + + QPushButton *retryButton = retryMsg.addButton(QMessageBox::Ok); + retryButton->setText(tr("Try Again")); + retryButton->setFocus(); + + retryMsg.exec(); + + if (retryMsg.clickedButton() == retryButton) { + return true; + } + return false; } void HWForm::NetTeamAccepted(const QString & team) @@ -1074,13 +1234,14 @@ 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(NickRegistered(const QString&)), this, SLOT(NetNickRegistered(const QString&)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(NickNotRegistered(const QString&)), this, SLOT(NetNickNotRegistered(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()); + ui.pageNetGame->chatWidget->setUsersModel(hwnet->roomPlayersModel()); // rooms list page stuff ui.pageRoomsList->setModel(hwnet->roomsListModel()); @@ -1109,26 +1270,26 @@ // net page stuff connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); + ui.pageNetGame->chatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); + ui.pageNetGame->chatWidget, SLOT(onChatString(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(roomMaster(bool)), - ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool)), Qt::QueuedConnection); - connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), + ui.pageNetGame->chatWidget, SLOT(adminAccess(bool)), Qt::QueuedConnection); + connect(ui.pageNetGame->chatWidget, SIGNAL(chatLine(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)), Qt::QueuedConnection); // chat widget actions - connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), + connect(ui.pageNetGame->chatWidget, SIGNAL(kick(const QString&)), hwnet, SLOT(kickPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), + connect(ui.pageNetGame->chatWidget, SIGNAL(ban(const QString&)), hwnet, SLOT(banPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), + connect(ui.pageNetGame->chatWidget, SIGNAL(info(const QString&)), hwnet, SLOT(infoPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), + connect(ui.pageNetGame->chatWidget, SIGNAL(follow(const QString&)), hwnet, SLOT(followPlayer(const QString&))); connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), hwnet, SLOT(kickPlayer(const QString&))); @@ -1151,9 +1312,9 @@ // nick list stuff connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), - ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool)), Qt::QueuedConnection); + ui.pageNetGame->chatWidget, SLOT(nickAdded(const QString&, bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickRemoved(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&)), Qt::QueuedConnection); + ui.pageNetGame->chatWidget, SLOT(nickRemoved(const QString&)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool)), Qt::QueuedConnection); connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), @@ -1176,11 +1337,16 @@ connect(hwnet, SIGNAL(serverMessageNew(const QString&)), ui.pageAdmin, SLOT(serverMessageNew(const QString &))); connect(hwnet, SIGNAL(serverMessageOld(const QString&)), ui.pageAdmin, SLOT(serverMessageOld(const QString &))); connect(hwnet, SIGNAL(latestProtocolVar(int)), ui.pageAdmin, SLOT(protocol(int))); + connect(hwnet, SIGNAL(bansList(const QStringList &)), ui.pageAdmin, SLOT(setBansList(const QStringList &))); connect(ui.pageAdmin, SIGNAL(setServerMessageNew(const QString&)), hwnet, SLOT(setServerMessageNew(const QString &))); connect(ui.pageAdmin, SIGNAL(setServerMessageOld(const QString&)), hwnet, SLOT(setServerMessageOld(const QString &))); connect(ui.pageAdmin, SIGNAL(setProtocol(int)), hwnet, SLOT(setLatestProtocolVar(int))); connect(ui.pageAdmin, SIGNAL(askServerVars()), hwnet, SLOT(askServerVars())); connect(ui.pageAdmin, SIGNAL(clearAccountsCache()), hwnet, SLOT(clearAccountsCache())); + connect(ui.pageAdmin, SIGNAL(bansListRequest()), hwnet, SLOT(getBanList())); + connect(ui.pageAdmin, SIGNAL(removeBan(QString)), hwnet, SLOT(removeBan(QString))); + connect(ui.pageAdmin, SIGNAL(banIP(QString,QString,int)), hwnet, SLOT(banIP(QString,QString,int))); + connect(ui.pageAdmin, SIGNAL(banNick(QString,QString,int)), hwnet, SLOT(banNick(QString,QString,int))); // disconnect connect(hwnet, SIGNAL(disconnected(const QString&)), this, SLOT(ForcedDisconnect(const QString&)), Qt::QueuedConnection); @@ -1190,23 +1356,95 @@ 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()) - { - nick = QInputDialog::getText(this, - QObject::tr("Nickname"), - QObject::tr("Please enter your nickname"), - QLineEdit::Normal, - QDir::home().dirName()); - config->setValue("net/nick",nick); +//nick and pass stuff + + //remove temppasswordhash just in case + config->clearTempHash(); + + //initialize + QString hash = config->passwordHash(); + QString temphash = config->tempHash(); + QString nickname = config->value("net/nick", "").toString(); + QString password; + + if (nickname.isEmpty() || hash.isEmpty()) { //if something from login is missing, start dialog loop + + while (nickname.isEmpty() || (hash.isEmpty() && temphash.isEmpty())) //while a nickname, or both hashes are missing + { + //open dialog + HWPasswordDialog * pwDialog = new HWPasswordDialog(this); + pwDialog->cbSave->setChecked(config->value("net/savepassword", true).toBool()); + + //if nickname is present, put it into the field + if (!nickname.isEmpty()) { + pwDialog->leNickname->setText(nickname); + pwDialog->lePassword->setFocus(); + } + + //if dialog close, create an error message + if (pwDialog->exec() != QDialog::Accepted) { + delete pwDialog; + GoBack(); + return; + } + + //set nick and pass from the dialog + nickname = pwDialog->leNickname->text(); + password = pwDialog->lePassword->text(); + + //check the nickname variable + if (nickname.isEmpty()) { + int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied.")); + GoBack(); + delete pwDialog; + if (retry) { + NetConnectOfficialServer(); + } + return; + } + + if (!password.isEmpty()) { + //calculate temphash and set it into config + temphash = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex(); + config->setTempHash(temphash); + + //if user wants to save password + bool save = pwDialog->cbSave->isChecked(); + config->setValue("net/savepassword", save); + if (save) // user wants to save password + { + config->setPasswordHash(temphash); + } + } + else { + delete pwDialog; + config->setValue("net/nick", nickname); + config->updNetNick(); + config->clearPasswordHash(); + break; + } + + delete pwDialog; + + //update nickname + config->setValue("net/nick", nickname); config->updNetNick(); + + //and all the variables + hash = config->passwordHash(); + temphash = config->tempHash(); + nickname = config->value("net/nick", "").toString(); + } } - ui.pageRoomsList->setUser(nick); - ui.pageNetGame->setUser(nick); + ui.pageRoomsList->setUser(nickname); + ui.pageNetGame->setUser(nickname); - hwnet->Connect(hostName, port, nick); + hwnet->Connect(hostName, port, nickname); } + + void HWForm::NetConnect() { HWHostPortDialog * hpd = new HWHostPortDialog(this); @@ -1271,6 +1509,20 @@ void HWForm::ForcedDisconnect(const QString & reason) { + if (reason == "Reconnected too fast") { //TODO: this is a hack, which should be remade + bool retry = RetryDialog(tr("Hedgewars - Connection error"), tr("You reconnected too fast.\nPlease wait a few seconds and try again.")); + if (retry) { + NetConnectOfficialServer(); + } + else { + while (ui.Pages->currentIndex() != ID_PAGE_NET + && ui.Pages->currentIndex() != ID_PAGE_MAIN) + { + GoBack(); + } + } + return; + } if (pnetserver) return; // we have server - let it care of all things if (hwnet) @@ -1280,7 +1532,6 @@ } while (ui.Pages->currentIndex() != ID_PAGE_NET - && ui.Pages->currentIndex() != ID_PAGE_NETTYPE && ui.Pages->currentIndex() != ID_PAGE_MAIN) { GoBack(); @@ -1294,7 +1545,7 @@ void HWForm::NetGameEnter() { - ui.pageNetGame->pChatWidget->clear(); + ui.pageNetGame->chatWidget->clear(); GoToPage(ID_PAGE_NETGAME); } @@ -1345,7 +1596,7 @@ //setVisible(true); setFocusPolicy(Qt::StrongFocus); if (id == ID_PAGE_INGAME) GoBack(); - Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); + Music(ui.pageOptions->CBFrontendMusic->isChecked()); if (wBackground) wBackground->startAnimation(); GoToPage(ID_PAGE_GAMESTATS); if (hwnet && (!game || !game->netSuspend)) hwnet->gameFinished(true); @@ -1363,7 +1614,7 @@ (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed || gameState == gsHalted))) { if (id == ID_PAGE_INGAME) GoBack(); - Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); + Music(ui.pageOptions->CBFrontendMusic->isChecked()); if (wBackground) wBackground->startAnimation(); if (hwnet) hwnet->gameFinished(false); } @@ -1480,7 +1731,9 @@ xfire_free(); #endif config->SaveOptions(); +#if VIDEOREC config->SaveVideosOptions(); +#endif event->accept(); } @@ -1632,19 +1885,28 @@ // 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() { + + QString prefix = datadir->absolutePath(); + QString userPrefix = cfgdir->absolutePath(); +#ifdef Q_WS_WIN + prefix = prefix.replace("/","\\"); + userPrefix = userPrefix.replace("/","\\"); +#endif + 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())); + return QString("--prefix " + prefix + + " --user-prefix " + userPrefix + + " --width " + QString::number(resolution.width()) + + " --height " + QString::number(resolution.height()) + + " --volume " + QString::number(config->volume()) + + (config->isMusicEnabled() ? "" : " --nomusic") + + (config->isSoundEnabled() ? "" : " --nosound") + + " --locale " + config->language() + ".txt" + + (config->vid_Fullscreen() ? " --fullscreen" : "") + + (config->isShowFPSEnabled() ? " --showfps" : "") + + (config->isAltDamageEnabled() ? " --altdmg" : "") + + " --frame-interval " + QString::number(config->timerInterval()) + + " --raw-quality " + QString::number(config->translateQuality())); } void HWForm::AssociateFiles() @@ -1659,8 +1921,8 @@ registry_hkcr.setValue("Hedgewars.Save/Default", tr("Hedgewars Save File", "File Types")); registry_hkcr.setValue("Hedgewars.Demo/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwdfile.ico\",0"); registry_hkcr.setValue("Hedgewars.Save/DefaultIcon/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwsfile.ico\",0"); - registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); - registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"" + cfgdir->absolutePath().replace("/","\\") + "\" \"" + datadir->absolutePath().replace("/", "\\") + "\" \"%1\" --set-everything "+arguments); + registry_hkcr.setValue("Hedgewars.Demo/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments); + registry_hkcr.setValue("Hedgewars.Save/Shell/Open/Command/Default", "\"" + bindir->absolutePath().replace("/", "\\") + "\\hwengine.exe\" \"%1\" "+arguments); #elif defined __APPLE__ // only useful when other apps have taken precedence over our file extensions and you want to reset it system("defaults write com.apple.LaunchServices LSHandlers -array-add 'LSHandlerContentTaghwdLSHandlerContentTagClasspublic.filename-extensionLSHandlerRoleAllorg.hedgewars.desktop'"); @@ -1681,7 +1943,7 @@ if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-demo")==0; if (success) success = system("xdg-mime default hwengine.desktop application/x-hedgewars-save")==0; // 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; + if (success) success = system(("sed -i 's/^\\(Exec=.*\\) \\([^ ]* %f\\)/\\1 \\2 "+arguments+"/' "+QDir::home().absolutePath()+"/.local/share/applications/hwengine.desktop").toLocal8Bit().constData())==0; #endif if (success) { @@ -1726,105 +1988,74 @@ void HWForm::SendFeedback() { - //Create Xml representation of google code issue first - if (!CreateIssueXml()) + // Get form data + + QString summary = ui.pageFeedback->summary->text(); + QString description = ui.pageFeedback->description->toPlainText(); + QString email = ui.pageFeedback->email->text(); + QString captchaCode = ui.pageFeedback->captcha_code->text(); + QString captchaID = QString::number(ui.pageFeedback->captchaID); + QString version = "HedgewarsFoundation-Hedgewars-" + (cVersionString?(*cVersionString):QString("")); + + if (summary.isEmpty() || description.isEmpty()) { - ShowErrorMessage(QMessageBox::tr("Please fill out all fields")); + ShowErrorMessage(QMessageBox::tr("Please fill out all fields. Email is optional.")); return; } - //Google login using fake account (feedback.hedgewars@gmail.com) + // Submit issue to PHP script + + QByteArray body; + body.append("captcha="); + body.append(captchaID); + body.append("&code="); + body.append(captchaCode); + body.append("&version="); + body.append(QUrl::toPercentEncoding(version)); + body.append("&title="); + body.append(QUrl::toPercentEncoding(summary)); + body.append("&body="); + body.append(QUrl::toPercentEncoding(description)); + body.append("&email="); + body.append(QUrl::toPercentEncoding(email)); + if (ui.pageFeedback->CheckSendSpecs->isChecked()) + { + body.append("&specs="); + body.append(QUrl::toPercentEncoding(ui.pageFeedback->specs)); + } + 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(); + QNetworkRequest header(QUrl("http://hedgewars.org/feedback/?submit")); + header.setRawHeader("Content-Length", QString::number(body.size()).toAscii()); - //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; + nam->post(header, body); } 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.setText(reply->readAll()); infoMsg.setWindowModality(Qt::WindowModal); infoMsg.exec(); ui.pageFeedback->summary->clear(); + ui.pageFeedback->email->clear(); ui.pageFeedback->description->clear(); - authToken = ""; - return; - } - - if (!getAuthToken(str)) - { - ShowErrorMessage(QMessageBox::tr("Error during authentication at google.com")); - return; - } + ui.pageFeedback->LoadCaptchaImage(); - 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); - + return; } - 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.com directly)")); - authToken = ""; + ShowErrorMessage(QString("Error: ") + reply->readAll()); + ui.pageFeedback->LoadCaptchaImage(); } - } -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 d24257910f8d -r aaefa587e277 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/hwform.h Tue Dec 25 04:45:22 2012 +0100 @@ -61,7 +61,6 @@ 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(); @@ -106,8 +105,11 @@ void NetWarning(const QString & wrnmsg); void NetGameEnter(); void NetPassword(const QString & nick); + void NetNickRegistered(const QString & nick); + void NetNickNotRegistered(const QString & nick); void NetNickTaken(const QString & nick); void NetAuthFailed(); + bool RetryDialog(const QString & title, const QString & label); void NetTeamAccepted(const QString& team); void AddNetTeam(const HWTeam& team); void RemoveNetTeam(const HWTeam& team); @@ -126,13 +128,8 @@ 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 + //Called after submitting new feedback void finishedSlot(QNetworkReply* reply); - //Filter the auth token from the reply from google - bool getAuthToken(QString str); void NetGameChangeStatus(bool isMaster); void NetGameMaster(); @@ -146,7 +143,7 @@ private: void _NetConnect(const QString & hostName, quint16 port, QString nick); - void UpdateTeamsLists(const QStringList* editable_teams=0); + void UpdateTeamsLists(); void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo); void closeEvent(QCloseEvent *event); void CustomizePalettes(); @@ -173,13 +170,12 @@ 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 + ID_PAGE_FEEDBACK , + ID_PAGE_VIDEOS , + MAX_PAGE }; QPointer game; QPointer pnetserver; @@ -194,8 +190,6 @@ QSignalMapper * pageSwitchMapper; QByteArray m_lastDemo; QNetworkAccessManager * nam; - QString issueXml; - QString authToken; QPropertyAnimation *animationNewSlide; QPropertyAnimation *animationOldSlide; diff -r d24257910f8d -r aaefa587e277 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/main.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -35,8 +35,6 @@ #include "DataManager.h" #include "FileEngine.h" -#include "frontlib.h" - #ifdef _WIN32 #include #endif @@ -90,9 +88,9 @@ bool checkForDir(const QString & dir) { - QDir tmpdir; - if (!tmpdir.exists(dir)) - if (!tmpdir.mkdir(dir)) + QDir tmpdir(dir); + if (!tmpdir.exists()) + if (!tmpdir.mkpath(dir)) { QMessageBox directoryMsg(QApplication::activeWindow()); directoryMsg.setIcon(QMessageBox::Warning); @@ -105,14 +103,41 @@ return true; } +bool checkForFile(const QString & file) +{ + QFile tmpfile(file); + if (!tmpfile.exists()) + return tmpfile.open(QFile::WriteOnly); + else + return true; +} + +#ifdef __APPLE__ +static CocoaInitializer *cocoaInit = NULL; +// Function to be called at end of program's termination on OS X to release +// the NSAutoReleasePool contained within the CocoaInitializer. +void releaseCocoaPool(void) +{ + if (cocoaInit != NULL) + { + delete cocoaInit; + cocoaInit = NULL; + } +} +#endif + int main(int argc, char *argv[]) { +#ifdef __APPLE__ + // This creates the autoreleasepool that prevents leaking, and destroys it only on exit + cocoaInit = new CocoaInitializer(); + atexit(releaseCocoaPool); +#endif + HWApplication app(argc, argv); FileEngineHandler engine(argv[0]); - flib_init(); - app.setAttribute(Qt::AA_DontShowIconsInMenus,false); QStringList arguments = app.arguments(); @@ -150,9 +175,14 @@ if(parsedArgs.contains("config-dir")) { QFileInfo f(parsedArgs["config-dir"]); - *cConfigDir = f.absoluteFilePath(); + cfgdir->setPath(f.absoluteFilePath()); custom_config = true; } + else + { + cfgdir->setPath(QDir::homePath()); + custom_config = false; + } app.setStyle(new QPlastiqueStyle()); @@ -164,14 +194,11 @@ qRegisterMetaType("HWTeam"); - bindir->cd("bin"); // workaround over NSIS installer + // workaround over NSIS installer which modifies the install path + //bindir->cd("./"); + bindir->cd(QCoreApplication::applicationDirPath()); - if(cConfigDir->length() == 0) - cfgdir->setPath(cfgdir->homePath()); - else - cfgdir->setPath(*cConfigDir); - - if(cConfigDir->length() == 0) + if(custom_config == false) { #ifdef __APPLE__ checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars"); @@ -212,14 +239,14 @@ datadir->cd(bindir->absolutePath()); datadir->cd(*cDataDir); - if(!datadir->cd("hedgewars/Data")) + if(!datadir->cd("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")); + arg(datadir->absolutePath()+"/Data")); missingMsg.setWindowModality(Qt::WindowModal); missingMsg.exec(); return 1; @@ -228,13 +255,15 @@ // setup PhysFS engine.mount(datadir->absolutePath()); engine.mount(cfgdir->absolutePath() + "/Data"); - engine.mount(cfgdir->absolutePath(), "/config"); + engine.mount(cfgdir->absolutePath()); engine.setWriteDir(cfgdir->absolutePath()); engine.mountPacks(); + checkForFile("physfs://hedgewars.ini"); + QTranslator Translator; { - QSettings settings("physfs://config/hedgewars.ini", QSettings::IniFormat); + QSettings settings("physfs://hedgewars.ini", QSettings::IniFormat); QString cc = settings.value("misc/locale", QString()).toString(); if(cc.isEmpty()) cc = QLocale::system().name(); @@ -254,10 +283,6 @@ registry_hklm.setValue("Software/Hedgewars/Path", bindir->absolutePath().replace("/", "\\")); } #endif -#ifdef __APPLE__ - // this creates the autoreleasepool that prevents leaking - CocoaInitializer initializer; -#endif QString style = ""; QString fname; @@ -294,9 +319,5 @@ app.form = new HWForm(NULL, style); app.form->show(); - int r = app.exec(); - - flib_quit(); - - return r; + return app.exec(); } diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/hwmap.cpp --- a/QTfrontend/net/hwmap.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/hwmap.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -47,9 +47,12 @@ QStringList HWMap::getArguments() { QStringList arguments; - arguments << cfgdir->absolutePath(); + arguments << "--internal"; + arguments << "--port"; arguments << QString("%1").arg(ipc_port); - arguments << "landpreview"; + arguments << "--user-prefix"; + arguments << cfgdir->absolutePath(); + arguments << "--landpreview"; return arguments; } diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/newnetclient.cpp --- a/QTfrontend/net/newnetclient.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/newnetclient.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -241,6 +241,7 @@ { mynick = lst[1]; m_playersModel->setNickname(mynick); + m_nick_registered = false; return ; } @@ -304,6 +305,10 @@ QStringList tmp = lst; tmp.removeFirst(); m_roomsListModel->setRoomsList(tmp); + if (m_nick_registered == false) + { + emit NickNotRegistered(mynick); + } return; } @@ -364,6 +369,14 @@ return; } + if (lst[0] == "BANLIST") + { + QStringList tmp = lst; + tmp.removeFirst(); + emit bansList(tmp); + return; + } + if (lst[0] == "CLIENT_FLAGS") { if(lst.size() < 3 || lst[1].size() < 2) @@ -530,7 +543,8 @@ if (lst[0] == "ASKPASSWORD") { - emit AskForPassword(mynick); + emit NickRegistered(mynick); + m_nick_registered = true; return; } @@ -565,6 +579,10 @@ if (lst[1] == "Authentication failed") { emit AuthFailed(); + m_game_connected = false; + Disconnect(); + //omitted 'emit disconnected()', we don't want the error message + return; } m_game_connected = false; Disconnect(); @@ -621,6 +639,12 @@ return; } + if (lst[0] == "ROUND_FINISHED") + { + emit FromNet(QByteArray("\x01o")); + return; + } + if (lst[0] == "ADD_TEAM") { if(lst.size() != 24) @@ -863,6 +887,26 @@ RawSendNet(QString("BAN%1%2").arg(delimeter).arg(nick)); } +void HWNewNet::banIP(const QString & ip, const QString & reason, int seconds) +{ + RawSendNet(QString("BANIP%1%2%1%3%1%4").arg(delimeter).arg(ip).arg(reason).arg(seconds)); +} + +void HWNewNet::banNick(const QString & nick, const QString & reason, int seconds) +{ + RawSendNet(QString("BANNICK%1%2%1%3%1%4").arg(delimeter).arg(nick).arg(reason).arg(seconds)); +} + +void HWNewNet::getBanList() +{ + RawSendNet(QByteArray("BANLIST")); +} + +void HWNewNet::removeBan(const QString & b) +{ + RawSendNet(QString("UNBAN%1%2").arg(delimeter).arg(b)); +} + void HWNewNet::kickPlayer(const QString & nick) { RawSendNet(QString("KICK%1%2").arg(delimeter).arg(nick)); diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/newnetclient.h Tue Dec 25 04:45:22 2012 +0100 @@ -69,6 +69,7 @@ QTcpSocket NetSocket; QString seed; bool m_game_connected; + bool m_nick_registered; RoomsListModel * m_roomsListModel; PlayersListModel * m_playersModel; QSortFilterProxyModel * m_lobbyPlayersModel; @@ -90,7 +91,8 @@ void disconnected(const QString & reason); void Error(const QString & errmsg); void Warning(const QString & wrnmsg); - void AskForPassword(const QString & nick); + void NickRegistered(const QString & nick); + void NickNotRegistered(const QString & nick); void NickTaken(const QString & nick); void AuthFailed(); void EnteredGame(); @@ -123,6 +125,7 @@ void serverMessageNew(const QString &); void serverMessageOld(const QString &); void latestProtocolVar(int); + void bansList(const QStringList &); void setMyReadyStatus(bool isReady); @@ -157,6 +160,10 @@ void toggleRestrictTeamAdds(); void partRoom(); void clearAccountsCache(); + void getBanList(); + void removeBan(const QString &); + void banIP(const QString & ip, const QString & reason, int seconds); + void banNick(const QString & nick, const QString & reason, int seconds); private slots: void ClientRead(); diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/recorder.cpp --- a/QTfrontend/net/recorder.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/recorder.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -99,29 +99,44 @@ { QStringList arguments; QRect resolution = config->rec_Resolution(); - arguments << cfgdir->absolutePath(); - arguments << QString::number(resolution.width()); - arguments << QString::number(resolution.height()); - arguments << "32"; // bpp + QString nick = config->netNick().toUtf8().toBase64(); + + arguments << "--internal"; + arguments << "--port"; arguments << QString("%1").arg(ipc_port); - arguments << "0"; // fullscreen - arguments << "0"; // sound - arguments << "0"; // music - arguments << "0"; // sound volume + arguments << "--prefix"; + arguments << datadir->absolutePath(); + arguments << "--user-prefix"; + arguments << cfgdir->absolutePath(); + arguments << "--locale"; + arguments << HWGame::tr("en.txt"); + arguments << "--frame-interval"; arguments << QString::number(config->timerInterval()); - arguments << datadir->absolutePath(); - arguments << "0"; // fps - arguments << (config->isAltDamageEnabled() ? "1" : "0"); - arguments << config->netNick().toUtf8().toBase64(); + arguments << "--width"; + arguments << QString::number(resolution.width()); + arguments << "--height"; + arguments << QString::number(resolution.height()); + arguments << "--nosound"; + arguments << "--raw-quality"; arguments << QString::number(config->translateQuality()); + arguments << "--stereo"; arguments << QString::number(config->stereoMode()); - arguments << HWGame::tr("en.txt"); - arguments << QString::number(config->rec_Framerate()); // framerate numerator - arguments << "1"; // framerate denominator + arguments << "--nomusic"; + arguments << "--volume"; + arguments << "0"; + if (config->isAltDamageEnabled()) + arguments << "--altdmg"; + if (!nick.isEmpty()) { + arguments << "--nick"; + arguments << nick; + } + arguments << "--recorder"; + arguments << QString::number(config->rec_Framerate()); //cVideoFramerateNum + arguments << "1"; //cVideoFramerateDen 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. +// 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"); diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/tcpBase.cpp --- a/QTfrontend/net/tcpBase.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/tcpBase.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -29,31 +29,39 @@ #ifdef HWLIBRARY extern "C" void Game(char**arguments); +extern "C" void GenLandPreview(int port); -//NOTE: most likely subclassing QThread is wrong -class EngineThread : public QThread + +EngineInstance::EngineInstance(QObject *parent) + : QObject(parent) { -protected: - void run(); -}; + port = 0; +} -void EngineThread::run() +EngineInstance::~EngineInstance() +{ +} + +void EngineInstance::start() { - char *args[12]; - args[0] = "1"; //cShowFPS - args[1] = "65000"; //ipcPort - args[2] = "1024"; //cScreenWidth - args[3] = "768"; //cScreenHeight - args[4] = "0"; //cReducedQuality - args[5] = "en.txt"; //cLocaleFName - args[6] = "koda"; //UserNick - args[7] = "1"; //SetSound - args[8] = "1"; //SetMusic - args[9] = "0"; //cAltDamage - args[10]= "../Resources/hedgewars/Data"; //cPathPrefix - args[11]= NULL; //recordFileName +#if 0 + char *args[11]; + args[0] = "65000"; //ipcPort + args[1] = "1024"; //cScreenWidth + args[2] = "768"; //cScreenHeight + args[3] = "0"; //cReducedQuality + args[4] = "en.txt"; //cLocaleFName + args[5] = "koda"; //UserNick + args[6] = "1"; //SetSound + args[7] = "1"; //SetMusic + args[8] = "0"; //cAltDamage + args[9]= datadir->absolutePath().toAscii().data(); //cPathPrefix + args[10]= NULL; //recordFileName Game(args); +#endif + GenLandPreview(port); } + #endif QList srvsList; @@ -66,6 +74,7 @@ if (IPCSocket) IPCSocket->deleteLater(); + } TCPBase::TCPBase(bool demoMode, QObject *parent) : @@ -90,11 +99,8 @@ exit(0); // FIXME - should be graceful exit here (lower Critical -> Warning above when implemented) } } -#ifdef HWLIBRARY - ipc_port=65000; //HACK -#else + ipc_port=IPCServer->serverPort(); -#endif } void TCPBase::NewConnection() @@ -118,8 +124,17 @@ IPCSocket = 0; #ifdef HWLIBRARY - EngineThread engineThread;// = new EngineThread(this); - engineThread.start(); + QThread *thread = new QThread; + EngineInstance *instance = new EngineInstance; + instance->port = IPCServer->serverPort(); + + instance->moveToThread(thread); + + connect(thread, SIGNAL(started()), instance, SLOT(start(void))); + connect(instance, SIGNAL(finished()), thread, SLOT(quit())); + connect(instance, SIGNAL(finished()), instance, SLOT(deleteLater())); + connect(instance, SIGNAL(finished()), thread, SLOT(deleteLater())); + thread->start(); #else QProcess * process; process = new QProcess(); diff -r d24257910f8d -r aaefa587e277 QTfrontend/net/tcpBase.h --- a/QTfrontend/net/tcpBase.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/net/tcpBase.h Tue Dec 25 04:45:22 2012 +0100 @@ -81,4 +81,21 @@ void tcpServerReady(); }; +#ifdef HWLIBRARY +class EngineInstance : public QObject +{ + Q_OBJECT +public: + EngineInstance(QObject *parent = 0); + ~EngineInstance(); + + int port; +public slots: + void start(void); +signals: + void finished(void); +private: +}; +#endif + #endif // _TCPBASE_INCLUDED diff -r d24257910f8d -r aaefa587e277 QTfrontend/res/NetworkPlayDisabled.png Binary file QTfrontend/res/NetworkPlayDisabled.png has changed diff -r d24257910f8d -r aaefa587e277 QTfrontend/res/css/christmas.css --- a/QTfrontend/res/css/christmas.css Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/res/css/christmas.css Tue Dec 25 04:45:22 2012 +0100 @@ -21,7 +21,7 @@ background-image: url(":/res/BackgroundChristmas.png"); background-position: bottom center; background-repeat: repeat-x; -background-color: #141250; +background-color: #0c0f28; } * { diff -r d24257910f8d -r aaefa587e277 QTfrontend/res/css/qt.css --- a/QTfrontend/res/css/qt.css Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/res/css/qt.css Tue Dec 25 04:45:22 2012 +0100 @@ -105,7 +105,6 @@ outline: none; } - QHeaderView { border-radius: 0; border-width: 0; diff -r d24257910f8d -r aaefa587e277 QTfrontend/res/html/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/res/html/about.html Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,94 @@ + + + +Hedgewars - Authors + + + + +

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>
+

+ +

Art:

+

John Dum <fizzy@gmail.com> +
+ Joshua Frese <joshfrese@gmail.com> +
+ Stanko Tadić <stanko@mfhinc.net> +
+ Julien Koesten <julienkoesten@aol.com> +
+ Joshua O'Sullivan <coheedftw@hotmail.co.uk> +
+ Nils Lück <nils.luck.design@gmail.com> +
+ Guillaume Englert <genglert@hybird.org> +
+ Hats: Trey Perry <tx.perry.j@gmail.com> +

+ +

Sounds:

+

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

+ +

Translations:

+ 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>, 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 <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>
+ Russian: Andrey Korotaev <unC0Rr@gmail.com>
+ Slovak: Jose Riha
+ Spanish: Carlos Vives <mail@carlosvives.es>
+ Swedish: Niklas Grahn <raewolusjoon@yaoo.com>, Henrik Rostedt <henrik.rostedt@gmail.com>
+ Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>, Igor Paliychuk <mansonigor@gmail.com>, Eugene Sakara <eresid@gmail.com> +

+ +

Special thanks:

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

+ + diff -r d24257910f8d -r aaefa587e277 QTfrontend/team.cpp --- a/QTfrontend/team.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/team.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -169,7 +169,7 @@ bool HWTeam::loadFromFile() { - QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); + QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); teamfile.setIniCodec("UTF-8"); m_name = teamfile.value("Team/Name", m_name).toString(); m_grave = teamfile.value("Team/Grave", "Statue").toString(); @@ -202,7 +202,7 @@ bool HWTeam::fileExists() { - QFile f(QString("physfs://config/Teams/%1.hwt").arg(m_name)); + QFile f(QString("physfs://Teams/%1.hwt").arg(m_name)); return f.exists(); } @@ -210,7 +210,7 @@ { if(m_isNetTeam) return false; - QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(m_name)); + QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(m_name)); cfgfile.remove(); return true; } @@ -219,11 +219,12 @@ { if (OldTeamName != m_name) { - QFile cfgfile(QString("physfs://config/Teams/%1.hwt").arg(OldTeamName)); + QFile cfgfile(QString("physfs://Teams/%1.hwt").arg(OldTeamName)); cfgfile.remove(); OldTeamName = m_name; } - QSettings teamfile(QString("physfs://config/Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); + + QSettings teamfile(QString("physfs://Teams/%1.hwt").arg(m_name), QSettings::IniFormat, 0); teamfile.setIniCodec("UTF-8"); teamfile.setValue("Team/Name", m_name); teamfile.setValue("Team/Grave", m_grave); @@ -234,6 +235,7 @@ teamfile.setValue("Team/Rounds", m_rounds); teamfile.setValue("Team/Wins", m_wins); teamfile.setValue("Team/CampaignProgress", m_campaignProgress); + for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) { QString hh = QString("Hedgehog%1/").arg(i); @@ -251,6 +253,7 @@ teamfile.setValue(QString("Achievements/%1").arg(achievements[i][0]), AchievementProgress[i]); else break; + return true; } diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/dialog/bandialog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/bandialog.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bandialog.h" + +BanDialog::BanDialog(QWidget *parent) : + QDialog(parent) +{ + QFormLayout * formLayout = new QFormLayout(this); + + rbIP = new QRadioButton(this); + rbIP->setChecked(true); + rbNick = new QRadioButton(this); + leId = new QLineEdit(this); + leReason = new QLineEdit(this); + cbTime = new QComboBox(this); + + cbTime->addItem(tr("10 minutes"), 5 * 60); + cbTime->addItem(tr("30 minutes"), 10 * 60); + cbTime->addItem(tr("1 hour"), 60 * 60); + cbTime->addItem(tr("3 hours"), 3 * 60 * 60); + cbTime->addItem(tr("5 hours"), 5 * 60 * 60); + cbTime->addItem(tr("24 hours"), 24 * 60 * 60); + cbTime->addItem(tr("3 days"), 72 * 60 * 60); + cbTime->addItem(tr("7 days"), 168 * 60 * 60); + cbTime->addItem(tr("14 days"), 336 * 60 * 60); + cbTime->addItem(tr("permanent"), 3650 * 24 * 60 * 60); + cbTime->setCurrentIndex(0); + + formLayout->addRow(tr("IP"), rbIP); + formLayout->addRow(tr("Nick"), rbNick); + formLayout->addRow(tr("IP/Nick"), leId); + formLayout->addRow(tr("Reason"), leReason); + formLayout->addRow(tr("Duration"), cbTime); + + formLayout->setLabelAlignment(Qt::AlignRight); + + QHBoxLayout * hbox = new QHBoxLayout(); + formLayout->addRow(hbox); + QPushButton * btnOk = new QPushButton(tr("Ok"), this); + QPushButton * btnCancel = new QPushButton(tr("Cancel"), this); + hbox->addStretch(); + hbox->addWidget(btnOk); + hbox->addWidget(btnCancel); + + connect(btnOk, SIGNAL(clicked()), this, SLOT(okClicked())); + connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); + + this->setWindowModality(Qt::WindowModal); +} + +bool BanDialog::byIP() +{ + return rbIP->isChecked(); +} + +int BanDialog::duration() +{ + return cbTime->itemData(cbTime->currentIndex()).toInt(); +} + +QString BanDialog::banId() +{ + return leId->text(); +} + +QString BanDialog::reason() +{ + return leReason->text().isEmpty() ? tr("you know why") : leReason->text(); +} + +void BanDialog::okClicked() +{ + if(leId->text().isEmpty()) + { + QMessageBox::warning(this, tr("Warning"), tr("Please, specify %1").arg(byIP() ? tr("IP") : tr("nickname"))); + return; + } + + accept(); +} diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/dialog/bandialog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/dialog/bandialog.h Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,32 @@ +#ifndef BANDIALOG_H +#define BANDIALOG_H + +#include + +class QComboBox; +class QRadioButton; +class QLineEdit; + +class BanDialog : public QDialog +{ + Q_OBJECT +public: + explicit BanDialog(QWidget *parent = 0); + + bool byIP(); + int duration(); + QString banId(); + QString reason(); + +private: + QRadioButton * rbIP; + QRadioButton * rbNick; + QLineEdit * leId; + QLineEdit * leReason; + QComboBox * cbTime; + +private slots: + void okClicked(); +}; + +#endif // BANDIALOG_H diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/dialog/input_password.cpp --- a/QTfrontend/ui/dialog/input_password.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/dialog/input_password.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -25,28 +25,44 @@ #include "input_password.h" -HWPasswordDialog::HWPasswordDialog(QWidget* parent, const QString & label) : QDialog(parent) +HWPasswordDialog::HWPasswordDialog(QWidget* parent) : QDialog(parent) { - setWindowTitle(tr("Password")); + setWindowTitle(tr("Login")); + + QString titleLabelText = "To connect to the server, please log in.\n\nIf you don't have an account on www.hedgewars.org,\njust enter your nickname."; + QString nickLabelText = "Nickname:"; + QString passLabelText = "Password:"; QGridLayout * layout = new QGridLayout(this); - QLabel * lbLabel = new QLabel(this); - lbLabel->setText(label); - layout->addWidget(lbLabel, 0, 0); + QLabel * titleLabel = new QLabel(this); + titleLabel->setText(titleLabelText); + layout->addWidget(titleLabel, 0, 0); + + QLabel * nickLabel = new QLabel(this); + nickLabel->setText(nickLabelText); + layout->addWidget(nickLabel, 1, 0); + + leNickname = new QLineEdit(this); + leNickname->setEchoMode(QLineEdit::Normal); + layout->addWidget(leNickname, 2, 0); + + QLabel * passLabel = new QLabel(this); + passLabel->setText(passLabelText); + layout->addWidget(passLabel, 3, 0); lePassword = new QLineEdit(this); lePassword->setEchoMode(QLineEdit::Password); - layout->addWidget(lePassword, 1, 0); + layout->addWidget(lePassword, 4, 0); cbSave = new QCheckBox(this); cbSave->setText(QCheckBox::tr("Save password")); - layout->addWidget(cbSave, 2, 0); + layout->addWidget(cbSave, 5, 0); QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); QPushButton * pbOK = dbbButtons->addButton(QDialogButtonBox::Ok); QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel); - layout->addWidget(dbbButtons, 3, 0); + layout->addWidget(dbbButtons, 6, 0); connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/dialog/input_password.h --- a/QTfrontend/ui/dialog/input_password.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/dialog/input_password.h Tue Dec 25 04:45:22 2012 +0100 @@ -28,9 +28,10 @@ { Q_OBJECT public: - HWPasswordDialog(QWidget* parent, const QString & label); + HWPasswordDialog(QWidget* parent); QLineEdit* lePassword; + QLineEdit* leNickname; QCheckBox* cbSave; }; diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/mouseoverfilter.cpp --- a/QTfrontend/ui/mouseoverfilter.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/mouseoverfilter.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -39,7 +39,7 @@ 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)) + if (button || textfield || checkbox || droplist || slider || tab) { SDLInteraction::instance().playSoundFile("/Sounds/steps.ogg"); } diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/AbstractPage.cpp --- a/QTfrontend/ui/page/AbstractPage.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/AbstractPage.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -41,8 +41,9 @@ QGridLayout * pageLayout = new QGridLayout(this); // stretch grid space for body and footer - pageLayout->setColumnStretch(0,0); - pageLayout->setColumnStretch(1,1); + pageLayout->setColumnStretch(0,1); + pageLayout->setColumnStretch(1,2); + pageLayout->setColumnStretch(2,1); pageLayout->setRowStretch(0,1); pageLayout->setRowStretch(1,0); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageadmin.cpp --- a/QTfrontend/ui/page/pageadmin.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageadmin.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -22,56 +22,98 @@ #include #include #include +#include +#include #include "pageadmin.h" #include "chatwidget.h" +#include "bandialog.h" QLayout * PageAdmin::bodyLayoutDefinition() { - QGridLayout * pageLayout = new QGridLayout(); - - // 0 - pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3); + QVBoxLayout * pageLayout = new QVBoxLayout(); - // 1 - QLabel * lblSMN = new QLabel(this); - lblSMN->setText(tr("Server message for latest version:")); - pageLayout->addWidget(lblSMN, 1, 0); + 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("Bans")); + + // page 1 + { + QGridLayout * tab1Layout = new QGridLayout(page1); + + // 0 + pbAsk = addButton(tr("Fetch data"), tab1Layout, 0, 0, 1, 3); - leServerMessageNew = new QLineEdit(this); - pageLayout->addWidget(leServerMessageNew, 1, 1); + // 1 + QLabel * lblSMN = new QLabel(this); + lblSMN->setText(tr("Server message for latest version:")); + tab1Layout->addWidget(lblSMN, 1, 0); + + leServerMessageNew = new QLineEdit(this); + tab1Layout->addWidget(leServerMessageNew, 1, 1); - // 2 - QLabel * lblSMO = new QLabel(this); - lblSMO->setText(tr("Server message for previous versions:")); - pageLayout->addWidget(lblSMO, 2, 0); + // 2 + QLabel * lblSMO = new QLabel(this); + lblSMO->setText(tr("Server message for previous versions:")); + tab1Layout->addWidget(lblSMO, 2, 0); + + leServerMessageOld = new QLineEdit(this); + tab1Layout->addWidget(leServerMessageOld, 2, 1); - leServerMessageOld = new QLineEdit(this); - pageLayout->addWidget(leServerMessageOld, 2, 1); + // 3 + QLabel * lblP = new QLabel(this); + lblP->setText(tr("Latest version protocol number:")); + tab1Layout->addWidget(lblP, 3, 0); + + sbProtocol = new QSpinBox(this); + tab1Layout->addWidget(sbProtocol, 3, 1); - // 3 - QLabel * lblP = new QLabel(this); - lblP->setText(tr("Latest version protocol number:")); - pageLayout->addWidget(lblP, 3, 0); + // 4 + QLabel * lblPreview = new QLabel(this); + lblPreview->setText(tr("MOTD preview:")); + tab1Layout->addWidget(lblPreview, 4, 0); - sbProtocol = new QSpinBox(this); - pageLayout->addWidget(sbProtocol, 3, 1); + tb = new QTextBrowser(this); + tb->setOpenExternalLinks(true); + tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet()); + tab1Layout->addWidget(tb, 4, 1, 1, 2); + + // 5 + pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), tab1Layout, 5, 0); + + // 6 + pbSetSM = addButton(tr("Set data"), tab1Layout, 6, 0, 1, 3); + } - // 4 - QLabel * lblPreview = new QLabel(this); - lblPreview->setText(tr("MOTD preview:")); - pageLayout->addWidget(lblPreview, 4, 0); + // page 2 + { + QGridLayout * tab2Layout = new QGridLayout(page2); + twBans = new QTableWidget(this); + twBans->setColumnCount(3); + twBans->setHorizontalHeaderLabels(QStringList() + << tr("IP/Nick") + << tr("Expiration") + << tr("Reason") + ); + twBans->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); + twBans->setEditTriggers(QAbstractItemView::NoEditTriggers); + twBans->setSelectionBehavior(QAbstractItemView::SelectRows); + twBans->setSelectionMode(QAbstractItemView::SingleSelection); + twBans->setAlternatingRowColors(true); + tab2Layout->addWidget(twBans, 0, 1, 4, 1); - tb = new QTextBrowser(this); - tb->setOpenExternalLinks(true); - tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet()); - pageLayout->addWidget(tb, 4, 1, 1, 2); + QPushButton * btnRefresh = addButton(tr("Refresh"), tab2Layout, 0, 0); + QPushButton * btnAdd = addButton(tr("Add"), tab2Layout, 1, 0); + QPushButton * btnRemove = addButton(tr("Remove"), tab2Layout, 2, 0); - // 5 - pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0); - - // 6 - pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3); + connect(btnRefresh, SIGNAL(clicked()), this, SIGNAL(bansListRequest())); + connect(btnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClicked())); + connect(btnAdd, SIGNAL(clicked()), this, SLOT(onAddClicked())); + connect(btnRemove, SIGNAL(clicked()), this, SLOT(onRemoveClicked())); + } return pageLayout; } @@ -106,7 +148,64 @@ { leServerMessageOld->setText(str); } + void PageAdmin::protocol(int proto) { sbProtocol->setValue(proto); } + +void PageAdmin::onAddClicked() +{ + BanDialog dialog(this); + + if(dialog.exec()) + { + if(dialog.byIP()) + { + emit banIP(dialog.banId(), dialog.reason(), dialog.duration()); + } else + { + emit banNick(dialog.banId(), dialog.reason(), dialog.duration()); + } + + emit bansListRequest(); + } +} + +void PageAdmin::onRemoveClicked() +{ + QList sel = twBans->selectedItems(); + + if(sel.size()) + { + emit removeBan(twBans->item(sel[0]->row(), 0)->data(Qt::DisplayRole).toString()); + emit bansListRequest(); + } +} + +void PageAdmin::setBansList(const QStringList & bans) +{ + if(bans.size() % 4) + return; + + twBans->setRowCount(bans.size() / 4); + + for(int i = 0; i < bans.size(); i += 4) + { + if(!twBans->item(i / 4, 0)) + { + twBans->setItem(i / 4, 0, new QTableWidgetItem()); + twBans->setItem(i / 4, 1, new QTableWidgetItem()); + twBans->setItem(i / 4, 2, new QTableWidgetItem()); + } + + twBans->item(i / 4, 0)->setData(Qt::DisplayRole, bans[i + 1]); + twBans->item(i / 4, 1)->setData(Qt::DisplayRole, bans[i + 3]); + twBans->item(i / 4, 2)->setData(Qt::DisplayRole, bans[i + 2]); + } +} + +void PageAdmin::onRefreshClicked() +{ + twBans->setRowCount(0); +} diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageadmin.h --- a/QTfrontend/ui/page/pageadmin.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageadmin.h Tue Dec 25 04:45:22 2012 +0100 @@ -21,6 +21,8 @@ #include "AbstractPage.h" +class QTableWidget; + class PageAdmin : public AbstractPage { Q_OBJECT @@ -32,6 +34,7 @@ void serverMessageNew(const QString & str); void serverMessageOld(const QString & str); void protocol(int proto); + void setBansList(const QStringList & bans); signals: void setServerMessageNew(const QString & str); @@ -39,6 +42,10 @@ void setProtocol(int proto); void askServerVars(); void clearAccountsCache(); + void bansListRequest(); + void removeBan(const QString &); + void banIP(const QString & ip, const QString & reason, int seconds); + void banNick(const QString & nick, const QString & reason, int seconds); protected: QLayout * bodyLayoutDefinition(); @@ -52,9 +59,13 @@ QSpinBox * sbProtocol; QTextBrowser * tb; QPushButton * pbClearAccountsCache; + QTableWidget * twBans; private slots: void smChanged(); + void onAddClicked(); + void onRemoveClicked(); + void onRefreshClicked(); }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagefeedback.cpp --- a/QTfrontend/ui/page/pagefeedback.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -20,6 +20,32 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#ifdef Q_WS_WIN +#define WINVER 0x0500 +#include +#else +#include +#include +#endif + +#ifdef Q_WS_MAC +#include +#endif + +#include #include "pagefeedback.h" #include "hwconsts.h" @@ -28,55 +54,347 @@ { QVBoxLayout * pageLayout = new QVBoxLayout(); QHBoxLayout * summaryLayout = new QHBoxLayout(); + QHBoxLayout * emailLayout = new QHBoxLayout(); + QHBoxLayout * descriptionLayout = new QHBoxLayout(); + QHBoxLayout * combinedTopLayout = new QHBoxLayout(); + QHBoxLayout * systemLayout = 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.

" + "

Please give us feedback!

" + "

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

" + "

Your email address is optional, but we may want to contact you.

" "

" ); pageLayout->addWidget(info); + QVBoxLayout * summaryEmailLayout = new QVBoxLayout(); + + const int labelWidth = 90; + + label_email = new QLabel(); + label_email->setText(QLabel::tr("Your Email")); + label_email->setFixedWidth(labelWidth); + emailLayout->addWidget(label_email); + email = new QLineEdit(); + emailLayout->addWidget(email); + summaryEmailLayout->addLayout(emailLayout); + label_summary = new QLabel(); - label_summary->setText(QLabel::tr("Summary ")); + label_summary->setText(QLabel::tr("Summary")); + label_summary->setFixedWidth(labelWidth); summaryLayout->addWidget(label_summary); summary = new QLineEdit(); summaryLayout->addWidget(summary); - pageLayout->addLayout(summaryLayout); + summaryEmailLayout->addLayout(summaryLayout); + + combinedTopLayout->addLayout(summaryEmailLayout); + + + CheckSendSpecs = new QCheckBox(); + CheckSendSpecs->setText(QLabel::tr("Send system information")); + CheckSendSpecs->setChecked(true); + systemLayout->addWidget(CheckSendSpecs); + BtnViewInfo = addButton("View", systemLayout, 1, false); + BtnViewInfo->setFixedSize(60, 30); + connect(BtnViewInfo, SIGNAL(clicked()), this, SLOT(ShowSpecs())); + combinedTopLayout->addLayout(systemLayout); + + combinedTopLayout->setStretch(0, 1); + combinedTopLayout->insertSpacing(1, 20); + + pageLayout->addLayout(combinedTopLayout); label_description = new QLabel(); label_description->setText(QLabel::tr("Description")); - pageLayout->addWidget(label_description, 0, Qt::AlignHCenter); + label_description->setFixedWidth(labelWidth); + descriptionLayout->addWidget(label_description, 0, Qt::AlignTop); description = new QTextBrowser(); description->setReadOnly(false); - pageLayout->addWidget(description); + descriptionLayout->addWidget(description); + pageLayout->addLayout(descriptionLayout); return pageLayout; } +QNetworkAccessManager * PageFeedback::GetNetManager() +{ + if (netManager) return netManager; + netManager = new QNetworkAccessManager(this); + connect(netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(NetReply(QNetworkReply*))); + return netManager; +} + +void PageFeedback::LoadCaptchaImage() +{ + QNetworkAccessManager *netManager = GetNetManager(); + QUrl captchaURL("http://hedgewars.org/feedback/?gencaptcha"); + QNetworkRequest req(captchaURL); + genCaptchaRequest = netManager->get(req); +} + +void PageFeedback::NetReply(QNetworkReply *reply) +{ + if (reply == genCaptchaRequest) + { + if (reply->error() != QNetworkReply::NoError) + { + qDebug() << "Error generating captcha image: " << reply->errorString(); + ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); + return; + } + + bool okay; + QByteArray body = reply->readAll(); + captchaID = QString(body).toInt(&okay); + + if (!okay) + { + qDebug() << "Failed to get captcha ID: " << body; + ShowErrorMessage(QMessageBox::tr("Failed to generate captcha")); + return; + } + + QString url = "http://hedgewars.org/feedback/?captcha&id="; + url += QString::number(captchaID); + + QNetworkAccessManager *netManager = GetNetManager(); + QUrl captchaURL(url); + QNetworkRequest req(captchaURL); + captchaImageRequest = netManager->get(req); + } + else if (reply == captchaImageRequest) + { + if (reply->error() != QNetworkReply::NoError) + { + qDebug() << "Error loading captcha image: " << reply->errorString(); + ShowErrorMessage(QMessageBox::tr("Failed to download captcha")); + return; + } + + QByteArray imageData = reply->readAll(); + QPixmap pixmap; + pixmap.loadFromData(imageData); + label_captcha->setPixmap(pixmap); + captcha_code->setText(""); + } +} + QLayout * PageFeedback::footerLayoutDefinition() { QHBoxLayout * bottomLayout = new QHBoxLayout(); + QHBoxLayout * captchaLayout = new QHBoxLayout(); + QVBoxLayout * captchaInputLayout = new QVBoxLayout(); - bottomLayout->setStretch(0,1); + label_captcha = new QLabel(); + label_captcha->setStyleSheet("border: 3px solid #ffcc00; border-radius: 4px"); + label_captcha->setText("
loading
captcha
"); + captchaLayout->addWidget(label_captcha); + + label_captcha_input = new QLabel(); + label_captcha_input->setText(QLabel::tr("Type the security code:")); + captchaInputLayout->addWidget(label_captcha_input); + captchaInputLayout->setAlignment(label_captcha, Qt::AlignBottom); + captcha_code = new QLineEdit(); + captcha_code->setFixedSize(165, 30); + captchaInputLayout->addWidget(captcha_code); + captchaInputLayout->setAlignment(captcha_code, Qt::AlignTop); + captchaLayout->addLayout(captchaInputLayout); + captchaLayout->setAlignment(captchaInputLayout, Qt::AlignLeft); + + captchaLayout->insertSpacing(-1, 40); + bottomLayout->addLayout(captchaLayout); + //TODO: create logo for send button - BtnSend = addButton("Send", bottomLayout, 0, false); - bottomLayout->insertStretch(0); + BtnSend = addButton("Send Feedback", bottomLayout, 0, false); + BtnSend->setFixedSize(120, 40); + + bottomLayout->setStretchFactor(captchaLayout, 0); + bottomLayout->setStretchFactor(BtnSend, 1); return bottomLayout; } +void PageFeedback::GenerateSpecs() +{ + // Gather some information about the system and embed it into the report + QDesktopWidget* screen = QApplication::desktop(); + QString os_version = "Operating system: "; + QString qt_version = QString("Qt version: ") + QT_VERSION_STR + QString("\n"); + QString total_ram = "Total RAM: "; + QString number_of_cores = "Number of cores: "; + QString compiler_bits = "Compiler architecture: "; + QString compiler_version = "Compiler version: "; + QString kernel_line = "Kernel: "; + QString screen_size = "Size of the screen(s): " + + QString::number(screen->width()) + "x" + QString::number(screen->height()) + "\n"; + QString number_of_screens = "Number of screens: " + QString::number(screen->screenCount()) + "\n"; + std::string processor_name = "Processor: "; + + // platform specific code +#ifdef Q_WS_MACX + number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n"; + + uint64_t memsize; + size_t len = sizeof(memsize); + static int mib_s[2] = { CTL_HW, HW_MEMSIZE }; + if (sysctl (mib_s, 2, &memsize, &len, NULL, 0) == 0) + total_ram += QString::number(memsize/1024/1024) + " MB\n"; + else + total_ram += "Error getting total RAM information\n"; + + int mib[] = {CTL_KERN, KERN_OSRELEASE}; + sysctl(mib, sizeof mib / sizeof(int), NULL, &len, NULL, 0); + + char *kernelVersion = (char *)malloc(sizeof(char)*len); + sysctl(mib, sizeof mib / sizeof(int), kernelVersion, &len, NULL, 0); + + QString kernelVersionStr = QString(kernelVersion); + free(kernelVersion); + int major_version = kernelVersionStr.split(".").first().toUInt() - 4; + int minor_version = kernelVersionStr.split(".").at(1).toUInt(); + os_version += QString("Mac OS X 10.%1.%2").arg(major_version).arg(minor_version) + " "; + + switch(major_version) + { + case 4: os_version += "\"Tiger\"\n"; break; + case 5: os_version += "\"Leopard\"\n"; break; + case 6: os_version += "\"Snow Leopard\"\n"; break; + case 7: os_version += "\"Lion\"\n"; break; + case 8: os_version += "\"Mountain Lion\"\n"; break; + default: os_version += "\"Unknown version\"\n"; break; + } +#endif +#ifdef Q_WS_WIN + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n"; + MEMORYSTATUSEX status; + status.dwLength = sizeof(status); + GlobalMemoryStatusEx(&status); + total_ram += QString::number(status.ullTotalPhys); + + switch(QSysInfo::WinVersion()) + { + case QSysInfo::WV_2000: os_version += "Windows 2000\n"; break; + case QSysInfo::WV_XP: os_version += "Windows XP\n"; break; + case QSysInfo::WV_VISTA: os_version += "Windows Vista\n"; break; + case QSysInfo::WV_WINDOWS7: os_version += "Windows 7\n"; break; + default: os_version += "Windows (Unknown version)\n"; break; + } + kernel_line += "Windows kernel\n"; +#endif +#ifdef Q_WS_X11 + number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n"; + long pages = sysconf(_SC_PHYS_PAGES), +#ifndef Q_OS_FREEBSD + available_pages = sysconf(_SC_AVPHYS_PAGES), +#else + available_pages = 0, +#endif + page_size = sysconf(_SC_PAGE_SIZE); + total_ram += QString::number(pages * page_size) + "\n"; + os_version += "GNU/Linux or BSD\n"; +#endif + + // uname -a +#if defined(Q_WS_X11) || defined(Q_WS_MACX) + QProcess *process = new QProcess(); + QStringList arguments = QStringList("-a"); + process->start("uname", arguments); + if (process->waitForFinished()) + kernel_line += QString(process->readAll()); + delete process; +#endif + + // cpu info + quint32 registers[4]; + quint32 i; + + i = 0x80000002; + asm volatile + ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) + : "a" (i), "c" (0)); + processor_name += std::string((const char *)®isters[0], 4); + processor_name += std::string((const char *)®isters[1], 4); + processor_name += std::string((const char *)®isters[2], 4); + processor_name += std::string((const char *)®isters[3], 4); + i = 0x80000003; + asm volatile + ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) + : "a" (i), "c" (0)); + processor_name += std::string((const char *)®isters[0], 4); + processor_name += std::string((const char *)®isters[1], 4); + processor_name += std::string((const char *)®isters[2], 4); + processor_name += std::string((const char *)®isters[3], 4); + i = 0x80000004; + asm volatile + ("cpuid" : "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]) + : "a" (i), "c" (0)); + processor_name += std::string((const char *)®isters[0], 4); + processor_name += std::string((const char *)®isters[1], 4); + processor_name += std::string((const char *)®isters[2], 4); + processor_name += std::string((const char *)®isters[3], 3); + + // compiler +#ifdef __GNUC__ + compiler_version += "GCC " + QString(__VERSION__) + "\n"; +#else + compiler_version += "Unknown\n"; +#endif + + if(sizeof(void*) == 4) + compiler_bits += "i386\n"; + else if(sizeof(void*) == 8) + compiler_bits += "x86_64\n"; + + // concat system info + specs = qt_version + + os_version + + total_ram + + screen_size + + number_of_screens + + QString::fromStdString(processor_name + "\n") + + number_of_cores + + compiler_version + + compiler_bits + + kernel_line; +} + void PageFeedback::connectSignals() { //TODO } +void PageFeedback::ShowErrorMessage(const QString & msg) +{ + QMessageBox msgMsg(this); + msgMsg.setIcon(QMessageBox::Warning); + msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error")); + msgMsg.setText(msg); + msgMsg.setWindowModality(Qt::WindowModal); + msgMsg.exec(); +} + +void PageFeedback::ShowSpecs() +{ + QMessageBox msgMsg(this); + msgMsg.setIcon(QMessageBox::Information); + msgMsg.setWindowTitle(QMessageBox::tr("System Information Preview")); + msgMsg.setText(specs); + msgMsg.setTextFormat(Qt::PlainText); + msgMsg.setWindowModality(Qt::WindowModal); + msgMsg.setStyleSheet("background: #0A0533;"); + msgMsg.exec(); +} + PageFeedback::PageFeedback(QWidget* parent) : AbstractPage(parent) { initPage(); - + netManager = NULL; + GenerateSpecs(); } diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagefeedback.h --- a/QTfrontend/ui/page/pagefeedback.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagefeedback.h Tue Dec 25 04:45:22 2012 +0100 @@ -21,24 +21,50 @@ #include "AbstractPage.h" +class QNetworkReply; +class QNetworkAccessManager; + class PageFeedback : public AbstractPage { Q_OBJECT public: PageFeedback(QWidget * parent = 0); + void EmbedSystemInfo(); + void LoadCaptchaImage(); QPushButton * BtnSend; + QPushButton * BtnViewInfo; + QCheckBox * CheckSendSpecs; QLineEdit * summary; QTextBrowser * description; QLabel * info; QLabel * label_summary; QLabel * label_description; + QLabel * label_captcha; + QLabel * label_email; + QLabel * label_captcha_input; + QLineEdit * captcha_code; + QLineEdit * email; + int captchaID; + QString specs; + + private slots: + + virtual void NetReply(QNetworkReply*); + virtual void ShowSpecs(); private: + void GenerateSpecs(); QLayout * bodyLayoutDefinition(); QLayout * footerLayoutDefinition(); + QNetworkAccessManager * GetNetManager(); + void ShowErrorMessage(const QString & msg); void connectSignals(); + + QNetworkAccessManager * netManager; + QNetworkReply * captchaImageRequest; + QNetworkReply * genCaptchaRequest; }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagemain.cpp --- a/QTfrontend/ui/page/pagemain.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagemain.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -46,10 +46,35 @@ BtnSinglePlayer->setWhatsThis(tr("Play a game on a single computer")); pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); + //BtnNet = addButton(":/res/NetworkPlay.png", (QBoxLayout*)netLayout, 1, true); BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); BtnNet->setToolTip(tr("Network Game")); BtnNet->setWhatsThis(tr("Play a game across a network")); pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); + connect(BtnNet, SIGNAL(clicked()), this, SLOT(toggleNetworkChoice())); + + originalNetworkIcon = BtnNet->icon(); + disabledNetworkIcon = QIcon(":/res/NetworkPlayDisabled.png"); + + //QWidget *netLayoutWidget = new QWidget(); + QVBoxLayout *netLayout = new QVBoxLayout(BtnNet); + //pageLayout->addWidget(netLayoutWidget, 2, 2, 1, 2); + //netLayoutWidget->setStyleSheet("background: green;"); + //netLayoutWidget->setFixedSize(314, 260); + netLayout->setSpacing(20); + netLayout->setAlignment(Qt::AlignHCenter); + + BtnNetLocal = addButton("Play local network game", (QBoxLayout*)netLayout, 0, false); + BtnNetLocal->setToolTip(tr("Play a local network game")); + BtnNetLocal->setWhatsThis(tr("Play a game across a local area network")); + BtnNetLocal->setFixedSize(BtnNet->width() - 50, 60); + BtnNetLocal->setVisible(false); + + BtnNetOfficial = addButton("Play official network game", (QBoxLayout*)netLayout, 0, false); + BtnNetOfficial->setToolTip(tr("Play a network game")); + BtnNetOfficial->setWhatsThis(tr("Play a game on an official server")); + BtnNetOfficial->setFixedSize(BtnNet->width() - 50, 60); + BtnNetOfficial->setVisible(false); // button order matters for overlapping (what's on top and what isn't) BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); @@ -59,10 +84,12 @@ pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); BtnFeedback = addButton("Feedback", pageLayout, 4, 0, 1, 4, false); + BtnFeedback->setFixedSize(86, 27); BtnFeedback->setWhatsThis(tr("Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars")); pageLayout->setAlignment(BtnFeedback, Qt::AlignHCenter); BtnDataDownload = addButton(tr("Downloadable Content"), pageLayout, 5, 0, 1, 4, false); + BtnDataDownload->setFixedSize(176, 27); //BtnDataDownload->setToolTip(tr(Downloadable Content")); BtnDataDownload->setWhatsThis(tr("Access the user created content downloadable from our website")); pageLayout->setAlignment(BtnDataDownload, Qt::AlignHCenter); @@ -115,7 +142,7 @@ } else { - 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!")); + setDefautDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game, while some features might be broken or incomplete!")); } } @@ -182,3 +209,12 @@ return Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]; } + +void PageMain::toggleNetworkChoice() +{ + bool visible = BtnNetLocal->isVisible(); + BtnNetLocal->setVisible(!visible); + BtnNetOfficial->setVisible(!visible); + if (visible) BtnNet->setIcon(originalNetworkIcon); + else BtnNet->setIcon(disabledNetworkIcon); +} diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagemain.h --- a/QTfrontend/ui/page/pagemain.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagemain.h Tue Dec 25 04:45:22 2012 +0100 @@ -21,15 +21,19 @@ #include "AbstractPage.h" +class QIcon; + class PageMain : public AbstractPage { - Q_OBJECT + Q_OBJECT public: PageMain(QWidget * parent = 0); QPushButton * BtnSinglePlayer; QPushButton * BtnNet; + QPushButton * BtnNetLocal; + QPushButton * BtnNetOfficial; QPushButton * BtnSetup; QPushButton * BtnFeedback; QPushButton * BtnInfo; @@ -41,8 +45,12 @@ QLayout * bodyLayoutDefinition(); QLayout * footerLayoutDefinition(); void connectSignals(); + QIcon originalNetworkIcon, disabledNetworkIcon; QString randomTip() const; + + private slots: + void toggleNetworkChoice(); }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagenetgame.cpp --- a/QTfrontend/ui/page/pagenetgame.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagenetgame.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -37,10 +37,10 @@ pageLayout->setColumnStretch(1, 50); // chatwidget - pChatWidget = new HWChatWidget(this, m_gameSettings, true); - 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); + chatWidget = new HWChatWidget(this, true); + chatWidget->setShowFollow(false); // don't show follow in nicks' context menus + chatWidget->setIgnoreListKick(true); // kick ignored players automatically + pageLayout->addWidget(chatWidget, 2, 0, 1, 2); pageLayout->setRowStretch(1, 100); pageLayout->setRowStretch(2, 100); @@ -96,10 +96,8 @@ connect(BtnUpdate, SIGNAL(clicked()), this, SLOT(onUpdateClick())); } -PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings) : AbstractPage(parent) +PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) { - m_gameSettings = gameSettings; - initPage(); QMenu * menu = new QMenu(BtnMaster); @@ -113,24 +111,23 @@ menu->addAction(restrictTeamAdds); BtnMaster->setMenu(menu); - } void PageNetGame::displayError(const QString & message) { - pChatWidget->displayError(message); + chatWidget->displayError(message); } void PageNetGame::displayNotice(const QString & message) { - pChatWidget->displayNotice(message); + chatWidget->displayNotice(message); } void PageNetGame::displayWarning(const QString & message) { - pChatWidget->displayWarning(message); + chatWidget->displayWarning(message); } @@ -178,5 +175,5 @@ void PageNetGame::setUser(const QString & nickname) { - pChatWidget->setUser(nickname); + chatWidget->setUser(nickname); } diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagenetgame.h --- a/QTfrontend/ui/page/pagenetgame.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagenetgame.h Tue Dec 25 04:45:22 2012 +0100 @@ -32,7 +32,7 @@ Q_OBJECT public: - PageNetGame(QWidget* parent, QSettings * gameSettings); + PageNetGame(QWidget* parent); /** * Sets the room name to display. @@ -52,7 +52,7 @@ QAction * restrictJoins; QAction * restrictTeamAdds; - HWChatWidget* pChatWidget; + HWChatWidget* chatWidget; TeamSelWidget* pNetTeamsWidget; GameCFGWidget* pGameCFG; @@ -72,8 +72,6 @@ QLayout * footerLayoutDefinition(); void connectSignals(); - QSettings * m_gameSettings; - HistoryLineEdit * leRoomName; QPushButton * btnSetup; }; diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagenettype.cpp --- a/QTfrontend/ui/page/pagenettype.cpp Sun Dec 02 00:03:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * 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 "pagenettype.h" - - -QLayout * PageNetType::bodyLayoutDefinition() -{ - QGridLayout * pageLayout = new QGridLayout(); - pageLayout->setRowStretch(0, 10); - pageLayout->setRowStretch(3, 10); - - pageLayout->setColumnStretch(1, 10); - pageLayout->setColumnStretch(2, 20); - 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); - - return pageLayout; -} - -PageNetType::PageNetType(QWidget* parent) : AbstractPage(parent) -{ - initPage(); -} diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagenettype.h --- a/QTfrontend/ui/page/pagenettype.h Sun Dec 02 00:03:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * 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_NETTYPE_H -#define PAGE_NETTYPE_H - -#include "AbstractPage.h" - -class PageNetType : public AbstractPage -{ - Q_OBJECT - - public: - PageNetType(QWidget* parent = 0); - - QPushButton * BtnLAN; - QPushButton * BtnOfficialServer; - - protected: - QLayout * bodyLayoutDefinition(); -}; - -#endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageoptions.cpp --- a/QTfrontend/ui/page/pageoptions.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -33,10 +33,19 @@ #include #include "pageoptions.h" +#include "gameuiconfig.h" #include "hwconsts.h" #include "fpsedit.h" #include "igbox.h" #include "DataManager.h" +#include "LibavInteraction.h" +#include "AutoUpdater.h" + +#ifdef __APPLE__ +#ifdef SPARKLE_ENABLED +#include "SparkleAutoUpdater.h" +#endif +#endif // TODO cleanup QLayout * PageOptions::bodyLayoutDefinition() @@ -50,6 +59,11 @@ tabs->addTab(page1, tr("General")); tabs->addTab(page2, tr("Advanced")); +#ifdef VIDEOREC + QWidget * page3 = new QWidget(this); + tabs->addTab(page3, tr("Video Recording")); +#endif + { // page 1 QGridLayout * page1Layout = new QGridLayout(page1); //gbTBLayout->setMargin(0); @@ -191,11 +205,7 @@ // List of installed languages CBLanguage = new QComboBox(groupMisc); - QDir tmpdir; - tmpdir.cd(cfgdir->absolutePath()); - tmpdir.cd("Data/Locale"); - tmpdir.setFilter(QDir::Files); - QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm")); + QStringList locs = DataManager::instance().entryList("Locale", QDir::Files, QStringList("hedgewars_*.qm")); CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); for(int i = 0; i < locs.count(); i++) { @@ -203,17 +213,6 @@ CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); } - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Locale"); - tmpdir.setFilter(QDir::Files); - QStringList tmplist = tmpdir.entryList(QStringList("hedgewars_*.qm")); - for(int i = 0; i < tmplist.count(); i++) - { - if (locs.contains(tmplist[i])) continue; - QLocale loc(tmplist[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); - CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); - } - MiscLayout->addWidget(CBLanguage, 0, 1); // Label and field for net nick @@ -239,7 +238,14 @@ #ifdef SPARKLE_ENABLED CBAutoUpdate = new QCheckBox(groupMisc); CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); - MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 3); + MiscLayout->addWidget(CBAutoUpdate, 7, 0, 1, 1); + + btnUpdateNow = new QPushButton(groupMisc); + connect(btnUpdateNow, SIGNAL(clicked()), this, SLOT(checkForUpdates())); + btnUpdateNow->setToolTip(tr("Check for updates")); + btnUpdateNow->setText("Check now"); + btnUpdateNow->setFixedSize(130, 30); + MiscLayout->addWidget(btnUpdateNow, 7, 1, 1, 1); #endif #endif page1Layout->addWidget(groupMisc, 2, 0); @@ -253,25 +259,33 @@ AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); + QGridLayout * GBAfrontendlayout = new QGridLayout(0); QHBoxLayout * GBAreslayout = new QHBoxLayout(0); QHBoxLayout * GBAstereolayout = new QHBoxLayout(0); QHBoxLayout * GBAqualayout = new QHBoxLayout(0); + QLabel * frontend = new QLabel(AGGroupBox); + frontend->setText(QLabel::tr("Frontend")); + frontend->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + GBAfrontendlayout->addWidget(frontend, 0, 0, 1, 2); + CBFrontendFullscreen = new QCheckBox(AGGroupBox); - CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); - GBAlayout->addWidget(CBFrontendFullscreen); + CBFrontendFullscreen->setText(QCheckBox::tr("Fullscreen")); + GBAfrontendlayout->addWidget(CBFrontendFullscreen, 1, 0); CBFrontendEffects = new QCheckBox(AGGroupBox); - CBFrontendEffects->setText(QCheckBox::tr("Frontend effects")); - GBAlayout->addWidget(CBFrontendEffects); + CBFrontendEffects->setText(QCheckBox::tr("Visual effects")); + GBAfrontendlayout->addWidget(CBFrontendEffects, 2, 0); - CBEnableFrontendSound = new QCheckBox(AGGroupBox); - CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds")); - GBAlayout->addWidget(CBEnableFrontendSound); + CBFrontendSound = new QCheckBox(AGGroupBox); + CBFrontendSound->setText(QCheckBox::tr("Sound")); + GBAfrontendlayout->addWidget(CBFrontendSound, 1, 1); - CBEnableFrontendMusic = new QCheckBox(AGGroupBox); - CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music")); - GBAlayout->addWidget(CBEnableFrontendMusic); + CBFrontendMusic = new QCheckBox(AGGroupBox); + CBFrontendMusic->setText(QCheckBox::tr("Music")); + GBAfrontendlayout->addWidget(CBFrontendMusic, 2, 1); + + GBAlayout->addLayout(GBAfrontendlayout); QFrame * hr = new QFrame(AGGroupBox); hr->setFrameStyle(QFrame::HLine); @@ -345,13 +359,15 @@ volumeBox->setSingleStep(5); GBAvollayout->addWidget(volumeBox, 0, 2); - CBEnableSound = new QCheckBox(AGGroupBox); - CBEnableSound->setText(QCheckBox::tr("Enable sound")); - GBAvollayout->addWidget(CBEnableSound, 1, 0, 1, 1); + CBSound = new QCheckBox(AGGroupBox); + CBSound->setText(QCheckBox::tr("Sound")); + CBSound->setWhatsThis(QCheckBox::tr("In-game sound effects")); + GBAvollayout->addWidget(CBSound, 1, 0); - CBEnableMusic = new QCheckBox(AGGroupBox); - CBEnableMusic->setText(QCheckBox::tr("Enable music")); - GBAvollayout->addWidget(CBEnableMusic, 1, 1, 1, 2); + CBMusic = new QCheckBox(AGGroupBox); + CBMusic->setText(QCheckBox::tr("Music")); + CBMusic->setWhatsThis(QCheckBox::tr("In-game music")); + GBAvollayout->addWidget(CBMusic, 1, 1, 1, 2); GBAvollayout->setSizeConstraint(QLayout::SetMinimumSize); @@ -492,6 +508,121 @@ page2Layout->addWidget(new QWidget(this), 2, 0); } +#ifdef VIDEOREC + { // page 3 + QGridLayout * page3Layout = new QGridLayout(page3); + + IconedGroupBox* pOptionsGroup = new IconedGroupBox(this); + pOptionsGroup->setIcon(QIcon(":/res/Settings.png")); // FIXME + pOptionsGroup->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + 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); + LibavInteraction::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); + + framerateBox = new QComboBox(pOptionsGroup); + framerateBox->addItem("24 fps", 24); + framerateBox->addItem("25 fps", 25); + framerateBox->addItem("30 fps", 30); + framerateBox->addItem("50 fps", 50); + framerateBox->addItem("60 fps", 60); + 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")); + btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters")); + pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5); + + page3Layout->addWidget(pOptionsGroup, 1, 0); + } +#endif previousQuality = this->SLQuality->value(); previousResolutionIndex = this->CBResolution->currentIndex(); @@ -507,6 +638,13 @@ void PageOptions::connectSignals() { +#ifdef VIDEOREC + 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())); +#endif + 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))); @@ -515,7 +653,7 @@ connect(CBSavePassword, SIGNAL(stateChanged(int)), this, SLOT(savePwdChanged(int))); } -PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) +PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent), config(0) { initPage(); } @@ -634,3 +772,145 @@ leProxyLogin->setEnabled(b); leProxyPassword->setEnabled(b); } + +// Video Recording + +void PageOptions::setConfig(GameUIConfig * config) +{ + this->config = config; +} + +// user changed file format, we need to update list of codecs +void PageOptions::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 + LibavInteraction::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 PageOptions::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 PageOptions::changeRecordAudio(int state) +{ + comboAudioCodecs->setEnabled(!!state); +} + +void PageOptions::setDefaultCodecs() +{ + // VLC should be able to handle any of these configurations + // Quicktime X only opens the first one + // Windows Media Player TODO + if (tryCodecs("mp4", "libx264", "aac")) + return; + if (tryCodecs("mp4", "libx264", "libfaac")) + return; + if (tryCodecs("mp4", "libx264", "libmp3lame")) + 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 PageOptions::setDefaultOptions() +{ + framerateBox->setCurrentIndex(2); + bitrateBox->setValue(1000); + checkRecordAudio->setChecked(true); + checkUseGameRes->setChecked(true); + setDefaultCodecs(); +} + +void PageOptions::checkForUpdates() +{ + AutoUpdater *updater = NULL; + +#ifdef __APPLE__ +#ifdef SPARKLE_ENABLED + updater = new SparkleAutoUpdater(); +#endif +#endif + + if (updater) + { + updater->checkForUpdatesNow(); + delete updater; + } +} + +bool PageOptions::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; +} diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageoptions.h --- a/QTfrontend/ui/page/pageoptions.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageoptions.h Tue Dec 25 04:45:22 2012 +0100 @@ -21,6 +21,7 @@ #include "AbstractPage.h" +class GameUIConfig; class FPSEdit; class IconedGroupBox; class QSignalMapper; @@ -57,10 +58,10 @@ IconedGroupBox *AGGroupBox; QComboBox *CBResolution; QComboBox *CBStereoMode; - QCheckBox *CBEnableSound; - QCheckBox *CBEnableFrontendSound; - QCheckBox *CBEnableMusic; - QCheckBox *CBEnableFrontendMusic; + QCheckBox *CBFrontendSound; + QCheckBox *CBFrontendMusic; + QCheckBox *CBSound; + QCheckBox *CBMusic; QCheckBox *CBFullscreen; QCheckBox *CBFrontendFullscreen; QCheckBox *CBShowFPS; @@ -69,6 +70,7 @@ QCheckBox *CBNameWithDate; #ifdef __APPLE__ QCheckBox *CBAutoUpdate; + QPushButton *BtnUpdateNow; #endif FPSEdit *fpsedit; @@ -84,6 +86,26 @@ QLineEdit * leProxyLogin; QLineEdit * leProxyPassword; + QComboBox *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 setConfig(GameUIConfig * config); + void setTeamOptionsEnabled(bool enabled); signals: @@ -106,6 +128,13 @@ QPushButton *BtnDeleteTeam; QList m_colorButtons; + QComboBox *comboAVFormats; + QComboBox *comboVideoCodecs; + QComboBox *comboAudioCodecs; + QPushButton *btnDefaults; + QPushButton *btnUpdateNow; + GameUIConfig * config; + private slots: void forceFullscreen(int index); void setFullscreen(int state); @@ -118,6 +147,13 @@ void colorButtonClicked(int i); void onColorModelDataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); void onProxyTypeChanged(); + void changeAVFormat(int index); + void changeUseGameRes(int state); + void changeRecordAudio(int state); + void checkForUpdates(); + + public slots: + void setDefaultOptions(); }; #endif diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageroomslist.cpp --- a/QTfrontend/ui/page/pageroomslist.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageroomslist.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -95,7 +95,7 @@ pageLayout->addLayout(filterLayout, 4, 0, 1, 2); - chatWidget = new HWChatWidget(this, m_gameSettings, false); + chatWidget = new HWChatWidget(this, false); pageLayout->addWidget(chatWidget, 5, 0, 1, 3); pageLayout->setRowStretch(5, 350); @@ -156,11 +156,9 @@ } -PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings) : +PageRoomsList::PageRoomsList(QWidget* parent) : AbstractPage(parent) { - m_gameSettings = gameSettings; - roomsModel = NULL; stateFilteredModel = NULL; schemeFilteredModel = NULL; @@ -612,13 +610,17 @@ QString("*%1*").arg(CBWeapons->currentText())); } +void PageRoomsList::setSettings(QSettings *settings) +{ + m_gameSettings = settings; +} 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()))); + (m_gameSettings->value("frontend/roomslist_header").toByteArray()))); } void PageRoomsList::saveHeaderState() diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pageroomslist.h --- a/QTfrontend/ui/page/pageroomslist.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pageroomslist.h Tue Dec 25 04:45:22 2012 +0100 @@ -32,10 +32,11 @@ Q_OBJECT public: - PageRoomsList(QWidget* parent, QSettings * config); + PageRoomsList(QWidget* parent); void displayError(const QString & message); void displayNotice(const QString & message); void displayWarning(const QString & message); + void setSettings(QSettings * settings); QLineEdit * roomName; QLineEdit * searchText; diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagetraining.cpp --- a/QTfrontend/ui/page/pagetraining.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagetraining.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -118,7 +118,7 @@ DataManager & dataMgr = DataManager::instance(); // get locale - QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", + QSettings settings("physfs://hedgewars.ini", QSettings::IniFormat); QString loc = settings.value("misc/locale", "").toString(); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagevideos.cpp --- a/QTfrontend/ui/page/pagevideos.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagevideos.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -109,119 +109,6 @@ 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); - LibavInteraction::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")); - btnDefaults->setWhatsThis(QPushButton::tr("Restore default coding parameters")); - pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5); - - pPageLayout->addWidget(pOptionsGroup, 1, 0); - } // list of videos { @@ -257,7 +144,7 @@ box->addWidget(filesTable); box->addWidget(btnOpenDir); - pPageLayout->addWidget(pTableGroup, 0, 1, 2, 1); + pPageLayout->addWidget(pTableGroup, 0, 1); } // description @@ -267,7 +154,6 @@ 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 @@ -282,18 +168,18 @@ "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::TextSelectableByKeyboard | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard); labelDesc->setTextFormat(Qt::RichText); labelDesc->setOpenExternalLinks(true); - pTopDescLayout->addWidget(labelDesc, 1); + labelDesc->setMinimumSize(ThumbnailSize); + //pTopDescLayout->addWidget(labelDesc, 1); // buttons: play and delete btnPlay = new QPushButton(QPushButton::tr("Play"), pDescGroup); @@ -310,7 +196,9 @@ pBottomDescLayout->addWidget(btnToYouTube); pDescLayout->addStretch(1); - pDescLayout->addLayout(pTopDescLayout, 0); + pDescLayout->addWidget(labelThumbnail, 0); + pDescLayout->addStretch(1); + pDescLayout->addWidget(labelDesc, 0); pDescLayout->addStretch(1); pDescLayout->addLayout(pBottomDescLayout, 0); @@ -327,10 +215,6 @@ 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())); @@ -362,124 +246,6 @@ 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 - LibavInteraction::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() -{ - // VLC should be able to handle any of these configurations - // Quicktime X only opens the first one - // Windows Media Player TODO - if (tryCodecs("mp4", "libx264", "aac")) - return; - if (tryCodecs("mp4", "libx264", "libfaac")) - return; - if (tryCodecs("mp4", "libx264", "libmp3lame")) - 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(30); - bitrateBox->setValue(1000); - 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) { @@ -1096,7 +862,7 @@ int row = filesTable->currentRow(); VideoItem * item = nameItem(row); - if (item->pUploading) + if (item->pUploading) //Act as 'cancel uploading' button { // ask user if (s)he is serious QMessageBox reallyStopMsg(this); @@ -1108,9 +874,10 @@ if (reallyStopMsg.exec() != QMessageBox::Ok) return; - item->pUploading->deleteLater(); + item->pUploading->abort(); + btnToYouTube->setText(QPushButton::tr("Upload to YouTube")); filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar - numUploads--; + //numUploads--; return; } diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/page/pagevideos.h --- a/QTfrontend/ui/page/pagevideos.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/page/pagevideos.h Tue Dec 25 04:45:22 2012 +0100 @@ -36,24 +36,6 @@ 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 @@ -83,12 +65,6 @@ GameUIConfig * config; QNetworkAccessManager* netManager; - // options group - QComboBox *comboAVFormats; - QComboBox *comboVideoCodecs; - QComboBox *comboAudioCodecs; - QPushButton *btnDefaults; - // file list group QTableWidget *filesTable; QPushButton *btnOpenDir; @@ -105,10 +81,6 @@ 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); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/about.cpp --- a/QTfrontend/ui/widget/about.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/about.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -21,6 +21,10 @@ #include #include #include +#include +#include +#include +#include #include "hwconsts.h" #include "SDLInteraction.h" @@ -59,97 +63,9 @@ mainLayout->addWidget(lbl1, 0, 1); lbl2 = new QTextBrowser(this); - 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>
" - "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( - "

John Dum <fizzy@gmail.com>" - "
" - "Joshua Frese <joshfrese@gmail.com>" - "
" - "Stanko Tadić <stanko@mfhinc.net>" - "
" - "Julien Koesten <julienkoesten@aol.com>" - "
" - "Joshua O'Sullivan <coheedftw@hotmail.co.uk>" - "
" - "Nils Lück <nils.luck.design@gmail.com>" - "
" - "Guillaume Englert <genglert@hybird.org>" - "
" - "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("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>, 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 <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>
" - "Russian: Andrey Korotaev <unC0Rr@gmail.com>
" - "Slovak: Jose Riha
" - "Spanish: Carlos Vives <mail@carlosvives.es>
" - "Swedish: Niklas Grahn <raewolusjoon@yaoo.com>, Henrik Rostedt <henrik.rostedt@gmail.com>
" - "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)" - "

" - ); + QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html"); + lbl2->setSource(localpage); //sets the source of the label from the file above mainLayout->addWidget(lbl2, 1, 1); setAcceptDrops(true); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/chatwidget.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -177,7 +177,7 @@ } -HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify) : +HWChatWidget::HWChatWidget(QWidget* parent, bool notify) : QWidget(parent), mainLayout(this) { @@ -187,7 +187,6 @@ m_isAdmin = false; m_autoKickEnabled = false; - if(gameSettings->value("frontend/sound", true).toBool()) { QStringList vpList = QStringList() << "Classic" << "Default" << "Mobster" << "Russian"; @@ -281,6 +280,10 @@ clear(); } +void HWChatWidget::setSettings(QSettings * settings) +{ + gameSettings = settings; +} void HWChatWidget::linkClicked(const QUrl & link) { diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/chatwidget.h --- a/QTfrontend/ui/widget/chatwidget.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/chatwidget.h Tue Dec 25 04:45:22 2012 +0100 @@ -54,7 +54,7 @@ Q_OBJECT public: - HWChatWidget(QWidget* parent, QSettings * gameSettings, bool notify); + HWChatWidget(QWidget* parent, bool notify); void setIgnoreListKick(bool enabled); ///< automatically kick people on ignore list (if possible) void setShowFollow(bool enabled); static const QString & styleSheet(); @@ -63,6 +63,7 @@ void displayWarning(const QString & message); void setUser(const QString & nickname); void setUsersModel(QAbstractItemModel * model); + void setSettings(QSettings * settings); protected: virtual void dragEnterEvent(QDragEnterEvent * event); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/qpushbuttonwithsound.cpp --- a/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -33,7 +33,7 @@ void QPushButtonWithSound::buttonClicked() { - if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled()) + if ( !isSoundEnabled ) return; if (this->isEnabled()) diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/teamselect.cpp --- a/QTfrontend/ui/widget/teamselect.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/teamselect.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -59,6 +59,7 @@ this, SLOT(changeTeamStatus(HWTeam))); } } + emit setEnabledGameStart(curPlayingTeams.size()>1); } @@ -168,6 +169,12 @@ m_curNotPlayingTeams.push_back(*itPlay); emit teamNotPlaying(*itPlay); curPlayingTeams.erase(itPlay); + + // Show team notice if less than two teams. + if (curPlayingTeams.size() < 2) + { + numTeamNotice->show(); + } } else { @@ -179,6 +186,12 @@ curPlayingTeams.push_back(*itDontPlay); if(!m_acceptOuter) emit teamWillPlay(*itDontPlay); m_curNotPlayingTeams.erase(itDontPlay); + + // Hide team notice if at least two teams. + if (curPlayingTeams.size() >= 2) + { + numTeamNotice->hide(); + } } FrameTeams* pRemoveTeams; @@ -254,6 +267,10 @@ framePlaying = new FrameTeams(); frameDontPlaying = new FrameTeams(); + // Add notice about number of required teams. + numTeamNotice = new QLabel("Two teams are required to play!"); + mainLayout.addWidget(numTeamNotice); + QPalette p; p.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); addScrArea(framePlaying, p.color(QPalette::Window).light(105), 250); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui/widget/teamselect.h --- a/QTfrontend/ui/widget/teamselect.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui/widget/teamselect.h Tue Dec 25 04:45:22 2012 +0100 @@ -20,6 +20,7 @@ #ifndef _TEAM_SELECT_INCLUDED #define _TEAM_SELECT_INCLUDED +#include #include #include #include @@ -74,6 +75,7 @@ FrameTeams* framePlaying; QVBoxLayout mainLayout; + QLabel *numTeamNotice; bool m_acceptOuter; QList curPlayingTeams; diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui_hwform.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -30,7 +30,6 @@ #include "pagefeedback.h" #include "pageingame.h" #include "pagescheme.h" -#include "pagenettype.h" #include "pageroomslist.h" #include "pageinfo.h" #include "pagenetgame.h" @@ -60,7 +59,7 @@ centralWidget = new QWidget(HWForm); centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - SetupPages(centralWidget, HWForm); + SetupPages(centralWidget); HWForm->setCentralWidget(centralWidget); @@ -74,7 +73,7 @@ font14 = new QFont("MS Shell Dlg", 14); } -void Ui_HWForm::SetupPages(QWidget *Parent, HWForm *HWForm) +void Ui_HWForm::SetupPages(QWidget *Parent) { Pages = new QStackedLayout(Parent); @@ -93,7 +92,7 @@ pageNet = new PageNet(); Pages->addWidget(pageNet); - pageNetGame = new PageNetGame(Parent, HWForm->gameSettings); + pageNetGame = new PageNetGame(Parent); Pages->addWidget(pageNetGame); pageInfo = new PageInfo(); @@ -120,7 +119,7 @@ pageInGame = new PageInGame(); Pages->addWidget(pageInGame); - pageRoomsList = new PageRoomsList(Parent, HWForm->gameSettings); + pageRoomsList = new PageRoomsList(Parent); Pages->addWidget(pageRoomsList); pageConnecting = new PageConnecting(); @@ -132,9 +131,6 @@ pageAdmin = new PageAdmin(); Pages->addWidget(pageAdmin); - pageNetType = new PageNetType(); - Pages->addWidget(pageNetType); - pageCampaign = new PageCampaign(); Pages->addWidget(pageCampaign); diff -r d24257910f8d -r aaefa587e277 QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/ui_hwform.h Tue Dec 25 04:45:22 2012 +0100 @@ -41,7 +41,6 @@ class PageConnecting; class PageScheme; class PageAdmin; -class PageNetType; class PageDrawMap; class PageVideos; class QStackedLayout; @@ -76,7 +75,6 @@ PageConnecting *pageConnecting; PageScheme *pageScheme; PageAdmin *pageAdmin; - PageNetType *pageNetType; PageCampaign *pageCampaign; PageDrawMap *pageDrawMap; PageVideos *pageVideos; @@ -86,7 +84,7 @@ void setupUi(HWForm *HWForm); void SetupFonts(); - void SetupPages(QWidget *Parent, HWForm *HWForm); + void SetupPages(QWidget *Parent); }; #endif // UI_HWFORM_H diff -r d24257910f8d -r aaefa587e277 QTfrontend/util/FileEngine.cpp --- a/QTfrontend/util/FileEngine.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/util/FileEngine.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -1,322 +1,380 @@ -/* borrowed from https://github.com/skhaz/qt-physfs-wrapper - * TODO: add copyright header, determine license - */ - -#include "hwpacksmounter.h" -#include "FileEngine.h" - - -const QString FileEngineHandler::scheme = "physfs:/"; - -FileEngine::FileEngine(const QString& filename) -: _handler(NULL) -, _flags(0) -{ - setFileName(filename); -} - -FileEngine::~FileEngine() -{ - close(); -} - -bool FileEngine::open(QIODevice::OpenMode openMode) -{ - close(); - - if (openMode & QIODevice::WriteOnly) { - _handler = PHYSFS_openWrite(_filename.toUtf8().constData()); - _flags = QAbstractFileEngine::WriteOwnerPerm | QAbstractFileEngine::WriteUserPerm | QAbstractFileEngine::FileType; - } - - else if (openMode & QIODevice::ReadOnly) { - _handler = PHYSFS_openRead(_filename.toUtf8().constData()); - } - - else if (openMode & QIODevice::Append) { - _handler = PHYSFS_openAppend(_filename.toUtf8().constData()); - } - - else { - qWarning("Bad file open mode: %d", (int)openMode); - } - - if (!_handler) { - qWarning("Failed to open %s, reason: %s", _filename.toUtf8().constData(), PHYSFS_getLastError()); - return false; - } - - return true; -} - -bool FileEngine::close() -{ - if (isOpened()) { - int result = PHYSFS_close(_handler); - _handler = NULL; - return result != 0; - } - - return true; -} - -bool FileEngine::flush() -{ - return PHYSFS_flush(_handler) != 0; -} - -qint64 FileEngine::size() const -{ - return _size; -} - -qint64 FileEngine::pos() const -{ - return PHYSFS_tell(_handler); -} - -bool FileEngine::seek(qint64 pos) -{ - return PHYSFS_seek(_handler, pos) != 0; -} - -bool FileEngine::isSequential() const -{ - return false; -} - -bool FileEngine::remove() -{ - return PHYSFS_delete(_filename.toUtf8().constData()) != 0; -} - -bool FileEngine::mkdir(const QString &dirName, bool createParentDirectories) const -{ - Q_UNUSED(createParentDirectories); - return PHYSFS_mkdir(dirName.toUtf8().constData()) != 0; -} - -bool FileEngine::rmdir(const QString &dirName, bool recurseParentDirectories) const -{ - Q_UNUSED(recurseParentDirectories); - return PHYSFS_delete(dirName.toUtf8().constData()) != 0; -} - -bool FileEngine::caseSensitive() const -{ - return true; -} - -bool FileEngine::isRelativePath() const -{ - return true; -} - -QAbstractFileEngineIterator * FileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames) -{ - return new FileEngineIterator(filters, filterNames, entryList(filters, filterNames)); -} - -QStringList FileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const -{ - Q_UNUSED(filters); - - QString file; - QStringList result; - char **files = PHYSFS_enumerateFiles(_filename.toUtf8().constData()); - - for (char **i = files; *i != NULL; i++) { - file = QString::fromUtf8(*i); - - if (filterNames.isEmpty() || QDir::match(filterNames, file)) { - result << file; - } - } - - PHYSFS_freeList(files); - - return result; -} - -QAbstractFileEngine::FileFlags FileEngine::fileFlags(FileFlags type) const -{ - return type & _flags; -} - -QString FileEngine::fileName(FileName file) const -{ - switch(file) - { - case QAbstractFileEngine::AbsolutePathName: - { - QString s(PHYSFS_getWriteDir()); - return s; - } - case QAbstractFileEngine::BaseName: - { - int l = _filename.lastIndexOf('/'); - QString s = _filename.mid(l + 1); - return s; - } - case QAbstractFileEngine::DefaultName: - case QAbstractFileEngine::AbsoluteName: - default: - { - QString s = "physfs:/" + _filename; - return s; - } - } -} - -QDateTime FileEngine::fileTime(FileTime time) const -{ - - switch (time) - { - case QAbstractFileEngine::ModificationTime: - default: - return _datetime; - break; - }; -} - -void FileEngine::setFileName(const QString &file) -{ - if(file.startsWith(FileEngineHandler::scheme)) - _filename = file.mid(FileEngineHandler::scheme.size()); - else - _filename = file; - - PHYSFS_Stat stat; - if (PHYSFS_stat(_filename.toUtf8().constData(), &stat) != 0) { - _size = stat.filesize; - _datetime = QDateTime::fromTime_t(stat.modtime); -// _flags |= QAbstractFileEngine::WriteUserPerm; - _flags |= QAbstractFileEngine::ReadUserPerm; - _flags |= QAbstractFileEngine::ExistsFlag; - - switch (stat.filetype) - { - case PHYSFS_FILETYPE_REGULAR: - _flags |= QAbstractFileEngine::FileType; - break; - - case PHYSFS_FILETYPE_DIRECTORY: - _flags |= QAbstractFileEngine::DirectoryType; - break; - case PHYSFS_FILETYPE_SYMLINK: - _flags |= QAbstractFileEngine::LinkType; - break; - default: ; - } - } -} - -bool FileEngine::atEnd() const -{ - return PHYSFS_eof(_handler) != 0; -} - -qint64 FileEngine::read(char *data, qint64 maxlen) -{ - return PHYSFS_readBytes(_handler, data, maxlen); -} - -qint64 FileEngine::write(const char *data, qint64 len) -{ - return PHYSFS_writeBytes(_handler, data, len); -} - -bool FileEngine::isOpened() const -{ - return _handler != NULL; -} - -QFile::FileError FileEngine::error() const -{ - return QFile::UnspecifiedError; -} - -QString FileEngine::errorString() const -{ - return PHYSFS_getLastError(); -} - -bool FileEngine::supportsExtension(Extension extension) const -{ - return extension == QAbstractFileEngine::AtEndExtension; -} - - - -FileEngineHandler::FileEngineHandler(char *argv0) -{ - PHYSFS_init(argv0); -} - -FileEngineHandler::~FileEngineHandler() -{ - PHYSFS_deinit(); -} - -QAbstractFileEngine* FileEngineHandler::create(const QString &filename) const -{ - if (filename.startsWith(scheme)) - return new FileEngine(filename.mid(scheme.size())); - else - return NULL; -} - -void FileEngineHandler::mount(const QString &path) -{ - PHYSFS_mount(path.toUtf8().constData(), NULL, 1); -} - -void FileEngineHandler::mount(const QString & path, const QString & mountPoint) -{ - PHYSFS_mount(path.toUtf8().constData(), mountPoint.toUtf8().constData(), 1); -} - -void FileEngineHandler::setWriteDir(const QString &path) -{ - PHYSFS_setWriteDir(path.toUtf8().constData()); -} - -void FileEngineHandler::mountPacks() -{ - hedgewarsMountPackages(); -} - - -FileEngineIterator::FileEngineIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &entries) - : QAbstractFileEngineIterator(filters, nameFilters) -{ - m_entries = entries; - - /* heck.. docs are unclear on this - * QDirIterator puts iterator before first entry - * but QAbstractFileEngineIterator example puts iterator on first entry - * though QDirIterator approach seems to be the right one - */ - - m_index = -1; -} - -bool FileEngineIterator::hasNext() const -{ - return m_index < m_entries.size() - 1; -} - -QString FileEngineIterator::next() -{ - if (!hasNext()) - return QString(); - - ++m_index; - return currentFilePath(); -} - -QString FileEngineIterator::currentFileName() const -{ - return m_entries.at(m_index); -} +/* borrowed from https://github.com/skhaz/qt-physfs-wrapper + * TODO: add copyright header, determine license + */ + +#include "hwpacksmounter.h" +#include "FileEngine.h" + + +const QString FileEngineHandler::scheme = "physfs:/"; + +FileEngine::FileEngine(const QString& filename) + : m_handle(NULL) + , m_size(0) + , m_flags(0) + , m_bufferSet(false) + , m_readWrite(false) +{ + setFileName(filename); +} + +FileEngine::~FileEngine() +{ + close(); +} + +bool FileEngine::open(QIODevice::OpenMode openMode) +{ + close(); + + if ((openMode & QIODevice::ReadWrite) == QIODevice::ReadWrite) { + m_handle = PHYSFS_openAppend(m_fileName.toUtf8().constData()); + if(m_handle) + { + m_readWrite = true; + seek(0); + } + } + + else if (openMode & QIODevice::WriteOnly) { + m_handle = PHYSFS_openWrite(m_fileName.toUtf8().constData()); + m_flags = QAbstractFileEngine::WriteOwnerPerm | QAbstractFileEngine::WriteUserPerm | QAbstractFileEngine::FileType; + } + + else if (openMode & QIODevice::ReadOnly) { + m_handle = PHYSFS_openRead(m_fileName.toUtf8().constData()); + } + + else if (openMode & QIODevice::Append) { + m_handle = PHYSFS_openAppend(m_fileName.toUtf8().constData()); + } + + else { + qWarning("[PHYSFS] Bad file open mode: %d", (int)openMode); + } + + if (!m_handle) { + qWarning("[PHYSFS] Failed to open %s, reason: %s", m_fileName.toUtf8().constData(), PHYSFS_getLastError()); + return false; + } + + return true; +} + +bool FileEngine::close() +{ + if (isOpened()) { + int result = PHYSFS_close(m_handle); + m_handle = NULL; + return result != 0; + } + + return true; +} + +bool FileEngine::flush() +{ + return PHYSFS_flush(m_handle) != 0; +} + +qint64 FileEngine::size() const +{ + return m_size; +} + +qint64 FileEngine::pos() const +{ + return PHYSFS_tell(m_handle); +} + +bool FileEngine::setSize(qint64 size) +{ + if(size == 0) + { + m_size = 0; + return open(QIODevice::WriteOnly); + } + else + return false; +} + +bool FileEngine::seek(qint64 pos) +{ + bool ok = PHYSFS_seek(m_handle, pos) != 0; + + return ok; +} + +bool FileEngine::isSequential() const +{ + return false; +} + +bool FileEngine::remove() +{ + return PHYSFS_delete(m_fileName.toUtf8().constData()) != 0; +} + +bool FileEngine::mkdir(const QString &dirName, bool createParentDirectories) const +{ + Q_UNUSED(createParentDirectories); + + return PHYSFS_mkdir(dirName.toUtf8().constData()) != 0; +} + +bool FileEngine::rmdir(const QString &dirName, bool recurseParentDirectories) const +{ + Q_UNUSED(recurseParentDirectories); + + return PHYSFS_delete(dirName.toUtf8().constData()) != 0; +} + +bool FileEngine::caseSensitive() const +{ + return true; +} + +bool FileEngine::isRelativePath() const +{ + return false; +} + +QAbstractFileEngineIterator * FileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames) +{ + return new FileEngineIterator(filters, filterNames, entryList(filters, filterNames)); +} + +QStringList FileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const +{ + Q_UNUSED(filters); + + QString file; + QStringList result; + char **files = PHYSFS_enumerateFiles(m_fileName.toUtf8().constData()); + + for (char **i = files; *i != NULL; i++) { + file = QString::fromUtf8(*i); + + if (filterNames.isEmpty() || QDir::match(filterNames, file)) { + result << file; + } + } + + PHYSFS_freeList(files); + + return result; +} + +QAbstractFileEngine::FileFlags FileEngine::fileFlags(FileFlags type) const +{ + return type & m_flags; +} + +QString FileEngine::fileName(FileName file) const +{ + switch(file) + { + case QAbstractFileEngine::AbsolutePathName: + { + QString s(PHYSFS_getWriteDir()); + return s; + } + case QAbstractFileEngine::BaseName: + { + int l = m_fileName.lastIndexOf('/'); + QString s = m_fileName.mid(l + 1); + return s; + } + case QAbstractFileEngine::DefaultName: + case QAbstractFileEngine::AbsoluteName: + default: + { + QString s = "physfs:/" + m_fileName; + return s; + } + } +} + +QDateTime FileEngine::fileTime(FileTime time) const +{ + switch (time) + { + case QAbstractFileEngine::ModificationTime: + default: + return m_date; + break; + }; +} + +void FileEngine::setFileName(const QString &file) +{ + if(file.startsWith(FileEngineHandler::scheme)) + m_fileName = file.mid(FileEngineHandler::scheme.size()); + else + m_fileName = file; + PHYSFS_Stat stat; + if (PHYSFS_stat(m_fileName.toUtf8().constData(), &stat) != 0) { + m_size = stat.filesize; + m_date = QDateTime::fromTime_t(stat.modtime); +// m_flags |= QAbstractFileEngine::WriteOwnerPerm; + m_flags |= QAbstractFileEngine::ReadOwnerPerm; + m_flags |= QAbstractFileEngine::ReadUserPerm; + m_flags |= QAbstractFileEngine::ExistsFlag; + m_flags |= QAbstractFileEngine::LocalDiskFlag; + + switch (stat.filetype) + { + case PHYSFS_FILETYPE_REGULAR: + m_flags |= QAbstractFileEngine::FileType; + break; + case PHYSFS_FILETYPE_DIRECTORY: + m_flags |= QAbstractFileEngine::DirectoryType; + break; + case PHYSFS_FILETYPE_SYMLINK: + m_flags |= QAbstractFileEngine::LinkType; + break; + default: ; + } + } +} + +bool FileEngine::atEnd() const +{ + return PHYSFS_eof(m_handle) != 0; +} + +qint64 FileEngine::read(char *data, qint64 maxlen) +{ + if(m_readWrite) + { + if(pos() == 0) + open(QIODevice::ReadOnly); + else + return -1; + } + + qint64 len = PHYSFS_readBytes(m_handle, data, maxlen); + return len; +} + +qint64 FileEngine::readLine(char *data, qint64 maxlen) +{ + if(!m_bufferSet) + { + PHYSFS_setBuffer(m_handle, 4096); + m_bufferSet = true; + } + + qint64 bytesRead = 0; + while(PHYSFS_readBytes(m_handle, data, 1) + && maxlen + && (*data == '\n')) + { + ++data; + --maxlen; + ++bytesRead; + } + + return bytesRead; +} + +qint64 FileEngine::write(const char *data, qint64 len) +{ + return PHYSFS_writeBytes(m_handle, data, len); +} + +bool FileEngine::isOpened() const +{ + return m_handle != NULL; +} + +QFile::FileError FileEngine::error() const +{ + return QFile::UnspecifiedError; +} + +QString FileEngine::errorString() const +{ + return PHYSFS_getLastError(); +} + +bool FileEngine::supportsExtension(Extension extension) const +{ + return + (extension == QAbstractFileEngine::AtEndExtension) + || (extension == QAbstractFileEngine::FastReadLineExtension) + ; +} + + +FileEngineHandler::FileEngineHandler(char *argv0) +{ + PHYSFS_init(argv0); +} + +FileEngineHandler::~FileEngineHandler() +{ + PHYSFS_deinit(); +} + +QAbstractFileEngine* FileEngineHandler::create(const QString &filename) const +{ + if (filename.startsWith(scheme)) + return new FileEngine(filename); + else + return NULL; +} + +void FileEngineHandler::mount(const QString &path) +{ + PHYSFS_mount(path.toUtf8().constData(), NULL, 1); +} + +void FileEngineHandler::mount(const QString & path, const QString & mountPoint) +{ + PHYSFS_mount(path.toUtf8().constData(), mountPoint.toUtf8().constData(), 1); +} + +void FileEngineHandler::setWriteDir(const QString &path) +{ + PHYSFS_setWriteDir(path.toUtf8().constData()); +} + +void FileEngineHandler::mountPacks() +{ + hedgewarsMountPackages(); +} + + +FileEngineIterator::FileEngineIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &entries) + : QAbstractFileEngineIterator(filters, nameFilters) +{ + m_entries = entries; + + /* heck.. docs are unclear on this + * QDirIterator puts iterator before first entry + * but QAbstractFileEngineIterator example puts iterator on first entry + * though QDirIterator approach seems to be the right one + */ + + m_index = -1; +} + +bool FileEngineIterator::hasNext() const +{ + return m_index < m_entries.size() - 1; +} + +QString FileEngineIterator::next() +{ + if (!hasNext()) + return QString(); + + ++m_index; + return currentFilePath(); +} + +QString FileEngineIterator::currentFileName() const +{ + return m_entries.at(m_index); +} diff -r d24257910f8d -r aaefa587e277 QTfrontend/util/FileEngine.h --- a/QTfrontend/util/FileEngine.h Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/util/FileEngine.h Tue Dec 25 04:45:22 2012 +0100 @@ -22,6 +22,7 @@ virtual bool flush(); virtual qint64 size() const; virtual qint64 pos() const; + virtual bool setSize(qint64 size); virtual bool seek(qint64 pos); virtual bool isSequential() const; virtual bool remove(); @@ -38,6 +39,7 @@ bool atEnd() const; virtual qint64 read(char *data, qint64 maxlen); + virtual qint64 readLine(char *data, qint64 maxlen); virtual qint64 write(const char *data, qint64 len); bool isOpened() const; @@ -48,11 +50,13 @@ virtual bool supportsExtension(Extension extension) const; private: - PHYSFS_file *_handler; - qint64 _size; - FileFlags _flags; - QString _filename; - QDateTime _datetime; + PHYSFS_file *m_handle; + qint64 m_size; + FileFlags m_flags; + QString m_fileName; + QDateTime m_date; + bool m_bufferSet; + bool m_readWrite; }; class FileEngineHandler : public QAbstractFileEngineHandler diff -r d24257910f8d -r aaefa587e277 QTfrontend/util/SDLInteraction.cpp --- a/QTfrontend/util/SDLInteraction.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/util/SDLInteraction.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -25,9 +25,13 @@ #include "SDL_mixer.h" #include "HWApplication.h" +#include "hwform.h" /* you know, we could just put a config singleton lookup function in gameuiconfig or something... */ +#include "gameuiconfig.h" #include "SDLInteraction.h" +#include "physfsrwops.h" + extern char sdlkeys[1024][2][128]; extern char xb360buttons[][128]; extern char xb360dpad[128]; @@ -184,16 +188,18 @@ return; SDL_Init(SDL_INIT_AUDIO); - Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); - m_audioInitialized = true; + if(!Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)) /* should we keep trying, or just turn off permanently? */ + m_audioInitialized = true; } void SDLInteraction::playSoundFile(const QString & soundFile) { + if (!HWForm::config || !HWForm::config->isFrontendSoundEnabled()) return; SDLAudioInit(); + if (!m_audioInitialized) return; if (!m_soundMap->contains(soundFile)) - m_soundMap->insert(soundFile, Mix_LoadWAV(soundFile.toLocal8Bit().constData())); + m_soundMap->insert(soundFile, Mix_LoadWAV_RW(PHYSFSRWOPS_openRead(soundFile.toLocal8Bit().constData()), 1)); //FIXME: this is a hack, but works as long as we have few concurrent playing sounds if (Mix_Playing(lastchannel) == false) @@ -230,9 +236,10 @@ return; SDLAudioInit(); + if (!m_audioInitialized) return; if (m_music == NULL) - m_music = Mix_LoadMUS(m_musicTrack.toLocal8Bit().constData()); + m_music = Mix_LoadMUS_RW(PHYSFSRWOPS_openRead(m_musicTrack.toLocal8Bit().constData())); Mix_VolumeMusic(MIX_MAX_VOLUME - 28); Mix_FadeInMusic(m_music, -1, 1750); diff -r d24257910f8d -r aaefa587e277 QTfrontend/util/namegen.cpp --- a/QTfrontend/util/namegen.cpp Sun Dec 02 00:03:16 2012 +0100 +++ b/QTfrontend/util/namegen.cpp Tue Dec 25 04:45:22 2012 +0100 @@ -125,22 +125,21 @@ QStringList list; // find .txt to load the names from - QFile * file = new QFile(QString("physfs://Names/%1.txt").arg(filename)); + QFile file(QString("physfs://Names/%1.txt").arg(filename)); - if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(file); - while (!in.atEnd()) + QTextStream in(&file); + QString line; + do { - QString line = in.readLine(); + line = in.readLine(); + if(!line.isEmpty()) list.append(line); - } + } while (!line.isNull()); } - // this QFile isn't needed any further - delete file; - if (list.size() == 0) list.append(filename); @@ -153,22 +152,21 @@ QStringList list; // find .cfg to load the dicts from - QFile * file = new QFile(QString("physfs://Names/%1.cfg").arg(hatname)); + QFile file(QString("physfs://Names/%1.cfg").arg(hatname)); - if (file->exists() && file->open(QIODevice::ReadOnly | QIODevice::Text)) + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - QTextStream in(file); - while (!in.atEnd()) + QTextStream in(&file); + QString line; + do { - QString line = in.readLine(); + line = in.readLine(); + if(!line.isEmpty()) list.append(line); - } + } while (!line.isNull()); } - // this QFile isn't needed any further - delete file; - if (list.size() == 0) list.append(QString("generic")); diff -r d24257910f8d -r aaefa587e277 README --- a/README Sun Dec 02 00:03:16 2012 +0100 +++ b/README Tue Dec 25 04:45:22 2012 +0100 @@ -5,3 +5,10 @@ Source: Copyright 2004-2011 Andrey Korotaev Portions copyright 2006-2008 Igor Ulyanov aka Displacer + +Instructions: +depending on your system, consult our wiki at: +- http://code.google.com/p/hedgewars/wiki/BuildingOnLinux +- http://code.google.com/p/hedgewars/wiki/BuildingOnWindows +- http://code.google.com/p/hedgewars/wiki/BuildingOnMac + diff -r d24257910f8d -r aaefa587e277 README_WINDOWS --- a/README_WINDOWS Sun Dec 02 00:03:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -For instructions, please visit: http://code.google.com/p/hedgewars/wiki/BuildingOnWindows diff -r d24257910f8d -r aaefa587e277 bin/CMakeLists.txt --- a/bin/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/bin/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,9 +1,9 @@ if(WIN32 AND NOT UNIX) - file(GLOB DLLs *.dll) - file(GLOB ICOs *.ico) - - install(FILES - ${DLLs} - ${ICOs} - DESTINATION bin) + file(GLOB DLLs *.dll) + file(GLOB ICOs *.ico) + + install(FILES + ${DLLs} + ${ICOs} + DESTINATION ${target_library_install_dir}) endif(WIN32 AND NOT UNIX) diff -r d24257910f8d -r aaefa587e277 cmake_modules/FindFFMPEG.cmake --- a/cmake_modules/FindFFMPEG.cmake Sun Dec 02 00:03:16 2012 +0100 +++ b/cmake_modules/FindFFMPEG.cmake Tue Dec 25 04:45:22 2012 +0100 @@ -16,17 +16,23 @@ # BSD license. # +set(FFMPEG_FOUND FALSE) + if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) # in cache already set(FFMPEG_FOUND TRUE) else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR) + # silence output option + if (FFMPEG_FIND_QUIETLY) + set(VERBOSITY "QUIET") + endif () # 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) + pkg_check_modules(_FFMPEG_AVCODEC libavcodec ${VERBOSITY}) + pkg_check_modules(_FFMPEG_AVFORMAT libavformat ${VERBOSITY}) + pkg_check_modules(_FFMPEG_AVUTIL libavutil ${VERBOSITY}) endif (PKG_CONFIG_FOUND) find_path(FFMPEG_AVCODEC_INCLUDE_DIR @@ -74,10 +80,6 @@ ${FFMPEG_LIBAVFORMAT} ${FFMPEG_LIBAVUTIL} ) - if (APPLE) - set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} "bz2" "-framework CoreVideo" "-framework VideoDecodeAcceleration") - endif(APPLE) - endif (FFMPEG_FOUND) if (FFMPEG_FOUND) diff -r d24257910f8d -r aaefa587e277 cmake_modules/FindFreepascal.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/FindFreepascal.cmake Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,37 @@ +# Load Freepascal +if (FPC) + set(FPC_EXECUTABLE ${FPC}) +else() + find_program(FPC_EXECUTABLE + NAMES fpc + PATHS /opt/local/bin /usr/local/bin /usr/bin) +endif() + +# Check Freepascal version +if (FPC_EXECUTABLE) + exec_program(${FPC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE FPC_VERSION_FULL) + + string(REGEX MATCH "[0-9]+\\.[0-9]+" FPC_VERSION_LONG "${FPC_VERSION_FULL}") + string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" FPC_VERSION "${FPC_VERSION_LONG}") + message(STATUS "Found Freepascal: ${FPC_EXECUTABLE} (version ${FPC_VERSION})") +else() + message(FATAL_ERROR "Could NOT find Freepascal") +endif() + +# Check for noexecstack flag support +message(STATUS "Checking whether linker needs explicit noexecstack") +set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack") +file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.") + +execute_process(COMMAND ${FPC_EXECUTABLE} ${NOEXECSTACK_FLAGS} checkstack.pas + WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + RESULT_VARIABLE TEST_NOEXECSTACK + OUTPUT_QUIET ERROR_QUIET) + +if (TEST_NOEXECSTACK) + set(NOEXECSTACK_FLAGS "") + message(STATUS "Checking whether linker needs explicit noexecstack -- no") +else(TEST_NOEXECSTACK) + message(STATUS "Checking whether linker needs explicit noexecstack -- yes") +endif(TEST_NOEXECSTACK) + diff -r d24257910f8d -r aaefa587e277 doc/protocol.txt --- a/doc/protocol.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/doc/protocol.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,34 +1,35 @@ - '?' ping? - '!' pong! - 'l','L' срабатывание команд -left, +left - 'r','R' -right, +right - 'u','U' -up, +up - 'd','D' -down, +down - 'z', 'Z' -precise, +precise - 'N' срабатывание команды /nextturn - 'S' /switch - 's' + <текст> /say - '+' пустой пакет для постоянности лага - '1'..'5' /timer 1..5 - chr(128+№) /slot № - 'w' /setweap - 'p' /put - 'j' /ljump - 'J' /hjump - 'E' + <текст> сообщение об ошибке - ',' /skip - 'K' вывести сообщение из KB - 'Q' выход через команду /quit - 'q' выход по причине окончания игры - 't' + № /taunt № - 'F' + команда team вылетела в сетевой игре + '?' ping? + '!' pong! + 'l','L' срабатывание команд -left, +left + 'r','R' -right, +right + 'u','U' -up, +up + 'd','D' -down, +down + 'z', 'Z' -precise, +precise + 'N' срабатывание команды /nextturn + 'S' /switch + 's' + <текст> /say + '+' пустой пакет для постоянности лага + '1'..'5' /timer 1..5 + chr(128+№) /slot № + 'w' /setweap + 'p' /put + 'j' /ljump + 'J' /hjump + 'E' + <текст> сообщение об ошибке + ',' /skip + 't' + № /taunt № фронтенд клиенту: - 'e' + <команда> выполнить "/<команда>" - 'T' + {L,N,D} тип игры (локальная, сетевая, просмотр демо) - 'W' + <текст> сообщение о нефатальной ошибке + 'e' + <команда> выполнить "/<команда>" + 'T' + {L,N,D} тип игры (локальная, сетевая, просмотр демо) + 'W' + <текст> сообщение о нефатальной ошибке + 'F' + команда team вылетела в сетевой игре + 'o' stop syncing, game over! Клиент фронтенду: - 'C' запрос текущего конфига игры - 'q' выход по причине окончания демки - 'i' статистика + 'C' запрос текущего конфига игры + 'q' выход по причине окончания демки + 'i' статистика + 'K' вывести сообщение из KB + 'Q' выход через команду /quit + 'q' выход по причине окончания игры diff -r d24257910f8d -r aaefa587e277 gameServer/Actions.hs --- a/gameServer/Actions.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/Actions.hs Tue Dec 25 04:45:22 2012 +0100 @@ -52,9 +52,10 @@ | KickRoomClient ClientIndex | BanClient NominalDiffTime B.ByteString ClientIndex | BanIP B.ByteString NominalDiffTime B.ByteString + | BanNick B.ByteString NominalDiffTime B.ByteString | BanList | Unban B.ByteString - | ChangeMaster + | ChangeMaster (Maybe ClientIndex) | RemoveClientTeams ClientIndex | ModifyClient (ClientInfo -> ClientInfo) | ModifyClient2 ClientIndex (ClientInfo -> ClientInfo) @@ -73,7 +74,7 @@ | RestartServer | AddNick2Bans B.ByteString B.ByteString UTCTime | AddIP2Bans B.ByteString B.ByteString UTCTime - | CheckBanned + | CheckBanned Bool | SaveReplay @@ -154,7 +155,7 @@ when loggedIn $ processAction $ AnswerClients clientsChans ["LOBBY:LEFT", clNick, msg] - mapM processAction + 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 @@ -234,7 +235,7 @@ if master then if playersNum > 1 then - mapM_ processAction [ChangeMaster, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] + mapM_ processAction [ChangeMaster Nothing, NoticeMessage AdminLeft, RemoveClientTeams ci, AnswerClients chans ["LEFT", clNick, msg]] else processAction RemoveRoom else @@ -250,26 +251,27 @@ moveClientToLobby rnc ci -processAction ChangeMaster = do +processAction (ChangeMaster delegateId)= do (Just ci) <- gets clientIndex proto <- client's clientProto ri <- clientRoomA rnc <- gets roomsClients - newMasterId <- liftM (last . filter (/= ci)) . io $ roomClientsIndicesM rnc ri + newMasterId <- liftM (\ids -> fromMaybe (last . filter (/= ci) $ ids) delegateId) . io $ roomClientsIndicesM rnc ri newMaster <- io $ client'sM rnc id newMasterId oldRoomName <- io $ room'sM rnc name ri oldMaster <- client's nick + kicked <- client's isKickedFromServer thisRoomChans <- liftM (map sendChan) $ roomClientsS ri - let newRoomName = if proto < 42 then nick newMaster else oldRoomName + let newRoomName = if (proto < 42) || kicked then nick newMaster else oldRoomName mapM_ processAction [ ModifyRoom (\r -> r{masterID = newMasterId , name = newRoomName , isRestrictedJoins = False , isRestrictedTeams = False + , isRegisteredOnly = 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] ] @@ -361,6 +363,7 @@ ) : UnreadyRoomClients : SendUpdateOnThisRoom + : AnswerClients thisRoomChans ["ROUND_FINISHED"] : answerRemovedTeams @@ -422,17 +425,14 @@ haveSameNick <- liftM (not . null . tail . filter (\c -> caseInsensitiveCompare (nick c) n)) allClientsS if haveSameNick then if p < 38 then - mapM_ processAction [ByeClient "Nickname is already in use", removeNick] + processAction $ ByeClient "Nickname is already in use" else - mapM_ processAction [NoticeMessage NickAlreadyInUse, removeNick] + processAction $ NoticeMessage NickAlreadyInUse else do db <- gets (dbQueries . serverInfo) io $ writeChan db $ CheckAccount ci (hashUnique uid) n h return () - where - removeNick = ModifyClient (\c -> c{nick = ""}) - processAction ClearAccountsCache = do dbq <- gets (dbQueries . serverInfo) @@ -440,17 +440,25 @@ return () -processAction (ProcessAccountInfo info) = +processAction (ProcessAccountInfo info) = do case info of HasAccount passwd isAdmin -> do - chan <- client's sendChan - mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = passwd, isAdministrator = isAdmin})] - Guest -> - processAction JoinLobby + b <- isBanned + when (not b) $ do + chan <- client's sendChan + mapM_ processAction [AnswerClients [chan] ["ASKPASSWORD"], ModifyClient (\c -> c{webPassword = passwd, isAdministrator = isAdmin})] + Guest -> do + b <- isBanned + when (not b) $ + processAction JoinLobby Admin -> do mapM_ processAction [ModifyClient (\cl -> cl{isAdministrator = True}), JoinLobby] chan <- client's sendChan processAction $ AnswerClients [chan] ["ADMIN_ACCESS"] + where + isBanned = do + processAction $ CheckBanned False + liftM B.null $ client's nick processAction JoinLobby = do @@ -479,8 +487,9 @@ clHost <- client's host currentTime <- io getCurrentTime mapM_ processAction [ - AddIP2Bans clHost "60 seconds cooldown after kick" (addUTCTime 60 currentTime), - ByeClient "Kicked" + AddIP2Bans clHost "60 seconds cooldown after kick" (addUTCTime 60 currentTime) + , ModifyClient (\c -> c{isKickedFromServer = True}) + , ByeClient "Kicked" ] @@ -494,24 +503,43 @@ , KickClient banId ] + processAction (BanIP ip seconds reason) = do currentTime <- io getCurrentTime let msg = B.concat ["Ban for ", B.pack . show $ seconds, " (", reason, ")"] processAction $ AddIP2Bans ip msg (addUTCTime seconds currentTime) + +processAction (BanNick n seconds reason) = do + currentTime <- io getCurrentTime + let msg = + if seconds > 60 * 60 * 24 * 365 then + B.concat ["Permanent ban (", reason, ")"] + else + B.concat ["Ban for ", B.pack . show $ seconds, " (", reason, ")"] + processAction $ + AddNick2Bans n msg (addUTCTime seconds currentTime) + + processAction BanList = do + time <- io $ getCurrentTime ch <- client's sendChan - b <- gets (B.pack . unlines . map show . bans . serverInfo) + b <- gets (B.intercalate "\n" . concatMap (ban2Str time) . bans . serverInfo) processAction $ AnswerClients [ch] ["BANLIST", b] + where + ban2Str time (BanByIP b r t) = ["I", b, r, B.pack . show $ t `diffUTCTime` time] + ban2Str time (BanByNick b r t) = ["N", b, r, B.pack . show $ t `diffUTCTime` time] + processAction (Unban entry) = do - processAction $ ModifyServerInfo (\s -> s{bans = filter f $ bans s}) + processAction $ ModifyServerInfo (\s -> s{bans = filter (not . f) $ bans s}) where f (BanByIP bip _ _) = bip == entry f (BanByNick bn _ _) = bn == entry + processAction (KickRoomClient kickId) = do modify (\s -> s{clientIndex = Just kickId}) ch <- client's sendChan @@ -533,7 +561,7 @@ mapM_ processAction [ AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion] - , CheckBanned + , CheckBanned True , AddIP2Bans (host cl) "Reconnected too fast" (addUTCTime 10 $ connectTime cl) ] @@ -547,21 +575,22 @@ when (not $ ci `Set.member` rc) $ processAction $ ModifyServerInfo (\s -> s{bans = BanByIP ip reason expiring : bans s}) -processAction CheckBanned = do +processAction (CheckBanned byIP) = do clTime <- client's connectTime clNick <- client's nick clHost <- client's host si <- gets serverInfo let validBans = filter (checkNotExpired clTime) $ bans si - let ban = L.find (checkBan clHost clNick) $ validBans + let ban = L.find (checkBan byIP clHost clNick) $ validBans mapM_ processAction $ ModifyServerInfo (\s -> s{bans = validBans}) : [ByeClient (getBanReason $ fromJust ban) | isJust ban] where checkNotExpired testTime (BanByIP _ _ time) = testTime `diffUTCTime` time <= 0 checkNotExpired testTime (BanByNick _ _ time) = testTime `diffUTCTime` time <= 0 - checkBan ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip - checkBan _ n (BanByNick bn _ _) = bn == n + checkBan True ip _ (BanByIP bip _ _) = bip `B.isPrefixOf` ip + checkBan False _ n (BanByNick bn _ _) = caseInsensitiveCompare bn n + checkBan _ _ _ _ = False getBanReason (BanByIP _ msg _) = msg getBanReason (BanByNick _ msg _) = msg diff -r d24257910f8d -r aaefa587e277 gameServer/CMakeLists.txt --- a/gameServer/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -42,4 +42,4 @@ add_custom_target(hedgewars-server ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}") -install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) +install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars-server${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir}) diff -r d24257910f8d -r aaefa587e277 gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/CoreTypes.hs Tue Dec 25 04:45:22 2012 +0100 @@ -36,6 +36,7 @@ isReady :: !Bool, isInGame :: Bool, isAdministrator :: Bool, + isKickedFromServer :: Bool, clientClan :: Maybe B.ByteString, teamsInGame :: Word } @@ -100,6 +101,7 @@ readyPlayers :: !Int, isRestrictedJoins :: Bool, isRestrictedTeams :: Bool, + isRegisteredOnly :: Bool, roomBansList :: ![B.ByteString], mapParams :: Map.Map B.ByteString B.ByteString, params :: Map.Map B.ByteString [B.ByteString] @@ -118,6 +120,7 @@ 0 False False + False [] ( Map.fromList $ Prelude.zipWith (,) diff -r d24257910f8d -r aaefa587e277 gameServer/HWProtoInRoomState.hs --- a/gameServer/HWProtoInRoomState.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/HWProtoInRoomState.hs Tue Dec 25 04:45:22 2012 +0100 @@ -56,7 +56,7 @@ roomChans <- roomClientsChans cl <- thisClient teamColor <- - if clientProto cl < 42 then + if clientProto cl < 42 then return color else liftM (head . (L.\\) (map B.singleton ['0'..]) . map teamcolor . teams) thisRoom @@ -264,6 +264,14 @@ [ModifyRoom (\r -> r{isRestrictedTeams = not $ isRestrictedTeams r})] +handleCmd_inRoom ["TOGGLE_REGISTERED_ONLY"] = do + cl <- thisClient + return $ + if not $ isMaster cl then + [ProtocolError "Not room master"] + else + [ModifyRoom (\r -> r{isRegisteredOnly = not $ isRegisteredOnly r})] + handleCmd_inRoom ["ROOM_NAME", newName] = do cl <- thisClient rs <- allRoomInfos @@ -293,6 +301,16 @@ [KickRoomClient kickId | master && isJust maybeClientId && (kickId /= thisClientId) && sameRoom] +handleCmd_inRoom ["DELEGATE", newAdmin] = do + (thisClientId, rnc) <- ask + maybeClientId <- clientByNick newAdmin + master <- liftM isMaster thisClient + let newAdminId = fromJust maybeClientId + let sameRoom = clientRoom rnc thisClientId == clientRoom rnc newAdminId + return + [ChangeMaster (Just newAdminId) | master && isJust maybeClientId && (newAdminId /= thisClientId) && sameRoom] + + handleCmd_inRoom ["TEAMCHAT", msg] = do cl <- thisClient chans <- roomSameClanChans @@ -308,8 +326,8 @@ let sameRoom = clientRoom rnc thisClientId == clientRoom rnc banId if master && isJust maybeClientId && (banId /= thisClientId) && sameRoom then return [ - ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r}) - , KickRoomClient banId +-- ModifyRoom (\r -> r{roomBansList = let h = host $ rnc `client` banId in h `deepseq` h : roomBansList r}) + KickRoomClient banId ] else return [] diff -r d24257910f8d -r aaefa587e277 gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/HWProtoLobbyState.hs Tue Dec 25 04:45:22 2012 +0100 @@ -80,6 +80,8 @@ [Warning "No such room"] else if isRestrictedJoins jRoom then [Warning "Joining restricted"] + else if isRegisteredOnly jRoom then + [Warning "Registered users only"] else if isBanned then [Warning "You are banned in this room"] else if roomPassword /= password jRoom then @@ -89,20 +91,21 @@ 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 + ++ (if clientProto cl < 38 then map (readynessMessage cl) jRoomClients else [sendStateFlags cl jRoomClients]) ++ answerFullConfig cl (mapParams jRoom) (params jRoom) ++ answerTeams cl jRoom - ++ watchRound cl jRoom + ++ watchRound cl jRoom chans where - readynessMessage cl c = AnswerClients [sendChan cl] $ - if clientProto cl < 38 then - [if isReady c then "READY" else "NOT_READY", nick c] - else - ["CLIENT_FLAGS", if isReady c then "+r" else "-r", nick c] + readynessMessage cl c = AnswerClients [sendChan cl] [if isReady c then "READY" else "NOT_READY", nick c] + sendStateFlags cl clients = AnswerClients [sendChan cl] . concat . intersperse [""] . filter (not . null) . concat $ + [f "+r" ready, f "-r" unready, f "+g" ingame, f "-g" inroomlobby] + where + (ready, unready) = partition isReady clients + (ingame, inroomlobby) = partition isInGame clients + f fl lst = ["CLIENT_FLAGS" : fl : map nick lst | not $ null lst] toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs @@ -119,11 +122,13 @@ answerTeams cl jRoom = let f = if isJust $ gameInfo jRoom then teamsAtStart . fromJust . gameInfo else teams in answerAllTeams cl $ f jRoom - watchRound cl jRoom = if isNothing $ gameInfo jRoom then + watchRound cl jRoom chans = if isNothing $ gameInfo jRoom then [] else - [AnswerClients [sendChan cl] ["RUN_GAME"], - AnswerClients [sendChan cl] $ "EM" : toEngineMsg "e$spectate 1" : Foldable.toList (roundMsgs . fromJust . gameInfo $ jRoom)] + [AnswerClients [sendChan cl] ["RUN_GAME"] + , AnswerClients chans ["CLIENT_FLAGS", "+g", nick cl] + , ModifyClient (\c -> c{isInGame = True}) + , AnswerClients [sendChan cl] $ "EM" : toEngineMsg "e$spectate 1" : Foldable.toList (roundMsgs . fromJust . gameInfo $ jRoom)] handleCmd_lobby ["JOIN_ROOM", roomName] = @@ -150,16 +155,20 @@ return [KickClient $ fromJust kickId | isAdministrator cl && isJust kickId && fromJust kickId /= ci] -handleCmd_lobby ["BAN", banNick, reason] = do +handleCmd_lobby ["BAN", banNick, reason, duration] = do (ci, _) <- ask cl <- thisClient banId <- clientByNick banNick - return [BanClient 60 reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci] + return [BanClient (readInt_ duration) reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci] handleCmd_lobby ["BANIP", ip, reason, duration] = do cl <- thisClient return [BanIP ip (readInt_ duration) reason | isAdministrator cl] +handleCmd_lobby ["BANNICK", n, reason, duration] = do + cl <- thisClient + return [BanNick n (readInt_ duration) reason | isAdministrator cl] + handleCmd_lobby ["BANLIST"] = do cl <- thisClient return [BanList | isAdministrator cl] diff -r d24257910f8d -r aaefa587e277 gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/gameServer/NetRoutines.hs Tue Dec 25 04:45:22 2012 +0100 @@ -41,6 +41,7 @@ False False False + False Nothing 0 ) diff -r d24257910f8d -r aaefa587e277 hedgewars/ArgParsers.inc --- a/hedgewars/ArgParsers.inc Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/ArgParsers.inc Tue Dec 25 04:45:22 2012 +0100 @@ -16,232 +16,319 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +procedure GciEasterEgg; +begin + WriteLn(stdout, ' '); + WriteLn(stdout, ' /\\\\\\\\\\\\ /\\\\\\\\\ /\\\\\\\\\\\ '); + WriteLn(stdout, ' /\\\////////// /\\\//////// \/////\\\/// '); + WriteLn(stdout, ' /\\\ /\\\/ \/\\\ '); + WriteLn(stdout, ' \/\\\ /\\\\\\\ /\\\ \/\\\ '); + WriteLn(stdout, ' \/\\\ \/////\\\ \/\\\ \/\\\ '); + WriteLn(stdout, ' \/\\\ \/\\\ \//\\\ \/\\\ '); + WriteLn(stdout, ' \/\\\ \/\\\ \///\\\ \/\\\ '); + WriteLn(stdout, ' \/\\\\\\\\\\\\\/ \////\\\\\\\\\ /\\\\\\\\\\\ '); + WriteLn(stdout, ' \///////////// \///////// \/////////// '); + WriteLn(stdout, ' '); + WriteLn(stdout, ' Command Line Parser Implementation by a Google Code-In Student '); + WriteLn(stdout, ' ASCII Art easter egg idea by @sheepluva '); + WriteLn(stdout, ' '); +end; -procedure internalStartGameWithParameters(); -var tmp: LongInt; +procedure DisplayUsage; begin - UserPathPrefix:= ParamStr(1); - cScreenWidth:= StrToInt(ParamStr(2)); - cScreenHeight:= StrToInt(ParamStr(3)); - cBits:= StrToInt(ParamStr(4)); - ipcPort:= StrToInt(ParamStr(5)); - cFullScreen:= ParamStr(6) = '1'; - 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)); - cReducedQuality:= StrToInt(ParamStr(15)); - tmp:= StrToInt(ParamStr(16)); + WriteLn(stdout, 'Usage: hwengine [options]'); + WriteLn(stdout, ''); + WriteLn(stdout, 'where [options] can be any of the following:'); + WriteLn(stdout, ' --prefix [path to folder]'); + WriteLn(stdout, ' --user-prefix [path to folder]'); + WriteLn(stdout, ' --locale [name of language file]'); + WriteLn(stdout, ' --nick [string]'); + WriteLn(stdout, ' --width [screen width in pixels]'); + WriteLn(stdout, ' --height [screen height in pixels]'); + WriteLn(stdout, ' --volume [sound level]'); + WriteLn(stdout, ' --frame-interval [milliseconds]'); + Writeln(stdout, ' --stereo [value]'); + WriteLn(stdout, ' --raw-quality [flags]'); + WriteLn(stdout, ' --low-quality'); + WriteLn(stdout, ' --nomusic'); + WriteLn(stdout, ' --nosound'); + WriteLn(stdout, ' --fullscreen'); + WriteLn(stdout, ' --showfps'); + WriteLn(stdout, ' --altdmg'); + WriteLn(stdout, ' --stats-only'); + WriteLn(stdout, ' --help'); + WriteLn(stdout, ''); + WriteLn(stdout, 'For more detailed help and examples go to:'); + WriteLn(stdout, 'http://code.google.com/p/hedgewars/wiki/CommandLineOptions'); + GameType:= gmtSyntax; +end; + +procedure setDepth(var paramIndex: LongInt); +begin + WriteLn(stdout, 'WARNING: --depth is a deprecated command, which could be removed in a future version!'); + WriteLn(stdout, ' This option no longer does anything, please consider removing it'); + WriteLn(stdout, ''); + inc(ParamIndex); +end; + +procedure statsOnlyGame; +begin + cOnlyStats:= true; + cReducedQuality:= $FFFFFFFF xor rqLowRes; + SetSound(false); + SetMusic(false); + SetVolume(0); +end; + +procedure setIpcPort(port: LongInt; var wrongParameter:Boolean); +begin + if isInternal then + ipcPort := port + else + begin + WriteLn(stderr, 'ERROR: use of --port is not allowed'); + wrongParameter := true; + end +end; + +function parseNick(nick: String): String; +begin + if isInternal then + parseNick:= DecodeBase64(nick) + else + parseNick:= nick; +end; + +procedure setStereoMode(tmp: LongInt); +begin GrayScale:= false; - if (tmp > 9) and (tmp < 16) then +{$IFDEF USE_S3D_RENDERING} + if (tmp > 9) and (tmp < 16) then begin + // set the gray anaglyph rendering GrayScale:= true; cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-9))) end - else if tmp <= 9 then + else if tmp <= 9 then + // set the fullcolor anaglyph cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp))) - else + else + // any other mode cStereoMode:= TStereoMode(max(0, min(ord(high(TStereoMode)), tmp-6))); - cLocaleFName:= ParamStr(17); +{$ELSE} + cStereoMode:= smNone; +{$ENDIF} +end; + +procedure startVideoRecording(var paramIndex: LongInt); +begin +{$IFDEF USE_VIDEO_RECORDING} + GameType:= gmtRecord; + inc(paramIndex); + cVideoFramerateNum:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); + cVideoFramerateDen:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); + RecPrefix:= ParamStr(paramIndex); inc(paramIndex); + cAVFormat:= ParamStr(paramIndex); inc(paramIndex); + cVideoCodec:= ParamStr(paramIndex); inc(paramIndex); + cVideoQuality:= StrToInt(ParamStr(paramIndex)); inc(paramIndex); + cAudioCodec:= ParamStr(paramIndex); inc(paramIndex); +{$ENDIF} +end; + +function getLongIntParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): LongInt; +var tmpInt, c: LongInt; +begin + inc(paramIndex); + val(str, tmpInt, c); + wrongParameter:= c <> 0; + if wrongParameter then + WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a number, you passed "'+str+'"'); + getLongIntParameter:= tmpInt; +end; + +function getStringParameter(str:String; var paramIndex:LongInt; var wrongParameter:Boolean): String; +begin + inc(paramIndex); + wrongParameter:= (str='') or (Copy(str,1,2) = '--'); + if wrongParameter then + WriteLn(stderr, 'ERROR: '+ParamStr(paramIndex-1)+' expects a string, you passed "'+str+'"'); + getStringParameter:= str; end; -{$IFDEF USE_VIDEO_RECORDING} -procedure internalStartVideoRecordingWithParameters(); + +procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); Forward; + +function parseParameter(cmd:String; arg:String; var paramIndex:LongInt): Boolean; +const videoArray: Array [1..3] of String = ('--width','--height','--depth'); + audioArray: Array [1..3] of String = ('--volume','--nomusic','--nosound'); + otherArray: Array [1..3] of String = ('--locale','--fullscreen','--showfps'); + mediaArray: Array [1..8] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen'); + allArray: Array [1..12] of String = ('--width','--height','--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality'); + reallyAll: array[0..28] of shortstring = ( + '--prefix', '--user-prefix', '--locale', '--width', '--height', '--frame-interval', '--volume','--nomusic', '--nosound', + '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick', + {deprecated} '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything', + {internal} '--internal', '--port', '--recorder', '--landpreview', + {misc} '--stats-only', '--gci', '--help'); +var cmdIndex: byte; +begin + parseParameter:= false; + cmdIndex:= 0; + + //NOTE: Any update to the list of parameters must be reflected in the case statement below, the reallyAll array above, + // the the DisplayUsage() procedure, the HWForm::getDemoArguments() function, and the online wiki + + while (cmdIndex <= High(reallyAll)) and (cmd <> reallyAll[cmdIndex]) do inc(cmdIndex); + case cmdIndex of + {--prefix} 0 : PathPrefix := getStringParameter (arg, paramIndex, parseParameter); + {--user-prefix} 1 : UserPathPrefix := getStringParameter (arg, paramIndex, parseParameter); + {--locale} 2 : cLocaleFName := getStringParameter (arg, paramIndex, parseParameter); + {--width} 3 : cScreenWidth := getLongIntParameter(arg, paramIndex, parseParameter); + {--height} 4 : cScreenHeight := getLongIntParameter(arg, paramIndex, parseParameter); + {--frame-interval} 5 : cTimerInterval := getLongIntParameter(arg, paramIndex, parseParameter); + {--volume} 6 : SetVolume ( getLongIntParameter(arg, paramIndex, parseParameter) ); + {--nomusic} 7 : SetMusic ( false ); + {--nosound} 8 : SetSound ( false ); + {--fullscreen} 9 : cFullScreen := true; + {--showfps} 10 : cShowFPS := true; + {--altdmg} 11 : cAltDamage := true; + {--low-quality} 12 : cReducedQuality:= $FFFFFFFF xor rqLowRes; + {--raw-quality} 13 : cReducedQuality:= getLongIntParameter(arg, paramIndex, parseParameter); + {--stereo} 14 : setStereoMode ( getLongIntParameter(arg, paramIndex, parseParameter) ); + {--nick} 15 : UserNick := parseNick( getStringParameter(arg, paramIndex, parseParameter) ); + {deprecated options} + {--depth} 16 : setDepth(paramIndex); + {--set-video} 17 : parseClassicParameter(videoArray,3,paramIndex); + {--set-audio} 18 : parseClassicParameter(audioArray,3,paramIndex); + {--set-other} 19 : parseClassicParameter(otherArray,3,paramIndex); + {--set-multimedia} 20 : parseClassicParameter(mediaArray,8,paramIndex); + {--set-everything} 21 : parseClassicParameter(allArray,12,paramIndex); + {"internal" options} + {--internal} 22 : {note it, but do nothing}; + {--port} 23 : setIpcPort( getLongIntParameter(arg, paramIndex, parseParameter), parseParameter ); + {--recorder} 24 : startVideoRecording(paramIndex); + {--landpreview} 25 : GameType := gmtLandPreview; + {anything else} + {--stats-only} 26 : statsOnlyGame(); + {--gci} 27 : GciEasterEgg(); + {--help} 28 : DisplayUsage(); + else + begin + //Asusme the first "non parameter" is the replay file, anything else is invalid + if (recordFileName = '') and (Copy(cmd,1,2) <> '--') then + recordFileName := cmd + else + begin + WriteLn(stderr, '"'+cmd+'" is not a valid option'); + parseParameter:= true; + end; + end; + end; +end; + +procedure parseClassicParameter(cmdArray: Array of String; size:LongInt; var paramIndex:LongInt); +var index, tmpInt: LongInt; + isBool, isValid: Boolean; + cmd, arg, newSyntax: String; 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); + WriteLn(stdout, 'WARNING: you are using a deprecated command, which could be removed in a future version!'); + WriteLn(stdout, ' Consider updating to the latest syntax, which is much more flexible!'); + WriteLn(stdout, ' Run `hwegine --help` to learn it!'); + WriteLn(stdout, ''); + + index:= 0; + tmpInt:= 1; + while (index < size) do + begin + inc(paramIndex); + cmd:= cmdArray[index]; + arg:= ParamStr(paramIndex); + isValid:= (cmd<>'--depth'); + + // check if the parameter is a boolean one + isBool:= (cmd = '--nomusic') or (cmd = '--nosound') or (cmd = '--fullscreen') or (cmd = '--showfps') or (cmd = '--altdmg'); + if isBool and (arg='0') then + isValid:= false; + if (cmd='--nomusic') or (cmd='--nosound') then + isValid:= not isValid; + + if isValid then + begin + parseParameter(cmd, arg, tmpInt); + newSyntax += cmd + ' '; + if not isBool then + newSyntax += arg + ' '; + end; + inc(index); + end; + + WriteLn(stdout, 'Attempted to automatically convert to the new syntax:'); + WriteLn(stdout, newSyntax); + WriteLn(stdout, ''); +end; + +procedure parseCommandLine{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar){$ENDIF}; +var paramIndex: LongInt; + paramTotal: LongInt; + wrongParameter: boolean; +begin + paramIndex:= 1; + paramTotal:={$IFDEF HWLIBRARY}argc{$ELSE}ParamCount{$ENDIF}; + wrongParameter:= false; + while (paramIndex <= paramTotal) do + begin + {$IFDEF HWLIBRARY} + wrongParameter:= parseParameter( argv[paramIndex], argv[paramIndex+1], paramIndex); + {$ELSE} + wrongParameter:= parseParameter( ParamStr(paramIndex), ParamStr(paramIndex+1), paramIndex); + {$ENDIF} + inc(paramIndex); + end; + if wrongParameter = true then + GameType:= gmtSyntax; +end; + +{$IFNDEF HWLIBRARY} +procedure GetParams; +//var tmpInt: LongInt; +begin + (* + tmpInt:=0; + while (tmpInt <= ParamCount) do + begin + WriteLn(stdout, inttostr(tmpInt) + ': ' + ParamStr(tmpInt)); + inc(tmpInt); + end; + *) + + isInternal:= (ParamStr(1) = '--internal'); + + UserPathPrefix := '.'; + PathPrefix := cDefaultPathPrefix; + recordFileName := ''; + parseCommandLine(); + + if (isInternal) and (ParamCount<=1) then + begin + WriteLn(stderr, '--internal should not be manually used'); + GameType := gmtSyntax; + end; + + if (not isInternal) and (recordFileName = '') then + begin + WriteLn(stderr, 'You must specify a replay file'); + GameType := gmtSyntax; + end + else if (recordFileName <> '') then + WriteLn(stdout, 'Attempting to play demo file "' + recordFilename + '"'); + + if (GameType = gmtSyntax) then + WriteLn(stderr, 'Please use --help to see possible arguments and their usage'); + + (* + WriteLn(stdout,'PathPrefix: ' + PathPrefix); + WriteLn(stdout,'UserPathPrefix: ' + UserPathPrefix); + *) end; {$ENDIF} -procedure setVideo(screenWidth: LongInt; screenHeight: LongInt; bitsStr: LongInt); -begin - cScreenWidth:= screenWidth; - cScreenHeight:= screenHeight; - cBits:= bitsStr -end; - -procedure setVideoWithParameters(screenWidthParam: string; screenHeightParam: string; bitsParam: string); -var screenWidthAsInt, screenHeightAsInt, bitsStrAsInt, c: LongInt; -begin - val(screenWidthParam, screenWidthAsInt, c); - val(screenHeightParam, screenHeightAsInt, c); - val(bitsParam, bitsStrAsInt, c); - setVideo(screenWidthAsInt,screenHeightAsInt,bitsStrAsInt) -end; - -procedure setOtherOptions(languageFile: string; fullScreen: boolean); -begin - cLocaleFName:= languageFile; - cFullScreen:= fullScreen -end; - -procedure setShowFPS(showFPS: boolean); -begin - cShowFPS:= showFPS -end; - -procedure setOtherOptionsWithParameters(languageFileParam: string; fullScreenParam: string; showFPSParam: string); -var fullScreen, showFPS: boolean; -begin - fullScreen:= fullScreenParam = '1'; - showFPS:= showFPSParam = '1'; - setOtherOptions(languageFileParam,fullScreen); - setShowFPS(showFPS) -end; - -procedure setAudio(initialVolume: LongInt; musicEnabled: boolean; soundEnabled: boolean); -begin - SetVolume(initialVolume); - SetMusic(musicEnabled); - SetSound(soundEnabled); -end; - -procedure setAudioWithParameters(initialVolumeParam: string; musicEnabledParam: string; soundEnabledParam: string); -var initialVolumeAsInt, c: LongInt; - musicEnabled, soundEnabled: boolean; -begin - val(initialVolumeParam, initialVolumeAsInt, c); - musicEnabled:= musicEnabledParam = '1'; - soundEnabled:= soundEnabledParam = '1'; - setAudio(initialVolumeAsInt,musicEnabled, soundEnabled) -end; - -procedure setMultimediaOptionsWithParameters(screenWidthParam, screenHeightParam, bitsParam: string; - initialVolumeParam, musicEnabledParam, soundEnabledParam: string; - languageFileParam, fullScreenParam: string); -begin - setVideoWithParameters(screenWidthParam,screenHeightParam, bitsParam); - setAudioWithParameters(initialVolumeParam,musicEnabledParam,soundEnabledParam); - setOtherOptions(languageFileParam,fullScreenParam = '1') -end; - -procedure setAltDamageTimerValueAndQuality(altDamage: boolean; timeIterval: LongInt; reducedQuality: boolean); -begin - cAltDamage:= altDamage; - cTimerInterval:= timeIterval; - if (reducedQuality) then //HACK - cReducedQuality:= $FFFFFFFF xor rqLowRes -end; - -procedure setAllOptionsWithParameters(screenWidthParam:string; screenHeightParam:string; bitsParam:string; - initialVolumeParam:string; musicEnabledParam:string; soundEnabledParam:string; - languageFileParam:string; fullScreenParam:string; showFPSParam:string; - altDamageParam:string; timeItervalParam:string; reducedQualityParam: string); -var showFPS, altDamage, reducedQuality: boolean; - timeIterval, c: LongInt; -begin - setMultimediaOptionsWithParameters(screenWidthParam,screenHeightParam, bitsParam, - initialVolumeParam,musicEnabledParam,soundEnabledParam, - languageFileParam,fullScreenParam); - showFPS := showFPSParam = '1'; - setShowFPS(showFPS); - - altDamage:= altDamageParam = '1'; - val(timeItervalParam, timeIterval, c); - reducedQuality:= reducedQualityParam = '1'; - setAltDamageTimerValueAndQuality(altDamage,timeIterval,reducedQuality); -end; - -procedure playReplayFileWithParameters(); -var paramIndex: LongInt; - wrongParameter: boolean; -begin - UserPathPrefix:= ParamStr(1); - PathPrefix:= ParamStr(2); - recordFileName:= ParamStr(3); - paramIndex:= 4; - wrongParameter:= false; - while (paramIndex <= ParamCount) and (not wrongParameter) do - begin - if ParamStr(paramIndex) = '--set-video' then -//--set-video [screen width] [screen height] [color dept] - begin - if(ParamCount-paramIndex < 3) then - begin - wrongParameter:= true; - GameType:= gmtSyntax - end; - setVideoWithParameters(ParamStr(paramIndex+1), ParamStr(paramIndex+2), ParamStr(paramIndex+3)); - paramIndex:= paramIndex + 4 - end - else -//--set-audio [volume] [enable music] [enable sounds] - if ParamStr(paramIndex) = '--set-audio' then - begin - if(ParamCount-paramIndex < 3) then - begin - wrongParameter := true; - GameType:= gmtSyntax - end; - setAudioWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3)); - paramIndex:= paramIndex + 4 - end - else -// --set-other [language file] [full screen] [show FPS] - if ParamStr(paramIndex) = '--set-other' then - begin - if(ParamCount-paramIndex < 3) then - begin - wrongParameter:= true; - GameType:= gmtSyntax - end; - setOtherOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2), ParamStr(paramIndex+3)); - paramIndex:= paramIndex + 4 - end - else -//--set-multimedia [screen width] [screen height] [color dept] [volume] [enable music] [enable sounds] [language file] [full screen] - if ParamStr(paramIndex) = '--set-multimedia' then - begin - if ParamCount-paramIndex < 8 then - begin - wrongParameter:= true; - GameType:= gmtSyntax - end; - setMultimediaOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3), - ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6), - ParamStr(paramIndex+7),ParamStr(paramIndex+8)); - paramIndex:= paramIndex + 9 - end - else -//--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] - if ParamStr(paramIndex) = '--set-everything' then - begin - if ParamCount-paramIndex < 12 then - begin - wrongParameter:= true; - GameType:= gmtSyntax - end; - setAllOptionsWithParameters(ParamStr(paramIndex+1),ParamStr(paramIndex+2),ParamStr(paramIndex+3), - ParamStr(paramIndex+4),ParamStr(paramIndex+5),ParamStr(paramIndex+6), - ParamStr(paramIndex+7),ParamStr(paramIndex+8),ParamStr(paramIndex+9), - ParamStr(paramIndex+10),ParamStr(paramIndex+11),ParamStr(paramIndex+12)); - paramIndex:= paramIndex + 13 - end - else - if ParamStr(paramIndex) = '--stats-only' then - begin - cOnlyStats:= true; - SetSound(false); - SetMusic(false); - cReducedQuality:= $FFFFFFFF xor rqLowRes; // HACK - paramIndex:= paramIndex + 1 - end - else - begin - wrongParameter:= true; - GameType:= gmtSyntax - end - end -end; - diff -r d24257910f8d -r aaefa587e277 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -6,11 +6,22 @@ include(${CMAKE_SOURCE_DIR}/cmake_modules/FindSDL_Extras.cmake) -configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc) #SOURCE AND PROGRAMS SECTION -set(hwengine_project ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas) -set(engine_output_name "hwengine") +if(${LIBENGINE}) + set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(hwengine_project ${CMAKE_CURRENT_SOURCE_DIR}/hwLibrary.pas) +else() + set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}") + set(hwengine_project ${CMAKE_CURRENT_SOURCE_DIR}/hwengine.pas) +endif() + +if (APPLE) + set(required_fpc_version 2.6) +else() + set(required_fpc_version 2.2) +endif() set(engine_sources ${hwengine_project} @@ -54,7 +65,6 @@ uLocale.pas uMatrix.pas uMisc.pas - uMobile.pas uPhysFSLayer.pas uRandom.pas uRender.pas @@ -81,9 +91,8 @@ ${CMAKE_CURRENT_BINARY_DIR}/config.inc ) -if(LIBENGINE) - message(STATUS "Engine will be built as library (experimental)") - set(hwengine_project ${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas) +if(${LIBENGINE}) + message(WARNING "Engine will be built as library (experimental)") set(pascal_flags "-dHWLIBRARY" ${pascal_flags}) # create position independent code, only required for x68_64 builds, similar to -fPIC @@ -92,64 +101,22 @@ endif(CMAKE_SIZEOF_VOID_P MATCHES "8") # 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") + if(APPLE AND current_macosx_version VERSION_GREATER "10.5") set(pascal_flags "-k-no_order_inits" ${pascal_flags}) endif() - - if(APPLE) - set(engine_output_name "libhwengine.dylib") - endif (APPLE) -endif(LIBENGINE) + set(destination_dir ${target_library_install_dir}) +else(${LIBENGINE}) + set(destination_dir ${target_binary_install_dir}) +endif(${LIBENGINE}) -#PASCAL DETECTION SECTION -IF(FPC) - set(fpc_executable ${FPC}) -ELSE() - find_program(fpc_executable fpc) -ENDIF() - -message(STATUS "Check for working FPC compiler: ${fpc_executable}") -execute_process(COMMAND ${fpc_executable} -iV OUTPUT_VARIABLE fpc_output ERROR_VARIABLE fpc_error) -if(fpc_error) - message(STATUS "Check for working FPC compiler: ${fpc_executable} -- broken") -else(fpc_error) - message(STATUS "Check for working FPC compiler: ${fpc_executable} -- works") -endif(fpc_error) +# Check Freepascal version +find_package(Freepascal) -string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") -if(fpc_version) - 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 "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_version LESS "020200") - message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0") - 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 FreePascal compiler found!") +if (FPC_VERSION VERSION_LESS required_fpc_version) + message(FATAL_ERROR "Freepascal is too old, minimum version required is ${required_fpc_version}") endif() -message(STATUS "Checking whether linker supports noexecstack flag") -set(noexecstack_flags "-k-z" "-knoexecstack") -file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.") - -execute_process(COMMAND ${fpc_executable} ${noexecstack_flags} checkstack.pas - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} - RESULT_VARIABLE testnoexecstack - OUTPUT_QUIET ERROR_QUIET - ) - -if(${testnoexecstack}) - set (noexecstack_flags "") - message(STATUS "Checking whether linker supports noexecstack flag -- no") -else(${testnoexecstack}) - message(STATUS "Checking whether linker supports noexecstack flag -- yes") -endif(${testnoexecstack}) #DEPENDECIES AND EXECUTABLES SECTION if(APPLE) @@ -162,13 +129,13 @@ endif() #on OSX we need to provide the SDL_main() function when building as executable - if(NOT LIBENGINE) + if(NOT ${LIBENGINE}) #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}") + string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}") #find libsdmain.a - find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/) + find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_library_only}/Resources/) if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") include_directories(${SDL_INCLUDE_DIR}) @@ -180,7 +147,6 @@ set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags}) endif() - set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags}) endif(APPLE) if(NOT NOPNG) @@ -199,9 +165,8 @@ #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 -if(fpc_version LESS "020600") +if(FPC_VERSION VERSION_LESS "2.6") #under some configurations CMAKE_BUILD_TOOL fails to pass on the jobserver, breaking parallel compilation - #TODO: check if this is needed on windows too if(UNIX) set(SAFE_BUILD_TOOL $(MAKE)) else() @@ -226,7 +191,7 @@ # there are some problems with linking our avwrapper as static lib, so link it as shared add_library(avwrapper SHARED videorec/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}) + install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir}) ELSE() add_library(avwrapper STATIC videorec/avwrapper.c) set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags}) @@ -238,29 +203,33 @@ message(STATUS "Video recording disabled by user") endif() -set(pascal_flags "-Fl${LIBRARY_OUTPUT_PATH}" ${pascal_flags}) -set(fpc_flags ${noexecstack_flags} ${pascal_flags} ${hwengine_project}) +set(fpc_flags ${NOEXECSTACK_FLAGS} ${pascal_flags} ${hwengine_project}) -IF(NOT APPLE) +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 "${fpc_executable}" - ARGS ${fpc_flags} + add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" + COMMAND "${FPC_EXECUTABLE}" + ARGS ${fpc_flags} -o${engine_output_name} MAIN_DEPENDENCY ${hwengine_project} DEPENDS ${engine_sources} ) -ELSE() +else() #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 "${fpc_executable}" + COMMAND "${FPC_EXECUTABLE}" ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch} MAIN_DEPENDENCY ${hwengine_project} DEPENDS ${engine_sources} ) add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}") + add_custom_command(TARGET hwengine.${build_arch} POST_BUILD + COMMAND "install_name_tool" + ARGS -id @executable_path/../Frameworks/${engine_output_name} + ${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch} + ) endforeach() add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" @@ -268,10 +237,10 @@ ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/${engine_output_name} DEPENDS ${lipo_args_list} ) -ENDIF() +endif() -add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}") +add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}") #when system Lua is not found we need to compile it before engine if(NOT LUA_FOUND) @@ -288,8 +257,8 @@ 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})) +if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND})) add_dependencies(${engine_output_name} ENGINECLEAN) endif() -install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir}) +install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir}) diff -r d24257910f8d -r aaefa587e277 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/GSHandlers.inc Tue Dec 25 04:45:22 2012 +0100 @@ -53,7 +53,7 @@ sX:= dX / steps; sY:= dY / steps; end - + else begin sX:= dX; @@ -75,7 +75,7 @@ end; procedure makeHogsWorry(x, y: hwFloat; r: LongInt); -var +var gi: PGear; d: LongInt; begin @@ -89,7 +89,7 @@ begin if (CurrentHedgehog^.Gear = gi) then PlaySoundV(sndOops, gi^.Hedgehog^.Team^.voicepack) - + else begin if (gi^.State and gstMoving) = 0 then @@ -97,15 +97,15 @@ gi^.dX.isNegative:= X r div 2 then - PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) + PlaySoundV(sndNooo, gi^.Hedgehog^.Team^.voicepack) else PlaySoundV(sndUhOh, gi^.Hedgehog^.Team^.voicepack); end; end; end; - + gi := gi^.NextGear end; end; @@ -116,10 +116,10 @@ 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 @@ -165,7 +165,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFallingGear(Gear: PGear); -var +var isFalling: boolean; //tmp: QWord; tdX, tdY: hwFloat; @@ -220,16 +220,16 @@ else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then collV := 1; end - else + else 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 + if land and lfIce <> 0 then Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) - else + else Gear^.dX := Gear^.dX * Gear^.Friction; Gear^.dY := - Gear^.dY * Gear^.Elasticity; @@ -252,7 +252,7 @@ Gear^.State := Gear^.State or gstCollision end else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then - collH := -hwSign(Gear^.dX); + 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 @@ -285,18 +285,18 @@ else Gear^.State := Gear^.State or gstMoving; - if (Gear^.nImpactSounds > 0) and + if (Gear^.nImpactSounds > 0) and (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^.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; //////////////////////////////////////////////////////////////////////////////// procedure doStepBomb(Gear: PGear); -var +var i, x, y: LongInt; dX, dY: hwFloat; vg: PVisualGear; @@ -307,7 +307,7 @@ dec(Gear^.Timer); if Gear^.Timer = 1000 then // might need adjustments - case Gear^.Kind of + case Gear^.Kind of gtGrenade: makeHogsWorry(Gear^.X, Gear^.Y, 50); gtClusterBomb: makeHogsWorry(Gear^.X, Gear^.Y, 20); gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75); @@ -331,10 +331,10 @@ if Gear^.Timer = 0 then begin - case Gear^.Kind of + 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: + gtClusterBomb: begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); @@ -346,7 +346,7 @@ FollowGear := AddGear(x, y, gtCluster, 0, dX, dY, 25) end end; - gtWatermelon: + gtWatermelon: begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); @@ -359,7 +359,7 @@ FollowGear^.DirAngle := i * 60 end end; - gtHellishBomb: + gtHellishBomb: begin x := hwRound(Gear^.X); y := hwRound(Gear^.Y); @@ -375,7 +375,7 @@ AddGear(x, y, gtFlame, 0, dX, -dY, 0) end else - begin + begin AddGear(x, y, gtFlame, 0, dX, dY, 0); AddGear(x, y, gtFlame, gstTmpFlag, dX, -dY, 0) end; @@ -415,7 +415,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepMolotov(Gear: PGear); -var +var s: Longword; i, gX, gY: LongInt; dX, dY: hwFloat; @@ -435,7 +435,7 @@ 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; @@ -694,10 +694,10 @@ end; p:= @(p^[s^.pitch shr 2]) end; - - // Why is this here. For one thing, there's no test on +1 being safe. + + // Why is this here. For one thing, there's no test on +1 being safe. //Land[py, px+1]:= lfBasic; - + if allpx then UpdateLandTexture(xx, Pred(s^.h), yy, Pred(s^.w), true) else @@ -762,7 +762,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepBeeWork(Gear: PGear); -var +var t: hwFloat; gX,gY,i: LongInt; uw, nuw: boolean; @@ -877,7 +877,7 @@ 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); Gear^.Timer := 5000; // save initial speed in otherwise unused Friction variable @@ -899,7 +899,7 @@ end; procedure doStepShotgunShot(Gear: PGear); -var +var i: LongWord; shell: PVisualGear; begin @@ -975,7 +975,7 @@ // Bullet trail VGear := AddVisualGear(hwRound(ox), hwRound(oy), vgtLineTrail); - + if VGear <> nil then begin VGear^.X:= hwFloat2Float(ox); @@ -998,7 +998,7 @@ end; procedure doStepBulletWork(Gear: PGear); -var +var i: LongInt; x, y: LongWord; oX, oY: hwFloat; @@ -1014,7 +1014,7 @@ 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); // let's interrupt before a collision to give portals a chance to catch the bullet @@ -1036,7 +1036,7 @@ 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 @@ -1064,7 +1064,7 @@ 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 @@ -1074,7 +1074,7 @@ VGear^.Angle := DxDy2Angle(-Gear^.dX, Gear^.dY); end; end; - + spawnBulletTrail(Gear); Gear^.doStep := @doStepShotIdle end; @@ -1090,7 +1090,7 @@ end; procedure doStepSniperRifleShot(Gear: PGear); -var +var HHGear: PGear; shell: PVisualGear; begin @@ -1121,7 +1121,7 @@ Gear^.dY := -AngleCos(HHGear^.Angle) * _0_5; PlaySound(sndGun); // add 3 initial steps to avoid problem with ammoshove related to calculation of radius + 1 radius as gear widths, and also just weird angles - Gear^.X := Gear^.X + Gear^.dX * 3; + Gear^.X := Gear^.X + Gear^.dX * 3; Gear^.Y := Gear^.Y + Gear^.dY * 3; Gear^.doStep := @doStepBulletWork; end @@ -1150,7 +1150,7 @@ begin dec(Gear^.Timer); case Gear^.Kind of - gtATStartGame: + gtATStartGame: begin AllInactive := false; if Gear^.Timer = 0 then @@ -1158,7 +1158,7 @@ AddCaption(trmsg[sidStartFight], cWhiteColor, capgrpGameState); end end; - gtATFinishGame: + gtATFinishGame: begin AllInactive := false; if Gear^.Timer = 1000 then @@ -1181,7 +1181,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepPickHammerWork(Gear: PGear); -var +var i, ei, x, y: LongInt; HHGear: PGear; begin @@ -1272,7 +1272,7 @@ end; procedure doStepPickHammer(Gear: PGear); -var +var i, y: LongInt; ar: TRangeArray; HHGear: PGear; @@ -1299,11 +1299,11 @@ end; //////////////////////////////////////////////////////////////////////////////// -var +var BTPrevAngle, BTSteps: LongInt; procedure doStepBlowTorchWork(Gear: PGear); -var +var HHGear: PGear; b: boolean; prevX: LongInt; @@ -1312,7 +1312,7 @@ dec(Gear^.Timer); if ((GameFlags and gfInfAttack) <> 0) and (TurnTimeLeft > 0) then dec(TurnTimeLeft); - + HHGear := Gear^.Hedgehog^.Gear; HedgehogChAngle(HHGear); @@ -1393,7 +1393,7 @@ end; procedure doStepBlowTorch(Gear: PGear); -var +var HHGear: PGear; begin BTPrevAngle := High(LongInt); @@ -1433,7 +1433,7 @@ 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 ((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); @@ -1495,9 +1495,9 @@ procedure doStepSMine(Gear: PGear); begin // TODO: do real calculation? - if TestCollisionXwithGear(Gear, 2) - or (TestCollisionYwithGear(Gear, -2) <> 0) - or TestCollisionXwithGear(Gear, -2) + 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 @@ -1572,14 +1572,14 @@ Try tweaking friction some more *) procedure doStepRollingBarrel(Gear: PGear); -var +var i: LongInt; particle: PVisualGear; begin 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 @@ -1598,10 +1598,10 @@ 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)); @@ -1650,7 +1650,7 @@ end; procedure doStepCase(Gear: PGear); -var +var i, x, y: LongInt; k: TGearType; exBoom: boolean; @@ -1691,7 +1691,7 @@ exBoom := true; end else - begin + begin if (Gear^.Pos <> posCaseHealth) and (GameTicks and $1FFF = 0) then // stir 'em up periodically begin gi := GearsList; @@ -1728,12 +1728,12 @@ sparkles^.dX:= 0; sparkles^.dY:= 0; sparkles^.Angle:= 270; - if Gear^.Tag = 1 then + if Gear^.Tag = 1 then sparkles^.Tint:= $3744D7FF else sparkles^.Tint:= $FAB22CFF end; end; - if Gear^.Timer < 1000 then + if Gear^.Timer < 1000 then begin AllInactive:= false; exit @@ -1792,7 +1792,7 @@ 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); - + Gear^.dY := - Gear^.dY * Gear^.Elasticity; if Gear^.dY > - _0_001 then Gear^.dY := _0 @@ -1846,7 +1846,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepShover(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -1862,7 +1862,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepWhip(Gear: PGear); -var +var HHGear: PGear; i: LongInt; begin @@ -1884,7 +1884,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFlame(Gear: PGear); -var +var gX,gY,i: LongInt; sticky: Boolean; vgt: PVisualGear; @@ -1911,10 +1911,10 @@ 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; @@ -1975,13 +1975,13 @@ Gear^.Radius := 1; end else if ((GameTicks and $3) = 3) then - doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage); + doMakeExplosion(gX, gY, 8, Gear^.Hedgehog, 0);//, EXPLNoDamage); //DrawExplosion(gX, gY, 4); - + if ((GameTicks and $7) = 0) and (Random(2) = 0) then for i:= Random(2) downto 0 do AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); - + if Gear^.Health > 0 then dec(Gear^.Health); Gear^.Timer := 450 - Gear^.Tag * 8 @@ -2024,7 +2024,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepFirePunchWork(Gear: PGear); -var +var HHGear: PGear; begin AllInactive := false; @@ -2061,7 +2061,7 @@ end; procedure doStepFirePunch(Gear: PGear); -var +var HHGear: PGear; begin AllInactive := false; @@ -2084,7 +2084,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepParachuteWork(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -2113,13 +2113,13 @@ 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; @@ -2132,7 +2132,7 @@ end; procedure doStepParachute(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -2159,7 +2159,7 @@ 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 + 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); @@ -2202,7 +2202,7 @@ // calcs for Napalm Strike, so that it will hit the target (without wind at least :P) if (Gear^.State = 2) then - Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900 + Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900 // calcs for regular falling gears else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 / @@ -2224,7 +2224,9 @@ begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); DeleteGear(Gear); - performRumble(); + with mobileRecord do + if (performRumble <> nil) and (not fastUntilLag) then + performRumble(kSystemSoundID_Vibrate); exit end; if (GameTicks and $3F) = 0 then @@ -2234,7 +2236,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepGirder(Gear: PGear); -var +var HHGear: PGear; x, y, tx, ty: hwFloat; begin @@ -2256,7 +2258,7 @@ isCursorVisible := true; DeleteGear(Gear) end - else + else begin PlaySound(sndPlaced); DeleteGear(Gear); @@ -2269,7 +2271,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepTeleportAfter(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -2303,7 +2305,7 @@ end; procedure doStepTeleport(Gear: PGear); -var +var HHGear: PGear; begin AllInactive := false; @@ -2344,7 +2346,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepSwitcherWork(Gear: PGear); -var +var HHGear: PGear; hedgehog: PHedgehog; State: Longword; @@ -2382,7 +2384,7 @@ until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0); SwitchCurrentHedgehog(@CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]); - AmmoMenuInvalidated:= true; + AmmoMenuInvalidated:= true; HHGear := CurrentHedgehog^.Gear; HHGear^.State := State; @@ -2396,7 +2398,7 @@ end; procedure doStepSwitcher(Gear: PGear); -var +var HHGear: PGear; begin Gear^.doStep := @doStepSwitcherWork; @@ -2412,7 +2414,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepMortar(Gear: PGear); -var +var dX, dY: hwFloat; i: LongInt; dxn, dyn: boolean; @@ -2445,7 +2447,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepKamikazeWork(Gear: PGear); -var +var i: LongWord; HHGear: PGear; sparkles: PVisualGear; @@ -2480,7 +2482,7 @@ i := 2; repeat - + Gear^.X := Gear^.X + HHGear^.dX; Gear^.Y := Gear^.Y + HHGear^.dY; HHGear^.X := Gear^.X; @@ -2563,7 +2565,7 @@ end; procedure doStepKamikaze(Gear: PGear); -var +var HHGear: PGear; begin AllInactive := false; @@ -2584,7 +2586,7 @@ //////////////////////////////////////////////////////////////////////////////// const cakeh = 27; -var +var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; @@ -2604,7 +2606,7 @@ end; procedure doStepCakeDown(Gear: PGear); -var +var gi: PGear; dmg, dmgBase: LongInt; fX, fY, tdX, tdY: hwFloat; @@ -2690,7 +2692,7 @@ end; procedure doStepCakeUp(Gear: PGear); -var +var i: Longword; begin AllInactive := false; @@ -2730,7 +2732,7 @@ end; procedure doStepCake(Gear: PGear); -var +var HHGear: PGear; begin AllInactive := false; @@ -2835,7 +2837,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepWaterUp(Gear: PGear); -var +var i: LongWord; begin if (Gear^.Tag = 0) @@ -2869,7 +2871,7 @@ forward; procedure doStepDrillDrilling(Gear: PGear); -var +var t: PGearArray; ox, oy: hwFloat; begin @@ -2893,10 +2895,10 @@ 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 <> 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 @@ -2911,7 +2913,7 @@ DeleteGear(Gear); exit end - + else if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)))) then begin StopSoundChan(Gear^.SoundChannel); @@ -2923,7 +2925,7 @@ end; procedure doStepDrill(Gear: PGear); -var +var t: PGearArray; oldDx, oldDy: hwFloat; t2: hwFloat; @@ -2947,7 +2949,7 @@ Gear^.dX := oldDx; Gear^.dY := oldDy; - if GameTicks > Gear^.FlightTime then + if GameTicks > Gear^.FlightTime then t := CheckGearsCollision(Gear) else t := nil; @@ -2958,7 +2960,7 @@ Gear^.dX := Gear^.dX * t2; Gear^.dY := Gear^.dY * t2; end - + else if (t <> nil) then begin //explode right on contact with HH @@ -2972,14 +2974,14 @@ Gear^.SoundChannel := LoopSound(sndDrillRocket); Gear^.doStep := @doStepDrillDrilling; - + if (Gear^.State and gsttmpFlag) <> 0 then gear^.RenderTimer:= true; 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 + if Gear^.Timer > 0 then dec(Gear^.Timer) else begin @@ -2991,7 +2993,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepBallgunWork(Gear: PGear); -var +var HHGear, ball: PGear; rx, ry: hwFloat; gX, gY: LongInt; @@ -3021,7 +3023,7 @@ end; procedure doStepBallgun(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -3034,7 +3036,7 @@ procedure doStepRCPlaneWork(Gear: PGear); const cAngleSpeed = 3; -var +var HHGear: PGear; i: LongInt; dX, dY: hwFloat; @@ -3143,7 +3145,7 @@ begin if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft; - + TurnTimeLeft:= 14 * 125; end; @@ -3153,7 +3155,7 @@ end; procedure doStepRCPlane(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -3161,7 +3163,7 @@ 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; Gear^.doStep := @doStepRCPlaneWork @@ -3169,7 +3171,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepJetpackWork(Gear: PGear); -var +var HHGear: PGear; fuel, i: LongInt; move: hwFloat; @@ -3248,9 +3250,9 @@ 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; @@ -3259,9 +3261,9 @@ 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 + 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; @@ -3271,7 +3273,7 @@ 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); @@ -3303,7 +3305,7 @@ end; procedure doStepJetpack(Gear: PGear); -var +var HHGear: PGear; begin Gear^.Pos:= 0; @@ -3316,7 +3318,7 @@ 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 Gear^.State := Gear^.State or gsttmpFlag; @@ -3339,13 +3341,13 @@ end; procedure doStepBirdyFly(Gear: PGear); -var +var HHGear: PGear; fuel, i: LongInt; move: hwFloat; begin HHGear := Gear^.Hedgehog^.Gear; - if HHGear = nil then + if HHGear = nil then begin DeleteGear(Gear); exit @@ -3369,11 +3371,11 @@ 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 @@ -3384,7 +3386,7 @@ 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); @@ -3402,7 +3404,7 @@ 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)); HHGear^.State := HHGear^.State or gstMoving; @@ -3445,7 +3447,7 @@ end; procedure doStepBirdyDescend(Gear: PGear); -var +var HHGear: PGear; begin if Gear^.Timer > 0 then @@ -3486,12 +3488,12 @@ end; procedure doStepBirdy(Gear: PGear); -var +var HHGear: PGear; begin gear^.State := gear^.State or gstAnimation and (not gstTmpFlag); Gear^.doStep := @doStepBirdyAppear; - + if CurrentHedgehog = nil then begin DeleteGear(Gear); @@ -3516,7 +3518,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepEggWork(Gear: PGear); -var +var vg: PVisualGear; i: LongInt; begin @@ -3559,18 +3561,18 @@ if (CurAmmoType = amPortalGun) then begin CurrentHedgehog^.Gear^.Message := CurrentHedgehog^.Gear^.Message and (not gmSwitch); - + CurWeapon:= GetCurAmmoEntry(CurrentHedgehog^); if CurWeapon^.Pos <> 0 then CurWeapon^.Pos := 0 - + else CurWeapon^.Pos := 1; end; end; procedure doStepPortal(Gear: PGear); -var +var iterator, conPortal: PGear; s, r, nx, ny, ox, oy, poffs, noffs, pspeed, nspeed, resetx, resety, resetdx, resetdy: hwFloat; @@ -3871,7 +3873,7 @@ 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); @@ -3938,7 +3940,7 @@ end; procedure doStepMovingPortal_real(Gear: PGear); -var +var x, y, tx, ty: LongInt; s: hwFloat; begin @@ -3952,7 +3954,7 @@ begin Gear^.State := Gear^.State or gstCollision; 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 @@ -3980,7 +3982,7 @@ else loadNewPortalBall(Gear, true); end - + else if (y > cWaterLine) or (y < -max(LAND_WIDTH,4096)) or (x > 2*max(LAND_WIDTH,4096)) @@ -3992,13 +3994,13 @@ begin doPortalColorSwitch(); doStepPerPixel(Gear, @doStepMovingPortal_real, true); - if (Gear^.Timer < 1) + if (Gear^.Timer < 1) or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) then deleteGear(Gear); end; procedure doStepPortalShot(newPortal: PGear); -var +var iterator: PGear; s: hwFloat; CurWeapon: PAmmo; @@ -4078,15 +4080,15 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepPiano(Gear: PGear); -var +var r0, r1: LongInt; odY: hwFloat; begin AllInactive := false; - if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and + if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and ((CurrentHedgehog^.Gear^.Message and gmSlot) <> 0) then begin - case CurrentHedgehog^.Gear^.MsgParam of + case CurrentHedgehog^.Gear^.MsgParam of 0: PlaySound(sndPiano0); 1: PlaySound(sndPiano1); 2: PlaySound(sndPiano2); @@ -4166,7 +4168,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepSineGunShotWork(Gear: PGear); -var +var x, y, rX, rY, t, tmp, initHealth: LongInt; oX, oY, ldX, ldY, sdX, sdY, sine, lx, ly, amp: hwFloat; justCollided: boolean; @@ -4261,7 +4263,7 @@ end; if random(100) = 0 then - AddVisualGear(x, y, vgtSmokeTrace); + AddVisualGear(x, y, vgtSmokeTrace); end else dec(Gear^.Health, 5); // if underwater get additional damage end; @@ -4299,7 +4301,7 @@ var HHGear: PGear; begin - PlaySound(sndSineGun); + PlaySound(sndSineGun); // push the shooting Hedgehog back HHGear := CurrentHedgehog^.Gear; @@ -4312,12 +4314,14 @@ Gear^.dY.isNegative := not Gear^.dY.isNegative; Gear^.doStep := @doStepSineGunShotWork; - performRumble(); + with mobileRecord do + if (performRumble <> nil) and (not fastUntilLag) then + performRumble(kSystemSoundID_Vibrate); end; //////////////////////////////////////////////////////////////////////////////// procedure doStepFlamethrowerWork(Gear: PGear); -var +var HHGear, flame: PGear; rx, ry, speed: hwFloat; i, gX, gY: LongInt; @@ -4327,7 +4331,7 @@ HedgehogChAngle(HHGear); gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle); gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle); - + if (GameTicks and $FF) = 0 then begin if (HHGear^.Message and gmRight) <> 0 then @@ -4341,11 +4345,11 @@ begin if HHGear^.dX.isNegative and (Gear^.Tag > 5) then dec(Gear^.Tag) - else if Gear^.Tag < 20 then + else if Gear^.Tag < 20 then inc(Gear^.Tag); end end; - + dec(Gear^.Timer); if Gear^.Timer = 0 then begin @@ -4355,12 +4359,12 @@ rx := rndSign(getRandomf * _0_1); ry := rndSign(getRandomf * _0_1); speed := _0_5 * (_10 / Gear^.Tag); - + 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 begin flame:= AddGear(gx, gy, gtFlame, 0, @@ -4391,7 +4395,7 @@ end; procedure doStepFlamethrower(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -4402,7 +4406,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepLandGunWork(Gear: PGear); -var +var HHGear, land: PGear; rx, ry, speed: hwFloat; i, gX, gY: LongInt; @@ -4412,7 +4416,7 @@ HedgehogChAngle(HHGear); gX := hwRound(Gear^.X) + GetLaunchX(amBallgun, hwSign(HHGear^.dX), HHGear^.Angle); gY := hwRound(Gear^.Y) + GetLaunchY(amBallgun, HHGear^.Angle); - + if (GameTicks and $FF) = 0 then begin if (HHGear^.Message and gmRight) <> 0 then @@ -4430,7 +4434,7 @@ inc(Gear^.Tag); end end; - + dec(Gear^.Timer); if Gear^.Timer = 0 then begin @@ -4440,11 +4444,11 @@ ry := rndSign(getRandomf * _0_1); speed := (_3 / Gear^.Tag); - land:= AddGear(gx, gy, gtFlake, gstTmpFlag, - SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx, + 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; @@ -4468,7 +4472,7 @@ end; procedure doStepLandGun(Gear: PGear); -var +var HHGear: PGear; begin HHGear := Gear^.Hedgehog^.Gear; @@ -4537,7 +4541,7 @@ end; procedure doStepHammerHitWork(Gear: PGear); -var +var i, j, ei: LongInt; HitGear: PGear; begin @@ -4592,7 +4596,7 @@ end; procedure doStepHammerHit(Gear: PGear); -var +var i, y: LongInt; ar: TRangeArray; HHGear: PGear; @@ -4643,7 +4647,7 @@ begin if (GameTicks and $F) <> 0 then exit; - end + end else if (GameTicks and $1FF) <> 0 then exit; @@ -4680,8 +4684,8 @@ inc(graves[i]^.Health); end; end; -} - end - else + end + else begin // now really resurrect the hogs with the hp saved in the graves for i:= 0 to graves.size - 1 do @@ -4729,8 +4733,8 @@ graves.ar^[i]^.Health := 0; end; Gear^.doStep := @doStepResurrectorWork; - end - else + end + else begin StopSoundChan(Gear^.SoundChannel); Gear^.Timer := 250; @@ -4750,7 +4754,7 @@ begin doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 10, Gear^.Hedgehog, EXPLAutoSound); gX := hwRound(Gear^.X); - gY := hwRound(Gear^.Y); + gY := hwRound(Gear^.Y); for i:= 0 to 10 do begin dX := AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandomf + _1); @@ -4778,7 +4782,7 @@ //////////////////////////////////////////////////////////////////////////////// procedure doStepStructure(Gear: PGear); -var +var x, y: LongInt; HH: PHedgehog; t: PGear; @@ -4795,7 +4799,7 @@ dec(Gear^.Health, Gear^.Damage); Gear^.Damage:= 0; - + if Gear^.Pos = 1 then begin AddGearCI(Gear); @@ -4806,7 +4810,7 @@ HideHog(HH); Gear^.Pos:= 2 end; - + if Gear^.Pos = 2 then begin if ((GameTicks mod 100) = 0) and (Gear^.Timer < 1000) then @@ -4822,7 +4826,7 @@ if Gear^.Tag <= TotalRounds then Gear^.Pos:= 3; end; - + if Gear^.Pos = 3 then if Gear^.Timer < 1000 then begin @@ -4840,7 +4844,7 @@ RestoreHog(HH); Gear^.Pos:= 4; end; - + if Gear^.Pos = 4 then if ((GameTicks mod 1000) = 0) and ((GameFlags and gfInvulnerable) = 0) then begin @@ -4852,12 +4856,12 @@ 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); @@ -4870,7 +4874,7 @@ //////////////////////////////////////////////////////////////////////////////// (* - TARDIS needs + TARDIS needs Warp in. Pos = 1 Pause. Pos = 2 Hide gear (TARDIS hedgehog was nil) @@ -4896,7 +4900,7 @@ begin AfterAttack; if Gear = CurAmmoGear then CurAmmoGear := nil; - if (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and + if (HH^.Gear^.Damage = 0) and (HH^.Gear^.Health > 0) and ((Gear^.State and (gstMoving or gstHHDeath or gstHHGone)) = 0) then HideHog(HH) end @@ -4916,7 +4920,7 @@ if (Gear^.Pos = 1) and (GameTicks and $1F = 0) and (Gear^.Power < 255) then begin inc(Gear^.Power); - if (Gear^.Power = 172) and (HH^.Gear <> nil) and + 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 @@ -4957,7 +4961,7 @@ begin if HH^.GearHidden <> nil then FindPlace(HH^.GearHidden, false, 0, LAND_WIDTH,true); - + if HH^.GearHidden <> nil then begin Gear^.X:= HH^.GearHidden^.X; @@ -5033,7 +5037,7 @@ 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". +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. @@ -5073,8 +5077,8 @@ 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 + 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; @@ -5088,8 +5092,8 @@ iter := GearsList; while iter <> nil do begin - if (iter^.Kind = gtHedgehog) and - (iter^.Hedgehog^.Effects[heFrozen] < 0) then + if (iter^.Kind = gtHedgehog) and + (iter^.Hedgehog^.Effects[heFrozen] < 0) then iter^.Hedgehog^.Effects[heFrozen]:= 0; iter:= iter^.NextGear end *) @@ -5211,7 +5215,7 @@ DeleteGear(Gear) end; // ssssss he essssscaped - if (Gear^.Timer > 250) and ((HHGear = nil) or + 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 @@ -5222,7 +5226,7 @@ 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 +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 @@ -5339,7 +5343,7 @@ 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, +var t, gx, gy, ga, // gear x,y,angle lx, ly, la, // land x,y,angle ox, oy, // x,y offset @@ -5363,7 +5367,7 @@ begin if CheckLandValue(gx, gy, $FF00) then begin - t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); + t:= Angle + hwRound((hwAbs(dX)+hwAbs(dY)) * _10); if t < 0 then inc(t, 4096) else if 4095 < t then dec(t, 4096); @@ -5400,7 +5404,7 @@ 4: begin ox:= 29; oy:= 8; w:= 19; h:= 19; - tx:= 0; ty:= 17 + tx:= 0; ty:= 17 end; 5: begin ox:= 29; oy:= 32; @@ -5410,7 +5414,7 @@ 6: begin ox:= 51; oy:= 3; w:= 11; h:= 23; - tx:= 0; ty:= 22 + tx:= 0; ty:= 22 end; 7: begin ox:= 51; oy:= 34; @@ -5418,7 +5422,7 @@ 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 @@ -5440,7 +5444,7 @@ AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle)) end; case Angle div 1024 of - 0: begin + 0: begin flipSurface(surf, true); flipSurface(surf, true); BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy-(h-ty), w, surf) diff -r d24257910f8d -r aaefa587e277 hedgewars/VGSHandlers.inc --- a/hedgewars/VGSHandlers.inc Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/VGSHandlers.inc Tue Dec 25 04:45:22 2012 +0100 @@ -60,8 +60,8 @@ else if Angle < - 360 then Angle:= Angle + 360; - - + + if (round(X) >= cLeftScreenBorder) and (round(X) <= cRightScreenBorder) and (round(Y) - 75 <= LAND_HEIGHT) @@ -644,10 +644,10 @@ begin gX:= round(Gear^.X); gY:= round(Gear^.Y); -for i:= 0 to 31 do +for i:= 0 to 31 do begin vg:= AddVisualGear(gX, gY, vgtFire); - if vg <> nil then + if vg <> nil then begin vg^.State:= gstTmpFlag; inc(vg^.FrameTicks, vg^.FrameTicks) @@ -688,10 +688,10 @@ gX:= round(Gear^.X); gY:= round(Gear^.Y); AddVisualGear(gX, gY, vgtSmokeRing); -for i:= 0 to 46 do +for i:= 0 to 46 do begin vg:= AddVisualGear(gX, gY, vgtFire); - if vg <> nil then + if vg <> nil then begin vg^.State:= gstTmpFlag; inc(vg^.FrameTicks, vg^.FrameTicks) @@ -704,7 +704,9 @@ Gear^.doStep:= @doStepBigExplosionWork; if Steps > 1 then Gear^.doStep(Gear, Steps-1); -performRumble(); +with mobileRecord do + if (performRumble <> nil) and (not fastUntilLag) then + performRumble(kSystemSoundID_Vibrate); end; procedure doStepChunk(Gear: PVisualGear; Steps: Longword); @@ -766,7 +768,7 @@ procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword); begin inc(Gear^.Timer, Steps); - + while Gear^.Timer >= 10 do begin dec(Gear^.Timer, 10); @@ -785,8 +787,8 @@ cWindspeedf := cWindspeedf + Gear^.Angle*Steps; if cWindspeedf > Gear^.dAngle then cWindspeedf:= Gear^.dAngle; end; - -if (WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle) then + +if (WindBarWidth = Gear^.Tag) and (cWindspeedf = Gear^.dAngle) then DeleteVisualGear(Gear) end; //////////////////////////////////////////////////////////////////////////////// @@ -800,7 +802,7 @@ else begin dec(Gear^.FrameTicks, Steps); - if (Gear^.FrameTicks < 501) and (Gear^.FrameTicks mod 5 = 0) then + if (Gear^.FrameTicks < 501) and (Gear^.FrameTicks mod 5 = 0) then Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or (((Gear^.Tint and $000000FF) * Gear^.FrameTicks) div 500) end end; diff -r d24257910f8d -r aaefa587e277 hedgewars/config.inc.in --- a/hedgewars/config.inc.in Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/config.inc.in Tue Dec 25 04:45:22 2012 +0100 @@ -24,3 +24,4 @@ const cNetProtoVersion = ${HEDGEWARS_PROTO_VER}; cVersionString = '${HEDGEWARS_VERSION}'; cLuaLibrary = '${LUA_LIBRARY}'; + cDefaultPathPrefix = '${CMAKE_INSTALL_PREFIX}/${SHAREPATH}/Data'; diff -r d24257910f8d -r aaefa587e277 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/hwengine.pas Tue Dec 25 04:45:22 2012 +0100 @@ -29,21 +29,23 @@ program hwengine; {$ENDIF} -uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uInputHandler, - uSound, uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uLandTexture, uCollisions, - uAILandMarks, SysUtils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug, uCommandHandlers, - uLandPainted, uFloat, uPhysFSLayer +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 + , uPhysFSLayer, uCursor {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF} {$IFDEF USE_TOUCH_INTERFACE}, uTouch {$ENDIF} {$IFDEF ANDROID}, GLUnit{$ENDIF} {$IFDEF WEBGL}, uWeb{$ENDIF} ; +var isInternal: Boolean; + {$IFDEF HWLIBRARY} procedure preInitEverything(); procedure initEverything(complete:boolean); procedure freeEverything(complete:boolean); -procedure Game(gameArgs: PPChar); cdecl; export; +procedure Game(argc: LongInt; argv: PPChar); cdecl; export; procedure GenLandPreview(port: Longint); cdecl; export; implementation @@ -53,6 +55,8 @@ procedure freeEverything(complete:boolean); forward; {$ENDIF} +{$INCLUDE "ArgParsers.inc"} + {$IFDEF WEBGL} procedure playFile(path: PChar); forward; function isEngineRunning():Integer; forward; @@ -185,7 +189,7 @@ {$ENDIF} 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 @@ -199,7 +203,7 @@ SDL_KEYUP: if GameState <> gsChat then ProcessKey(event.key); - + SDL_WINDOWEVENT: if event.window.event = SDL_WINDOWEVENT_SHOWN then begin @@ -225,13 +229,13 @@ cNewScreenHeight:= max(2 * (event.window.data2 div 2), cMinScreenHeight); 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} @@ -243,13 +247,19 @@ SDL_KEYUP: if GameState <> gsChat then ProcessKey(event.key); - + SDL_MOUSEBUTTONDOWN: - ProcessMouse(event.button, true); - + if GameState = gsConfirm then + begin + resetPosition(); + ParseCommand('quit', true); + end + else + ProcessMouse(event.button, true); + SDL_MOUSEBUTTONUP: - ProcessMouse(event.button, false); - + ProcessMouse(event.button, false); + SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then begin @@ -258,7 +268,7 @@ if prevFocusState xor cHasFocus then onFocusStateChanged() end; - + SDL_VIDEORESIZE: begin // using lower values than cMinScreenWidth or cMinScreenHeight causes widget overlap and off-screen widget parts @@ -354,7 +364,7 @@ {$ENDIF} /////////////////////////////////////////////////////////////////////////////// -procedure Game{$IFDEF HWLIBRARY}(gameArgs: PPChar); cdecl; export{$ENDIF}; +procedure Game{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar); cdecl; export{$ENDIF}; var p: TPathType; s: shortstring; i: LongInt; @@ -365,24 +375,11 @@ begin {$IFDEF HWLIBRARY} preInitEverything(); - cShowFPS:= {$IFDEF DEBUGFILE}true{$ELSE}false{$ENDIF}; - ipcPort:= StrToInt(gameArgs[0]); - cScreenWidth:= StrToInt(gameArgs[1]); - cScreenHeight:= StrToInt(gameArgs[2]); - cReducedQuality:= StrToInt(gameArgs[3]); - cLocaleFName:= gameArgs[4]; - UserNick:= gameArgs[5]; - SetSound(gameArgs[6] = '1'); - SetMusic(gameArgs[7] = '1'); - cAltDamage:= gameArgs[8] = '1'; - PathPrefix:= gameArgs[9]; - UserPathPrefix:= '../Documents'; - recordFileName:= gameArgs[10]; + parseCommandLine(argc, argv); {$ENDIF} initEverything(true); + WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); - WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')'); - for i:= 0 to ParamCount do AddFileLog(inttostr(i) + ': ' + ParamStr(i)); @@ -402,7 +399,7 @@ InitOffscreenOpenGL() else {$ENDIF} - begin + begin // show main window if cFullScreen then ParseCommand('fullscr 1', true) @@ -460,7 +457,7 @@ exit; end; {$ENDIF} - + {$IFDEF WEBGL} l := generateResourceList(); clear_filelist_hook(); @@ -592,60 +589,6 @@ end; {$IFNDEF HWLIBRARY} -/////////////////////////////////////////////////////////////////////////////// -procedure DisplayUsage; -var i: LongInt; -begin - 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(stdout, ParamStr(i) + ' '); - - WriteLn(stdout, ''); -end; - -/////////////////////////////////////////////////////////////////////////////// -{$INCLUDE "ArgParsers.inc"} - -procedure GetParams; -begin - if (ParamCount < 3) then - GameType:= gmtSyntax - else - if (ParamCount = 3) and (ParamStr(3) = 'landpreview') then - begin - ipcPort:= StrToInt(ParamStr(2)); - GameType:= gmtLandPreview; - end - else - begin - if (ParamCount = 3) and (ParamStr(3) = '--stats-only') then - playReplayFileWithParameters() - else - if ParamCount = cDefaultParamNum then - internalStartGameWithParameters() -{$IFDEF USE_VIDEO_RECORDING} - else if ParamCount = cVideorecParamNum then - internalStartVideoRecordingWithParameters() -{$ENDIF} - else - playReplayFileWithParameters(); - end -end; /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////// m a i n /////////////////////////////////// @@ -667,9 +610,8 @@ if GameType = gmtLandPreview then GenLandPreview() - else if GameType = gmtSyntax then - DisplayUsage() - else Game(); + else if GameType <> gmtSyntax then + Game(); // return 1 when engine is not called correctly {$IFDEF PAS2C} diff -r d24257910f8d -r aaefa587e277 hedgewars/options.inc --- a/hedgewars/options.inc Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/options.inc Tue Dec 25 04:45:22 2012 +0100 @@ -50,12 +50,12 @@ {$IFDEF MOBILE} {$DEFINE HWLIBRARY} - {$DEFINE S3D_DISABLED} {$DEFINE GLunit:=gles11} {$DEFINE USE_LANDSCAPE_AMMOMENU} {$DEFINE USE_TOUCH_INTERFACE} {$ELSE} {$DEFINE USE_AM_NUMCOLUMN} + {$DEFINE USE_S3D_RENDERING} {$ENDIF} diff -r d24257910f8d -r aaefa587e277 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uAIAmmoTests.pas Tue Dec 25 04:45:22 2012 +0100 @@ -21,7 +21,7 @@ unit uAIAmmoTests; interface uses SDLh, uConsts, uFloat, uTypes; -const +const amtest_Rare = $00000001; // check only several positions amtest_NoTarget = $00000002; // each pos, but no targetting @@ -116,7 +116,7 @@ (proc: nil; flags: 0), // amDrillStrike (proc: nil; flags: 0), // amSnowball (proc: nil; flags: 0), // amTardis - (proc: nil; flags: 0), // amStructure + //(proc: nil; flags: 0), // amStructure (proc: nil; flags: 0), // amLandGun (proc: nil; flags: 0), // amIceGun (proc: nil; flags: 0) // amKnife @@ -163,9 +163,9 @@ dX:= dX + windSpeed; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + 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 @@ -222,9 +222,9 @@ dX:= dX + windSpeed; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine); - + EX:= trunc(x); EY:= trunc(y); if Level = 1 then @@ -281,7 +281,7 @@ dX:= dX + windSpeed; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + 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); @@ -333,7 +333,7 @@ y:= y + dY; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or + 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); @@ -341,7 +341,7 @@ 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)); @@ -377,7 +377,7 @@ if not (r > 1) then begin x:= meX; - y:= meY; + y:= meY; dY:= -Vy; t:= TestTime; repeat @@ -385,15 +385,15 @@ y:= y + dY; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + 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 t < 50 then if Level = 1 then Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) else Score:= RateExplosion(Me, EX, EY, 101) - else + else Score:= BadTurn; if (valueResult < Score) and (Score > 0) then @@ -445,13 +445,13 @@ y:= y + dY; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or + 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 t < 50 then Score:= RateExplosion(Me, EX, EY, 41) - else + else Score:= BadTurn; if valueResult < Score then @@ -498,16 +498,16 @@ y:= y + dY; dY:= dY + cGravityf; dec(t) - until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 6)) or + 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 + if t < 50 then Score:= RateExplosion(Me, EX, EY, 200) + RateExplosion(Me, EX, EY + 120, 200) - else + else Score:= BadTurn; - + if valueResult < Score then begin ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); @@ -544,7 +544,7 @@ else Solve:= 0 end; - + function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; //const tDelta = 24; var Vx, Vy: real; @@ -579,7 +579,7 @@ dY:= dY + cGravityf; EX:= trunc(x); EY:= trunc(y); - until (((Me = CurrentHedgehog^.Gear) and TestColl(EX, EY, 4)) or + 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 @@ -633,16 +633,16 @@ y:= y + vY; rx:= trunc(x); ry:= trunc(y); - if ((Me = CurrentHedgehog^.Gear) and TestColl(rx, ry, 2)) or + 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 + + if valueResult = 0 then valueResult:= 1024 - Metric(Targ.X, Targ.Y, rx, ry) div 64 - else + else dec(valueResult, Level * 4000); // 27/20 is reuse bonus exit(valueResult * 27 div 20) @@ -748,7 +748,7 @@ fallDmg:= TraceShoveFall(Targ.X, Targ.Y, vX * 0.00166 * dmg, vY * 0.00166 * dmg); if fallDmg < 0 then TestSniperRifle:= BadTurn - else + else TestSniperRifle:= Max(0, trunc((dmg + fallDmg) * dmgMod) * 1024) end else @@ -787,13 +787,13 @@ , 32, 30, 115 , dx, -dy, trackFall); if (v1 > valueResult) or (v2 > valueResult) then - if (v2 > v1) + 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 + else begin ap.Angle:= -a; valueResult:= v1 @@ -801,7 +801,7 @@ a:= a - 15 - random(cMaxAngle div 16) end; - + if valueResult <= 0 then valueResult:= BadTurn; @@ -847,18 +847,18 @@ , 19, 30, 40 , 0.45, -0.9, trackFall); - if (v2 > v1) + 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 + else begin ap.Angle:= -1; valueResult:= v1 end; - + if valueResult <= 0 then valueResult:= BadTurn; @@ -882,8 +882,8 @@ 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 + {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 @@ -901,18 +901,18 @@ , 30, 30, 25 , 1, -0.8, trackFall); - if (v2 > v1) + 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 + else begin ap.Angle:= -1; valueResult:= v1 end; - + if valueResult <= 0 then valueResult:= BadTurn else @@ -931,13 +931,13 @@ ap.Time:= 0; ap.Power:= 1; - if Level = 1 then + if Level = 1 then trackFall:= afTrackFall else if Level = 2 then trackFall:= 0 else exit(BadTurn); - + valueResult:= 0; v:= 0; @@ -958,16 +958,16 @@ ap.Angle:= DxDy2AttackAnglef(dx, -dy) end; - + if dx >= 0 then cx:= 0.45 else cx:= -0.45; for i:= 0 to 512 div step - 2 do begin - valueResult:= valueResult + + valueResult:= valueResult + RateShove(trunc(x), trunc(y) , 30, 30, 25 , cx, -0.9, trackFall or afSetSkip); - + x:= x + dx; y:= y + dy; end; @@ -982,7 +982,7 @@ for i:= 1 to 512 div step - 2 do begin y:= y + dy; - v:= v + + v:= v + RateShove(tx, trunc(y) , 30, 30, 25 , -cx, -0.9, trackFall or afSetSkip); @@ -1015,7 +1015,7 @@ ap.Time:= 0; ap.Power:= 1; ap.Angle:= 0; - + rate:= RateHammer(Me); if rate = 0 then rate:= BadTurn; @@ -1106,7 +1106,7 @@ 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 @@ -1125,7 +1125,7 @@ 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 ap.AttackPutX := bonuses.ar[i].X; @@ -1147,7 +1147,7 @@ begin cakeStep(Gear); v:= RateExplosion(Me, hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg * 2, afTrackFall); - if v > ap.Power then + if v > ap.Power then begin ap.ExplX:= hwRound(Gear^.X); ap.ExplY:= hwRound(Gear^.Y); diff -r d24257910f8d -r aaefa587e277 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uChat.pas Tue Dec 25 04:45:22 2012 +0100 @@ -41,6 +41,7 @@ Width: LongInt; s: shortstring; end; + TChatCmd = (quit, pause, finish, fullscreen); var Strs: array[0 .. MaxStrIndex] of TChatLine; MStrs: array[0 .. MaxStrIndex] of shortstring; @@ -52,15 +53,25 @@ ChatReady: boolean; showAll: boolean; -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] - (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow] - (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red] - (r:$00; g:$FF; b:$FF; unused:$FF) // input line [Light Blue] - ); +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] + (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow] + (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red] + (r:$00; g:$FF; b:$FF; unused:$FF) // input line [Light Blue] + ); + ChatCommandz: array [TChatCmd] of record + ChatCmd: string[31]; + ProcedureCallChatCmd: string[31]; + end = ( + (ChatCmd: '/quit'; ProcedureCallChatCmd: 'halt'), + (ChatCmd: '/pause'; ProcedureCallChatCmd: 'pause'), + (ChatCmd: '/finish'; ProcedureCallChatCmd: 'finish'), + (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr') + ); procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); var strSurface, resSurface: PSDL_Surface; @@ -181,7 +192,7 @@ i:= MaxStrIndex else dec(i); - + inc(cnt); inc(t) end; @@ -197,6 +208,7 @@ procedure AcceptChatString(s: shortstring); var i: TWave; + j: TChatCmd; c, t: LongInt; x: byte; begin @@ -204,13 +216,13 @@ 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 (not CurrentTeam^.ExtDriven) and (x <> 0) then for c:= 0 to Pred(TeamsCount) do if (TeamsArray[c] = CurrentTeam) then @@ -267,6 +279,13 @@ ParseCommand('/taunt ' + char(i), true); exit end; + + for j:= Low(TChatCmd) to High(TChatCmd) do + if (s = ChatCommandz[j].ChatCmd) then + begin + ParseCommand(ChatCommandz[j].ProcedureCallChatCmd, true); + exit + end; end else ParseCommand('/say ' + s, true); diff -r d24257910f8d -r aaefa587e277 hedgewars/uCommandHandlers.pas --- a/hedgewars/uCommandHandlers.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uCommandHandlers.pas Tue Dec 25 04:45:22 2012 +0100 @@ -30,11 +30,13 @@ {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF}; var prevGState: TGameState = gsConfirm; + 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); procedure chGenCmd(var s: shortstring); begin case s[1] of - 'R': if ReadyTimeLeft > 1 then + 'R': if ReadyTimeLeft > 1 then begin ReadyTimeLeft:= 1; if not isExternalSource then @@ -479,7 +481,7 @@ with CurrentHedgehog^.Gear^ do begin Message:= Message or (gmSlot and InputMask); - MsgParam:= slot; + MsgParam:= slot; ScriptCall('onSlot', MsgParam); end end; @@ -516,7 +518,7 @@ with CurrentHedgehog^.Gear^ do begin Message:= Message or (gmAnimate and InputMask); - MsgParam:= byte(s[1]) ; + MsgParam:= byte(s[1]) ; ScriptCall('onTaunt', MsgParam); end end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uConsts.pas Tue Dec 25 04:45:22 2012 +0100 @@ -27,8 +27,6 @@ const sfMax = 1000; - cDefaultParamNum = 17; - cVideorecParamNum = cDefaultParamNum + 7; // message constants errmsgCreateSurface = 'Error creating SDL surface'; @@ -92,7 +90,7 @@ // lfObject and lfBasic are only to be different *graphically* in all other ways they should be treated the same lfBasic = $8000; // white lfIndestructible = $4000; // red - lfObject = $2000; + lfObject = $2000; lfDamaged = $1000; // lfIce = $0800; // blue lfBouncy = $0400; // green @@ -112,9 +110,7 @@ GL_TEXTURE_PRIORITY = $8066; {$ENDIF} - cSendCursorPosTime : LongWord = 50; cVisibleWater : LongInt = 128; - cCursorEdgesDist : LongInt = 100; cTeamHealthWidth : LongInt = 128; cifRandomize = $00000001; @@ -122,8 +118,6 @@ cifMap = $00000002; // either theme or map (or map+theme) cifAllInited = cifRandomize or cifTheme or cifMap; - cTransparentColor: Longword = $00000000; - RGB_LUMINANCE_RED = 0.212671; RGB_LUMINANCE_GREEN = 0.715160; RGB_LUMINANCE_BLUE = 0.072169; @@ -131,18 +125,14 @@ cMaxTeams = 8; cMaxHHIndex = 7; cMaxHHs = 48; - cMaxSpawnPoints = 1024; cMaxEdgePoints = 16384; cHHRadius = 9; cHHStepTicks = 29; - cUsualZ = 500; - cSmokeZ = 499; cHHZ = 1000; cCurrHHZ = Succ(cHHZ); - cOnHHZ = 2000; cBarrelHealth = 60; cShotgunRadius = 22; @@ -152,18 +142,11 @@ cKeyMaxIndex = 1600; 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; - cSendEmptyPacketTime = 1000; - trigTurns = $80000001; - // game flags gfAny = $FFFFFFFF; gfOneClanMode = $00000001; // used in trainings @@ -242,11 +225,11 @@ cMaxSlotIndex = 9; cMaxSlotAmmoIndex = 5; - + // ai hints aihUsualProcessing = $00000000; aihDoesntMatter = $00000001; - + // ammo properties ammoprop_Timerable = $00000001; ammoprop_Power = $00000002; @@ -262,7 +245,7 @@ ammoprop_Utility = $00001000; ammoprop_Effect = $00002000; ammoprop_SetBounce = $00004000; - ammoprop_NeedUpDown = $00008000;//Used by TouchInterface to show or hide up/down widgets + ammoprop_NeedUpDown = $00008000;//Used by TouchInterface to show or hide up/down widgets ammoprop_OscAim = $00010000; ammoprop_NoMoveAfter = $00020000; ammoprop_Track = $00040000; @@ -290,40 +273,8 @@ NoPointX = Low(LongInt); cTargetPointRef : TPoint = (X: NoPointX; Y: 0); - // hog tag mask - htNone = $00; - htTeamName = $01; - htName = $02; - htHealth = $04; - htTransparent = $08; - - AMAnimDuration = 200; - AMHidden = 0;//AMState values - AMShowingUp = 1; - AMShowing = 2; - AMHiding = 3; + kSystemSoundID_Vibrate = $00000FFF; - 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 d24257910f8d -r aaefa587e277 hedgewars/uCursor.pas --- a/hedgewars/uCursor.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uCursor.pas Tue Dec 25 04:45:22 2012 +0100 @@ -3,6 +3,7 @@ interface procedure init; +procedure resetPosition; procedure updatePosition; implementation @@ -15,6 +16,11 @@ procedure init; begin + resetPosition(); +end; + +procedure resetPosition; +begin SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2); end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGame.pas Tue Dec 25 04:45:22 2012 +0100 @@ -26,7 +26,7 @@ //////////////////// implementation //////////////////// -uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uMobile, +uses uInputHandler, uTeams, uIO, uAI, uGears, uSound, uVisualGears, uTypes, uVariables, uCommands, uConsts {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF}; @@ -48,7 +48,7 @@ else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; - if (GameType = gmtDemo) then + if (GameType = gmtDemo) then if isSpeed then begin i:= RealTicks-SpeedStart; @@ -96,7 +96,9 @@ AddVisualGear(0, 0, vgtTeamHealthSorter); AddVisualGear(0, 0, vgtSmoothWindBar); {$IFDEF IPHONEOS}InitIPC;{$ENDIF} - uMobile.SaveLoadingEnded(); + with mobileRecord do + if SaveLoadingEnded <> nil then + SaveLoadingEnded(); end; end else ProcessGears diff -r d24257910f8d -r aaefa587e277 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGears.pas Tue Dec 25 04:45:22 2012 +0100 @@ -56,7 +56,7 @@ implementation uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, - uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables, + uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uVariables, uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture, uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope; @@ -172,7 +172,7 @@ dec(Gear^.Hedgehog^.InitialHealth, 5) end end; - if tmp > 0 then + if tmp > 0 then begin inc(Gear^.Damage, min(tmp, max(0,Gear^.Health - 1 - Gear^.Damage))); HHHurt(Gear^.Hedgehog, dsPoison); @@ -212,7 +212,7 @@ DeleteGear(curHandledGear) else begin - if curHandledGear^.Message and gmRemoveFromList <> 0 then + if curHandledGear^.Message and gmRemoveFromList <> 0 then begin 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 @@ -246,13 +246,13 @@ if delay = 0 then inc(step) end; - + stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; - + stSweep: if SweepDirty then begin @@ -261,7 +261,7 @@ end else inc(step); - + stTurnReact: begin if (not bBetweenTurns) and (not isInMultiShoot) then @@ -272,7 +272,7 @@ else inc(step, 2); end; - + stAfterDelay: begin if delay = 0 then @@ -315,12 +315,12 @@ if cHealthDecrease <> 0 then begin 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); @@ -530,7 +530,7 @@ end; t:= t^.NextGear end; - + if ((GameFlags and gfResetWeps) <> 0) and (not PlacingHogs) then ResetWeapons; @@ -677,8 +677,8 @@ gtKnife, gtCase, gtTarget, - gtExplosives, - gtStructure: begin + gtExplosives: begin//, +// gtStructure: begin //addFileLog('ShotgunShot radius: ' + inttostr(Gear^.Radius) + ', t^.Radius = ' + inttostr(t^.Radius) + ', distance = ' + inttostr(dist) + ', dmg = ' + inttostr(dmg)); dmg:= 0; r:= Gear^.Radius + t^.Radius; @@ -760,7 +760,7 @@ if (Gear^.State and gstNoDamage) = 0 then begin - if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then + if (Ammo^.Kind = gtDEagleShot) or (Ammo^.Kind = gtSniperRifleShot) then begin VGear := AddVisualGear(hwround(Ammo^.X), hwround(Ammo^.Y), vgtBulletHit); if VGear <> nil then @@ -777,8 +777,8 @@ gtKnife, gtTarget, gtCase, - gtExplosives, - gtStructure: + gtExplosives: //, + //gtStructure: begin if (Ammo^.Kind = gtDrill) then begin @@ -810,7 +810,7 @@ end else Gear^.State:= Gear^.State or gstWinner; - if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then + 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)); @@ -906,10 +906,6 @@ inc(Count) end; end; - // unC0Rr, while it is true user can watch value on map screen, IMO this (and check above) should be enforced in UI - // - is there a good place to put values for the different widgets to check? Right now they are kind of disconnected. - //it would be nice if divide teams, forts mode and hh per map could all be checked by the team widget, or maybe disable start button - TryDo(Count <= MaxHedgehogs, 'Too many hedgehogs for this map! (max # is ' + inttostr(MaxHedgehogs) + ')', true); while (Count > 0) do begin i:= GetRandom(Count); @@ -938,9 +934,9 @@ s:= 0; SetLength(GearsNearArray, s); t := GearsList; - while t <> nil do + while t <> nil do begin - if (t^.Kind = Kind) + if (t^.Kind = Kind) and ((X - t^.X)*(X - t^.X) + (Y - t^.Y)*(Y-t^.Y) < int2hwFloat(r)) then begin inc(s); @@ -1032,7 +1028,7 @@ FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0); cCaseFactor := 0; FollowGear^.Pos := posCaseDummy; - + if explode then FollowGear^.Pos := FollowGear^.Pos + posCaseExplode; if poison then @@ -1271,7 +1267,7 @@ // if team matches current hedgehog team, default to current hedgehog if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then hh:= CurrentHedgehog - else + else begin // otherwise use the first living hog or the hog amongs the remaining ones indicated by i j:= 0; @@ -1287,7 +1283,7 @@ inc(j) end end; - if hh <> nil then + if hh <> nil then begin Gear:= AddVisualGear(0, 0, vgtSpeechBubble); if Gear <> nil then @@ -1367,7 +1363,7 @@ @doStepNapalmBomb, @doStepSnowball, @doStepSnowflake, - @doStepStructure, + //@doStepStructure, @doStepLandGun, @doStepTardis, @doStepIceGun, diff -r d24257910f8d -r aaefa587e277 hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGearsHedgehog.pas Tue Dec 25 04:45:22 2012 +0100 @@ -23,17 +23,17 @@ uses uTypes; procedure doStepHedgehog(Gear: PGear); -procedure AfterAttack; -procedure HedgehogStep(Gear: PGear); -procedure doStepHedgehogMoving(Gear: PGear); -procedure HedgehogChAngle(HHGear: 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, +uses uConsts, uVariables, uFloat, uAmmos, uSound, uCaptions, uCommands, uLocale, uUtils, uVisualGears, uStats, uIO, uScript, - uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, + uGearsList, uGears, uCollisions, uRandom, uStore, uTeams, uGearsUtils; var GHStepTicks: LongWord = 0; @@ -66,7 +66,7 @@ MultiShootAttacks:= 0; HHGear^.Message:= HHGear^.Message and (not (gmLJump or gmHJump)); - + if Ammoz[CurAmmoType].Slot = slot then begin i:= 0; @@ -81,8 +81,8 @@ end; until (i = 1) or ((Ammo^[slot, ammoidx].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, ammoidx].AmmoType].SkipTurns)) - - end + + end else begin i:= 0; @@ -105,7 +105,7 @@ LoadHedgehogHat(HHGear^.Hedgehog^, Hat); end; // Try again in the next slot - if CurAmmoType = prevAmmo then + if CurAmmoType = prevAmmo then begin if slot >= cMaxSlotIndex then slot:= 0 else inc(slot); HHGear^.MsgParam:= slot; @@ -204,7 +204,7 @@ if ((State and gstHHDriven) <> 0) and ((State and (gstAttacked or gstHHChooseTarget)) = 0) and (((State and gstMoving) = 0) or (Power > 0) or (CurAmmoType = amTeleport) - or + 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)) @@ -250,7 +250,7 @@ and ((Gear^.Message and gmLJump) <> 0) and ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then begin - newDx:= dX; + newDx:= dX; newDy:= dY; altUse:= true end @@ -278,15 +278,15 @@ 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 + amKnife: begin newGear:= AddGear(hwRound(lx), hwRound(ly), gtKnife, 0, xx*Power/cPowerDivisor, yy*Power/cPowerDivisor, 0); - newGear^.State:= newGear^.State or gstMoving; + 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, + newGear:= AddGear(hwRound(lx + xx * cHHRadius), hwRound(ly + yy * cHHRadius), gtPortal, 0, xx * _0_6, yy * _0_6, // set selected color CurWeapon^.Pos); end; @@ -346,7 +346,7 @@ cGravity:= cMaxWindSpeed; cGravityf:= 0.00025 end; - amExtraDamage: begin + amExtraDamage: begin PlaySound(sndHellishImpact4); cDamageModifier:= _1_5 end; @@ -374,7 +374,7 @@ 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); + //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; @@ -383,11 +383,11 @@ newGear^.dX:= newDx / newGear^.Density; newGear^.dY:= newDY / newGear^.Density end; - + case CurAmmoType of - amGrenade, amMolotov, - amClusterBomb, amGasBomb, - amBazooka, amSnowball, + amGrenade, amMolotov, + amClusterBomb, amGasBomb, + amBazooka, amSnowball, amBee, amSMine, amMortar, amWatermelon, amHellishBomb, amDrill: FollowGear:= newGear; @@ -404,11 +404,11 @@ amSeduction, amBallgun, amJetpack, amBirdy, amFlamethrower, amLandGun, - amResurrector, amStructure, + 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 @@ -432,7 +432,7 @@ 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 +(* 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)*) @@ -468,7 +468,7 @@ AfterAttack; end end - else + else Message:= Message and (not gmAttack); end; TargetPoint.X := NoPointX; @@ -488,13 +488,13 @@ 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 @@ -509,7 +509,7 @@ TagTurnTimeLeft:= TurnTimeLeft; TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100; end; - if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) and (HHGear <> nil) then + 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^) @@ -537,7 +537,7 @@ dec(Gear^.Timer); if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) - end + end else if Gear^.Timer = 1 then begin Gear^.State:= Gear^.State or gstNoDamage; @@ -545,7 +545,7 @@ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; DeleteGear(Gear); SetAllToActive - end + end else // Gear^.Timer = 0 begin AllInactive:= false; @@ -598,7 +598,7 @@ if cnt <> 0 then AddAmmo(HH, ammo, cnt) else AddAmmo(HH, ammo); - if (not (HH.Team^.ExtDriven + if (not (HH.Team^.ExtDriven or (HH.BotLevel > 0))) or (HH.Team^.Clan^.ClanIndex = LocalClan) or (GameType = gmtDemo) then @@ -636,7 +636,7 @@ posCaseUtility, posCaseAmmo: begin PlaySound(sndShotgunReload); - if Gear^.AmmoType <> amNothing then + if Gear^.AmmoType <> amNothing then begin AddPickup(HH^.Hedgehog^, Gear^.AmmoType, Gear^.Power, hwRound(Gear^.X), hwRound(Gear^.Y)); end @@ -644,7 +644,7 @@ begin // Add spawning here... AddRandomness(GameTicks); - + gi := GearsList; while gi <> nil do begin @@ -759,7 +759,7 @@ if (Gear^.Message and gmLeft )<>0 then Gear^.dX:= -cLittle else if (Gear^.Message and gmRight )<>0 then - Gear^.dX:= cLittle + Gear^.dX:= cLittle else exit; StepSoundTimer:= cHHStepTicks; @@ -826,7 +826,7 @@ Gear^.dY:= _0; Gear^.State:= Gear^.State or gstMoving; if (CurrentHedgehog^.Gear = Gear) - and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then + and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then begin // TODO: why so aggressive at setting FollowGear when falling? FollowGear:= Gear; @@ -842,7 +842,7 @@ or ((Gear^.dY.QWordValue + Gear^.dX.QWordValue) > _0_55.QWordValue))) then Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density end - end + end else begin land:= TestCollisionYwithGear(Gear, 1); @@ -899,7 +899,7 @@ Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 - end + end else if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin @@ -963,7 +963,7 @@ // 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)) + if (not Gear^.dY.isNegative) and (not TestCollisionYKick(Gear, 1)) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then begin CheckHHDamage(Gear); @@ -1003,7 +1003,7 @@ if isInMultiShoot then HHGear^.Message:= 0; -if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then +if ((Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_Utility) <> 0) and isInMultiShoot then AllInactive:= true else if not isInMultiShoot then AllInactive:= false; @@ -1057,7 +1057,7 @@ 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 +else with Hedgehog^ do if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and ((HHGear^.Message and gmLJump) <> 0) @@ -1163,7 +1163,7 @@ begin ResurrectHedgehog(Gear); end - else + else begin Gear^.State:= (Gear^.State or gstHHDeath) and (not gstAnimation); Gear^.doStep:= @doStepHedgehogDead; @@ -1208,9 +1208,9 @@ procedure doStepHedgehog(Gear: PGear); (* var x,y,tx,ty: LongInt; - tdX, tdY, slope: hwFloat; + tdX, tdY, slope: hwFloat; land: Word; *) -var slope: hwFloat; +var slope: hwFloat; begin CheckSum:= CheckSum xor Gear^.Hedgehog^.BotLevel; if (Gear^.Message and gmDestroy) <> 0 then diff -r d24257910f8d -r aaefa587e277 hedgewars/uGearsList.pas --- a/hedgewars/uGearsList.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGearsList.pas Tue Dec 25 04:45:22 2012 +0100 @@ -35,8 +35,83 @@ uTextures, uScript, uRenderUtils, uAI, uCollisions, uGearsRender, uGearsUtils, uDebug; +const + GearKindAmmoTypeMap : array [TGearType] of TAmmoType = ( +(* gtFlame *) amNothing +(* gtHedgehog *) , amNothing +(* gtMine *) , amMine +(* gtCase *) , amNothing +(* gtExplosives *) , amNothing +(* gtGrenade *) , amGrenade +(* gtShell *) , amBazooka +(* gtGrave *) , amNothing +(* gtBee *) , amBee +(* gtShotgunShot *) , amShotgun +(* gtPickHammer *) , amPickHammer +(* gtRope *) , amRope +(* gtDEagleShot *) , amDEagle +(* gtDynamite *) , amDynamite +(* gtClusterBomb *) , amClusterBomb +(* gtCluster *) , amClusterBomb +(* gtShover *) , amBaseballBat // Shover is only used for baseball bat right now +(* gtFirePunch *) , amFirePunch +(* gtATStartGame *) , amNothing +(* gtATFinishGame *) , amNothing +(* gtParachute *) , amParachute +(* gtAirAttack *) , amAirAttack +(* gtAirBomb *) , amAirAttack +(* gtBlowTorch *) , amBlowTorch +(* gtGirder *) , amGirder +(* gtTeleport *) , amTeleport +(* gtSwitcher *) , amSwitch +(* gtTarget *) , amNothing +(* gtMortar *) , amMortar +(* gtWhip *) , amWhip +(* gtKamikaze *) , amKamikaze +(* gtCake *) , amCake +(* gtSeduction *) , amSeduction +(* gtWatermelon *) , amWatermelon +(* gtMelonPiece *) , amWatermelon +(* gtHellishBomb *) , amHellishBomb +(* gtWaterUp *) , amNothing +(* gtDrill *) , amDrill +(* gtBallGun *) , amBallgun +(* gtBall *) , amBallgun +(* gtRCPlane *) , amRCPlane +(*gtSniperRifleShot *) , amSniperRifle +(* gtJetpack *) , amJetpack +(* gtMolotov *) , amMolotov +(* gtBirdy *) , amBirdy +(* gtEgg *) , amBirdy +(* gtPortal *) , amPortalGun +(* gtPiano *) , amPiano +(* gtGasBomb *) , amGasBomb +(* gtSineGunShot *) , amSineGun +(* gtFlamethrower *) , amFlamethrower +(* gtSMine *) , amSMine +(* gtPoisonCloud *) , amNothing +(* gtHammer *) , amHammer +(* gtHammerHit *) , amHammer +(* gtResurrector *) , amResurrector +(* gtPoisonCloud *) , amNothing +(* gtSnowball *) , amSnowball +(* gtFlake *) , amNothing +//(* 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 GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless +const + cUsualZ = 500; + cOnHHZ = 2000; + procedure InsertGearToList(Gear: PGear); var tmp, ptmp: PGear; begin @@ -86,7 +161,7 @@ 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); @@ -108,7 +183,7 @@ gear^.AmmoType:= GearKindAmmoTypeMap[Kind]; gear^.CollisionMask:= $FFFF; -if CurrentHedgehog <> nil then +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 @@ -119,7 +194,7 @@ gear^.Z:= cHHZ+1 else gear^.Z:= cUsualZ; - + case Kind of gtGrenade, gtClusterBomb, @@ -463,6 +538,7 @@ gear^.Radius:= 5; gear^.Density:= _1_5; end; +{ gtStructure: begin gear^.Elasticity:= _0_55; gear^.Friction:= _0_995; @@ -473,6 +549,7 @@ gear^.Tag:= TotalRounds + 3; gear^.Pos:= 1; end; +} gtIceGun: gear^.Health:= 1000; gtGenericFaller:begin gear^.AdvBounce:= 1; @@ -570,7 +647,7 @@ 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 + with CurrentHedgehog^ do begin inc(Team^.stats.AIKills); FreeTexture(Team^.AIKillsTex); diff -r d24257910f8d -r aaefa587e277 hedgewars/uGearsRender.pas --- a/hedgewars/uGearsRender.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGearsRender.pas Tue Dec 25 04:45:22 2012 +0100 @@ -24,17 +24,17 @@ uses uTypes, uConsts, GLunit, uFloat, SDLh; type - Tar = record - X, Y: hwFloat; - dLen: hwFloat; - b : boolean; - end; + Tar = record + X, Y: hwFloat; + dLen: hwFloat; + b : boolean; + end; TRopePoints = record - Count : Longword; - HookAngle : GLfloat; - ar : array[0..MAXROPEPOINTS] of Tar; - rounded : array[0..MAXROPEPOINTS + 2] of TVertex2f; - end; + Count : Longword; + HookAngle : GLfloat; + ar : array[0..MAXROPEPOINTS] of Tar; + rounded : array[0..MAXROPEPOINTS + 2] of TVertex2f; + end; procedure RenderGear(Gear: PGear; x, y: LongInt); var RopePoints: TRopePoints; @@ -42,6 +42,14 @@ implementation uses uRender, uUtils, uVariables, uAmmos, Math, uVisualGears; +const + // hog tag mask + htNone = $00; + htTeamName = $01; + htName = $02; + htHealth = $04; + htTransparent = $08; + procedure DrawRopeLinesRQ(Gear: PGear); begin with RopePoints do @@ -85,7 +93,7 @@ if (X1 = X2) and (Y1 = Y2) then begin //OutError('WARNING: zero length rope line!', false); - DrawRopeLine := 0; + DrawRopeLine := 0; exit end; eX:= 0; @@ -103,7 +111,7 @@ end else sX:= dX; - if (dY > 0) then + if (dY > 0) then sY:= 1 else if (dY < 0) then @@ -111,7 +119,7 @@ sY:= -1; dY:= -dY end - else + else sY:= dY; if (dX > dY) then @@ -344,8 +352,8 @@ // draw crosshair CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle)); CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle)); - - + + DrawTextureRotated(HH^.Team^.CrosshairTex, 12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0, sign * (Gear^.Angle * 180.0) / cMaxAngle); @@ -620,13 +628,13 @@ 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); @@ -642,7 +650,7 @@ amKnife: DrawSpriteRotatedF(sprHandKnife, hx, hy, 0, sign, aangle); amSeduction: begin DrawSpriteRotated(sprHandSeduction, hx, hy, sign, aangle); - DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA); + 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); @@ -935,8 +943,8 @@ if Gear^.Target.X <> NoPointX then if Gear^.AmmoType = amBee then 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) + 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 @@ -946,7 +954,7 @@ 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 DrawSpriteRotatedF(sprMolotov, x, y, (RealTicks div 125) mod 8, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX)) else DrawSprite(sprMolotov, x, y, 8); @@ -990,20 +998,20 @@ 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 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 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 @@ -1087,7 +1095,7 @@ 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); @@ -1155,9 +1163,9 @@ gtNapalmBomb: DrawSpriteRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0 then begin - Tint((ExplosionBorderColor shr RShift) and $FF, - (ExplosionBorderColor shr GShift) and $FF, - (ExplosionBorderColor 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 DrawTextureRotatedF(SpritesData[sprSnowDust].Texture, 1, 0, 0, x, y, 0, 1, 8, 8, Gear^.DirAngle); @@ -1182,12 +1190,12 @@ if Gear^.FlightTime > 0 then Tint($FF, $FF, $FF, $FF); end; - gtStructure: DrawSprite(sprTarget, x - 16, y - 16, 0); + //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 + 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 diff -r d24257910f8d -r aaefa587e277 hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uGearsUtils.pas Tue Dec 25 04:45:22 2012 +0100 @@ -23,7 +23,7 @@ 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); +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); @@ -106,8 +106,8 @@ gtTarget, gtFlame, gtKnife, - gtExplosives, - gtStructure: begin + gtExplosives: begin //, + //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; @@ -233,7 +233,7 @@ end; end end; - if ((GameFlags and gfKarma) <> 0) and + 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 @@ -241,13 +241,13 @@ CurrentHedgehog^.Gear^.LastDamage := CurrentHedgehog; spawnHealthTagForHH(CurrentHedgehog^.Gear, tmpDmg); end; - uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); + uStats.HedgehogDamaged(Gear, AttackerHog, Damage, false); end; - end - else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure + end else + //else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure Gear^.Hedgehog:= AttackerHog; inc(Gear^.Damage, Damage); - + ScriptCall('onGearDamage', Gear^.UID, Damage); end; @@ -260,7 +260,7 @@ AllInactive:= false; HHGear^.Active:= true; end; - + procedure HHHurt(Hedgehog: PHedgehog; Source: TDamageSource); begin if (Source = dsFall) or (Source = dsExplosion) then @@ -284,7 +284,7 @@ end; procedure CheckHHDamage(Gear: PGear); -var +var dmg: Longword; i: LongWord; particle: PVisualGear; @@ -320,7 +320,7 @@ procedure CalcRotationDirAngle(Gear: PGear); -var +var dAngle: real; begin // Frac/Round to be kind to JS as of 2012-08-27 where there is yet no int64/uint64 @@ -338,7 +338,7 @@ end; function CheckGearDrowning(Gear: PGear): boolean; -var +var skipSpeed, skipAngle, skipDecay: hwFloat; i, maxDrops, X, Y: LongInt; vdX, vdY: real; @@ -401,14 +401,14 @@ else Gear^.doStep := @doStepDrowningGear; if Gear^.Kind = gtFlake then - exit // skip splashes + 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 + else if Gear^.Density * Gear^.dY > _0_5 then PlaySound(sndSkip) else PlaySound(sndDroplet2); @@ -420,7 +420,7 @@ and (CurAmmoGear^.dY < _0_01)))) then begin splash:= AddVisualGear(X, cWaterLine, vgtSplash); - if splash <> nil then + if splash <> nil then with splash^ do begin Scale:= hwFloat2Float(Gear^.Density / _3 * Gear^.dY); @@ -443,12 +443,12 @@ dY := dY - vdY / 5; if splash <> nil then begin - if splash^.Scale > 1 then + 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 + else begin dX:= dX * splash^.Scale; dY:= dY * splash^.Scale @@ -482,7 +482,7 @@ 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 + with CurrentHedgehog^ do begin inc(Team^.stats.AIKills); FreeTexture(Team^.AIKillsTex); @@ -499,7 +499,7 @@ sparkles^.Tint:= tempTeam^.Clan^.Color shl 8 or $FF; //sparkles^.Angle:= random(360); end; - FindPlace(gear, false, 0, LAND_WIDTH, true); + FindPlace(gear, false, 0, LAND_WIDTH, true); if gear <> nil then begin AddVisualGear(hwRound(gear^.X), hwRound(gear^.Y), vgtExplosion); @@ -580,7 +580,7 @@ repeat inc(y, 2); until (y >= cWaterLine) or - ((not ignoreOverlap) and (CountNonZeroz(x, y, Gear^.Radius - 1, 1, $FFFF) = 0)) 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; @@ -588,8 +588,8 @@ 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)); + ((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) @@ -614,15 +614,15 @@ end; if cnt > 0 then - begin - temp := ar[GetRandom(cnt)]; + begin + temp := ar[GetRandom(cnt)]; with temp do begin ar2[cnt2].x:= x; ar2[cnt2].y:= y; inc(cnt2) - end - end + end + end until (x + Delta > Right); dec(Delta, 60) @@ -690,7 +690,7 @@ if TestCollisionX(Gear, hwSign(Gear^.dX)) or TestCollisionY(Gear, hwSign(Gear^.dY)) then Gear^.State := Gear^.State or gstCollision - else + else Gear^.State := Gear^.State and (not gstCollision) end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uIO.pas Tue Dec 25 04:45:22 2012 +0100 @@ -41,6 +41,9 @@ implementation uses uConsole, uConsts, uVariables, uCommands, uUtils, uDebug; +const + cSendEmptyPacketTime = 1000; + type PCmd = ^TCmd; TCmd = packed record Next: PCmd; @@ -122,6 +125,7 @@ 'E': OutError(copy(s, 2, Length(s) - 1), true); 'W': OutError(copy(s, 2, Length(s) - 1), false); 'M': ParseCommand('landcheck ' + s, true); + 'o': if fastUntilLag then ParseCommand('forcequit', true); 'T': case s[2] of 'L': GameType:= gmtLocal; 'D': GameType:= gmtDemo; @@ -194,7 +198,7 @@ while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do begin ParseIPCCommand(copy(ss, 2, byte(ss[1]))); - Delete(ss, 1, Succ(byte(ss[1]))); + Delete(ss, 1, Succ(byte(ss[1]))); end end until i = 0; @@ -219,7 +223,7 @@ SendEmptyPacketTicks:= 0; 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); @@ -428,7 +432,7 @@ lastcmd:= nil; isPonged:= false; SocketString:= ''; - + hiTicks:= 0; SendEmptyPacketTicks:= 0; diff -r d24257910f8d -r aaefa587e277 hedgewars/uInputHandler.pas --- a/hedgewars/uInputHandler.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uInputHandler.pas Tue Dec 25 04:45:22 2012 +0100 @@ -54,12 +54,22 @@ LALT = $0800; RALT = $1000; LCTRL = $2000; - RCTRL = $4000; + RCTRL = $4000; var tkbd: array[0..cKbdMaxIndex] of boolean; quitKeyCode, closeKeyCode: Byte; KeyNames: array [0..cKeyMaxIndex] of string[15]; CurrentBinds: TBinds; + ControllerNumControllers: Integer; + ControllerEnabled: Integer; + ControllerNumAxes: array[0..5] of Integer; + //ControllerNumBalls: array[0..5] of Integer; + ControllerNumHats: array[0..5] of Integer; + ControllerNumButtons: array[0..5] of Integer; + ControllerAxes: array[0..5] of array[0..19] of Integer; + //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; + ControllerHats: array[0..5] of array[0..19] of Byte; + ControllerButtons: array[0..5] of array[0..19] of Byte; function KeyNameToCode(name: shortstring): LongInt; inline; begin @@ -79,12 +89,12 @@ (* 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; + 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); @@ -100,7 +110,7 @@ SplitByChar(Modifier, mod_, ':');//remove the first mod: part Modifier:= mod_; for i:= 0 to ModifierCount do - begin + begin mod_:= ''; SplitByChar(Modifier, mod_, ':'); if (Modifier = 'lshift') then code:= code or LSHIFT; @@ -221,7 +231,7 @@ s:= shortstring(sdl_getkeyname(i)); //WriteLnToConsole('uInputHandler - ' + IntToStr(i) + ': ' + s + ' ' + IntToStr(cKeyMaxIndex)); if s = 'unknown key' then KeyNames[i]:= '' - else + else begin for t:= 1 to Length(s) do if s[t] = ' ' then @@ -381,10 +391,10 @@ 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; diff -r d24257910f8d -r aaefa587e277 hedgewars/uLand.pas --- a/hedgewars/uLand.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uLand.pas Tue Dec 25 04:45:22 2012 +0100 @@ -37,7 +37,7 @@ procedure ResizeLand(width, height: LongWord); var potW, potH: LongInt; -begin +begin potW:= toPowerOf2(width); potH:= toPowerOf2(height); if (potW <> LAND_WIDTH) or (potH <> LAND_HEIGHT) then @@ -240,7 +240,7 @@ rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; 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)) @@ -340,7 +340,7 @@ SDL_FreeSurface(tmpsurf); for x:= leftX+2 to rightX-2 do for y:= topY+2 to LAND_HEIGHT-3 do - if (Land[y, x] = 0) and + if (Land[y, x] = 0) and (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or ((Land[y, x+1] = lfBasic) and ((Land[y-1,x] = lfBasic) or (Land[y+1,x] = lfBasic)))) then begin @@ -348,16 +348,16 @@ 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) end; @@ -372,25 +372,25 @@ ((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 - + 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) end; @@ -488,7 +488,7 @@ for x:= 0 to Pred(tmpsurf^.w) do begin // this an if instead of masking colours to avoid confusing map creators - if ((AMask and p^[x]) = 0) then + if ((AMask and p^[x]) = 0) then Land[cpY + y, cpX + x]:= 0 else if p^[x] = $FFFFFFFF then // white Land[cpY + y, cpX + x]:= lfObject @@ -524,8 +524,8 @@ procedure LoadMap; var tmpsurf : PSDL_Surface; - s : shortstring; - f : textfile; + s : shortstring; + f : textfile; mapName : shortstring = ''; begin @@ -556,7 +556,7 @@ LAND_HEIGHT - tmpsurf^.h, tmpsurf^.w, tmpsurf); - + SDL_FreeSurface(tmpsurf); LoadMask; @@ -601,7 +601,7 @@ begin map:= cPathz[ptMapCurrent] + '/map.png'; mask:= cPathz[ptMapCurrent] + '/mask.png'; - if (not(FileExists(map)) and FileExists(mask)) then + if (not(pfsExists(map)) and pfsExists(mask)) then begin maskOnly:= true; LoadMask; @@ -635,7 +635,7 @@ if Land[y, x] <> 0 then begin inc(c); - if c > 1000 then // avoid accidental triggering + if c > (LAND_WIDTH div 2) then // avoid accidental triggering begin hasBorder:= true; break; @@ -697,7 +697,7 @@ if (GameFlags and gfForts = 0) and (maskOnly or (cPathz[ptMapCurrent] = '')) then AddObjects - + else AddProgress(); @@ -753,7 +753,7 @@ rw:= rh*2; end; if rh < rw div 2 then rh:= rw * 2; - + ox:= (rw-LAND_WIDTH) div 2; oy:= rh-LAND_HEIGHT; @@ -769,7 +769,7 @@ cbit:= bit * 8; for yy:= y * lh to y * lh + 7 do for xx:= x * lw + cbit to x * lw + cbit + 7 do - if ((yy-oy) and LAND_HEIGHT_MASK = 0) and ((xx-ox) and LAND_WIDTH_MASK = 0) + 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 diff -r d24257910f8d -r aaefa587e277 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uLandObjects.pas Tue Dec 25 04:45:22 2012 +0100 @@ -37,6 +37,7 @@ const MaxRects = 512; MAXOBJECTRECTS = 16; MAXTHEMEOBJECTS = 32; + cThemeCFGFilename = 'theme.cfg'; type TRectsArray = array[0..MaxRects] of TSDL_Rect; PRectArray = ^TRectsArray; @@ -73,7 +74,7 @@ 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; @@ -103,7 +104,7 @@ LandPixels[cpY + y, cpX + x]:= p^[x]; end else - if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then + 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 @@ -202,7 +203,7 @@ 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; @@ -219,7 +220,7 @@ while rr.x < x2 do begin // 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 + if (Theme = 'Snow') or (Theme = 'Christmas') then BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce) else BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf); @@ -394,9 +395,9 @@ procedure CheckRect(Width, Height, x, y, w, h: LongWord); begin - if (x + w > Width) then + 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 + if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); end; @@ -494,7 +495,7 @@ c2.g:= t; c2.b:= t end; - ExplosionBorderColor:= (c2.r shl RShift) or (c2.g shl GShift) or (c2.b shl BShift) 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 diff -r d24257910f8d -r aaefa587e277 hedgewars/uLandOutline.pas --- a/hedgewars/uLandOutline.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uLandOutline.pas Tue Dec 25 04:45:22 2012 +0100 @@ -27,6 +27,9 @@ end end; +const + cMaxEdgePoints = 16384; + procedure Push(_xl, _xr, _y, _dir: LongInt); begin TryDo(Stack.Count <= 8192, 'FillLand: stack overflow', true); @@ -96,9 +99,9 @@ i:= 0; with pa do while i < LongInt(Count) - 1 do - if (ar[i + 1].X = NTPX) then + if (ar[i + 1].X = NTPX) then inc(i, 2) - else + else begin DrawLine(ar[i].x, ar[i].y, ar[i + 1].x, ar[i + 1].y, Color); inc(i) @@ -127,7 +130,7 @@ begin Vx:= _0; Vy:= _0 - end + end else begin d2:= _1 / d2; @@ -234,7 +237,7 @@ CheckIntersect:= false else if (c2 < 0) or (c2 > dm) then CheckIntersect:= false; - end + end else begin if (c1 > 0) or (c1 < dm) then diff -r d24257910f8d -r aaefa587e277 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uLocale.pas Tue Dec 25 04:45:22 2012 +0100 @@ -40,7 +40,7 @@ trevt_n: array[TEventId] of integer; procedure LoadLocale(FileName: shortstring); -var s: shortstring; +var s: ansistring; f: pfsFile; a, b, c: LongInt; first: array[TEventId] of boolean; @@ -58,7 +58,7 @@ begin while not pfsEof(f) do begin - pfsReadLn(f, s); + pfsReadLnA(f, s); if Length(s) = 0 then continue; if (s[1] < '0') or (s[1] > '9') then diff -r d24257910f8d -r aaefa587e277 hedgewars/uMobile.pas --- a/hedgewars/uMobile.pas Sun Dec 02 00:03:16 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -(* - * 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"} - -(* - * 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 - -function isPhone: Boolean; inline; -function getScreenDPI: Double; inline; -procedure performRumble; inline; - -procedure GameLoading; inline; -procedure GameLoaded; inline; -procedure SaveLoadingEnded; inline; - -implementation -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} - 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} -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; -{$IFDEF IPHONEOS}const kSystemSoundID_Vibrate = $00000FFF;{$ENDIF} -begin - // do not vibrate while synchronising a demo/save - if not fastUntilLag then - begin -{$IFDEF IPHONEOS} - AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); -{$ENDIF} - end; -end; - -procedure GameLoading; inline; -begin -{$IFDEF IPHONEOS} - startLoadingIndicator(); -{$ENDIF} -end; - -procedure GameLoaded; inline; -begin -{$IFDEF IPHONEOS} - stopLoadingIndicator(); -{$ENDIF} -end; - -procedure SaveLoadingEnded; inline; -begin -{$IFDEF IPHONEOS} - saveFinishedSynching(); -{$ENDIF} -end; - - -end. diff -r d24257910f8d -r aaefa587e277 hedgewars/uPhysFSLayer.pas --- a/hedgewars/uPhysFSLayer.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uPhysFSLayer.pas Tue Dec 25 04:45:22 2012 +0100 @@ -30,6 +30,7 @@ function pfsClose(f: PFSFile): boolean; procedure pfsReadLn(f: PFSFile; var s: shortstring); +procedure pfsReadLnA(f: PFSFile; var s: ansistring); function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; function pfsEOF(f: PFSFile): boolean; @@ -41,7 +42,7 @@ {$IFNDEF PAS2C} //apparently pas2c doesn't render the functions below if it finds 'implementation' first implementation -uses uUtils, uVariables; +uses uUtils, uVariables, sysutils; {$ENDIF} function PHYSFS_init(argv: PChar): LongInt; cdecl; external PhysfsLibName; @@ -109,6 +110,28 @@ end end; +procedure pfsReadLnA(f: PFSFile; var s: ansistring); +var c: char; + b: shortstring; +begin +s:= ''; +b[0]:= #0; + +while (PHYSFS_readBytes(f, @c, 1) = 1) and (c <> #10) do + if (c <> #13) then + begin + inc(b[0]); + b[byte(b[0])]:= c; + if b[0] = #255 then + begin + s:= s + b; + b[0]:= #0 + end + end; + +s:= s + b +end; + function pfsBlockRead(f: PFSFile; buf: pointer; size: Int64): Int64; var r: Int64; begin @@ -122,8 +145,16 @@ procedure initModule; var i: LongInt; + cPhysfsId: shortstring; begin - i:= PHYSFS_init(Str2PChar(ParamStr(0))); +{$IFDEF HWLIBRARY} + //TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html + cPhysfsId:= GetCurrentDir() + {$IFDEF DARWIN}'/Hedgewars.app/Contents/MacOS/' + {$ENDIF} ' hedgewars'; +{$ELSE} + cPhysfsId:= ParamStr(0); +{$ENDIF} + + i:= PHYSFS_init(Str2PChar(cPhysfsId)); AddFileLog('[PhysFS] init: ' + inttostr(i)); i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true); diff -r d24257910f8d -r aaefa587e277 hedgewars/uRender.pas --- a/hedgewars/uRender.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uRender.pas Tue Dec 25 04:45:22 2012 +0100 @@ -55,6 +55,12 @@ implementation uses uVariables; +{$IFDEF USE_TOUCH_INTERFACE} +const + FADE_ANIM_TIME = 500; + MOVE_ANIM_TIME = 500; +{$ENDIF} + var LastTint: LongWord = 0; procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); @@ -120,7 +126,7 @@ } procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); -var +var rr: TSDL_Rect; VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; //VertexBuffer, TextureBuffer: TVertexRect; @@ -479,9 +485,9 @@ SetVertexPointer(@VertexBuffer[0], Length(VertexBuffer)); glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); Tint($FF, $FF, $FF, $FF); - + glPopMatrix; - + glEnable(GL_TEXTURE_2D); {$ELSE} @@ -550,14 +556,14 @@ end; -procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); +procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); begin Tint(r, g, b, a); - DrawCircle(X, Y, Radius, Width); + DrawCircle(X, Y, Radius, Width); Tint($FF, $FF, $FF, $FF); end; -procedure DrawCircle(X, Y, Radius, Width: LongInt); +procedure DrawCircle(X, Y, Radius, Width: LongInt); var i: LongInt; CircleVertex: array [0..59] of TVertex2f; @@ -670,9 +676,9 @@ if RealTicks > (fadeAnimStart + FADE_ANIM_TIME) then fadeAnimStart:= 0 else - if show then + if show then alpha:= Byte(trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)) - else + else alpha:= Byte($FF - trunc((RealTicks - fadeAnimStart)/FADE_ANIM_TIME * $FF)); end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uScript.pas Tue Dec 25 04:45:22 2012 +0100 @@ -80,7 +80,7 @@ uTextures, uLandGraphics, SDLh, - SysUtils, + SysUtils, uIO, uPhysFSLayer ; @@ -111,7 +111,7 @@ function lc_band(L: PLua_State): LongInt; Cdecl; begin - if lua_gettop(L) <> 2 then + if lua_gettop(L) <> 2 then begin LuaError('Lua: Wrong number of parameters passed to band!'); lua_pushnil(L); @@ -123,7 +123,7 @@ function lc_bor(L: PLua_State): LongInt; Cdecl; begin - if lua_gettop(L) <> 2 then + if lua_gettop(L) <> 2 then begin LuaError('Lua: Wrong number of parameters passed to bor!'); lua_pushnil(L); @@ -135,7 +135,7 @@ function lc_bnot(L: PLua_State): LongInt; Cdecl; begin - if lua_gettop(L) <> 1 then + if lua_gettop(L) <> 1 then begin LuaError('Lua: Wrong number of parameters passed to bnot!'); lua_pushnil(L); @@ -147,7 +147,7 @@ function lc_div(L: PLua_State): LongInt; Cdecl; begin - if lua_gettop(L) <> 2 then + if lua_gettop(L) <> 2 then begin LuaError('Lua: Wrong number of parameters passed to div!'); lua_pushnil(L); @@ -273,7 +273,7 @@ HealthCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); lua_pushinteger(L, gear^.uid); end; - lc_spawnfakehealthcrate := 1; + lc_spawnfakehealthcrate := 1; end; function lc_spawnfakeammocrate(L: PLua_State): LongInt; Cdecl; @@ -302,7 +302,7 @@ lua_pushnil(L); end else - begin + begin gear := SpawnFakeCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2), UtilityCrate, lua_toboolean(L, 3), lua_toboolean(L, 4)); lua_pushinteger(L, gear^.uid); @@ -331,7 +331,7 @@ else lua_pushnil(L); end; - lc_spawnhealthcrate := 1; + lc_spawnhealthcrate := 1; end; function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl; @@ -344,7 +344,7 @@ end else begin - if (lua_gettop(L) = 3) then + 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 @@ -440,7 +440,7 @@ c:= lua_toboolean(L, 5); vg:= AddVisualGear(x, y, vgt, s, c); - if vg <> nil then + if vg <> nil then begin lastVisualGearByUID:= vg; lua_pushinteger(L, vg^.uid) @@ -690,7 +690,7 @@ else begin gear := GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then lua_pushinteger(L, gear^.Hedgehog^.BotLevel) else lua_pushnil(L); @@ -723,7 +723,7 @@ else begin gear:= GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then begin lua_pushinteger(L, gear^.Hedgehog^.Team^.Clan^.ClanIndex) end @@ -764,7 +764,7 @@ for j:= 0 to 7 do begin hh:= team^.Hedgehogs[j]; - if (hh.Gear <> nil) or (hh.GearHidden <> nil) then + if (hh.Gear <> nil) or (hh.GearHidden <> nil) then begin FreeTexture(hh.NameTagTex); hh.NameTagTex:= RenderStringTex(hh.Name, clan^.Color, fnt16); @@ -805,7 +805,7 @@ else begin gear:= GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then begin lua_pushstring(L, str2pchar(gear^.Hedgehog^.Team^.TeamName)) end @@ -826,7 +826,7 @@ else begin gear:= GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then begin lua_pushstring(L, str2pchar(gear^.Hedgehog^.Name)) end @@ -1023,7 +1023,7 @@ prevgear^.Z := cHHZ; prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList; end; - + SwitchCurrentHedgehog(gear^.Hedgehog); CurrentTeam:= CurrentHedgehog^.Team; @@ -1046,7 +1046,7 @@ 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)); @@ -1084,7 +1084,7 @@ if (lua_gettop(L) = 2) then begin gear:= GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and (gear^.Hedgehog <> nil) then begin ammo:= GetAmmoEntry(gear^.Hedgehog^, TAmmoType(lua_tointeger(L, 2))); if ammo^.AmmoType = amNothing then @@ -1094,7 +1094,7 @@ end else lua_pushinteger(L, 0) end - else + else begin LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!'); lua_pushnil(L) @@ -1117,7 +1117,7 @@ gear^.Health:= lua_tointeger(L, 2); if (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then - begin + begin RenderHealth(gear^.Hedgehog^); RecountTeamHealth(gear^.Hedgehog^.Team) end; @@ -1650,7 +1650,7 @@ LuaError('Lua: Wrong number of parameters passed to GetHogHat!') else begin gear := GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) and (gear^.Hedgehog <> nil) then + if (gear <> nil) and ((gear^.Kind = gtHedgehog) or (gear^.Kind = gtGrave)) and (gear^.Hedgehog <> nil) then lua_pushstring(L, str2pchar(gear^.Hedgehog^.Hat)) else lua_pushnil(L); @@ -1942,7 +1942,7 @@ if StoreCnt-1 < k then AddAmmoStore; inc(k) end -else +else for i:= 0 to Pred(TeamsCount) do begin for j:= 0 to Pred(TeamsArray[i]^.HedgehogsNumber) do @@ -1994,7 +1994,7 @@ exit; f:= pfsOpenRead(s); -if f = nil then +if f = nil then exit; physfsReaderSetBuffer(@buf); @@ -2191,7 +2191,7 @@ AddAmmoStore; TeamsArray[i]^.Hedgehogs[j].AmmoStore:= StoreCnt - 1 end -else +else for i:= 0 to Pred(TeamsCount) do begin if ScriptExists('onNewAmmoStore') then @@ -2321,6 +2321,7 @@ ScriptSetInteger('gstHHGone' ,$00100000); ScriptSetInteger('gstInvisible' ,$00200000); +// ai hints ScriptSetInteger('aihUsualProcessing' ,$00000000); ScriptSetInteger('aihDoesntMatter' ,$00000001); diff -r d24257910f8d -r aaefa587e277 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uSound.pas Tue Dec 25 04:45:22 2012 +0100 @@ -21,7 +21,7 @@ unit uSound; (* * This unit controls the sounds and music of the game. - * Doesn't really do anything if isSoundEnabled = false. + * Doesn't really do anything if isSoundEnabled = false and isMusicEnabled = false * * There are three basic types of sound controls: * Music - The background music of the game: @@ -120,6 +120,136 @@ isMusicEnabled: boolean; isSoundEnabled: boolean; isSEBackup: boolean; + 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)); + Soundz: array[TSound] of record + FileName: string[31]; + Path : TPathType; + end = ( + (FileName: ''; Path: ptNone ),// sndNone + (FileName: 'grenadeimpact.ogg'; Path: ptSounds),// sndGrenadeImpact + (FileName: 'explosion.ogg'; Path: ptSounds),// sndExplosion + (FileName: 'throwpowerup.ogg'; Path: ptSounds),// sndThrowPowerUp + (FileName: 'throwrelease.ogg'; Path: ptSounds),// sndThrowRelease + (FileName: 'splash.ogg'; Path: ptSounds),// sndSplash + (FileName: 'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload + (FileName: 'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire + (FileName: 'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact + (FileName: 'mineimpact.ogg'; Path: ptSounds),// sndMineImpact + (FileName: 'minetick.ogg'; Path: ptSounds),// sndMineTicks + (FileName: 'Droplet1.ogg'; Path: ptSounds),// sndMudballImpact + (FileName: 'pickhammer.ogg'; Path: ptSounds),// sndPickhammer + (FileName: 'gun.ogg'; Path: ptSounds),// sndGun + (FileName: 'bee.ogg'; Path: ptSounds),// sndBee + (FileName: 'Jump1.ogg'; Path: ptVoices),// sndJump1 + (FileName: 'Jump2.ogg'; Path: ptVoices),// sndJump2 + (FileName: 'Jump3.ogg'; Path: ptVoices),// sndJump3 + (FileName: 'Yessir.ogg'; Path: ptVoices),// sndYesSir + (FileName: 'Laugh.ogg'; Path: ptVoices),// sndLaugh + (FileName: 'Illgetyou.ogg'; Path: ptVoices),// sndIllGetYou + (FileName: 'JustYouWait.ogg'; Path: ptVoices),// sndJustYouWait + (FileName: 'Incoming.ogg'; Path: ptVoices),// sndIncoming + (FileName: 'Missed.ogg'; Path: ptVoices),// sndMissed + (FileName: 'Stupid.ogg'; Path: ptVoices),// sndStupid + (FileName: 'Firstblood.ogg'; Path: ptVoices),// sndFirstBlood + (FileName: 'Boring.ogg'; Path: ptVoices),// sndBoring + (FileName: 'Byebye.ogg'; Path: ptVoices),// sndByeBye + (FileName: 'Sameteam.ogg'; Path: ptVoices),// sndSameTeam + (FileName: 'Nutter.ogg'; Path: ptVoices),// sndNutter + (FileName: 'Reinforcements.ogg'; Path: ptVoices),// sndReinforce + (FileName: 'Traitor.ogg'; Path: ptVoices),// sndTraitor + (FileName: 'Youllregretthat.ogg'; Path: ptVoices),// sndRegret + (FileName: 'Enemydown.ogg'; Path: ptVoices),// sndEnemyDown + (FileName: 'Coward.ogg'; Path: ptVoices),// sndCoward + (FileName: 'Hurry.ogg'; Path: ptVoices),// sndHurry + (FileName: 'Watchit.ogg'; Path: ptVoices),// sndWatchIt + (FileName: 'Kamikaze.ogg'; Path: ptVoices),// sndKamikaze + (FileName: 'cake2.ogg'; Path: ptSounds),// sndCake + (FileName: 'Ow1.ogg'; Path: ptVoices),// sndOw1 + (FileName: 'Ow2.ogg'; Path: ptVoices),// sndOw2 + (FileName: 'Ow3.ogg'; Path: ptVoices),// sndOw3 + (FileName: 'Ow4.ogg'; Path: ptVoices),// sndOw4 + (FileName: 'Firepunch1.ogg'; Path: ptVoices),// sndFirepunch1 + (FileName: 'Firepunch2.ogg'; Path: ptVoices),// sndFirepunch2 + (FileName: 'Firepunch3.ogg'; Path: ptVoices),// sndFirepunch3 + (FileName: 'Firepunch4.ogg'; Path: ptVoices),// sndFirepunch4 + (FileName: 'Firepunch5.ogg'; Path: ptVoices),// sndFirepunch5 + (FileName: 'Firepunch6.ogg'; Path: ptVoices),// sndFirepunch6 + (FileName: 'Melon.ogg'; Path: ptVoices),// sndMelon + (FileName: 'Hellish.ogg'; Path: ptSounds),// sndHellish + (FileName: 'Yoohoo.ogg'; Path: ptSounds),// sndYoohoo + (FileName: 'rcplane.ogg'; Path: ptSounds),// sndRCPlane + (FileName: 'whipcrack.ogg'; Path: ptSounds),// sndWhipCrack + (FileName:'ride_of_the_valkyries.ogg'; Path: ptSounds),// sndRideOfTheValkyries + (FileName: 'denied.ogg'; Path: ptSounds),// sndDenied + (FileName: 'placed.ogg'; Path: ptSounds),// sndPlaced + (FileName: 'baseballbat.ogg'; Path: ptSounds),// sndBaseballBat + (FileName: 'steam.ogg'; Path: ptSounds),// sndVaporize + (FileName: 'warp.ogg'; Path: ptSounds),// sndWarp + (FileName: 'suddendeath.ogg'; Path: ptSounds),// sndSuddenDeath + (FileName: 'mortar.ogg'; Path: ptSounds),// sndMortar + (FileName: 'shutterclick.ogg'; Path: ptSounds),// sndShutter + (FileName: 'homerun.ogg'; Path: ptSounds),// sndHomerun + (FileName: 'molotov.ogg'; Path: ptSounds),// sndMolotov + (FileName: 'Takecover.ogg'; Path: ptVoices),// sndCover + (FileName: 'Uh-oh.ogg'; Path: ptVoices),// sndUhOh + (FileName: 'Oops.ogg'; Path: ptVoices),// sndOops + (FileName: 'Nooo.ogg'; Path: ptVoices),// sndNooo + (FileName: 'Hello.ogg'; Path: ptVoices),// sndHello + (FileName: 'ropeshot.ogg'; Path: ptSounds),// sndRopeShot + (FileName: 'ropeattach.ogg'; Path: ptSounds),// sndRopeAttach + (FileName: 'roperelease.ogg'; Path: ptSounds),// sndRopeRelease + (FileName: 'switchhog.ogg'; Path: ptSounds),// sndSwitchHog + (FileName: 'Victory.ogg'; Path: ptVoices),// sndVictory + (FileName: 'Flawless.ogg'; Path: ptVoices),// sndFlawless + (FileName: 'sniperreload.ogg'; Path: ptSounds),// sndSniperReload + (FileName: 'steps.ogg'; Path: ptSounds),// sndSteps + (FileName: 'lowgravity.ogg'; Path: ptSounds),// sndLowGravity + (FileName: 'hell_growl.ogg'; Path: ptSounds),// sndHellishImpact1 + (FileName: 'hell_ooff.ogg'; Path: ptSounds),// sndHellishImpact2 + (FileName: 'hell_ow.ogg'; Path: ptSounds),// sndHellishImpact3 + (FileName: 'hell_ugh.ogg'; Path: ptSounds),// sndHellishImpact4 + (FileName: 'melonimpact.ogg'; Path: ptSounds),// sndMelonImpact + (FileName: 'Droplet1.ogg'; Path: ptSounds),// sndDroplet1 + (FileName: 'Droplet2.ogg'; Path: ptSounds),// sndDroplet2 + (FileName: 'Droplet3.ogg'; Path: ptSounds),// sndDroplet3 + (FileName: 'egg.ogg'; Path: ptSounds),// sndEggBreak + (FileName: 'drillgun.ogg'; Path: ptSounds),// sndDrillRocket + (FileName: 'PoisonCough.ogg'; Path: ptVoices),// sndPoisonCough + (FileName: 'PoisonMoan.ogg'; Path: ptVoices),// sndPoisonMoan + (FileName: 'BirdyLay.ogg'; Path: ptSounds),// sndBirdyLay + (FileName: 'Whistle.ogg'; Path: ptSounds),// sndWhistle + (FileName: 'beewater.ogg'; Path: ptSounds),// sndBeeWater + (FileName: '1C.ogg'; Path: ptSounds),// sndPiano0 + (FileName: '2D.ogg'; Path: ptSounds),// sndPiano1 + (FileName: '3E.ogg'; Path: ptSounds),// sndPiano2 + (FileName: '4F.ogg'; Path: ptSounds),// sndPiano3 + (FileName: '5G.ogg'; Path: ptSounds),// sndPiano4 + (FileName: '6A.ogg'; Path: ptSounds),// sndPiano5 + (FileName: '7B.ogg'; Path: ptSounds),// sndPiano6 + (FileName: '8C.ogg'; Path: ptSounds),// sndPiano7 + (FileName: '9D.ogg'; Path: ptSounds),// sndPiano8 + (FileName: 'skip.ogg'; Path: ptSounds),// sndSkip + (FileName: 'sinegun.ogg'; Path: ptSounds),// sndSineGun + (FileName: 'Ooff1.ogg'; Path: ptVoices),// sndOoff1 + (FileName: 'Ooff2.ogg'; Path: ptVoices),// sndOoff2 + (FileName: 'Ooff3.ogg'; Path: ptVoices),// sndOoff3 + (FileName: 'hammer.ogg'; Path: ptSounds),// sndWhack + (FileName: 'Comeonthen.ogg'; Path: ptVoices),// sndComeonthen + (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: 'TARDIS.ogg'; Path: ptSounds) // sndTardis + ); + function AskForVoicepack(name: shortstring): Pointer; @@ -157,26 +287,31 @@ procedure InitSound; const channels: LongInt = {$IFDEF MOBILE}1{$ELSE}2{$ENDIF}; +var success: boolean; begin - if not isSoundEnabled then + if not (isSoundEnabled or isMusicEnabled) then exit; WriteToConsole('Init sound...'); - isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; + success:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; - if isSoundEnabled then - isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; + if success then + success:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0; - if isSoundEnabled then + if success then WriteLnToConsole(msgOK) else + begin WriteLnToConsole(msgFailed); + isSoundEnabled:= false; + isMusicEnabled:= false; + end; WriteToConsole('Init SDL_mixer... '); SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); WriteLnToConsole(msgOK); Mix_AllocateChannels(Succ(chanTPU)); - ChangeVolume(cInitVolume); + ChangeVolume(cInitVolume); end; procedure ResetSound; @@ -256,7 +391,7 @@ if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then begin s:= cPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; - if (not FileExists(s)) and (snd in [sndFirePunch2, sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6]) then + if (not pfsExists(s)) and (snd in [sndFirePunch2, sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6]) then s:= cPathz[Soundz[sndFirePunch1].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName; WriteToConsole(msgLoading + s + ' '); voicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1); @@ -289,7 +424,7 @@ if (snd = sndVictory) or (snd = sndFlawless) then begin Mix_FadeOutChannel(-1, 800); - for i:= 0 to 7 do + for i:= 0 to High(VoiceList) do VoiceList[i].snd:= sndNone; LastVoice.snd:= sndNone; end; @@ -311,9 +446,9 @@ 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 + while (i sndNone) then begin LastVoice.snd:= VoiceList[i].snd; @@ -413,7 +548,7 @@ procedure PlayMusic; var s: shortstring; begin - if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then + if (MusicFN = '') or (not isMusicEnabled) then exit; s:= '/Music/' + MusicFN; @@ -434,7 +569,7 @@ function ChangeVolume(voldelta: LongInt): LongInt; begin ChangeVolume:= 0; - if (not isSoundEnabled) or ((voldelta = 0) and (not (cInitVolume = 0))) then + if not (isSoundEnabled or isMusicEnabled) or ((voldelta = 0) and (not (cInitVolume = 0))) then exit; inc(Volume, voldelta); @@ -474,7 +609,7 @@ procedure MuteAudio; begin - if not isSoundEnabled then + if not (isSoundEnabled or isMusicEnabled) then exit; if (isAudioMuted) then @@ -589,7 +724,7 @@ 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 *) + or sound files bigger than 32k will lockup the game on slow cpu *) for i:= Low(TSound) to High(TSound) do defVoicepack^.chunks[i]:= nil; @@ -597,7 +732,7 @@ procedure freeModule; begin - if isSoundEnabled then + if isSoundEnabled or isMusicEnabled then ReleaseSound(true); end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uStore.pas Tue Dec 25 04:45:22 2012 +0100 @@ -36,7 +36,7 @@ procedure FinishProgress; function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; -// loads an image from the game's data files +// loads an image from the games 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; @@ -70,7 +70,7 @@ procedure EndWater; implementation -uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands +uses uMisc, uConsole, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands , uPhysFSLayer , uDebug {$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF} @@ -85,6 +85,9 @@ {$ELSE} SDLPrimSurface: PSDL_Surface; {$ENDIF} + squaresize : LongInt; + numsquares : LongInt; + ProgrTex: PTexture; {$IFDEF GL2} shaderMain: GLuint; @@ -97,6 +100,10 @@ OpenGLSetupedBefore : boolean; {$ENDIF} +const + cHHFileName = 'Hedgehog'; + cCHFileName = 'Crosshair'; + function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect; var w, h: LongInt; tmpsurf: PSDL_Surface; @@ -219,7 +226,7 @@ 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; + 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; @@ -227,7 +234,7 @@ 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 + //if (maxLevel > 0) and (maxLevel < 3) then Flag:= 'cpu_plain' else Flag:= 'cpu' end else if (Flag = 'cpu') or (Flag = 'cpu_plain') then @@ -237,10 +244,10 @@ 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); + 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; @@ -402,7 +409,7 @@ if not reload then begin {$IFDEF USE_CONTEXT_RESTORE} - Surface:= tmpsurf + Surface:= tmpsurf {$ELSE} if saveSurf then Surface:= tmpsurf @@ -464,7 +471,7 @@ WriteLnToConsole('Leaving StoreLoad'); end; -{$IF NOT DEFINED(S3D_DISABLED) OR DEFINED(USE_VIDEO_RECORDING)} +{$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} procedure CreateFramebuffer(var frame, depth, tex: GLuint); begin glGenFramebuffersEXT(1, @frame); @@ -566,7 +573,7 @@ if defaultFrame <> 0 then DeleteFramebuffer(defaultFrame, depthv, texv); {$ENDIF} -{$IFNDEF S3D_DISABLED} +{$IFDEF USE_S3D_RENDERING} if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then begin DeleteFramebuffer(framel, depthl, texl); @@ -748,7 +755,7 @@ ReadLn(f, line); source:= source + line + #10; end; - + Close(f); WriteLnToConsole('Compiling shader: ' + Pathz[ptShaders] + '/' + shaderFile); @@ -872,7 +879,7 @@ end else if (MaxTextureSize < 1024) and (MaxTextureSize >= 512) then begin - cReducedQuality := cReducedQuality or rqNoBackground; + cReducedQuality := cReducedQuality or rqNoBackground; AddFileLog('Texture size too small for backgrounds, disabling.'); end; @@ -988,7 +995,7 @@ UpdateModelviewProjection; {$ENDIF} -{$IFNDEF S3D_DISABLED} +{$IFNDEF USE_S3D_RENDERING} if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then begin // prepare left and right frame buffers and associated textures @@ -1017,7 +1024,7 @@ hglTranslatef(0, -cScreenHeight / 2, 0); EnableTexture(True); - + glEnableVertexAttribArray(aVertex); glEnableVertexAttribArray(aTexCoord); glGenBuffers(1, @vBuffer); @@ -1120,7 +1127,7 @@ glMatrixMode(GL_PROJECTION); glLoadMatrixf(@mProjection[0, 0]); glMatrixMode(GL_MODELVIEW); - {$ENDIF} + {$ENDIF} end; *) @@ -1203,8 +1210,10 @@ squaresize:= texsurf^.w shr 1; numsquares:= texsurf^.h div squaresize; SDL_FreeSurface(texsurf); + with mobileRecord do + if GameLoading <> nil then + GameLoading(); - uMobile.GameLoading(); end; TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); @@ -1228,7 +1237,9 @@ procedure FinishProgress; begin - uMobile.GameLoaded(); + with mobileRecord do + if GameLoaded <> nil then + GameLoaded(); WriteLnToConsole('Freeing progress surface... '); FreeTexture(ProgrTex); ProgrTex:= nil; @@ -1502,7 +1513,7 @@ //uTextures.freeModule; //DEBUG ONLY {$ENDIF} AddFileLog('Freeing old primary surface...'); - {$IFNDEF SDL13} + {$IFNDEF SDL13} {$IFNDEF WEBGL} SDL_FreeSurface(SDLPrimSurface); SDLPrimSurface:= nil; @@ -1550,7 +1561,7 @@ s:= SDL_getenv('SDL_VIDEO_CENTERED'); SDL_putenv('SDL_VIDEO_CENTERED=1'); {$ENDIF} - SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); + SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, 0, flags); SDLTry(SDLPrimSurface <> nil, true); {$IFDEF WIN32}SDL_putenv(str2pchar('SDL_VIDEO_CENTERED=' + s));{$ENDIF} end; @@ -1564,7 +1575,7 @@ 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) - else if ((cReducedQuality and rqNoBackground) = 0) then + 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); diff -r d24257910f8d -r aaefa587e277 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uTeams.pas Tue Dec 25 04:45:22 2012 +0100 @@ -46,6 +46,7 @@ var MaxTeamHealth: LongInt; GameOver: boolean; + NextClan: boolean; function CheckForWin: boolean; var AliveClan: PClan; @@ -95,7 +96,7 @@ if (Gear <> nil) then Gear^.State:= gstWinner; if Flawless then - AddVoice(sndFlawless, Teams[0]^.voicepack) + AddVoice(sndFlawless, Teams[0]^.voicepack) else AddVoice(sndVictory, Teams[0]^.voicepack); @@ -577,8 +578,8 @@ procedure chBind(var id: shortstring); var KeyName, Modifier, tmp : shortstring; - b : LongInt; - i : Integer; + b : LongInt; + i : Integer; begin KeyName:= ''; Modifier:= ''; diff -r d24257910f8d -r aaefa587e277 hedgewars/uTouch.pas --- a/hedgewars/uTouch.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uTouch.pas Tue Dec 25 04:45:22 2012 +0100 @@ -22,7 +22,7 @@ interface -uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uAmmos, uWorld, uMobile; +uses SysUtils, uConsole, uVariables, SDLh, uFloat, uConsts, uCommands, GLUnit, uTypes, uCaptions, uAmmos, uWorld; procedure initModule; @@ -76,20 +76,20 @@ xTouchClick,yTouchClick : LongInt; timeSinceClick : Longword; - //Pinch to zoom + //Pinch to zoom pinchSize : LongInt; baseZoomValue: GLFloat; //aiming aimingCrosshair: boolean; - aimingUp, aimingDown: boolean; + aimingUp, aimingDown: boolean; targetAngle: LongInt; buttonsDown: Longword; targetting, targetted: boolean; //true when targetting an airstrike or the like procedure onTouchDown(x,y: Longword; pointerId: TSDL_FingerId); -var +var finger: PTouch_Data; begin {$IFDEF USE_TOUCH_INTERFACE} @@ -161,7 +161,7 @@ ParseTeamCommand('/timer ' + inttostr((GetCurAmmoEntry(CurrentHedgeHog^)^.Timer div 1000) mod 5 + 1)); end; exit; - end; + end; dec(buttonsDown);//no buttonsDown, undo the inc() above if buttonsDown = 0 then begin @@ -201,8 +201,8 @@ end; exit //todo change into switch rather than ugly ifs end; - -if aimingCrosshair then + +if aimingCrosshair then begin aim(finger^); exit @@ -252,10 +252,10 @@ if (buttonsDown > 0) and (widget <> nil) then begin dec(buttonsDown); - + if widget = @arrowLeft then ParseTeamCommand('-left'); - + if widget = @arrowRight then ParseTeamCommand('-right'); @@ -267,7 +267,7 @@ 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 @@ -279,10 +279,10 @@ 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; @@ -309,8 +309,8 @@ //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; +// timeSinceClick:= 0;//we make an assumption there won't be an 'click' in the first 300 ticks(milliseconds) +// exit; // end; xTouchClick:= finger.x; @@ -318,12 +318,12 @@ timeSinceClick:= RealTicks; if bShowAmmoMenu then - begin + begin if isOnRect(AmmoRect, finger) then begin CursorPoint.X:= finger.x; CursorPoint.Y:= finger.y; - ParseTeamCommand('put'); + ParseTeamCommand('put'); end else bShowAmmoMenu:= false; @@ -339,28 +339,28 @@ if isOnWidget(jumpWidget, finger) then begin - ParseTeamCommand('hjump'); + ParseTeamCommand('hjump'); exit; end; {$ENDIF} end; function addFinger(x,y: Longword; id: TSDL_FingerId): PTouch_Data; -var +var xCursor, yCursor, index : LongInt; begin //Check array sizes - if length(fingers) < Integer(pointerCount) then + 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; end; - - + + 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 fingers[pointerCount].id := id; @@ -372,7 +372,7 @@ fingers[pointerCount].dy := 0; fingers[pointerCount].timeSinceDown:= RealTicks; fingers[pointerCount].pressedWidget:= nil; - + addFinger:= @fingers[pointerCount]; inc(pointerCount); end; @@ -391,22 +391,22 @@ var index : Longword; begin - + dec(pointerCount); for index := 0 to pointerCount do begin if fingers[index].id = id then begin - - //put the last finger into the spot of the finger to be removed, + + //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; - fingers[index].historicalX := fingers[pointerCount].historicalX; - fingers[index].historicalY := fingers[pointerCount].historicalY; + fingers[index].id := fingers[pointerCount].id; + fingers[index].x := fingers[pointerCount].x; + fingers[index].y := fingers[pointerCount].y; + fingers[index].historicalX := fingers[pointerCount].historicalX; + fingers[index].historicalY := fingers[pointerCount].historicalY; fingers[index].timeSinceDown := fingers[pointerCount].timeSinceDown; fingers[pointerCount].id := nilFingerId; @@ -430,12 +430,12 @@ var deltaAngle: LongInt; begin -invertCursor := not(bShowAmmoMenu or targetting); +invertCursor := not(bShowAmmoMenu or targetting); if aimingCrosshair then if CurrentHedgehog^.Gear <> nil then begin deltaAngle:= CurrentHedgehog^.Gear^.Angle - targetAngle; - if (deltaAngle > -5) and (deltaAngle < 5) then + if (deltaAngle > -5) and (deltaAngle < 5) then begin if(aimingUp)then begin @@ -475,10 +475,10 @@ aimingUp:= true; ParseTeamCommand('+up'); end; - end; + end; end; end - else + else begin if aimingUp then begin @@ -498,7 +498,7 @@ index: LongWord; begin for index := 0 to High(fingers) do - if fingers[index].id = id then + if fingers[index].id = id then begin findFinger := @fingers[index]; break; @@ -506,7 +506,7 @@ end; procedure aim(finger: TTouch_Data); -var +var hogX, hogY, touchX, touchY, deltaX, deltaY: LongInt; begin if CurrentHedgehog^.Gear <> nil then @@ -519,7 +519,7 @@ convertToWorldCoord(touchX, touchY, finger); deltaX := abs(TouchX-HogX); deltaY := TouchY-HogY; - + targetAngle:= (Round(DeltaY / sqrt(sqr(deltaX) + sqr(deltaY)) * 2048) + 2048) div 2; end; //if CurrentHedgehog^.Gear <> nil end; @@ -558,7 +558,7 @@ 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))); + WriteLnToConsole(inttostr(x) + ' ' + inttostr(y) + ' ' + inttostr(round(mobileRecord.getScreenDPI() * 10))); end; function isOnCurrentHog(finger: TTouch_Data): boolean; @@ -579,9 +579,9 @@ procedure convertToWorldCoord(var x,y: LongInt; finger: TTouch_Data); begin -//if x <> nil then +//if x <> nil then x := finger.x-WorldDx; -//if y <> nil then +//if y <> nil then y := (cScreenHeight - finger.y)-WorldDy; end; @@ -637,10 +637,10 @@ buttonsDown:= 0; setLength(fingers, 4); - for index := 0 to High(fingers) do + for index := 0 to High(fingers) do fingers[index].id := nilFingerId; - rectSize:= round(baseRectSize * uMobile.getScreenDPI); + rectSize:= round(baseRectSize * mobileRecord.getScreenDPI()); halfRectSize:= rectSize shl 1; end; diff -r d24257910f8d -r aaefa587e277 hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uTypes.pas Tue Dec 25 04:45:22 2012 +0100 @@ -103,7 +103,7 @@ 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.) @@ -152,7 +152,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, amIceGun, amKnife); // 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); @@ -393,15 +393,27 @@ TClan = record Color: Longword; Teams: array[0..Pred(cMaxTeams)] of PTeam; - TeamsNumber: LongInt;{xymeng, org:LongWord} + TeamsNumber: LongInt;{xymeng, org:LongWord} TagTeamIndex: Longword; CurrTeam: LongWord; ClanHealth: LongInt; ClanIndex: LongInt; - TurnNumber: LongInt;{xymeng, org:LongWord} + TurnNumber: LongInt;{xymeng, org:LongWord} Flawless: boolean; end; + cdeclPtr = procedure; cdecl; + cdeclIntPtr = procedure(num: LongInt); cdecl; + functionDoublePtr = function: Double; + + TMobileRecord = record + getScreenDPI: functionDoublePtr; + PerformRumble: cdeclIntPtr; + GameLoading: cdeclPtr; + GameLoaded: cdeclPtr; + SaveLoadingEnded: cdeclPtr; + end; + TAmmoStrId = (sidGrenade, sidClusterBomb, sidBazooka, sidBee, sidShotgun, sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, @@ -414,11 +426,11 @@ sidMolotov, sidBirdy, sidPortalGun, sidPiano, sidGasBomb, sidSineGun, sidFlamethrower,sidSMine, sidHammer, sidResurrector, sidDrillStrike, sidSnowball, sidNothing, sidTardis, - sidStructure, sidLandGun, sidIceGun, sidKnife); + {sidStructure,} sidLandGun, sidIceGun, sidKnife); TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, - sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady, + sidNoEndTurn, sidNotYetAvailable, sidRoundSD, sidRoundsSD, sidReady, sidBounce1, sidBounce2, sidBounce3, sidBounce4, sidBounce5, sidBounce, sidMute); @@ -429,17 +441,17 @@ TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable, gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery, - gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, - gidRandomMineTimer, gidDamageModifier, gidResetHealth, gidAISurvival, + 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; TDirtyTag = packed array of array of byte; - + TPreview = packed array[0..127, 0..31] of byte; - + PWidgetMovement = ^TWidgetMovement; TWidgetMovement = record animate : Boolean; diff -r d24257910f8d -r aaefa587e277 hedgewars/uUtils.pas --- a/hedgewars/uUtils.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uUtils.pas Tue Dec 25 04:45:22 2012 +0100 @@ -76,6 +76,17 @@ procedure WriteLn(var f: textfile; s: shortstring); {$ENDIF} +function isPhone: Boolean; inline; +function getScreenDPI: Double; inline; //cdecl; external; + +{$IFDEF IPHONEOS} +procedure startLoadingIndicator; cdecl; external; +procedure stopLoadingIndicator; cdecl; external; +procedure saveFinishedSynching; cdecl; external; +function isApplePhone: Boolean; cdecl; external; +procedure AudioServicesPlaySystemSound(num: LongInt); cdecl; external; +{$ENDIF} + procedure initModule(isNotPreview: boolean); procedure freeModule; @@ -368,7 +379,7 @@ ((#$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 + then begin CheckCJKFont:= THWFont( ord(font) + ((ord(High(THWFont))+1) div 2) ); exit; @@ -418,10 +429,35 @@ end; {$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} + 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} +end; + +//This dummy function should be reimplemented (externally). +function getScreenDPI: Double; inline; +begin +{$IFDEF ANDROID} +// getScreenDPI:= Android_JNI_getDensity(); + getScreenDPI:= 1; +{$ELSE} + getScreenDPI:= 1; +{$ENDIF} +end; + procedure initModule(isNotPreview: boolean); {$IFDEF DEBUGFILE} var logfileBase: shortstring; -{$IFNDEF MOBILE}var i: LongInt;{$ENDIF} + i: LongInt; {$ENDIF} begin {$IFDEF DEBUGFILE} @@ -440,26 +476,25 @@ {$I-} {$IFDEF MOBILE} {$IFDEF IPHONEOS} Assign(f, UserPathPrefix + '/hw-' + logfileBase + '.log'); {$ENDIF} - {$IFDEF ANDROID} Assign(f,pathPrefix + '/' + logfileBase + '.log'); {$ENDIF} - Rewrite(f); + {$IFDEF ANDROID} Assign(f, pathPrefix + '/' + logfileBase + '.log'); {$ENDIF} + i:= i; // avoid hint {$ELSE} + f:= stdout; // if everything fails, write to stderr if (UserPathPrefix <> '') then begin - i:= 0; - while(i < 7) do + if not FileExists(UserPathPrefix + '/Logs/') then + CreateDir(UserPathPrefix + '/Logs/'); + i:= 0; + while(i < 7) do begin - assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log'); - rewrite(f); - if IOResult = 0 then - break; - inc(i) + assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log'); + if IOResult = 0 then + break; + inc(i) end; - if i = 7 then - f:= stderr; // if everything fails, write to stderr - end - else - f:= stderr; + end; {$ENDIF} + Rewrite(f); {$I+} {$ENDIF} diff -r d24257910f8d -r aaefa587e277 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uVariables.pas Tue Dec 25 04:45:22 2012 +0100 @@ -21,7 +21,7 @@ unit uVariables; interface -uses SDLh, uTypes, uFloat, GLunit, uConsts, Math, uMobile, uUtils, uMatrix; +uses SDLh, uTypes, uFloat, GLunit, uConsts, Math, uUtils, uMatrix; var /////// init flags /////// @@ -34,7 +34,6 @@ cNewScreenWidth : LongInt; cNewScreenHeight : LongInt; cScreenResizeDelay : LongWord; - cBits : LongInt; ipcPort : Word; cFullScreen : boolean; cLocaleFName : shortstring; @@ -157,9 +156,8 @@ cVampiric : boolean; cArtillery : boolean; WeaponTooltipTex: PTexture; - AmmoMenuTex : PTexture; AmmoMenuInvalidated: boolean; - AmmoRect : TSDL_Rect; + AmmoRect : TSDL_Rect; HHTexture : PTexture; cMaxZoomLevel : real; cMinZoomLevel : real; @@ -196,17 +194,10 @@ LuaTemplateNumber : LongInt; {org: 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 ); + mobileRecord: TMobileRecord; + ///////////////////////////////////// //Buttons {$IFDEF USE_TOUCH_INTERFACE} @@ -692,126 +683,6 @@ (Sprite: sprJuggle; FramesCount: 49; Interval: 38; cmd: '/juggle'; Voice: sndNone; VoiceDelay: 0) ); - Soundz: array[TSound] of record - FileName: string[31]; - Path : TPathType; - end = ( - (FileName: ''; Path: ptNone ),// sndNone - (FileName: 'grenadeimpact.ogg'; Path: ptSounds),// sndGrenadeImpact - (FileName: 'explosion.ogg'; Path: ptSounds),// sndExplosion - (FileName: 'throwpowerup.ogg'; Path: ptSounds),// sndThrowPowerUp - (FileName: 'throwrelease.ogg'; Path: ptSounds),// sndThrowRelease - (FileName: 'splash.ogg'; Path: ptSounds),// sndSplash - (FileName: 'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload - (FileName: 'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire - (FileName: 'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact - (FileName: 'mineimpact.ogg'; Path: ptSounds),// sndMineImpact - (FileName: 'minetick.ogg'; Path: ptSounds),// sndMineTicks - (FileName: 'Droplet1.ogg'; Path: ptSounds),// sndMudballImpact - (FileName: 'pickhammer.ogg'; Path: ptSounds),// sndPickhammer - (FileName: 'gun.ogg'; Path: ptSounds),// sndGun - (FileName: 'bee.ogg'; Path: ptSounds),// sndBee - (FileName: 'Jump1.ogg'; Path: ptVoices),// sndJump1 - (FileName: 'Jump2.ogg'; Path: ptVoices),// sndJump2 - (FileName: 'Jump3.ogg'; Path: ptVoices),// sndJump3 - (FileName: 'Yessir.ogg'; Path: ptVoices),// sndYesSir - (FileName: 'Laugh.ogg'; Path: ptVoices),// sndLaugh - (FileName: 'Illgetyou.ogg'; Path: ptVoices),// sndIllGetYou - (FileName: 'JustYouWait.ogg'; Path: ptVoices),// sndJustYouWait - (FileName: 'Incoming.ogg'; Path: ptVoices),// sndIncoming - (FileName: 'Missed.ogg'; Path: ptVoices),// sndMissed - (FileName: 'Stupid.ogg'; Path: ptVoices),// sndStupid - (FileName: 'Firstblood.ogg'; Path: ptVoices),// sndFirstBlood - (FileName: 'Boring.ogg'; Path: ptVoices),// sndBoring - (FileName: 'Byebye.ogg'; Path: ptVoices),// sndByeBye - (FileName: 'Sameteam.ogg'; Path: ptVoices),// sndSameTeam - (FileName: 'Nutter.ogg'; Path: ptVoices),// sndNutter - (FileName: 'Reinforcements.ogg'; Path: ptVoices),// sndReinforce - (FileName: 'Traitor.ogg'; Path: ptVoices),// sndTraitor - (FileName: 'Youllregretthat.ogg'; Path: ptVoices),// sndRegret - (FileName: 'Enemydown.ogg'; Path: ptVoices),// sndEnemyDown - (FileName: 'Coward.ogg'; Path: ptVoices),// sndCoward - (FileName: 'Hurry.ogg'; Path: ptVoices),// sndHurry - (FileName: 'Watchit.ogg'; Path: ptVoices),// sndWatchIt - (FileName: 'Kamikaze.ogg'; Path: ptVoices),// sndKamikaze - (FileName: 'cake2.ogg'; Path: ptSounds),// sndCake - (FileName: 'Ow1.ogg'; Path: ptVoices),// sndOw1 - (FileName: 'Ow2.ogg'; Path: ptVoices),// sndOw2 - (FileName: 'Ow3.ogg'; Path: ptVoices),// sndOw3 - (FileName: 'Ow4.ogg'; Path: ptVoices),// sndOw4 - (FileName: 'Firepunch1.ogg'; Path: ptVoices),// sndFirepunch1 - (FileName: 'Firepunch2.ogg'; Path: ptVoices),// sndFirepunch2 - (FileName: 'Firepunch3.ogg'; Path: ptVoices),// sndFirepunch3 - (FileName: 'Firepunch4.ogg'; Path: ptVoices),// sndFirepunch4 - (FileName: 'Firepunch5.ogg'; Path: ptVoices),// sndFirepunch5 - (FileName: 'Firepunch6.ogg'; Path: ptVoices),// sndFirepunch6 - (FileName: 'Melon.ogg'; Path: ptVoices),// sndMelon - (FileName: 'Hellish.ogg'; Path: ptSounds),// sndHellish - (FileName: 'Yoohoo.ogg'; Path: ptSounds),// sndYoohoo - (FileName: 'rcplane.ogg'; Path: ptSounds),// sndRCPlane - (FileName: 'whipcrack.ogg'; Path: ptSounds),// sndWhipCrack - (FileName:'ride_of_the_valkyries.ogg'; Path: ptSounds),// sndRideOfTheValkyries - (FileName: 'denied.ogg'; Path: ptSounds),// sndDenied - (FileName: 'placed.ogg'; Path: ptSounds),// sndPlaced - (FileName: 'baseballbat.ogg'; Path: ptSounds),// sndBaseballBat - (FileName: 'steam.ogg'; Path: ptSounds),// sndVaporize - (FileName: 'warp.ogg'; Path: ptSounds),// sndWarp - (FileName: 'suddendeath.ogg'; Path: ptSounds),// sndSuddenDeath - (FileName: 'mortar.ogg'; Path: ptSounds),// sndMortar - (FileName: 'shutterclick.ogg'; Path: ptSounds),// sndShutter - (FileName: 'homerun.ogg'; Path: ptSounds),// sndHomerun - (FileName: 'molotov.ogg'; Path: ptSounds),// sndMolotov - (FileName: 'Takecover.ogg'; Path: ptVoices),// sndCover - (FileName: 'Uh-oh.ogg'; Path: ptVoices),// sndUhOh - (FileName: 'Oops.ogg'; Path: ptVoices),// sndOops - (FileName: 'Nooo.ogg'; Path: ptVoices),// sndNooo - (FileName: 'Hello.ogg'; Path: ptVoices),// sndHello - (FileName: 'ropeshot.ogg'; Path: ptSounds),// sndRopeShot - (FileName: 'ropeattach.ogg'; Path: ptSounds),// sndRopeAttach - (FileName: 'roperelease.ogg'; Path: ptSounds),// sndRopeRelease - (FileName: 'switchhog.ogg'; Path: ptSounds),// sndSwitchHog - (FileName: 'Victory.ogg'; Path: ptVoices),// sndVictory - (FileName: 'Flawless.ogg'; Path: ptVoices),// sndFlawless - (FileName: 'sniperreload.ogg'; Path: ptSounds),// sndSniperReload - (FileName: 'steps.ogg'; Path: ptSounds),// sndSteps - (FileName: 'lowgravity.ogg'; Path: ptSounds),// sndLowGravity - (FileName: 'hell_growl.ogg'; Path: ptSounds),// sndHellishImpact1 - (FileName: 'hell_ooff.ogg'; Path: ptSounds),// sndHellishImpact2 - (FileName: 'hell_ow.ogg'; Path: ptSounds),// sndHellishImpact3 - (FileName: 'hell_ugh.ogg'; Path: ptSounds),// sndHellishImpact4 - (FileName: 'melonimpact.ogg'; Path: ptSounds),// sndMelonImpact - (FileName: 'Droplet1.ogg'; Path: ptSounds),// sndDroplet1 - (FileName: 'Droplet2.ogg'; Path: ptSounds),// sndDroplet2 - (FileName: 'Droplet3.ogg'; Path: ptSounds),// sndDroplet3 - (FileName: 'egg.ogg'; Path: ptSounds),// sndEggBreak - (FileName: 'drillgun.ogg'; Path: ptSounds),// sndDrillRocket - (FileName: 'PoisonCough.ogg'; Path: ptVoices),// sndPoisonCough - (FileName: 'PoisonMoan.ogg'; Path: ptVoices),// sndPoisonMoan - (FileName: 'BirdyLay.ogg'; Path: ptSounds),// sndBirdyLay - (FileName: 'Whistle.ogg'; Path: ptSounds),// sndWhistle - (FileName: 'beewater.ogg'; Path: ptSounds),// sndBeeWater - (FileName: '1C.ogg'; Path: ptSounds),// sndPiano0 - (FileName: '2D.ogg'; Path: ptSounds),// sndPiano1 - (FileName: '3E.ogg'; Path: ptSounds),// sndPiano2 - (FileName: '4F.ogg'; Path: ptSounds),// sndPiano3 - (FileName: '5G.ogg'; Path: ptSounds),// sndPiano4 - (FileName: '6A.ogg'; Path: ptSounds),// sndPiano5 - (FileName: '7B.ogg'; Path: ptSounds),// sndPiano6 - (FileName: '8C.ogg'; Path: ptSounds),// sndPiano7 - (FileName: '9D.ogg'; Path: ptSounds),// sndPiano8 - (FileName: 'skip.ogg'; Path: ptSounds),// sndSkip - (FileName: 'sinegun.ogg'; Path: ptSounds),// sndSineGun - (FileName: 'Ooff1.ogg'; Path: ptVoices),// sndOoff1 - (FileName: 'Ooff2.ogg'; Path: ptVoices),// sndOoff2 - (FileName: 'Ooff3.ogg'; Path: ptVoices),// sndOoff3 - (FileName: 'hammer.ogg'; Path: ptSounds),// sndWhack - (FileName: 'Comeonthen.ogg'; Path: ptVoices),// sndComeonthen - (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: 'TARDIS.ogg'; Path: ptSounds) // sndTardis - ); var Ammoz: array [TAmmoType] of record NameId: TAmmoStrId; @@ -855,9 +726,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or - ammoprop_Power or - ammoprop_AltUse or + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or ammoprop_SetBounce or ammoprop_NeedUpDown; Count: AMMO_INFINITE; @@ -883,9 +754,9 @@ NameTex: nil; Probability: 100; NumberInCase: 3; - Ammo: (Propz: ammoprop_Timerable or - ammoprop_Power or - ammoprop_AltUse or + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or ammoprop_SetBounce or ammoprop_NeedUpDown; Count: 5; @@ -911,7 +782,7 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse or ammoprop_NeedUpDown; Count: AMMO_INFINITE; @@ -937,8 +808,8 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or - ammoprop_NeedTarget or + Ammo: (Propz: ammoprop_Power or + ammoprop_NeedTarget or ammoprop_DontHold or ammoprop_NeedUpDown; Count: 2; @@ -989,9 +860,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_AttackInMove or - ammoprop_NoCrosshair or + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_AttackInMove or + ammoprop_NoCrosshair or ammoprop_DontHold; Count: 2; NumPerTurn: 0; @@ -1016,7 +887,7 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold; Count: AMMO_INFINITE; NumPerTurn: 0; @@ -1070,10 +941,10 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_AttackInMove or - ammoprop_DontHold or - ammoprop_AltUse or + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_AttackInMove or + ammoprop_DontHold or + ammoprop_AltUse or ammoprop_SetBounce; Count: 2; NumPerTurn: 0; @@ -1122,9 +993,9 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_AttackInMove or - ammoprop_DontHold or + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_AttackInMove or + ammoprop_DontHold or ammoprop_AltUse; Count: 1; NumPerTurn: 0; @@ -1149,8 +1020,8 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_ForwMsgs or + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_ForwMsgs or ammoprop_AttackInMove; Count: AMMO_INFINITE; NumPerTurn: 0; @@ -1445,8 +1316,8 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_DontHold or + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_DontHold or ammoprop_NeedUpDown or ammoprop_AttackInMove; Count: 1; @@ -1472,8 +1343,8 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_NoCrosshair or + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Track; Count: 1; @@ -1499,7 +1370,7 @@ NameTex: nil; Probability: 100; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_NoCrosshair; Count: 1; @@ -1525,8 +1396,8 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or - ammoprop_Power or + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or ammoprop_NeedUpDown or ammoprop_AltUse; Count: 0; @@ -1552,7 +1423,7 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or + Ammo: (Propz: ammoprop_Power or ammoprop_NeedUpDown or ammoprop_AltUse; Count: 0; @@ -1606,7 +1477,7 @@ NameTex: nil; Probability: 300; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or + Ammo: (Propz: ammoprop_Power or ammoprop_NeedUpDown or ammoprop_AltUse; Count: AMMO_INFINITE; @@ -1632,7 +1503,7 @@ NameTex: nil; Probability: 400; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NeedUpDown or ammoprop_DontHold; Count: AMMO_INFINITE; @@ -1860,7 +1731,7 @@ NameTex: nil; Probability: 20; NumberInCase: 2; - Ammo: (Propz: ammoprop_NeedUpDown or + Ammo: (Propz: ammoprop_NeedUpDown or ammoprop_OscAim or ammoprop_NoMoveAfter; Count: 2; @@ -1917,7 +1788,7 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or + Ammo: (Propz: ammoprop_Power or ammoprop_NeedUpDown or ammoprop_AltUse; Count: AMMO_INFINITE; @@ -2026,9 +1897,9 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or - ammoprop_Power or - ammoprop_AltUse or + Ammo: (Propz: ammoprop_Timerable or + ammoprop_Power or + ammoprop_AltUse or ammoprop_NeedUpDown or ammoprop_SetBounce; Count: AMMO_INFINITE; @@ -2079,7 +1950,7 @@ NameTex: nil; Probability: 20; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NeedUpDown or ammoprop_DontHold; Count: 1; @@ -2210,7 +2081,7 @@ NameTex: nil; Probability: 0; NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse or ammoprop_NoRoundEnd; Count: 2; @@ -2228,7 +2099,7 @@ SkipTurns: 0; PosCount: 1; PosSprite: sprWater; - ejectX: 0; + ejectX: 0; ejectY: 0), // Tardis @@ -2258,7 +2129,8 @@ ejectX: 0; ejectY: 0), -// Structure +// Structure +{ (NameId: sidStructure; NameTex: nil; Probability: 0; @@ -2284,7 +2156,8 @@ PosSprite: sprWater; ejectX: 0; ejectY: 0), - +} + // Land Gun (NameId: sidLandGun; NameTex: nil; @@ -2314,7 +2187,7 @@ NameTex: nil; Probability: 20; NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NeedUpDown or ammoprop_DontHold; Count: 1; @@ -2361,76 +2234,6 @@ ejectY: 0) ); -const - GearKindAmmoTypeMap : array [TGearType] of TAmmoType = ( -(* gtFlame *) amNothing -(* gtHedgehog *) , amNothing -(* gtMine *) , amMine -(* gtCase *) , amNothing -(* gtExplosives *) , amNothing -(* gtGrenade *) , amGrenade -(* gtShell *) , amBazooka -(* gtGrave *) , amNothing -(* gtBee *) , amBee -(* gtShotgunShot *) , amShotgun -(* gtPickHammer *) , amPickHammer -(* gtRope *) , amRope -(* gtDEagleShot *) , amDEagle -(* gtDynamite *) , amDynamite -(* gtClusterBomb *) , amClusterBomb -(* gtCluster *) , amClusterBomb -(* gtShover *) , amBaseballBat // Shover is only used for baseball bat right now -(* gtFirePunch *) , amFirePunch -(* gtATStartGame *) , amNothing -(* gtATFinishGame *) , amNothing -(* gtParachute *) , amParachute -(* gtAirAttack *) , amAirAttack -(* gtAirBomb *) , amAirAttack -(* gtBlowTorch *) , amBlowTorch -(* gtGirder *) , amGirder -(* gtTeleport *) , amTeleport -(* gtSwitcher *) , amSwitch -(* gtTarget *) , amNothing -(* gtMortar *) , amMortar -(* gtWhip *) , amWhip -(* gtKamikaze *) , amKamikaze -(* gtCake *) , amCake -(* gtSeduction *) , amSeduction -(* gtWatermelon *) , amWatermelon -(* gtMelonPiece *) , amWatermelon -(* gtHellishBomb *) , amHellishBomb -(* gtWaterUp *) , amNothing -(* gtDrill *) , amDrill -(* gtBallGun *) , amBallgun -(* gtBall *) , amBallgun -(* gtRCPlane *) , amRCPlane -(*gtSniperRifleShot *) , amSniperRifle -(* gtJetpack *) , amJetpack -(* gtMolotov *) , amMolotov -(* gtBirdy *) , amBirdy -(* gtEgg *) , amBirdy -(* gtPortal *) , amPortalGun -(* gtPiano *) , amPiano -(* gtGasBomb *) , amGasBomb -(* gtSineGunShot *) , amSineGun -(* gtFlamethrower *) , amFlamethrower -(* gtSMine *) , amSMine -(* gtPoisonCloud *) , amNothing -(* gtHammer *) , amHammer -(* gtHammerHit *) , amHammer -(* gtResurrector *) , amResurrector -(* gtPoisonCloud *) , amNothing -(* gtSnowball *) , amSnowball -(* gtFlake *) , amNothing -(* 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 Land: TCollisionArray; LandPixels: TLandArray; @@ -2464,7 +2267,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; - NextClan: boolean; FollowGear: PGear; WindBarWidth: LongInt; @@ -2475,13 +2277,9 @@ WaterColor, DeepWaterColor: TSDL_Color; SkyColor, RQSkyColor, SDSkyColor: TSDL_Color; SkyOffset: LongInt; - HorizontOffset: LongInt; {$IFDEF COUNTTICKS} cntTicks: LongWord; {$ENDIF} - cOffsetY: LongInt; - AFRToggle: Boolean; - bAFRRight: Boolean; PauseTexture, @@ -2491,9 +2289,6 @@ cStereoDepth: GLfloat; SupportNPOTT: Boolean; Step: LongInt; - squaresize : LongInt; - numsquares : LongInt; - ProgrTex: PTexture; MissionIcons: PSDL_Surface; ropeIconTex: PTexture; @@ -2505,24 +2300,12 @@ defaultFrame, depthv: GLuint; texv: GLuint; - VisualGearLayers: array[0..6] of PVisualGear; lastVisualGearByUID: PVisualGear; vobFrameTicks, vobFramesCount, vobCount: Longword; vobVelocity, vobFallSpeed: LongInt; vobSDFrameTicks, vobSDFramesCount, vobSDCount: Longword; vobSDVelocity, vobSDFallSpeed: LongInt; - ControllerNumControllers: Integer; - ControllerEnabled: Integer; - ControllerNumAxes: array[0..5] of Integer; - //ControllerNumBalls: array[0..5] of Integer; - ControllerNumHats: array[0..5] of Integer; - ControllerNumButtons: array[0..5] of Integer; - ControllerAxes: array[0..5] of array[0..19] of Integer; - //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; - ControllerHats: array[0..5] of array[0..19] of Byte; - ControllerButtons: array[0..5] of array[0..19] of Byte; - DefaultBinds : TBinds; lastTurnChecksum : Longword; @@ -2563,7 +2346,6 @@ cScreenWidth := 1024; cScreenHeight := 768; - cBits := 32; cShowFPS := false; cAltDamage := true; cTimerInterval := 8; @@ -2723,7 +2505,7 @@ cHasFocus := true; cInactDelay := 100; ReadyTimeLeft := 0; - + disableLandBack := false; ScreenFade := sfNone; @@ -2764,6 +2546,19 @@ aVertex:= 0; aTexCoord:= 1; aColor:= 2; + + mobileRecord.getScreenDPI:= @getScreenDPI; //TODO: define external function. + {$IFDEF IPHONEOS} + mobileRecord.PerformRumble:= @AudioServicesPlaySystemSound; + mobileRecord.GameLoading:= @startLoadingIndicator; + mobileRecord.GameLoaded:= @stopLoadingIndicator; + mobileRecord.SaveLoadingEnded:= @saveFinishedSynching; + {$ELSE} + mobileRecord.PerformRumble:= nil; + mobileRecord.GameLoading:= nil; + mobileRecord.GameLoaded:= nil; + mobileRecord.SaveLoadingEnded:= nil; + {$ENDIF} end; procedure freeModule; diff -r d24257910f8d -r aaefa587e277 hedgewars/uVideoRec.pas --- a/hedgewars/uVideoRec.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uVideoRec.pas Tue Dec 25 04:45:22 2012 +0100 @@ -30,11 +30,6 @@ {$IFNDEF WIN32} {$LINKLIB ../bin/libavwrapper.a} {$ENDIF} -{$IFDEF DARWIN} - {$LINKLIB bz2} - {$LINKFRAMEWORK CoreVideo} - {$LINKFRAMEWORK VideoDecodeAcceleration} -{$ENDIF} interface diff -r d24257910f8d -r aaefa587e277 hedgewars/uVisualGears.pas --- a/hedgewars/uVisualGears.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uVisualGears.pas Tue Dec 25 04:45:22 2012 +0100 @@ -53,10 +53,13 @@ procedure KickFlakes(Radius, X, Y: LongInt); implementation -uses uSound, uMobile, uVariables, uTextures, uRender, Math, uRenderUtils, uStore, uUtils; +uses uSound, uVariables, uTextures, uRender, Math, uRenderUtils, uStore, uUtils; -const cExplFrameTicks = 110; +const + cExplFrameTicks = 110; + cSmokeZ = 499; var VGCounter: LongWord; + VisualGearLayers: array[0..6] of PVisualGear; // For better maintainability the step handlers of visual gears are stored // in a separate file. @@ -151,7 +154,7 @@ vgtEvilTrace, vgtNote, vgtSmoothWindBar])) then - + exit; inc(VGCounter); @@ -365,7 +368,7 @@ if random(2) = 0 then dx := -dx; end; - vgtNote: + vgtNote: begin dx:= 0.005 * (random(15) + 10); dy:= -0.001 * (random(40) + 20); @@ -382,7 +385,7 @@ Frame:= 7; Angle:= 0; end; -vgtSmoothWindBar: +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); @@ -408,7 +411,7 @@ case Gear^.Kind of vgtFlake: if cFlattenFlakes then gear^.Layer:= 0 - else if random(3) = 0 then + else if random(3) = 0 then begin gear^.Scale:= 0.5; gear^.Layer:= 0 // 33% - far back @@ -699,9 +702,9 @@ DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); end; vgtSmallDamageTag: DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex); - vgtHealthTag: if Gear^.Tex <> nil then + vgtHealthTag: if Gear^.Tex <> nil then begin - if Gear^.Frame = 0 then + if Gear^.Frame = 0 then DrawTextureCentered(round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy, Gear^.Tex) else begin @@ -709,11 +712,11 @@ 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); + DrawTexture(round(Gear^.X), round(Gear^.Y), Gear^.Tex, Gear^.Angle); SetScale(zoom) end end; - vgtStraightShot: begin + vgtStraightShot: begin if Gear^.dX < 0 then i:= -1 else diff -r d24257910f8d -r aaefa587e277 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uWorld.pas Tue Dec 25 04:45:22 2012 +0100 @@ -60,10 +60,9 @@ , uCaptions , uCursor , uCommands - , uMobile -{$IFDEF USE_VIDEO_RECORDING} +{$IFDEF USE_VIDEO_RECORDING} , uVideoRec -{$ENDIF} +{$ENDIF} {$IFDEF GL2} , uMatrix {$ENDIF} @@ -87,6 +86,10 @@ isFirstFrame: boolean; AMAnimType: LongInt; recTexture: PTexture; + AmmoMenuTex : PTexture; + HorizontOffset: LongInt; + cOffsetY: LongInt; + AFRToggle: Boolean; const cStereo_Sky = 0.0500; cStereo_Horizon = 0.0250; @@ -96,6 +99,28 @@ cStereo_Water_near = 0.0025; cStereo_Outside = -0.0400; + 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; + + cSendCursorPosTime = 50; + cCursorEdgesDist = 100; + // helper functions to create the goal/game mode string function AddGoal(s: ansistring; gf: longword; si: TGoalStrId; i: LongInt): ansistring; var t: ansistring; @@ -223,7 +248,7 @@ {$IFDEF USE_TOUCH_INTERFACE} //positioning of the buttons -buttonScale:= uMobile.getScreenDPI/cDefaultZoomLevel; +buttonScale:= mobileRecord.getScreenDPI()/cDefaultZoomLevel; with JumpWidget do @@ -418,14 +443,14 @@ 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 @@ -459,25 +484,25 @@ AMFrame:= LongInt(Ammo^[i,t].AmmoType) - 1; if STurns >= 0 then //weapon not usable yet, draw grayed out with turns remaining begin - DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, + DrawSpriteFrame2Surf(sprAMAmmosBW, amSurface, x + AMSlotPadding, y + AMSlotPadding, AMFrame); if STurns < 100 then - DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, - x + AMSlotSize-16, + DrawSpriteFrame2Surf(sprTurnsLeft, amSurface, + x + AMSlotSize-16, y + AMSlotSize + 1 - 16, STurns); end else //draw colored version begin - DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, + DrawSpriteFrame2Surf(sprAMAmmos, amSurface, x + AMSlotPadding, y + AMSlotPadding, AMFrame); end; {$IFDEF USE_LANDSCAPE_AMMOMENU} - inc(y, AMSlotSize + 1); //the plus one is for the border + inc(y, AMSlotSize + 1); //the plus one is for the border {$ELSE} - inc(x, AMSlotSize + 1); + inc(x, AMSlotSize + 1); {$ENDIF} - end; - end; + end; + end; {$IFDEF USE_LANDSCAPE_AMMOMENU} inc(x, AMSlotSize + 1); {$ELSE} @@ -486,7 +511,7 @@ 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); +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); @@ -531,8 +556,8 @@ exit end; -//Init the menu -if(AmmoMenuInvalidated) then +//Init the menu +if(AmmoMenuInvalidated) then begin AmmoMenuInvalidated:= false; FreeTexture(AmmoMenuTex); @@ -588,7 +613,7 @@ begin AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState)); AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState)); - if (AMAnimType and AMTypeMaskAlpha) <> 0 then + if (AMAnimType and AMTypeMaskAlpha) <> 0 then Tint($FF, $ff, $ff, Round($ff * AMAnimState)); end else @@ -613,10 +638,10 @@ begin AMShiftX:= Round(AMShiftTargetX * AMAnimState); AMShiftY:= Round(AMShiftTargetY * AMAnimState); - if (AMAnimType and AMTypeMaskAlpha) <> 0 then + if (AMAnimType and AMTypeMaskAlpha) <> 0 then Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState))); end - else + else begin AMShiftX:= AMShiftTargetX; AMShiftY:= AMShiftTargetY; @@ -624,10 +649,10 @@ AMState:= AMHidden; end; end; - + DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex); -if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then +if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then Tint($FF, $ff, $ff, $ff); Pos:= -1; @@ -648,15 +673,15 @@ begin 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 * (AMSlotSize+1))) and (CursorPoint.X <= AmmoRect.x + ((c+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 + (c * (AMSlotSize+1)) + AMSlotPadding, + DrawSprite(sprAMSlot, + AmmoRect.x + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding, AmmoRect.y + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding -1, 0); end; inc(g); @@ -678,15 +703,15 @@ 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 * (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, + DrawSprite(sprAMSlot, + AmmoRect.x + BORDERSIZE + (g * (AMSlotSize+1)) + AMSlotPadding, AmmoRect.y + BORDERSIZE + (c * (AMSlotSize+1)) + AMSlotPadding -1, 0); end; inc(g); @@ -759,8 +784,8 @@ procedure DrawWater(Alpha: byte; OffsetY: LongInt); var VertexBuffer : array [0..3] of TVertex2f; - r : TSDL_Rect; - lw, lh : GLfloat; + r : TSDL_Rect; + lw, lh : GLfloat; begin if SuddenDeathDmg then begin @@ -786,7 +811,7 @@ begin if r.y < 0 then r.y:= 0; - + glDisable(GL_TEXTURE_2D); VertexBuffer[0].X:= -lw; VertexBuffer[0].Y:= r.y; @@ -991,7 +1016,7 @@ glClear(GL_COLOR_BUFFER_BIT); DrawWorldStereo(Lag, rmDefault) end -{$IFNDEF S3D_DISABLED} +{$IFDEF USE_S3D_RENDERING} else if (cStereoMode = smAFR) then begin AFRToggle:= (not AFRToggle); @@ -1104,7 +1129,7 @@ procedure ChangeDepth(rm: TRenderMode; d: GLfloat); begin -{$IFDEF S3D_DISABLED} +{$IFNDEF USE_S3D_RENDERING} rm:= rm; d:= d; // avoid hint exit; {$ELSE} @@ -1126,16 +1151,19 @@ {$ENDIF} {$ENDIF} end; - + procedure ResetDepth(rm: TRenderMode); begin -{$IFNDEF S3D_DISABLED} +{$IFNDEF USE_S3D_RENDERING} + rm:= rm; // avoid hint + exit; +{$ELSE} if rm = rmDefault then exit; {$IFDEF GL2} hglMatrixMode(MATRIX_PROJECTION); hglTranslatef(-stereoDepth, 0, 0); - hglMatrixMode(MATRIX_MODELVIEW); + hglMatrixMode(MATRIX_MODELVIEW); {$ELSE} glMatrixMode(GL_PROJECTION); glTranslatef(-stereoDepth, 0, 0); @@ -1144,7 +1172,7 @@ cStereoDepth:= 0; {$ENDIF} end; - + procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode); var i, t, h: LongInt; r: TSDL_Rect; @@ -1182,7 +1210,7 @@ if (cReducedQuality and rq2DWater) = 0 then begin // Waves - DrawWater(255, SkyOffset); + DrawWater(255, SkyOffset); ChangeDepth(RM, -cStereo_Water_distant); DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64); ChangeDepth(RM, -cStereo_Water_distant); @@ -1299,7 +1327,7 @@ i:= Succ(Pred(ReadyTimeLeft) div 1000) else i:= Succ(Pred(TurnTimeLeft) div 1000); - + if i>99 then t:= 112 else if i>9 then @@ -1479,7 +1507,7 @@ else AMAnimStartTime:= RealTicks - (AMAnimDuration - (RealTicks - AMAnimStartTime)); AMState:= AMHiding; - end; + end; if bShowAmmoMenu or (AMState = AMHiding) then ShowAmmoMenu; @@ -1533,8 +1561,8 @@ if t < 10 then s:= '0' + s; s:= inttostr(i div 60) + ':' + s; - - + + tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels); tmpSurface:= doSurfaceConversion(tmpSurface); FreeTexture(timeTexture); @@ -1639,7 +1667,7 @@ DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); // draw red circle - glDisable(GL_TEXTURE_2D); + 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 @@ -1748,7 +1776,7 @@ {$ENDIF} {$ENDIF} - if CursorPoint.X < AmmoRect.x + amNumOffsetX + 3 then//check left + 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; @@ -1895,7 +1923,7 @@ begin utilityWidget.sprite:= sprTimerButton; animateWidget(@utilityWidget, true, true); - end + end else if (Ammoz[ammoType].Ammo.Propz and ammoprop_NeedTarget) <> 0 then begin utilityWidget.sprite:= sprTargetButton; @@ -1919,7 +1947,7 @@ begin show:= showWidget; if fade then fadeAnimStart:= RealTicks; - + with moveAnim do begin animate:= true; diff -r d24257910f8d -r aaefa587e277 misc/liblua/CMakeLists.txt --- a/misc/liblua/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/liblua/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -11,7 +11,7 @@ set(LUA_LIBRARY lua.dll) set_target_properties(lua PROPERTIES PREFIX "") - install(TARGETS lua RUNTIME DESTINATION ${target_dir}) + install(TARGETS lua RUNTIME DESTINATION ${target_library_install_dir}) else(WIN32) add_definitions(-DLUA_USE_LINUX) add_library(lua STATIC ${lua_src}) diff -r d24257910f8d -r aaefa587e277 misc/libopenalbridge/CMakeLists.txt --- a/misc/libopenalbridge/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/libopenalbridge/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -15,14 +15,14 @@ #visualstudio and windows in general don't like static linking, so we're building the library in shared mode if(WIN32) #workaround for visualstudio (wants headers in the source list) - set(openal_src *.h ${openal_src}) + set(openal_src *.h ${openal_src}) #deps for the shared library - link_libraries(${VORBISFILE_LIBRARY}) - link_libraries(${VORBIS_LIBRARY}) - link_libraries(${OGG_LIBRARY}) - link_libraries(${OPENAL_LIBRARY}) + link_libraries(${VORBISFILE_LIBRARY}) + link_libraries(${VORBIS_LIBRARY}) + link_libraries(${OGG_LIBRARY}) + link_libraries(${OPENAL_LIBRARY}) #build a shared library - set (build_type SHARED) + set (build_type SHARED) endif() #compiles and links actual library @@ -30,10 +30,10 @@ if(WIN32) if(MSVC) - SET_TARGET_PROPERTIES(openalbridge PROPERTIES LINK_FLAGS /DEF:openalbridge.def) + set_target_properties(openalbridge PROPERTIES LINK_FLAGS /DEF:openalbridge.def) endif(MSVC) #install it in the executable directory - install(TARGETS openalbridge DESTINATION bin) + install(TARGETS openalbridge DESTINATION bin) endif(WIN32) #type make openalbridge_test to get a small executable test diff -r d24257910f8d -r aaefa587e277 misc/physfs/CMakeLists.txt --- a/misc/physfs/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/physfs/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -16,6 +16,7 @@ SET(WINDOWS TRUE) ENDIF(WIN32 AND NOT WINDOWS) + # Bleh, let's do it for "APPLE" too. IF(APPLE AND NOT MACOSX) SET(MACOSX TRUE) @@ -48,7 +49,7 @@ # Need these everywhere... ADD_DEFINITIONS(-fno-common) - SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework Carbon -framework IOKit") + SET(OTHER_LDFLAGS ${OTHER_LDFLAGS} "-framework IOKit") ENDIF(MACOSX) # Add some gcc-specific command lines. @@ -285,6 +286,8 @@ TARGET_LINK_LIBRARIES(physfs ${OPTIONAL_LIBRARY_LIBS} ${OTHER_LDFLAGS}) SET(PHYSFS_LIB_TARGET physfs) SET(PHYSFS_INSTALL_TARGETS ${PHYSFS_INSTALL_TARGETS} ";physfs") + INSTALL(TARGETS ${PHYSFS_INSTALL_TARGETS} + RUNTIME DESTINATION ${target_library_install_dir}) ENDIF(PHYSFS_BUILD_SHARED) IF(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC) diff -r d24257910f8d -r aaefa587e277 misc/physfs/Xcode/Physfs.xcodeproj/project.pbxproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/physfs/Xcode/Physfs.xcodeproj/project.pbxproj Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,354 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 610FB79016613776002FB2A7 /* archiver_dir.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77916613776002FB2A7 /* archiver_dir.c */; }; + 610FB79116613776002FB2A7 /* archiver_grp.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77A16613776002FB2A7 /* archiver_grp.c */; }; + 610FB79216613776002FB2A7 /* archiver_hog.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77B16613776002FB2A7 /* archiver_hog.c */; }; + 610FB79316613776002FB2A7 /* archiver_iso9660.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77C16613776002FB2A7 /* archiver_iso9660.c */; }; + 610FB79416613776002FB2A7 /* archiver_lzma.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77D16613776002FB2A7 /* archiver_lzma.c */; }; + 610FB79516613776002FB2A7 /* archiver_mvl.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77E16613776002FB2A7 /* archiver_mvl.c */; }; + 610FB79616613776002FB2A7 /* archiver_qpak.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB77F16613776002FB2A7 /* archiver_qpak.c */; }; + 610FB79716613776002FB2A7 /* archiver_unpacked.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78016613776002FB2A7 /* archiver_unpacked.c */; }; + 610FB79816613776002FB2A7 /* archiver_wad.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78116613776002FB2A7 /* archiver_wad.c */; }; + 610FB79916613776002FB2A7 /* archiver_zip.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78216613776002FB2A7 /* archiver_zip.c */; }; + 610FB79A16613776002FB2A7 /* physfs_byteorder.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78316613776002FB2A7 /* physfs_byteorder.c */; }; + 610FB79B16613776002FB2A7 /* physfs_casefolding.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB78416613776002FB2A7 /* physfs_casefolding.h */; }; + 610FB79C16613776002FB2A7 /* physfs_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB78516613776002FB2A7 /* physfs_internal.h */; }; + 610FB79D16613776002FB2A7 /* physfs_miniz.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB78616613776002FB2A7 /* physfs_miniz.h */; }; + 610FB79E16613776002FB2A7 /* physfs_platforms.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB78716613776002FB2A7 /* physfs_platforms.h */; }; + 610FB79F16613776002FB2A7 /* physfs_unicode.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78816613776002FB2A7 /* physfs_unicode.c */; }; + 610FB7A016613776002FB2A7 /* physfs.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78916613776002FB2A7 /* physfs.c */; }; + 610FB7A116613776002FB2A7 /* physfs.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB78A16613776002FB2A7 /* physfs.h */; }; + 610FB7A216613776002FB2A7 /* platform_beos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78B16613776002FB2A7 /* platform_beos.cpp */; }; + 610FB7A316613776002FB2A7 /* platform_macosx.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78C16613776002FB2A7 /* platform_macosx.c */; }; + 610FB7A416613776002FB2A7 /* platform_posix.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78D16613776002FB2A7 /* platform_posix.c */; }; + 610FB7A516613776002FB2A7 /* platform_unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78E16613776002FB2A7 /* platform_unix.c */; }; + 610FB7A616613776002FB2A7 /* platform_windows.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB78F16613776002FB2A7 /* platform_windows.c */; }; + 610FB7AE16613813002FB2A7 /* hwpacksmounter.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB7A916613813002FB2A7 /* hwpacksmounter.c */; }; + 610FB7AF16613813002FB2A7 /* hwpacksmounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB7AA16613813002FB2A7 /* hwpacksmounter.h */; }; + 610FB7B016613813002FB2A7 /* physfslualoader.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB7AB16613813002FB2A7 /* physfslualoader.c */; }; + 610FB7B116613813002FB2A7 /* physfsrwops.c in Sources */ = {isa = PBXBuildFile; fileRef = 610FB7AC16613813002FB2A7 /* physfsrwops.c */; }; + 610FB7B216613813002FB2A7 /* physfsrwops.h in Headers */ = {isa = PBXBuildFile; fileRef = 610FB7AD16613813002FB2A7 /* physfsrwops.h */; }; + AA747D9F0F9514B9006C5449 /* Physfs_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Physfs_Prefix.pch */; }; + AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 610FB77916613776002FB2A7 /* archiver_dir.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_dir.c; path = ../src/archiver_dir.c; sourceTree = SOURCE_ROOT; }; + 610FB77A16613776002FB2A7 /* archiver_grp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_grp.c; path = ../src/archiver_grp.c; sourceTree = SOURCE_ROOT; }; + 610FB77B16613776002FB2A7 /* archiver_hog.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_hog.c; path = ../src/archiver_hog.c; sourceTree = SOURCE_ROOT; }; + 610FB77C16613776002FB2A7 /* archiver_iso9660.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_iso9660.c; path = ../src/archiver_iso9660.c; sourceTree = SOURCE_ROOT; }; + 610FB77D16613776002FB2A7 /* archiver_lzma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_lzma.c; path = ../src/archiver_lzma.c; sourceTree = SOURCE_ROOT; }; + 610FB77E16613776002FB2A7 /* archiver_mvl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_mvl.c; path = ../src/archiver_mvl.c; sourceTree = SOURCE_ROOT; }; + 610FB77F16613776002FB2A7 /* archiver_qpak.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_qpak.c; path = ../src/archiver_qpak.c; sourceTree = SOURCE_ROOT; }; + 610FB78016613776002FB2A7 /* archiver_unpacked.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_unpacked.c; path = ../src/archiver_unpacked.c; sourceTree = SOURCE_ROOT; }; + 610FB78116613776002FB2A7 /* archiver_wad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_wad.c; path = ../src/archiver_wad.c; sourceTree = SOURCE_ROOT; }; + 610FB78216613776002FB2A7 /* archiver_zip.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = archiver_zip.c; path = ../src/archiver_zip.c; sourceTree = SOURCE_ROOT; }; + 610FB78316613776002FB2A7 /* physfs_byteorder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = physfs_byteorder.c; path = ../src/physfs_byteorder.c; sourceTree = SOURCE_ROOT; }; + 610FB78416613776002FB2A7 /* physfs_casefolding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfs_casefolding.h; path = ../src/physfs_casefolding.h; sourceTree = SOURCE_ROOT; }; + 610FB78516613776002FB2A7 /* physfs_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfs_internal.h; path = ../src/physfs_internal.h; sourceTree = SOURCE_ROOT; }; + 610FB78616613776002FB2A7 /* physfs_miniz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfs_miniz.h; path = ../src/physfs_miniz.h; sourceTree = SOURCE_ROOT; }; + 610FB78716613776002FB2A7 /* physfs_platforms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfs_platforms.h; path = ../src/physfs_platforms.h; sourceTree = SOURCE_ROOT; }; + 610FB78816613776002FB2A7 /* physfs_unicode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = physfs_unicode.c; path = ../src/physfs_unicode.c; sourceTree = SOURCE_ROOT; }; + 610FB78916613776002FB2A7 /* physfs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = physfs.c; path = ../src/physfs.c; sourceTree = SOURCE_ROOT; }; + 610FB78A16613776002FB2A7 /* physfs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfs.h; path = ../src/physfs.h; sourceTree = SOURCE_ROOT; }; + 610FB78B16613776002FB2A7 /* platform_beos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = platform_beos.cpp; path = ../src/platform_beos.cpp; sourceTree = SOURCE_ROOT; }; + 610FB78C16613776002FB2A7 /* platform_macosx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = platform_macosx.c; path = ../src/platform_macosx.c; sourceTree = SOURCE_ROOT; }; + 610FB78D16613776002FB2A7 /* platform_posix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = platform_posix.c; path = ../src/platform_posix.c; sourceTree = SOURCE_ROOT; }; + 610FB78E16613776002FB2A7 /* platform_unix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = platform_unix.c; path = ../src/platform_unix.c; sourceTree = SOURCE_ROOT; }; + 610FB78F16613776002FB2A7 /* platform_windows.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = platform_windows.c; path = ../src/platform_windows.c; sourceTree = SOURCE_ROOT; }; + 610FB7A916613813002FB2A7 /* hwpacksmounter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hwpacksmounter.c; path = ../extras/hwpacksmounter.c; sourceTree = SOURCE_ROOT; }; + 610FB7AA16613813002FB2A7 /* hwpacksmounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hwpacksmounter.h; path = ../extras/hwpacksmounter.h; sourceTree = SOURCE_ROOT; }; + 610FB7AB16613813002FB2A7 /* physfslualoader.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = physfslualoader.c; path = ../extras/physfslualoader.c; sourceTree = SOURCE_ROOT; }; + 610FB7AC16613813002FB2A7 /* physfsrwops.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = physfsrwops.c; path = ../extras/physfsrwops.c; sourceTree = SOURCE_ROOT; }; + 610FB7AD16613813002FB2A7 /* physfsrwops.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = physfsrwops.h; path = ../extras/physfsrwops.h; sourceTree = SOURCE_ROOT; }; + AA747D9E0F9514B9006C5449 /* Physfs_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Physfs_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 /* libPhysfs.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPhysfs.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 /* libPhysfs.a */, + ); + name = Products; + sourceTree = ""; + }; + 0867D691FE84028FC02AAC07 /* Physfs */ = { + isa = PBXGroup; + children = ( + 08FB77AEFE84172EC02AAC07 /* Sources */, + 610FB77116613730002FB2A7 /* Extras */, + 32C88DFF0371C24200C91783 /* Other Sources */, + 0867D69AFE84028FC02AAC07 /* Frameworks */, + 034768DFFF38A50411DB9C8B /* Products */, + ); + name = Physfs; + sourceTree = ""; + }; + 0867D69AFE84028FC02AAC07 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AACBBE490F95108600F1A2B1 /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 08FB77AEFE84172EC02AAC07 /* Sources */ = { + isa = PBXGroup; + children = ( + 610FB77916613776002FB2A7 /* archiver_dir.c */, + 610FB77A16613776002FB2A7 /* archiver_grp.c */, + 610FB77B16613776002FB2A7 /* archiver_hog.c */, + 610FB77C16613776002FB2A7 /* archiver_iso9660.c */, + 610FB77D16613776002FB2A7 /* archiver_lzma.c */, + 610FB77E16613776002FB2A7 /* archiver_mvl.c */, + 610FB77F16613776002FB2A7 /* archiver_qpak.c */, + 610FB78016613776002FB2A7 /* archiver_unpacked.c */, + 610FB78116613776002FB2A7 /* archiver_wad.c */, + 610FB78216613776002FB2A7 /* archiver_zip.c */, + 610FB78316613776002FB2A7 /* physfs_byteorder.c */, + 610FB78416613776002FB2A7 /* physfs_casefolding.h */, + 610FB78516613776002FB2A7 /* physfs_internal.h */, + 610FB78616613776002FB2A7 /* physfs_miniz.h */, + 610FB78716613776002FB2A7 /* physfs_platforms.h */, + 610FB78816613776002FB2A7 /* physfs_unicode.c */, + 610FB78916613776002FB2A7 /* physfs.c */, + 610FB78A16613776002FB2A7 /* physfs.h */, + 610FB78B16613776002FB2A7 /* platform_beos.cpp */, + 610FB78C16613776002FB2A7 /* platform_macosx.c */, + 610FB78D16613776002FB2A7 /* platform_posix.c */, + 610FB78E16613776002FB2A7 /* platform_unix.c */, + 610FB78F16613776002FB2A7 /* platform_windows.c */, + ); + name = Sources; + sourceTree = ""; + }; + 32C88DFF0371C24200C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + AA747D9E0F9514B9006C5449 /* Physfs_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 610FB77116613730002FB2A7 /* Extras */ = { + isa = PBXGroup; + children = ( + 610FB7A916613813002FB2A7 /* hwpacksmounter.c */, + 610FB7AA16613813002FB2A7 /* hwpacksmounter.h */, + 610FB7AB16613813002FB2A7 /* physfslualoader.c */, + 610FB7AC16613813002FB2A7 /* physfsrwops.c */, + 610FB7AD16613813002FB2A7 /* physfsrwops.h */, + ); + name = Extras; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC07A0554694100DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + AA747D9F0F9514B9006C5449 /* Physfs_Prefix.pch in Headers */, + 610FB79B16613776002FB2A7 /* physfs_casefolding.h in Headers */, + 610FB79C16613776002FB2A7 /* physfs_internal.h in Headers */, + 610FB79D16613776002FB2A7 /* physfs_miniz.h in Headers */, + 610FB79E16613776002FB2A7 /* physfs_platforms.h in Headers */, + 610FB7A116613776002FB2A7 /* physfs.h in Headers */, + 610FB7AF16613813002FB2A7 /* hwpacksmounter.h in Headers */, + 610FB7B216613813002FB2A7 /* physfsrwops.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + D2AAC07D0554694100DB518D /* Physfs */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Physfs" */; + buildPhases = ( + D2AAC07A0554694100DB518D /* Headers */, + D2AAC07B0554694100DB518D /* Sources */, + D2AAC07C0554694100DB518D /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Physfs; + productName = Physfs; + productReference = D2AAC07E0554694100DB518D /* libPhysfs.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 "Physfs" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 0867D691FE84028FC02AAC07 /* Physfs */; + productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D2AAC07D0554694100DB518D /* Physfs */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + D2AAC07B0554694100DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 610FB79016613776002FB2A7 /* archiver_dir.c in Sources */, + 610FB79116613776002FB2A7 /* archiver_grp.c in Sources */, + 610FB79216613776002FB2A7 /* archiver_hog.c in Sources */, + 610FB79316613776002FB2A7 /* archiver_iso9660.c in Sources */, + 610FB79416613776002FB2A7 /* archiver_lzma.c in Sources */, + 610FB79516613776002FB2A7 /* archiver_mvl.c in Sources */, + 610FB79616613776002FB2A7 /* archiver_qpak.c in Sources */, + 610FB79716613776002FB2A7 /* archiver_unpacked.c in Sources */, + 610FB79816613776002FB2A7 /* archiver_wad.c in Sources */, + 610FB79916613776002FB2A7 /* archiver_zip.c in Sources */, + 610FB79A16613776002FB2A7 /* physfs_byteorder.c in Sources */, + 610FB79F16613776002FB2A7 /* physfs_unicode.c in Sources */, + 610FB7A016613776002FB2A7 /* physfs.c in Sources */, + 610FB7A216613776002FB2A7 /* platform_beos.cpp in Sources */, + 610FB7A316613776002FB2A7 /* platform_macosx.c in Sources */, + 610FB7A416613776002FB2A7 /* platform_posix.c in Sources */, + 610FB7A516613776002FB2A7 /* platform_unix.c in Sources */, + 610FB7A616613776002FB2A7 /* platform_windows.c in Sources */, + 610FB7AE16613813002FB2A7 /* hwpacksmounter.c in Sources */, + 610FB7B016613813002FB2A7 /* physfslualoader.c in Sources */, + 610FB7B116613813002FB2A7 /* physfsrwops.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/Physfs.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 = Physfs_Prefix.pch; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Physfs; + }; + name = Debug; + }; + 1DEB922008733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + DSTROOT = /tmp/Physfs.dst; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Physfs_Prefix.pch; + INSTALL_PATH = /usr/local/lib; + PRODUCT_NAME = Physfs; + }; + name = Release; + }; + 1DEB922308733DC00010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../liblua\"", + "\"$(SRCROOT)/../../../../Library/SDL/include\"", + ); + OTHER_LDFLAGS = "-ObjC"; + PREBINDING = NO; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 1DEB922408733DC00010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../liblua\"", + "\"$(SRCROOT)/../../../../Library/SDL/include\"", + ); + OTHER_LDFLAGS = "-ObjC"; + PREBINDING = NO; + SDKROOT = iphoneos; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "Physfs" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB921F08733DC00010E9CD /* Debug */, + 1DEB922008733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "Physfs" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB922308733DC00010E9CD /* Debug */, + 1DEB922408733DC00010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 0867D690FE84028FC02AAC07 /* Project object */; +} diff -r d24257910f8d -r aaefa587e277 misc/physfs/Xcode/Physfs_Prefix.pch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/misc/physfs/Xcode/Physfs_Prefix.pch Tue Dec 25 04:45:22 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 d24257910f8d -r aaefa587e277 misc/physfs/extras/hwpacksmounter.c --- a/misc/physfs/extras/hwpacksmounter.c Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/physfs/extras/hwpacksmounter.c Tue Dec 25 04:45:22 2012 +0100 @@ -1,11 +1,10 @@ #include #include #include -#include "physfs.h" #include "hwpacksmounter.h" -void hedgewarsMountPackages() +PHYSFS_DECL void hedgewarsMountPackages() { char ** filesList = PHYSFS_enumerateFiles("/"); char **i; diff -r d24257910f8d -r aaefa587e277 misc/physfs/extras/hwpacksmounter.h --- a/misc/physfs/extras/hwpacksmounter.h Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/physfs/extras/hwpacksmounter.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,11 +1,13 @@ #ifndef HEDGEWARS_PACKAGES_MOUNTER_H #define HEDGEWARS_PACKAGES_MOUNTER_H +#include "physfs.h" + #ifdef __cplusplus extern "C" { #endif -void hedgewarsMountPackages(); +PHYSFS_DECL void hedgewarsMountPackages(); #ifdef __cplusplus diff -r d24257910f8d -r aaefa587e277 misc/physfs/extras/physfslualoader.c --- a/misc/physfs/extras/physfslualoader.c Sun Dec 02 00:03:16 2012 +0100 +++ b/misc/physfs/extras/physfslualoader.c Tue Dec 25 04:45:22 2012 +0100 @@ -5,7 +5,7 @@ void *physfsReaderBuffer; -const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size) +PHYSFS_DECL const char * physfsReader(lua_State *L, PHYSFS_File *f, size_t *size) { if(PHYSFS_eof(f)) @@ -23,7 +23,7 @@ } } -void physfsReaderSetBuffer(void *buffer) +PHYSFS_DECL void physfsReaderSetBuffer(void *buffer) { physfsReaderBuffer = buffer; } diff -r d24257910f8d -r aaefa587e277 project_files/Android-build/CMakeLists.txt --- a/project_files/Android-build/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/Android-build/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -18,7 +18,7 @@ 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") + message(FATAL_ERROR "Couldn't detect the Ant build tool") endif() if(NOT ANDROID_NDK) @@ -26,9 +26,9 @@ endif() if(IS_DIRECTORY "${ANDROID_NDK}") - MESSAGE(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) + message(STATUS "Detected the android NDK directory at: " ${ANDROID_NDK}) else () - MESSAGE(FATAL_ERROR "Couldn't detect the Android NDK directory") + message(FATAL_ERROR "Couldn't detect the Android NDK directory") endif() if(NOT ANDROID_NDK_TOOLCHAINDIR) @@ -39,9 +39,9 @@ endif() if(IS_DIRECTORY "${ANDROID_NDK_TOOLCHAINDIR}") - MESSAGE(STATUS "Detected the Android NDK toolchain at: ${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}") + 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 @@ -52,23 +52,23 @@ endif() if( IS_DIRECTORY "${ANDROID_SDK}") - MESSAGE(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) + message(STATUS "Detected the android SDK directory at: " ${ANDROID_SDK}) else () - MESSAGE(FATAL_ERROR "Couldn't detect the Android SDK directory") + message(FATAL_ERROR "Couldn't detect the Android SDK directory") endif() if( NOT FPC_DIR) find_program(FPC_DIR ppcrossarm) get_filename_component(FPC_DIR "${FPC_DIR}" PATH) - if(IS_DIRECTORY "${FPC_DIR}") - 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}") - MESSAGE(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}") + message(STATUS "Detected the FreePascal directory at: " "${FPC_DIR}") else () - MESSAGE(FATAL_ERROR "Couldn't detect the FreePascal directory") + message(FATAL_ERROR "Couldn't detect the FreePascal directory") endif() set(SDL_DIR /home/richard/Downloads/android-project) @@ -77,7 +77,7 @@ set(ANDROID_SDK_API_LVL 16) set(ANDROID_NDK_API_LVL 5) -MESSAGE(STATUS "Creating Makefile.android...") +message(STATUS "Creating Makefile.android...") configure_file(Templates/Makefile.android .) @@ -89,9 +89,9 @@ "--target android-${ANDROID_SDK_API_LVL}" OUTPUT_VARIABLE androidoutput ) - MESSAGE(STATUS "Updating android project config...\n" ${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.") + message(FATAL_ERROR "Couldn't find the android executable in ${ANDROID_SDK}/platform-tools or ${ANDROID_SDK}/tools.") endif() exec_program(${HGCOMMAND} diff -r d24257910f8d -r aaefa587e277 project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj --- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj Tue Dec 25 04:45:22 2012 +0100 @@ -34,6 +34,8 @@ 610C8E3714E018D200CF5C4C /* MNEValueTrackingSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 610C8E3614E018D200CF5C4C /* MNEValueTrackingSlider.m */; }; 610D5FB21270E2660033333A /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43411E290650040BA66 /* Icon-Small@2x.png */; }; 610D5FB31270E26C0033333A /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 61F7A43611E290650040BA66 /* Icon@2x.png */; }; + 610FB7C81661390E002FB2A7 /* uPhysFSLayer.pas in Sources */ = {isa = PBXBuildFile; fileRef = 610FB7C71661390E002FB2A7 /* uPhysFSLayer.pas */; }; + 610FB81A166139DF002FB2A7 /* libPhysfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 610FB7F8166139A4002FB2A7 /* libPhysfs.a */; }; 61156521147F48B6006729A9 /* About.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61156520147F48B6006729A9 /* About.strings */; }; 61156523147F48B7006729A9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61156522147F48B7006729A9 /* Localizable.strings */; }; 61156525147F48B8006729A9 /* Scheme.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61156524147F48B8006729A9 /* Scheme.strings */; }; @@ -255,6 +257,76 @@ /* End PBXBuildRule section */ /* Begin PBXContainerItemProxy section */ + 610FB7E116613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 619599BA1364E65900B429B6 /* Freetype.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = libFreetype; + }; + 610FB7E316613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61A19BF414D20D83004B1E6D /* SDL_net.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = BE48FF6507AFA9A800BB41DA; + remoteInfo = "Static Library"; + }; + 610FB7E516613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 6195993F1364C82B00B429B6 /* Lua.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = libLua; + }; + 610FB7E716613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61A19AE314D2010A004B1E6D /* SDL.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = FD6526620DE8FCCB002AD96B; + remoteInfo = libSDL; + }; + 610FB7E916613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61A19C1E14D20F51004B1E6D /* SDL_mixer.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = BE1FA90707AF96B2004B6283; + remoteInfo = "Static Library"; + }; + 610FB7EB16613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61A19BC114D20CDA004B1E6D /* SDL_ttf.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = BE48FD6807AFA17000BB41DA; + remoteInfo = "Static Library"; + }; + 610FB7ED16613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 619598181364BCD200B429B6 /* Tremor.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = libTremor; + }; + 610FB7EF16613980002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 61A19B6114D20B6C004B1E6D /* SDL_image.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = BE1FA72F07AF4C45004B6283; + remoteInfo = libSDL_image; + }; + 610FB7F7166139A4002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 610FB7F3166139A4002FB2A7 /* Physfs.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D2AAC07E0554694100DB518D; + remoteInfo = Physfs; + }; + 610FB81B166139EC002FB2A7 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 610FB7F3166139A4002FB2A7 /* Physfs.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D2AAC07D0554694100DB518D; + remoteInfo = Physfs; + }; 6162456614E6159C00CC97FB /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 619599BA1364E65900B429B6 /* Freetype.xcodeproj */; @@ -346,6 +418,8 @@ 610782951440EE5C00645B29 /* gameMods.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = gameMods.plist; path = Resources/gameMods.plist; sourceTree = ""; }; 610C8E3514E018D200CF5C4C /* MNEValueTrackingSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MNEValueTrackingSlider.h; path = Classes/MNEValueTrackingSlider.h; sourceTree = ""; }; 610C8E3614E018D200CF5C4C /* MNEValueTrackingSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MNEValueTrackingSlider.m; path = Classes/MNEValueTrackingSlider.m; sourceTree = ""; }; + 610FB7C71661390E002FB2A7 /* uPhysFSLayer.pas */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = uPhysFSLayer.pas; path = ../../hedgewars/uPhysFSLayer.pas; sourceTree = SOURCE_ROOT; }; + 610FB7F3166139A4002FB2A7 /* Physfs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Physfs.xcodeproj; path = ../../misc/physfs/Xcode/Physfs.xcodeproj; sourceTree = SOURCE_ROOT; }; 6115651A147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/About.strings; sourceTree = ""; }; 6115651B147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Localizable.strings; sourceTree = ""; }; 6115651C147F48AE006729A9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = Locale/English.lproj/Scheme.strings; sourceTree = ""; }; @@ -649,6 +723,7 @@ 616245D114E6160200CC97FB /* libFreetype.a in Frameworks */, 619599451364C83D00B429B6 /* libLua.a in Frameworks */, 6195981F1364BCEF00B429B6 /* libTremor.a in Frameworks */, + 610FB81A166139DF002FB2A7 /* libPhysfs.a in Frameworks */, 61A19AFC14D20170004B1E6D /* libSDL2.a in Frameworks */, 61A19B7714D20B7A004B1E6D /* libSDL2_image.a in Frameworks */, 61A19C2414D20F5A004B1E6D /* libSDL2_mixer.a in Frameworks */, @@ -757,6 +832,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 610FB7F3166139A4002FB2A7 /* Physfs.xcodeproj */, 619599BA1364E65900B429B6 /* Freetype.xcodeproj */, 6195993F1364C82B00B429B6 /* Lua.xcodeproj */, 619598181364BCD200B429B6 /* Tremor.xcodeproj */, @@ -780,6 +856,14 @@ name = Frameworks; sourceTree = ""; }; + 610FB7F4166139A4002FB2A7 /* Products */ = { + isa = PBXGroup; + children = ( + 610FB7F8166139A4002FB2A7 /* libPhysfs.a */, + ); + name = Products; + sourceTree = ""; + }; 61156510147F481B006729A9 /* Locale */ = { isa = PBXGroup; children = ( @@ -1133,6 +1217,7 @@ 9283015C0F10E48900CC5A3C /* Pascal Sources */ = { isa = PBXGroup; children = ( + 610FB7C71661390E002FB2A7 /* uPhysFSLayer.pas */, 619349C5160BAF3E00A08518 /* uAILandMarks.pas */, 619349C6160BAF3E00A08518 /* uGearsHandlers.pas */, 619349C7160BAF3E00A08518 /* uGearsHandlersRope.pas */, @@ -1213,6 +1298,15 @@ ); dependencies = ( 9283015A0F10E41300CC5A3C /* PBXTargetDependency */, + 610FB7E216613980002FB2A7 /* PBXTargetDependency */, + 610FB7E416613980002FB2A7 /* PBXTargetDependency */, + 610FB7E616613980002FB2A7 /* PBXTargetDependency */, + 610FB7E816613980002FB2A7 /* PBXTargetDependency */, + 610FB7EA16613980002FB2A7 /* PBXTargetDependency */, + 610FB7EC16613980002FB2A7 /* PBXTargetDependency */, + 610FB7EE16613980002FB2A7 /* PBXTargetDependency */, + 610FB7F016613980002FB2A7 /* PBXTargetDependency */, + 610FB81C166139EC002FB2A7 /* PBXTargetDependency */, ); name = Hedgewars; productName = HedgewarsMobile; @@ -1273,6 +1367,10 @@ ProjectRef = 6195993F1364C82B00B429B6 /* Lua.xcodeproj */; }, { + ProductGroup = 610FB7F4166139A4002FB2A7 /* Products */; + ProjectRef = 610FB7F3166139A4002FB2A7 /* Physfs.xcodeproj */; + }, + { ProductGroup = 61A19AE414D2010A004B1E6D /* Products */; ProjectRef = 61A19AE314D2010A004B1E6D /* SDL.xcodeproj */; }, @@ -1307,6 +1405,13 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ + 610FB7F8166139A4002FB2A7 /* libPhysfs.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libPhysfs.a; + remoteRef = 610FB7F7166139A4002FB2A7 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; 6162456714E6159C00CC97FB /* libFreetype.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; @@ -1647,12 +1752,58 @@ 619349C8160BAF3E00A08518 /* uAILandMarks.pas in Sources */, 619349C9160BAF3E00A08518 /* uGearsHandlers.pas in Sources */, 619349CA160BAF3E00A08518 /* uGearsHandlersRope.pas in Sources */, + 610FB7C81661390E002FB2A7 /* uPhysFSLayer.pas in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 610FB7E216613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = libFreetype; + targetProxy = 610FB7E116613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7E416613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Static Library"; + targetProxy = 610FB7E316613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7E616613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = libLua; + targetProxy = 610FB7E516613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7E816613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = libSDL; + targetProxy = 610FB7E716613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7EA16613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Static Library"; + targetProxy = 610FB7E916613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7EC16613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "Static Library"; + targetProxy = 610FB7EB16613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7EE16613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = libTremor; + targetProxy = 610FB7ED16613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB7F016613980002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = libSDL_image; + targetProxy = 610FB7EF16613980002FB2A7 /* PBXContainerItemProxy */; + }; + 610FB81C166139EC002FB2A7 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Physfs; + targetProxy = 610FB81B166139EC002FB2A7 /* PBXContainerItemProxy */; + }; 9283015A0F10E41300CC5A3C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 928301160F10CAFC00CC5A3C /* fpc */; diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/base64/base64.h --- a/project_files/frontlib/base64/base64.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/base64/base64.h Tue Dec 25 04:45:22 2012 +0100 @@ -24,7 +24,7 @@ /* Get bool. */ # include -/* This uses that the expression (n+(k-1))/k means the smallest +/*! This uses that the expression (n+(k-1))/k means the smallest integer >= n/k, i.e., the ceiling of n/k. */ # define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/frontlib.h --- a/project_files/frontlib/frontlib.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/frontlib.h Tue Dec 25 04:45:22 2012 +0100 @@ -26,10 +26,6 @@ #ifndef FRONTLIB_H_ #define FRONTLIB_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "ipc/gameconn.h" #include "ipc/mapconn.h" #include "net/netconn.h" @@ -49,8 +45,4 @@ */ void flib_quit(); -#ifdef __cplusplus -} -#endif - #endif /* FRONTLIB_H_ */ diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/hw_doc.doxygen --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/hw_doc.doxygen Tue Dec 25 04:45:22 2012 +0100 @@ -0,0 +1,1846 @@ +# Doxyfile 1.8.2 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "HW Frontlib" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = "doc" + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. Note that you specify absolute paths here, but also +# relative paths, which will be relative from the directory where doxygen is +# started. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, +# and language is one of the parsers supported by doxygen: IDL, Java, +# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, +# C++. For instance to make doxygen treat .inc files as Fortran files (default +# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note +# that for custom extensions you also need to set FILE_PATTERNS otherwise the +# files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented classes, +# or namespaces to their corresponding documentation. Such a link can be +# prevented in individual cases by by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES (the +# default) will make doxygen replace the get and set methods by a property in +# the documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If left blank doxygen will +# generate a default style sheet. Note that it is recommended to use +# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this +# tag will in the future become obsolete. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional +# user-defined cascading style sheet that is included after the standard +# style sheets created by doxygen. Using this option one can overrule +# certain style aspects. This is preferred over using HTML_STYLESHEET +# since it does not replace the standard style sheet and is therefor more +# robust against future updates. Doxygen will copy the style sheet file to +# the output directory. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely +# identify the documentation publisher. This should be a reverse domain-name +# style string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = YES + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/hwconsts.h --- a/project_files/frontlib/hwconsts.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/hwconsts.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,118 +1,118 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (c) 2004-2012 Andrey Korotaev - * Copyright (c) 2012 Simeon Maxein - * - * 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 - */ - -/** - * This file contains important constants which might need to be changed to adapt to - * changes in the engine or protocols. - * - * It also contains getter functions for some constants (in particular for constants - * that are important for the layout of data structures), so that client code can - * query the constants that the library was built with. - */ - -#ifndef HWCONSTS_H_ -#define HWCONSTS_H_ - -#include -#include -#include - -#define HEDGEHOGS_PER_TEAM 8 -#define DEFAULT_HEDGEHOG_COUNT 4 -#define DEFAULT_COLOR_INDEX 0 - -#define NETGAME_DEFAULT_PORT 46631 -#define PROTOCOL_VERSION 42 -#define MIN_SERVER_VERSION 1 - -// Used for sending scripts to the engine -#define MULTIPLAYER_SCRIPT_PATH "Scripts/Multiplayer/" - -#define WEAPONS_COUNT 56 - -// TODO allow frontend to override these? -/* A merge of mikade/bugq colours w/ a bit of channel feedback */ -#define HW_TEAMCOLOR_ARRAY { UINT32_C(0xffff0204), /* red */ \ - UINT32_C(0xff4980c1), /* blue */ \ - UINT32_C(0xff1de6ba), /* teal */ \ - UINT32_C(0xffb541ef), /* purple */ \ - UINT32_C(0xffe55bb0), /* pink */ \ - UINT32_C(0xff20bf00), /* green */ \ - UINT32_C(0xfffe8b0e), /* orange */ \ - UINT32_C(0xff5f3605), /* brown */ \ - UINT32_C(0xffffff01), /* yellow */ \ - /* add new colors here */ \ - 0 } /* Keep this 0 at the end */ - -extern const size_t flib_teamcolor_count; -extern const uint32_t flib_teamcolors[]; - -/** - * Returns the team color (ARGB) corresponding to the color index (0 if index out of bounds) - */ -uint32_t flib_get_teamcolor(int colorIndex); - -/** - * Returns the number of team colors (i.e. the length of the flib_teamcolors array) - */ -int flib_get_teamcolor_count(); - -/** - * Returns the HEDGEHOGS_PER_TEAM constant - */ -int flib_get_hedgehogs_per_team(); - -/** - * Returns the WEAPONS_COUNT constant - */ -int flib_get_weapons_count(); - -/* - * These structs define the meaning of values in the flib_scheme struct, i.e. their correspondence to - * ini settings, engine commands and positions in the network protocol (the last is encoded in the - * order of settings/mods). - */ -typedef struct { - const char *name; // A name identifying this setting (used as key in the schemes file) - const char *engineCommand; // The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting) - const bool maxMeansInfinity; // If true, send a very high number to the engine if the setting is equal to its maximum - const bool times1000; // If true (for time-based settings), multiply the setting by 1000 before sending it to the engine. - const int min; // The smallest allowed value - const int max; // The highest allowed value - const int def; // The default value -} flib_metascheme_setting; - -typedef struct { - const char *name; // A name identifying this mod (used as key in the schemes file) - const int bitmaskIndex; // Mods are sent to the engine in a single integer, this field describes which bit of that integer is used - // for this particular mod. -} flib_metascheme_mod; - -typedef struct { - const int settingCount; - const int modCount; - const flib_metascheme_setting *settings; - const flib_metascheme_mod *mods; -} flib_metascheme; - -extern const flib_metascheme flib_meta; - -const flib_metascheme *flib_get_metascheme(); - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (c) 2004-2012 Andrey Korotaev + * Copyright (c) 2012 Simeon Maxein + * + * 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 + */ + +/** + * This file contains important constants which might need to be changed to adapt to + * changes in the engine or protocols. + * + * It also contains getter functions for some constants (in particular for constants + * that are important for the layout of data structures), so that client code can + * query the constants that the library was built with. + */ + +#ifndef HWCONSTS_H_ +#define HWCONSTS_H_ + +#include +#include +#include + +#define HEDGEHOGS_PER_TEAM 8 +#define DEFAULT_HEDGEHOG_COUNT 4 +#define DEFAULT_COLOR_INDEX 0 + +#define NETGAME_DEFAULT_PORT 46631 +#define PROTOCOL_VERSION 42 +#define MIN_SERVER_VERSION 1 + +//! Used for sending scripts to the engine +#define MULTIPLAYER_SCRIPT_PATH "Scripts/Multiplayer/" + +#define WEAPONS_COUNT 56 + +// TODO allow frontend to override these? +/*! A merge of mikade/bugq colours w/ a bit of channel feedback */ +#define HW_TEAMCOLOR_ARRAY { UINT32_C(0xffff0204), /*! red */ \ + UINT32_C(0xff4980c1), /*! blue */ \ + UINT32_C(0xff1de6ba), /*! teal */ \ + UINT32_C(0xffb541ef), /*! purple */ \ + UINT32_C(0xffe55bb0), /*! pink */ \ + UINT32_C(0xff20bf00), /*! green */ \ + UINT32_C(0xfffe8b0e), /*! orange */ \ + UINT32_C(0xff5f3605), /*! brown */ \ + UINT32_C(0xffffff01), /*! yellow */ \ + /*! add new colors here */ \ + 0 } /*! Keep this 0 at the end */ + +extern const size_t flib_teamcolor_count; +extern const uint32_t flib_teamcolors[]; + +/** + * Returns the team color (ARGB) corresponding to the color index (0 if index out of bounds) + */ +uint32_t flib_get_teamcolor(int colorIndex); + +/** + * Returns the number of team colors (i.e. the length of the flib_teamcolors array) + */ +int flib_get_teamcolor_count(); + +/** + * Returns the HEDGEHOGS_PER_TEAM constant + */ +int flib_get_hedgehogs_per_team(); + +/** + * Returns the WEAPONS_COUNT constant + */ +int flib_get_weapons_count(); + +/*! + * These structs define the meaning of values in the flib_scheme struct, i.e. their correspondence to + * ini settings, engine commands and positions in the network protocol (the last is encoded in the + * order of settings/mods). + */ +typedef struct { + const char *name; //!< A name identifying this setting (used as key in the schemes file) + const char *engineCommand; //!< The command needed to send the setting to the engine. May be null if the setting is not sent to the engine (for the "health" setting) + const bool maxMeansInfinity; //!< If true, send a very high number to the engine if the setting is equal to its maximum + const bool times1000; //!< If true (for time-based settings), multiply the setting by 1000 before sending it to the engine. + const int min; //!< The smallest allowed value + const int max; //!< The highest allowed value + const int def; //!< The default value +} flib_metascheme_setting; + +typedef struct { + const char *name; //!< A name identifying this mod (used as key in the schemes file) + const int bitmaskIndex; //!< Mods are sent to the engine in a single integer, this field describes which bit of that integer is used + //! for this particular mod. +} flib_metascheme_mod; + +typedef struct { + const int settingCount; + const int modCount; + const flib_metascheme_setting *settings; + const flib_metascheme_mod *mods; +} flib_metascheme; + +extern const flib_metascheme flib_meta; + +const flib_metascheme *flib_get_metascheme(); + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/md5/md5.h --- a/project_files/frontlib/md5/md5.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/md5/md5.h Tue Dec 25 04:45:22 2012 +0100 @@ -27,7 +27,7 @@ This code implements the MD5 Algorithm defined in RFC 1321, whose text is available at - http://www.ietf.org/rfc/rfc1321.txt + http://www.ietf.org/rfc/rfc1321.txt The code is derived from the text of the RFC, including the test suite (section A.5) but excluding the rest of Appendix A. It does not include any code or documentation that is identified in the RFC as being @@ -38,12 +38,12 @@ that follows (in reverse chronological order): 2002-04-13 lpd Removed support for non-ANSI compilers; removed - references to Ghostscript; clarified derivation from RFC 1321; - now handles byte order either statically or dynamically. + references to Ghostscript; clarified derivation from RFC 1321; + now handles byte order either statically or dynamically. 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5); - added conditionalization for C++ compilation from Martin - Purschke . + added conditionalization for C++ compilation from Martin + Purschke . 1999-05-03 lpd Original version. */ @@ -63,25 +63,25 @@ typedef unsigned char md5_byte_t; /* 8-bit byte */ typedef unsigned int md5_word_t; /* 32-bit word */ -/* Define the state of the MD5 Algorithm. */ +/*! Define the state of the MD5 Algorithm. */ typedef struct md5_state_s { - md5_word_t count[2]; /* message length in bits, lsw first */ - md5_word_t abcd[4]; /* digest buffer */ - md5_byte_t buf[64]; /* accumulate block */ + md5_word_t count[2]; /*! message length in bits, lsw first */ + md5_word_t abcd[4]; /*! digest buffer */ + md5_byte_t buf[64]; /*! accumulate block */ } md5_state_t; #ifdef __cplusplus -extern "C" +extern "C" { #endif -/* Initialize the algorithm. */ +/*! Initialize the algorithm. */ void md5_init(md5_state_t *pms); -/* Append a string to the message. */ +/*! Append a string to the message. */ void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes); -/* Finish the message and return the digest. */ +/*! Finish the message and return the digest. */ void md5_finish(md5_state_t *pms, md5_byte_t digest[16]); #ifdef __cplusplus diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/model/gamesetup.h --- a/project_files/frontlib/model/gamesetup.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/model/gamesetup.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,47 +1,47 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * A complete game configuration that contains all settings the engine needs to start a - * local or networked game. - */ - -#ifndef MODEL_GAMESETUP_H_ -#define MODEL_GAMESETUP_H_ - -#include "scheme.h" -#include "weapon.h" -#include "map.h" -#include "teamlist.h" - -typedef struct { - char *style; // e.g. "Capture the Flag" - flib_scheme *gamescheme; - flib_map *map; - flib_teamlist *teamlist; -} flib_gamesetup; - -void flib_gamesetup_destroy(flib_gamesetup *gamesetup); - -/** - * Deep-copy of the flib_gamesetup. - */ -flib_gamesetup *flib_gamesetup_copy(const flib_gamesetup *gamesetup); - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * A complete game configuration that contains all settings the engine needs to start a + * local or networked game. + */ + +#ifndef MODEL_GAMESETUP_H_ +#define MODEL_GAMESETUP_H_ + +#include "scheme.h" +#include "weapon.h" +#include "map.h" +#include "teamlist.h" + +typedef struct { + char *style; //!< e.g. "Capture the Flag" + flib_scheme *gamescheme; + flib_map *map; + flib_teamlist *teamlist; +} flib_gamesetup; + +void flib_gamesetup_destroy(flib_gamesetup *gamesetup); + +/** + * Deep-copy of the flib_gamesetup. + */ +flib_gamesetup *flib_gamesetup_copy(const flib_gamesetup *gamesetup); + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/model/map.h --- a/project_files/frontlib/model/map.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/model/map.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,114 +1,114 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef MODEL_MAP_H_ -#define MODEL_MAP_H_ - -#include -#include -#include - -#define MAPGEN_REGULAR 0 -#define MAPGEN_MAZE 1 -#define MAPGEN_DRAWN 2 -#define MAPGEN_NAMED 3 - -#define TEMPLATEFILTER_ALL 0 -#define TEMPLATEFILTER_SMALL 1 -#define TEMPLATEFILTER_MEDIUM 2 -#define TEMPLATEFILTER_LARGE 3 -#define TEMPLATEFILTER_CAVERN 4 -#define TEMPLATEFILTER_WACKY 5 - -#define MAZE_SIZE_SMALL_TUNNELS 0 -#define MAZE_SIZE_MEDIUM_TUNNELS 1 -#define MAZE_SIZE_LARGE_TUNNELS 2 -#define MAZE_SIZE_SMALL_ISLANDS 3 -#define MAZE_SIZE_MEDIUM_ISLANDS 4 -#define MAZE_SIZE_LARGE_ISLANDS 5 - -/** - * Data structure for defining a map. This contains the whole recipe to - * exactly recreate a particular map. - * - * The required fields depend on the map generator, see the comments - * at the struct for details. - */ -typedef struct { - int mapgen; // Always one of the MAPGEN_ constants - char *name; // The name of the map for MAPGEN_NAMED (e.g. "Cogs"), otherwise one of "+rnd+", "+maze+" or "+drawn+". - char *seed; // Used for all maps. This is a random seed for all (non-AI) entropy in the round. Typically a random UUID, but can be any string. - char *theme; // Used for all maps. This is the name of a directory in Data/Themes (e.g. "Beach") - uint8_t *drawData; // Used for MAPGEN_DRAWN - size_t drawDataSize; // Used for MAPGEN_DRAWN - int templateFilter; // Used for MAPGEN_REGULAR. One of the TEMPLATEFILTER_xxx constants. - int mazeSize; // Used for MAPGEN_MAZE. One of the MAZE_SIZE_xxx constants. -} flib_map; - -/** - * Create a generated map. theme should be the name of a - * directory in "Themes" and templateFilter should be one of the - * TEMPLATEFILTER_* constants, but this is not checked before - * passing it to the engine. - * - * Use flib_map_destroy to free the returned object. - * No NULL parameters allowed, returns NULL on failure. - */ -flib_map *flib_map_create_regular(const char *seed, const char *theme, int templateFilter); - -/** - * Create a generated maze-type map. theme should be the name of a - * directory in "Themes" and mazeSize should be one of the - * MAZE_SIZE_* constants, but this is not checked before - * passing it to the engine. - * - * Use flib_map_destroy to free the returned object. - * No NULL parameters allowed, returns NULL on failure. - */ -flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize); - -/** - * Create a map from the Maps-Directory. name should be the name of a - * directory in "Maps", but this is not checked before - * passing it to the engine. If this is a mission, the corresponding - * script is used automatically. - * - * Use flib_map_destroy to free the returned object. - * No NULL parameters allowed, returns NULL on failure. - */ -flib_map *flib_map_create_named(const char *seed, const char *name); - -/** - * Create a hand-drawn map. Use flib_map_destroy to free the returned object. - * No NULL parameters allowed, returns NULL on failure. - */ -flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize); - -/** - * Create a deep copy of the map. Returns NULL on failure or if NULL was passed. - */ -flib_map *flib_map_copy(const flib_map *map); - -/** - * Decrease the reference count of the object and free it if this was the last reference. - */ -void flib_map_destroy(flib_map *map); - - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef MODEL_MAP_H_ +#define MODEL_MAP_H_ + +#include +#include +#include + +#define MAPGEN_REGULAR 0 +#define MAPGEN_MAZE 1 +#define MAPGEN_DRAWN 2 +#define MAPGEN_NAMED 3 + +#define TEMPLATEFILTER_ALL 0 +#define TEMPLATEFILTER_SMALL 1 +#define TEMPLATEFILTER_MEDIUM 2 +#define TEMPLATEFILTER_LARGE 3 +#define TEMPLATEFILTER_CAVERN 4 +#define TEMPLATEFILTER_WACKY 5 + +#define MAZE_SIZE_SMALL_TUNNELS 0 +#define MAZE_SIZE_MEDIUM_TUNNELS 1 +#define MAZE_SIZE_LARGE_TUNNELS 2 +#define MAZE_SIZE_SMALL_ISLANDS 3 +#define MAZE_SIZE_MEDIUM_ISLANDS 4 +#define MAZE_SIZE_LARGE_ISLANDS 5 + +/** + * Data structure for defining a map. This contains the whole recipe to + * exactly recreate a particular map. + * + * The required fields depend on the map generator, see the comments + * at the struct for details. + */ +typedef struct { + int mapgen; //!< Always one of the MAPGEN_ constants + char *name; //!< The name of the map for MAPGEN_NAMED (e.g. "Cogs"), otherwise one of "+rnd+", "+maze+" or "+drawn+". + char *seed; //!< Used for all maps. This is a random seed for all (non-AI) entropy in the round. Typically a random UUID, but can be any string. + char *theme; //!< Used for all maps. This is the name of a directory in Data/Themes (e.g. "Beach") + uint8_t *drawData; //!< Used for MAPGEN_DRAWN + size_t drawDataSize; //!< Used for MAPGEN_DRAWN + int templateFilter; //!< Used for MAPGEN_REGULAR. One of the TEMPLATEFILTER_xxx constants. + int mazeSize; //!< Used for MAPGEN_MAZE. One of the MAZE_SIZE_xxx constants. +} flib_map; + +/** + * Create a generated map. theme should be the name of a + * directory in "Themes" and templateFilter should be one of the + * TEMPLATEFILTER_* constants, but this is not checked before + * passing it to the engine. + * + * Use flib_map_destroy to free the returned object. + * No NULL parameters allowed, returns NULL on failure. + */ +flib_map *flib_map_create_regular(const char *seed, const char *theme, int templateFilter); + +/** + * Create a generated maze-type map. theme should be the name of a + * directory in "Themes" and mazeSize should be one of the + * MAZE_SIZE_* constants, but this is not checked before + * passing it to the engine. + * + * Use flib_map_destroy to free the returned object. + * No NULL parameters allowed, returns NULL on failure. + */ +flib_map *flib_map_create_maze(const char *seed, const char *theme, int mazeSize); + +/** + * Create a map from the Maps-Directory. name should be the name of a + * directory in "Maps", but this is not checked before + * passing it to the engine. If this is a mission, the corresponding + * script is used automatically. + * + * Use flib_map_destroy to free the returned object. + * No NULL parameters allowed, returns NULL on failure. + */ +flib_map *flib_map_create_named(const char *seed, const char *name); + +/** + * Create a hand-drawn map. Use flib_map_destroy to free the returned object. + * No NULL parameters allowed, returns NULL on failure. + */ +flib_map *flib_map_create_drawn(const char *seed, const char *theme, const uint8_t *drawData, size_t drawDataSize); + +/** + * Create a deep copy of the map. Returns NULL on failure or if NULL was passed. + */ +flib_map *flib_map_copy(const flib_map *map); + +/** + * Decrease the reference count of the object and free it if this was the last reference. + */ +void flib_map_destroy(flib_map *map); + + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/model/mapcfg.h --- a/project_files/frontlib/model/mapcfg.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/model/mapcfg.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,38 +1,38 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/* - * Data structure and functions for accessing the map.cfg of named maps. - */ - -#ifndef MAPCFG_H_ -#define MAPCFG_H_ - -typedef struct { - char theme[256]; - int hogLimit; -} flib_mapcfg; - -/** - * Read the map configuration for the map with this name. - * The dataDirPath must end in a path separator. - */ -int flib_mapcfg_read(const char *dataDirPath, const char *mapname, flib_mapcfg *out); - -#endif /* MAPCFG_H_ */ +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/*! + * Data structure and functions for accessing the map.cfg of named maps. + */ + +#ifndef MAPCFG_H_ +#define MAPCFG_H_ + +typedef struct { + char theme[256]; + int hogLimit; +} flib_mapcfg; + +/** + * Read the map configuration for the map with this name. + * The dataDirPath must end in a path separator. + */ +int flib_mapcfg_read(const char *dataDirPath, const char *mapname, flib_mapcfg *out); + +#endif /* MAPCFG_H_ */ diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/model/room.h --- a/project_files/frontlib/model/room.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/model/room.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,42 +1,42 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * Models the room information for the lobby roomlist. - */ - -#ifndef ROOM_H_ -#define ROOM_H_ - -#include - -typedef struct { - bool inProgress; // true if the game is running - char *name; - int playerCount; - int teamCount; - char *owner; - char *map; // This is either a map name, or one of +rnd+, +maze+ or +drawn+. - char *scheme; - char *weapons; -} flib_room; - -void flib_room_destroy(); - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * Models the room information for the lobby roomlist. + */ + +#ifndef ROOM_H_ +#define ROOM_H_ + +#include + +typedef struct { + bool inProgress; //!< true if the game is running + char *name; + int playerCount; + int teamCount; + char *owner; + char *map; //!< This is either a map name, or one of +rnd+, +maze+ or +drawn+. + char *scheme; + char *weapons; +} flib_room; + +void flib_room_destroy(); + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/model/team.h --- a/project_files/frontlib/model/team.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/model/team.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,130 +1,130 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * This file defines a data structure for a hedgewars team. - * - * Teams are used in several different contexts in Hedgewars, and some of these require - * extra information about teams. For example, the weaponset is important - * to the engine, but not for ini reading/writing, and with the team statistics it is the - * other way around. To keep things simple, the data structure can hold all information - * used in any context. On the downside, that means we can't use static typing to ensure - * that team information is "complete" for a particular purpose. - */ -#ifndef TEAM_H_ -#define TEAM_H_ - - -#include "weapon.h" -#include "../hwconsts.h" - -#include -#include - -#define TEAM_DEFAULT_HEALTH 100 - -/** - * Struct representing a single keybinding. - */ -typedef struct { - char *action; - char *binding; -} flib_binding; - -typedef struct { - char *name; - char *hat; // e.g. hair_yellow; References a .png file in Data/Graphics/Hats - - // Statistics. They are irrelevant for the engine or server, - // but provided for ini reading/writing by the frontend. - int rounds; - int kills; - int deaths; - int suicides; - - int difficulty; // 0 = human, 1 = most difficult bot ... 5 = least difficult bot (somewhat counterintuitive) - - // Transient setting used in game setup - int initialHealth; - flib_weaponset *weaponset; -} flib_hog; - -typedef struct { - flib_hog hogs[HEDGEHOGS_PER_TEAM]; - char *name; - char *grave; // e.g. "Bone"; References a .png file in Data/Graphics/Graves - char *fort; // e.g. "Castle"; References a series of files in Data/Forts - char *voicepack; // e.g. "Classic"; References a directory in Data/Sounds/voices - char *flag; // e.g. "hedgewars"; References a .png file in Data/Graphics/Flags - - flib_binding *bindings; - int bindingCount; - - // Statistics. They are irrelevant for the engine or server, - // but provided for ini reading/writing by the frontend. - int rounds; - int wins; - int campaignProgress; - - // Transient settings used in game setup - int colorIndex; // Index into a color table - int hogsInGame; // The number of hogs that will actually play - bool remoteDriven; // true for non-local teams in a network game - char *ownerName; // Username of the owner of a team in a network game -} flib_team; - -/** - * Free all memory associated with the team - */ -void flib_team_destroy(flib_team *team); - -/** - * Loads a team, returns NULL on error. Destroy this team using flib_team_destroy. - * This will not fill in the fields marked as "transient" in the structs above. - */ -flib_team *flib_team_from_ini(const char *filename); - -/** - * Write the team to an ini file. Attempts to retain extra ini settings - * that were already present. Note that not all fields of a team struct - * are stored in the ini, some are only used intermittently to store - * information about a team in the context of a game. - * - * The flib_team can handle "difficulty" on a per-hog basis, but it - * is only written per-team in the team file. The difficulty of the - * first hog is used for the entire team when writing. - */ -int flib_team_to_ini(const char *filename, const flib_team *team); - -/** - * Set the same weaponset for every hog in the team - */ -int flib_team_set_weaponset(flib_team *team, const flib_weaponset *set); - -/** - * Set the same initial health for every hog. - */ -void flib_team_set_health(flib_team *team, int health); - -/** - * Create a deep copy of a team. Returns NULL on failure. - */ -flib_team *flib_team_copy(const flib_team *team); - -#endif /* TEAM_H_ */ +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * This file defines a data structure for a hedgewars team. + * + * Teams are used in several different contexts in Hedgewars, and some of these require + * extra information about teams. For example, the weaponset is important + * to the engine, but not for ini reading/writing, and with the team statistics it is the + * other way around. To keep things simple, the data structure can hold all information + * used in any context. On the downside, that means we can't use static typing to ensure + * that team information is "complete" for a particular purpose. + */ +#ifndef TEAM_H_ +#define TEAM_H_ + + +#include "weapon.h" +#include "../hwconsts.h" + +#include +#include + +#define TEAM_DEFAULT_HEALTH 100 + +/** + * Struct representing a single keybinding. + */ +typedef struct { + char *action; + char *binding; +} flib_binding; + +typedef struct { + char *name; + char *hat; //!< e.g. hair_yellow; References a .png file in Data/Graphics/Hats + + //! Statistics. They are irrelevant for the engine or server, + //! but provided for ini reading/writing by the frontend. + int rounds; + int kills; + int deaths; + int suicides; + + int difficulty; //!< 0 = human, 1 = most difficult bot ... 5 = least difficult bot (somewhat counterintuitive) + + //! Transient setting used in game setup + int initialHealth; + flib_weaponset *weaponset; +} flib_hog; + +typedef struct { + flib_hog hogs[HEDGEHOGS_PER_TEAM]; + char *name; + char *grave; //!< e.g. "Bone"; References a .png file in Data/Graphics/Graves + char *fort; //!< e.g. "Castle"; References a series of files in Data/Forts + char *voicepack; //!< e.g. "Classic"; References a directory in Data/Sounds/voices + char *flag; //!< e.g. "hedgewars"; References a .png file in Data/Graphics/Flags + + flib_binding *bindings; + int bindingCount; + + //! Statistics. They are irrelevant for the engine or server, + //! but provided for ini reading/writing by the frontend. + int rounds; + int wins; + int campaignProgress; + + //! Transient settings used in game setup + int colorIndex; //!< Index into a color table + int hogsInGame; //!< The number of hogs that will actually play + bool remoteDriven; //!< true for non-local teams in a network game + char *ownerName; //!< Username of the owner of a team in a network game +} flib_team; + +/** + * Free all memory associated with the team + */ +void flib_team_destroy(flib_team *team); + +/** + * Loads a team, returns NULL on error. Destroy this team using flib_team_destroy. + * This will not fill in the fields marked as "transient" in the structs above. + */ +flib_team *flib_team_from_ini(const char *filename); + +/** + * Write the team to an ini file. Attempts to retain extra ini settings + * that were already present. Note that not all fields of a team struct + * are stored in the ini, some are only used intermittently to store + * information about a team in the context of a game. + * + * The flib_team can handle "difficulty" on a per-hog basis, but it + * is only written per-team in the team file. The difficulty of the + * first hog is used for the entire team when writing. + */ +int flib_team_to_ini(const char *filename, const flib_team *team); + +/** + * Set the same weaponset for every hog in the team + */ +int flib_team_set_weaponset(flib_team *team, const flib_weaponset *set); + +/** + * Set the same initial health for every hog. + */ +void flib_team_set_health(flib_team *team, int health); + +/** + * Create a deep copy of a team. Returns NULL on failure. + */ +flib_team *flib_team_copy(const flib_team *team); + +#endif /* TEAM_H_ */ diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/net/netconn.h --- a/project_files/frontlib/net/netconn.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/net/netconn.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,654 +1,654 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * This file contains functions for communicating with a Hedgewars server to chat, prepare and play - * rounds of Hedgewars. - * - * To use this, first create a netconn object by calling flib_netconn_create. This will start the - * connection to the game server (which might fail right away, the function returns null then). You - * should also register your callback functions right at the start to ensure you don't miss any - * callbacks. - * - * In order to allow the netconn to run, you should regularly call flib_netconn_tick(), which - * performs network I/O and calls your callbacks on interesting events. - * - * When the connection is closed, you will receive the onDisconnect callback. This is the signal to - * destroy the netconn and stop calling tick(). - * - * The connection process lasts from the time you create the netconn until you receive the - * onConnected callback (or onDisconnected in case something goes wrong). During that time, you - * might receive the onNickTaken and onPasswordRequest callbacks; see their description for more - * information on how to handle them. You could also receive other callbacks during connecting (e.g. - * about the room list), but it should be safe to ignore them. - * - * Once you are connected, you are in the lobby, and you can enter rooms and leave them again. The - * room and lobby states have different protocols, so many commands only work in either one or the - * other. If you are in a room you might also be in a game, but most of the functions behave the - * same ingame as in a room. - * - * The state changes from lobby to room when the server tells you that you just entered one, which - * will also trigger the onEnterRoom callback. This usually happens in reply to either a joinRoom, - * createRoom or playerFollow command. - * - * The state changes back to lobby when the room is dissolved, when you are kicked from the room, or - * when you actively leave the room using flib_netconn_send_leaveRoom. The first two events will - * trigger the onLeaveRoom callback. - */ - -#ifndef NETCONN_H_ -#define NETCONN_H_ - -#include "../model/gamesetup.h" -#include "../model/scheme.h" -#include "../model/room.h" - -#include -#include -#include - -#define NETCONN_STATE_CONNECTING 0 -#define NETCONN_STATE_LOBBY 1 -#define NETCONN_STATE_ROOM 2 -#define NETCONN_STATE_DISCONNECTED 10 - -#define NETCONN_DISCONNECT_NORMAL 0 // The connection was closed normally -#define NETCONN_DISCONNECT_SERVER_TOO_OLD 1 // The server has a lower protocol version than we do -#define NETCONN_DISCONNECT_AUTH_FAILED 2 // You sent a password with flib_netconn_send_password that was not accepted -#define NETCONN_DISCONNECT_CONNLOST 3 // The network connection was lost -#define NETCONN_DISCONNECT_INTERNAL_ERROR 100 // Something went wrong in frontlib itself - -#define NETCONN_ROOMLEAVE_ABANDONED 0 // The room was closed because the chief left -#define NETCONN_ROOMLEAVE_KICKED 1 // You have been kicked from the room - -#define NETCONN_MSG_TYPE_PLAYERINFO 0 // A response to flib_netconn_send_playerInfo -#define NETCONN_MSG_TYPE_SERVERMESSAGE 1 // The welcome message when connecting to the lobby -#define NETCONN_MSG_TYPE_WARNING 2 // A general warning message -#define NETCONN_MSG_TYPE_ERROR 3 // A general error message - -#define NETCONN_MAPCHANGE_FULL 0 -#define NETCONN_MAPCHANGE_MAP 1 -#define NETCONN_MAPCHANGE_MAPGEN 2 -#define NETCONN_MAPCHANGE_DRAWNMAP 3 -#define NETCONN_MAPCHANGE_MAZE_SIZE 4 -#define NETCONN_MAPCHANGE_TEMPLATE 5 -#define NETCONN_MAPCHANGE_THEME 6 -#define NETCONN_MAPCHANGE_SEED 7 - -typedef struct _flib_netconn flib_netconn; - -/** - * Create a new netplay connection with these parameters. - * The path to the data directory must end with a path delimiter (e.g. C:\Games\Hedgewars\Data\) - */ -flib_netconn *flib_netconn_create(const char *playerName, const char *dataDirPath, const char *host, int port); -void flib_netconn_destroy(flib_netconn *conn); - -/** - * Perform I/O operations and call callbacks if something interesting happens. - * Should be called regularly. - */ -void flib_netconn_tick(flib_netconn *conn); - -/** - * Are you currently the owner of this room? The return value only makes sense in - * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states. - */ -bool flib_netconn_is_chief(flib_netconn *conn); - -/** - * Returns the playername. This is *probably* the one provided on creation, but if that name was - * already taken, a different one could have been set by the onNickTaken callback or its default - * implementation. - */ -const char *flib_netconn_get_playername(flib_netconn *conn); - -/** - * Generate a game setup from the current room state. - * Returns NULL if the room state does not contain enough information for a complete game setup, - * or if an error occurs. - * - * The new gamesetup must be destroyed with flib_gamesetup_destroy(). - */ -flib_gamesetup *flib_netconn_create_gamesetup(flib_netconn *conn); - - - - -// Send functions needed when connecting and disconnecting - - /** - * Request a different nickname. - * This function only makes sense in reaction to an onNickTaken callback, because the netconn - * automatically requests the nickname you provide on creation, and once the server accepts the - * nickname it can no longer be changed. - */ - int flib_netconn_send_nick(flib_netconn *conn, const char *nick); - - /** - * Send the password in reply to a password request. - * If the server does not accept the password, you will be disconnected - * (NETCONN_DISCONNECT_AUTH_FAILED) - */ - int flib_netconn_send_password(flib_netconn *conn, const char *passwd); - - /** - * Tell the server that you want to leave. If successful, the server will disconnect you. - */ - int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg); - - -// Send functions that make sense both in the lobby and in rooms - - /** - * Send a chat message. This message is either sent to the lobby or the room, depending on - * whether you are in a room at the moment. The message is not echoed back to you. - */ - int flib_netconn_send_chat(flib_netconn *conn, const char *chat); - - /** - * Kick a player. This has different meanings in the lobby and in a room; - * In the lobby, it will kick the player from the server, and you need to be a server admin to - * do it. In a room, it will kick the player from the room, and you need to be room chief. - */ - int flib_netconn_send_kick(flib_netconn *conn, const char *playerName); - - /** - * Request information about a player (e.g. current room, version, partial IP). If the action - * succeeds, you will receive an onMessage callback with NETCONN_MSG_TYPE_PLAYERINFO containing - * the requested information. - */ - int flib_netconn_send_playerInfo(flib_netconn *conn, const char *playerName); - - -// Send functions that only make sense in the lobby - - /** - * Request an update of the room list. Only makes sense when in lobby state. - * If the action succeeds, you will receive an onRoomlist callback containing the current room - * data. - */ - int flib_netconn_send_request_roomlist(flib_netconn *conn); - - /** - * Join a room as guest (not chief). Only makes sense when in lobby state. If the action - * succeeds, you will receive an onEnterRoom callback with chief=false followed by other - * callbacks with current room information. - */ - int flib_netconn_send_joinRoom(flib_netconn *conn, const char *room); - - /** - * Follow a player. Only valid in the lobby. If the player is in a room (or in a game), this - * command is analogous to calling flib_netconn_send_joinRoom with that room. - */ - int flib_netconn_send_playerFollow(flib_netconn *conn, const char *playerName); - - /** - * Create and join a new room. Only makes sense when in lobby state. If the action succeeds, - * you will receive an onEnterRoom callback with chief=true. - */ - int flib_netconn_send_createRoom(flib_netconn *conn, const char *room); - - /** - * Ban a player. The scope of this ban depends on whether you are in a room or in the lobby. - * In a room, you need to be the room chief, and the ban will apply to the room only. In the - * lobby, you need to be server admin to ban someone, and the ban applies to the entire server. - */ - int flib_netconn_send_ban(flib_netconn *conn, const char *playerName); - - /** - * Does something administrator-y. At any rate you need to be an administrator and in the lobby - * to use this command. - */ - int flib_netconn_send_clearAccountsCache(flib_netconn *conn); - - /** - * Sets a server variable to the indicated value. Only makes sense if you are server admin and - * in the lobby. Known variables are MOTD_NEW, MOTD_OLD and LATEST_PROTO. MOTD_OLD is shown to - * players with older protocol versions, to inform them that they might want to update. - */ - int flib_netconn_send_setServerVar(flib_netconn *conn, const char *name, const char *value); - - /** - * Queries all server variables. Only makes sense if you are server admin and in the lobby. - * If the action succeeds, you will receive several onServerVar callbacks with the - * current values of all server variables. - */ - int flib_netconn_send_getServerVars(flib_netconn *conn); - - -// Send functions that only make sense in a room - - /** - * Leave the room for the lobby. Only makes sense in room state. msg can be NULL if you don't - * want to send a message. The server always accepts a part command, so once you send it off, - * you can just assume that you are back in the lobby. - */ - int flib_netconn_send_leaveRoom(flib_netconn *conn, const char *msg); - - /** - * Change your "ready" status in the room. Only makes sense when in room state. If the action - * succeeds, you will receive an onClientFlags callback containing the change. - */ - int flib_netconn_send_toggleReady(flib_netconn *conn); - - /** - * Add a team to the current room. Apart from the "fixed" team information, this also includes - * the color, but not the number of hogs. Only makes sense when in room state. If the action - * succeeds, you will receive an onTeamAccepted callback with the name of the team. - * - * Notes: Technically, sending a color here is the only way for a non-chief to set the color of - * her own team. The server remembers this color and even generates a separate teamColor message - * to inform everyone of it. However, at the moment the frontends generally override this color - * with one they choose themselves in order to deal with unfortunate behavior of the QtFrontend, - * which always sends color index 0 when adding a team but thinks that the team has a random - * color. The chief always sends a new color in order to bring the QtFrontend back into sync. - */ - int flib_netconn_send_addTeam(flib_netconn *conn, const flib_team *team); - - /** - * Remove the team with the name teamname. Only makes sense when in room state. - * The server does not send a reply on success. - */ - int flib_netconn_send_removeTeam(flib_netconn *conn, const char *teamname); - - -// Send functions that only make sense in a room and if you are room chief - - /** - * Rename the current room. Only makes sense in room state and if you are chief. If the action - * succeeds, you (and everyone else on the server) will receive an onRoomUpdate message - * containing the change. - */ - int flib_netconn_send_renameRoom(flib_netconn *conn, const char *roomName); - - /** - * Set the number of hogs for a team. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_teamHogCount(flib_netconn *conn, const char *teamname, int hogcount); - - /** - * Set the teamcolor of a team. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, int colorIndex); - - /** - * Set the weaponset for the room. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_weaponset(flib_netconn *conn, const flib_weaponset *weaponset); - - /** - * Set the map for the room. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_map(flib_netconn *conn, const flib_map *map); - - /** - * Set the mapname. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapName(flib_netconn *conn, const char *mapName); - - /** - * Set the map generator (regular, maze, drawn, named). Only makes sense in room state and if - * you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapGen(flib_netconn *conn, int mapGen); - - /** - * Set the map template for regular maps. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapTemplate(flib_netconn *conn, int templateFilter); - - /** - * Set the maze template (maze size) for mazes. Only makes sense in room state and if you are - * chief. The server does not send a reply. - */ - int flib_netconn_send_mapMazeSize(flib_netconn *conn, int mazeSize); - - /** - * Set the seed for the map. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapSeed(flib_netconn *conn, const char *seed); - - /** - * Set the theme for the map. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapTheme(flib_netconn *conn, const char *theme); - - /** - * Set the draw data for the drawn map. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_mapDrawdata(flib_netconn *conn, const uint8_t *drawData, size_t size); - - /** - * Set the script (game style). Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_script(flib_netconn *conn, const char *scriptName); - - /** - * Set the scheme. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_scheme(flib_netconn *conn, const flib_scheme *scheme); - - /** - * Signal that you want to start the game. Only makes sense in room state and if you are chief. - * The server will check whether all players are ready and whether it believes the setup makes - * sense (e.g. more than one clan). If the server is satisfied, you will receive an onRunGame - * callback (all other clients in the room are notified the same way). Otherwise the server - * might answer with a warning, or might not answer at all. - */ - int flib_netconn_send_startGame(flib_netconn *conn); - - /** - * Allow/forbid players to join the room. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_toggleRestrictJoins(flib_netconn *conn); - - /** - * Allow/forbid adding teams to the room. Only makes sense in room state and if you are chief. - * The server does not send a reply. - */ - int flib_netconn_send_toggleRestrictTeams(flib_netconn *conn); - - -// Send functions that are only needed for running a game - - /** - * Send a teamchat message, forwarded from the engine. Only makes sense ingame. - * The server does not send a reply. In contrast to a Chat message, the server - * automatically converts this into an engine message and passes it on to the other - * clients. - */ - int flib_netconn_send_teamchat(flib_netconn *conn, const char *msg); - - /** - * Send an engine message. Only makes sense when ingame. In a networked game, you have to pass - * all the engine messages from the engine here, and they will be spread to all other clients - * in the game to keep the game in sync. - */ - int flib_netconn_send_engineMessage(flib_netconn *conn, const uint8_t *message, size_t size); - - /** - * Inform the server that the round has ended. Call this when the engine has disconnected, - * passing 1 if the round ended normally, 0 otherwise. - */ - int flib_netconn_send_roundfinished(flib_netconn *conn, bool withoutError); - - - - - -// Callbacks that are important for connecting/disconnecting - - /** - * onNickTaken is called when connecting to the server, if it turns out that there is already a - * player with the same nick. - * In order to proceed, a new nickname needs to be sent to the server using - * flib_netconn_send_nick() (or of course you can bail out and send a QUIT). - * If you don't set a callback, the netconn will automatically react by generating a new name. - */ - void flib_netconn_onNickTaken(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); - - /** - * When connecting with a registered nickname, the server will ask for a password before - * admitting you in. This callback is called when that happens. As a reaction, you can send the - * password using flib_netconn_send_password. If you don't register a callback, the default - * behavior is to just quit in a way that will cause a disconnect with - * NETCONN_DISCONNECT_AUTH_FAILED. - * - * You can't just choose a new nickname when you receive this callback, because at that point - * the server has already accepted your nick. - */ - void flib_netconn_onPasswordRequest(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); - - /** - * This is called when the server has accepted our nickname (and possibly password) and we have - * entered the lobby. - */ - void flib_netconn_onConnected(flib_netconn *conn, void (*callback)(void *context), void* context); - - /** - * This is always the last callback (unless the netconn is destroyed early), and the netconn - * should be destroyed when it is received. The reason for the disconnect is passed as one of - * the NETCONN_DISCONNECT_ constants. Sometimes a message is included as well, but that - * parameter might also be NULL. - */ - void flib_netconn_onDisconnected(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void* context); - - -// Callbacks that make sense in most situations - - /** - * Callback for several informational messages that should be displayed to the user - * (e.g. in the chat window), but do not require a reaction. If a game is running, you might - * want to redirect some of these messages to the engine as well so the user will see them. - */ - void flib_netconn_onMessage(flib_netconn *conn, void (*callback)(void *context, int msgtype, const char *msg), void* context); - - /** - * We received a chat message. Where this message belongs depends on the current state - * (lobby/room). If a game is running the message should be passed to the engine. - */ - void flib_netconn_onChat(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *msg), void* context); - - /** - * Callbacks for incremental room list updates. They will fire whenever these events occur, - * even before you first query the actual roomlist - so be sure not to blindly reference your - * room list in these callbacks. The server currently only sends updates when a room changes - * its name, so in order to update other room information you need to query the roomlist again - * (see send_request_roomlist / onRoomlist). - */ - void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_room *room), void* context); - void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context); - void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_room *room), void* context); - - /** - * Callbacks for players joining or leaving the lobby. In contrast to the roomlist updates, you - * will get a JOIN callback for every player already on the server when you join (and there is - * no direct way to query the current playerlist) - * - * NOTE: partMessage may be NULL. - */ - void flib_netconn_onLobbyJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); - void flib_netconn_onLobbyLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context); - - /** - * This is called when the server informs us that one or more flags associated with a - * player/client have changed. - * - * nick is the name of the player, flags is a string containing one character for each modified - * flag (see below), and newFlagState signals whether the flags should be set to true or false. - * - * Some of these flags are important for protocol purposes (especially if they are set for you) - * while others are just informational. Also, some flags are only relevant for players who are - * in the same room as you, and the server will not inform you if they change for others. - * - * These are the currently known/used flags: - * a: Server admin. Always updated. - * h: Room chief. Updated when in the same room. - * r: Ready to play. Updated when in the same room. - * u: Registered user. Always updated. - * - * The server tells us the 'a' and 'u' flags for all players when we first join the lobby, and - * also tells us the 'r' and 'h' flags when we join or create a room. It assumes that all flags - * are initially false, so it will typically only tell you to set certain flags to true when - * transmitting the initial states. Reset the 'h' and 'r' flags to false when leaving a room, - * or when entering room state, to arrive at the right state for each player. - * - * The room chief state of yourself is particularly important because it determines whether you - * can modify settings of the current room. Generally, when you create a room you start out - * being room chief, and when you join an existing room you are not. However, if the original - * chief leaves a room, the server can choose a new chief, and if that happens the chief flag - * will be transferred to someone else. - */ - void flib_netconn_onClientFlags(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *flags, bool newFlagState), void *context); - -// Callbacks that happen only in response to specific requests - - /** - * Response to flib_netconn_send_request_roomlist(). - * The rooms array contains the current state of all rooms on the server. - */ - void flib_netconn_onRoomlist(flib_netconn *conn, void (*callback)(void *context, const flib_room **rooms, int roomCount), void* context); - - /** - * Response to flib_netconn_send_joinRoom, flib_netconn_send_playerFollow or - * flib_netconn_send_createRoom. - * - * You just left the lobby and entered a room. - * If chief is true, you can and should send a full configuration for the room now. This - * consists of ammo, scheme, script and map, where map apparently has to come last. - */ - void flib_netconn_onEnterRoom(flib_netconn *conn, void (*callback)(void *context, bool chief), void *context); - - /** - * Response to flib_netconn_send_addTeam. - * The server might reject your team for several reasons, e.g. because it has the same name as - * an existing team, or because the room chief restricted adding new teams. If the team is - * accepted by the server, this callback is fired. - * - * If you are the room chief, you are expected to provide the hog count for your own team now - * using flib_netconn_send_teamHogCount. The color of the team is already set to the one you - * provided in addTeam. - */ - void flib_netconn_onTeamAccepted(flib_netconn *conn, void (*callback)(void *context, const char *team), void *context); - - /** - * When you query the server vars with flib_netconn_send_getServerVars (only works as admin), - * the server replies with a list of them. This callback is called for each entry in that list. - */ - void flib_netconn_onServerVar(flib_netconn *conn, void (*callback)(void *context, const char *name, const char *value), void *context); - - -// Callbacks that are only relevant in a room - - /** - * You just left a room and entered the lobby again. - * reason is one of the NETCONN_ROOMLEAVE_ constants (usually a kick). - * This will not be called when you actively leave a room using PART. - * Don't confuse with onRoomLeave, which indicates that *someone else* left the room. - */ - void flib_netconn_onLeaveRoom(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void *context); - - /** - * Someone joined or left the room you are currently in. - * Analogous to onLobbyJoin/leave, you will receive the join callback for all players that are - * already in the room when you join, including for yourself (this is actually how it is - * determined that you joined a room). - * - * However, you will *not* receive onRoomLeave messages for everyone when you leave the room. - */ - void flib_netconn_onRoomJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); - void flib_netconn_onRoomLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context); - - /** - * A new team was added to the room. The person who adds a team does NOT receive this callback - * (he gets onTeamAccepted instead). - * - * The team does not contain bindings, stats, weaponset, color or the number of hogs (but it is - * assumed to be the default of 4). - * - * If you receive this message and you are the room chief, you may want to send a color and hog - * count for this team using flib_netconn_send_teamHogCount / teamColor for QtFrontend - * compatibility. - * - * The server currently sends another message with the color of the team to the same recipients - * as this teamAdd message, which will trigger an onTeamColorChanged callback. See the - * description of flib_netconn_send_addTeam for more information. - */ - void flib_netconn_onTeamAdd(flib_netconn *conn, void (*callback)(void *context, const flib_team *team), void *context); - - /** - * A team was removed from the room. The person who removed the team will not receive this - * callback. - */ - void flib_netconn_onTeamDelete(flib_netconn *conn, void (*callback)(void *context, const char *teamname), void *context); - - /** - * The number of hogs in a team has been changed by the room chief. If you are the chief and - * change the number of hogs yourself, you will not receive this callback. - */ - void flib_netconn_onHogCountChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int hogs), void *context); - - /** - * The color of a team has been set or changed. The client who set or changed the color will - * not receive this callback. - * - * Normally, only the chief can change the color of a team. However, this message is also - * generated when a team is added, so you can receive it even as chief. - */ - void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int colorIndex), void *context); - - /** - * The room chief has changed the game scheme (or you just joined a room). - * You will not receive this callback if you changed the scheme yourself. - */ - void flib_netconn_onSchemeChanged(flib_netconn *conn, void (*callback)(void *context, const flib_scheme *scheme), void *context); - - /** - * The room chief has changed the map (or you just joined a room). Only non-chiefs receive these - * messages. - * - * To reduce the number of callback functions, the netconn keeps track of the current map - * settings and always passes the entire current map config, but informs the callee about what - * has changed (see the NETCONN_MAPCHANGE_ constants). - * - * Caution: Due to the way the protocol works, the map might not be complete at this point if it - * is a hand-drawn map, because the "full" map config does not include the drawn map data. - */ - void flib_netconn_onMapChanged(flib_netconn *conn, void (*callback)(void *context, const flib_map *map, int changetype), void *context); - - /** - * The room chief has changed the game style (or you just joined a room). If you are the chief - * and change the style yourself, you will not receive this callback. - */ - void flib_netconn_onScriptChanged(flib_netconn *conn, void (*callback)(void *context, const char *script), void *context); - - /** - * The room chief has changed the weaponset (or you just joined a room). If you are the chief - * and change the weaponset yourself, you will not receive this callback. - */ - void flib_netconn_onWeaponsetChanged(flib_netconn *conn, void (*callback)(void *context, const flib_weaponset *weaponset), void *context); - - /** - * The game is starting. Fire up the engine and join in! - * You can let the netconn generate the right game setup using flib_netconn_create_gamesetup - */ - void flib_netconn_onRunGame(flib_netconn *conn, void (*callback)(void *context), void *context); - - /** - * You are in a room, a game is in progress, and the server is sending you the new input for the - * engine to keep up to date with the current happenings. Pass it on to the engine using - * flib_gameconn_send_enginemsg. - */ - void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const uint8_t *message, size_t size), void *context); - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * This file contains functions for communicating with a Hedgewars server to chat, prepare and play + * rounds of Hedgewars. + * + * To use this, first create a netconn object by calling flib_netconn_create. This will start the + * connection to the game server (which might fail right away, the function returns null then). You + * should also register your callback functions right at the start to ensure you don't miss any + * callbacks. + * + * In order to allow the netconn to run, you should regularly call flib_netconn_tick(), which + * performs network I/O and calls your callbacks on interesting events. + * + * When the connection is closed, you will receive the onDisconnect callback. This is the signal to + * destroy the netconn and stop calling tick(). + * + * The connection process lasts from the time you create the netconn until you receive the + * onConnected callback (or onDisconnected in case something goes wrong). During that time, you + * might receive the onNickTaken and onPasswordRequest callbacks; see their description for more + * information on how to handle them. You could also receive other callbacks during connecting (e.g. + * about the room list), but it should be safe to ignore them. + * + * Once you are connected, you are in the lobby, and you can enter rooms and leave them again. The + * room and lobby states have different protocols, so many commands only work in either one or the + * other. If you are in a room you might also be in a game, but most of the functions behave the + * same ingame as in a room. + * + * The state changes from lobby to room when the server tells you that you just entered one, which + * will also trigger the onEnterRoom callback. This usually happens in reply to either a joinRoom, + * createRoom or playerFollow command. + * + * The state changes back to lobby when the room is dissolved, when you are kicked from the room, or + * when you actively leave the room using flib_netconn_send_leaveRoom. The first two events will + * trigger the onLeaveRoom callback. + */ + +#ifndef NETCONN_H_ +#define NETCONN_H_ + +#include "../model/gamesetup.h" +#include "../model/scheme.h" +#include "../model/room.h" + +#include +#include +#include + +#define NETCONN_STATE_CONNECTING 0 +#define NETCONN_STATE_LOBBY 1 +#define NETCONN_STATE_ROOM 2 +#define NETCONN_STATE_DISCONNECTED 10 + +#define NETCONN_DISCONNECT_NORMAL 0 //!< The connection was closed normally +#define NETCONN_DISCONNECT_SERVER_TOO_OLD 1 //!< The server has a lower protocol version than we do +#define NETCONN_DISCONNECT_AUTH_FAILED 2 //!< You sent a password with flib_netconn_send_password that was not accepted +#define NETCONN_DISCONNECT_CONNLOST 3 //!< The network connection was lost +#define NETCONN_DISCONNECT_INTERNAL_ERROR 100 //!< Something went wrong in frontlib itself + +#define NETCONN_ROOMLEAVE_ABANDONED 0 //!< The room was closed because the chief left +#define NETCONN_ROOMLEAVE_KICKED 1 //!< You have been kicked from the room + +#define NETCONN_MSG_TYPE_PLAYERINFO 0 //!< A response to flib_netconn_send_playerInfo +#define NETCONN_MSG_TYPE_SERVERMESSAGE 1 //!< The welcome message when connecting to the lobby +#define NETCONN_MSG_TYPE_WARNING 2 //!< A general warning message +#define NETCONN_MSG_TYPE_ERROR 3 //!< A general error message + +#define NETCONN_MAPCHANGE_FULL 0 +#define NETCONN_MAPCHANGE_MAP 1 +#define NETCONN_MAPCHANGE_MAPGEN 2 +#define NETCONN_MAPCHANGE_DRAWNMAP 3 +#define NETCONN_MAPCHANGE_MAZE_SIZE 4 +#define NETCONN_MAPCHANGE_TEMPLATE 5 +#define NETCONN_MAPCHANGE_THEME 6 +#define NETCONN_MAPCHANGE_SEED 7 + +typedef struct _flib_netconn flib_netconn; + +/** + * Create a new netplay connection with these parameters. + * The path to the data directory must end with a path delimiter (e.g. C:\Games\Hedgewars\Data\) + */ +flib_netconn *flib_netconn_create(const char *playerName, const char *dataDirPath, const char *host, int port); +void flib_netconn_destroy(flib_netconn *conn); + +/** + * Perform I/O operations and call callbacks if something interesting happens. + * Should be called regularly. + */ +void flib_netconn_tick(flib_netconn *conn); + +/** + * Are you currently the owner of this room? The return value only makes sense in + * NETCONN_STATE_ROOM and NETCONN_STATE_INGAME states. + */ +bool flib_netconn_is_chief(flib_netconn *conn); + +/** + * Returns the playername. This is *probably* the one provided on creation, but if that name was + * already taken, a different one could have been set by the onNickTaken callback or its default + * implementation. + */ +const char *flib_netconn_get_playername(flib_netconn *conn); + +/** + * Generate a game setup from the current room state. + * Returns NULL if the room state does not contain enough information for a complete game setup, + * or if an error occurs. + * + * The new gamesetup must be destroyed with flib_gamesetup_destroy(). + */ +flib_gamesetup *flib_netconn_create_gamesetup(flib_netconn *conn); + + + + +// Send functions needed when connecting and disconnecting + + /** + * Request a different nickname. + * This function only makes sense in reaction to an onNickTaken callback, because the netconn + * automatically requests the nickname you provide on creation, and once the server accepts the + * nickname it can no longer be changed. + */ + int flib_netconn_send_nick(flib_netconn *conn, const char *nick); + + /** + * Send the password in reply to a password request. + * If the server does not accept the password, you will be disconnected + * (NETCONN_DISCONNECT_AUTH_FAILED) + */ + int flib_netconn_send_password(flib_netconn *conn, const char *passwd); + + /** + * Tell the server that you want to leave. If successful, the server will disconnect you. + */ + int flib_netconn_send_quit(flib_netconn *conn, const char *quitmsg); + + +// Send functions that make sense both in the lobby and in rooms + + /** + * Send a chat message. This message is either sent to the lobby or the room, depending on + * whether you are in a room at the moment. The message is not echoed back to you. + */ + int flib_netconn_send_chat(flib_netconn *conn, const char *chat); + + /** + * Kick a player. This has different meanings in the lobby and in a room; + * In the lobby, it will kick the player from the server, and you need to be a server admin to + * do it. In a room, it will kick the player from the room, and you need to be room chief. + */ + int flib_netconn_send_kick(flib_netconn *conn, const char *playerName); + + /** + * Request information about a player (e.g. current room, version, partial IP). If the action + * succeeds, you will receive an onMessage callback with NETCONN_MSG_TYPE_PLAYERINFO containing + * the requested information. + */ + int flib_netconn_send_playerInfo(flib_netconn *conn, const char *playerName); + + +// Send functions that only make sense in the lobby + + /** + * Request an update of the room list. Only makes sense when in lobby state. + * If the action succeeds, you will receive an onRoomlist callback containing the current room + * data. + */ + int flib_netconn_send_request_roomlist(flib_netconn *conn); + + /** + * Join a room as guest (not chief). Only makes sense when in lobby state. If the action + * succeeds, you will receive an onEnterRoom callback with chief=false followed by other + * callbacks with current room information. + */ + int flib_netconn_send_joinRoom(flib_netconn *conn, const char *room); + + /** + * Follow a player. Only valid in the lobby. If the player is in a room (or in a game), this + * command is analogous to calling flib_netconn_send_joinRoom with that room. + */ + int flib_netconn_send_playerFollow(flib_netconn *conn, const char *playerName); + + /** + * Create and join a new room. Only makes sense when in lobby state. If the action succeeds, + * you will receive an onEnterRoom callback with chief=true. + */ + int flib_netconn_send_createRoom(flib_netconn *conn, const char *room); + + /** + * Ban a player. The scope of this ban depends on whether you are in a room or in the lobby. + * In a room, you need to be the room chief, and the ban will apply to the room only. In the + * lobby, you need to be server admin to ban someone, and the ban applies to the entire server. + */ + int flib_netconn_send_ban(flib_netconn *conn, const char *playerName); + + /** + * Does something administrator-y. At any rate you need to be an administrator and in the lobby + * to use this command. + */ + int flib_netconn_send_clearAccountsCache(flib_netconn *conn); + + /** + * Sets a server variable to the indicated value. Only makes sense if you are server admin and + * in the lobby. Known variables are MOTD_NEW, MOTD_OLD and LATEST_PROTO. MOTD_OLD is shown to + * players with older protocol versions, to inform them that they might want to update. + */ + int flib_netconn_send_setServerVar(flib_netconn *conn, const char *name, const char *value); + + /** + * Queries all server variables. Only makes sense if you are server admin and in the lobby. + * If the action succeeds, you will receive several onServerVar callbacks with the + * current values of all server variables. + */ + int flib_netconn_send_getServerVars(flib_netconn *conn); + + +// Send functions that only make sense in a room + + /** + * Leave the room for the lobby. Only makes sense in room state. msg can be NULL if you don't + * want to send a message. The server always accepts a part command, so once you send it off, + * you can just assume that you are back in the lobby. + */ + int flib_netconn_send_leaveRoom(flib_netconn *conn, const char *msg); + + /** + * Change your "ready" status in the room. Only makes sense when in room state. If the action + * succeeds, you will receive an onClientFlags callback containing the change. + */ + int flib_netconn_send_toggleReady(flib_netconn *conn); + + /** + * Add a team to the current room. Apart from the "fixed" team information, this also includes + * the color, but not the number of hogs. Only makes sense when in room state. If the action + * succeeds, you will receive an onTeamAccepted callback with the name of the team. + * + * Notes: Technically, sending a color here is the only way for a non-chief to set the color of + * her own team. The server remembers this color and even generates a separate teamColor message + * to inform everyone of it. However, at the moment the frontends generally override this color + * with one they choose themselves in order to deal with unfortunate behavior of the QtFrontend, + * which always sends color index 0 when adding a team but thinks that the team has a random + * color. The chief always sends a new color in order to bring the QtFrontend back into sync. + */ + int flib_netconn_send_addTeam(flib_netconn *conn, const flib_team *team); + + /** + * Remove the team with the name teamname. Only makes sense when in room state. + * The server does not send a reply on success. + */ + int flib_netconn_send_removeTeam(flib_netconn *conn, const char *teamname); + + +// Send functions that only make sense in a room and if you are room chief + + /** + * Rename the current room. Only makes sense in room state and if you are chief. If the action + * succeeds, you (and everyone else on the server) will receive an onRoomUpdate message + * containing the change. + */ + int flib_netconn_send_renameRoom(flib_netconn *conn, const char *roomName); + + /** + * Set the number of hogs for a team. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_teamHogCount(flib_netconn *conn, const char *teamname, int hogcount); + + /** + * Set the teamcolor of a team. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_teamColor(flib_netconn *conn, const char *teamname, int colorIndex); + + /** + * Set the weaponset for the room. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_weaponset(flib_netconn *conn, const flib_weaponset *weaponset); + + /** + * Set the map for the room. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_map(flib_netconn *conn, const flib_map *map); + + /** + * Set the mapname. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapName(flib_netconn *conn, const char *mapName); + + /** + * Set the map generator (regular, maze, drawn, named). Only makes sense in room state and if + * you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapGen(flib_netconn *conn, int mapGen); + + /** + * Set the map template for regular maps. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapTemplate(flib_netconn *conn, int templateFilter); + + /** + * Set the maze template (maze size) for mazes. Only makes sense in room state and if you are + * chief. The server does not send a reply. + */ + int flib_netconn_send_mapMazeSize(flib_netconn *conn, int mazeSize); + + /** + * Set the seed for the map. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapSeed(flib_netconn *conn, const char *seed); + + /** + * Set the theme for the map. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapTheme(flib_netconn *conn, const char *theme); + + /** + * Set the draw data for the drawn map. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_mapDrawdata(flib_netconn *conn, const uint8_t *drawData, size_t size); + + /** + * Set the script (game style). Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_script(flib_netconn *conn, const char *scriptName); + + /** + * Set the scheme. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_scheme(flib_netconn *conn, const flib_scheme *scheme); + + /** + * Signal that you want to start the game. Only makes sense in room state and if you are chief. + * The server will check whether all players are ready and whether it believes the setup makes + * sense (e.g. more than one clan). If the server is satisfied, you will receive an onRunGame + * callback (all other clients in the room are notified the same way). Otherwise the server + * might answer with a warning, or might not answer at all. + */ + int flib_netconn_send_startGame(flib_netconn *conn); + + /** + * Allow/forbid players to join the room. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_toggleRestrictJoins(flib_netconn *conn); + + /** + * Allow/forbid adding teams to the room. Only makes sense in room state and if you are chief. + * The server does not send a reply. + */ + int flib_netconn_send_toggleRestrictTeams(flib_netconn *conn); + + +// Send functions that are only needed for running a game + + /** + * Send a teamchat message, forwarded from the engine. Only makes sense ingame. + * The server does not send a reply. In contrast to a Chat message, the server + * automatically converts this into an engine message and passes it on to the other + * clients. + */ + int flib_netconn_send_teamchat(flib_netconn *conn, const char *msg); + + /** + * Send an engine message. Only makes sense when ingame. In a networked game, you have to pass + * all the engine messages from the engine here, and they will be spread to all other clients + * in the game to keep the game in sync. + */ + int flib_netconn_send_engineMessage(flib_netconn *conn, const uint8_t *message, size_t size); + + /** + * Inform the server that the round has ended. Call this when the engine has disconnected, + * passing 1 if the round ended normally, 0 otherwise. + */ + int flib_netconn_send_roundfinished(flib_netconn *conn, bool withoutError); + + + + + +// Callbacks that are important for connecting/disconnecting + + /** + * onNickTaken is called when connecting to the server, if it turns out that there is already a + * player with the same nick. + * In order to proceed, a new nickname needs to be sent to the server using + * flib_netconn_send_nick() (or of course you can bail out and send a QUIT). + * If you don't set a callback, the netconn will automatically react by generating a new name. + */ + void flib_netconn_onNickTaken(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); + + /** + * When connecting with a registered nickname, the server will ask for a password before + * admitting you in. This callback is called when that happens. As a reaction, you can send the + * password using flib_netconn_send_password. If you don't register a callback, the default + * behavior is to just quit in a way that will cause a disconnect with + * NETCONN_DISCONNECT_AUTH_FAILED. + * + * You can't just choose a new nickname when you receive this callback, because at that point + * the server has already accepted your nick. + */ + void flib_netconn_onPasswordRequest(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); + + /** + * This is called when the server has accepted our nickname (and possibly password) and we have + * entered the lobby. + */ + void flib_netconn_onConnected(flib_netconn *conn, void (*callback)(void *context), void* context); + + /** + * This is always the last callback (unless the netconn is destroyed early), and the netconn + * should be destroyed when it is received. The reason for the disconnect is passed as one of + * the NETCONN_DISCONNECT_ constants. Sometimes a message is included as well, but that + * parameter might also be NULL. + */ + void flib_netconn_onDisconnected(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void* context); + + +// Callbacks that make sense in most situations + + /** + * Callback for several informational messages that should be displayed to the user + * (e.g. in the chat window), but do not require a reaction. If a game is running, you might + * want to redirect some of these messages to the engine as well so the user will see them. + */ + void flib_netconn_onMessage(flib_netconn *conn, void (*callback)(void *context, int msgtype, const char *msg), void* context); + + /** + * We received a chat message. Where this message belongs depends on the current state + * (lobby/room). If a game is running the message should be passed to the engine. + */ + void flib_netconn_onChat(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *msg), void* context); + + /** + * Callbacks for incremental room list updates. They will fire whenever these events occur, + * even before you first query the actual roomlist - so be sure not to blindly reference your + * room list in these callbacks. The server currently only sends updates when a room changes + * its name, so in order to update other room information you need to query the roomlist again + * (see send_request_roomlist / onRoomlist). + */ + void flib_netconn_onRoomAdd(flib_netconn *conn, void (*callback)(void *context, const flib_room *room), void* context); + void flib_netconn_onRoomDelete(flib_netconn *conn, void (*callback)(void *context, const char *name), void* context); + void flib_netconn_onRoomUpdate(flib_netconn *conn, void (*callback)(void *context, const char *oldName, const flib_room *room), void* context); + + /** + * Callbacks for players joining or leaving the lobby. In contrast to the roomlist updates, you + * will get a JOIN callback for every player already on the server when you join (and there is + * no direct way to query the current playerlist) + * + * NOTE: partMessage may be NULL. + */ + void flib_netconn_onLobbyJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); + void flib_netconn_onLobbyLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context); + + /** + * This is called when the server informs us that one or more flags associated with a + * player/client have changed. + * + * nick is the name of the player, flags is a string containing one character for each modified + * flag (see below), and newFlagState signals whether the flags should be set to true or false. + * + * Some of these flags are important for protocol purposes (especially if they are set for you) + * while others are just informational. Also, some flags are only relevant for players who are + * in the same room as you, and the server will not inform you if they change for others. + * + * These are the currently known/used flags: + * a: Server admin. Always updated. + * h: Room chief. Updated when in the same room. + * r: Ready to play. Updated when in the same room. + * u: Registered user. Always updated. + * + * The server tells us the 'a' and 'u' flags for all players when we first join the lobby, and + * also tells us the 'r' and 'h' flags when we join or create a room. It assumes that all flags + * are initially false, so it will typically only tell you to set certain flags to true when + * transmitting the initial states. Reset the 'h' and 'r' flags to false when leaving a room, + * or when entering room state, to arrive at the right state for each player. + * + * The room chief state of yourself is particularly important because it determines whether you + * can modify settings of the current room. Generally, when you create a room you start out + * being room chief, and when you join an existing room you are not. However, if the original + * chief leaves a room, the server can choose a new chief, and if that happens the chief flag + * will be transferred to someone else. + */ + void flib_netconn_onClientFlags(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *flags, bool newFlagState), void *context); + +// Callbacks that happen only in response to specific requests + + /** + * Response to flib_netconn_send_request_roomlist(). + * The rooms array contains the current state of all rooms on the server. + */ + void flib_netconn_onRoomlist(flib_netconn *conn, void (*callback)(void *context, const flib_room **rooms, int roomCount), void* context); + + /** + * Response to flib_netconn_send_joinRoom, flib_netconn_send_playerFollow or + * flib_netconn_send_createRoom. + * + * You just left the lobby and entered a room. + * If chief is true, you can and should send a full configuration for the room now. This + * consists of ammo, scheme, script and map, where map apparently has to come last. + */ + void flib_netconn_onEnterRoom(flib_netconn *conn, void (*callback)(void *context, bool chief), void *context); + + /** + * Response to flib_netconn_send_addTeam. + * The server might reject your team for several reasons, e.g. because it has the same name as + * an existing team, or because the room chief restricted adding new teams. If the team is + * accepted by the server, this callback is fired. + * + * If you are the room chief, you are expected to provide the hog count for your own team now + * using flib_netconn_send_teamHogCount. The color of the team is already set to the one you + * provided in addTeam. + */ + void flib_netconn_onTeamAccepted(flib_netconn *conn, void (*callback)(void *context, const char *team), void *context); + + /** + * When you query the server vars with flib_netconn_send_getServerVars (only works as admin), + * the server replies with a list of them. This callback is called for each entry in that list. + */ + void flib_netconn_onServerVar(flib_netconn *conn, void (*callback)(void *context, const char *name, const char *value), void *context); + + +// Callbacks that are only relevant in a room + + /** + * You just left a room and entered the lobby again. + * reason is one of the NETCONN_ROOMLEAVE_ constants (usually a kick). + * This will not be called when you actively leave a room using PART. + * Don't confuse with onRoomLeave, which indicates that *someone else* left the room. + */ + void flib_netconn_onLeaveRoom(flib_netconn *conn, void (*callback)(void *context, int reason, const char *message), void *context); + + /** + * Someone joined or left the room you are currently in. + * Analogous to onLobbyJoin/leave, you will receive the join callback for all players that are + * already in the room when you join, including for yourself (this is actually how it is + * determined that you joined a room). + * + * However, you will *not* receive onRoomLeave messages for everyone when you leave the room. + */ + void flib_netconn_onRoomJoin(flib_netconn *conn, void (*callback)(void *context, const char *nick), void* context); + void flib_netconn_onRoomLeave(flib_netconn *conn, void (*callback)(void *context, const char *nick, const char *partMessage), void* context); + + /** + * A new team was added to the room. The person who adds a team does NOT receive this callback + * (he gets onTeamAccepted instead). + * + * The team does not contain bindings, stats, weaponset, color or the number of hogs (but it is + * assumed to be the default of 4). + * + * If you receive this message and you are the room chief, you may want to send a color and hog + * count for this team using flib_netconn_send_teamHogCount / teamColor for QtFrontend + * compatibility. + * + * The server currently sends another message with the color of the team to the same recipients + * as this teamAdd message, which will trigger an onTeamColorChanged callback. See the + * description of flib_netconn_send_addTeam for more information. + */ + void flib_netconn_onTeamAdd(flib_netconn *conn, void (*callback)(void *context, const flib_team *team), void *context); + + /** + * A team was removed from the room. The person who removed the team will not receive this + * callback. + */ + void flib_netconn_onTeamDelete(flib_netconn *conn, void (*callback)(void *context, const char *teamname), void *context); + + /** + * The number of hogs in a team has been changed by the room chief. If you are the chief and + * change the number of hogs yourself, you will not receive this callback. + */ + void flib_netconn_onHogCountChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int hogs), void *context); + + /** + * The color of a team has been set or changed. The client who set or changed the color will + * not receive this callback. + * + * Normally, only the chief can change the color of a team. However, this message is also + * generated when a team is added, so you can receive it even as chief. + */ + void flib_netconn_onTeamColorChanged(flib_netconn *conn, void (*callback)(void *context, const char *teamName, int colorIndex), void *context); + + /** + * The room chief has changed the game scheme (or you just joined a room). + * You will not receive this callback if you changed the scheme yourself. + */ + void flib_netconn_onSchemeChanged(flib_netconn *conn, void (*callback)(void *context, const flib_scheme *scheme), void *context); + + /** + * The room chief has changed the map (or you just joined a room). Only non-chiefs receive these + * messages. + * + * To reduce the number of callback functions, the netconn keeps track of the current map + * settings and always passes the entire current map config, but informs the callee about what + * has changed (see the NETCONN_MAPCHANGE_ constants). + * + * Caution: Due to the way the protocol works, the map might not be complete at this point if it + * is a hand-drawn map, because the "full" map config does not include the drawn map data. + */ + void flib_netconn_onMapChanged(flib_netconn *conn, void (*callback)(void *context, const flib_map *map, int changetype), void *context); + + /** + * The room chief has changed the game style (or you just joined a room). If you are the chief + * and change the style yourself, you will not receive this callback. + */ + void flib_netconn_onScriptChanged(flib_netconn *conn, void (*callback)(void *context, const char *script), void *context); + + /** + * The room chief has changed the weaponset (or you just joined a room). If you are the chief + * and change the weaponset yourself, you will not receive this callback. + */ + void flib_netconn_onWeaponsetChanged(flib_netconn *conn, void (*callback)(void *context, const flib_weaponset *weaponset), void *context); + + /** + * The game is starting. Fire up the engine and join in! + * You can let the netconn generate the right game setup using flib_netconn_create_gamesetup + */ + void flib_netconn_onRunGame(flib_netconn *conn, void (*callback)(void *context), void *context); + + /** + * You are in a room, a game is in progress, and the server is sending you the new input for the + * engine to keep up to date with the current happenings. Pass it on to the engine using + * flib_gameconn_send_enginemsg. + */ + void flib_netconn_onEngineMessage(flib_netconn *conn, void (*callback)(void *context, const uint8_t *message, size_t size), void *context); + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/frontlib/net/netconn_internal.h --- a/project_files/frontlib/net/netconn_internal.h Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/frontlib/net/netconn_internal.h Tue Dec 25 04:45:22 2012 +0100 @@ -1,151 +1,151 @@ -/* - * Hedgewars, a free turn based strategy game - * Copyright (C) 2012 Simeon Maxein - * - * 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; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -/** - * Common definitions needed by netconn functions, to allow splitting them into several files. - */ - -#ifndef NETCONN_INTERNAL_H_ -#define NETCONN_INTERNAL_H_ - -#include "netconn.h" -#include "netbase.h" -#include "../model/map.h" -#include "../model/team.h" -#include "../model/weapon.h" -#include "../model/room.h" - -#include -#include -#include - -struct _flib_netconn { - flib_netbase *netBase; - char *playerName; - char *dataDirPath; - - int netconnState; // One of the NETCONN_STATE constants - - bool isChief; // Player can modify the current room - flib_map *map; - flib_teamlist pendingTeamlist; - flib_teamlist teamlist; - flib_scheme *scheme; - char *style; - flib_weaponset *weaponset; - - void (*onMessageCb)(void *context, int msgtype, const char *msg); - void *onMessageCtx; - - void (*onConnectedCb)(void *context); - void *onConnectedCtx; - - void (*onDisconnectedCb)(void *context, int reason, const char *message); - void *onDisconnectedCtx; - - void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount); - void *onRoomlistCtx; - - void (*onRoomAddCb)(void *context, const flib_room *room); - void *onRoomAddCtx; - - void (*onRoomDeleteCb)(void *context, const char *name); - void *onRoomDeleteCtx; - - void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room); - void *onRoomUpdateCtx; - - void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState); - void *onClientFlagsCtx; - - void (*onChatCb)(void *context, const char *nick, const char *msg); - void *onChatCtx; - - void (*onLobbyJoinCb)(void *context, const char *nick); - void *onLobbyJoinCtx; - - void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage); - void *onLobbyLeaveCtx; - - void (*onRoomJoinCb)(void *context, const char *nick); - void *onRoomJoinCtx; - - void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage); - void *onRoomLeaveCtx; - - void (*onNickTakenCb)(void *context, const char *nick); - void *onNickTakenCtx; - - void (*onPasswordRequestCb)(void *context, const char *nick); - void *onPasswordRequestCtx; - - void (*onEnterRoomCb)(void *context, bool chief); - void *onEnterRoomCtx; - - void (*onLeaveRoomCb)(void *context, int reason, const char *message); - void *onLeaveRoomCtx; - - void (*onTeamAddCb)(void *context, const flib_team *team); - void *onTeamAddCtx; - - void (*onTeamDeleteCb)(void *context, const char *teamname); - void *onTeamDeleteCtx; - - void (*onRunGameCb)(void *context); - void *onRunGameCtx; - - void (*onTeamAcceptedCb)(void *context, const char *teamName); - void *onTeamAcceptedCtx; - - void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs); - void *onHogCountChangedCtx; - - void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex); - void *onTeamColorChangedCtx; - - void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size); - void *onEngineMessageCtx; - - void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme); - void *onSchemeChangedCtx; - - void (*onMapChangedCb)(void *context, const flib_map *map, int changetype); - void *onMapChangedCtx; - - void (*onScriptChangedCb)(void *context, const char *script); - void *onScriptChangedCtx; - - void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset); - void *onWeaponsetChangedCtx; - - void (*onServerVarCb)(void *context, const char *name, const char *value); - void *onServerVarCtx; - - bool running; - bool destroyRequested; -}; - -void netconn_clearCallbacks(flib_netconn *conn); -void netconn_leaveRoom(flib_netconn *conn); -void netconn_setMap(flib_netconn *conn, const flib_map *map); -void netconn_setWeaponset(flib_netconn *conn, const flib_weaponset *weaponset); -void netconn_setScript(flib_netconn *conn, const char *script); -void netconn_setScheme(flib_netconn *conn, const flib_scheme *scheme); - -#endif +/* + * Hedgewars, a free turn based strategy game + * Copyright (C) 2012 Simeon Maxein + * + * 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; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** + * Common definitions needed by netconn functions, to allow splitting them into several files. + */ + +#ifndef NETCONN_INTERNAL_H_ +#define NETCONN_INTERNAL_H_ + +#include "netconn.h" +#include "netbase.h" +#include "../model/map.h" +#include "../model/team.h" +#include "../model/weapon.h" +#include "../model/room.h" + +#include +#include +#include + +struct _flib_netconn { + flib_netbase *netBase; + char *playerName; + char *dataDirPath; + + int netconnState; //!< One of the NETCONN_STATE constants + + bool isChief; //!< Player can modify the current room + flib_map *map; + flib_teamlist pendingTeamlist; + flib_teamlist teamlist; + flib_scheme *scheme; + char *style; + flib_weaponset *weaponset; + + void (*onMessageCb)(void *context, int msgtype, const char *msg); + void *onMessageCtx; + + void (*onConnectedCb)(void *context); + void *onConnectedCtx; + + void (*onDisconnectedCb)(void *context, int reason, const char *message); + void *onDisconnectedCtx; + + void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount); + void *onRoomlistCtx; + + void (*onRoomAddCb)(void *context, const flib_room *room); + void *onRoomAddCtx; + + void (*onRoomDeleteCb)(void *context, const char *name); + void *onRoomDeleteCtx; + + void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room); + void *onRoomUpdateCtx; + + void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState); + void *onClientFlagsCtx; + + void (*onChatCb)(void *context, const char *nick, const char *msg); + void *onChatCtx; + + void (*onLobbyJoinCb)(void *context, const char *nick); + void *onLobbyJoinCtx; + + void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage); + void *onLobbyLeaveCtx; + + void (*onRoomJoinCb)(void *context, const char *nick); + void *onRoomJoinCtx; + + void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage); + void *onRoomLeaveCtx; + + void (*onNickTakenCb)(void *context, const char *nick); + void *onNickTakenCtx; + + void (*onPasswordRequestCb)(void *context, const char *nick); + void *onPasswordRequestCtx; + + void (*onEnterRoomCb)(void *context, bool chief); + void *onEnterRoomCtx; + + void (*onLeaveRoomCb)(void *context, int reason, const char *message); + void *onLeaveRoomCtx; + + void (*onTeamAddCb)(void *context, const flib_team *team); + void *onTeamAddCtx; + + void (*onTeamDeleteCb)(void *context, const char *teamname); + void *onTeamDeleteCtx; + + void (*onRunGameCb)(void *context); + void *onRunGameCtx; + + void (*onTeamAcceptedCb)(void *context, const char *teamName); + void *onTeamAcceptedCtx; + + void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs); + void *onHogCountChangedCtx; + + void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex); + void *onTeamColorChangedCtx; + + void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size); + void *onEngineMessageCtx; + + void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme); + void *onSchemeChangedCtx; + + void (*onMapChangedCb)(void *context, const flib_map *map, int changetype); + void *onMapChangedCtx; + + void (*onScriptChangedCb)(void *context, const char *script); + void *onScriptChangedCtx; + + void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset); + void *onWeaponsetChangedCtx; + + void (*onServerVarCb)(void *context, const char *name, const char *value); + void *onServerVarCtx; + + bool running; + bool destroyRequested; +}; + +void netconn_clearCallbacks(flib_netconn *conn); +void netconn_leaveRoom(flib_netconn *conn); +void netconn_setMap(flib_netconn *conn, const flib_map *map); +void netconn_setWeaponset(flib_netconn *conn, const flib_weaponset *weaponset); +void netconn_setScript(flib_netconn *conn, const char *script); +void netconn_setScheme(flib_netconn *conn, const flib_scheme *scheme); + +#endif diff -r d24257910f8d -r aaefa587e277 project_files/hedgewars.pro --- a/project_files/hedgewars.pro Sun Dec 02 00:03:16 2012 +0100 +++ b/project_files/hedgewars.pro Tue Dec 25 04:45:22 2012 +0100 @@ -1,271 +1,272 @@ -TEMPLATE = app -TARGET = hedgewars -DEPENDPATH += ../QTfrontend/ -INCLUDEPATH += ../QTfrontend -INCLUDEPATH += ../QTfrontend/model -INCLUDEPATH += ../QTfrontend/ui -INCLUDEPATH += ../QTfrontend/ui/widget -INCLUDEPATH += ../QTfrontend/ui/page -INCLUDEPATH += ../QTfrontend/ui/dialog -INCLUDEPATH += ../QTfrontend/net -INCLUDEPATH += ../QTfrontend/util -INCLUDEPATH += ../misc/physfs/src -INCLUDEPATH += ../misc/physfs/extras -INCLUDEPATH += ../project_files/frontlib - -DESTDIR = ../bin - -QT += network -QT += webkit - -HEADERS += ../QTfrontend/model/ThemeModel.h \ - ../QTfrontend/model/MapModel.h \ - ../QTfrontend/model/ammoSchemeModel.h \ - ../QTfrontend/model/netserverslist.h \ - ../QTfrontend/ui/page/pagedrawmap.h \ - ../QTfrontend/ui/page/pagedata.h \ - ../QTfrontend/ui/page/pagetraining.h \ - ../QTfrontend/ui/page/pageselectweapon.h \ - ../QTfrontend/ui/page/pagesingleplayer.h \ - ../QTfrontend/ui/page/pagenettype.h \ - ../QTfrontend/ui/page/pageingame.h \ - ../QTfrontend/ui/page/pageadmin.h \ - ../QTfrontend/ui/page/pagescheme.h \ - ../QTfrontend/ui/page/pagemultiplayer.h \ - ../QTfrontend/ui/page/pageplayrecord.h \ - ../QTfrontend/ui/page/pagemain.h \ - ../QTfrontend/ui/page/pageoptions.h \ - ../QTfrontend/ui/page/pagenetgame.h \ - ../QTfrontend/ui/page/pageeditteam.h \ - ../QTfrontend/ui/page/pageconnecting.h \ - ../QTfrontend/ui/page/pageroomslist.h \ - ../QTfrontend/ui/page/pagenet.h \ - ../QTfrontend/ui/page/pagecampaign.h \ - ../QTfrontend/ui/page/pageinfo.h \ - ../QTfrontend/ui/page/pagenetserver.h \ - ../QTfrontend/ui/page/pagegamestats.h \ - ../QTfrontend/ui/dialog/input_ip.h \ - ../QTfrontend/ui/qaspectratiolayout.h \ - ../QTfrontend/ui/widget/bgwidget.h \ - ../QTfrontend/ui/widget/fpsedit.h \ - ../QTfrontend/ui/widget/FreqSpinBox.h \ - ../QTfrontend/ui/widget/igbox.h \ - ../QTfrontend/ui/widget/chatwidget.h \ - ../QTfrontend/ui/widget/togglebutton.h \ - ../QTfrontend/ui/widget/SquareLabel.h \ - ../QTfrontend/ui/widget/itemNum.h \ - ../QTfrontend/ui/widget/frameTeam.h \ - ../QTfrontend/ui/widget/teamselect.h \ - ../QTfrontend/ui/widget/vertScrollArea.h \ - ../QTfrontend/ui/widget/about.h \ - ../QTfrontend/ui/widget/teamselhelper.h \ - ../QTfrontend/ui/widget/drawmapwidget.h \ - ../QTfrontend/ui/widget/databrowser.h \ - ../QTfrontend/ui/widget/hedgehogerWidget.h \ - ../QTfrontend/ui/widget/selectWeapon.h \ - ../QTfrontend/ui/widget/weaponItem.h \ - ../QTfrontend/ui/widget/gamecfgwidget.h \ - ../QTfrontend/ui/widget/mapContainer.h \ - ../QTfrontend/ui/widget/HistoryLineEdit.h \ - ../QTfrontend/ui/widget/SmartLineEdit.h \ - ../QTfrontend/util/DataManager.h \ - ../QTfrontend/net/netregister.h \ - ../QTfrontend/net/netserver.h \ - ../QTfrontend/net/netudpwidget.h \ - ../QTfrontend/net/tcpBase.h \ - ../QTfrontend/net/proto.h \ - ../QTfrontend/net/newnetclient.h \ - ../QTfrontend/net/netudpserver.h \ - ../QTfrontend/net/hwmap.h \ - ../QTfrontend/util/namegen.h \ - ../QTfrontend/ui/page/AbstractPage.h \ - ../QTfrontend/drawmapscene.h \ - ../QTfrontend/game.h \ - ../QTfrontend/gameuiconfig.h \ - ../QTfrontend/HWApplication.h \ - ../QTfrontend/hwform.h \ - ../QTfrontend/util/SDLInteraction.h \ - ../QTfrontend/team.h \ - ../QTfrontend/achievements.h \ - ../QTfrontend/binds.h \ - ../QTfrontend/ui_hwform.h \ - ../QTfrontend/KB.h \ - ../QTfrontend/hwconsts.h \ - ../QTfrontend/sdlkeys.h \ - ../QTfrontend/ui/mouseoverfilter.h \ - ../QTfrontend/ui/qpushbuttonwithsound.h \ - ../QTfrontend/ui/widget/qpushbuttonwithsound.h \ - ../QTfrontend/ui/page/pagefeedback.h \ - ../QTfrontend/model/roomslistmodel.h \ - ../QTfrontend/ui/dialog/input_password.h \ - ../QTfrontend/ui/widget/colorwidget.h \ - ../QTfrontend/model/HatModel.h \ - ../QTfrontend/model/GameStyleModel.h \ - ../QTfrontend/ui/page/pagevideos.h \ - ../QTfrontend/net/recorder.h \ - ../QTfrontend/ui/dialog/ask_quit.h \ - ../QTfrontend/ui/dialog/upload_video.h \ - ../QTfrontend/campaign.h \ - ../QTfrontend/model/playerslistmodel.h \ - ../QTfrontend/util/LibavInteraction.h \ - ../QTfrontend/util/FileEngine.h - - -SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \ - ../QTfrontend/model/MapModel.cpp \ - ../QTfrontend/model/ThemeModel.cpp \ - ../QTfrontend/model/netserverslist.cpp \ - ../QTfrontend/ui/qaspectratiolayout.cpp \ - ../QTfrontend/ui/page/pagemain.cpp \ - ../QTfrontend/ui/page/pagetraining.cpp \ - ../QTfrontend/ui/page/pageroomslist.cpp \ - ../QTfrontend/ui/page/pagemultiplayer.cpp \ - ../QTfrontend/ui/page/pagegamestats.cpp \ - ../QTfrontend/ui/page/pagenettype.cpp \ - ../QTfrontend/ui/page/pageeditteam.cpp \ - ../QTfrontend/ui/page/pagenetgame.cpp \ - ../QTfrontend/ui/page/pagedata.cpp \ - ../QTfrontend/ui/page/pagedrawmap.cpp \ - ../QTfrontend/ui/page/pageplayrecord.cpp \ - ../QTfrontend/ui/page/pageselectweapon.cpp \ - ../QTfrontend/ui/page/pageingame.cpp \ - ../QTfrontend/ui/page/pagenetserver.cpp \ - ../QTfrontend/ui/page/pagecampaign.cpp \ - ../QTfrontend/ui/page/pageadmin.cpp \ - ../QTfrontend/ui/page/pageinfo.cpp \ - ../QTfrontend/ui/page/pageconnecting.cpp \ - ../QTfrontend/ui/page/pagesingleplayer.cpp \ - ../QTfrontend/ui/page/pagenet.cpp \ - ../QTfrontend/ui/page/pagescheme.cpp \ - ../QTfrontend/ui/page/pageoptions.cpp \ - ../QTfrontend/ui/dialog/input_ip.cpp \ - ../QTfrontend/ui/widget/igbox.cpp \ - ../QTfrontend/ui/widget/selectWeapon.cpp \ - ../QTfrontend/ui/widget/FreqSpinBox.cpp \ - ../QTfrontend/ui/widget/SquareLabel.cpp \ - ../QTfrontend/ui/widget/frameTeam.cpp \ - ../QTfrontend/ui/widget/fpsedit.cpp \ - ../QTfrontend/ui/widget/databrowser.cpp \ - ../QTfrontend/ui/widget/teamselect.cpp \ - ../QTfrontend/ui/widget/gamecfgwidget.cpp \ - ../QTfrontend/ui/widget/chatwidget.cpp \ - ../QTfrontend/ui/widget/itemNum.cpp \ - ../QTfrontend/ui/widget/bgwidget.cpp \ - ../QTfrontend/ui/widget/about.cpp \ - ../QTfrontend/ui/widget/togglebutton.cpp \ - ../QTfrontend/ui/widget/vertScrollArea.cpp \ - ../QTfrontend/ui/widget/hedgehogerWidget.cpp \ - ../QTfrontend/ui/widget/teamselhelper.cpp \ - ../QTfrontend/ui/widget/drawmapwidget.cpp \ - ../QTfrontend/ui/widget/weaponItem.cpp \ - ../QTfrontend/ui/widget/mapContainer.cpp \ - ../QTfrontend/ui/widget/HistoryLineEdit.cpp \ - ../QTfrontend/ui/widget/SmartLineEdit.cpp \ - ../QTfrontend/util/DataManager.cpp \ - ../QTfrontend/net/tcpBase.cpp \ - ../QTfrontend/net/netregister.cpp \ - ../QTfrontend/net/proto.cpp \ - ../QTfrontend/net/hwmap.cpp \ - ../QTfrontend/net/netudpserver.cpp \ - ../QTfrontend/net/newnetclient.cpp \ - ../QTfrontend/net/netudpwidget.cpp \ - ../QTfrontend/net/netserver.cpp \ - ../QTfrontend/util/namegen.cpp \ - ../QTfrontend/ui/page/AbstractPage.cpp \ - ../QTfrontend/achievements.cpp \ - ../QTfrontend/binds.cpp \ - ../QTfrontend/drawmapscene.cpp \ - ../QTfrontend/game.cpp \ - ../QTfrontend/gameuiconfig.cpp \ - ../QTfrontend/HWApplication.cpp \ - ../QTfrontend/hwform.cpp \ - ../QTfrontend/main.cpp \ - ../QTfrontend/util/SDLInteraction.cpp \ - ../QTfrontend/team.cpp \ - ../QTfrontend/ui_hwform.cpp \ - ../QTfrontend/hwconsts.cpp \ - ../QTfrontend/ui/mouseoverfilter.cpp \ - ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp \ - ../QTfrontend/ui/page/pagefeedback.cpp \ - ../QTfrontend/model/roomslistmodel.cpp \ - ../QTfrontend/ui/dialog/input_password.cpp \ - ../QTfrontend/ui/widget/colorwidget.cpp \ - ../QTfrontend/model/HatModel.cpp \ - ../QTfrontend/model/GameStyleModel.cpp \ - ../QTfrontend/ui/page/pagevideos.cpp \ - ../QTfrontend/net/recorder.cpp \ - ../QTfrontend/ui/dialog/ask_quit.cpp \ - ../QTfrontend/ui/dialog/upload_video.cpp \ - ../QTfrontend/campaign.cpp \ - ../QTfrontend/model/playerslistmodel.cpp \ - ../QTfrontend/util/LibavInteraction.cpp \ - ../QTfrontend/util/FileEngine.cpp - - -TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \ - ../share/hedgewars/Data/Locale/hedgewars_bg.ts \ - ../share/hedgewars/Data/Locale/hedgewars_cs.ts \ - ../share/hedgewars/Data/Locale/hedgewars_da.ts \ - ../share/hedgewars/Data/Locale/hedgewars_de.ts \ - ../share/hedgewars/Data/Locale/hedgewars_el.ts \ - ../share/hedgewars/Data/Locale/hedgewars_en.ts \ - ../share/hedgewars/Data/Locale/hedgewars_es.ts \ - ../share/hedgewars/Data/Locale/hedgewars_fi.ts \ - ../share/hedgewars/Data/Locale/hedgewars_fr.ts \ - ../share/hedgewars/Data/Locale/hedgewars_gl.ts \ - ../share/hedgewars/Data/Locale/hedgewars_hu.ts \ - ../share/hedgewars/Data/Locale/hedgewars_it.ts \ - ../share/hedgewars/Data/Locale/hedgewars_ja.ts \ - ../share/hedgewars/Data/Locale/hedgewars_ko.ts \ - ../share/hedgewars/Data/Locale/hedgewars_lt.ts \ - ../share/hedgewars/Data/Locale/hedgewars_ms.ts \ - ../share/hedgewars/Data/Locale/hedgewars_nl.ts \ - ../share/hedgewars/Data/Locale/hedgewars_pl.ts \ - ../share/hedgewars/Data/Locale/hedgewars_pt_BR.ts \ - ../share/hedgewars/Data/Locale/hedgewars_pt_PT.ts \ - ../share/hedgewars/Data/Locale/hedgewars_ro.ts \ - ../share/hedgewars/Data/Locale/hedgewars_ru.ts \ - ../share/hedgewars/Data/Locale/hedgewars_sk.ts \ - ../share/hedgewars/Data/Locale/hedgewars_sv.ts \ - ../share/hedgewars/Data/Locale/hedgewars_tr_TR.ts \ - ../share/hedgewars/Data/Locale/hedgewars_uk.ts \ - ../share/hedgewars/Data/Locale/hedgewars_zh_CN.ts \ - ../share/hedgewars/Data/Locale/hedgewars_zh_TW.ts - -RESOURCES += ../QTfrontend/hedgewars.qrc - -LIBS += -L../bin -lphysfs -lfrontlib - -macx { - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 - QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk - - OBJECTIVE_SOURCES += ../QTfrontend/*.m ../QTfrontend/*.mm - SOURCES += ../QTfrontend/AutoUpdater.cpp ../QTfrontend/InstallController.cpp \ - ../../build/QTfrontend/hwconsts.cpp - HEADERS += ../QTfrontend/M3InstallController.h ../QTfrontend/M3Panel.h \ - ../QTfrontend/NSWorkspace_RBAdditions.h ../QTfrontend/AutoUpdater.h \ - ../QTfrontend/CocoaInitializer.h ../QTfrontend/InstallController.h \ - ../QTfrontend/SparkleAutoUpdater.h - - LIBS += -lobjc -framework AppKit -framework IOKit -framework Foundation -framework SDL -framework SDL_Mixer -framework Sparkle -DSPARKLE_ENABLED - INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL_Mixer.framework/Headers - CONFIG += warn_on x86 - #CONFIG += x86 ppc x86_64 ppc64 -} - -win32 { - RC_FILE = ../QTfrontend/hedgewars.rc - SOURCES += ../QTfrontend/xfire.cpp - INCLUDEPATH += ../misc/winutils/include - LIBS += -L../misc/winutils/lib -} - -!macx { - LIBS += -lSDL -lSDL_mixer -lSDL_net - !win32 { - INCLUDEPATH += /usr/local/include/SDL /usr/include/SDL - } -} - -FORMS += +TEMPLATE = app +TARGET = hedgewars +DEPENDPATH += ../QTfrontend/ +INCLUDEPATH += ../QTfrontend +INCLUDEPATH += ../QTfrontend/model +INCLUDEPATH += ../QTfrontend/ui +INCLUDEPATH += ../QTfrontend/ui/widget +INCLUDEPATH += ../QTfrontend/ui/page +INCLUDEPATH += ../QTfrontend/ui/dialog +INCLUDEPATH += ../QTfrontend/net +INCLUDEPATH += ../QTfrontend/util +INCLUDEPATH += ../misc/physfs/src +INCLUDEPATH += ../misc/physfs/extras + +DESTDIR = ../bin + +QT += network +QT += webkit + +HEADERS += ../QTfrontend/model/ThemeModel.h \ + ../QTfrontend/model/MapModel.h \ + ../QTfrontend/model/ammoSchemeModel.h \ + ../QTfrontend/model/netserverslist.h \ + ../QTfrontend/ui/page/pagedrawmap.h \ + ../QTfrontend/ui/page/pagedata.h \ + ../QTfrontend/ui/page/pagetraining.h \ + ../QTfrontend/ui/page/pageselectweapon.h \ + ../QTfrontend/ui/page/pagesingleplayer.h \ + ../QTfrontend/ui/page/pagenettype.h \ + ../QTfrontend/ui/page/pageingame.h \ + ../QTfrontend/ui/page/pageadmin.h \ + ../QTfrontend/ui/page/pagescheme.h \ + ../QTfrontend/ui/page/pagemultiplayer.h \ + ../QTfrontend/ui/page/pageplayrecord.h \ + ../QTfrontend/ui/page/pagemain.h \ + ../QTfrontend/ui/page/pageoptions.h \ + ../QTfrontend/ui/page/pagenetgame.h \ + ../QTfrontend/ui/page/pageeditteam.h \ + ../QTfrontend/ui/page/pageconnecting.h \ + ../QTfrontend/ui/page/pageroomslist.h \ + ../QTfrontend/ui/page/pagenet.h \ + ../QTfrontend/ui/page/pagecampaign.h \ + ../QTfrontend/ui/page/pageinfo.h \ + ../QTfrontend/ui/page/pagenetserver.h \ + ../QTfrontend/ui/page/pagegamestats.h \ + ../QTfrontend/ui/dialog/input_ip.h \ + ../QTfrontend/ui/qaspectratiolayout.h \ + ../QTfrontend/ui/widget/bgwidget.h \ + ../QTfrontend/ui/widget/fpsedit.h \ + ../QTfrontend/ui/widget/FreqSpinBox.h \ + ../QTfrontend/ui/widget/igbox.h \ + ../QTfrontend/ui/widget/chatwidget.h \ + ../QTfrontend/ui/widget/togglebutton.h \ + ../QTfrontend/ui/widget/SquareLabel.h \ + ../QTfrontend/ui/widget/itemNum.h \ + ../QTfrontend/ui/widget/frameTeam.h \ + ../QTfrontend/ui/widget/teamselect.h \ + ../QTfrontend/ui/widget/vertScrollArea.h \ + ../QTfrontend/ui/widget/about.h \ + ../QTfrontend/ui/widget/teamselhelper.h \ + ../QTfrontend/ui/widget/drawmapwidget.h \ + ../QTfrontend/ui/widget/databrowser.h \ + ../QTfrontend/ui/widget/hedgehogerWidget.h \ + ../QTfrontend/ui/widget/selectWeapon.h \ + ../QTfrontend/ui/widget/weaponItem.h \ + ../QTfrontend/ui/widget/gamecfgwidget.h \ + ../QTfrontend/ui/widget/mapContainer.h \ + ../QTfrontend/ui/widget/HistoryLineEdit.h \ + ../QTfrontend/ui/widget/SmartLineEdit.h \ + ../QTfrontend/util/DataManager.h \ + ../QTfrontend/net/netregister.h \ + ../QTfrontend/net/netserver.h \ + ../QTfrontend/net/netudpwidget.h \ + ../QTfrontend/net/tcpBase.h \ + ../QTfrontend/net/proto.h \ + ../QTfrontend/net/newnetclient.h \ + ../QTfrontend/net/netudpserver.h \ + ../QTfrontend/net/hwmap.h \ + ../QTfrontend/util/namegen.h \ + ../QTfrontend/ui/page/AbstractPage.h \ + ../QTfrontend/drawmapscene.h \ + ../QTfrontend/game.h \ + ../QTfrontend/gameuiconfig.h \ + ../QTfrontend/HWApplication.h \ + ../QTfrontend/hwform.h \ + ../QTfrontend/util/SDLInteraction.h \ + ../QTfrontend/team.h \ + ../QTfrontend/achievements.h \ + ../QTfrontend/binds.h \ + ../QTfrontend/ui_hwform.h \ + ../QTfrontend/KB.h \ + ../QTfrontend/hwconsts.h \ + ../QTfrontend/sdlkeys.h \ + ../QTfrontend/ui/mouseoverfilter.h \ + ../QTfrontend/ui/qpushbuttonwithsound.h \ + ../QTfrontend/ui/widget/qpushbuttonwithsound.h \ + ../QTfrontend/ui/page/pagefeedback.h \ + ../QTfrontend/model/roomslistmodel.h \ + ../QTfrontend/ui/dialog/input_password.h \ + ../QTfrontend/ui/widget/colorwidget.h \ + ../QTfrontend/model/HatModel.h \ + ../QTfrontend/model/GameStyleModel.h \ + ../QTfrontend/ui/page/pagevideos.h \ + ../QTfrontend/net/recorder.h \ + ../QTfrontend/ui/dialog/ask_quit.h \ + ../QTfrontend/ui/dialog/upload_video.h \ + ../QTfrontend/campaign.h \ + ../QTfrontend/model/playerslistmodel.h \ + ../QTfrontend/util/LibavInteraction.h \ + ../QTfrontend/util/FileEngine.h \ + ../QTfrontend/ui/dialog/bandialog.h + + +SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \ + ../QTfrontend/model/MapModel.cpp \ + ../QTfrontend/model/ThemeModel.cpp \ + ../QTfrontend/model/netserverslist.cpp \ + ../QTfrontend/ui/qaspectratiolayout.cpp \ + ../QTfrontend/ui/page/pagemain.cpp \ + ../QTfrontend/ui/page/pagetraining.cpp \ + ../QTfrontend/ui/page/pageroomslist.cpp \ + ../QTfrontend/ui/page/pagemultiplayer.cpp \ + ../QTfrontend/ui/page/pagegamestats.cpp \ + ../QTfrontend/ui/page/pagenettype.cpp \ + ../QTfrontend/ui/page/pageeditteam.cpp \ + ../QTfrontend/ui/page/pagenetgame.cpp \ + ../QTfrontend/ui/page/pagedata.cpp \ + ../QTfrontend/ui/page/pagedrawmap.cpp \ + ../QTfrontend/ui/page/pageplayrecord.cpp \ + ../QTfrontend/ui/page/pageselectweapon.cpp \ + ../QTfrontend/ui/page/pageingame.cpp \ + ../QTfrontend/ui/page/pagenetserver.cpp \ + ../QTfrontend/ui/page/pagecampaign.cpp \ + ../QTfrontend/ui/page/pageadmin.cpp \ + ../QTfrontend/ui/page/pageinfo.cpp \ + ../QTfrontend/ui/page/pageconnecting.cpp \ + ../QTfrontend/ui/page/pagesingleplayer.cpp \ + ../QTfrontend/ui/page/pagenet.cpp \ + ../QTfrontend/ui/page/pagescheme.cpp \ + ../QTfrontend/ui/page/pageoptions.cpp \ + ../QTfrontend/ui/dialog/input_ip.cpp \ + ../QTfrontend/ui/widget/igbox.cpp \ + ../QTfrontend/ui/widget/selectWeapon.cpp \ + ../QTfrontend/ui/widget/FreqSpinBox.cpp \ + ../QTfrontend/ui/widget/SquareLabel.cpp \ + ../QTfrontend/ui/widget/frameTeam.cpp \ + ../QTfrontend/ui/widget/fpsedit.cpp \ + ../QTfrontend/ui/widget/databrowser.cpp \ + ../QTfrontend/ui/widget/teamselect.cpp \ + ../QTfrontend/ui/widget/gamecfgwidget.cpp \ + ../QTfrontend/ui/widget/chatwidget.cpp \ + ../QTfrontend/ui/widget/itemNum.cpp \ + ../QTfrontend/ui/widget/bgwidget.cpp \ + ../QTfrontend/ui/widget/about.cpp \ + ../QTfrontend/ui/widget/togglebutton.cpp \ + ../QTfrontend/ui/widget/vertScrollArea.cpp \ + ../QTfrontend/ui/widget/hedgehogerWidget.cpp \ + ../QTfrontend/ui/widget/teamselhelper.cpp \ + ../QTfrontend/ui/widget/drawmapwidget.cpp \ + ../QTfrontend/ui/widget/weaponItem.cpp \ + ../QTfrontend/ui/widget/mapContainer.cpp \ + ../QTfrontend/ui/widget/HistoryLineEdit.cpp \ + ../QTfrontend/ui/widget/SmartLineEdit.cpp \ + ../QTfrontend/util/DataManager.cpp \ + ../QTfrontend/net/tcpBase.cpp \ + ../QTfrontend/net/netregister.cpp \ + ../QTfrontend/net/proto.cpp \ + ../QTfrontend/net/hwmap.cpp \ + ../QTfrontend/net/netudpserver.cpp \ + ../QTfrontend/net/newnetclient.cpp \ + ../QTfrontend/net/netudpwidget.cpp \ + ../QTfrontend/net/netserver.cpp \ + ../QTfrontend/util/namegen.cpp \ + ../QTfrontend/ui/page/AbstractPage.cpp \ + ../QTfrontend/achievements.cpp \ + ../QTfrontend/binds.cpp \ + ../QTfrontend/drawmapscene.cpp \ + ../QTfrontend/game.cpp \ + ../QTfrontend/gameuiconfig.cpp \ + ../QTfrontend/HWApplication.cpp \ + ../QTfrontend/hwform.cpp \ + ../QTfrontend/main.cpp \ + ../QTfrontend/util/SDLInteraction.cpp \ + ../QTfrontend/team.cpp \ + ../QTfrontend/ui_hwform.cpp \ + ../QTfrontend/hwconsts.cpp \ + ../QTfrontend/ui/mouseoverfilter.cpp \ + ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp \ + ../QTfrontend/ui/page/pagefeedback.cpp \ + ../QTfrontend/model/roomslistmodel.cpp \ + ../QTfrontend/ui/dialog/input_password.cpp \ + ../QTfrontend/ui/widget/colorwidget.cpp \ + ../QTfrontend/model/HatModel.cpp \ + ../QTfrontend/model/GameStyleModel.cpp \ + ../QTfrontend/ui/page/pagevideos.cpp \ + ../QTfrontend/net/recorder.cpp \ + ../QTfrontend/ui/dialog/ask_quit.cpp \ + ../QTfrontend/ui/dialog/upload_video.cpp \ + ../QTfrontend/campaign.cpp \ + ../QTfrontend/model/playerslistmodel.cpp \ + ../QTfrontend/util/LibavInteraction.cpp \ + ../QTfrontend/util/FileEngine.cpp \ + ../QTfrontend/ui/dialog/bandialog.cpp + + +TRANSLATIONS += ../share/hedgewars/Data/Locale/hedgewars_ar.ts \ + ../share/hedgewars/Data/Locale/hedgewars_bg.ts \ + ../share/hedgewars/Data/Locale/hedgewars_cs.ts \ + ../share/hedgewars/Data/Locale/hedgewars_da.ts \ + ../share/hedgewars/Data/Locale/hedgewars_de.ts \ + ../share/hedgewars/Data/Locale/hedgewars_el.ts \ + ../share/hedgewars/Data/Locale/hedgewars_en.ts \ + ../share/hedgewars/Data/Locale/hedgewars_es.ts \ + ../share/hedgewars/Data/Locale/hedgewars_fi.ts \ + ../share/hedgewars/Data/Locale/hedgewars_fr.ts \ + ../share/hedgewars/Data/Locale/hedgewars_gl.ts \ + ../share/hedgewars/Data/Locale/hedgewars_hu.ts \ + ../share/hedgewars/Data/Locale/hedgewars_it.ts \ + ../share/hedgewars/Data/Locale/hedgewars_ja.ts \ + ../share/hedgewars/Data/Locale/hedgewars_ko.ts \ + ../share/hedgewars/Data/Locale/hedgewars_lt.ts \ + ../share/hedgewars/Data/Locale/hedgewars_ms.ts \ + ../share/hedgewars/Data/Locale/hedgewars_nl.ts \ + ../share/hedgewars/Data/Locale/hedgewars_pl.ts \ + ../share/hedgewars/Data/Locale/hedgewars_pt_BR.ts \ + ../share/hedgewars/Data/Locale/hedgewars_pt_PT.ts \ + ../share/hedgewars/Data/Locale/hedgewars_ro.ts \ + ../share/hedgewars/Data/Locale/hedgewars_ru.ts \ + ../share/hedgewars/Data/Locale/hedgewars_sk.ts \ + ../share/hedgewars/Data/Locale/hedgewars_sv.ts \ + ../share/hedgewars/Data/Locale/hedgewars_tr_TR.ts \ + ../share/hedgewars/Data/Locale/hedgewars_uk.ts \ + ../share/hedgewars/Data/Locale/hedgewars_zh_CN.ts \ + ../share/hedgewars/Data/Locale/hedgewars_zh_TW.ts + +RESOURCES += ../QTfrontend/hedgewars.qrc + +LIBS += -L../bin -lphysfs + +macx { + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 + QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.6.sdk + + OBJECTIVE_SOURCES += ../QTfrontend/*.m ../QTfrontend/*.mm + SOURCES += ../QTfrontend/AutoUpdater.cpp ../QTfrontend/InstallController.cpp \ + ../../build/QTfrontend/hwconsts.cpp + HEADERS += ../QTfrontend/M3InstallController.h ../QTfrontend/M3Panel.h \ + ../QTfrontend/NSWorkspace_RBAdditions.h ../QTfrontend/AutoUpdater.h \ + ../QTfrontend/CocoaInitializer.h ../QTfrontend/InstallController.h \ + ../QTfrontend/SparkleAutoUpdater.h + + LIBS += -lobjc -framework AppKit -framework IOKit -framework Foundation -framework SDL -framework SDL_Mixer -framework Sparkle -DSPARKLE_ENABLED + INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers /Library/Frameworks/SDL_Mixer.framework/Headers + CONFIG += warn_on x86 + #CONFIG += x86 ppc x86_64 ppc64 +} + +win32 { + RC_FILE = ../QTfrontend/hedgewars.rc + SOURCES += ../QTfrontend/xfire.cpp + INCLUDEPATH += ../misc/winutils/include + LIBS += -L../misc/winutils/lib +} + +!macx { + LIBS += -lSDL -lSDL_mixer -lSDL_net + !win32 { + INCLUDEPATH += /usr/local/include/SDL /usr/include/SDL + } +} + +FORMS += diff -r d24257910f8d -r aaefa587e277 share/CMakeLists.txt --- a/share/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/share/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,13 +1,22 @@ add_subdirectory(hedgewars) -IF(APPLE OR CROSSAPPLE) +if(APPLE) #needed for CFBundleVersion and CFBundleShortVersionString #should reuse the variables set in main CMakeLists.txt - IF(HGCOMMAND AND (EXISTS ${CMAKE_SOURCE_DIR}/.hg)) + if(HGCOMMAND AND (EXISTS ${CMAKE_SOURCE_DIR}/.hg)) set(HEDGEWARS_REVISION ${revision_number}) - ELSE() + else() set(HEDGEWARS_REVISION ${HEDGEWARS_VERSION}) - ENDIF() + endif() + + #silly libav that always brings in VideoDecoderAcceleration, avaible only from 10.6.3 + if(NOT NOVIDEOREC) + set(FFMPEG_FIND_QUIETLY true) + find_package(FFMPEG) + if(${FFMPEG_FOUND} AND ${minimum_macosx_version} VERSION_EQUAL "10.6") + set(minimum_macosx_version "10.6.3") + endif() + endif() configure_file(${hedgewars_SOURCE_DIR}/share/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) @@ -20,4 +29,4 @@ DESTINATION ../Resources/) install(PROGRAMS "${hedgewars_SOURCE_DIR}/share/dsa_pub.pem" DESTINATION ../Resources/) -ENDIF(APPLE OR CROSSAPPLE) +endif(APPLE) diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/Ammos.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/Ammos@2x.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/Ammos@2x.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/Ammos_bw.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/Ammos_bw.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/Ammos_bw@2x.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/Ammos_bw@2x.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/BorderHorizontal.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/BorderHorizontal.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/BorderVertical.png Binary file share/hedgewars/Data/Graphics/AmmoMenu/BorderVertical.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt --- a/share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/Graphics/AmmoMenu/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,6 +1,5 @@ file(GLOB AmmoMenuSprites *.png) -list(REMOVE_ITEM AmmoMenuSprites *@2x.png Border*.png) install(FILES - ${AmmoMenuSprites} - DESTINATION ${SHAREPATH}Data/Graphics/AmmoMenu) + ${AmmoMenuSprites} + DESTINATION ${SHAREPATH}Data/Graphics/AmmoMenu) diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Locale/en.txt --- a/share/hedgewars/Data/Locale/en.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/Locale/en.txt Tue Dec 25 04:45:22 2012 +0100 @@ -64,7 +64,7 @@ 01:02=%1 wins! 01:03=Volume %1% 01:04=Paused -01:05=Really quit (Y/Esc)? +01:05=Really quit? (Y/Esc) (Click to resume) 01:06=Sudden Death! 01:07=%1 remaining 01:08=Fuel @@ -508,7 +508,7 @@ 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=Take a trip 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: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 diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Locale/hedgewars_it.ts --- a/share/hedgewars/Data/Locale/hedgewars_it.ts Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/Locale/hedgewars_it.ts Tue Dec 25 04:45:22 2012 +0100 @@ -163,7 +163,8 @@ Someone already uses your nickname %1 on the server. Please pick another nickname: - + Qualcun altro sta già usando il tuo nickname %1 sul server. +Per favore scegli un altro nickname: @@ -348,19 +349,19 @@ Duration: %1m %2s - Durata: %1m %2s + Durata: %1m %2s Video: %1x%2, - Video: %1x%2, + Video: %1x%2, %1 fps, - %1 fps, + %1 fps, Audio: - Audio: + Audio: @@ -935,35 +936,35 @@ Proxy host - + Server proxy Proxy port - + Porta proxy Proxy login - + Login Proxy Proxy password - + Password proxy No proxy - + Nessun proxy Socks5 proxy - + Proxy Socks5 HTTP proxy - + Proxy HTTP System proxy settings - + Impostazioni proxy di sistema @@ -1872,195 +1873,198 @@ Teams - Are you sure? - + Squadre - Sei sicuro? Do you really want to delete the team '%1'? - + Vuoi davvero cancellare la squadra '%1'? Cannot delete default scheme '%1'! - + Non posso cancellare lo schema di default '%1'! Please select a record from the list - + Per favore scegli una voce dalla lista Unable to start server - + Impossibile avviare il server Hedgewars - Error - + Hedgewars - Errore Hedgewars - Success - + Hedgewars - Completato All file associations have been set - + Tutte le associazioni di file sono state impostate Successfully posted the issue on hedgewars.googlecode.com - + Problema inviato correttamente a hedgewars.googlecode.com Error during authentication at google.com - + Errore durante l'autenticazione a google.com Error reporting the issue, please try again later (or visit hedgewars.googlecode.com directly) - + Errore nell'invio del problema, si prega di provare più tardi (o visitare hedgewars.googlecode.com direttamente) Main - Error - + Main - Errore Cannot create directory %1 - Impossibile creare la directory %1 + Impossibile creare la directory %1 Failed to open data directory: %1 Please check your installation! - + Impossibile creare la directory dati: +%1 + +Per favore controlla l'installazione! TCP - Error - + TCP - Errore Unable to start the server: %1. - Impossibile avviare il server: %1. + Impossibile avviare il server: %1. Unable to run engine at - + Impossibile avviare il motore a Error code: %1 - + Codice di errore: %1 Video upload - Error - + Caricamento video - Errore Netgame - Error - + Gioco in rete - Errore Please select a server from the list - + Per favore scegli un server dalla lista Please enter room name - Inserisci il nome della stanza + Inserisci il nome della stanza Record Play - Error - + Registrazione gioco - Errore Please select record from the list - Seleziona un record dalla lista + Seleziona un record dalla lista Cannot rename to - + Impossibile rinominare a Cannot delete file - + Impossibile cancellare il file Room Name - Error - + Nome stanza - Errore Please select room from the list - Seleziona la stanza dalla lista + Seleziona la stanza dalla lista Room Name - Are you sure? - + Nome stanza - Sei sicuro? The game you are trying to join has started. Do you still want to join the room? - La partita a cui stai cercando di unirti è già iniziata. + La partita a cui stai cercando di unirti è già iniziata. Voui comunque entrare nella stanza? Schemes - Warning - + Schemi - Attenzione Schemes - Are you sure? - + Schemi - Sei sicuro? Do you really want to delete the game scheme '%1'? - + Vuoi davvero cancellare lo schema di gioco '%1'? Videos - Are you sure? - + Video - Sei sicuro? Do you really want to delete the video '%1'? - + Vuoi davvero cancellare il video '%1'? Do you really want to remove %1 file(s)? - - + Vuoi davvero cancellare il file? + Vuoi davvero cancellare %1 file? Do you really want to cancel uploading %1? - + Vuoi davvero terminare di caricare %1? File error - Errore con il file + Errore con il file Cannot open '%1' for writing - + Non posso aprire '%1' in scrittura Cannot open '%1' for reading - + Non posso aprire '%1' in lettura Cannot use the ammo '%1'! - + Non posso usare le munizioni '%1'! Weapons - Warning - + Armi - Attenzione Cannot overwrite default weapon set '%1'! - + Non posso sovrascrivere l'insieme base di armi '%1'! Cannot delete default weapon set '%1'! - + Non posso cancellare l'insieme base di armi '%1'! Weapons - Are you sure? - + Armi - Sei sicuro? Do you really want to delete the weapon set '%1'? - + Vuoi davvero cancellare l'insieme di armi '%1'? @@ -2174,23 +2178,23 @@ Restore default coding parameters - + Ripristina i parametri di base della codifica Open the video directory in your system - + Apri la directory video sul tuo sistema Play this video - + Riproduci questo video Delete this video - + Cancella questo video Upload this video to your Youtube account - + Cariva questo video nel tuo account Youtube diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Locale/hedgewars_sk.ts --- a/share/hedgewars/Data/Locale/hedgewars_sk.ts Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/Locale/hedgewars_sk.ts Tue Dec 25 04:45:22 2012 +0100 @@ -5,7 +5,7 @@ AbstractPage Go back - + Krok späť @@ -57,7 +57,7 @@ HWAskQuitDialog Do you really want to quit? - + Naozaj chcete odísť? @@ -166,7 +166,7 @@ Someone already uses your nickname %1 on the server. Please pick another nickname: - + Prezývku %1 už niekto na serveri používa. Prosím, zvoľte si inú prezývku: @@ -314,29 +314,29 @@ Remote host has closed connection - + Vzdialený hostiteľ ukončiť spojenie The server is too old. Disconnecting now. - + Server je príliš zastaraný. Odpojím sa. HWPasswordDialog Password - Heslo + Heslo HWUploadVideoDialog Upload video - + Upload videa Upload - + Upload @@ -351,19 +351,19 @@ Duration: %1m %2s - + Trvanie: %1m %2s Video: %1x%2, - + Video: %1x%2, %1 fps, - + %1 fps, Audio: - + Zvuk: @@ -440,7 +440,7 @@ Eraser - + Guma @@ -532,7 +532,7 @@ PageInfo Open the snapshot folder - + Otvoriť priečinok so snímkami @@ -788,43 +788,43 @@ Local Game - + Miestna hra Play a game on a single computer - + Hrať hru na tomto počítači Network Game - + Hra na sieti Play a game across a network - + Hra cez sieť Read about who is behind the Hedgewars Project - + Prečítajte si, kto stojí za projektom Hedgewars Leave a feedback here reporting issues, suggesting features or just saying how you like Hedgewars - + Dajte nám späťnú väzbu formou hlásenia chýb, navrhovania nových vlastností alebo nám len napíšte, čo sa vám na Hedgewars páči Access the user created content downloadable from our website - + Stiahnuť obsah vytvorený inými užívateľmi z našej stránky Exit game - + Ukončiť hru Manage videos recorded from game - + Spravovať videá nahrané počas hrania Edit game preferences - + Upraviť nastavenia hry @@ -857,11 +857,11 @@ Join hundreds of players online! - + Pripojte sa ku stovkám hráčov online! Join or host your own game server in a Local Area Network. - + Pripojiť sa k existujúcej hre alebo vytvoriť vlastnú hru na miestnej sieti. @@ -908,47 +908,47 @@ General - Všeobecné + Všeobecné Advanced - Pokročilé + Pokročilé Reset to default colors - + Nastaviť východzie farby Proxy host - + Hostiteľ proxy Proxy port - + Port proxy Proxy login - + Login pre proxy Proxy password - + Heslo pre proxy No proxy - + Bez proxy Socks5 proxy - + Socks5 proxy HTTP proxy - + HTTP proxy System proxy settings - + Systémové nastavenia proxy @@ -1151,47 +1151,47 @@ PageSinglePlayer Simple Game - + Jednoduchá hra Play a quick game against the computer with random settings - + Zahrajte si rýchlu hru proti počítaču s náhodnými nastaveniami Multiplayer - + Hra viacerých hráčov Play a hotseat game against your friends, or AI teams - + Zahrajte si hru za týmto počítačom proti kamarátom alebo počítačovým protivníkom Campaign Mode - + Režim kampane Training Mode - + Tréningový režim Practice your skills in a range of training missions - + Cibrite si svoje schopnosti v rade tréningových misií Demos - + Demá Watch recorded demos - + Prezerať nahrané demá Load - Načítať + Načítať Load a previously saved game - + Načítať uloženú hru @@ -1206,50 +1206,50 @@ Pick the mission or training to play - + Vyberte si misiu alebo tréning Start fighting - + Začať boj PageVideos Name - Meno + Meno Size - + Veľkosť %1 bytes - - + + %1 bajtov (in progress...) - + (prebieha...) Date: - + Dátum: Size: - + Veľkosť: encoding - + kódovanie uploading - + uploadujem @@ -1355,23 +1355,23 @@ Save password - + Uložiť heslo Save account name and password - + Uložiť meno účtu a heslo Video is private - + Video je súkromné Record audio - + Nahrať audio Use game resolution - + Použiť rozlíšenie hry @@ -1537,27 +1537,27 @@ Custom colors - + Vlastné farby Miscellaneous - + Rozličné Video recording options - + Voľby nahrávania videa Videos - + Videá Description - + Popis Proxy settings - + Nastavenia proxy @@ -1743,63 +1743,63 @@ There are videos that are currently being processed. Exiting now will abort them. Do you really want to quit? - + Momentálne sa niektoré videá spracovávajú. Ukončením zrušíte spracovávanie. Naozaj chcete ukončiť program? Please provide either the YouTube account name or the email address associated with the Google Account. - + Prosím zadajte buď názov YouTube účtu alebo e-mailovú adresu prepojenú s Google účtom. Account name (or email): - + Názov účtu (alebo e-mail): Password: - + Heslo: Video title: - + Názov videa: Video description: - + Popis videa: Tags (comma separated): - + Značky (oddelené čiarkou): Summary - + Sumár Description - + Popis Nickname - Prezývka + Prezývka Format - + Formát Audio codec - + Audio kodek Video codec - + Video kodek Framerate - + Snímkovanie Bitrate (Kbps) - + Bitový tok (Kbps) @@ -1814,7 +1814,7 @@ anonymous - + anonymný @@ -1840,214 +1840,217 @@ Please fill out all fields - + Prosím, vyplňte všetky polia Error while authenticating at google.com: - + Chyba pri autentizácii voči google.com: Login or password is incorrect - + Prihlasovacie meno alebo heslo je nesprávne Error while sending metadata to youtube.com: - + Chyba pri posielaní metadát na youtube.com: Teams - Are you sure? - + Tímy - Ste si istý? Do you really want to delete the team '%1'? - + Naozaj chcete vymazať tím '%1'? Cannot delete default scheme '%1'! - + Nemôžem vymazať východziu schému '%1'! Please select a record from the list - + Prosím, vyberte nahrávku zo zoznamu Unable to start server - + Nepodarilo sa spustiť server Hedgewars - Error - + Hedgewars - Chyba Hedgewars - Success - + Hedgewars - Úspech All file associations have been set - + Všeky súborové asociácie boli nastavené Successfully posted the issue on hedgewars.googlecode.com - + Popis problému bol úspešne odoslaný na hedgewars.google.com Error during authentication at google.com - + Chyba počas autentizácie voči google.com Error reporting the issue, please try again later (or visit hedgewars.googlecode.com directly) - + Chyba pri hlásení problému, skúste to prosím neskôr (alebo navštívte priamo hedgewars.googlecode.com) Main - Error - + Hlavné okno - Chyba Cannot create directory %1 - Nepodarilo sa vytvoriť adresár %1 + Nepodarilo sa vytvoriť adresár %1 Failed to open data directory: %1 Please check your installation! - + Chyba pri otváraní adresára s dátami: +%1 + +Skontrolujte, prosím, inštaláciu! TCP - Error - + TCP - Chyba Unable to start the server: %1. - Nie je možné spustiť server: %1. + Nepodarilo sa spustiť server: %1. Unable to run engine at - + Nepodarilo sa spustiť enginu na Error code: %1 - + Kód chyby: %1 Video upload - Error - + Upload videa - Chyba Netgame - Error - + Sieťová hra - Chyba Please select a server from the list - + Prosím, vyberte server zo zoznamu Please enter room name - Prosím zadajte názov miestnosti + Prosím, zadajte názov miestnosti Record Play - Error - + Prehrávanie záznamu - Chyba Please select record from the list - Prosím vyberte záznam zo zoznamu + Prosím, vyberte záznam zo zoznamu Cannot rename to - + Nepodarilo sa premenovať na Cannot delete file - + Nepodarilo sa vymazať súbor Room Name - Error - + Názov miestnosti - Chyba Please select room from the list - Prosím vyberte miestnosť zo zoznamu + Prosím, vyberte miestnosť zo zoznamu Room Name - Are you sure? - + Názov miestnosti - Ste si istý? The game you are trying to join has started. Do you still want to join the room? - Hra, ku ktorej sa snažíte pripojiť, už začala. + Hra, ku ktorej sa snažíte pripojiť, už začala. Aj napriek tomu chcete vojsť do miestnosti? Schemes - Warning - + Schémy - Varovanie Schemes - Are you sure? - + Schémy - Ste si istý? Do you really want to delete the game scheme '%1'? - + Naozaj chcete vymazať hernú schému '%1'? Videos - Are you sure? - + Videa - Ste si istý? Do you really want to delete the video '%1'? - + Naozaj chcete vymazať video '%1'? Do you really want to remove %1 file(s)? - - + + Naozaj chcete vymazať %1 súbor(y)? Do you really want to cancel uploading %1? - + Naozaj chcete zrušiť uploadovanie %1? File error - Chyba v súbore + Chyba v súbore Cannot open '%1' for writing - + Nepodarilo sa otvoriť '%1' pre zápis Cannot open '%1' for reading - + Nepodarilo sa otvoriť '%1' pre čítanie Cannot use the ammo '%1'! - + Nemôžem použiť muníciu '%1'! Weapons - Warning - + Zbrane - Varovanie Cannot overwrite default weapon set '%1'! - + Nemôžete prepísať východziu sadu zbraní '%1'! Cannot delete default weapon set '%1'! - + Nemôžete vymazať východziu sadu zbraní '%1'! Weapons - Are you sure? - + Zbrane - Ste si istý? Do you really want to delete the weapon set '%1'? - + Naozaj chcete vymazať sadu zbraní '%1'? @@ -2137,94 +2140,94 @@ More info - + Viac informácii Set default options - + Nastaviť východzie Open videos directory - + Otvoriť adresár s videami Play - + Prehrať Upload to YouTube - + Uploadovať na YouTube Cancel uploading - + Zrušiť upload Restore default coding parameters - + Obnoviť pôvodné parametre pre kódovanie Open the video directory in your system - + Otvoriť adresár s videami vo vašom systéme Play this video - + Prehrať toto videa Delete this video - + Vymazať toto video Upload this video to your Youtube account - + Uploadovať video na váš účet YouTube RoomsListModel In progress - Prebieha + Prebieha Room Name - Názov miestnosti + Názov miestnosti C - C + C T - T + T Owner - Majiteľ + Majiteľ Map - Mapa + Mapa Rules - Pravidlá + Pravidlá Weapons - Výzbroj + Výzbroj Random Map - Náhodná mapa + Náhodná mapa Random Maze - Náhodné bludisko + Náhodné bludisko Hand-drawn - + Ručne kreslená @@ -2523,11 +2526,11 @@ mute audio - + stlmiť zvuk record - + nahrať @@ -2617,7 +2620,7 @@ Record video: - + Nahrať video: diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Locale/sk.txt --- a/share/hedgewars/Data/Locale/sk.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/Locale/sk.txt Tue Dec 25 04:45:22 2012 +0100 @@ -56,6 +56,8 @@ 00:53=TARDIS 00:54=Budova 00:55=Postrek zeme +00:56=Zmrazovač +00:57=Sekáčik 01:00=Do boja! 01:01=Remíza @@ -78,6 +80,7 @@ 01:18=Vysoký 01:19=Extrémny 01:20=%1 odskok +01:21=Vypnutý zvuk ; Správy o udalostiach ; Ježko (%1) zomrel diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Maps/ShoppaKing/map.png Binary file share/hedgewars/Data/Maps/ShoppaKing/map.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Maps/ShoppaKing/map.xcf Binary file share/hedgewars/Data/Maps/ShoppaKing/map.xcf has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/Maps/TrophyRace/map.png Binary file share/hedgewars/Data/Maps/TrophyRace/map.png has changed diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/misc/CMakeLists.txt --- a/share/hedgewars/Data/misc/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/misc/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -1,14 +1,9 @@ -if(DEFINED DATA_INSTALL_DIR) - set(HEDGEWARS_DATADIR ${DATA_INSTALL_DIR} -) -else() - set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/) -endif() if(UNIX AND NOT APPLE) -configure_file(hwengine.desktop.in hwengine.desktop) + configure_file(hwengine.desktop.in hwengine.desktop) + + file(GLOB miscfiles *.xml *.desktop) + + install(FILES ${miscfiles} DESTINATION ${SHAREPATH}/Data/misc) endif() -file(GLOB miscfiles *.xml *.desktop) - -install(FILES ${miscfiles} DESTINATION ${SHAREPATH}Data/misc) diff -r d24257910f8d -r aaefa587e277 share/hedgewars/Data/misc/hwengine.desktop.in --- a/share/hedgewars/Data/misc/hwengine.desktop.in Sun Dec 02 00:03:16 2012 +0100 +++ b/share/hedgewars/Data/misc/hwengine.desktop.in Tue Dec 25 04:45:22 2012 +0100 @@ -17,7 +17,7 @@ GenericName[sv]=Hedgewarsmotorn, för att öppna demo- och sparfiler GenericName[da]=Kæmpende Pindsvin Icon=hedgewars.png -Exec=${CMAKE_INSTALL_PREFIX}/bin/hwengine ${HEDGEWARS_DATADIR}/hedgewars/Data %f +Exec=${CMAKE_INSTALL_PREFIX}/${target_binary_install_dir}/hwengine %f Path=/tmp Terminal=false StartupNotify=false diff -r d24257910f8d -r aaefa587e277 tools/CMakeLists.txt --- a/tools/CMakeLists.txt Sun Dec 02 00:03:16 2012 +0100 +++ b/tools/CMakeLists.txt Tue Dec 25 04:45:22 2012 +0100 @@ -29,13 +29,20 @@ string(REGEX REPLACE "(.*)/include.*" "\\1" qt_base_dir "${QT_INCLUDE_DIR}") #remove the ";-framework Cocoa" from the SDL_LIBRARY variable - string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}") + string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}") if(NOT NOPNG) #get the neme of the library (harmelss if it is static) string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}") endif() + set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}) + if(${BUILD_ENGINE_LIBRARY}) + set(engine_full_path "${frameworks_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") + else() + set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}") + endif() + #this tool is present in qt 4.5 but only if you compile from sources #from qt 4.6 is present also in the binary version find_program(macdeployqt_executable NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin) diff -r d24257910f8d -r aaefa587e277 tools/CreateMacBundle.cmake.in --- a/tools/CreateMacBundle.cmake.in Sun Dec 02 00:03:16 2012 +0100 +++ b/tools/CreateMacBundle.cmake.in Tue Dec 25 04:45:22 2012 +0100 @@ -1,34 +1,34 @@ message(STATUS "Performing standalone bundle creation...") -execute_process(COMMAND ls ${frameworks_dir} RESULT_VARIABLE doBundle OUTPUT_QUIET ERROR_QUIET) +execute_process(COMMAND stat ${frameworks_dir} RESULT_VARIABLE doBundle OUTPUT_QUIET ERROR_QUIET) execute_process(COMMAND mkdir -p ${frameworks_dir}) # macdeployqt will convert safely any absolute path library for 'hedgewars' -execute_process(COMMAND ${macdeployqt_executable} ${CMAKE_BINARY_DIR}/${bundle_name} OUTPUT_QUIET ERROR_QUIET) +execute_process(COMMAND ${macdeployqt_executable} ${CMAKE_BINARY_DIR}/Hedgewars.app OUTPUT_QUIET ERROR_QUIET) if(NOT ${NOVIDEOREC}) # but macdeployqt will not work for 'hwengine'; luckily the dylibs were already updated before - execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVCODEC} @executable_path/../Frameworks/libavcodec.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine) - execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVFORMAT} @executable_path/../Frameworks/libavformat.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine) - execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVUTIL} @executable_path/../Frameworks/libavutil.dylib ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine) + execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVCODEC} @executable_path/../Frameworks/libavcodec.dylib ${engine_full_path}) + execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVFORMAT} @executable_path/../Frameworks/libavformat.dylib ${engine_full_path}) + execute_process(COMMAND install_name_tool -change ${FFMPEG_LIBAVUTIL} @executable_path/../Frameworks/libavutil.dylib ${engine_full_path}) endif() if(NOT ${NOPNG}) #same here, for libpng and hwengine, let's assume the version pulled by macdeployqt is the same #(yes libpng is pulled by macdeployqt even when NOVIDEOREC is active) - execute_process(COMMAND install_name_tool -change ${PNG_LIBRARY} @executable_path/../Frameworks/${PNG_LIBNAME} ${CMAKE_BINARY_DIR}/${bundle_name}/Contents/MacOS/hwengine) + execute_process(COMMAND install_name_tool -change ${PNG_LIBRARY} @executable_path/../Frameworks/${PNG_LIBNAME} ${engine_full_path}) endif() if(doBundle EQUAL 1) - execute_process(COMMAND cp -pPR ${sdl_dir} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL.framework) - execute_process(COMMAND cp -pPR ${SDLIMAGE_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_image.framework) - execute_process(COMMAND cp -pPR ${SDLNET_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_net.framework) - execute_process(COMMAND cp -pPR ${SDLTTF_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_ttf.framework) - execute_process(COMMAND cp -pPR ${SDLMIXER_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/SDL_mixer.framework) - execute_process(COMMAND cp -pPR ${OGG_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/Ogg.framework) - execute_process(COMMAND cp -pPR ${VORBIS_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/Vorbis.framework) + execute_process(COMMAND cp -pPR ${sdl_library_only} ${frameworks_dir}/SDL.framework) + execute_process(COMMAND cp -pPR ${SDLIMAGE_LIBRARY} ${frameworks_dir}/SDL_image.framework) + execute_process(COMMAND cp -pPR ${SDLNET_LIBRARY} ${frameworks_dir}/SDL_net.framework) + execute_process(COMMAND cp -pPR ${SDLTTF_LIBRARY} ${frameworks_dir}/SDL_ttf.framework) + execute_process(COMMAND cp -pPR ${SDLMIXER_LIBRARY} ${frameworks_dir}/SDL_mixer.framework) + execute_process(COMMAND cp -pPR ${OGG_LIBRARY} ${frameworks_dir}/Ogg.framework) + execute_process(COMMAND cp -pPR ${VORBIS_LIBRARY} ${frameworks_dir}/Vorbis.framework) if(${SPARKLE_FOUND}) - execute_process(COMMAND cp -pPR ${SPARKLE_LIBRARY} ${CMAKE_BINARY_DIR}/${frameworks_dir}/Sparkle.framework) + execute_process(COMMAND cp -pPR ${SPARKLE_LIBRARY} ${frameworks_dir}/Sparkle.framework) endif() message(STATUS "Bundle frameworks added") else() diff -r d24257910f8d -r aaefa587e277 tools/pas2c/PascalPreprocessor.hs --- a/tools/pas2c/PascalPreprocessor.hs Sun Dec 02 00:03:16 2012 +0100 +++ b/tools/pas2c/PascalPreprocessor.hs Tue Dec 25 04:45:22 2012 +0100 @@ -22,7 +22,6 @@ -- , ("WEBGL", "") -- , ("AI_MAINTHREAD", "") , ("ENDIAN_LITTLE", "") - , ("S3D_DISABLED", "") ] preprocess :: String -> String -> String -> IO String