From 4ab68334420edd5ab362e0c7b5252b9f0a8c064a Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Mon, 26 Aug 2024 14:00:13 +0200 Subject: [PATCH 1/2] Document coding standards Adds documentation explaining the coding standards to follow. Co-authored-by: F1F7Y <64418963+F1F7Y@users.noreply.github.com> --- README.md | 2 ++ STANDARDS.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 STANDARDS.md diff --git a/README.md b/README.md index 80be8fd0f..648122010 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,6 @@ Check [BUILD.md](BUILD.md) for instructions on how to compile, you can also down ## Format +For project coding standards check out [STANDARDS.md](STANDARDS.md). + This project uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html), make sure you run `clang-format -i --style=file --exclude=primedev/include primedev/*.cpp primedev/*.h` when opening a Pull Request. Check the tool's website for instructions on how to integrate it with your IDE. diff --git a/STANDARDS.md b/STANDARDS.md new file mode 100644 index 000000000..d2eca8887 --- /dev/null +++ b/STANDARDS.md @@ -0,0 +1,49 @@ +# Code standards + +There are exceptions, ask for them! + +### General rules + +> Basic rules that apply all the time. + +Always assert your assumptions! + +Use PascalCase for all names. + +Suffix structs with `_t`. + +Prefix classes with `C` (class) and `I` (abstract class). + +Prefix all class member variables with `m_`. + +Prefixes `g_` for global variables and `s_` for static variables are welcome. + +For hooking we use `o_` for function pointers pointing to the original implementation and `h_` for functions we replace them with. + +Document all function implementations and their arguments (if the argument is self explanatory you don't need to document it) valve style: +``` +//----------------------------------------------------------------------------- +// Purpose: MH_MakeHook wrapper +// Input : *ppOriginal - Original function being detoured +// pDetour - Detour function +// Output : true on success, false otherwise +//----------------------------------------------------------------------------- +``` + +Don't overcomment your code unless nescessary, expect the reader to have limited knowledge. + +Use `FIXME` comments for possible improvements/issues, `NOTE` for important information one might want to look into. + +### Valve source files + +> Rules that apply to all files from original valve code base. + +When adding or just modifying a file that's present in valve source place it where valve put it. + +Always use hungarian notation in these files. + +### New files + +> Rules that apply to Respawn or our own files. + +When adding new files follow the general rules, you don't have to use hungarian notation. Put the file where you think it makes the most sense. From b431248dcd6c0fbe54646c6895be89e2faa79d1e Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Mon, 26 Aug 2024 14:33:03 +0200 Subject: [PATCH 2/2] docs: Add preamble text in regards to reformatting existing code Co-authored-by: F1F7Y <64418963+F1F7Y@users.noreply.github.com> --- STANDARDS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/STANDARDS.md b/STANDARDS.md index d2eca8887..89d365238 100644 --- a/STANDARDS.md +++ b/STANDARDS.md @@ -2,6 +2,10 @@ There are exceptions, ask for them! +### Preamble + +You are more than welcome to reformat any existing files using these rules should they fail to match them but please SPLIT your formatting changes from the rest by making a separate PR! + ### General rules > Basic rules that apply all the time.