Fix compilation with gcc

fix-squashed-planets
tomangelo2 2022-09-15 01:14:29 +02:00
parent 8632c7404d
commit 789c8b2292
6 changed files with 20 additions and 12 deletions

View File

@ -23,6 +23,8 @@
#include "CBot/CBotVar/CBotVar.h" #include "CBot/CBotVar/CBotVar.h"
#include <cmath>
namespace CBot namespace CBot
{ {
@ -43,7 +45,7 @@ bool CBotExprLitNan::Execute(CBotStack* &pj)
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create("", CBotTypFloat); CBotVar* var = CBotVar::Create("", CBotTypFloat);
var->SetValFloat(std::nanf("")); var->SetValFloat(nanf(""));
pile->SetVar(var); // put on the stack pile->SetVar(var); // put on the stack
return pj->Return(pile); // forward below return pj->Return(pile); // forward below
} }

View File

@ -38,6 +38,8 @@
#include "CBot/CBotCStack.h" #include "CBot/CBotCStack.h"
#include <cmath>
namespace CBot namespace CBot
{ {
@ -218,7 +220,7 @@ CBotInstr* CBotParExpr::CompileLitExpr(CBotToken* &p, CBotCStack* pStack)
CBotInstr* inst = new CBotExprLitNan(); CBotInstr* inst = new CBotExprLitNan();
inst->SetToken(pp); inst->SetToken(pp);
CBotVar* var = CBotVar::Create("", CBotTypFloat); CBotVar* var = CBotVar::Create("", CBotTypFloat);
var->SetValFloat(std::nanf("")); var->SetValFloat(nanf(""));
pStk->SetVar(var); pStk->SetVar(var);
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
} }

View File

@ -31,6 +31,7 @@
#include "CBot/CBotVar/CBotVar.h" #include "CBot/CBotVar/CBotVar.h"
#include <cassert> #include <cassert>
#include <cmath>
#include <algorithm> #include <algorithm>
namespace CBot namespace CBot

View File

@ -112,6 +112,7 @@
#include <algorithm> #include <algorithm>
#include <iomanip> #include <iomanip>
#include <stdexcept> #include <stdexcept>
#include <cmath>
#include <ctime> #include <ctime>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -4155,7 +4156,7 @@ bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadiu
} }
} }
float nan = std::nanf(""); float nan = nanf("");
center = Math::Vector{ nan, nan, nan }; center = Math::Vector{ nan, nan, nan };

View File

@ -100,7 +100,7 @@ float HaltToFloat(uint16_t value)
// NaN // NaN
else if ((exponent == 31) && (mantissa != 0)) else if ((exponent == 31) && (mantissa != 0))
{ {
result = std::nanf(""); result = nanf("");
} }
// Normal number // Normal number
else else

View File

@ -67,6 +67,8 @@
#include "ui/displaytext.h" #include "ui/displaytext.h"
#include <cmath>
using namespace CBot; using namespace CBot;
CBotTypResult CScriptFunctions::cClassNull(CBotVar* thisclass, CBotVar* &var) CBotTypResult CScriptFunctions::cClassNull(CBotVar* thisclass, CBotVar* &var)
@ -2325,7 +2327,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v
if ( err != ERR_OK ) if ( err != ERR_OK )
{ {
script->m_taskExecutor->StopForegroundTask(); script->m_taskExecutor->StopForegroundTask();
result->SetValFloat(std::nanf("")); result->SetValFloat(nanf(""));
return true; return true;
} }
@ -2336,7 +2338,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v
if ( script->m_returnValue == boost::none ) if ( script->m_returnValue == boost::none )
{ {
result->SetValFloat(std::nanf("")); result->SetValFloat(nanf(""));
} }
else else
{ {
@ -3657,11 +3659,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user)
if (IsObjectBeingTransported(object)) if (IsObjectBeingTransported(object))
{ {
pSub = pVar->GetItemList(); // "x" pSub = pVar->GetItemList(); // "x"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
pSub = pSub->GetNext(); // "y" pSub = pSub->GetNext(); // "y"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
pSub = pSub->GetNext(); // "z" pSub = pSub->GetNext(); // "z"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
} }
else else
{ {
@ -3762,11 +3764,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user)
if (IsObjectBeingTransported(object) || physics == nullptr) if (IsObjectBeingTransported(object) || physics == nullptr)
{ {
pSub = pVar->GetItemList(); // "x" pSub = pVar->GetItemList(); // "x"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
pSub = pSub->GetNext(); // "y" pSub = pSub->GetNext(); // "y"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
pSub = pSub->GetNext(); // "z" pSub = pSub->GetNext(); // "z"
pSub->SetValFloat(std::nanf("")); pSub->SetValFloat(nanf(""));
} }
else else
{ {