Skip to content

Style Guide

Nick edited this page Jul 29, 2017 · 1 revision

Style Guide

These are the general code standards for use in SWAT:Elite Force. It is expected (although not required) that code submitted adheres to these standards.

Whitespace

All indentations should be tabs.

Switch Indentation

Switch cases should be indented, and the code that is inside the case should be indented as well:

    switch (CurrentFireMode)
    {
        case FireMode_Single:
        case FireMode_SingleTaser:
	case FireMode_DoubleTaser:
            break;

        case FireMode_Burst:
            BurstShotsRemaining = BurstShotCount;
            break;

        case FireMode_Auto:
            // MCJ: now set above in PreUse().
            //AutoFireShotIndex = 0;
            //Pawn(Owner).OnAutoFireStarted();
            break;

        default:
            assert(false);  //unexpected FireMode
            break;
    }

Brackets

ALL if, for, while, else, function, etc statements should have brackets, and these brackets should be on a separate line. The brackets are necessary to prevent accidental bugs, and having them on a separate line is much better for readability.

simulated function SetPerfectAimNextShot()
{
    PerfectAimNextShot = true;
}

Comments

Comments describing a function should be short, brief, and take up no more than three lines. They should all be using the inline comment (//). Generally this is the least irritating commenting system.

// Used by the AI - whether firing this weapon will hit its intended target
// (and not, for example, an actor or levelinfo that is in between our target)
simulated function bool WillHitIntendedTarget(Actor Target, bool MomentumMatters, vector EndTrace)

Generally, all comments at the beginning of a code block should be on the same line as their bracket. This is so that the code doesn't take up more space than is needed.

if(Victim.IsA('LevelInfo'))
{ // LevelInfo is hidden AND blocks all bullets!
    return false;
}
Clone this wiki locally