# HG changeset patch # User koda # Date 1370911372 -7200 # Node ID d87e2c7838fa1129ad9ad8fff62bd07ba5f22e0e # Parent 115e7daa47966fe162256d12976b73b0eb2568f9# Parent 955a90b8886577fcc8f20b7c6e3a64d6518a8c5f merge (could have grafted) diff -r 955a90b88865 -r d87e2c7838fa CMakeLists.txt --- a/CMakeLists.txt Fri Jun 07 16:35:48 2013 +0200 +++ b/CMakeLists.txt Tue Jun 11 02:42:52 2013 +0200 @@ -2,14 +2,7 @@ #initialise cmake environment cmake_minimum_required(VERSION 2.6.0) -if(CMAKE_VERSION VERSION_LESS "2.8") - set(WARNING "WARNING: ") - set(allow_parse_args FALSE) -else() - set(WARNING WARNING) - set(allow_parse_args TRUE) -endif() -foreach(hwpolicy CMP0003 CMP0012 CMP0017) +foreach(hwpolicy CMP0003 CMP0012 CMP0017 CMP0018) if(POLICY ${hwpolicy}) cmake_policy(SET ${hwpolicy} NEW) endif() @@ -42,50 +35,13 @@ endif() -#detect Mercurial revision and init rev/hash information -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 "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" HEDGEWARS_REVISION ${internal_version}) - string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" HEDGEWARS_HASH ${internal_version}) - - if(HGCHANGED) - message(${WARNING} "You have uncommitted changes in your repository!") - endif() - #let's assume that if you have hg you might be interested in debugging - set(default_build_type "DEBUG") - #write down hash and rev for easy picking should hg be missing - file(WRITE "${CMAKE_SOURCE_DIR}/share/version_info.txt" "Hedgewars versioning information, do not modify\nrev ${HEDGEWARS_REVISION}\nhash ${HEDGEWARS_HASH}\n") -else() - set(default_build_type "RELEASE") - # when compiling outside rev control, fetch revision and hash information from version_info.txt - find_file(version_info version_info.txt PATH ${CMAKE_SOURCE_DIR}/share) - if(version_info) - file(STRINGS ${version_info} internal_version REGEX "rev") - string(REGEX REPLACE "rev ([0-9]*)" "\\1" HEDGEWARS_REVISION ${internal_version}) - file(STRINGS ${version_info} internal_version REGEX "hash") - string(REGEX REPLACE "hash ([a-zA-Z0-9]*)" "\\1" HEDGEWARS_HASH ${internal_version}) - else() - message(${WARNING} "${CMAKE_SOURCE_DIR}/share/version_info.txt not found, revision information " - "will be incorrect!!! Contact your source provider to fix this!") - set(HEDGEWARS_REVISION "0000") - set(HEDGEWARS_HASH "unknown") - endif() -endif() - - #versioning set(CPACK_PACKAGE_VERSION_MAJOR 0) set(CPACK_PACKAGE_VERSION_MINOR 9) -set(CPACK_PACKAGE_VERSION_PATCH 19) -set(HEDGEWARS_PROTO_VER 45) +set(CPACK_PACKAGE_VERSION_PATCH 20) +set(HEDGEWARS_PROTO_VER 46) set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +include(${CMAKE_MODULE_PATH}/revinfo.cmake) message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})") @@ -122,79 +78,8 @@ endif() endif() - -if(APPLE) - set(CMAKE_FIND_FRAMEWORK "FIRST") - - #what system are we building for - set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) - - #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version - find_program(sw_vers sw_vers) - if(sw_vers) - execute_process(COMMAND ${sw_vers} "-productVersion" - OUTPUT_VARIABLE current_macosx_version - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) - else() - if(NOT minimum_macosx_version) - message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set") - else() - message(${WARNING} "sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable") - set(current_macosx_version ${minimum_macosx_version}) - endif() - endif() - - #if nothing is set, we deploy only for the current system - if(NOT minimum_macosx_version) - set(minimum_macosx_version ${current_macosx_version}) - endif() - - #lower systems don't have enough processing power anyway - 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 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") - set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") - list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}") - endif() - - #CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking - if(NOT CMAKE_OSX_ARCHITECTURES) - if(current_macosx_version VERSION_LESS "10.6") - if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") - set(CMAKE_OSX_ARCHITECTURES "ppc7400") - else() - set(CMAKE_OSX_ARCHITECTURES "i386") - endif() - else() - set(CMAKE_OSX_ARCHITECTURES "x86_64") - endif() - endif() - - #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} 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 "/Developer/usr/bin/gcc-4.0") - set(CMAKE_CXX_COMPILER "/Developer/usr/bin/g++-4.0") - else() - string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) - set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") - endif() - endif() - - #add user framework directory, other paths can be passed via FPFLAGS - list(APPEND pascal_flags "-Ff~/Library/Frameworks") - #set deployment target - list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}") -endif(APPLE) +#platform specific init code +include(${CMAKE_MODULE_PATH}/platform.cmake) #when build type is not specified, assume Debug/Release according to build version information @@ -209,12 +94,11 @@ endif (CMAKE_BUILD_TYPE) +#perform safe check that enable/disable compilation features +include(${CMAKE_MODULE_PATH}/compilerchecks.cmake) + #set default flags values for all projects (unless MINIMAL_FLAGS is true) if(NOT ${MINIMAL_FLAGS}) - if(WINDOWS) - #this flags prevents a few dll hell problems - set(CMAKE_C_FLAGS "-static-libgcc ${CMAKE_C_FLAGS}") - endif(WINDOWS) set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}") set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}") @@ -229,36 +113,13 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG") endif() - -#TESTING TIME -include(CheckCCompilerFlag) - -#check for noexecstack on ELF, should be set on Gentoo and similar -set(CMAKE_REQUIRED_FLAGS "-Wl,-z -Wl,noexecstack") -check_c_compiler_flag("" HAVE_NOEXECSTACK) #empty because we are testing a linker flag -if(HAVE_NOEXECSTACK) - list(APPEND pascal_flags "-k-z" "-knoexecstack") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") -endif() -unset(CMAKE_REQUIRED_FLAGS) - -#check for ASLR and DEP security features on Windows -#both supported in binutils >= 2.20, available since Vista and XP SP2 respectively -set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase") -check_c_compiler_flag("" HAVE_WINASLRDEP) #empty because we are testing a linker flag -if(HAVE_WINASLRDEP) - list(APPEND pascal_flags "-k--nxcompat" "-k--dynamicbase") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}") -endif() -unset(CMAKE_REQUIRED_FLAGS) - #parse additional parameters if(FPFLAGS OR GHFLAGS) - if(${allow_parse_args}) + if(CMAKE_VERSION VERSION_GREATER "2.6") separate_arguments(fpflags_parsed UNIX_COMMAND ${FPFLAGS}) separate_arguments(ghflags_parsed UNIX_COMMAND ${GHFLAGS}) else() - message(${WARNING} "FPFLAGS and GHFLAGS are available only when using CMake >= 2.8") + message("*** FPFLAGS and GHFLAGS are available only when using CMake >= 2.8 ***") endif() endif() diff -r 955a90b88865 -r d87e2c7838fa ChangeLog.txt --- a/ChangeLog.txt Fri Jun 07 16:35:48 2013 +0200 +++ b/ChangeLog.txt Tue Jun 11 02:42:52 2013 +0200 @@ -1,6 +1,9 @@ + features * bugfixes +0.9.19 -> ???: + * increase precision in damage calcs; extra damage affects fire properly now + 0.9.18 -> 0.9.19: + New Freezer weapon - freezes terrain, water, hedgehogs, mines, cases, explosives + Saucer can aim weapons and fire underwater @@ -59,6 +62,7 @@ + Reduce amount of memory needed for engine to store land data + Countless other small fixes and improvements + Detect desyncs early + + Mudball will not cause any direct damage anymore * Fix cake getting stuck in barrels, crates and hedgehogs * Fix all knowns bugs which caused network game hang when players close engine or quit * Fix drill strike bug when drill's timer gets ridiculously high value instead of explosion diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/HWApplication.cpp --- a/QTfrontend/HWApplication.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/HWApplication.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -23,11 +23,11 @@ #include "hwform.h" #include "MessageDialog.h" -#if !defined(Q_WS_WIN) +#if !defined(Q_OS_WIN) #include "signal.h" #endif -#if !defined(Q_WS_WIN) +#if !defined(Q_OS_WIN) void terminateFrontend(int signal) { Q_UNUSED(signal); @@ -38,7 +38,7 @@ HWApplication::HWApplication(int &argc, char **argv) : QApplication(argc, argv) { -#if !defined(Q_WS_WIN) +#if !defined(Q_OS_WIN) signal(SIGINT, &terminateFrontend); #endif #if 0 diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/hedgewars.qrc --- a/QTfrontend/hedgewars.qrc Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/hedgewars.qrc Tue Jun 11 02:42:52 2013 +0200 @@ -133,6 +133,7 @@ res/StatsMostSelfDamage.png res/StatsSelfKilled.png res/StatsSkipped.png + res/StatsCustomAchievement.png res/Start.png res/mapRandom.png res/mapMaze.png diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/hwform.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -102,7 +102,7 @@ #include "DataManager.h" #include "AutoUpdater.h" -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #define WINVER 0x0500 #include #else @@ -110,7 +110,7 @@ #include #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include #endif @@ -1923,7 +1923,7 @@ QString prefix = "\"" + datadir->absolutePath() + "\""; QString userPrefix = "\"" + cfgdir->absolutePath() + "\""; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN prefix = prefix.replace("/","\\"); userPrefix = userPrefix.replace("/","\\"); #endif diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/main.cpp --- a/QTfrontend/main.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/main.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -135,7 +135,7 @@ HWApplication app(argc, argv); QLabel *splash = NULL; -#if defined Q_WS_WIN +#if defined Q_OS_WIN QPixmap pixmap(":res/splash.png"); splash = new QLabel(0, Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint); splash->setAttribute(Qt::WA_TranslucentBackground); diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/res/Hedgehog.png Binary file QTfrontend/res/Hedgehog.png has changed diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/res/StatsCustomAchievement.png Binary file QTfrontend/res/StatsCustomAchievement.png has changed diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/page/pagegamestats.cpp --- a/QTfrontend/ui/page/pagegamestats.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/page/pagegamestats.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -40,10 +40,15 @@ QLayout * PageGameStats::bodyLayoutDefinition() { + kindOfPoints = QString(""); + defaultGraphTitle = true; QGridLayout * pageLayout = new QGridLayout(); pageLayout->setSpacing(20); pageLayout->setColumnStretch(0, 1); pageLayout->setColumnStretch(1, 1); + pageLayout->setRowStretch(0, 1); + pageLayout->setRowStretch(1, 20); + //pageLayout->setRowStretch(1, -1); this should work but there is unnecessary empty space betwin lines if used pageLayout->setContentsMargins(7, 7, 7, 0); QGroupBox * gb = new QGroupBox(this); @@ -61,15 +66,15 @@ gbl->addWidget(l); gbl->addWidget(labelGameStats); gb->setLayout(gbl); - pageLayout->addWidget(gb, 1, 1, 1, 2); + pageLayout->addWidget(gb, 1, 1); // graph graphic = new FitGraphicsView(gb); - l = new QLabel(this); - l->setTextFormat(Qt::RichText); - l->setText("

" + PageGameStats::tr("Health graph") + "

"); - l->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - gbl->addWidget(l); + labelGraphTitle = new QLabel(this); + labelGraphTitle->setTextFormat(Qt::RichText); + labelGraphTitle->setText("

" + PageGameStats::tr("Health graph") + "

"); + labelGraphTitle->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + gbl->addWidget(labelGraphTitle); gbl->addWidget(graphic); graphic->scale(1.0, -1.0); graphic->setBackgroundBrush(QBrush(Qt::black)); @@ -154,28 +159,41 @@ void PageGameStats::renderStats() { - QGraphicsScene * scene = new QGraphicsScene(); - - QMap >::const_iterator i = healthPoints.constBegin(); - while (i != healthPoints.constEnd()) - { - quint32 c = i.key(); - //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); - QVector hps = i.value(); + graphic->show(); + labelGraphTitle-> show(); + if(defaultGraphTitle) { + labelGraphTitle->setText("

" + PageGameStats::tr("Health graph") + "

"); + } else { + defaultGraphTitle = true; + } + // if not health data sent + if(healthPoints.size() == 0) { + labelGraphTitle->hide(); + graphic->hide(); + } else { + QGraphicsScene * scene = new QGraphicsScene(); - QPainterPath path; - if (hps.size()) - path.moveTo(0, hps[0]); + QMap >::const_iterator i = healthPoints.constBegin(); + while (i != healthPoints.constEnd()) + { + quint32 c = i.key(); + //QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); + QVector hps = i.value(); - for(int t = 1; t < hps.size(); ++t) - path.lineTo(t, hps[t]); + QPainterPath path; + if (hps.size()) + path.moveTo(0, hps[0]); - scene->addPath(path, QPen(c)); - ++i; - } + for(int t = 1; t < hps.size(); ++t) + path.lineTo(t, hps[t]); - graphic->setScene(scene); - graphic->fitInView(graphic->sceneRect()); + scene->addPath(path, QPen(c)); + ++i; + } + + graphic->setScene(scene); + graphic->fitInView(graphic->sceneRect()); + } } void PageGameStats::GameStats(char type, const QString & info) @@ -217,6 +235,13 @@ healthPoints[clan].append(hp); break; } + case 'g' : + { + // TODO: change default picture or add change pic capability + defaultGraphTitle = false; + labelGraphTitle->setText("

" + info + "

"); + break; + } case 'T': // local team stats { //AddStatText("

local team: " + info + "

"); @@ -232,7 +257,11 @@ } break; } - + case 'p' : + { + kindOfPoints = info; + break; + } case 'P' : { int i = info.indexOf(' '); @@ -269,7 +298,13 @@ } QString message; - QString killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); + QString killstring; + if(kindOfPoints.compare("") == 0) { + killstring = PageGameStats::tr("(%1 kill)", "", kills).arg(kills); + } else { + killstring = PageGameStats::tr("(%1 %2)", "", kills).arg(kills).arg(kindOfPoints); + kindOfPoints = QString(""); + } message = QString("

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

"; @@ -300,6 +335,12 @@ AddStatText(message); break; } + case 'c' : + { + QString message = "

"+info+"

"; + AddStatText(message); + break; + } } } diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/page/pagegamestats.h --- a/QTfrontend/ui/page/pagegamestats.h Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/page/pagegamestats.h Tue Jun 11 02:42:52 2013 +0200 @@ -49,6 +49,8 @@ QLabel *labelGameStats; QLabel *labelGameWin; QLabel *labelGameRank; + QLabel *labelGraphTitle; + QString kindOfPoints; FitGraphicsView * graphic; public slots: @@ -67,6 +69,7 @@ QMap > healthPoints; unsigned int playerPosition; quint32 lastColor; + bool defaultGraphTitle; protected: QLayout * bodyLayoutDefinition(); diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/page/pagenet.cpp --- a/QTfrontend/ui/page/pagenet.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/page/pagenet.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -73,7 +73,7 @@ BtnNetSvrStart = formattedButton(QPushButton::tr("Start server")); BtnNetSvrStart->setMinimumWidth(180); QString serverPath = bindir->absolutePath() + "/hedgewars-server"; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN serverPath += + ".exe"; #endif QFile server(serverPath); diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/page/pagevideos.cpp --- a/QTfrontend/ui/page/pagevideos.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/page/pagevideos.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -414,7 +414,7 @@ setName(item, newName); } } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN // there is a bug in qt, QDir::rename() doesn't fail on such names but damages files if (newName.contains(QRegExp("[\"*:<>?\\/|]"))) { @@ -508,8 +508,8 @@ else { QString path = item->path(); - desc += tr("Date: %1\n").arg(QFileInfo(path).created().toString(Qt::DefaultLocaleLongDate)); - desc += tr("Size: %1\n").arg(FileSizeStr(path)); + desc += tr("Date: %1").arg(QFileInfo(path).created().toString(Qt::DefaultLocaleLongDate)) + "\n"; + desc += tr("Size: %1").arg(FileSizeStr(path)) + "\n"; if (item->desc.isEmpty()) { // Extract description from file; diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/qaspectratiolayout.cpp --- a/QTfrontend/ui/qaspectratiolayout.cpp Fri Jun 07 16:35:48 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation. - */ - -#include "qaspectratiolayout.h" - -QAspectRatioLayout::QAspectRatioLayout(QWidget* parent, int spacing) : QLayout(parent) -{ - init(spacing); -} - -QAspectRatioLayout::QAspectRatioLayout(int spacing) -{ - init(spacing); -} - -QAspectRatioLayout::~QAspectRatioLayout() -{ - delete item; - delete lastReceivedRect; - delete _geometry; -} - -void QAspectRatioLayout::init(int spacing) -{ - item = 0; - lastReceivedRect = new QRect(0, 0, 0, 0); - _geometry = new QRect(0, 0, 0, 0); - setSpacing(spacing); -} - - -/* Adds item if place isn't already taken. */ -void QAspectRatioLayout::add(QLayoutItem* item) -{ - if(!hasItem()) - { - replaceItem(item); - } -} - -/* Adds item if place isn't already taken. */ -void QAspectRatioLayout::addItem(QLayoutItem* item) -{ - if(!hasItem()) - { - replaceItem(item); - } -} - -/* Adds widget if place isn't already taken. */ -void QAspectRatioLayout::addWidget(QWidget* widget) -{ - if(!hasItem()) - { - replaceItem(new QWidgetItem(widget)); - } -} - -/* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::take() -{ - QLayoutItem* item = 0; - if(this->hasItem()) - { - item = this->item; - this->item = 0; - } - return item; -} - -/* Returns the item pointer and dereferences it here. */ -QLayoutItem* QAspectRatioLayout::takeAt(int index) -{ - if(index != 0) - { - return 0; - } - return this->take(); -} - -/* Returns the item pointer. */ -QLayoutItem* QAspectRatioLayout::itemAt(int index) const -{ - if(index != 0) - { - return 0; - } - if(hasItem()) - { - return this->item; - } - return 0; -} - -/* Checks if we have an item. */ -bool QAspectRatioLayout::hasItem() const -{ - return this->item != 0; -} - -/* Returns the count of items which can be either 0 or 1. */ -int QAspectRatioLayout::count() const -{ - int returnValue = 0; - if(hasItem()) - { - returnValue = 1; - } - return returnValue; -} - -/* Replaces the item with the new and returns the old. */ -QLayoutItem* QAspectRatioLayout::replaceItem(QLayoutItem* item) -{ - QLayoutItem* old = 0; - if(this->hasItem()) - { - old = this->item; - } - this->item = item; - setGeometry(*this->_geometry); - return old; -} - -/* Tells which way layout expands. */ -Qt::Orientations QAspectRatioLayout::expandingDirections() const -{ - return Qt::Horizontal | Qt::Vertical; -} - -/* Tells which size is preferred. */ -QSize QAspectRatioLayout::sizeHint() const -{ - return this->item->minimumSize(); -} - -/* Tells minimum size. */ -QSize QAspectRatioLayout::minimumSize() const -{ - return this->item->minimumSize(); -} - -/* - * Tells if heightForWidth calculations is handled. - * It isn't since width isn't enough to calculate - * proper size. - */ -bool QAspectRatioLayout::hasHeightForWidth() const -{ - return false; -} - -/* Replaces lastReceivedRect. */ -void QAspectRatioLayout::setLastReceivedRect(const QRect& rect) -{ - QRect* oldRect = this->lastReceivedRect; - this->lastReceivedRect = new QRect(rect.topLeft(), rect.size()); - delete oldRect; -} - -/* Returns geometry */ -QRect QAspectRatioLayout::geometry() -{ - return QRect(*this->_geometry); -} - -/* Sets geometry to given size. */ -void QAspectRatioLayout::setGeometry(const QRect& rect) -{ - /* - * We check if the item is set and - * if size is the same previously received. - * If either is false nothing is done. - */ - if(!this->hasItem() || - areRectsEqual(*this->lastReceivedRect, rect)) - { - return; - } - /* Replace the last received rectangle. */ - setLastReceivedRect(rect); - /* Calculate proper size for the item relative to the received size. */ - QSize properSize = calculateProperSize(rect.size()); - /* Calculate center location in the rect and with item size. */ - QPoint properLocation = calculateCenterLocation(rect.size(), properSize); - /* Set items geometry */ - this->item->setGeometry(QRect(properLocation, properSize)); - QRect* oldRect = this->_geometry; - /* Cache the calculated geometry. */ - this->_geometry = new QRect(properLocation, properSize); - delete oldRect; - /* Super classes setGeometry */ - QLayout::setGeometry(*this->_geometry); -} - -/* Takes the shortest side and creates QSize - * with the shortest side as width and height. */ -QSize QAspectRatioLayout::calculateProperSize(QSize from) const -{ - QSize properSize; - if(from.height() * 2 < from.width()) - { - properSize.setHeight(from.height() - this->margin()); - properSize.setWidth(from.height() * 2 - this->margin()); - } - else - { - properSize.setWidth(from.width() - this->margin()); - properSize.setHeight(from.width() / 2 - this->margin()); - } - return properSize; -} - -/* Calculates center location from the given height and width for item size. */ -QPoint QAspectRatioLayout::calculateCenterLocation(QSize from, - QSize itemSize) const -{ - QPoint centerLocation; - if((from.width() - itemSize.width()) > 0) - { - centerLocation.setX((from.width() - itemSize.width())/2); - } - if((from.height() - itemSize.height()) > 0) - { - centerLocation.setY((from.height() - itemSize.height())/2); - } - return centerLocation; -} - -/* Compares if two QRects are equal. */ -bool QAspectRatioLayout::areRectsEqual(const QRect& a, - const QRect& b) const -{ - bool result = false; - if(a.x() == b.x() && - a.y() == b.y() && - a.height() == b.height() && - a.width() == b.width()) - { - result = true; - } - return result; -} diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/qaspectratiolayout.h --- a/QTfrontend/ui/qaspectratiolayout.h Fri Jun 07 16:35:48 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2009 Nokia Corporation. - */ - -#ifndef QASPECTRATIOLAYOUT_H_ -#define QASPECTRATIOLAYOUT_H_ - -#include -#include -#include -#include -#include - - -class QAspectRatioLayout : public QLayout -{ - Q_OBJECT - - public: - QAspectRatioLayout(QWidget* parent, int spacing =-1); - QAspectRatioLayout(int spacing = -1); - ~QAspectRatioLayout(); - - /* Convenience method */ - virtual void add(QLayoutItem* item); - - /* http://doc.trolltech.com/qlayout.html#addItem */ - virtual void addItem(QLayoutItem* item); - /* http://doc.trolltech.com/qlayout.html#addWidget */ - virtual void addWidget(QWidget* widget); - /* http://doc.trolltech.com/qlayout.html#takeAt */ - virtual QLayoutItem* takeAt(int index); - /* http://doc.trolltech.com/qlayout.html#itemAt */ - virtual QLayoutItem* itemAt(int index) const; - /* http://doc.trolltech.com/qlayout.html#count */ - virtual int count() const; - - /* - * These are ours since we do have only one item. - */ - virtual QLayoutItem* replaceItem(QLayoutItem* item); - virtual QLayoutItem* take(); - virtual bool hasItem() const; - - /* http://doc.trolltech.com/qlayout.html#expandingDirections */ - virtual Qt::Orientations expandingDirections() const; - - /* - * This method contains most of the juice of this article. - * http://doc.trolltech.com/qlayoutitem.html#setGeometry - */ - virtual void setGeometry(const QRect& rect); - /* http://doc.trolltech.com/qlayoutitem.html#geometry */ - virtual QRect geometry(); - - /* http://doc.trolltech.com/qlayoutitem.html#sizeHint */ - virtual QSize sizeHint() const; - /* http://doc.trolltech.com/qlayout.html#minimumSize */ - virtual QSize minimumSize() const; - /* http://doc.trolltech.com/qlayoutitem.html#hasHeightForWidth */ - virtual bool hasHeightForWidth() const; - - private: - /* Saves the last received rect. */ - void setLastReceivedRect(const QRect& rect); - /* Used to initialize the object. */ - void init(int spacing); - /* Calculates the maximum size for the item from the assigned size. */ - QSize calculateProperSize(QSize from) const; - /* Calculates the center location from the assigned size and - * the items size. */ - QPoint calculateCenterLocation(QSize from, QSize itemSize) const; - /* Check if two QRects are equal */ - bool areRectsEqual(const QRect& a, const QRect& b) const; - /* Contains item reference */ - QLayoutItem* item; - /* - * Used for caching so we won't do calculations every time - * setGeometry is called. - */ - QRect* lastReceivedRect; - /* Contains geometry */ - QRect* _geometry; - -}; - -#endif /* QASPECTRATIOLAYOUT_H_ */ diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/about.cpp --- a/QTfrontend/ui/widget/about.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/about.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -52,11 +52,8 @@ QLabel *imageLabel = new QLabel; QImage image(":/res/Hedgehog.png"); imageLabel->setPixmap(QPixmap::fromImage(image)); - imageLabel->setScaledContents(true); - imageLabel->setMinimumWidth(2.8); - imageLabel->setMaximumWidth(280); - imageLabel->setMinimumHeight(30); - imageLabel->setMaximumHeight(300); + imageLabel->setFixedWidth(273); + imageLabel->setFixedHeight(300); leftLayout->addWidget(imageLabel, 0, Qt::AlignHCenter); diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/chatwidget.cpp --- a/QTfrontend/ui/widget/chatwidget.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/chatwidget.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -176,7 +176,7 @@ QWidget(parent), mainLayout(this) { - this->gameSettings = gameSettings; + this->gameSettings = NULL; this->notify = notify; m_isAdmin = false; diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/drawmapwidget.cpp --- a/QTfrontend/ui/widget/drawmapwidget.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/drawmapwidget.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -62,8 +62,43 @@ { Q_UNUSED(event); + int height = this->height(); + int width = this->width(); + + if ((m_scene->height() > 0) && (m_scene->width() > 0) && (height > 0)) + { + qreal saspect = m_scene->width() / m_scene->height(); + + qreal h = height; + qreal w = width; + qreal waspect = w / h; + + if (waspect < saspect) + { + h = w / saspect; + } + else if (waspect > saspect) + { + w = saspect * h; + } + + int fixedh = (int)h; + int fixedw = (int)w; + + if (ui->graphicsView->width() != fixedw) + { + ui->graphicsView->setFixedWidth(fixedw); + } + + if (ui->graphicsView->height() != fixedh) + { + ui->graphicsView->setFixedHeight(fixedh); + } + + } + if(ui->graphicsView && ui->graphicsView->scene()) - ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio); + ui->graphicsView->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio); } void DrawMapWidget::showEvent(QShowEvent * event) diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/drawmapwidget.h --- a/QTfrontend/ui/widget/drawmapwidget.h Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/drawmapwidget.h Tue Jun 11 02:42:52 2013 +0200 @@ -25,7 +25,6 @@ #include #include -#include "qaspectratiolayout.h" #include "drawmapscene.h" @@ -61,12 +60,13 @@ QVBoxLayout * vbox = new QVBoxLayout(drawMapWidget); vbox->setMargin(0); lblPoints = new QLabel("0", drawMapWidget); - vbox->addWidget(lblPoints); - QAspectRatioLayout * arLayout = new QAspectRatioLayout(); - arLayout->setMargin(0); + QLayout * arLayout = new QVBoxLayout(); + arLayout->setAlignment(Qt::AlignCenter); vbox->addLayout(arLayout); graphicsView = new DrawMapView(drawMapWidget); + graphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + graphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); arLayout->addWidget(graphicsView); retranslateUi(drawMapWidget); diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/feedbackdialog.cpp --- a/QTfrontend/ui/widget/feedbackdialog.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/feedbackdialog.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -34,7 +34,7 @@ #include -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #define WINVER 0x0500 #include #else @@ -42,7 +42,7 @@ #include #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include #ifndef _SC_NPROCESSORS_ONLN #define _SC_NPROCESSORS_ONLN 58 @@ -207,7 +207,7 @@ QString processor_name = "Processor: "; // platform specific code -#ifdef Q_WS_MACX +#ifdef Q_OS_MACX number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n"; uint64_t memsize; @@ -240,7 +240,7 @@ default: os_version += "\"Unknown version\"\n"; break; } #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN SYSTEM_INFO sysinfo; GetSystemInfo(&sysinfo); number_of_cores += QString::number(sysinfo.dwNumberOfProcessors) + "\n"; @@ -262,7 +262,7 @@ } kernel_line += "Windows kernel\n"; #endif -#ifdef Q_WS_X11 +#ifdef Q_OS_X11 number_of_cores += QString::number(sysconf(_SC_NPROCESSORS_ONLN)) + "\n"; long pages = sysconf(_SC_PHYS_PAGES), /* @@ -277,7 +277,7 @@ #endif // uname -a -#if defined(Q_WS_X11) || defined(Q_WS_MACX) +#if defined(Q_OS_X11) || defined(Q_OS_MAC) QProcess *process = new QProcess(); QStringList arguments = QStringList("-a"); process->start("uname", arguments); @@ -286,7 +286,7 @@ delete process; #endif -#if (!defined(Q_WS_MACX) && defined(__i386__)) || defined(__x86_64__) +#if (!defined(Q_OS_MAC) && defined(__i386__)) || defined(__x86_64__) // cpu info quint32 registers[4]; quint32 i; diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/roomnameprompt.cpp --- a/QTfrontend/ui/widget/roomnameprompt.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/roomnameprompt.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -62,7 +62,7 @@ QPushButton * btnOkay = new QPushButton(tr("Create room")); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept())); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC buttonLayout->addWidget(btnCancel); buttonLayout->addWidget(btnOkay); #else diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/ui/widget/seedprompt.cpp --- a/QTfrontend/ui/widget/seedprompt.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/ui/widget/seedprompt.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -62,7 +62,7 @@ QPushButton * btnOkay = new QPushButton(tr("Set seed")); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept())); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC buttonLayout->addWidget(btnCancel); buttonLayout->addWidget(btnOkay); #else diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/util/FileEngine.cpp --- a/QTfrontend/util/FileEngine.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/util/FileEngine.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -54,7 +54,7 @@ } if (!m_handle) { - qWarning("[PHYSFS] Failed to open %s, reason: %s", m_fileName.toUtf8().constData(), PHYSFS_getLastError()); + qWarning(QString("[PHYSFS] Failed to open %1, reason: %2").arg(m_fileName).arg(FileEngineHandler::errorStr()).toLocal8Bit().constData()); return false; } @@ -310,6 +310,8 @@ FileEngineHandler::FileEngineHandler(char *argv0) { PHYSFS_init(argv0); + + qDebug(QString("[PHYSFS] Init: %1").arg(errorStr()).toLocal8Bit().constData()); } FileEngineHandler::~FileEngineHandler() @@ -328,16 +330,19 @@ void FileEngineHandler::mount(const QString &path) { PHYSFS_mount(path.toUtf8().constData(), NULL, 0); + qDebug(QString("[PHYSFS] Mounting '%1' to '/': %2").arg(path).arg(errorStr()).toLocal8Bit().constData()); } void FileEngineHandler::mount(const QString & path, const QString & mountPoint) { PHYSFS_mount(path.toUtf8().constData(), mountPoint.toUtf8().constData(), 0); + qDebug(QString("[PHYSFS] Mounting '%1' to '%2': %3").arg(path).arg(mountPoint).arg(errorStr()).toLocal8Bit().data()); } void FileEngineHandler::setWriteDir(const QString &path) { PHYSFS_setWriteDir(path.toUtf8().constData()); + qDebug(QString("[PHYSFS] Setting write dir to '%1': %2").arg(path).arg(errorStr()).toLocal8Bit().data()); } void FileEngineHandler::mountPacks() @@ -345,6 +350,12 @@ hedgewarsMountPackages(); } +QString FileEngineHandler::errorStr() +{ + QString s = QString::fromUtf8(PHYSFS_getLastError()); + return s.isEmpty() ? "ok" : s; +} + FileEngineIterator::FileEngineIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &entries) : QAbstractFileEngineIterator(filters, nameFilters) diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/util/FileEngine.h --- a/QTfrontend/util/FileEngine.h Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/util/FileEngine.h Tue Jun 11 02:42:52 2013 +0200 @@ -71,6 +71,7 @@ static void mount(const QString & path, const QString & mountPoint); static void setWriteDir(const QString & path); static void mountPacks(); + static QString errorStr(); // private: static const QString scheme; diff -r 955a90b88865 -r d87e2c7838fa QTfrontend/util/LibavInteraction.cpp --- a/QTfrontend/util/LibavInteraction.cpp Fri Jun 07 16:35:48 2013 +0200 +++ b/QTfrontend/util/LibavInteraction.cpp Tue Jun 11 02:42:52 2013 +0200 @@ -278,7 +278,7 @@ return ""; int s = float(pContext->duration)/AV_TIME_BASE; - QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60); + QString desc = tr("Duration: %1m %2s").arg(s/60).arg(s%60) + "\n"; for (int i = 0; i < (int)pContext->nb_streams; i++) { AVStream* pStream = pContext->streams[i]; @@ -290,11 +290,11 @@ if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO) { - desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height); + desc += QString(tr("Video: %1x%2")).arg(pCodec->width).arg(pCodec->height) + ", "; if (pStream->avg_frame_rate.den) { float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den; - desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2); + desc += QString(tr("%1 fps")).arg(fps, 0, 'f', 2) + ", "; } } else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO) diff -r 955a90b88865 -r d87e2c7838fa cmake_modules/compilerchecks.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/compilerchecks.cmake Tue Jun 11 02:42:52 2013 +0200 @@ -0,0 +1,78 @@ + +#TESTING TIME +include(CheckCCompilerFlag) +#when you need to check for a linker flag, just leave the argument of "check_c_compiler_flag" empty + +# CMAKE_C{XX}_FLAGS is for compiler flags (c and c++) +# CMAKE_EXE_LINKER_FLAGS is for linker flags (also add them to pascal_flags and haskell_flags) +# CMAKE_SHARED_LIBRARY__FLAGS same but for shared libraries + +#TODO: should there be two different checks for C and CXX? + +#stack protection, when found it needs to go in the linker flags too (-lssp is added) +check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR) +if(HAVE_STACKPROTECTOR) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector") + set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector") + set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector") +endif() + +#symbol visibility, not supported on Windows (so we error out to avoid spam) +check_c_compiler_flag("-fvisibility=hidden -Werror" HAVE_VISIBILITY) +if(HAVE_VISIBILITY) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +endif() + + +#check for noexecstack on ELF, Gentoo security +set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack") +check_c_compiler_flag("" HAVE_NOEXECSTACK) +if(HAVE_NOEXECSTACK) + list(APPEND pascal_flags "-k-z" "-knoexecstack") + list(APPEND haskell_flags "-optl" "-z" "-optl" "noexecstack") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") +endif() + +#check for full relro on ELF, Debian security +set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro,-z,now") +check_c_compiler_flag("" HAVE_RELROFULL) +if(HAVE_RELROFULL) + list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know") + list(APPEND haskell_flags "-optl" "-z" "-optl" "relro" "-optl" "-z" "-optl" "now") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") +else() + #if full relro is not available, try partial relro + set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro") + check_c_compiler_flag("" HAVE_RELROPARTIAL) + if(HAVE_RELROPARTIAL) + list(APPEND pascal_flags "-k-z" "-krelro") + list(APPEND haskell_flags "-optl" "-z" "-optl" "relro") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") + endif() +endif() + +#check for ASLR on Windows Vista or later, requires binutils >= 2.20 +set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") +check_c_compiler_flag("" HAVE_WINASLR) +if(HAVE_WINASLR) + list(APPEND pascal_flags "-k--nxcompat") + list(APPEND haskell_flags "-optl" "--nxcompat") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") +endif() + +#check for DEP on Windows XP SP2 or later, requires binutils >= 2.20 +set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") +check_c_compiler_flag("" HAVE_WINDEP) +if(HAVE_WINDEP) + list(APPEND pascal_flags "-k--dynamicbase") + list(APPEND haskell_flags "-optl" "--dynamicbase") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}") +endif() + + +#always unset or these flags will be spread everywhere +unset(CMAKE_REQUIRED_FLAGS) + diff -r 955a90b88865 -r d87e2c7838fa cmake_modules/platform.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/platform.cmake Tue Jun 11 02:42:52 2013 +0200 @@ -0,0 +1,80 @@ + +if(APPLE) + set(CMAKE_FIND_FRAMEWORK "FIRST") + +#what system are we building for + set(minimum_macosx_version $ENV{MACOSX_DEPLOYMENT_TARGET}) + +#detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version + find_program(sw_vers sw_vers) + if(sw_vers) + execute_process(COMMAND ${sw_vers} "-productVersion" + OUTPUT_VARIABLE current_macosx_version + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version}) + else() + if(NOT minimum_macosx_version) + message(FATAL_ERROR "sw_vers not found! Need explicit MACOSX_DEPLOYMENT_TARGET variable set") + else() + message("*** sw_vers not found! Fallback to MACOSX_DEPLOYMENT_TARGET variable ***") + set(current_macosx_version ${minimum_macosx_version}) + endif() + endif() + +#if nothing is set, we deploy only for the current system + if(NOT minimum_macosx_version) + set(minimum_macosx_version ${current_macosx_version}) + endif() + +#lower systems don't have enough processing power anyway + 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 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") + set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}") + list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}") + endif() + +#CMAKE_OSX_ARCHITECTURES and CMAKE_OSX_SYSROOT need to be set for universal binary and correct linking + if(NOT CMAKE_OSX_ARCHITECTURES) + if(current_macosx_version VERSION_LESS "10.6") + if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc*") + set(CMAKE_OSX_ARCHITECTURES "ppc7400") + else() + set(CMAKE_OSX_ARCHITECTURES "i386") + endif() + else() + set(CMAKE_OSX_ARCHITECTURES "x86_64") + endif() + endif() + +#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} 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 "/Developer/usr/bin/gcc-4.0") + set(CMAKE_CXX_COMPILER "/Developer/usr/bin/g++-4.0") + else() + string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" sdk_version ${minimum_macosx_version}) + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX${sdk_version}.sdk/") + endif() + endif() + +#add user framework directory, other paths can be passed via FPFLAGS + list(APPEND pascal_flags "-Ff~/Library/Frameworks") +#set deployment target + list(APPEND pascal_flags "-k-macosx_version_min" "-k${minimum_macosx_version}" "-XR${CMAKE_OSX_SYSROOT}") + +endif(APPLE) + +if(WINDOWS) + #this flags prevents a few dll hell problems + set(CMAKE_C_FLAGS "-static-libgcc ${CMAKE_C_FLAGS}") +endif(WINDOWS) + diff -r 955a90b88865 -r d87e2c7838fa cmake_modules/revinfo.cmake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmake_modules/revinfo.cmake Tue Jun 11 02:42:52 2013 +0200 @@ -0,0 +1,38 @@ +#detect Mercurial revision and init rev/hash information +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 "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" HEDGEWARS_REVISION ${internal_version}) + string(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" HEDGEWARS_HASH ${internal_version}) + + if(HGCHANGED) + message("*** You have uncommitted changes in your repository ***") + endif() + #let's assume that if you have hg you might be interested in debugging + set(default_build_type "DEBUG") + #write down hash and rev for easy picking should hg be missing + file(WRITE "${CMAKE_SOURCE_DIR}/share/version_info.txt" "Hedgewars versioning information, do not modify\nrev ${HEDGEWARS_REVISION}\nhash ${HEDGEWARS_HASH}\n") +else() + set(default_build_type "RELEASE") + # when compiling outside rev control, fetch revision and hash information from version_info.txt + find_file(version_info version_info.txt PATH ${CMAKE_SOURCE_DIR}/share) + if(version_info) + file(STRINGS ${version_info} internal_version REGEX "rev") + string(REGEX REPLACE "rev ([0-9]*)" "\\1" HEDGEWARS_REVISION ${internal_version}) + file(STRINGS ${version_info} internal_version REGEX "hash") + string(REGEX REPLACE "hash ([a-zA-Z0-9]*)" "\\1" HEDGEWARS_HASH ${internal_version}) + else() + message(WARNING "${CMAKE_SOURCE_DIR}/share/version_info.txt not found, revision information " + "will be incorrect!!! Contact your source provider to fix this!") + set(HEDGEWARS_REVISION "0000") + set(HEDGEWARS_HASH "unknown") + endif() +endif() + + diff -r 955a90b88865 -r d87e2c7838fa gameServer/Actions.hs --- a/gameServer/Actions.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/Actions.hs Tue Jun 11 02:42:52 2013 +0200 @@ -162,7 +162,13 @@ rnc <- gets roomsClients io $ do - modifyClient rnc (\cl -> cl{teamsInGame = 0, isReady = False, isMaster = False, isInGame = False, clientClan = Nothing}) ci + modifyClient rnc ( + \cl -> cl{teamsInGame = 0 + , isReady = False + , isMaster = False + , isInGame = False + , isJoinedMidGame = False + , clientClan = Nothing}) ci modifyRoom rnc (\r -> r{playersIn = playersIn r + 1}) ri moveClientToRoom rnc ri ci @@ -290,7 +296,7 @@ pr <- client's clientProto mapM_ processAction [ AnswerClients (map sendChan roomPlayers) $ notReadyMessage pr . map nick . filter (not . isMaster) $ roomPlayers - , ModifyRoomClients (\cl -> cl{isReady = isMaster cl}) + , ModifyRoomClients (\cl -> cl{isReady = isMaster cl, isJoinedMidGame = False}) , ModifyRoom (\r -> r{readyPlayers = 1}) ] where @@ -301,10 +307,17 @@ rnc <- gets roomsClients ri <- clientRoomA thisRoomChans <- liftM (map sendChan) $ roomClientsS ri + joinedMidGame <- liftM (filter isJoinedMidGame) $ roomClientsS ri answerRemovedTeams <- io $ - room'sM rnc (map (\t -> AnswerClients thisRoomChans ["REMOVE_TEAM", t]) . leftTeams . fromJust . gameInfo) ri + room'sM rnc (\r -> let gi = fromJust $ gameInfo r in + concatMap (\c -> + (answerFullConfigParams c (mapParams r) (params r)) + ++ + (map (\t -> AnswerClients [sendChan c] ["REMOVE_TEAM", t]) $ leftTeams gi) + ) joinedMidGame + ) ri - mapM_ processAction $ + mapM_ processAction $ ( SaveReplay : ModifyRoom (\r -> r{ @@ -312,10 +325,11 @@ readyPlayers = 0 } ) - : UnreadyRoomClients : SendUpdateOnThisRoom : AnswerClients thisRoomChans ["ROUND_FINISHED"] : answerRemovedTeams + ) + ++ [UnreadyRoomClients] processAction (SendTeamRemovalMessage teamName) = do diff -r 955a90b88865 -r d87e2c7838fa gameServer/CoreTypes.hs --- a/gameServer/CoreTypes.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/CoreTypes.hs Tue Jun 11 02:42:52 2013 +0200 @@ -107,6 +107,7 @@ isAdministrator :: Bool, isChecker :: Bool, isKickedFromServer :: Bool, + isJoinedMidGame :: Bool, clientClan :: !(Maybe B.ByteString), checkInfo :: Maybe CheckInfo, teamsInGame :: Word diff -r 955a90b88865 -r d87e2c7838fa gameServer/HWProtoChecker.hs --- a/gameServer/HWProtoChecker.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/HWProtoChecker.hs Tue Jun 11 02:42:52 2013 +0200 @@ -1,17 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} module HWProtoChecker where -import qualified Data.Map as Map import Data.Maybe -import Data.List import Control.Monad.Reader -------------------------------------- import CoreTypes import Actions -import Utils import HandlerUtils -import RoomsAndClients -import EngineInteraction handleCmd_checker :: CmdHandler diff -r 955a90b88865 -r d87e2c7838fa gameServer/HWProtoCore.hs --- a/gameServer/HWProtoCore.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/HWProtoCore.hs Tue Jun 11 02:42:52 2013 +0200 @@ -4,7 +4,6 @@ import Control.Monad.Reader import Data.Maybe import qualified Data.ByteString.Char8 as B -import qualified Data.List as L -------------------------------------- import CoreTypes import Actions @@ -34,24 +33,24 @@ else return [ModifyClient (\c -> c{pingsQueue = pingsQueue c - 1})] -handleCmd ("CMD" : parameters) = - let c = concatMap B.words parameters in - if not $ null c then - h $ (upperCase . head $ c) : tail c - else - return [] +handleCmd ["CMD", parameters] = do + let (cmd, plist) = B.break (== ' ') parameters + let param = B.dropWhile (== ' ') plist + h (upperCase cmd) param where - h ["DELEGATE", n] = handleCmd ["DELEGATE", n] - h ["STATS"] = handleCmd ["STATS"] - h ("PART":m:ms) = handleCmd ["PART", B.unwords $ m:ms] - h ("QUIT":m:ms) = handleCmd ["QUIT", B.unwords $ m:ms] - h ("RND":rs) = handleCmd ("RND":rs) - h ("GLOBAL":m:ms) = do + h "DELEGATE" n | not $ B.null n = handleCmd ["DELEGATE", n] + h "STATS" _ = handleCmd ["STATS"] + h "PART" m | not $ B.null m = handleCmd ["PART", m] + | otherwise = handleCmd ["PART"] + h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m] + | otherwise = handleCmd ["QUIT"] + h "RND" p = handleCmd ("RND" : B.words p) + h "GLOBAL" p = do cl <- thisClient rnc <- liftM snd ask let chans = map (sendChan . client rnc) $ allClients rnc - return [AnswerClients chans ["CHAT", "[global notice]", B.unwords $ m:ms] | isAdministrator cl] - h c = return [Warning . B.concat . L.intersperse " " $ "Unknown cmd" : c] + return [AnswerClients chans ["CHAT", "[global notice]", p] | isAdministrator cl] + h c p = return [Warning $ B.concat ["Unknown cmd: /", c, p]] handleCmd cmd = do (ci, irnc) <- ask diff -r 955a90b88865 -r d87e2c7838fa gameServer/HWProtoLobbyState.hs --- a/gameServer/HWProtoLobbyState.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/HWProtoLobbyState.hs Tue Jun 11 02:42:52 2013 +0200 @@ -1,7 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} module HWProtoLobbyState where -import qualified Data.Map as Map import Data.Maybe import Data.List import Control.Monad.Reader @@ -51,7 +50,7 @@ [ AddRoom rName roomPassword , AnswerClients [sendChan cl] ["CLIENT_FLAGS", "+hr", nick cl] - , ModifyClient (\c -> c{isMaster = True, isReady = True}) + , ModifyClient (\c -> c{isMaster = True, isReady = True, isJoinedMidGame = False}) , ModifyRoom (\r -> r{readyPlayers = 1}) ] @@ -87,12 +86,13 @@ else [ MoveToRoom jRI + , ModifyClient (\c -> c{isJoinedMidGame = isJust $ gameInfo jRoom}) , AnswerClients [sendChan cl] $ "JOINED" : nicks , AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] , AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", ownerNick] ] ++ (if clientProto cl < 38 then map (readynessMessage cl) jRoomClients else [sendStateFlags cl jRoomClients]) - ++ answerFullConfig cl (mapParams jRoom) (params jRoom) + ++ answerFullConfig cl jRoom ++ answerTeams cl jRoom ++ watchRound cl jRoom chans @@ -105,18 +105,9 @@ (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 - - answerFullConfig cl mpr pr - | clientProto cl < 38 = map (toAnswer cl) $ - (reverse . map (\(a, b) -> (a, [b])) $ Map.toList mpr) - ++ (("SCHEME", pr Map.! "SCHEME") - : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr)) - - | otherwise = map (toAnswer cl) $ - ("FULLMAPCONFIG", Map.elems mpr) - : ("SCHEME", pr Map.! "SCHEME") - : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr) + -- get config from gameInfo if possible, otherwise from room + answerFullConfig cl jRoom = let f r g = (if isJust $ gameInfo jRoom then g . fromJust . gameInfo else r) jRoom + in answerFullConfigParams cl (f mapParams giMapParams) (f params giParams) answerTeams cl jRoom = let f = if isJust $ gameInfo jRoom then teamsAtStart . fromJust . gameInfo else teams in answerAllTeams cl $ f jRoom diff -r 955a90b88865 -r d87e2c7838fa gameServer/HandlerUtils.hs --- a/gameServer/HandlerUtils.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/HandlerUtils.hs Tue Jun 11 02:42:52 2013 +0200 @@ -6,7 +6,7 @@ import RoomsAndClients import CoreTypes -import Actions + thisClient :: Reader (ClientIndex, IRnC) ClientInfo thisClient = do diff -r 955a90b88865 -r d87e2c7838fa gameServer/NetRoutines.hs --- a/gameServer/NetRoutines.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/NetRoutines.hs Tue Jun 11 02:42:52 2013 +0200 @@ -44,6 +44,7 @@ False False False + False Nothing Nothing 0 diff -r 955a90b88865 -r d87e2c7838fa gameServer/Utils.hs --- a/gameServer/Utils.hs Fri Jun 07 16:35:48 2013 +0200 +++ b/gameServer/Utils.hs Tue Jun 11 02:42:52 2013 +0200 @@ -137,5 +137,25 @@ head (Map.findWithDefault ["Default"] "AMMO" (params r)) ] + +answerFullConfigParams :: + ClientInfo + -> Map.Map B.ByteString B.ByteString + -> Map.Map B.ByteString [B.ByteString] + -> [Action] +answerFullConfigParams cl mpr pr + | clientProto cl < 38 = map (toAnswer cl) $ + (reverse . map (\(a, b) -> (a, [b])) $ Map.toList mpr) + ++ (("SCHEME", pr Map.! "SCHEME") + : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr)) + + | otherwise = map (toAnswer cl) $ + ("FULLMAPCONFIG", Map.elems mpr) + : ("SCHEME", pr Map.! "SCHEME") + : (filter (\(p, _) -> p /= "SCHEME") $ Map.toList pr) + where + toAnswer cl (paramName, paramStrs) = AnswerClients [sendChan cl] $ "CFG" : paramName : paramStrs + + loc :: B.ByteString -> B.ByteString loc = id diff -r 955a90b88865 -r d87e2c7838fa hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/CMakeLists.txt Tue Jun 11 02:42:52 2013 +0200 @@ -102,7 +102,7 @@ ) if(${BUILD_ENGINE_LIBRARY}) - message(${WARNING} "Engine will be built as library (experimental)") + message("*** Engine will be built as library (experimental) ***") list(APPEND pascal_flags "-dHWLIBRARY") # create position independent code, only required for x68_64 builds, similar to -fPIC diff -r 955a90b88865 -r d87e2c7838fa hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/GSHandlers.inc Tue Jun 11 02:42:52 2013 +0200 @@ -5122,20 +5122,20 @@ end; procedure doStepIceGun(Gear: PGear); -const iceWaitCollision:Longint = 0; -const iceCollideWithGround:Longint = 1; +const iceWaitCollision = 0; +const iceCollideWithGround = 1; //const iceWaitNextTarget:Longint = 2; //const iceCollideWithHog:Longint = 4; -const iceCollideWithWater:Longint = 5; +const iceCollideWithWater = 5; //const waterFreezingTime:Longint = 500; -const groundFreezingTime:Longint = 1000; +const groundFreezingTime = 1000; const iceRadius = 32; const iceHeight = 40; var HHGear, iter: PGear; landRect: TSDL_Rect; ndX, ndY: hwFloat; - i, j, t, gX, gY: LongInt; + i, t, gX, gY: LongInt; hogs: PGearArrayS; vg: PVisualGear; begin @@ -5218,7 +5218,7 @@ if vg <> nil then begin i:= random(100) + 155; - vg^.Tint:= i shl 24 or i shl 16 or $FF shl 8 or Longword(random(200) + 55); + vg^.Tint:= (i shl 24) or (i shl 16) or ($FF shl 8) or (random(200) + 55); vg^.Angle:= random(360); vg^.dx:= 0.001 * random(80); vg^.dy:= 0.001 * random(80) diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uAIAmmoTests.pas Tue Jun 11 02:42:52 2013 +0200 @@ -20,7 +20,7 @@ unit uAIAmmoTests; interface -uses SDLh, uConsts, uFloat, uTypes, uAIMisc; +uses uConsts, uFloat, uTypes, uAIMisc; const amtest_Rare = $00000001; // check only several positions amtest_NoTarget = $00000002; // each pos, but no targetting @@ -330,7 +330,7 @@ function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; - TestTime: Longword; + TestTime: LongInt; x, y, dY, meX, meY: real; t: LongInt; begin @@ -382,7 +382,7 @@ const tDelta = 24; var Vx, Vy, r: real; Score, EX, EY, valueResult: LongInt; - TestTime: Longword; + TestTime: LongInt; x, y, meX, meY, dY: real; t: LongInt; begin @@ -681,7 +681,7 @@ function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; var Vx, Vy, x, y, t: real; d: Longword; - fallDmg, valueResult: LongInt; + {fallDmg, }valueResult: LongInt; begin if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); Level:= Level; // avoid compiler hint @@ -724,7 +724,7 @@ function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; var Vx, Vy, x, y, t, dmg: real; d: Longword; - fallDmg: LongInt; + //fallDmg: LongInt; begin if (Level > 3) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); Level:= Level; // avoid compiler hint diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uAIMisc.pas Tue Jun 11 02:42:52 2013 +0200 @@ -113,7 +113,7 @@ Targets.reset:= false; end; procedure FillTargets; -var i, t: Longword; +var //i, t: Longword; f, e: LongInt; Gear: PGear; begin diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uChat.pas --- a/hedgewars/uChat.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uChat.pas Tue Jun 11 02:42:52 2013 +0200 @@ -48,8 +48,8 @@ LocalStrs: array[0 .. MaxStrIndex] of shortstring; missedCount: LongWord; lastStr: LongWord; - localLastStr: LongWord; - history: LongWord; + localLastStr: LongInt; + history: LongInt; visibleCount: LongWord; InputStr: TChatLine; InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uGears.pas --- a/hedgewars/uGears.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uGears.pas Tue Jun 11 02:42:52 2013 +0200 @@ -774,7 +774,8 @@ begin dec(i); Gear:= t^.ar[i]; - if (Ammo^.Kind = gtFlame) and (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heFrozen] > 255) then + if ((Ammo^.Kind = gtFlame) or (Ammo^.Kind = gtBlowTorch)) and + (Gear^.Kind = gtHedgehog) and (Gear^.Hedgehog^.Effects[heFrozen] > 255) then Gear^.Hedgehog^.Effects[heFrozen]:= max(255,Gear^.Hedgehog^.Effects[heFrozen]-10000); tmpDmg:= ModifyDamage(Damage, Gear); if (Gear^.State and gstNoDamage) = 0 then diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uGearsHedgehog.pas --- a/hedgewars/uGearsHedgehog.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uGearsHedgehog.pas Tue Jun 11 02:42:52 2013 +0200 @@ -808,7 +808,8 @@ var da: LongWord; begin with HHGear^.Hedgehog^ do - if ((CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amRope) and ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) + if (((CurAmmoType = amRope) or ((CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amRope))) and + ((HHGear^.State and (gstMoving or gstHHJumping)) = gstMoving)) or ((CurAmmoType = amPortalGun) and ((HHGear^.State and gstMoving) <> 0)) then da:= 2 else da:= 1; diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uGearsUtils.pas Tue Jun 11 02:42:52 2013 +0200 @@ -183,9 +183,9 @@ if (CurrentHedgehog <> nil) and CurrentHedgehog^.King then i:= _1_5; if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.King or (Gear^.Hedgehog^.Effects[heFrozen] > 0)) then - ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent * _0_5) + ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_5 * _0_01) else - ModifyDamage:= hwRound(_0_01 * cDamageModifier * dmg * i * cDamagePercent) + ModifyDamage:= hwRound(cDamageModifier * dmg * i * cDamagePercent * _0_01) end; procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uIO.pas --- a/hedgewars/uIO.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uIO.pas Tue Jun 11 02:42:52 2013 +0200 @@ -212,7 +212,7 @@ end; procedure SendStat(sit: TStatInfoType; s: shortstring); -const stc: array [TStatInfoType] of char = ('r', 'D', 'k', 'K', 'H', 'T', 'P', 's', 'S', 'B'); +const stc: array [TStatInfoType] of char = ('r', 'D', 'k', 'K', 'H', 'T', 'P', 's', 'S', 'B', 'c', 'g', 'p'); var buf: shortstring; begin buf:= 'i' + stc[sit] + s; diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uScript.pas --- a/hedgewars/uScript.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uScript.pas Tue Jun 11 02:42:52 2013 +0200 @@ -83,7 +83,8 @@ SDLh, SysUtils, uIO, - uPhysFSLayer + uPhysFSLayer, + typinfo ; var luaState : Plua_State; @@ -1285,6 +1286,64 @@ lc_endgame:= 0 end; +function lc_sendstat(L : Plua_State) : LongInt; Cdecl; +var statInfo : TStatInfoType; +var i : LongInt; +var color : shortstring; +begin + statInfo := TStatInfoType(GetEnumValue(TypeInfo(TStatInfoType),lua_tostring(L, 1))); + if (lua_gettop(L) <> 2) and ((statInfo <> siPlayerKills) + and (statInfo <> siClanHealth)) then + begin + LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 2 parameters.'); + end + else if (lua_gettop(L) <> 3) and ((statInfo = siPlayerKills) + or (statInfo = siClanHealth)) then + begin + LuaError('Lua: Wrong number of parameters passed to SendStat! Expected 3 parameters.'); + end + else + begin + if ((statInfo = siPlayerKills) or (statInfo = siClanHealth)) then + begin + // 3: team name + for i:= 0 to Pred(TeamsCount) do + begin + with TeamsArray[i]^ do + begin + if TeamName = lua_tostring(L, 3) then + begin + color := uUtils.IntToStr(Clan^.Color); + Break; + end + end + end; + if (statInfo = siPlayerKills) then + begin + SendStat(siPlayerKills, color + ' ' + + lua_tostring(L, 2) + ' ' + TeamsArray[i]^.TeamName); + end + else if (statInfo = siClanHealth) then + begin + SendStat(siClanHealth, color + ' ' + + lua_tostring(L, 2)); + end + end + else + begin + SendStat(statInfo,lua_tostring(L, 2)); + end; + end; + lc_sendstat:= 0 +end; + +function lc_sendhealthstatsoff(L : Plua_State) : LongInt; Cdecl; +begin + L:= L; // avoid compiler hint + uStats.SendHealthStatsOn := false; + lc_sendhealthstatsoff:= 0 +end; + function lc_findplace(L : Plua_State) : LongInt; Cdecl; var gear: PGear; fall: boolean; @@ -2382,6 +2441,8 @@ lua_register(luaState, _P'WriteLnToConsole', @lc_writelntoconsole); lua_register(luaState, _P'GetGearType', @lc_getgeartype); lua_register(luaState, _P'EndGame', @lc_endgame); +lua_register(luaState, _P'SendStat', @lc_sendstat); +lua_register(luaState, _P'SendHealthStatsOff', @lc_sendhealthstatsoff); lua_register(luaState, _P'FindPlace', @lc_findplace); lua_register(luaState, _P'SetGearPosition', @lc_setgearposition); lua_register(luaState, _P'GetGearPosition', @lc_getgearposition); diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uStats.pas --- a/hedgewars/uStats.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uStats.pas Tue Jun 11 02:42:52 2013 +0200 @@ -24,7 +24,8 @@ var TotalRounds: LongInt; FinishedTurnsTotal: LongInt; - + SendHealthStatsOn : boolean = true; + procedure initModule; procedure freeModule; @@ -162,12 +163,13 @@ StepDamageRecv:= 0; StepDamageGiven:= 0 end; - -for t:= 0 to Pred(ClansCount) do - with ClansArray[t]^ do - begin - SendStat(siClanHealth, IntToStr(Color) + ' ' + IntToStr(ClanHealth)); - end; + +if SendHealthStatsOn then + for t:= 0 to Pred(ClansCount) do + with ClansArray[t]^ do + begin + SendStat(siClanHealth, IntToStr(Color) + ' ' + IntToStr(ClanHealth)); + end; Kills:= 0; KillsClan:= 0; @@ -207,103 +209,104 @@ maxTeamDamageName : shortstring; winnersClan : PClan; begin -msd:= 0; msdhh:= nil; -msk:= 0; mskhh:= nil; -mskcnt:= 0; -maxTeamKills := 0; -maxTurnSkips := 0; -maxTeamDamage := 0; -winnersClan:= nil; +if SendHealthStatsOn then + msd:= 0; msdhh:= nil; + msk:= 0; mskhh:= nil; + mskcnt:= 0; + maxTeamKills := 0; + maxTurnSkips := 0; + maxTeamDamage := 0; + winnersClan:= nil; -for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - if not ExtDriven then - SendStat(siTeamStats, GetTeamStatString(TeamsArray[t])); - for i:= 0 to cMaxHHIndex do - begin - if Hedgehogs[i].stats.MaxStepDamageGiven > msd then - begin - msdhh:= @Hedgehogs[i]; - msd:= Hedgehogs[i].stats.MaxStepDamageGiven - end; - if Hedgehogs[i].stats.MaxStepKills >= msk then - if Hedgehogs[i].stats.MaxStepKills = msk then - inc(mskcnt) - else - begin - mskcnt:= 1; - mskhh:= @Hedgehogs[i]; - msk:= Hedgehogs[i].stats.MaxStepKills - end; - end; + for t:= 0 to Pred(TeamsCount) do + with TeamsArray[t]^ do + begin + if not ExtDriven then + SendStat(siTeamStats, GetTeamStatString(TeamsArray[t])); + for i:= 0 to cMaxHHIndex do + begin + if Hedgehogs[i].stats.MaxStepDamageGiven > msd then + begin + msdhh:= @Hedgehogs[i]; + msd:= Hedgehogs[i].stats.MaxStepDamageGiven + end; + if Hedgehogs[i].stats.MaxStepKills >= msk then + if Hedgehogs[i].stats.MaxStepKills = msk then + inc(mskcnt) + else + begin + mskcnt:= 1; + mskhh:= @Hedgehogs[i]; + msk:= Hedgehogs[i].stats.MaxStepKills + end; + end; - { send player stats for winner teams } - if Clan^.ClanHealth > 0 then - begin - winnersClan:= Clan; - SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + - IntToStr(stats.Kills) + ' ' + TeamName); - end; + { send player stats for winner teams } + if Clan^.ClanHealth > 0 then + begin + winnersClan:= Clan; + SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + + IntToStr(stats.Kills) + ' ' + TeamName); + end; - { determine maximum values of TeamKills, TurnSkips, TeamDamage } - if stats.TeamKills > maxTeamKills then - begin - maxTeamKills := stats.TeamKills; - maxTeamKillsName := TeamName; - end; - if stats.TurnSkips > maxTurnSkips then - begin - maxTurnSkips := stats.TurnSkips; - maxTurnSkipsName := TeamName; - end; - if stats.TeamDamage > maxTeamDamage then - begin - maxTeamDamage := stats.TeamDamage; - maxTeamDamageName := TeamName; - end; + { determine maximum values of TeamKills, TurnSkips, TeamDamage } + if stats.TeamKills > maxTeamKills then + begin + maxTeamKills := stats.TeamKills; + maxTeamKillsName := TeamName; + end; + if stats.TurnSkips > maxTurnSkips then + begin + maxTurnSkips := stats.TurnSkips; + maxTurnSkipsName := TeamName; + end; + if stats.TeamDamage > maxTeamDamage then + begin + maxTeamDamage := stats.TeamDamage; + maxTeamDamageName := TeamName; + end; - end; + end; -{ now send player stats for loser teams } -for t:= 0 to Pred(TeamsCount) do - begin - with TeamsArray[t]^ do - begin - if Clan^.ClanHealth = 0 then - begin - SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + - IntToStr(stats.Kills) + ' ' + TeamName); - end; - end; -end; + { now send player stats for loser teams } + for t:= 0 to Pred(TeamsCount) do + begin + with TeamsArray[t]^ do + begin + if Clan^.ClanHealth = 0 then + begin + SendStat(siPlayerKills, IntToStr(Clan^.Color) + ' ' + + IntToStr(stats.Kills) + ' ' + TeamName); + end; + end; + end; -if msdhh <> nil then - SendStat(siMaxStepDamage, IntToStr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); -if mskcnt = 1 then - SendStat(siMaxStepKills, IntToStr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); + if msdhh <> nil then + SendStat(siMaxStepDamage, IntToStr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); + if mskcnt = 1 then + SendStat(siMaxStepKills, IntToStr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); -if maxTeamKills > 1 then - SendStat(siMaxTeamKills, IntToStr(maxTeamKills) + ' ' + maxTeamKillsName); -if maxTurnSkips > 2 then - SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName); -if maxTeamDamage > 30 then - SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName); + if maxTeamKills > 1 then + SendStat(siMaxTeamKills, IntToStr(maxTeamKills) + ' ' + maxTeamKillsName); + if maxTurnSkips > 2 then + SendStat(siMaxTurnSkips, IntToStr(maxTurnSkips) + ' ' + maxTurnSkipsName); + if maxTeamDamage > 30 then + SendStat(siMaxTeamDamage, IntToStr(maxTeamDamage) + ' ' + maxTeamDamageName); -if KilledHHs > 0 then - SendStat(siKilledHHs, IntToStr(KilledHHs)); + if KilledHHs > 0 then + SendStat(siKilledHHs, IntToStr(KilledHHs)); -// now to console -if winnersClan <> nil then - begin - WriteLnToConsole('WINNERS'); - for t:= 0 to winnersClan^.TeamsNumber - 1 do - WriteLnToConsole(winnersClan^.Teams[t]^.TeamName); - end -else - WriteLnToConsole('DRAW'); + // now to console + if winnersClan <> nil then + begin + WriteLnToConsole('WINNERS'); + for t:= 0 to winnersClan^.TeamsNumber - 1 do + WriteLnToConsole(winnersClan^.Teams[t]^.TeamName); + end + else + WriteLnToConsole('DRAW'); -WriteLnToConsole(''); + WriteLnToConsole(''); end; procedure initModule; diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uTeams.pas Tue Jun 11 02:42:52 2013 +0200 @@ -96,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); @@ -110,7 +110,7 @@ end; procedure SwitchHedgehog; -var c, i, t, j: LongWord; +var c, i, t: LongWord; PrevHH, PrevTeam : LongWord; begin TargetPoint.X:= NoPointX; @@ -190,18 +190,22 @@ CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; until ((Hedgehogs[CurrHedgehog].Gear <> nil) and (Hedgehogs[CurrHedgehog].Effects[heFrozen] < 256)) or (CurrHedgehog = PrevHH) end - until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 50256)) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0)) + until ((CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256)) or (PrevTeam = CurrTeam) or ((CurrTeam = TagTeamIndex) and ((GameFlags and gfTagTeam) <> 0)) end; if (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then begin - inc(CurrentTeam^.Clan^.TurnNumber); with CurrentTeam^.Clan^ do for t:= 0 to Pred(TeamsNumber) do with Teams[t]^ do for i:= 0 to Pred(HedgehogsNumber) do with Hedgehogs[i] do - if Effects[heFrozen] > 255 then - Effects[heFrozen]:= max(255,Effects[heFrozen]-50000) + begin + if Effects[heFrozen] > 255 then Effects[heFrozen]:= max(255,Effects[heFrozen]-50000); + if (Gear <> nil) and (Effects[heFrozen] < 256) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then + CurrHedgehog:= i + end; + if (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear = nil) or (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] > 255) then + inc(CurrentTeam^.Clan^.TurnNumber); end until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen] < 256); diff -r 955a90b88865 -r d87e2c7838fa hedgewars/uTypes.pas --- a/hedgewars/uTypes.pas Fri Jun 07 16:35:48 2013 +0200 +++ b/hedgewars/uTypes.pas Tue Jun 11 02:42:52 2013 +0200 @@ -164,7 +164,8 @@ TStatInfoType = (siGameResult, siMaxStepDamage, siMaxStepKills, siKilledHHs, siClanHealth, siTeamStats, siPlayerKills, siMaxTeamDamage, - siMaxTeamKills, siMaxTurnSkips ); + siMaxTeamKills, siMaxTurnSkips, siCustomAchievement, siGraphTitle, + siPointType); // Various "emote" animations a hedgehog can do TWave = (waveRollup, waveSad, waveWave, waveHurrah, waveLemonade, waveShrug, waveJuggle); diff -r 955a90b88865 -r d87e2c7838fa misc/libphysfs/CMakeLists.txt --- a/misc/libphysfs/CMakeLists.txt Fri Jun 07 16:35:48 2013 +0200 +++ b/misc/libphysfs/CMakeLists.txt Tue Jun 11 02:42:52 2013 +0200 @@ -48,11 +48,13 @@ # Fallback to older OS X on PowerPC to support wider range of systems... if(CMAKE_OSX_ARCHITECTURES MATCHES ppc) add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020) - set(OTHER_LDFLAGS ${OTHER_LDFLAGS} " -mmacosx-version-min=10.2") + list(APPEND OTHER_LDFLAGS "-mmacosx-version-min=10.2") endif(CMAKE_OSX_ARCHITECTURES MATCHES ppc) # Need these everywhere... add_definitions(-fno-common) + find_library(foundation_framework NAMES Foundation) + list(APPEND OTHER_LDFLAGS ${foundation_framework}) find_library(iokit_framework NAMES IOKit) list(APPEND OTHER_LDFLAGS ${iokit_framework}) endif(MACOSX) @@ -60,7 +62,7 @@ # Add some gcc-specific command lines. if(CMAKE_COMPILER_IS_GNUCC) # Always build with debug symbols...you can strip it later. - add_definitions(-g -pipe -Werror -fsigned-char) + add_definitions(-g -fsigned-char) # Stupid BeOS generates warnings in the system headers. if(NOT BEOS) diff -r 955a90b88865 -r d87e2c7838fa misc/libphysfs/platform_macosx.c --- a/misc/libphysfs/platform_macosx.c Fri Jun 07 16:35:48 2013 +0200 +++ b/misc/libphysfs/platform_macosx.c Tue Jun 11 02:42:52 2013 +0200 @@ -44,6 +44,31 @@ fflush(stderr); abort(); } + + +/* apparently libssp is missing from 10.4 SDK + code from http://wiki.osdev.org/GCC_Stack_Smashing_Protector */ +void * __stack_chk_guard = NULL; + +void __stack_chk_guard_setup() +{ + unsigned char * p; + p = (unsigned char *) &__stack_chk_guard; + + /* If you have the ability to generate random numbers in your kernel then use them, + otherwise for 32-bit code: *p = 0x00000aff; */ + *p = random(); +} + +void __attribute__((noreturn)) __stack_chk_fail() +{ + /* put your panic function or similar in here */ + unsigned char * vid = (unsigned char *)0xB8000; + vid[1] = 7; + for(;;) + vid[0]++; +} + #endif #endif /* __APPLE__ */ diff -r 955a90b88865 -r d87e2c7838fa project_files/hedgewars.pro --- a/project_files/hedgewars.pro Fri Jun 07 16:35:48 2013 +0200 +++ b/project_files/hedgewars.pro Tue Jun 11 02:42:52 2013 +0200 @@ -44,7 +44,6 @@ ../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 \ @@ -123,7 +122,6 @@ ../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 \