Add CONTRIBUTING.md, update coding guidelines

This commit is contained in:
LagoLunatic
2026-08-23 14:29:44 -04:00
parent 85047b9356
commit 4caa5d8fc4
4 changed files with 29 additions and 8 deletions
+19 -7
View File
@@ -6,13 +6,25 @@ Naming variables properly isn't required to help with the decompilation. You can
## Table of Contents
1. [Primitive types](#primitive-types)
2. [Offsets and padding](#offsets-and-padding)
3. [Includes](#includes)
4. [Naming style](#naming-style)
5. [Use the official names where possible](#use-the-official-names-where-possible)
6. [Resource archive enums](#resource-archive-enums)
7. [Look at the actor's model](#look-at-the-actors-model)
1. [Avoid Ghidra-isms](#avoid-ghidra-isms)
2. [Primitive types](#primitive-types)
3. [Offsets and padding](#offsets-and-padding)
4. [Includes](#includes)
5. [Naming style](#naming-style)
6. [Use the official names where possible](#use-the-official-names-where-possible)
7. [Resource archive enums](#resource-archive-enums)
8. [Look at the actor's model](#look-at-the-actors-model)
## Avoid Ghidra-isms
Try to avoid directly copy-pasting code from Ghidra without cleaning it up. Ghidra tends to produce strange code that humans wouldn't write. Some common examples include:
- Assigning to variables inside of `if` statements using the comma operator instead of creating multiple nested `if` statements
- Always using `} else { if {` instead of `} else if {`, creating excessive indentation levels
- Placing excessive unnecessary parentheses around conditions in complex if statements, even when the code would be logically equivalent without them
- Copying the value of a variable to a second variable and checking the second variable, instead of just checking the first variable directly
These make the code harder for a human to read, and occasionally they can even affect how the code matches in subtle ways (e.g. regalloc).
## Primitive types
+3 -1
View File
@@ -4,6 +4,8 @@ This document describes the basics how to start decompiling code and contributin
If you haven't already, you should first follow the instructions in the [readme](../README.md) to get the decomp set up, as well as the tools you will be using to work on it: objdiff and Ghidra.
You should also read the [coding guidelines page](coding_guidelines.md) page to ensure that the code you write is clear and readable.
## Table of Contents
1. [Choosing an object to decompile](#choosing-an-object-to-decompile)
@@ -689,4 +691,4 @@ Then you can just submit a pull request as-is instead of worrying about it any m
Once an actor is fully decompiled, you can start naming some of its member variables if you want to. This is completely optional - it's normal to submit a PR without documenting most fields. Leaving them unnamed (e.g. `field_0x290`) is preferable to coming up with wrong names if you aren't sure.
But if you do decide to start naming things, you should check out the [coding guidelines page](coding_guidelines.md).
But if you do decide to start naming things, you should check out the ['Naming style' section of the coding guidelines page](coding_guidelines.md#naming-style).