|
Author
|
Message
|
|
Veteran Member
|

09-29-2022
, 06:23
Re: [TF2] Merasmus code cleanup
|
#1
|
Here's a review: - You can remove public from non-global forward callbacks such as OnPlayerActivate and Event_DeathPre. It's been a few major versions since that was necessary (SM 1.7, I think?)
- You can simplify the fixed vector initialization:
Code:
float vecc[] = { 1.0, 1.0, 1.5 };
TeleportEntity(k, NULL_VECTOR, NULL_VECTOR, vecc);
You might be able to put the braced initializer directly into TeleportEntity without a tag mismatch; I keep forgetting if that's been fixed in SM 1.11 and don't feel like setting up an environment to test.
- The strings that are part of a set could be moved to an array:
Code:
char HELLFIRE_SOUNDS[][] = {
HELLFIRE,
HELLFIRE2,
HELLFIRE3,
};
Normally I'd suggest putting the strings there directly, but some of them are reused in Command_GetmsRandom.
- I'd suggest using GetURandomInt over GetRandomInt just to avoid depending on the game's own random stream. It looks like you already do that with GetURandomFloat.
- Use guard clauses to return early on failed IsValidEntity checks.
- Rename variables for consistency, but the globals in particular should all have a prefix to make it obvious what scope they have and to minimize the risk of variable shadowing, even though the compiler does warn you about that.
- ParticleIndex should use an entity reference EntIndexToEntRef. You can use the value in most places that accept entity indices. You may also want to use a client-sized array to store that state and ensure that calls to BuildParticle clean up previous particles.
__________________
Last edited by nosoop; 09-29-2022 at 06:24.
|
|
|
|