Raised This Month: $ Target: $400
 0% 

Solved [TF2] Merasmus code cleanup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nosoop
Veteran Member
Join Date: Aug 2014
Old 09-29-2022 , 06:23   Re: [TF2] Merasmus code cleanup
Reply With Quote #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.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 09-29-2022 at 06:24.
nosoop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:03.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode