From 08f6c32551e1aba5e22a3fbe142b0a32fa7e0259 Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Wed, 9 Feb 2022 20:43:35 +0100 Subject: [PATCH 01/37] Update Homebrew installation command --- INSTALL-MacOSX.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL-MacOSX.md b/INSTALL-MacOSX.md index 001241fa..85cc5f28 100644 --- a/INSTALL-MacOSX.md +++ b/INSTALL-MacOSX.md @@ -4,7 +4,7 @@ To compile Colobot on MacOS X, you need to first get Developer Command Line Tool After installing Developer Command Line Tools, you should have basic tools like clang and git installed. After that, you can grab other required packages with Homebrew. So as in instructions on [the project page](http://brew.sh/): ```bash - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` And then: ```bash From e3ba1a1840de2953946cafa750df80f636d3505b Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Thu, 10 Feb 2022 19:46:50 +0100 Subject: [PATCH 02/37] Fix compilation errors on MacOS --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96b534a5..19e2fa0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,8 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") # Platform-dependent implementation of system.h set(SYSTEM_CPP_MODULE "system_macosx.cpp") set(SYSTEM_H_MODULE "system_macosx.h") + # Fix compilation errors in MacOS SDK files + set(CMAKE_CXX_FLAGS "${NORMAL_CXX_FLAGS} -Wno-nullability-extension -Wno-nullability-completeness -Wno-expansion-to-defined -Wno-four-char-constants -Wno-gnu-zero-variadic-macro-arguments -Wno-variadic-macros -Wno-zero-length-array") # To avoid CMake warning set(CMAKE_MACOSX_RPATH 1) elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") From 483a8558488ae88853f3cd537f0b9152f81a31e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Br=C3=B6nneg=C3=A5rd?= <1162652+rasmusgo@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:00:19 +0100 Subject: [PATCH 03/37] Add DistanceSquared to vector.h --- src/math/vector.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/math/vector.h b/src/math/vector.h index e57ccbb6..0af4840b 100644 --- a/src/math/vector.h +++ b/src/math/vector.h @@ -273,6 +273,14 @@ inline float Distance(const Math::Vector &a, const Math::Vector &b) (a.z-b.z)*(a.z-b.z) ); } +//! Returns the squared distance between the ends of two vectors +inline float DistanceSquared(const Math::Vector &a, const Math::Vector &b) +{ + return (a.x-b.x)*(a.x-b.x) + + (a.y-b.y)*(a.y-b.y) + + (a.z-b.z)*(a.z-b.z); +} + //! Clamps the vector \a vec to range between \a min and \a max inline Vector Clamp(const Vector &vec, const Vector &min, const Vector &max) { @@ -285,4 +293,3 @@ inline Vector Clamp(const Vector &vec, const Vector &min, const Vector &max) } // namespace Math - From fdc1792932315c084036840c94bf779018355a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Br=C3=B6nneg=C3=A5rd?= <1162652+rasmusgo@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:02:08 +0100 Subject: [PATCH 04/37] Let space() find points on the spaceship --- src/level/robotmain.cpp | 89 ++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 68ecee4f..89e72c68 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -4101,66 +4101,55 @@ float SearchNearestObject(CObjectManager* objMan, Math::Vector center, CObject* } return min; } + +bool BlockedByObject(CObjectManager* objMan, Math::Vector center, float space, CObject* exclu) +{ + for (CObject* obj : objMan->GetAllObjects()) + { + if (!obj->GetDetectable()) continue; // inactive? + if (IsObjectBeingTransported(obj)) continue; + + if (obj == exclu) continue; + + for (const auto &crashSphere : obj->GetAllCrashSpheres()) + { + const Math::Vector oPos = crashSphere.sphere.pos; + const float oRadius = crashSphere.sphere.radius; + const float minDist = oRadius + space; + + if (Math::DistanceSquared(center, oPos) < minDist * minDist) + return true; + } + } + return false; +} } //! Calculates a free space bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadius, float space, CObject *exclu) { - if (minRadius < maxRadius) // from internal to external? + for (float radius = minRadius; radius <= maxRadius; radius += space) { - for (float radius = minRadius; radius <= maxRadius; radius += space) + float ia = space/radius; + for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia) { - float ia = space/radius; - for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia) + Math::Point p; + p.x = center.x+radius; + p.y = center.z; + p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); + Math::Vector pos; + pos.x = p.x; + pos.z = p.y; + pos.y = 0.0f; + m_terrain->AdjustToFloor(pos, true); + if (!BlockedByObject(m_objMan.get(), pos, space, exclu)) { - Math::Point p; - p.x = center.x+radius; - p.y = center.z; - p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p); - Math::Vector pos; - pos.x = p.x; - pos.z = p.y; - pos.y = 0.0f; - m_terrain->AdjustToFloor(pos, true); - float dist = SearchNearestObject(m_objMan.get(), pos, exclu); - if (dist >= space) + float flat = m_terrain->GetFlatZoneRadius(pos, space); + if (flat >= space) { - float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); - if (flat >= dist/2.0f) - { - center = pos; - return true; - } - } - } - } - } - else // from external to internal? - { - for (float radius=maxRadius; radius >= minRadius; radius -= space) - { - float ia = space/radius; - for (float angle=0.0f ; angleAdjustToFloor(pos, true); - float dist = SearchNearestObject(m_objMan.get(), pos, exclu); - if (dist >= space) - { - float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f); - if (flat >= dist/2.0f) - { - center = pos; - return true; - } + center = pos; + return true; } } } From ec425c768b59806d4cae9333b934351d185d2432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 9 Jul 2022 16:47:59 +0200 Subject: [PATCH 05/37] Use the Y floor coordinate from topo() so it doesn't ignore spaceship's modified floor height --- src/level/robotmain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index e4693680..27d09873 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -4142,7 +4142,7 @@ bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadiu pos.x = p.x; pos.z = p.y; pos.y = 0.0f; - m_terrain->AdjustToFloor(pos, true); + pos.y = m_terrain->GetFloorLevel(pos); if (!BlockedByObject(m_objMan.get(), pos, space, exclu)) { float flat = m_terrain->GetFlatZoneRadius(pos, space); From b5e27c9f1945b6ea5610e4706a426a4187cdf9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 9 Jul 2022 16:48:59 +0200 Subject: [PATCH 06/37] space() now returns a point with NaNs instead of the original position when it can't find free space --- src/level/robotmain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 27d09873..2c348e7a 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -4154,6 +4154,11 @@ bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadiu } } } + + float nan = std::nanf(""); + + center = Math::Vector{ nan, nan, nan }; + return false; } From 3c98af04b5ba53b32644db7efc755f581519e63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 13 Aug 2022 17:18:14 +0200 Subject: [PATCH 07/37] Fixed passing bool to message() --- src/CBot/CBotVar/CBotVarValue.h | 2 +- src/script/scriptfunc.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CBot/CBotVar/CBotVarValue.h b/src/CBot/CBotVar/CBotVarValue.h index c305aa2f..0cc83104 100644 --- a/src/CBot/CBotVar/CBotVarValue.h +++ b/src/CBot/CBotVar/CBotVarValue.h @@ -70,7 +70,7 @@ public: return LoadString(TX_NAN); std::ostringstream s; - s << m_val; + s << std::boolalpha << m_val; return s.str(); } diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index f36121f7..323bea85 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -2859,6 +2859,7 @@ CBotTypResult CScriptFunctions::cMessage(CBotVar* &var, void* user) { if ( var == nullptr ) return CBotTypResult(CBotErrLowParam); if ( var->GetType() != CBotTypString && + var->GetType() != CBotTypBoolean && var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); var = var->GetNext(); From 2ea94244e9b1da632b024efeb4a9bec7af1e8604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sun, 14 Aug 2022 23:47:47 +0200 Subject: [PATCH 08/37] Fixed const-correctness of getters --- src/CBot/CBotVar/CBotVar.cpp | 18 +++++++++--------- src/CBot/CBotVar/CBotVar.h | 18 +++++++++--------- src/CBot/CBotVar/CBotVarArray.cpp | 2 +- src/CBot/CBotVar/CBotVarArray.h | 2 +- src/CBot/CBotVar/CBotVarChar.h | 2 +- src/CBot/CBotVar/CBotVarClass.cpp | 2 +- src/CBot/CBotVar/CBotVarClass.h | 2 +- src/CBot/CBotVar/CBotVarInt.cpp | 2 +- src/CBot/CBotVar/CBotVarInt.h | 2 +- src/CBot/CBotVar/CBotVarPointer.cpp | 2 +- src/CBot/CBotVar/CBotVarPointer.h | 2 +- src/CBot/CBotVar/CBotVarString.h | 4 ++-- src/CBot/CBotVar/CBotVarValue.h | 16 ++++++++-------- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/CBot/CBotVar/CBotVar.cpp b/src/CBot/CBotVar/CBotVar.cpp index c975ed7b..4c268cb4 100644 --- a/src/CBot/CBotVar/CBotVar.cpp +++ b/src/CBot/CBotVar/CBotVar.cpp @@ -355,7 +355,7 @@ CBotTypResult CBotVar::GetTypResult(GetTypeMode mode) } //////////////////////////////////////////////////////////////////////////////// -CBotType CBotVar::GetType(GetTypeMode mode) +CBotType CBotVar::GetType(GetTypeMode mode) const { if ( mode == GetTypeMode::CLASS_AS_POINTER && m_type.Eq(CBotTypClass) ) return CBotTypPointer; @@ -584,43 +584,43 @@ CBotVarClass* CBotVar::GetPointer() // All these functions must be defined in the subclasses // derived from class CBotVar -signed char CBotVar::GetValByte() +signed char CBotVar::GetValByte() const { assert(0); return 0; } -short CBotVar::GetValShort() +short CBotVar::GetValShort() const { assert(0); return 0; } -uint32_t CBotVar::GetValChar() +uint32_t CBotVar::GetValChar() const { assert(0); return 0; } -int CBotVar::GetValInt() +int CBotVar::GetValInt() const { assert(0); return 0; } -long CBotVar::GetValLong() +long CBotVar::GetValLong() const { assert(0); return 0; } -float CBotVar::GetValFloat() +float CBotVar::GetValFloat() const { assert(0); return 0; } -double CBotVar::GetValDouble() +double CBotVar::GetValDouble() const { assert(0); return 0; @@ -822,7 +822,7 @@ void CBotVar::SetValString(const std::string& val) } //////////////////////////////////////////////////////////////////////////////// -std::string CBotVar::GetValString() +std::string CBotVar::GetValString() const { assert(0); return std::string(); diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index e351398d..d1d336cf 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -199,7 +199,7 @@ public: * \brief GetType Returns the base type of the variable (::CBotType) * \param mode Mode, see GetTypeMode enum */ - CBotType GetType(GetTypeMode mode = GetTypeMode::NORMAL); + CBotType GetType(GetTypeMode mode = GetTypeMode::NORMAL) const; /** * \brief Returns the complete type of the variable (CBotTypResult) @@ -508,27 +508,27 @@ public: */ virtual void SetValString(const std::string& val); - virtual signed char GetValByte(); + virtual signed char GetValByte() const; - virtual short GetValShort(); + virtual short GetValShort() const; - virtual uint32_t GetValChar(); + virtual uint32_t GetValChar() const; /** * \brief Get value as integer * \return Current value */ - virtual int GetValInt(); + virtual int GetValInt() const; - virtual long GetValLong(); + virtual long GetValLong() const; /** * \brief Get value as float * \return Current value */ - virtual float GetValFloat(); + virtual float GetValFloat() const; - virtual double GetValDouble(); + virtual double GetValDouble() const; /** * \brief Get value as string @@ -539,7 +539,7 @@ public: * * \return Current value */ - virtual std::string GetValString(); + virtual std::string GetValString() const; /** * \brief Set value for pointer types diff --git a/src/CBot/CBotVar/CBotVarArray.cpp b/src/CBot/CBotVar/CBotVarArray.cpp index b0895448..be31ddd2 100644 --- a/src/CBot/CBotVar/CBotVarArray.cpp +++ b/src/CBot/CBotVar/CBotVarArray.cpp @@ -129,7 +129,7 @@ CBotVar* CBotVarArray::GetItemList() } //////////////////////////////////////////////////////////////////////////////// -std::string CBotVarArray::GetValString() +std::string CBotVarArray::GetValString() const { if ( m_pInstance == nullptr ) return ( std::string( "Null pointer" ) ) ; return m_pInstance->GetValString(); diff --git a/src/CBot/CBotVar/CBotVarArray.h b/src/CBot/CBotVar/CBotVarArray.h index 46986900..144a5050 100644 --- a/src/CBot/CBotVar/CBotVarArray.h +++ b/src/CBot/CBotVar/CBotVarArray.h @@ -49,7 +49,7 @@ public: CBotVar* GetItem(int n, bool grow = false) override; CBotVar* GetItemList() override; - std::string GetValString() override; + std::string GetValString() const override; bool Save1State(std::ostream &ostr) override; diff --git a/src/CBot/CBotVar/CBotVarChar.h b/src/CBot/CBotVar/CBotVarChar.h index 7b6031d5..6bbfb9c1 100644 --- a/src/CBot/CBotVar/CBotVarChar.h +++ b/src/CBot/CBotVar/CBotVarChar.h @@ -32,7 +32,7 @@ class CBotVarChar : public CBotVarInteger public: CBotVarChar(const CBotToken &name) : CBotVarInteger(name) {} - std::string GetValString() override + std::string GetValString() const override { if (m_binit == CBotVar::InitType::UNDEF) return LoadString(TX_UNDEF); diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp index c7d81cb5..5f7743e9 100644 --- a/src/CBot/CBotVar/CBotVarClass.cpp +++ b/src/CBot/CBotVar/CBotVarClass.cpp @@ -291,7 +291,7 @@ CBotVar* CBotVarClass::GetItemList() } //////////////////////////////////////////////////////////////////////////////// -std::string CBotVarClass::GetValString() +std::string CBotVarClass::GetValString() const { std::string res; diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h index 254ec88b..75abca72 100644 --- a/src/CBot/CBotVar/CBotVarClass.h +++ b/src/CBot/CBotVar/CBotVarClass.h @@ -52,7 +52,7 @@ public: CBotVar* GetItemRef(int nIdent) override; CBotVar* GetItem(int n, bool bExtend) override; CBotVar* GetItemList() override; - std::string GetValString() override; + std::string GetValString() const override; bool Save1State(std::ostream &ostr) override; diff --git a/src/CBot/CBotVar/CBotVarInt.cpp b/src/CBot/CBotVar/CBotVarInt.cpp index 8a69a9f4..7e4fdc24 100644 --- a/src/CBot/CBotVar/CBotVarInt.cpp +++ b/src/CBot/CBotVar/CBotVarInt.cpp @@ -35,7 +35,7 @@ void CBotVarInt::SetValInt(int val, const std::string& defnum) m_defnum = defnum; } -std::string CBotVarInt::GetValString() +std::string CBotVarInt::GetValString() const { if (!m_defnum.empty()) return m_defnum; return CBotVarValue::GetValString(); diff --git a/src/CBot/CBotVar/CBotVarInt.h b/src/CBot/CBotVar/CBotVarInt.h index 62c4adeb..c41034d9 100644 --- a/src/CBot/CBotVar/CBotVarInt.h +++ b/src/CBot/CBotVar/CBotVarInt.h @@ -33,7 +33,7 @@ public: CBotVarInt(const CBotToken &name) : CBotVarInteger(name) {} void SetValInt(int val, const std::string& s = "") override; - std::string GetValString() override; + std::string GetValString() const override; void Copy(CBotVar* pSrc, bool bName = true) override; diff --git a/src/CBot/CBotVar/CBotVarPointer.cpp b/src/CBot/CBotVar/CBotVarPointer.cpp index ed5eda00..db979c97 100644 --- a/src/CBot/CBotVar/CBotVarPointer.cpp +++ b/src/CBot/CBotVar/CBotVarPointer.cpp @@ -90,7 +90,7 @@ CBotVar* CBotVarPointer::GetItemList() } //////////////////////////////////////////////////////////////////////////////// -std::string CBotVarPointer::GetValString() +std::string CBotVarPointer::GetValString() const { std::string s = "Pointer to "; if ( m_pVarClass == nullptr ) s = "Null pointer" ; diff --git a/src/CBot/CBotVar/CBotVarPointer.h b/src/CBot/CBotVar/CBotVarPointer.h index 4fa1d0ae..0d03ae44 100644 --- a/src/CBot/CBotVar/CBotVarPointer.h +++ b/src/CBot/CBotVar/CBotVarPointer.h @@ -47,7 +47,7 @@ public: CBotVar* GetItem(const std::string& name) override; CBotVar* GetItemRef(int nIdent) override; CBotVar* GetItemList() override; - std::string GetValString() override; + std::string GetValString() const override; void SetPointer(CBotVar* p) override; CBotVarClass* GetPointer() override; diff --git a/src/CBot/CBotVar/CBotVarString.h b/src/CBot/CBotVar/CBotVarString.h index 679c7a9a..b4ed70e4 100644 --- a/src/CBot/CBotVar/CBotVarString.h +++ b/src/CBot/CBotVar/CBotVarString.h @@ -48,12 +48,12 @@ public: SetValString(ToString(val)); } - int GetValInt() override + int GetValInt() const override { return FromString(GetValString()); } - float GetValFloat() override + float GetValFloat() const override { return FromString(GetValString()); } diff --git a/src/CBot/CBotVar/CBotVarValue.h b/src/CBot/CBotVar/CBotVarValue.h index 0cc83104..9d1e6f4a 100644 --- a/src/CBot/CBotVar/CBotVarValue.h +++ b/src/CBot/CBotVar/CBotVarValue.h @@ -62,7 +62,7 @@ public: m_binit = CBotVar::InitType::DEF; } - std::string GetValString() override + std::string GetValString() const override { if (m_binit == CBotVar::InitType::UNDEF) return LoadString(TX_UNDEF); @@ -133,37 +133,37 @@ public: this->SetValue(static_cast(val)); } - signed char GetValByte() override + signed char GetValByte() const override { return static_cast(this->m_val); } - short GetValShort() override + short GetValShort() const override { return static_cast(this->m_val); } - uint32_t GetValChar() override + uint32_t GetValChar() const override { return static_cast(this->m_val); } - int GetValInt() override + int GetValInt() const override { return static_cast(this->m_val); } - long GetValLong() override + long GetValLong() const override { return static_cast(this->m_val); } - float GetValFloat() override + float GetValFloat() const override { return static_cast(this->m_val); } - double GetValDouble() override + double GetValDouble() const override { return static_cast(this->m_val); } From 8632c7404df91077ea826fe298138e1447dae696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 15 Aug 2022 00:04:54 +0200 Subject: [PATCH 09/37] Refactored NaN implementation strfind() now returns -1 instead of NaN when substring can't be found added isnan() as an alternative way of checking if a value is NaN --- src/CBot/CBotInstr/CBotExprLitNan.cpp | 4 +-- src/CBot/CBotInstr/CBotExpression.cpp | 6 ---- src/CBot/CBotInstr/CBotParExpr.cpp | 4 +-- src/CBot/CBotInstr/CBotPostIncExpr.cpp | 5 ---- src/CBot/CBotInstr/CBotPreIncExpr.cpp | 6 ---- src/CBot/CBotInstr/CBotTwoOpExpr.cpp | 12 ++++++-- src/CBot/CBotVar/CBotVar.h | 7 ----- src/CBot/CBotVar/CBotVarChar.h | 2 -- src/CBot/CBotVar/CBotVarValue.h | 2 -- src/CBot/stdlib/FileFunctions.cpp | 4 +-- src/CBot/stdlib/MathFunctions.cpp | 32 +++++++++++++++++++++ src/CBot/stdlib/StringFunctions.cpp | 2 +- src/script/cbottoken.cpp | 5 +++- src/script/scriptfunc.cpp | 40 +++++++++++++++++--------- 14 files changed, 78 insertions(+), 53 deletions(-) diff --git a/src/CBot/CBotInstr/CBotExprLitNan.cpp b/src/CBot/CBotInstr/CBotExprLitNan.cpp index 52e30d5f..60f73e8e 100644 --- a/src/CBot/CBotInstr/CBotExprLitNan.cpp +++ b/src/CBot/CBotInstr/CBotExprLitNan.cpp @@ -41,9 +41,9 @@ bool CBotExprLitNan::Execute(CBotStack* &pj) CBotStack* pile = pj->AddStack(this); if (pile->IfStep()) return false; - CBotVar* var = CBotVar::Create("", CBotTypInt); + CBotVar* var = CBotVar::Create("", CBotTypFloat); - var->SetInit(CBotVar::InitType::IS_NAN); // nan + var->SetValFloat(std::nanf("")); pile->SetVar(var); // put on the stack return pj->Return(pile); // forward below } diff --git a/src/CBot/CBotInstr/CBotExpression.cpp b/src/CBot/CBotInstr/CBotExpression.cpp index 2374a2a6..8a9e91de 100644 --- a/src/CBot/CBotInstr/CBotExpression.cpp +++ b/src/CBot/CBotInstr/CBotExpression.cpp @@ -206,12 +206,6 @@ bool CBotExpression::Execute(CBotStack* &pj) if (m_token.GetType() != ID_ASS) { pVar = pile1->GetVar(); // recovers if interrupted - initKind = pVar->GetInit(); - if (initKind == CBotVar::InitType::IS_NAN) - { - pile2->SetError(CBotErrNan, m_leftop->GetToken()); - return pj->Return(pile2); - } result = CBotVar::Create("", pVar->GetTypResult(CBotVar::GetTypeMode::CLASS_AS_INTRINSIC)); } diff --git a/src/CBot/CBotInstr/CBotParExpr.cpp b/src/CBot/CBotInstr/CBotParExpr.cpp index 46f72818..fe33c82d 100644 --- a/src/CBot/CBotInstr/CBotParExpr.cpp +++ b/src/CBot/CBotInstr/CBotParExpr.cpp @@ -217,8 +217,8 @@ CBotInstr* CBotParExpr::CompileLitExpr(CBotToken* &p, CBotCStack* pStack) { CBotInstr* inst = new CBotExprLitNan(); inst->SetToken(pp); - CBotVar* var = CBotVar::Create("", CBotTypInt); - var->SetInit(CBotVar::InitType::IS_NAN); + CBotVar* var = CBotVar::Create("", CBotTypFloat); + var->SetValFloat(std::nanf("")); pStk->SetVar(var); return pStack->Return(inst, pStk); } diff --git a/src/CBot/CBotInstr/CBotPostIncExpr.cpp b/src/CBot/CBotInstr/CBotPostIncExpr.cpp index fac31e2c..5ce6284d 100644 --- a/src/CBot/CBotInstr/CBotPostIncExpr.cpp +++ b/src/CBot/CBotInstr/CBotPostIncExpr.cpp @@ -56,11 +56,6 @@ bool CBotPostIncExpr::Execute(CBotStack* &pj) CBotStack* pile3 = pile2->AddStack(this); if (pile3->IfStep()) return false; - if (var1->IsNAN()) - { - pile1->SetError(CBotErrNan, &m_token); - } - if (!var1->IsDefined()) { pile1->SetError(CBotErrNotInit, &m_token); diff --git a/src/CBot/CBotInstr/CBotPreIncExpr.cpp b/src/CBot/CBotInstr/CBotPreIncExpr.cpp index afb2b65c..6416215b 100644 --- a/src/CBot/CBotInstr/CBotPreIncExpr.cpp +++ b/src/CBot/CBotInstr/CBotPreIncExpr.cpp @@ -55,12 +55,6 @@ bool CBotPreIncExpr::Execute(CBotStack* &pj) // pile2 is modified on return if (!(static_cast(m_instr))->ExecuteVar(var1, pile2, nullptr, true)) return false; - if (var1->IsNAN()) - { - pile->SetError(CBotErrNan, &m_token); - return pj->Return(pile); // operation performed - } - if (!var1->IsDefined()) { pile->SetError(CBotErrNotInit, &m_token); diff --git a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp index ad09f221..52b78372 100644 --- a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp @@ -305,7 +305,13 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera static bool VarIsNAN(const CBotVar* var) { - return var->GetInit() > CBotVar::InitType::DEF; + if (var->GetType() == CBotTypFloat) + return std::isnan(var->GetValFloat()); + + if (var->GetType() == CBotTypDouble) + return std::isnan(var->GetValDouble()); + + return false; } static bool IsNan(CBotVar* left, CBotVar* right, CBotError* err = nullptr) @@ -475,13 +481,13 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack) break; case ID_EQ: if ( IsNan(left, right) ) - result->SetValInt(left->GetInit() == right->GetInit()) ; + result->SetValInt(VarIsNAN(left) == VarIsNAN(right)); else result->SetValInt(temp->Eq(left , right)); // equal break; case ID_NE: if ( IsNan(left, right) ) - result->SetValInt(left ->GetInit() != right->GetInit()) ; + result->SetValInt(VarIsNAN(left) != VarIsNAN(right)); else result->SetValInt(temp->Ne(left , right)); // different break; diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index d1d336cf..c9739e3f 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -243,7 +243,6 @@ public: UNDEF = 0, //!< the variable value is currently not defined DEF = 1, //!< the variable value is defined IS_POINTER = 2, //!< the variable value is as a pointer - IS_NAN = 999 //!< the variable value is NAN }; /** @@ -269,12 +268,6 @@ public: */ bool IsDefined() const { return GetInit() == InitType::DEF; } - /** - * \brief Checks if the variable is currently NAN - * \return InitType::NAN - */ - bool IsNAN() const { return GetInit() == InitType::IS_NAN; } - //@} //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/CBot/CBotVar/CBotVarChar.h b/src/CBot/CBotVar/CBotVarChar.h index 6bbfb9c1..168604f6 100644 --- a/src/CBot/CBotVar/CBotVarChar.h +++ b/src/CBot/CBotVar/CBotVarChar.h @@ -36,8 +36,6 @@ public: { if (m_binit == CBotVar::InitType::UNDEF) return LoadString(TX_UNDEF); - if (m_binit == CBotVar::InitType::IS_NAN) - return LoadString(TX_NAN); if (0x10FFFF < m_val || (0xD7FF < m_val && m_val < 0xE000)) return "\xEF\xBF\xBD"; // replacement character U+FFFD diff --git a/src/CBot/CBotVar/CBotVarValue.h b/src/CBot/CBotVar/CBotVarValue.h index 9d1e6f4a..fddb6bfe 100644 --- a/src/CBot/CBotVar/CBotVarValue.h +++ b/src/CBot/CBotVar/CBotVarValue.h @@ -66,8 +66,6 @@ public: { if (m_binit == CBotVar::InitType::UNDEF) return LoadString(TX_UNDEF); - if (m_binit == CBotVar::InitType::IS_NAN) - return LoadString(TX_NAN); std::ostringstream s; s << std::boolalpha << m_val; diff --git a/src/CBot/stdlib/FileFunctions.cpp b/src/CBot/stdlib/FileFunctions.cpp index 04e54ac1..bb48268d 100644 --- a/src/CBot/stdlib/FileFunctions.cpp +++ b/src/CBot/stdlib/FileFunctions.cpp @@ -133,7 +133,7 @@ bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception if (!pVar->IsDefined()) return true; // file not opened g_files.erase(pVar->GetValInt()); - pVar->SetInit(CBotVar::InitType::IS_NAN); + pVar->SetInit(CBotVar::InitType::UNDEF); return true; } @@ -203,7 +203,7 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, v g_files.erase(handleIter); - pVar->SetInit(CBotVar::InitType::IS_NAN); + pVar->SetInit(CBotVar::InitType::UNDEF); return true; } diff --git a/src/CBot/stdlib/MathFunctions.cpp b/src/CBot/stdlib/MathFunctions.cpp index 5353f80d..105f805a 100644 --- a/src/CBot/stdlib/MathFunctions.cpp +++ b/src/CBot/stdlib/MathFunctions.cpp @@ -218,6 +218,37 @@ bool rTrunc(CBotVar* var, CBotVar* result, int& exception, void* user) return true; } +// Instruction "isnan()" + +CBotTypResult cIsNAN(CBotVar*& var, void* user) +{ + if (var == nullptr) return CBotTypResult(CBotErrLowParam); + + if (var->GetType() > CBotTypDouble) return CBotTypResult(CBotErrBadNum); + + var = var->GetNext(); + if (var != nullptr) return CBotTypResult(CBotErrOverParam); + + return CBotTypResult(CBotTypBoolean); +} + +bool rIsNAN(CBotVar* var, CBotVar* result, int& exception, void* user) +{ + bool isnan = false; + + if (var->GetType() == CBotTypFloat) + { + if (std::isnan(var->GetValFloat())) isnan = true; + } + else if (var->GetType() == CBotTypDouble) + { + if (std::isnan(var->GetValDouble())) isnan = true; + } + + result->SetValInt(isnan); + return true; +} + } // namespace void InitMathFunctions() @@ -237,6 +268,7 @@ void InitMathFunctions() CBotProgram::AddFunction("ceil", rCeil, cOneFloat); CBotProgram::AddFunction("round", rRound, cOneFloat); CBotProgram::AddFunction("trunc", rTrunc, cOneFloat); + CBotProgram::AddFunction("isnan", rIsNAN, cIsNAN); } } // namespace CBot diff --git a/src/CBot/stdlib/StringFunctions.cpp b/src/CBot/stdlib/StringFunctions.cpp index c543df7f..a9d61b81 100644 --- a/src/CBot/stdlib/StringFunctions.cpp +++ b/src/CBot/stdlib/StringFunctions.cpp @@ -233,7 +233,7 @@ bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) } else { - pResult->SetInit(CBotVar::InitType::IS_NAN); + pResult->SetValInt(-1); } return true; } diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp index 911b985d..d14a7068 100644 --- a/src/script/cbottoken.cpp +++ b/src/script/cbottoken.cpp @@ -301,6 +301,7 @@ std::string GetHelpFilename(const char *token) if ( strcmp(token, "ceil" ) == 0 ) helpfile = "cbot/ceil"; if ( strcmp(token, "round" ) == 0 ) helpfile = "cbot/round"; if ( strcmp(token, "trunc" ) == 0 ) helpfile = "cbot/trunc"; + if ( strcmp(token, "isnan" ) == 0 ) helpfile = "cbot/isnan"; if ( strcmp(token, "retobject" ) == 0 ) helpfile = "cbot/retobj"; if ( strcmp(token, "errmode" ) == 0 ) helpfile = "cbot/errmode"; if ( strcmp(token, "isbusy" ) == 0 ) helpfile = "cbot/isbusy"; @@ -463,9 +464,10 @@ bool IsFunction(const char *token) if ( strcmp(token, "ceil" ) == 0 ) return true; if ( strcmp(token, "round" ) == 0 ) return true; if ( strcmp(token, "trunc" ) == 0 ) return true; + if ( strcmp(token, "isnan" ) == 0 ) return true; if ( strcmp(token, "retobjectbyid") == 0 ) return true; if ( strcmp(token, "retobject" ) == 0 ) return true; - if ( strcmp(token, "isbusy" ) == 0 ) return true; + if ( strcmp(token, "isbusy" ) == 0 ) return true; if ( strcmp(token, "factory" ) == 0 ) return true; if ( strcmp(token, "research" ) == 0 ) return true; if ( strcmp(token, "takeoff" ) == 0 ) return true; @@ -571,6 +573,7 @@ const char* GetHelpText(const char *token) if ( strcmp(token, "ceil" ) == 0 ) return "ceil ( value );"; if ( strcmp(token, "round" ) == 0 ) return "round ( value );"; if ( strcmp(token, "trunc" ) == 0 ) return "trunc ( value );"; + if ( strcmp(token, "isnan" ) == 0 ) return "isnan ( value );"; if ( strcmp(token, "retobject" ) == 0 ) return "retobject ( rank );"; if ( strcmp(token, "retobjectbyid") == 0 ) return "retobjectbyid ( rank );"; if ( strcmp(token, "progfunc" ) == 0 ) return "progfunc ( funcname );"; diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index 323bea85..bd782618 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -1836,18 +1836,30 @@ bool CScriptFunctions::rSpace(CBotVar* var, CBotVar* result, int& exception, voi } } } - script->m_main->FreeSpace(center, rMin, rMax, dist, pThis); + + bool success = script->m_main->FreeSpace(center, rMin, rMax, dist, pThis); if ( result != nullptr ) { pSub = result->GetItemList(); if ( pSub != nullptr ) { - pSub->SetValFloat(center.x/g_unit); - pSub = pSub->GetNext(); // "y" - pSub->SetValFloat(center.z/g_unit); - pSub = pSub->GetNext(); // "z" - pSub->SetValFloat(center.y/g_unit); + if (success) + { + pSub->SetValFloat(center.x / g_unit); + pSub = pSub->GetNext(); // "y" + pSub->SetValFloat(center.z / g_unit); + pSub = pSub->GetNext(); // "z" + pSub->SetValFloat(center.y / g_unit); + } + else + { + pSub->SetValFloat(center.x); + pSub = pSub->GetNext(); // "y" + pSub->SetValFloat(center.y); + pSub = pSub->GetNext(); // "z" + pSub->SetValFloat(center.z); + } } } return true; @@ -2313,7 +2325,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v if ( err != ERR_OK ) { script->m_taskExecutor->StopForegroundTask(); - result->SetInit(CBotVar::InitType::IS_NAN); + result->SetValFloat(std::nanf("")); return true; } @@ -2324,7 +2336,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v if ( script->m_returnValue == boost::none ) { - result->SetInit(CBotVar::InitType::IS_NAN); + result->SetValFloat(std::nanf("")); } else { @@ -3645,11 +3657,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user) if (IsObjectBeingTransported(object)) { pSub = pVar->GetItemList(); // "x" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); pSub = pSub->GetNext(); // "y" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); pSub = pSub->GetNext(); // "z" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); } else { @@ -3750,11 +3762,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user) if (IsObjectBeingTransported(object) || physics == nullptr) { pSub = pVar->GetItemList(); // "x" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); pSub = pSub->GetNext(); // "y" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); pSub = pSub->GetNext(); // "z" - pSub->SetInit(CBotVar::InitType::IS_NAN); + pSub->SetValFloat(std::nanf("")); } else { From a74adb5f59d2a94646f087d0af4ba08d6d154475 Mon Sep 17 00:00:00 2001 From: Krzysztof Rewak Date: Wed, 24 Aug 2022 20:25:25 +0200 Subject: [PATCH 10/37] Missing PL translation (#1512) * missing PL translation * update po.pl --- po/pl.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/pl.po b/po/pl.po index 90e9f65f..8bad637b 100644 --- a/po/pl.po +++ b/po/pl.po @@ -86,7 +86,7 @@ msgid "Access to solution\\Shows the solution (detailed instructions for mission msgstr "Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje dotyczące misji)" msgid "Access to solutions\\Show program \"4: Solution\" in the exercises" -msgstr "Accčs aux solutions\\Programme \"4: Solution\" dans les exercices" +msgstr "Dostęp do rozwiązań\\Pokaż program \"4: Rozwiązanie\" w ćwiczeniach" msgid "Add new program" msgstr "Dodaj nowy program" From 438e4bba62a511ed7ad178a404c5698a129453da Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Tue, 13 Sep 2022 19:58:11 +0200 Subject: [PATCH 11/37] First attempt to run MacOS build on Github Actions --- .github/workflows/build.yml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0792ccf..2fc5861e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,6 +76,46 @@ jobs: name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }}) path: build/gtestresults.xml if: matrix.target_os == 'linux' + build-macos: + runs-on: ${{ matrix.host_os }} + container: ${{ matrix.container }} + strategy: + matrix: + target_os: [macos] + host_os: [macos-11, macos-12] + container: [''] + fail-fast: false + steps: + - name: Install Colobot dependencies + run: brew install cmake sdl2 sdl2_image sdl2_ttf boost glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet + if: matrix.container == '' + - uses: actions/checkout@v2 + - name: Checkout the Google Test submodule + run: git submodule update --init -- lib/googletest + - name: Create build directory + run: cmake -E make_directory build + - name: Run CMake (for Mac) + working-directory: build + run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. + if: matrix.target_os == 'macos' + - name: Build + working-directory: build + run: make -j `nproc` + - name: Install + working-directory: build + run: DESTDIR=. make package + - name: Upload build + uses: actions/upload-artifact@v2 + with: + name: ${{matrix.target_os}}-debug + path: build/install + if: matrix.host_os == 'macos-11' + - name: Upload test results + uses: actions/upload-artifact@v2 + with: + name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }}) + path: build/gtestresults.xml + if: matrix.target_os == 'macos' build-windows: runs-on: windows-2019 strategy: From 2a91d6bf358fb4a3fd703c60bf1fe477fc3f78c3 Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Tue, 13 Sep 2022 20:14:47 +0200 Subject: [PATCH 12/37] Temporarily remove tests --- .github/workflows/build.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fc5861e..7dc469fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: run: cmake -E make_directory build - name: Run CMake (for Mac) working-directory: build - run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. + run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. if: matrix.target_os == 'macos' - name: Build working-directory: build @@ -110,12 +110,6 @@ jobs: name: ${{matrix.target_os}}-debug path: build/install if: matrix.host_os == 'macos-11' - - name: Upload test results - uses: actions/upload-artifact@v2 - with: - name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }}) - path: build/gtestresults.xml - if: matrix.target_os == 'macos' build-windows: runs-on: windows-2019 strategy: From 0693aa5e1e234338565afeb1afefe90fdc0a927f Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Tue, 13 Sep 2022 20:45:07 +0200 Subject: [PATCH 13/37] Fix OpenAL library path --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7dc469fd..57d4eead 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: run: cmake -E make_directory build - name: Run CMake (for Mac) working-directory: build - run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. + run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. if: matrix.target_os == 'macos' - name: Build working-directory: build From afbf687255f82c61db303dc959dadcc473289fdb Mon Sep 17 00:00:00 2001 From: tomangelo Date: Tue, 13 Sep 2022 21:03:14 +0200 Subject: [PATCH 14/37] Try to fix packaging --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57d4eead..c06bb7fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,7 +103,7 @@ jobs: run: make -j `nproc` - name: Install working-directory: build - run: DESTDIR=. make package + run: DESTDIR=. sudo make package - name: Upload build uses: actions/upload-artifact@v2 with: From 87ad81f891cc06b27a0be1e95b2dbdc05cfa400b Mon Sep 17 00:00:00 2001 From: tomangelo Date: Tue, 13 Sep 2022 21:21:49 +0200 Subject: [PATCH 15/37] Don't try to make package for now --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c06bb7fb..40c0f955 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,9 +101,6 @@ jobs: - name: Build working-directory: build run: make -j `nproc` - - name: Install - working-directory: build - run: DESTDIR=. sudo make package - name: Upload build uses: actions/upload-artifact@v2 with: From 4ec0083cd84016dab8b3bf38867d20353d7f4ceb Mon Sep 17 00:00:00 2001 From: tomangelo Date: Tue, 13 Sep 2022 21:48:43 +0200 Subject: [PATCH 16/37] Try to move binary to separate directory --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40c0f955..9fa57298 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,6 +101,9 @@ jobs: - name: Build working-directory: build run: make -j `nproc` + - name: Install + working-directory: build + run: make -j `nproc` install - name: Upload build uses: actions/upload-artifact@v2 with: From 4c767953ea4e16f049a68449ff2151a05db82f4e Mon Sep 17 00:00:00 2001 From: tomangelo Date: Tue, 13 Sep 2022 21:58:35 +0200 Subject: [PATCH 17/37] Fix path --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9fa57298..58e27161 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: run: cmake -E make_directory build - name: Run CMake (for Mac) working-directory: build - run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. + run: cmake -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. if: matrix.target_os == 'macos' - name: Build working-directory: build From 6cc58b872fc1f06e71357a469cbc7da2ad4b1b03 Mon Sep 17 00:00:00 2001 From: tomangelo Date: Wed, 14 Sep 2022 23:25:16 +0200 Subject: [PATCH 18/37] Let's try to get tests instead Making .dmg package needs `data` directory, while `make install` does weird stuff with path, for now I'll skip that. --- .github/workflows/build.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 58e27161..9f8ce4fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,15 +101,17 @@ jobs: - name: Build working-directory: build run: make -j `nproc` - - name: Install + - name: Run tests + # TODO: Maybe run Windows tests using wine as well? working-directory: build - run: make -j `nproc` install - - name: Upload build + run: ./colobot_ut --gtest_output=xml:gtestresults.xml + if: matrix.target_os == 'macos' + - name: Upload test results uses: actions/upload-artifact@v2 with: - name: ${{matrix.target_os}}-debug - path: build/install - if: matrix.host_os == 'macos-11' + name: Test results (${{ matrix.target_os }}, ${{ matrix.host_os }}) + path: build/gtestresults.xml + if: matrix.target_os == 'macos' build-windows: runs-on: windows-2019 strategy: From 708d3cfd46f8c11531e6d2db4e2350ef1811a940 Mon Sep 17 00:00:00 2001 From: tomangelo Date: Wed, 14 Sep 2022 23:58:42 +0200 Subject: [PATCH 19/37] Enable building tests Making .dmg package needs `data` directory, while `make install` does weird stuff with path, for now I'll skip that. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f8ce4fd..f75106c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,7 @@ jobs: run: cmake -E make_directory build - name: Run CMake (for Mac) working-directory: build - run: cmake -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. + run: cmake -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTESTS=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd .. if: matrix.target_os == 'macos' - name: Build working-directory: build From c0669a591b69fc69ada423b2d787249f5625f649 Mon Sep 17 00:00:00 2001 From: tomangelo Date: Thu, 15 Sep 2022 00:12:54 +0200 Subject: [PATCH 20/37] Update INSTALL-MacOSX.md --- INSTALL-MacOSX.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL-MacOSX.md b/INSTALL-MacOSX.md index 85cc5f28..6d392f19 100644 --- a/INSTALL-MacOSX.md +++ b/INSTALL-MacOSX.md @@ -20,7 +20,7 @@ If you've installed everything correctly, the simple way of compiling Colobot wi git clone --recursive https://github.com/colobot/colobot.git mkdir colobot/build cd colobot/build - cmake ../ + cmake -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd ../ make ``` From 789c8b22920dc4292c463e910ebac3393992bb3d Mon Sep 17 00:00:00 2001 From: tomangelo2 Date: Thu, 15 Sep 2022 01:14:29 +0200 Subject: [PATCH 21/37] Fix compilation with gcc --- src/CBot/CBotInstr/CBotExprLitNan.cpp | 4 +++- src/CBot/CBotInstr/CBotParExpr.cpp | 4 +++- src/CBot/CBotInstr/CBotTwoOpExpr.cpp | 1 + src/level/robotmain.cpp | 3 ++- src/math/half.cpp | 2 +- src/script/scriptfunc.cpp | 18 ++++++++++-------- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/CBot/CBotInstr/CBotExprLitNan.cpp b/src/CBot/CBotInstr/CBotExprLitNan.cpp index 60f73e8e..9ae23150 100644 --- a/src/CBot/CBotInstr/CBotExprLitNan.cpp +++ b/src/CBot/CBotInstr/CBotExprLitNan.cpp @@ -23,6 +23,8 @@ #include "CBot/CBotVar/CBotVar.h" +#include + namespace CBot { @@ -43,7 +45,7 @@ bool CBotExprLitNan::Execute(CBotStack* &pj) if (pile->IfStep()) return false; CBotVar* var = CBotVar::Create("", CBotTypFloat); - var->SetValFloat(std::nanf("")); + var->SetValFloat(nanf("")); pile->SetVar(var); // put on the stack return pj->Return(pile); // forward below } diff --git a/src/CBot/CBotInstr/CBotParExpr.cpp b/src/CBot/CBotInstr/CBotParExpr.cpp index fe33c82d..4986560b 100644 --- a/src/CBot/CBotInstr/CBotParExpr.cpp +++ b/src/CBot/CBotInstr/CBotParExpr.cpp @@ -38,6 +38,8 @@ #include "CBot/CBotCStack.h" +#include + namespace CBot { @@ -218,7 +220,7 @@ CBotInstr* CBotParExpr::CompileLitExpr(CBotToken* &p, CBotCStack* pStack) CBotInstr* inst = new CBotExprLitNan(); inst->SetToken(pp); CBotVar* var = CBotVar::Create("", CBotTypFloat); - var->SetValFloat(std::nanf("")); + var->SetValFloat(nanf("")); pStk->SetVar(var); return pStack->Return(inst, pStk); } diff --git a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp index 52b78372..9072a48e 100644 --- a/src/CBot/CBotInstr/CBotTwoOpExpr.cpp +++ b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp @@ -31,6 +31,7 @@ #include "CBot/CBotVar/CBotVar.h" #include +#include #include namespace CBot diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 2c348e7a..e2ddc726 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -112,6 +112,7 @@ #include #include #include +#include #include #include @@ -4155,7 +4156,7 @@ bool CRobotMain::FreeSpace(Math::Vector ¢er, float minRadius, float maxRadiu } } - float nan = std::nanf(""); + float nan = nanf(""); center = Math::Vector{ nan, nan, nan }; diff --git a/src/math/half.cpp b/src/math/half.cpp index a205c736..be847c81 100644 --- a/src/math/half.cpp +++ b/src/math/half.cpp @@ -100,7 +100,7 @@ float HaltToFloat(uint16_t value) // NaN else if ((exponent == 31) && (mantissa != 0)) { - result = std::nanf(""); + result = nanf(""); } // Normal number else diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index bd782618..e9cd4d40 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -67,6 +67,8 @@ #include "ui/displaytext.h" +#include + using namespace CBot; 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 ) { script->m_taskExecutor->StopForegroundTask(); - result->SetValFloat(std::nanf("")); + result->SetValFloat(nanf("")); return true; } @@ -2336,7 +2338,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v if ( script->m_returnValue == boost::none ) { - result->SetValFloat(std::nanf("")); + result->SetValFloat(nanf("")); } else { @@ -3657,11 +3659,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user) if (IsObjectBeingTransported(object)) { pSub = pVar->GetItemList(); // "x" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); pSub = pSub->GetNext(); // "y" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); pSub = pSub->GetNext(); // "z" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); } else { @@ -3762,11 +3764,11 @@ void CScriptFunctions::uObject(CBotVar* botThis, void* user) if (IsObjectBeingTransported(object) || physics == nullptr) { pSub = pVar->GetItemList(); // "x" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); pSub = pSub->GetNext(); // "y" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); pSub = pSub->GetNext(); // "z" - pSub->SetValFloat(std::nanf("")); + pSub->SetValFloat(nanf("")); } else { From b7cb26822b928cb31e12b3b5178b6a7d21eefe31 Mon Sep 17 00:00:00 2001 From: Emxx52 Date: Sun, 6 Nov 2022 04:12:02 +0100 Subject: [PATCH 22/37] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c501750..002ca535 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,7 +134,7 @@ jobs: - name: Install Colobot dependencies uses: lukka/run-vcpkg@v7 with: - vcpkgGitCommitId: 'e809a42f87565e803b2178a0c11263f462d1800a' + vcpkgGitCommitId: '68ad399d5596a540e8a12173c3d189cbc0f82be8' vcpkgTriplet: ${{ matrix.vcpkg_triplet }} vcpkgArguments: 'boost-system boost-filesystem boost-regex boost-lexical-cast boost-bimap boost-algorithm boost-property-tree boost-optional boost-range sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs mpg123' # SHA-256 hash of the list of packages above, for caching purposes From 21b6572b5b146577687c9dc109507d7614c433fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 26 Nov 2022 17:36:11 +0100 Subject: [PATCH 23/37] Fix for SDL on Windows --- CMakeLists.txt | 13 ++++++++++--- src/CMakeLists.txt | 24 ++++++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68b4d827..68d707ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,13 +309,20 @@ include("${colobot_SOURCE_DIR}/cmake/colobot-lint.cmake") ## find_package(OpenGL 1.4 REQUIRED) -find_package(SDL2 REQUIRED) -find_package(SDL2_image REQUIRED) -find_package(SDL2_ttf REQUIRED) find_package(PNG 1.2 REQUIRED) find_package(Gettext REQUIRED) find_package(PhysFS REQUIRED) +if(PLATFORM_WINDOWS) + find_package(SDL2 CONFIG REQUIRED) + find_package(SDL2_image CONFIG REQUIRED) + find_package(SDL2_ttf CONFIG REQUIRED) +else() + find_package(SDL2 REQUIRED) + find_package(SDL2_image REQUIRED) + find_package(SDL2_ttf REQUIRED) +endif() + set(Boost_USE_STATIC_LIBS ${BOOST_STATIC}) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME ${USE_STATIC_RUNTIME}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10def122..27819d46 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -480,9 +480,6 @@ target_include_directories(colobotbase PUBLIC target_link_libraries(colobotbase PUBLIC CBot localename - SDL2::Core - SDL2::Image - SDL2::TTF OpenGL::GL PNG::PNG GLEW::GLEW @@ -507,6 +504,20 @@ if(mp3lame_FOUND) ) endif() +if(PLATFORM_WINDOWS) + target_link_libraries(colobotbase PUBLIC + $,SDL2::SDL2,SDL2::SDL2-static> + $,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static> + $,SDL2_ttf::SDL2_ttf,SDL2_ttf::SDL2_ttf-static> + ) +elseif() + target_link_libraries(colobotbase PUBLIC + SDL2::Core + SDL2::Image + SDL2::TTF + ) +endif() + # Optional libraries if(OPENAL_SOUND) target_sources(colobotbase PRIVATE @@ -601,7 +612,12 @@ endif() if(PLATFORM_WINDOWS) target_sources(colobot PRIVATE ../desktop/colobot.rc) endif() -target_link_libraries(colobot colobotbase SDL2::Main) + +if(PLATFORM_WINDOWS) + target_link_libraries(colobot colobotbase SDL2::SDL2main) +elseif() + target_link_libraries(colobot colobotbase SDL2::Main) +endif() # Install install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) From 1d8e06c7ba94e65915f80329406596b477cb5bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 26 Nov 2022 20:00:44 +0100 Subject: [PATCH 24/37] Revert "Fix for SDL on Windows" This reverts commit 21b6572b5b146577687c9dc109507d7614c433fb. --- CMakeLists.txt | 13 +++---------- src/CMakeLists.txt | 24 ++++-------------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68d707ae..68b4d827 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -309,20 +309,13 @@ include("${colobot_SOURCE_DIR}/cmake/colobot-lint.cmake") ## find_package(OpenGL 1.4 REQUIRED) +find_package(SDL2 REQUIRED) +find_package(SDL2_image REQUIRED) +find_package(SDL2_ttf REQUIRED) find_package(PNG 1.2 REQUIRED) find_package(Gettext REQUIRED) find_package(PhysFS REQUIRED) -if(PLATFORM_WINDOWS) - find_package(SDL2 CONFIG REQUIRED) - find_package(SDL2_image CONFIG REQUIRED) - find_package(SDL2_ttf CONFIG REQUIRED) -else() - find_package(SDL2 REQUIRED) - find_package(SDL2_image REQUIRED) - find_package(SDL2_ttf REQUIRED) -endif() - set(Boost_USE_STATIC_LIBS ${BOOST_STATIC}) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME ${USE_STATIC_RUNTIME}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27819d46..10def122 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -480,6 +480,9 @@ target_include_directories(colobotbase PUBLIC target_link_libraries(colobotbase PUBLIC CBot localename + SDL2::Core + SDL2::Image + SDL2::TTF OpenGL::GL PNG::PNG GLEW::GLEW @@ -504,20 +507,6 @@ if(mp3lame_FOUND) ) endif() -if(PLATFORM_WINDOWS) - target_link_libraries(colobotbase PUBLIC - $,SDL2::SDL2,SDL2::SDL2-static> - $,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static> - $,SDL2_ttf::SDL2_ttf,SDL2_ttf::SDL2_ttf-static> - ) -elseif() - target_link_libraries(colobotbase PUBLIC - SDL2::Core - SDL2::Image - SDL2::TTF - ) -endif() - # Optional libraries if(OPENAL_SOUND) target_sources(colobotbase PRIVATE @@ -612,12 +601,7 @@ endif() if(PLATFORM_WINDOWS) target_sources(colobot PRIVATE ../desktop/colobot.rc) endif() - -if(PLATFORM_WINDOWS) - target_link_libraries(colobot colobotbase SDL2::SDL2main) -elseif() - target_link_libraries(colobot colobotbase SDL2::Main) -endif() +target_link_libraries(colobot colobotbase SDL2::Main) # Install install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR}) From 436c316a4ac2d451034d2d7a28349ebf4ce1cfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 26 Nov 2022 20:04:44 +0100 Subject: [PATCH 25/37] Updated SDL2 and SDL2_image library names --- cmake/FindSDL2.cmake | 4 ++-- cmake/FindSDL2_image.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake index 2445d36e..2f2388d0 100644 --- a/cmake/FindSDL2.cmake +++ b/cmake/FindSDL2.cmake @@ -186,7 +186,7 @@ endif() # SDL-2.0 is the name used by FreeBSD ports... # don't confuse it for the version number. find_library(SDL2_LIBRARY - NAMES SDL2 SDL-2.0 + NAMES SDL2 SDL-2.0 SDL2-static HINTS ENV SDL2DIR ${SDL2_NO_DEFAULT_PATH_CMD} @@ -223,7 +223,7 @@ if(NOT SDL2_BUILDING_LIBRARY) HINTS ENV SDL2DIR ${SDL2_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATH_SUFFIXES lib lib/manual-link ${VC_LIB_PATH_SUFFIX} PATHS ${SDL2MAIN_LIBRARY_PATHS} DOC "Where the SDL2main library can be found" ) diff --git a/cmake/FindSDL2_image.cmake b/cmake/FindSDL2_image.cmake index 624e9154..f056f4bb 100644 --- a/cmake/FindSDL2_image.cmake +++ b/cmake/FindSDL2_image.cmake @@ -166,7 +166,7 @@ endif() # Search for the SDL2_image library find_library(SDL2_IMAGE_LIBRARY - NAMES SDL2_image + NAMES SDL2_image SDL2_image-static HINTS ENV SDL2IMAGEDIR ENV SDL2DIR From d47e26586325ec11425cef5c95fc206dc103dbe2 Mon Sep 17 00:00:00 2001 From: suve Date: Thu, 19 Jan 2023 10:34:55 +0100 Subject: [PATCH 26/37] Add missing includes Some parts of the code used the fixed-size type uint32_t, which is defined in stdint.h / cstdint - without including said header file. With GCC13, the inter-header dependencies seem to have changed and the file is no longer included transitively, requiring an explicit include. --- src/CBot/CBotFileUtils.h | 1 + src/CBot/CBotInstr/CBotExprLitChar.h | 2 ++ src/CBot/CBotStack.cpp | 1 + src/CBot/CBotVar/CBotVar.h | 1 + src/object/task/taskgoto.h | 1 + 5 files changed, 6 insertions(+) diff --git a/src/CBot/CBotFileUtils.h b/src/CBot/CBotFileUtils.h index dccefc78..757f31a1 100644 --- a/src/CBot/CBotFileUtils.h +++ b/src/CBot/CBotFileUtils.h @@ -19,6 +19,7 @@ #pragma once +#include #include #include diff --git a/src/CBot/CBotInstr/CBotExprLitChar.h b/src/CBot/CBotInstr/CBotExprLitChar.h index ab04cd3d..cca338f8 100644 --- a/src/CBot/CBotInstr/CBotExprLitChar.h +++ b/src/CBot/CBotInstr/CBotExprLitChar.h @@ -21,6 +21,8 @@ #include "CBot/CBotInstr/CBotInstr.h" +#include + namespace CBot { diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 3a73d373..0d63ea90 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -30,6 +30,7 @@ #include "CBot/CBotExternalCall.h" #include +#include #include #include diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index c9739e3f..3cb628e9 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -24,6 +24,7 @@ #include "CBot/CBotEnums.h" #include "CBot/CBotUtils.h" +#include #include namespace CBot diff --git a/src/object/task/taskgoto.h b/src/object/task/taskgoto.h index e502c7c8..57a3cb6f 100644 --- a/src/object/task/taskgoto.h +++ b/src/object/task/taskgoto.h @@ -24,6 +24,7 @@ #include "math/vector.h" #include +#include #include #include From 0618174b2b3ec0dd781a400ec0986926874a23e4 Mon Sep 17 00:00:00 2001 From: lolbot-iichan Date: Sun, 5 Feb 2023 16:34:55 +0300 Subject: [PATCH 27/37] ENGINE: Fix operator < for COldModelManager::FileInfo There was a rare case when Old Model Manager's model base object list was not working correctly. Testcase: CreateObject pos=10;0 dir=1.5 type=LeggedTrainer selectable=1 team=1 CreateObject pos=-10;0 dir=0.25 type=LeggedTrainer selectable=1 team=2 Expected result (after fix): models are displayed correctly Actual result (before fix): some legs are missing, instead of them giant surfaces are floating high above the model The reason was is failing to find the element that was just created and added with `m_models.find(FileInfo(fileName, mirrored, team))` This happened for objects that had mirrored body parts (at least Ants, Wasps and all Legged units were affected) in case they were assigned to several teams. Everyone were missing some legs since the `modelManager->AddModelReference("ant6.mod", true, rank, m_object->GetTeam())` Wasps were also usually missing some wings. --- src/graphics/engine/oldmodelmanager.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/graphics/engine/oldmodelmanager.h b/src/graphics/engine/oldmodelmanager.h index feb7424c..16b28f77 100644 --- a/src/graphics/engine/oldmodelmanager.h +++ b/src/graphics/engine/oldmodelmanager.h @@ -114,6 +114,8 @@ private: if (variant < other.variant) return true; + if (variant > other.variant) + return false; return !mirrored && mirrored != other.mirrored; } From 5efd8342ecd8ce8f151a610b8cb5305be642a107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 26 Nov 2022 20:04:44 +0100 Subject: [PATCH 28/37] Updated SDL2 and SDL2_image library names --- cmake/FindSDL2.cmake | 4 ++-- cmake/FindSDL2_image.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake index 2445d36e..2f2388d0 100644 --- a/cmake/FindSDL2.cmake +++ b/cmake/FindSDL2.cmake @@ -186,7 +186,7 @@ endif() # SDL-2.0 is the name used by FreeBSD ports... # don't confuse it for the version number. find_library(SDL2_LIBRARY - NAMES SDL2 SDL-2.0 + NAMES SDL2 SDL-2.0 SDL2-static HINTS ENV SDL2DIR ${SDL2_NO_DEFAULT_PATH_CMD} @@ -223,7 +223,7 @@ if(NOT SDL2_BUILDING_LIBRARY) HINTS ENV SDL2DIR ${SDL2_NO_DEFAULT_PATH_CMD} - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} + PATH_SUFFIXES lib lib/manual-link ${VC_LIB_PATH_SUFFIX} PATHS ${SDL2MAIN_LIBRARY_PATHS} DOC "Where the SDL2main library can be found" ) diff --git a/cmake/FindSDL2_image.cmake b/cmake/FindSDL2_image.cmake index 624e9154..f056f4bb 100644 --- a/cmake/FindSDL2_image.cmake +++ b/cmake/FindSDL2_image.cmake @@ -166,7 +166,7 @@ endif() # Search for the SDL2_image library find_library(SDL2_IMAGE_LIBRARY - NAMES SDL2_image + NAMES SDL2_image SDL2_image-static HINTS ENV SDL2IMAGEDIR ENV SDL2DIR From ec9607784c5dced1c81cbb15309703a07b5b0e00 Mon Sep 17 00:00:00 2001 From: olokos <1755581+olokos@users.noreply.github.com> Date: Mon, 6 Feb 2023 17:22:05 +0100 Subject: [PATCH 29/37] Remove redundant " from CMakeLists.txt --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10def122..2f78e100 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ # Compile flags as defined in global CMakeLists -set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS}") +set(CMAKE_CXX_FLAGS ${COLOBOT_CXX_FLAGS}) set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE}) set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG}) From f60c62f05df341b8f1071a5cbed70a14188f15eb Mon Sep 17 00:00:00 2001 From: olokos <1755581+olokos@users.noreply.github.com> Date: Mon, 6 Feb 2023 17:53:56 +0100 Subject: [PATCH 30/37] Graphics - Engine - Fix pause blur for new SDL --- src/graphics/engine/engine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index d0ffcc44..5946d389 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -3599,7 +3599,8 @@ void CEngine::Capture3DScene() // create SDL surface and final texture ImageData image; - image.surface = SDL_CreateRGBSurfaceFrom(blured.get(), newWidth, newHeight, 32, 0, 0, 0, 0, 0xFF000000); + image.surface = SDL_CreateRGBSurfaceFrom(blured.get(), newWidth, newHeight, + 32, 4 * newWidth, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); TextureCreateParams params; params.filter = TEX_FILTER_BILINEAR; From 4634461c1d90ba85c8ac5fe2f5834f03d646e0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 3 Apr 2023 00:01:30 +0200 Subject: [PATCH 31/37] Added vcpkg manifest file --- .github/workflows/build.yml | 6 ++--- CMakeLists.txt | 3 --- src/CMakeLists.txt | 20 ---------------- vcpkg.json | 48 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 26 deletions(-) create mode 100644 vcpkg.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 945845b4..e03248f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,11 +98,11 @@ jobs: - name: Install Colobot dependencies uses: lukka/run-vcpkg@v7 with: - vcpkgGitCommitId: 'e809a42f87565e803b2178a0c11263f462d1800a' + vcpkgGitCommitId: '716c3524a54f1f50a25d16a4cdd360f5a7fcc150' vcpkgTriplet: ${{ matrix.vcpkg_triplet }} - vcpkgArguments: 'boost-system boost-filesystem boost-regex boost-lexical-cast boost-bimap boost-algorithm boost-property-tree boost-optional boost-range sdl2 sdl2-ttf sdl2-image glew libpng libwebp tiff gettext libsndfile libvorbis libogg openal-soft physfs mpg123' + setupOnly: true # SHA-256 hash of the list of packages above, for caching purposes - appendedCacheKey: '84402d9834b06a1b571e0fda32a791915777d47a394a1469d4773322bd71614b' + appendedCacheKey: '56a81d2ed18a506e5ce5cf4dc4e6ed9874bba3905ed5e9b073ea717a0663db0a' - name: Install external tools working-directory: ${{ github.workspace }} run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe4357d..203b8dda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,9 +330,6 @@ endif() find_package(SndFile REQUIRED) -find_package(mpg123 QUIET) -find_package(mp3lame QUIET) - if(NOT ASSERTS) add_definitions(-DNDEBUG) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f78e100..f1cd79c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -493,20 +493,6 @@ target_link_libraries(colobotbase PUBLIC SndFile::sndfile ) -if(mpg123_FOUND) - target_link_libraries(colobotbase PUBLIC - MPG123::libmpg123 - MPG123::libout123 - MPG123::libsyn123 - ) -endif() - -if(mp3lame_FOUND) - target_link_libraries(colobotbase PUBLIC - mp3lame::mp3lame - ) -endif() - # Optional libraries if(OPENAL_SOUND) target_sources(colobotbase PRIVATE @@ -536,9 +522,6 @@ if(PLATFORM_WINDOWS) find_package(Intl REQUIRED) find_library(BZ2_LIBRARY NAMES bz2) - find_library(JPEG_LIBRARY NAMES jpeg) - find_library(TIFF_LIBRARY NAMES tiff) - find_library(LZMA_LIBRARY NAMES lzma) find_library(FREETYPE_LIBRARY NAMES freetype) find_library(ICONV_LIBRARY NAMES iconv) find_library(CHARSET_LIBRARY NAMES charset) @@ -548,10 +531,7 @@ if(PLATFORM_WINDOWS) target_link_libraries(colobotbase PUBLIC Gettext::Intl - ${JPEG_LIBRARY} - ${TIFF_LIBRARY} ${BZ2_LIBRARY} - ${LZMA_LIBRARY} ${FREETYPE_LIBRARY} ${ICONV_LIBRARY} ${CHARSET_LIBRARY} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..673c5935 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,48 @@ +{ + "name": "colobot", + "version-string": "0.1.0", + "builtin-baseline": "e809a42f87565e803b2178a0c11263f462d1800a", + "dependencies": [ + "boost-system", + "boost-filesystem", + "boost-regex", + "boost-lexical-cast", + "boost-bimap", + "boost-algorithm", + "boost-property-tree", + "boost-optional", + "boost-range", + "sdl2", + { + "name": "sdl2-image", + "default-features": false + }, + { + "name": "sdl2-ttf", + "default-features": false + }, + "glew", + "libpng", + "gettext", + { + "name": "libsndfile", + "default-features": false, + "features": [ "external-libs" ] + }, + { + "name": "freetype", + "default-features": false + }, + "libvorbis", + "libogg", + "opus", + "openal-soft", + "physfs", + "zlib" + ], + "overrides": [ + { + "name": "zlib", "version": "1.2.13" + } + ] +} From 0b978f7dbc1b73cf9596b197ee85a9f0cf6d6c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 3 Apr 2023 00:51:27 +0200 Subject: [PATCH 32/37] Use newer version of vcpkg to fix broken link --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e03248f2..545f90ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -98,7 +98,7 @@ jobs: - name: Install Colobot dependencies uses: lukka/run-vcpkg@v7 with: - vcpkgGitCommitId: '716c3524a54f1f50a25d16a4cdd360f5a7fcc150' + vcpkgGitCommitId: '69efe9cc2df0015f0bb2d37d55acde4a75c9a25b' vcpkgTriplet: ${{ matrix.vcpkg_triplet }} setupOnly: true # SHA-256 hash of the list of packages above, for caching purposes From bfd9dae53331c1d67a590169f7cc0ec44df30f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Sat, 8 Apr 2023 20:43:26 +0200 Subject: [PATCH 33/37] Removed Ubuntu 18.04 actions --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac7b768f..f01483b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: target_os: [linux] - host_os: [ubuntu-18.04, ubuntu-20.04] + host_os: [ubuntu-20.04] container: [''] fail-fast: false steps: @@ -40,7 +40,7 @@ jobs: with: name: ${{matrix.target_os}}-debug path: build/install - if: matrix.host_os == 'ubuntu-18.04' + if: matrix.host_os == 'ubuntu-20.04' - name: Create AppImage working-directory: build run: | @@ -64,7 +64,7 @@ jobs: with: name: ${{matrix.target_os}}-debug-AppImage path: build/appimage - if: matrix.target_os == 'linux' && matrix.host_os == 'ubuntu-18.04' + if: matrix.target_os == 'linux' && matrix.host_os == 'ubuntu-20.04' - name: Run tests # TODO: Maybe run Windows tests using wine as well? working-directory: build From 7c0dbd914f5fc8d249ec596236ce74090e61172f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 10 Apr 2023 20:55:39 +0200 Subject: [PATCH 34/37] Cache vcpkg dependencies --- .github/workflows/build.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f01483b0..337d639d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -134,11 +134,12 @@ jobs: - name: Install Colobot dependencies uses: lukka/run-vcpkg@v7 with: + setupOnly: true vcpkgGitCommitId: '69efe9cc2df0015f0bb2d37d55acde4a75c9a25b' vcpkgTriplet: ${{ matrix.vcpkg_triplet }} - setupOnly: true - # SHA-256 hash of the list of packages above, for caching purposes - appendedCacheKey: '56a81d2ed18a506e5ce5cf4dc4e6ed9874bba3905ed5e9b073ea717a0663db0a' + # SHA-256 hash of the vcpkg.json file, recalculated automatically when it changes + appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }} + additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed - name: Install external tools working-directory: ${{ github.workspace }} run: | From 9a01408edad204869cc9781b001fd09e9361c409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 10 Apr 2023 21:37:55 +0200 Subject: [PATCH 35/37] Added CMakeUserPresets.json to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 781f171c..a5d26644 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ CMakeLists.txt.user.* /CMakeSettings.json /.vs /out + +CMakeUserPresets.json From 158901ff0259b5033ff9501db99b3ca03022b63a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 10 Apr 2023 22:36:52 +0200 Subject: [PATCH 36/37] Fixed cached path --- .github/workflows/build.yml | 2 +- vcpkg.json | 46 ++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 337d639d..0f597890 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,7 +139,7 @@ jobs: vcpkgTriplet: ${{ matrix.vcpkg_triplet }} # SHA-256 hash of the vcpkg.json file, recalculated automatically when it changes appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }} - additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed + additionalCachedPaths: ${{ github.workspace }}/build/vcpkg_installed - name: Install external tools working-directory: ${{ github.workspace }} run: | diff --git a/vcpkg.json b/vcpkg.json index 673c5935..ab33b4cf 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,15 +3,32 @@ "version-string": "0.1.0", "builtin-baseline": "e809a42f87565e803b2178a0c11263f462d1800a", "dependencies": [ - "boost-system", - "boost-filesystem", - "boost-regex", - "boost-lexical-cast", - "boost-bimap", "boost-algorithm", - "boost-property-tree", + "boost-bimap", + "boost-filesystem", + "boost-lexical-cast", "boost-optional", + "boost-property-tree", "boost-range", + "boost-regex", + "boost-system", + { + "name": "freetype", + "default-features": false + }, + "glew", + "gettext", + "libogg", + "libpng", + { + "name": "libsndfile", + "default-features": false, + "features": [ "external-libs" ] + }, + "libvorbis", + "openal-soft", + "opus", + "physfs", "sdl2", { "name": "sdl2-image", @@ -21,23 +38,6 @@ "name": "sdl2-ttf", "default-features": false }, - "glew", - "libpng", - "gettext", - { - "name": "libsndfile", - "default-features": false, - "features": [ "external-libs" ] - }, - { - "name": "freetype", - "default-features": false - }, - "libvorbis", - "libogg", - "opus", - "openal-soft", - "physfs", "zlib" ], "overrides": [ From 9dd0159585a09e8a26df030bc26a5667e30b04ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Kapu=C5=9Bci=C5=84ski?= Date: Mon, 10 Apr 2023 23:22:23 +0200 Subject: [PATCH 37/37] Added useless comment for testing --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a5d26644..e340866c 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,5 @@ CMakeLists.txt.user.* /.vs /out +# Ignore CMakeUserPresets.json CMakeUserPresets.json