Skip to content

Commit ac59eba

Browse files
committed
get rid of unnecessary #defines
1 parent 216cd78 commit ac59eba

1 file changed

Lines changed: 51 additions & 48 deletions

File tree

Strategic/Assignments.h

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111

1212
// this distinguishes whether we're only looking for patients healable THIS HOUR (those that have been on their assignment
1313
// long enough), or those that will be healable EVER (regardless of whether they're getting healed during this hour)
14-
#define HEALABLE_EVER 0
15-
#define HEALABLE_THIS_HOUR 1
14+
constexpr auto HEALABLE_EVER = 0;
15+
constexpr auto HEALABLE_THIS_HOUR = 1;
1616

1717

1818
// merc collapses from fatigue if max breath drops to this. Can't go any lower!
19-
#define BREATHMAX_ABSOLUTE_MINIMUM 10
20-
#define BREATHMAX_GOTTA_STOP_MOVING 30
21-
#define BREATHMAX_PRETTY_TIRED 50
22-
#define BREATHMAX_CANCEL_COLLAPSE 60
23-
#define BREATHMAX_CANCEL_TIRED 75
24-
#define BREATHMAX_FULLY_RESTED 95
19+
constexpr auto BREATHMAX_ABSOLUTE_MINIMUM = 10;
20+
constexpr auto BREATHMAX_GOTTA_STOP_MOVING = 30;
21+
constexpr auto BREATHMAX_PRETTY_TIRED = 50;
22+
constexpr auto BREATHMAX_CANCEL_COLLAPSE = 60;
23+
constexpr auto BREATHMAX_CANCEL_TIRED = 75;
24+
constexpr auto BREATHMAX_FULLY_RESTED = 95;
2525

2626

27-
#define VEHICLE_REPAIR_POINTS_DIVISOR 10
27+
constexpr auto VEHICLE_REPAIR_POINTS_DIVISOR = 10;
2828

2929
// controls how easily SAM sites are repaired
3030
// NOTE: A repairman must generate a least this many points / hour to be ABLE to repair a SAM site at all!
31-
#define SAM_SITE_REPAIR_DIVISOR 4 // Flugente: changed from 10 to 4
31+
constexpr auto SAM_SITE_REPAIR_DIVISOR = 4; // Flugente: changed from 10 to 4;
3232

3333
// minimum condition at which a destroyed SAM site controller is visible in tactical again
34-
#define MIN_CONDITION_SHOW_SAM_CONTROLLER 20
34+
constexpr auto MIN_CONDITION_SHOW_SAM_CONTROLLER = 20;
3535

3636
// Assignments Defines
3737
enum
@@ -104,42 +104,45 @@ enum
104104
NUM_ASSIGNMENTS,
105105
};
106106

107-
#define IS_DOCTOR(assignment) ((assignment == DOCTOR) || (assignment == FACILITY_DOCTOR))
107+
constexpr auto IS_DOCTOR(int a) -> bool { return a == DOCTOR || a == FACILITY_DOCTOR; };
108+
109+
// Does not include HOSPITAL since mercs are not responsible for their care
110+
constexpr auto IS_PATIENT(int a) -> bool { return IS_DOCTOR(a) || a == PATIENT || a == FACILITY_PATIENT; };
111+
112+
constexpr auto IS_REPAIR(int a) -> bool { return a == REPAIR || a == FACILITY_REPAIR; };
113+
constexpr auto SPY_LOCATION(int a) -> bool { return a == CONCEALED || a == GATHERINTEL; };
114+
115+
// Flugente: does this assignment benefit from other mercs being on administration assignment?
116+
constexpr auto ADMINISTRATION_BONUS(int a) -> bool {
117+
return IS_DOCTOR(a)
118+
|| IS_REPAIR(a)
119+
|| a == TRAIN_SELF
120+
|| a == TRAIN_TOWN
121+
|| a == TRAIN_TEAMMATE
122+
|| a == TRAIN_BY_OTHER
123+
|| a == MOVE_EQUIPMENT
124+
|| a == FACILITY_STAFF
125+
|| a == FACILITY_INTERROGATE_PRISONERS
126+
|| a == FACILITY_SPREAD_PROPAGANDA
127+
|| a == FACILITY_SPREAD_PROPAGANDA_GLOBAL
128+
|| a == FACILITY_STRATEGIC_MILITIA_MOVEMENT
129+
|| a == DISEASE_DIAGNOSE
130+
|| a == DISEASE_DOCTOR_SECTOR
131+
|| a == FORTIFICATION
132+
|| a == TRAIN_WORKERS
133+
|| a == DOCTOR_MILITIA
134+
|| a == DRILL_MILITIA
135+
|| a == BURIAL;
136+
};
137+
108138
// left the last : off so syntax is visually consistent with non-macro case statements
109139
#define CASE_DOCTOR case DOCTOR: case FACILITY_DOCTOR
110140

111-
// Does not include HOSPITAL since mercs are not responsible for their care
112-
#define IS_PATIENT(assignment) ((assignment == DOCTOR) || (assignment == PATIENT) || (assignment == FACILITY_DOCTOR) || (assignment == FACILITY_PATIENT))
113141
// Does not include DOCTOR types because switch cases must be unique
114142
#define CASE_PATIENT case PATIENT: case FACILITY_PATIENT
115143

116-
#define IS_REPAIR(assignment) ((assignment == REPAIR) || (assignment == FACILITY_REPAIR))
117144
#define CASE_REPAIR case REPAIR: case FACILITY_REPAIR
118145

119-
#define SPY_LOCATION(assignment) ((assignment == CONCEALED) || (assignment == GATHERINTEL) )
120-
121-
// Flugente: does this assignment benefit from other mercs being on administration assignment?
122-
#define ADMINISTRATION_BONUS(assignment) ( IS_DOCTOR(assignment) || \
123-
IS_REPAIR(assignment) || \
124-
(assignment==TRAIN_SELF) || \
125-
(assignment==TRAIN_TOWN) || \
126-
(assignment==TRAIN_TEAMMATE) || \
127-
(assignment==TRAIN_BY_OTHER) || \
128-
(assignment==MOVE_EQUIPMENT) || \
129-
(assignment==FACILITY_STAFF) || \
130-
(assignment==FACILITY_INTERROGATE_PRISONERS) || \
131-
(assignment==FACILITY_SPREAD_PROPAGANDA) || \
132-
(assignment==FACILITY_SPREAD_PROPAGANDA_GLOBAL) || \
133-
(assignment==FACILITY_STRATEGIC_MILITIA_MOVEMENT) || \
134-
(assignment==DISEASE_DIAGNOSE) || \
135-
(assignment==DISEASE_DOCTOR_SECTOR) || \
136-
(assignment==FORTIFICATION) || \
137-
(assignment==TRAIN_WORKERS) || \
138-
(assignment==DOCTOR_MILITIA) || \
139-
(assignment==DRILL_MILITIA) || \
140-
(assignment==BURIAL) \
141-
)
142-
143146
// strings for snitch exposition
144147
enum
145148
{
@@ -168,7 +171,7 @@ enum
168171
NUM_SNITCH_GATHERING_RUMOURS_RESULT,
169172
};
170173

171-
#define NO_ASSIGNMENT 127 //used when no pSoldier->ubDesiredSquad
174+
constexpr auto NO_ASSIGNMENT = 127; //used when no pSoldier->ubDesiredSquad;
172175

173176
// Train stats defines (must match ATTRIB_MENU_ defines, and pAttributeMenuStrings )
174177
enum
@@ -251,14 +254,14 @@ BOOLEAN CanCharacterBeAwakened( SOLDIERTYPE *pSoldier, BOOLEAN fExplainWhyNot );
251254
// put character in vehicle?
252255
BOOLEAN CanCharacterVehicle( SOLDIERTYPE *pCharacter );
253256

254-
#define CHARACTER_CANT_JOIN_SQUAD_ALREADY_IN_IT -6
255-
#define CHARACTER_CANT_JOIN_SQUAD_SQUAD_MOVING -5
256-
#define CHARACTER_CANT_JOIN_SQUAD_MOVING -4
257-
#define CHARACTER_CANT_JOIN_SQUAD_VEHICLE -3
258-
#define CHARACTER_CANT_JOIN_SQUAD_TOO_FAR -2
259-
#define CHARACTER_CANT_JOIN_SQUAD_FULL -1
260-
#define CHARACTER_CANT_JOIN_SQUAD 0
261-
#define CHARACTER_CAN_JOIN_SQUAD 1
257+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_ALREADY_IN_IT = -6;
258+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_SQUAD_MOVING = -5;
259+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_MOVING = -4;
260+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_VEHICLE = -3;
261+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_TOO_FAR = -2;
262+
constexpr auto CHARACTER_CANT_JOIN_SQUAD_FULL = -1;
263+
constexpr auto CHARACTER_CANT_JOIN_SQUAD = 0;
264+
constexpr auto CHARACTER_CAN_JOIN_SQUAD = 1;
262265

263266
// can character be added to squad
264267
INT8 CanCharacterSquad( SOLDIERTYPE *pCharacter, INT8 bSquadValue );

0 commit comments

Comments
 (0)