Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Fix several compiler warnings #484

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libs/animation/src/animation_imp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ void AnimationImp::BuildAnimationMatrices()

// Auto normalization
if (normBlend != 0.0f)
{
if (plCnt > 1)
{
normBlend = 1.0f / normBlend;
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions src/libs/battle_interface/src/battle_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -295,15 +297,17 @@ 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);
BIUtils::ReadPosFromAttr(pAList, "ActiveIcon_Size", m_pntActiveIconSize.x, m_pntActiveIconSize.y,
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;
}

Expand Down
7 changes: 6 additions & 1 deletion src/libs/battle_interface/src/battle_sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion src/libs/battle_interface/src/item_entity/item_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<MODEL *>(core.GetEntityPointer(m_eidModel));
Expand Down
14 changes: 12 additions & 2 deletions src/libs/battle_interface/src/sea/battle_ship_sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/libs/battle_interface/src/sea/island_descr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 1 addition & 3 deletions src/libs/blot/src/blots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/core/include/ifs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/libs/core/src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions src/libs/core/src/core_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<storm::OSWindow> window) override;
bool Initialize();
void ResetCore();
bool Run();
bool Run() override;
bool LoadClassesTable();

void ProcessExecute();
Expand All @@ -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);
Expand Down Expand Up @@ -133,9 +133,9 @@ class CoreImpl final : public CorePrivate
bool IsLayerFrozen(layer_index_t index) const override;
void ForEachEntity(const std::function<void(entptr_t)>& f) override;

void collectCrashInfo() const;
void collectCrashInfo() const override;

[[nodiscard]] bool initialized() const
[[nodiscard]] bool initialized() const override
{
return Initialized;
}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/core/src/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -2357,7 +2357,7 @@ ATTRIBUTES *DATA::GetAClass()
return nullptr;
}

AttributesClass = new ATTRIBUTES(pVCompiler->GetVSC());
AttributesClass = new ATTRIBUTES(*pVCompiler->GetVSC());
}
return AttributesClass;
}
Expand Down
7 changes: 4 additions & 3 deletions src/libs/core/src/internal_functions.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "compiler.h"
#include "core_impl.h"
#include "debug-trap.h"
#include "math_common.hpp"

#include <execution>

Expand Down Expand Up @@ -1534,7 +1535,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t
break;

case FUNC_FRAND:
TempFloat1 = static_cast<float>(rand()) / RAND_MAX;
TempFloat1 = storm::RandomFloat();
pV = SStack.Push();
// TempFloat1 = 1.0f; // ***
pV->Set(TempFloat1);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/libs/core/src/message.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma once

#include "message.h"

#include <algorithm>
Expand Down
4 changes: 3 additions & 1 deletion src/libs/geometry/src/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char*>(avb[vb - SHIFT_VALUE].buff);
delete static_cast<char *>(avb[vb - SHIFT_VALUE].buff);
avb[vb - SHIFT_VALUE].nvertices = 0;
}
else
RenderService->ReleaseVertexBuffer(vb);
}
}

GEOS::ID GEOM_SERVICE_R::CreateIndexBuffer(int32_t size)
Expand Down
6 changes: 3 additions & 3 deletions src/libs/island/src/foam.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/libs/island/src/island.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "tga.h"
#include <cstdio>

using storm::Sqr;

CREATE_CLASS(ISLAND)

CREATE_CLASS(CoastFoam)
Expand Down
18 changes: 9 additions & 9 deletions src/libs/island/src/island.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 &center, float radius, ADD_POLYGON_FUNC addpoly)
bool Clip(const PLANE *planes, int32_t nplanes, const CVECTOR &center, 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()
{
Expand Down
Loading