--- description: C++ plugin and Python server coding standards alwaysApply: true --- # Coding Standards For C++ plugin work: - Prioritise stability and safety over cleverness. - Avoid unsafe game-thread access. - Interact with Fallout 4 runtime objects on the game thread unless clearly safe otherwise. - Use defensive null checks for pointers, actors, cells, worldspaces, forms, and lookup results. - Do not crash the game if a pointer, actor, cell, worldspace, or form lookup fails. - Use throttled logging for repeated runtime events. - Keep logs useful for debugging, but do not spam the log every frame. - Keep networking code separated from game-world manipulation where possible. - Preserve existing behaviour unless the requested change requires modifying it. - Do not make large architecture rewrites unless explicitly requested. - Prefer small, testable milestones. For Python server work: - Keep the server simple and readable. - Preserve unknown JSON fields where possible so the protocol can evolve without breaking older code. - Treat malformed packets as client input errors, not server-fatal errors. - Do not crash the server because of one bad client message. - Preserve backwards compatibility unless specifically requested. - Keep `server/fake_client.py` useful for testing protocol changes. General implementation guidance: - Prefer clear naming over overly abstract systems. - Add TODO comments only where they are genuinely useful. - Do not remove useful debugging logs unless they are too spammy. - Do not remove fallback behaviour or safe defaults.