diff --git a/src/libs/animation/src/animation_imp.cpp b/src/libs/animation/src/animation_imp.cpp index 6c3d0a1bd..d7be96860 100644 --- a/src/libs/animation/src/animation_imp.cpp +++ b/src/libs/animation/src/animation_imp.cpp @@ -240,6 +240,7 @@ void AnimationImp::BuildAnimationMatrices() // Auto normalization if (normBlend != 0.0f) + { if (plCnt > 1) { normBlend = 1.0f / normBlend; @@ -381,6 +382,7 @@ void AnimationImp::BuildAnimationMatrices() // for(int32_t j = 0; j < nbones; j++) // aniInfo->GetBone(j).BlendFrame(frame); } + } for (int32_t j = 0; j < nbones; j++) { auto &bn = aniInfo->GetBone(j); diff --git a/src/libs/battle_interface/src/battle_command.cpp b/src/libs/battle_interface/src/battle_command.cpp index cbf3ea39c..18094e17d 100644 --- a/src/libs/battle_interface/src/battle_command.cpp +++ b/src/libs/battle_interface/src/battle_command.cpp @@ -272,7 +272,8 @@ void BICommandList::Init() sscanf(pAList->GetAttribute("CommandNoteOffset"), "%d,%d", &m_NoteOffset.x, &m_NoteOffset.y); // Setting values for arrows (up / down) - if (attr = pAList->GetAttribute("UDArrow_Texture")) + attr = pAList->GetAttribute("UDArrow_Texture"); + if (attr) m_sUpDownArrowTexture = attr; BIUtils::ReadRectFromAttr(pAList, "UDArrow_UV_Up", m_frUpArrowUV, m_frUpArrowUV); BIUtils::ReadRectFromAttr(pAList, "UDArrow_UV_Down", m_frDownArrowUV, m_frDownArrowUV); @@ -283,7 +284,8 @@ void BICommandList::Init() BIUtils::ReadPosFromAttr(pAList, "UDArrow_Offset_Down", m_pntDownArrowOffset.x, m_pntDownArrowOffset.y, m_pntDownArrowOffset.x, m_pntDownArrowOffset.y); - if (attr = pAList->GetAttribute("LRArrow_Texture")) + attr = pAList->GetAttribute("LRArrow_Texture"); + if (attr) m_sLeftRightArrowTexture = attr; BIUtils::ReadRectFromAttr(pAList, "LRArrow_UV_Left", m_frLeftArrowUV, m_frLeftArrowUV); BIUtils::ReadRectFromAttr(pAList, "LRArrow_UV_Right", m_frRightArrowUV, m_frRightArrowUV); @@ -295,7 +297,8 @@ void BICommandList::Init() m_pntRightArrowOffset.x, m_pntRightArrowOffset.y); // set values for the menu activity icon - if (attr = pAList->GetAttribute("ActiveIcon_Texture")) + attr = pAList->GetAttribute("ActiveIcon_Texture"); + if (attr) m_sActiveIconTexture = attr; BIUtils::ReadPosFromAttr(pAList, "ActiveIcon_Offset", m_pntActiveIconOffset.x, m_pntActiveIconOffset.y, m_pntActiveIconOffset.x, m_pntActiveIconOffset.y); @@ -303,7 +306,8 @@ void BICommandList::Init() m_pntActiveIconSize.x, m_pntActiveIconSize.y); BIUtils::ReadRectFromAttr(pAList, "ActiveIcon_UV1", m_frActiveIconUV1, m_frActiveIconUV1); BIUtils::ReadRectFromAttr(pAList, "ActiveIcon_UV2", m_frActiveIconUV2, m_frActiveIconUV2); - if (attr = pAList->GetAttribute("ActiveIcon_Note")) + attr = pAList->GetAttribute("ActiveIcon_Note"); + if (attr) m_sActiveIconNote = attr; } diff --git a/src/libs/battle_interface/src/battle_sign.cpp b/src/libs/battle_interface/src/battle_sign.cpp index 4ff155c71..97b01e2ba 100644 --- a/src/libs/battle_interface/src/battle_sign.cpp +++ b/src/libs/battle_interface/src/battle_sign.cpp @@ -164,7 +164,12 @@ void BISignIcon::Init(ATTRIBUTES *pRoot, ATTRIBUTES *pA) pcTmp = pA->GetAttribute("fontoffset"); if (pcTmp) - sscanf(pcTmp, "%ld,%ld", &m_SignTextFontOffset.x, &m_SignTextFontOffset.y); + { + long x{}, y{}; + sscanf(pcTmp, "%ld,%ld", &x, &y); + m_SignTextFontOffset.x = x; + m_SignTextFontOffset.y = y; + } pcTmp = pA->GetAttribute("backtexturename"); if (pcTmp) diff --git a/src/libs/battle_interface/src/item_entity/item_entity.cpp b/src/libs/battle_interface/src/item_entity/item_entity.cpp index abf272f15..88a0bdcbd 100644 --- a/src/libs/battle_interface/src/item_entity/item_entity.cpp +++ b/src/libs/battle_interface/src/item_entity/item_entity.cpp @@ -26,10 +26,16 @@ bool ItemEntity::Init() void ItemEntity::Realize(uint32_t delta_time) { if (m_bVisible && m_pModel) + { if (m_bTieToLocator) + { DrawIntoLocator(); + } else + { m_pModel->ProcessStage(Stage::realize, delta_time); + } + } } uint64_t ItemEntity::ProcessMessage(MESSAGE &message) @@ -107,7 +113,8 @@ bool ItemEntity::ReadAndCreate() auto *const pcTechnique = BIUtils::GetStringFromAttr(AttributesPointer, "technique", ""); if (pcModelName) { - if (m_eidModel = core.CreateEntity("modelr")) + m_eidModel = core.CreateEntity("modelr"); + if (m_eidModel) { core.Send_Message(m_eidModel, "ls", MSG_MODEL_LOAD_GEO, pcModelName); m_pModel = static_cast(core.GetEntityPointer(m_eidModel)); diff --git a/src/libs/battle_interface/src/sea/battle_ship_sign.cpp b/src/libs/battle_interface/src/sea/battle_ship_sign.cpp index 58425e76e..ae713a20d 100644 --- a/src/libs/battle_interface/src/sea/battle_ship_sign.cpp +++ b/src/libs/battle_interface/src/sea/battle_ship_sign.cpp @@ -195,7 +195,12 @@ void BIShipIcon::Init(ATTRIBUTES *pRoot, ATTRIBUTES *pA) // ugeen 150920 pcTmp = pA->GetAttribute("sailorfontoffset"); if (pcTmp) - sscanf(pcTmp, "%ld,%ld", &m_SailorFontOffset.x, &m_SailorFontOffset.y); + { + long x{}, y{}; + sscanf(pcTmp, "%ld,%ld", &x, &y); + m_SailorFontOffset.x = x; + m_SailorFontOffset.y = y; + } pcTmp = pA->GetAttribute("shipnamefontid"); if (pcTmp) @@ -205,7 +210,12 @@ void BIShipIcon::Init(ATTRIBUTES *pRoot, ATTRIBUTES *pA) pcTmp = pA->GetAttribute("shipnamefontoffset"); if (pcTmp) - sscanf(pcTmp, "%ld,%ld", &m_ShipNameFontOffset.x, &m_ShipNameFontOffset.y); + { + long x{}, y{}; + sscanf(pcTmp, "%ld,%ld", &x, &y); + m_ShipNameFontOffset.x = x; + m_ShipNameFontOffset.y = y; + } pcTmp = pA->GetAttribute("backtexturename"); if (pcTmp) diff --git a/src/libs/battle_interface/src/sea/island_descr.cpp b/src/libs/battle_interface/src/sea/island_descr.cpp index d03264008..2c2821e0d 100644 --- a/src/libs/battle_interface/src/sea/island_descr.cpp +++ b/src/libs/battle_interface/src/sea/island_descr.cpp @@ -65,12 +65,14 @@ void ISLAND_DESCRIBER::SetIsland(ATTRIBUTES *pAIsland) { int32_t lTmp; if (pvdat->Get(lTmp, 0)) + { if (lTmp == 0) m_pLocators[i].locatorType = ISLAND_LOCATOR_LAND; else if (lTmp == 1) m_pLocators[i].locatorType = ISLAND_LOCATOR_FORT; else m_pLocators[i].locatorType = ISLAND_LOCATOR_TOWN; + } if (pvdat->Get(lTmp, 1)) m_pLocators[i].relation = lTmp; if (pvdat->Get(lTmp, 2)) diff --git a/src/libs/blot/src/blots.cpp b/src/libs/blot/src/blots.cpp index f02f3c978..fdcac7953 100644 --- a/src/libs/blot/src/blots.cpp +++ b/src/libs/blot/src/blots.cpp @@ -76,9 +76,7 @@ uint64_t Blots::ProcessMessage(MESSAGE &message) if (pCharAttributeRoot) { blotsInfo = pCharAttributeRoot->CreateSubAClass(pCharAttributeRoot, "ship.blots"); - char buf[32]; - sprintf_s(buf, "%i", BLOTS_MAX); - blotsInfo->SetValue(buf); + blotsInfo->SetValue(std::to_string(BLOTS_MAX)); for (int32_t i = 0; i < BLOTS_MAX; i++) LoadBlot(i); } diff --git a/src/libs/core/include/ifs.h b/src/libs/core/include/ifs.h index f6e7db186..fc1c5941b 100644 --- a/src/libs/core/include/ifs.h +++ b/src/libs/core/include/ifs.h @@ -125,7 +125,7 @@ class IFS : public INIFILE IFS_NOT_IMPLEMENTED(float GetFloat(const char *section_name, const char *key_name, float def_val)) IFS_NOT_IMPLEMENTED(bool GetFloatNext(const char *section_name, const char *key_name, float *val)) - bool CaseSensitive(bool yes) + bool CaseSensitive(bool yes) override { return false; } diff --git a/src/libs/core/src/compiler.cpp b/src/libs/core/src/compiler.cpp index 3ffe29702..e1216ad30 100644 --- a/src/libs/core/src/compiler.cpp +++ b/src/libs/core/src/compiler.cpp @@ -6341,7 +6341,7 @@ bool COMPILER::ReadVariable(char *name, /* DWORD code,*/ bool bDim, uint32_t a_i else if (eType == S_TOKEN_TYPE::VAR_OBJECT) { ReadData(nullptr, sizeof(uint64_t)); - ATTRIBUTES TA(&SCodec); + ATTRIBUTES TA(SCodec); ReadAttributesData(&TA, nullptr); } else @@ -6391,12 +6391,12 @@ bool COMPILER::ReadVariable(char *name, /* DWORD code,*/ bool bDim, uint32_t a_i pV->Set(eid); if (pV->AttributesClass == nullptr) - pV->AttributesClass = new ATTRIBUTES(&SCodec); + pV->AttributesClass = new ATTRIBUTES(SCodec); ReadAttributesData(pV->AttributesClass, nullptr); } else { - ATTRIBUTES *pTA = new ATTRIBUTES(&SCodec); + ATTRIBUTES *pTA = new ATTRIBUTES(SCodec); ReadAttributesData(pTA, nullptr); delete pTA; } @@ -6450,7 +6450,7 @@ bool COMPILER::ReadVariable(char *name, /* DWORD code,*/ bool bDim, uint32_t a_i } if (pVRef->AttributesClass == nullptr) - pVRef->AttributesClass = new ATTRIBUTES(&SCodec); + pVRef->AttributesClass = new ATTRIBUTES(SCodec); if (pString) { pA = pVRef->AttributesClass->CreateSubAClass(pVRef->AttributesClass, pString); diff --git a/src/libs/core/src/core_impl.h b/src/libs/core/src/core_impl.h index a83bf2af8..6e2314908 100644 --- a/src/libs/core/src/core_impl.h +++ b/src/libs/core/src/core_impl.h @@ -13,17 +13,17 @@ class CoreImpl final : public CorePrivate { public: - void Init(); + void Init() override; - void InitBase(); - void ReleaseBase(); + void InitBase() override; + void ReleaseBase() override; - void CleanUp(); + void CleanUp() override; void SetWindow(std::shared_ptr window) override; bool Initialize(); void ResetCore(); - bool Run(); + bool Run() override; bool LoadClassesTable(); void ProcessExecute(); @@ -43,7 +43,7 @@ class CoreImpl final : public CorePrivate void EraseEntities(); void ClearEvents(); void *MakeClass(const char *class_name); - void AppState(bool state); + void AppState(bool state) override; uint32_t MakeHashValue(const char *string); VMA *FindVMA(const char *class_name); VMA *FindVMA(int32_t hash); @@ -133,9 +133,9 @@ class CoreImpl final : public CorePrivate bool IsLayerFrozen(layer_index_t index) const override; void ForEachEntity(const std::function& f) override; - void collectCrashInfo() const; + void collectCrashInfo() const override; - [[nodiscard]] bool initialized() const + [[nodiscard]] bool initialized() const override { return Initialized; } diff --git a/src/libs/core/src/data.cpp b/src/libs/core/src/data.cpp index 533d065bd..9bb345c08 100644 --- a/src/libs/core/src/data.cpp +++ b/src/libs/core/src/data.cpp @@ -402,9 +402,9 @@ void DATA::Set(const char *attribute_name, const char *attribute_value) return; } - AttributesClass = new ATTRIBUTES(pVCompiler->GetVSC()); + AttributesClass = new ATTRIBUTES(*pVCompiler->GetVSC()); } - AttributesClass->SetAttribute(attribute_name, attribute_value); + AttributesClass->SetAttribute(std::string_view(attribute_name), std::string_view(attribute_value)); // Attributes.SetAttribute(attribute_name,attribute_value); } @@ -2357,7 +2357,7 @@ ATTRIBUTES *DATA::GetAClass() return nullptr; } - AttributesClass = new ATTRIBUTES(pVCompiler->GetVSC()); + AttributesClass = new ATTRIBUTES(*pVCompiler->GetVSC()); } return AttributesClass; } diff --git a/src/libs/core/src/internal_functions.cpp b/src/libs/core/src/internal_functions.cpp index 8a5df1cd1..b722e3ae0 100644 --- a/src/libs/core/src/internal_functions.cpp +++ b/src/libs/core/src/internal_functions.cpp @@ -1,6 +1,7 @@ #include "compiler.h" #include "core_impl.h" #include "debug-trap.h" +#include "math_common.hpp" #include @@ -1534,7 +1535,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t break; case FUNC_FRAND: - TempFloat1 = static_cast(rand()) / RAND_MAX; + TempFloat1 = storm::RandomFloat(); pV = SStack.Push(); // TempFloat1 = 1.0f; // *** pV->Set(TempFloat1); @@ -1581,7 +1582,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t } pV2->Get(pChar); - if (ent = core.CreateEntity(pChar, pV->GetAClass())) + if (ent = core.CreateEntity(pChar, pV->GetAClass()); ent) { // core_internal.Entity_SetAttributePointer(&entid_t,pV->GetAClass()); pV->Set(ent); @@ -1607,7 +1608,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t break; } pV->Get(pChar); - if (ent = core.CreateEntity(pChar)) + if (ent = core.CreateEntity(pChar); ent) { pV = SStack.Push(); pV->Set(ent); diff --git a/src/libs/core/src/message.cpp b/src/libs/core/src/message.cpp index e06537730..471ae7c4d 100644 --- a/src/libs/core/src/message.cpp +++ b/src/libs/core/src/message.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "message.h" #include diff --git a/src/libs/geometry/src/geometry.cpp b/src/libs/geometry/src/geometry.cpp index d2ef36f50..c4aa0b814 100644 --- a/src/libs/geometry/src/geometry.cpp +++ b/src/libs/geometry/src/geometry.cpp @@ -369,13 +369,15 @@ void GEOM_SERVICE_R::ReleaseVertexBuffer(GEOS::ID vb) if (vb == INVALID_BUFFER_ID) return; if (RenderService) + { if (vb >= SHIFT_VALUE) { - delete static_cast(avb[vb - SHIFT_VALUE].buff); + delete static_cast(avb[vb - SHIFT_VALUE].buff); avb[vb - SHIFT_VALUE].nvertices = 0; } else RenderService->ReleaseVertexBuffer(vb); + } } GEOS::ID GEOM_SERVICE_R::CreateIndexBuffer(int32_t size) diff --git a/src/libs/island/src/foam.h b/src/libs/island/src/foam.h index 77603cfde..4ce4bed2c 100644 --- a/src/libs/island/src/foam.h +++ b/src/libs/island/src/foam.h @@ -19,12 +19,12 @@ class CoastFoam : public Entity { public: CoastFoam(); - ~CoastFoam(); + ~CoastFoam() override; - bool Init(); + bool Init() override; void Realize(uint32_t Delta_Time); void Execute(uint32_t Delta_Time); - uint32_t AttributeChanged(ATTRIBUTES *pA); + uint32_t AttributeChanged(ATTRIBUTES *pA) override; void ProcessStage(Stage stage, uint32_t delta) override { diff --git a/src/libs/island/src/island.cpp b/src/libs/island/src/island.cpp index 452932e94..ffc92cc11 100644 --- a/src/libs/island/src/island.cpp +++ b/src/libs/island/src/island.cpp @@ -9,6 +9,8 @@ #include "tga.h" #include +using storm::Sqr; + CREATE_CLASS(ISLAND) CREATE_CLASS(CoastFoam) diff --git a/src/libs/island/src/island.h b/src/libs/island/src/island.h index c793a827a..b1cc4cb30 100644 --- a/src/libs/island/src/island.h +++ b/src/libs/island/src/island.h @@ -118,10 +118,10 @@ class ISLAND : public ISLAND_BASE public: ISLAND(); - ~ISLAND(); - bool Init(); + ~ISLAND() override; + bool Init() override; void Realize(uint32_t Delta_Time); - uint64_t ProcessMessage(MESSAGE &message); + uint64_t ProcessMessage(MESSAGE &message) override; void ProcessStage(Stage stage, uint32_t delta) override { @@ -143,28 +143,28 @@ class ISLAND : public ISLAND_BASE void SetDevice(); // inherit functions COLLISION_OBJECT - float Trace(const CVECTOR &src, const CVECTOR &dst); + float Trace(const CVECTOR &src, const CVECTOR &dst) override; - bool Clip(const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, float radius, ADD_POLYGON_FUNC addpoly) + bool Clip(const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, float radius, ADD_POLYGON_FUNC addpoly) override { return false; }; - const char *GetCollideMaterialName() + const char *GetCollideMaterialName() override { return nullptr; }; - bool GetCollideTriangle(TRIANGLE &triangle) + bool GetCollideTriangle(TRIANGLE &triangle) override { return false; }; // inherit functions CANNON_TRACE_BASE - float Cannon_Trace(int32_t iBallOwner, const CVECTOR &src, const CVECTOR &dst); + float Cannon_Trace(int32_t iBallOwner, const CVECTOR &src, const CVECTOR &dst) override; // inherit functions ISLAND_BASE - bool GetMovePoint(CVECTOR &vSrc, CVECTOR &vDst, CVECTOR &vRes); + bool GetMovePoint(CVECTOR &vSrc, CVECTOR &vDst, CVECTOR &vRes) override; entid_t GetModelEID() { diff --git a/src/libs/math/include/math3d.h b/src/libs/math/include/math3d.h index fef4d18ab..6a2490c8a 100644 --- a/src/libs/math/include/math3d.h +++ b/src/libs/math/include/math3d.h @@ -94,13 +94,13 @@ inline float sqrf(float f) // Random number inline float Rnd(float max = 1.0f) { - return rand() * (max * (1.0f / RAND_MAX)); + return storm::RandomFloat(max); } // Random number inline float RRnd(float min, float max) { - return min + rand() * ((max - min) * (1.0f / RAND_MAX)); + return min + storm::RandomFloat(max - min); } // Limit float diff --git a/src/libs/math/include/math3d/vector.h b/src/libs/math/include/math3d/vector.h index e882689be..0dc8ef78a 100644 --- a/src/libs/math/include/math3d/vector.h +++ b/src/libs/math/include/math3d/vector.h @@ -6,8 +6,9 @@ #pragma once -#include -#include +#include "../math_common.hpp" + +#include #pragma pack(push, 1) @@ -1042,24 +1043,24 @@ inline Vector &Vector::Reflection(const Vector &normal) // Fill with a unit vector with a random direction inline Vector &Vector::Rand() { - Make2D(rand() * ((2.0f * 3.141592654f) / RAND_MAX)); + Make2D(storm::RandomFloat(2.0f * 3.141592654f)); y = z; z = 0.0f; - return Rotate(rand() * ((2.0f * 3.141592654f) / RAND_MAX)); + return Rotate(storm::RandomFloat(2.0f * 3.141592654f)); } // Fill with unit vector with random direction in XZ inline Vector &Vector::Rand2D() { - return Make2D(rand() * ((2.0f * 3.141592654f) / RAND_MAX)); + return Make2D(storm::RandomFloat(2.0f * 3.141592654f)); } // Fill with random values in a given ABB inline Vector &Vector::Rand(const Vector &min, const Vector &max) { - x = min.x + rand() * ((max.x - min.x) * (1.0f / RAND_MAX)); - y = min.y + rand() * ((max.y - min.y) * (1.0f / RAND_MAX)); - z = min.z + rand() * ((max.z - min.z) * (1.0f / RAND_MAX)); + x = min.x + storm::RandomFloat(max.x - min.x); + x = min.y + storm::RandomFloat(max.y - min.y); + x = min.z + storm::RandomFloat(max.z - min.z); return *this; } @@ -1067,7 +1068,7 @@ inline Vector &Vector::Rand(const Vector &min, const Vector &max) inline Vector &Vector::Rand(const Vector &pos, float radius) { Rand(); - *this *= rand() * (radius * (1.0f / RAND_MAX)); + *this *= storm::RandomFloat(radius); return *this; } diff --git a/src/libs/math/include/math_common.hpp b/src/libs/math/include/math_common.hpp new file mode 100644 index 000000000..5c92960b2 --- /dev/null +++ b/src/libs/math/include/math_common.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include + +#ifdef SQR +#undef SQR +#endif + +#define SQR(x) ::storm::Sqr(x) +#define FRAND(x) ::storm::RandomFloat(x) + +namespace storm { + +constexpr const float kRandMaxFloat = static_cast(RAND_MAX); + +inline float RandomFloat() { + return static_cast(rand()) / storm::kRandMaxFloat; +} + +inline float RandomFloat(const float x) { + return x * RandomFloat(); +} + +template +inline T Sqr(const T x) { + return x * x; +} + +} // namespace storm diff --git a/src/libs/math/include/math_inlines.h b/src/libs/math/include/math_inlines.h index 8e410a938..5469eb203 100644 --- a/src/libs/math/include/math_inlines.h +++ b/src/libs/math/include/math_inlines.h @@ -1,5 +1,7 @@ #pragma once +#include "math_common.hpp" + #include #include @@ -7,8 +9,6 @@ #include "c_vector.h" -#define SQR(a) ((a) * (a)) -#define FRAND(x) ((x) * (float)rand() / (float)RAND_MAX) #define SIGN(x) ((x) < 0 ? -1.0f : 1.0f) #define SIGNZ(x) ((x) == 0.0f ? 0.0f : ((x) < 0.0f ? -1.0f : 1.0f)) #define MAX(x, y) (((x) > (y)) ? (x) : (y)) @@ -63,11 +63,6 @@ template T Max(T t1, T t2) return ((t1 > t2) ? t1 : t2); }; -template T Sqr(T t1) -{ - return (t1 * t1); -}; - constexpr float PI = 3.14159265358979323846f; constexpr float PIm2 = (PI * 2.0f); constexpr float PId2 = (PI / 2.0f); diff --git a/src/libs/math/include/types3d.h b/src/libs/math/include/types3d.h index e23b04039..452cbca18 100644 --- a/src/libs/math/include/types3d.h +++ b/src/libs/math/include/types3d.h @@ -1,14 +1,10 @@ #pragma once +#include "math_common.hpp" + #pragma pack(push) #pragma pack(1) -#ifdef SQR -#undef SQR -#endif - -#define SQR(x) ((x) * (x)) - typedef struct { float x; diff --git a/src/libs/sailors/src/sailors_way_points.cpp b/src/libs/sailors/src/sailors_way_points.cpp index 456d0f8e3..7d1e18879 100644 --- a/src/libs/sailors/src/sailors_way_points.cpp +++ b/src/libs/sailors/src/sailors_way_points.cpp @@ -83,7 +83,7 @@ void SailorsPoints::Draw(VDX9RENDER *rs, bool pointmode) RS_RECT pRSR; pRSR.fSize = 1; - pRSR.fAngle = PI * 2.0f * rand() / RAND_MAX; + pRSR.fAngle = storm::RandomFloat(PI * 2.0f * rand()); for (auto i = 0; i < points.count; i++) { diff --git a/src/libs/sea/src/sea.cpp b/src/libs/sea/src/sea.cpp index f6958d4d8..e592e3980 100644 --- a/src/libs/sea/src/sea.cpp +++ b/src/libs/sea/src/sea.cpp @@ -12,6 +12,8 @@ #include "tga.h" #include "v_file_service.h" +using storm::Sqr; + CREATE_CLASS(SEA) //#define OLD_WORLD_POS diff --git a/src/libs/sea_ai/src/ai_balls.cpp b/src/libs/sea_ai/src/ai_balls.cpp index cc88df422..3db4342c2 100644 --- a/src/libs/sea_ai/src/ai_balls.cpp +++ b/src/libs/sea_ai/src/ai_balls.cpp @@ -3,6 +3,8 @@ #include "math_inlines.h" #include "shared/messages.h" +using storm::Sqr; + AIBalls *AIBalls::pAIBalls = nullptr; AIBalls::AIBalls() diff --git a/src/libs/util/include/utf8.h b/src/libs/util/include/utf8.h index 84ff498c6..15d807993 100644 --- a/src/libs/util/include/utf8.h +++ b/src/libs/util/include/utf8.h @@ -114,7 +114,7 @@ inline int Utf8ToCodepoint(const char *utf8) if (u0 >= 0xC0 && u0 <= 0xDF) return (u0 - 192) * 64 + (u1 - 128); - if (utf8[0] == 0xed && (utf8[1] & 0xa0) == 0xa0) + if (u0 == 0xed && (u1 & 0xa0) == 0xa0) return -1; // code points, 0xd800 to 0xdfff if (l < 3) diff --git a/src/libs/xinterface/testsuite/options_parser.cpp b/src/libs/xinterface/testsuite/options_parser.cpp index be090a40b..f68bc7740 100644 --- a/src/libs/xinterface/testsuite/options_parser.cpp +++ b/src/libs/xinterface/testsuite/options_parser.cpp @@ -67,7 +67,7 @@ TEST_CASE("Parse options", "[xinterface]") { auto source = "title=My title\ntext=Hello, World!\n"s; - ATTRIBUTES attribute(&string_codec); + ATTRIBUTES attribute(string_codec); storm::parseOptions(source, attribute); @@ -86,7 +86,7 @@ TEST_CASE("Parse options", "[xinterface]") { auto source = "title=My title\ntext=Hello, World!"s; - ATTRIBUTES attribute(&string_codec); + ATTRIBUTES attribute(string_codec); storm::parseOptions(source, attribute); @@ -110,7 +110,7 @@ TEST_CASE("Parse options", "[xinterface]") "had better get away before I am detected and destroyed with the rest of the English here.\n" "text.t2=A French squadron captured the English colony, #sOxbay# on #sisland_Oxbay#. The French succeeded because the fort's defences were so weak. I escaped only by great good fortune. I suppose I should inform the governor of the main English colony - #sRedmond# on the island #sisland_Redmond#, Sir Robert Christopher Silehard, about the attack, so he can take appropriate measures. By chance, I noticed someone else also managed to escape the French. I saw a ship sailing away from the bay. I wonder who the captain was.\n"s; - ATTRIBUTES attribute(&string_codec); + ATTRIBUTES attribute(string_codec); storm::parseOptions(source, attribute);