08.07.2012, 06:23
I tend to layout gamemode projects by seperating the files into folders. The folders symbolize a library or a 'class' of related methods. The rough idea is as follows:
Where variables are declared varies on your laziness. Ideally I believe the variables should be static and declared in their <module>.pwn file (to allow more general variable names without conflicts, and to discourage manipulating a variable outside of it's "module logical domain"). Use of static can cause undeclared variable compile errors due to file-level symbol hiding. This can be resolved by using getter/setter type methods (which are better theoretically)
A core module can be created for stuff that is unique to the gamemode or cannot be classified into a general purpose library.
- <mode>.pwn (Link all the modules together, delegate responsibilities to <module>.pwn)
- <mode>.h (Define your global constants, enumerations and forward functions. Variables)
- version.in (Optional. SVN repository input file, allows for revision numbers to be generated to version.h which <mode>.h can include)
- compile.bat (Optional. Runs some extra compiling procedures such as getting SVN revision number and authors)
- modules\
- modules.def (Optional. Define your scoping definitions here if you like using them, Module1::, Module2:: etc)
- <module>\
- <module>.h (Define your module constants, enumerations and forward functions. Variables)
- <module>.pwn (Your module core logic, written as if it were a library for use by your handler. Variables)
- events.pwn (Custom events/callbacks defined by your module. Code is very specific to the gamemode (messages etc.), generally not able to be re-used.)
- handlers.pwn (Handle SA:MP and other 'external' callbacks using your module)
- scriptfiles\ (List of scriptfiles ready to be dumped on the server)
- something.cfg
- users.db
Where variables are declared varies on your laziness. Ideally I believe the variables should be static and declared in their <module>.pwn file (to allow more general variable names without conflicts, and to discourage manipulating a variable outside of it's "module logical domain"). Use of static can cause undeclared variable compile errors due to file-level symbol hiding. This can be resolved by using getter/setter type methods (which are better theoretically)
A core module can be created for stuff that is unique to the gamemode or cannot be classified into a general purpose library.