A trimmed down and cleaned up version of TFA Base focused on stability and performance: fewer unnecessary hook calls, network operations, and allocations, cleaner module loading, and explicit early returns on heavy code paths.
- Compact loader (
lua/tfa/framework/tfa_loader.lua): singleloadFolder, global cache, deterministic load order for modules/enums/external code. - Ordered ConVars and commands (
lua/tfa/modules/tfa_commands.lua):EnsureReplConVarandCreateReplConVarhelpers eliminate dozens of repeated checks, default clip updates are moved into a dedicated callback. - Optimized hooks (
lua/tfa/modules/tfa_hooks.lua): cachedLocalPlayer/active weapon, early returns if the weapon is not TFA, less work inPlayerTickandPreRender. - Safer netcode (
lua/tfa/modules/tfa_netcode.lua): localizednet.*, player/weapon validity checks before doing anything. - Scope rendering (
lua/tfa/modules/tfa_rendertarget.lua): runs only for TFA weapons, reuses materials/RTs, correctly resets bones. - Sound management (
lua/tfa/modules/tfa_functions.lua): sharedaddSoundhelper, sound patching without duplication, localized references tomath/string/sound. - Attachments (
lua/tfa/modules/tfa_attachments.lua): load order is "base -> everything else", cached inheritance,ProtectedCallaroundTFAAttachmentsLoaded. - Particles and effects (
lua/tfa/modules/tfa_particles*.lua): does not re-add already loaded PCFs, does not recompute offsets without a valid weapon, fewer unnecessary allocations. - Backend (
lua/tfa/modules/tfa_backend.lua): removed HTTP calls to Steam, no-op callbacks instead of network timeouts. - M9K converter (
lua/tfa/modules/tfa_m9conversion.lua): careful owner/data checks, cached math/string, sane defaults without hard assumptions.
- Steam group check removed: functions in
tfa_backend.luareturn immediately. If you need the old group check, you will have to reintroduce it manually. - Automatic resource precache removed:
tfa_precache.luakeeps a directory cache and does not fire off heavy recursion. If needed, callTFA.PrecacheDirectoryfrom your own code. - Scope rendering now runs only for TFA weapons. If you piggybacked a custom SWEP on this logic, you will need to adapt it.
- Fewer global lookups and allocations thanks to localized APIs and shared helpers.
- Early exits on heavy paths (hooks, rendering, precache) so you do not burn frames for no reason.
- No more potential stalls from network or disk operations (Steam HTTP, massive startup precache).
- Cleaner module structure that is easier to maintain and extend.
- Copy the entire
tfa base optimizedfolder as an addon (the folder name can be anything, for exampletfa_base_optimized). - Make sure there is no other TFA Base version in addons. The loader will stop if it detects conflicting versions.
- If your server needs specific ConVars, add them to your config - most of them are already created automatically.
- For manual precache, when needed, use
TFA.PrecacheDirectory(path, type)(type:mat/mdl/sndor empty for auto detection).
- If you want to bring back Steam group network checks or auto precache, add them in surgically so you do not lose performance in the rest of the code.
- When extending functionality, stick to the principles of this build: localize your APIs, validate early, and avoid blocking operations in hooks.