17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 01:39:20 +02:00

fix(sonar): addressing reliability/security issues (#202)

This commit is contained in:
jerrrrycho
2026-10-04 20:00:13 +02:00
committed by GitHub
parent 51521a135a
commit 79bd0c8e91
36 changed files with 254 additions and 246 deletions

View File

@@ -598,11 +598,11 @@ void TAnimModel::on_season_update() {
void TAnimModel::RaPrepare()
{ // ustawia światła i animacje we wzorcu modelu przed renderowaniem egzemplarza
bool state; // stan światła
if (Global.UpdateMaterials)
on_season_update();
for (int i = 0; i < iNumLights; ++i)
{
bool state{ false }; // stan światła
auto const lightmode { static_cast<int>( std::abs( lsLights[ i ] ) ) };
switch( lightmode ) {
case ls_On:

View File

@@ -1529,7 +1529,9 @@ void TSubModel::ParentMatrix(float4x4 *m) const
void TSubModel::ReplaceMatrix(const glm::mat4 &mat)
{
*fMatrix = float4x4(glm::value_ptr(mat));
for (int column = 0; column < 4; ++column)
for (int row = 0; row < 4; ++row)
fMatrix->e[column * 4 + row] = mat[column][row];
}
void TSubModel::ReplaceMaterial(const std::string &name)
@@ -1618,13 +1620,8 @@ TSubModel *TModel3d::GetFromName(std::string const &Name) const
{ // wyszukanie submodelu po nazwie
if (Name.empty())
return Root; // potrzebne do terenu z E3D
if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne
return Root ? Root->GetFromName(Name) : nullptr;
else // wczytano z pliku binarnego, można wyszukać iteracyjnie
{
// for (int i=0;i<iSubModelsCount;++i)
return Root ? Root->GetFromName(Name) : nullptr;
}
// both text and binary models are searched recursively
return Root ? Root->GetFromName(Name) : nullptr;
};
// locates particle source submodels and stores them on internal list

View File

@@ -394,12 +394,12 @@ opengl_texture::make_from_memory(size_t width, size_t height, const uint8_t *raw
void opengl_texture::update_from_memory(size_t width, size_t height, const uint8_t *raw)
{
if (id != (GLuint)-1 && (width != data_width || height != data_height || GL_SRGB8_ALPHA8 != data_format || GL_RGBA != data_components))
if (id != invalid_id && (width != data_width || height != data_height || GL_SRGB8_ALPHA8 != data_format || GL_RGBA != data_components))
{
glDeleteTextures(1, &id);
id = (GLuint)-1;
id = invalid_id;
}
if (id == (GLuint)-1)
if (id == invalid_id)
{
data_width = width;
data_height = height;

View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <istream>
#include <limits>
#include "winheaders.h"
#include <string>
#include "model/ResourceManager.h"
@@ -84,7 +85,8 @@ struct opengl_texture : public ITexture {
virtual void update_from_memory(size_t width, size_t height, const uint8_t *data) override;
// members
GLuint id{ (GLuint)-1 }; // associated GL resource
static constexpr GLuint invalid_id { std::numeric_limits<GLuint>::max() }; // id value of texture without GL resource
GLuint id{ invalid_id }; // associated GL resource
bool has_alpha{ false }; // indicates the texture has alpha channel
bool is_ready{ false }; // indicates the texture was processed and is ready for use
std::string traits; // requested texture attributes: wrapping modes etc