12 #ifndef COMPANY_MANAGER_FACE_H 13 #define COMPANY_MANAGER_FACE_H 34 enum CompanyManagerFaceVariable {
61 byte valid_values[GE_END];
68 { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
69 { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
70 { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } },
71 { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } },
72 { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } },
73 { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
74 { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } },
75 { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } },
76 { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } },
77 { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } },
78 { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } },
79 { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } },
80 { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } },
81 { 20, 4, { 9, 5, 5, 5 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } },
82 { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } },
83 { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } },
84 { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } },
85 { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } }
100 assert(_cmf_info[cmfv].valid_values[ge] != 0);
102 return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
115 assert(val < _cmf_info[cmfv].valid_values[ge]);
117 SB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length, val);
137 if (val >= _cmf_info[cmfv].valid_values[ge]) {
139 }
else if (val < 0) {
155 return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length) < _cmf_info[cmfv].
valid_values[ge];
168 assert(val < (1U << _cmf_info[cmfv].length));
170 return (val * _cmf_info[cmfv].valid_values[ge]) >> _cmf_info[cmfv].
length;
187 for (CompanyManagerFaceVariable cmfv = CMFV_EYE_COLOUR; cmfv < CMFV_END; cmfv++) {
190 if (cmfv != CMFV_MOUSTACHE || is_moust_male) {
212 cmf = interactive ? InteractiveRandom() : Random();
238 assert(_cmf_info[cmfv].valid_values[ge] != 0);
240 return _cmf_info[cmfv].
first_sprite[ge] +
GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
A female of Caucasian origin (white)
assert_compile(lengthof(_cmf_info)==CMFV_END)
Make sure the table's size is right.
This bit set means a female, otherwise male.
A male of African origin (black)
Functions related to bit mathematics.
Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw...
A male of Caucasian origin (white)
byte length
Number of bits used in the CompanyManagerFace.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Pseudo random number generator.
static const CompanyManagerFaceBitsInfo _cmf_info[]
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
void DrawCompanyManagerFace(CompanyManagerFace face, int colour, int x, int y)
Draws the face of a company manager's face.
uint32 CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
byte valid_values[GE_END]
The number of valid values per gender/ethnicity.
static void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, bool interactive=true)
Make a random new face.
static void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount)
Increase/Decrease the company manager's face variable by the given amount.
static void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Sets the company manager's face bits for the given company manager's face variable.
#define lengthof(x)
Return the length of an fixed size array.
static uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Scales a company manager's face bits variable to the correct scope.
static SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the sprite to draw for the given company manager's face variable.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Checks whether the company manager's face bits have a valid range.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
SpriteID first_sprite[GE_END]
The first sprite per gender/ethnicity.
byte offset
Offset in bits into the CompanyManagerFace.
This bit set means black, otherwise white.
Types related to companies.
static void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
Scales all company manager's face bits to the correct scope.
GenderEthnicity
The gender/race combinations that we have faces for.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
A female of African origin (black)
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
static uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the company manager's face bits for the given company manager's face variable.
This file contains all sprite-related enums and defines.