From 29a3970b72ef0d2e82f0aa88791c3db42ad28c5e Mon Sep 17 00:00:00 2001 From: ac-stef Date: Fri, 9 Sep 2016 22:22:55 +0200 Subject: [PATCH] fix flyspeed and a compiler optimisation error (for clang >= 4, O3 may be reactivated in the makefile) --- source/src/Makefile | 2 +- source/src/physics.cpp | 2 +- source/src/vertmodel.h | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/src/Makefile b/source/src/Makefile index 4a1f0f2f..d1089e32 100644 --- a/source/src/Makefile +++ b/source/src/Makefile @@ -26,7 +26,7 @@ ifeq ($(ACDEBUG),yes) endif ifneq (,$(findstring clang,$(CXX))) - CXXFLAGS= -O3 -fomit-frame-pointer + CXXFLAGS= -O2 -fomit-frame-pointer override CXXFLAGS+= -Wall -fsigned-char else CXXFLAGS= -O3 -fomit-frame-pointer diff --git a/source/src/physics.cpp b/source/src/physics.cpp index 499a6746..fb8c2ee2 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -457,7 +457,7 @@ void moveplayer(physent *pl, int moveres, bool local, int curtime) float chspeed = (pl->onfloor || pl->onladder || !pl->crouchedinair) ? 0.4f : 1.0f; - const bool crouching = pl->crouching || pl->eyeheight < pl->maxeyeheight; + const bool crouching = pl->crouching || (pl->eyeheight < pl->maxeyeheight && pl->eyeheight > 1.1f); const float speed = curtime/(water ? 2000.0f : 1000.0f)*pl->maxspeed*(crouching && pl->state != CS_EDITING ? chspeed : 1.0f)*(pl==player1 && isfly ? flyspeed : 1.0f); const float friction = water ? 20.0f : (pl->onfloor || isfly ? 6.0f : (pl->onladder ? 1.5f : 30.0f)); const float fpsfric = max(friction/curtime*20.0f, 1.0f); diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 38d31a2a..bf6191d6 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -180,7 +180,9 @@ struct vertmodel : model } #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 -__attribute__((optimize(2))) + __attribute__((optimize(2))) +#elif defined(__clang__) && __clang_major__ >= 4 + __attribute__((optnone)) #endif dyncacheentry *gendynverts(animstate &as, anpos &cur, anpos *prev, float ai_t) { @@ -294,7 +296,9 @@ __attribute__((optimize(2))) } #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 -__attribute__((optimize(2))) + __attribute__((optimize(2))) +#elif defined(__clang__) && __clang_major__ >= 4 + __attribute__((optnone)) #endif shadowcacheentry *genshadowvolume(animstate &as, anpos &cur, anpos *prev, float ai_t, vec *buf) { @@ -357,7 +361,9 @@ __attribute__((optimize(2))) } #if defined(__GNUC__) && defined(__OPTIMIZE__) && !defined(__clang__) && !defined(__ICL) && __GNUC__ >= 4 && __GNUC_MINOR__ > 4 -__attribute__((optimize(2))) + __attribute__((optimize(2))) +#elif defined(__clang__) && __clang_major__ >= 4 + __attribute__((optnone)) #endif lightcacheentry *lightvertexes(animstate &as, anpos &cur, anpos *prev, float ai_t, vec *buf) {