View Single Post
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-06-2009 , 10:15   Re: Weapon Lights * Updated v0.6 (03-Feb-2009)
Reply With Quote #22

Detagging this is unnecessary:
Code:
enum _:Coord_e{ Float:x, Float:y, Float:z };

Instead, just tag the variable that uses it.

This is extra code that will be loaded into memory which is unnecessary:
Code:
return (get_pdata_int (i_WeaponIndex, m_iSilencerFireMode, EXTRAOFFSET_WEAPONS ) & M4A1_SILENCED);

Instead, make a variable which defaults to the get_pdata_int() call, then in the switch statement, run the & operator on it with M4A1_SILENCED or USP_SILENCED. You can then simply return that value after the switch or add a default statement which returns 0.

Code:
#define MAX_WEAPONS 30 #define NOT_GUNS_BITSUM (1 << CSW_HEGRENADE | 1 << CSW_SMOKEGRENADE | 1 << CSW_FLASHBANG | 1 << CSW_KNIFE | 1 << CSW_C4)
v

Bad form. Define everything at the top.

Code:
gi_Red

If you consider this Hungarian notation, it is bad form. The proper form would be:

Code:
g_iRed

This would be similar for all other variables.

Code:
    RegisterHamsPrimaryAttack ();

This is unnecessary redirection. Just run this function in plugin_init() since it's only called once. A C++ compiler would optimize this out by inlining it but the Pawn compiler is stupid and won't. You may also consider removing the call to CacheCvarsValue() since it will be called a few seconds after plugin_init() anyway on round start.

Code:
    switch (get_pdata_int (i_WeaponIndex, m_iWeaponType, EXTRAOFFSET_WEAPONS))     {     case CSW_M4A1 : return (get_pdata_int (i_WeaponIndex, m_iSilencerFireMode, EXTRAOFFSET_WEAPONS ) & M4A1_SILENCED);     case CSW_USP : return (get_pdata_int (i_WeaponIndex, m_iSilencerFireMode, EXTRAOFFSET_WEAPONS ) & USP_SILENCED);     case CSW_TMP : return 1;     }     return 0;

Bad indentation. Indent the case statements by one more tab.

All-in-all, this plugin is pretty well done. I noticed the indentation in the previous problem and automatically assumed it probably had other problems, but reading over it again I would have put "This plugin is well done."
__________________
Hawk552 is offline
Send a message via AIM to Hawk552