mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-01-17 14:28:30 +01:00
Fix crash when doing sim.ambientAirTemp(0/0)
This commit is contained in:
parent
5eb2495d61
commit
b0e29c8c23
@ -1,6 +1,7 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
#include "Config.h"
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
@ -43,6 +44,9 @@ inline unsigned clamp_flt(float f, float min, float max)
|
||||
|
||||
inline float restrict_flt(float f, float min, float max)
|
||||
{
|
||||
// Fix crash in certain cases when f is nan
|
||||
if (!std::isfinite(f))
|
||||
return min;
|
||||
if (f < min)
|
||||
return min;
|
||||
if (f > max)
|
||||
|
Loading…
x
Reference in New Issue
Block a user