|
R-Type 0.1
|
These rules keep the code base consistent. When in doubt, follow the code around you.
make format before committing and do not format by hand.#pragma once.| Element | Style | Example |
|---|---|---|
| Classes and structs | PascalCase | NetworkServer, SnapshotPayload |
| Functions and methods | camelCase | sendSnapshot(), pollInput() |
| Local variables and parameters | camelCase | connectionId |
| Private data members | Underscore then camelCase | _connections, _running |
| Public data members | camelCase, no prefix | networkId, actionMask |
| Constants | UPPER_SNAKE_CASE | MAX_PAYLOAD_SIZE, HEADER_SIZE |
| Enum values | PascalCase | MessageType::CreateEntity |
| Namespaces | Lowercase | rtk, rtype::server |
| JSON builders | Component name then FromJson | transformFromJson() |
Namespaces show where code belongs: rtk for the generic engine, rtype for the game, rtype::protocol for the wire format, rtype::client and rtype::server for each program.
get_components<T>().get(entity), and always check them.std::unique_ptr or containers.final.const, and functions whose result must be used [[nodiscard]].bool and leave their output untouched on failure.using namespace in headers.xxxFromJson() builder.dt. Every speed and timer is multiplied by the elapsed time of the frame.lib/ may include code from src/, the graphical library or game assets.kill_entity(). Never erase an entity while another system may iterate over it.static_assert on their size.Every public class, struct, function, method, enum value and public data member has a Doxygen comment. Private members used only by the implementation are not documented.
/** ... */ blocks with @brief, one short sentence.@param per parameter and a @return when there is a value, each one short sentence.///< after a field or an enum value for a one line description.namespace ... { line and close it before the matching }. Declarations outside any namespace are wrapped the same way, right after #pragma once.| Folder | Group |
|---|---|
lib/GameEngine | api_engine |
lib/Network | api_network |
src/Common/Protocol | api_protocol |
src/Common (other files) | api_gameplay |
src/Client | api_client |
src/Server | api_server |
lib/GameEngine/include, by kind: components, systems, events.lib/Network/src.src/Common.assets/descriptionEntity as JSON, never in C++.