-
Notifications
You must be signed in to change notification settings - Fork 82
Coding Guidelines
Marcel de Vries edited this page Jul 12, 2017
·
3 revisions
- Include a NaturalDocs formatted header in your functions
- Use CBA ASSERTS to validate data before progressing
- Ideally for every function, use ASSERTS to validate input parameters and output results
- Use ALIVE_fnc_xxx for your function definitions
- Always use fnc_xxx.sqf for your function file names
- Integrate Test scripts to automate testing inherent to the development process
- When bug fixing, modify the test script first to identify the bug, fix the bug, re-run test script
- CBA_fnc_test for testing frameworks
- Use Object Oriented SQF
- Utilise inheritance/reuse of existing code wherever possible from a parent class using OO
- http://community.bistudio.com/wiki/Biki2.0:Performance_Considerations
- http://community.bistudio.com/wiki/Code_Optimisation
- ACE mod also has some good guides on approach to script scheduler
- Embrace CBA use of Macros
- Embrace CBA use of function wrappers
- CBA_fnc_debug/error/log and associated MACROs for debug level messages
- Avoid execVM/spawn where possible
- Move all initialisation code/messaging into the module directory
- Avoid global variables - if you want to share a variable, use setVariable on a server side game logic as this allows for multiple instances of the same module.
- Wherever possible use stringtable.xml files to facilitate language localisation in future.
-
count
is for counting andforEach
is traversing items in a collection.
- Avoid loops!
- Non critical operations that have a "near" end can be scheduled but critical operations (like animations or things where you need an exact execution) must be handled within one frame.
- It's better to handle code in unscheduled space because you have direct control over it and it isn't impacted by "engine laziness", as in "waiting" for the next operation to happen.
- You know that your code is executed non-scheduled if waituntil and sleep _time; (within the code you want to execute) doesn't work and an appropriate error is logged to RPT!
- If you want to process too much data in one frame or you overload the schedular then the game engine will freeze for a moment, so split the operations over several frames.