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

Particle man removes more particles than expected #169

Closed
FreeSlave opened this issue Sep 18, 2022 · 2 comments
Closed

Particle man removes more particles than expected #169

FreeSlave opened this issue Sep 18, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@FreeSlave
Copy link
Contributor

I've made a test branch master...FreeSlave:halflife-updated:particleman-test

It draws a particle in front of the player every 0.2 seconds, and each particle lives for 1 second, but it looks like after the one second not only the first spawned particle is getting deleted, but also all other particles. I suspect something wrong with deletion code.

@FreeSlave
Copy link
Contributor Author

FreeSlave commented Sep 18, 2022

Looks like the problem is in this line https://github.com/SamVanheer/halflife-updated/blob/603b2f7c1568c66208bb5e31bf6235556fbad1c8/cl_dll/particleman/CMiniMem.cpp#L45

It erases the range instead of the one element.

@FreeSlave FreeSlave changed the title Particle man removes particles when it's not expected Particle man removes more particles than expected Sep 18, 2022
@SamVanheer
Copy link
Collaborator

Looks like i wrote it like i was writing the erase-remove idiom. I'll make it remove only the particle being removed.

For future reference, test code to confirm this behavior:

gEngfuncs.pfnAddCommand("test_particles",
	[]() {
		auto player = gEngfuncs.GetLocalPlayer();

		auto origin = player->origin;

		Vector forward;
		AngleVectors(player->angles, forward, nullptr, nullptr);

		auto model = gEngfuncs.CL_LoadModel("sprites/blood.spr", nullptr);

		for (int i = 0; i < 10; ++i)
		{
			auto particle = g_pParticleMan->CreateParticle(origin + forward * 64 + Vector(0, 0, 8 * i), g_vecZero, model, 32, 255, "test_particle");

			particle->m_flDieTime = gEngfuncs.GetClientTime() + 5 * ((10 - i) + 1);
		}
	});

Added to Initialize.

@SamVanheer SamVanheer self-assigned this Sep 18, 2022
@SamVanheer SamVanheer added the bug Something isn't working label Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants