Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ spcomp -i addons/sourcemod/scripting/include -o addons/sourcemod/plugins/FixSpra

### Best Practices Applied
✅ **Memory Management**: Uses `delete` for StringMaps/ArrayLists instead of `.Clear()`
✅ **Async Operations**: File operations use timers to prevent timeouts
✅ **Async Operations**: Folder scans (`SprayScan`) run on a timer with a per-tick time budget (`SCAN_BUDGET`) and never do file work inside `OnMapEnd`
✅ **StringMaps over Arrays**: Efficient data storage
✅ **Error Handling**: Comprehensive validation and logging
✅ **Performance**: Caching validated files, batched processing
Expand All @@ -109,7 +109,7 @@ spcomp -i addons/sourcemod/scripting/include -o addons/sourcemod/plugins/FixSpra
### Adding New Exploit Detection
1. Update `g_iVal[]` array with new byte patterns
2. Modify `ValFile()` function for new validation logic
3. Add corresponding test cases to `RecursiveSearchDirs()`
3. Add corresponding test cases to `ScanTestFile()`
4. Update `g_hCvarPunish` handling if needed

### Integrating New Banning Systems
Expand All @@ -119,7 +119,8 @@ spcomp -i addons/sourcemod/scripting/include -o addons/sourcemod/plugins/FixSpra
4. Mark natives as optional in `AskPluginLoad2()`

### Performance Optimization
- Monitor `MAX_READ` constant (current: 50 files per batch)
- Tune `SCAN_BUDGET` (current: 2 ms of file work per 0.1 s timer tick) instead of processing a fixed number of files per batch
- Scan file operations use the plain filesystem (`use_valve_fs` false): Valve FS lookups search every game path and cost far more per call
- Use `TIMEOUT_LOG` to prevent log spam (current: 10.0 seconds)
- Cache results in StringMaps to avoid repeated validation
- Use `RequestFrame()` for async operations
Expand Down Expand Up @@ -205,17 +206,16 @@ if( condition_check ) {
1. **Build Failures**: Check the GitHub Actions CI logs for compiler or dependency errors
2. **File Not Found**: Verify `spray_exploit_fixer_path` cvar is correct
3. **Memory Leaks**: Ensure StringMaps are `delete`d, not `.Clear()`ed
4. **Timeouts**: Increase batch size or timer delays for large file sets
4. **Server hitches**: Lower `SCAN_BUDGET`; large folders then take more ticks but each tick stays short

### Debug Logging
- Set `spray_exploit_fixer_log 1` for all activity
- Set `spray_exploit_fixer_msg 1` for console output
- Check `sourcemod/logs/spray_downloads.log` for detailed logs

### Performance Monitoring
- Monitor `g_iTotal` counter in batch processing
- Check `g_fTime` for operation duration in `CmdSprays`
- Watch for script execution timeouts during file operations
- `sm_spray_test` reports the total scan duration when it finishes
- Each `TimerScan` call should stay close to `SCAN_BUDGET`; a single slow file operation can still exceed it

This plugin demonstrates advanced SourcePawn techniques for file validation, async processing, and multi-platform compatibility. Focus on maintaining the security-first approach while ensuring server performance.

Expand All @@ -227,7 +227,7 @@ This plugin demonstrates advanced SourcePawn techniques for file validation, asy
- `.github/workflows/ci.yml` - CI/CD pipeline

### Important Constants
- `MAX_READ = 50` - Files processed per batch
- `SCAN_BUDGET = 0.002` - Seconds of file work per scan timer tick
- `TIMEOUT_LOG = 10.0` - Seconds between duplicate log entries
- `PATH_BACKUP = "backup_sprays"` - Invalid spray storage folder

Expand Down
Loading
Loading