diff --git a/polymer/eduke32/build/include/compat.h b/polymer/eduke32/build/include/compat.h index d03b0cc76..6a34503a6 100644 --- a/polymer/eduke32/build/include/compat.h +++ b/polymer/eduke32/build/include/compat.h @@ -452,14 +452,23 @@ static inline void dtol(double d, int32_t *a) #endif #if __GNUC__ >= 4 -static inline __attribute__((warn_unused_result)) int32_t clamp(int32_t in, int32_t min, int32_t max) +# define CLAMP_DECL static inline __attribute__((warn_unused_result)) #else -static inline int32_t clamp(int32_t in, int32_t min, int32_t max) +# define CLAMP_DECL static inline #endif + +// Clamp to [..]. The case in <= min is handled first. +CLAMP_DECL int32_t clamp(int32_t in, int32_t min, int32_t max) { return in <= min ? min : (in >= max ? max : in); } +// Clamp to [..]. The case in >= max is handled first. +CLAMP_DECL int32_t clamp2(int32_t in, int32_t min, int32_t max) +{ + return in >= max ? max : (in <= min ? min : in); +} + #define BMAX_PATH 256 diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index b90e9aa0d..8a3d77c5b 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -1257,10 +1257,8 @@ void editinput(void) handle_sprite_in_clipboard(i); - getzsofslope(hit.sect, hit.pos.x, hit.pos.y, &cz, &fz); - spriteoncfz(i, &cz, &fz); - sprite[i].z = clamp(hit.pos.z, cz, fz); + sprite[i].z = clamp2(hit.pos.z, cz, fz); if (AIMING_AT_WALL || AIMING_AT_MASKWALL) {