17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 16:59:06 +01:00

fix(sonar): addressing last reliability/security issues

This commit is contained in:
jerrrrycho
2026-10-06 14:21:55 +02:00
parent c6b76a0b72
commit e570874f63
5 changed files with 14 additions and 10 deletions

View File

@@ -550,12 +550,12 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, glm::dvec3 const &Origin,
void TSegment::render_lines(std::vector<gfx::basic_vertex> &out, float quality) const
{
float step = 1.0f / iSegCount / quality;
float x;
int const stepcount = static_cast<int>(iSegCount * quality);
glm::vec3 previous = FastGetPoint(0.0);
for (x = step; x <= 1.0f; x += step) {
for (int i = 1; i <= stepcount; ++i) {
float const x = std::min(1.0f, i * step);
out.push_back(gfx::basic_vertex(previous, glm::vec3(0.0f), glm::vec2(0.0f)));
previous = glm::vec3(FastGetPoint(x));
@@ -571,13 +571,13 @@ void TSegment::render_lines(std::vector<gfx::basic_vertex> &out, float quality)
glm::vec3 TSegment::get_nearest_point(const glm::dvec3 &point, float quality) const
{
float step = 1.0f / iSegCount / quality;
float x;
int const stepcount = static_cast<int>(iSegCount * quality);
glm::vec3 nearest;
float min = std::numeric_limits<float>::max();
for (x = step; x <= 1.0f; x += step) {
for (int i = 1; i <= stepcount; ++i) {
float const x = std::min(1.0f, i * step);
glm::vec3 p1 = FastGetPoint(x);
glm::vec3 p2 = FastGetPoint(glm::min(1.0f, x + step));

View File

@@ -3719,7 +3719,9 @@ void TTrack::build_sleeper_transforms()
auto const expected = static_cast<std::size_t>( std::max( 0.0, ( length - start ) / spacing ) ) + 1u;
m_sleeper_local_transforms.reserve( m_sleeper_local_transforms.size() + expected );
for( double s = start; s < length; s += spacing ) {
for( std::size_t sleeperidx = 0;; ++sleeperidx ) {
auto const s = start + static_cast<double>( sleeperidx ) * spacing;
if( s >= length ) { break; }
glm::dvec3 pos;
glm::vec3 angles;
segment->RaPositionGet( s, pos, angles );