Group action timer API internal functions together

develop
Tachytaenius 2022-11-23 13:20:22 +00:00
parent e93d7eefb3
commit 5e0c0d22cb
1 changed files with 20 additions and 20 deletions

@ -2016,6 +2016,26 @@ void subtractActionTimerCore(df::unit_action *action, int32_t amount)
}
}
void multiplyActionTimerCore(df::unit_action *action, float amount)
{
int32_t *timer = getActionTimerPointer(action);
if (timer != nullptr && *timer != 0) {
double value = *timer;
value = max(value * amount, 1.0);
if (value > INT32_MAX) {
value = INT32_MAX;
}
*timer = value;
}
}
void setActionTimerCore(df::unit_action *action, int32_t amount) {
int32_t *timer = getActionTimerPointer(action);
if (timer != nullptr && *timer != 0) {
*timer = amount;
}
}
void Units::subtractActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
{
CHECK_NULL_POINTER(unit);
@ -2039,19 +2059,6 @@ void Units::subtractCategoryActionTimers(df::unit *unit, int32_t amount, df::uni
}
}
void multiplyActionTimerCore(df::unit_action *action, float amount)
{
int32_t *timer = getActionTimerPointer(action);
if (timer != nullptr && *timer != 0) {
double value = *timer;
value = max(value * amount, 1.0);
if (value > INT32_MAX) {
value = INT32_MAX;
}
*timer = value;
}
}
void Units::multiplyActionTimer(df::unit *unit, float amount, df::unit_action_type affectedActionType)
{
CHECK_NULL_POINTER(unit);
@ -2075,13 +2082,6 @@ void Units::multiplyCategoryActionTimers(df::unit *unit, float amount, df::unit_
}
}
void setActionTimerCore(df::unit_action *action, int32_t amount) {
int32_t *timer = getActionTimerPointer(action);
if (timer != nullptr && *timer != 0) {
*timer = amount;
}
}
void Units::setActionTimer(df::unit *unit, int32_t amount, df::unit_action_type affectedActionType)
{
CHECK_NULL_POINTER(unit);