10 #ifndef COMPANY_MANAGER_FACE_H
11 #define COMPANY_MANAGER_FACE_H
32 enum CompanyManagerFaceVariable {
59 uint8_t valid_values[GE_END];
66 { 0, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
67 { 1, 2, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
68 { 0, 3, { 4, 4, 4, 4 }, { 0, 0, 0, 0 } },
69 { 3, 1, { 2, 0, 2, 0 }, { 0, 0, 0, 0 } },
70 { 3, 1, { 0, 2, 0, 2 }, { 0, 0, 0, 0 } },
71 { 4, 1, { 2, 2, 2, 2 }, { 0, 0, 0, 0 } },
72 { 5, 2, { 3, 3, 1, 1 }, { 0, 0, 0, 0 } },
73 { 0, 0, { 1, 1, 1, 1 }, { 0x325, 0x326, 0x390, 0x3B0 } },
74 { 7, 2, { 4, 1, 2, 2 }, { 0x327, 0x327, 0x391, 0x3B1 } },
75 { 9, 4, { 12, 16, 11, 16 }, { 0x32B, 0x337, 0x39A, 0x3B8 } },
76 { 13, 2, { 3, 0, 3, 0 }, { 0x367, 0, 0x397, 0 } },
77 { 13, 4, { 12, 10, 9, 9 }, { 0x35B, 0x351, 0x3A5, 0x3C8 } },
78 { 17, 3, { 8, 4, 4, 5 }, { 0x349, 0x34C, 0x393, 0x3B3 } },
79 { 20, 4, { 9, 5, 5, 5 }, { 0x382, 0x38B, 0x3D4, 0x3D9 } },
80 { 24, 2, { 3, 3, 3, 3 }, { 0x36B, 0x378, 0x36B, 0x378 } },
81 { 26, 2, { 4, 4, 4, 4 }, { 0x36E, 0x37B, 0x36E, 0x37B } },
82 { 28, 3, { 6, 3, 6, 3 }, { 0x372, 0x37F, 0x372, 0x3D1 } },
83 { 31, 1, { 2, 2, 2, 2 }, { 0x347, 0x347, 0x3AE, 0x3AE } }
98 assert(
_cmf_info[cmfv].valid_values[ge] != 0);
113 assert(val <
_cmf_info[cmfv].valid_values[ge]);
135 if (val >=
_cmf_info[cmfv].valid_values[ge]) {
137 }
else if (val < 0) {
166 assert(val < (1U <<
_cmf_info[cmfv].length));
185 for (CompanyManagerFaceVariable cmfv = CMFV_EYE_COLOUR; cmfv < CMFV_END; cmfv++) {
188 if (cmfv != CMFV_MOUSTACHE || is_moust_male) {
208 cmf = randomizer.
Next();
234 assert(
_cmf_info[cmfv].valid_values[ge] != 0);
Functions related to bit mathematics.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
GenderEthnicity
The gender/race combinations that we have faces for.
@ GE_BM
A male of African origin (black)
@ GE_WF
A female of Caucasian origin (white)
@ GE_WM
A male of Caucasian origin (white)
@ ETHNICITY_BLACK
This bit set means black, otherwise white.
@ GE_BF
A female of African origin (black)
@ GENDER_FEMALE
This bit set means a female, otherwise male.
void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer)
Make a random new face.
void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
Scales all company manager's face bits to the correct scope.
void DrawCompanyManagerFace(CompanyManagerFace face, Colours colour, const Rect &r)
Draws the face of a company manager's face.
uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
Scales a company manager's face bits variable to the correct scope.
uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge)
Make sure the table's size is right.
bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Checks whether the company manager's face bits have a valid range.
static const CompanyManagerFaceBitsInfo _cmf_info[]
Lookup table for indices into the CompanyManagerFace, valid ranges and sprites.
void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge, uint val)
Sets the company manager's face bits for the given company manager's face variable.
void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount)
Increase/Decrease the company manager's face variable by the given amount.
SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
Gets the sprite to draw for the given company manager's face variable.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Types related to companies.
uint32_t CompanyManagerFace
Company manager face bits, info see in company_manager_face.h.
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Pseudo random number generator.
This file contains all sprite-related enums and defines.
#define lengthof(array)
Return the length of an fixed size array.
Information about the valid values of CompanyManagerFace bitgroups as well as the sprites to draw.
SpriteID first_sprite[GE_END]
The first sprite per gender/ethnicity.
uint8_t length
Number of bits used in the CompanyManagerFace.
uint8_t valid_values[GE_END]
The number of valid values per gender/ethnicity.
uint8_t offset
Offset in bits into the CompanyManagerFace.
Structure to encapsulate the pseudo random number generators.
uint32_t Next()
Generate the next pseudo random number.
Specification of a rectangle with absolute coordinates of all edges.