mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix damage wraparound if very high damage (#11872)
This commit is contained in:
parent
85da2e284b
commit
b81948a14c
7 changed files with 10 additions and 8 deletions
|
@ -306,7 +306,7 @@ HitParams getHitParams(const ItemGroupList &armor_groups,
|
|||
const ToolCapabilities *tp, float time_from_last_punch,
|
||||
u16 initial_wear)
|
||||
{
|
||||
s16 damage = 0;
|
||||
s32 damage = 0;
|
||||
float result_wear = 0.0f;
|
||||
float punch_interval_multiplier =
|
||||
rangelim(time_from_last_punch / tp->full_punch_interval, 0.0f, 1.0f);
|
||||
|
@ -320,6 +320,8 @@ HitParams getHitParams(const ItemGroupList &armor_groups,
|
|||
result_wear = calculateResultWear(tp->punch_attack_uses, initial_wear);
|
||||
result_wear *= punch_interval_multiplier;
|
||||
}
|
||||
// Keep damage in sane bounds for simplicity
|
||||
damage = rangelim(damage, -U16_MAX, U16_MAX);
|
||||
|
||||
u32 wear_i = (u32) result_wear;
|
||||
return {damage, wear_i};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue