Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float does not work correctly #970

Closed
accelerator74 opened this issue Jun 5, 2024 · 2 comments
Closed

float does not work correctly #970

accelerator74 opened this issue Jun 5, 2024 · 2 comments

Comments

@accelerator74
Copy link

accelerator74 commented Jun 5, 2024

The latest sourcemod build 1.12.7140 operations with the float are performed incorrectly:

#include <sdkhooks>

public void OnPluginStart()
{
	for (int i = 1; i <= MaxClients; i++)
	{
		if (IsClientInGame(i))
		{
			SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
		}
	}
}

public void OnClientPutInServer(int client)
{
	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}

Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3])
{
	PrintToChatAll("damage: %f", damage);
	int new_damage = 10000;
	damage += float(new_damage);
	PrintToChatAll("new_damage: %f", damage);
	return Plugin_Changed;
}

Output:

damage: 143.750000
new_damage: -0.000000

The compiler simply does not see operators in inc files.

@accelerator74
Copy link
Author

Also, the compiler stopped complaining about an overflowed array, like this:

char str[10] = "asdasdsadassadadsdas";

The compiler on sm 1.10 reported an error:

error 018: initialization data exceeds declared size

@dvander
Copy link
Member

dvander commented Jun 6, 2024

Thanks, this has been fixed on master.

@dvander dvander closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants