-
Notifications
You must be signed in to change notification settings - Fork 41
Variable naming convention
Nightinggale edited this page Sep 29, 2019
·
2 revisions
Vanilla has a naming convention of variables. Modders have tried to maintain this as well as add new conventions to new classes, but it's used inconsistently. This page is intended to contain "the official" naming convention.
m_ is used before anything else to indicate that the variable is a member of a class.
prefix | name | example | comments |
---|---|---|---|
c | char | char cFirstCharacter | |
e | enum | UnitTypes eUnit | |
i | integer | int iLength | |
k | info reference | const CvUnitInfo& kUnit = GC.getUnitInfo(eUnit) | No idea why vanilla picked k |
p | pointer | CvUnit* pUnit | |
sz | Cv(W)String | szName | should we split CvString and CvWString? They use 8 and 16 bit chars respectively, hence not fully compatible. |
prefix | name | example | comments |
---|---|---|---|
ai | C style int array | int* aiList = new int[8] | Avoid using. Array classes with internal allocation and range verification code are safer. |
ba_ | BoolArray | BoolArray ba_HasYield(JIT_ARRAY_YIELD) | |
ja_ | JustInTimeArray | YieldArray< int > ja_iYieldCount | Uses the prefix of the template class too, in this case i for int. |
info_ | InfoArray | InfoArray info_FreePromotions | 1-4D write once arrays, optimized for xml data in info classes. |
Vector | Do we have a standard for those? |