[Bug]: NormalizeVector returning a false vector length

Abierto
#2,297 3 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
backend

Línea de trabajo

Start with core/smn_vector.cpp, particularly the VectorNormalize call at the linked location, and use the reproduction code to check how NormalizeVector handles a zero vector on the reported CSS version. Compare its returned length and vector with the previous-version results; done means zero input yields a zero length and zero vector without changing the expected behavior for other inputs.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug
Prerequisites
  • I have checked that my issue doesn't exist yet in the issue tracker
Operating System and Version

Debian GNU/Linux 12 (bookworm)

Game / AppID and Version

240 (Latest)

SourceMod Version

1.13.0.7215

Metamod:Source Version

1.12.0-dev+1217

Version Verification
Updated SourceMod Version

1.13.0.7219

Updated Metamod:Source Version

No response

Description

The NormalizeVector function doesn't work correctly with zero vectors in latest CSS versions (64 bit linux).
Instead of returning a zero length and a zero vector, it returns a very small, but incorrect, non-zero length.

This is different from how it behaves in the previous CSS version, where it correctly returns a zero length.

I guess a simple solution would be to implement an explicit check for zero vectors and returning a zero length instead of the VectorNormalize value.

Steps to Reproduce
#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart() 
{
	RegAdminCmd("sm_test", Command_Test, ADMFLAG_ROOT, "Test command ( ͡° ͜ʖ ͡°)");
}

Action Command_Test(int client, int args)
{
	float fAngles[3];
	float fLength = NormalizeVector(fAngles, fAngles);
	ReplyToCommand(client, "Length: %f", fLength);
	return Plugin_Handled;
}
Relevant Log Output
Result (Latest CSS version)
sm_test
Length: 0.000009

Result (Previous CSS version)
sm_test
Length: 0.000000
Lenguaje dominante
C++
Estrellas
1.2k
Forks
476
Merge medio
2 d 9 h
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de alliedmodders/sourcemod

Todos los issues de alliedmodders/sourcemod

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.