the same time… completely confused. Anyway, here's the updated conventions documentation.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5296 c06c8d41-db1a-0410-9941-cceddc491573
HEPDNNSAFGB2AKJIFJEJV3JOMT7ZKE4R64HW3MYNU2V2ZHQ2P4LQC Conditionals------------
B) Logical operators--------------------Conditionals longer than a line should be indented under the starting bracket.This probably seems obvious for simple ifs ...if (!player_in_branch(BRANCH_COCYTUS)&& !player_in_branch(BRANCH_SWAMP)&& !player_in_branch(BRANCH_SHOALS)){_prepare_water( level_number );}... but it should also be followed for else if conditionals.else if (keyin == ESCAPE || keyin == ' '|| keyin == '\r' || keyin == '\n'){canned_msg( MSG_OK );return (false);}Space allowing, logical connectives of different precedence should use nestedindenting.case ABIL_MAPPING: // Gnome + sense surrounds mutif (abil.ability == ABIL_MAPPING&& player_mutation_level(MUT_MAPPING) < 3&& (you.level_type == LEVEL_PANDEMONIUM|| you.level_type == LEVEL_LABYRINTH)){mpr("You feel momentarily disoriented.");return (false);}If a logical connective needs to be distributed over several lines,the conjunction/disjunction operators (&&, ||) should be placed at thebeginning of the new line rather than at the end of the old one.else if (you.mutation[mutat] >= 3&& mutat != MUT_STRONG && mutat != MUT_CLEVER&& mutat != MUT_AGILE && mutat != MUT_WEAK&& mutat != MUT_DOPEY && mutat != MUT_CLUMSY){return false;}Since conjunctions (&&) take precedence over disjunctions (||), pureconjunctive logical connectives don't need to be bracketed, unless this isabsolutely vital for understanding. (Nested indenting helps here.)if (you.skills[SK_ICE_MAGIC] > you.skills[SK_FIRE_MAGIC]|| you.skills[SK_FIRE_MAGIC] == you.skills[SK_ICE_MAGIC]&& you.skills[SK_AIR_MAGIC] > you.skills[SK_EARTH_MAGIC]){book = BOOK_CONJURATIONS_II;}
should be used if the bigger part of statements needs braces for logical reasonsor because of one of the conventions above. Otherwise, theymay be omitted.
should be used if the bigger part of statements needs braces for logicalreasons or because of one of the conventions above. Otherwise, they may beomitted.