-
Notifications
You must be signed in to change notification settings - Fork 5
Spell duration overflow
Some spells have duration(how much time it lasts). Duration depends on skill. The higher the skill - the longer spell lasts. The longest spell duration known is 4095 seconds. If skill goes higher, then duration starts from 0. This is known as number overflow.
Duration as well as in-game time is stored in tick units which is 1/16th of a game second. Spell duration is calculated and stored as uint_16
. Therefore 4095 seconds corresponds to 65535 ticks. So any time bigger than 4095 seconds doesn't fit into 2 bytes.
If duration is more than 65535 ticks, set it exactly to 65535. So as a result, spell duration is capped to 4095 seconds. You cannot get more than that, but at least it won't overflow.
The actual duration that affects stats, damage or such is calculated on server. The duration shown in client is calculated on client side and may not reflect what server thinks about the duration.
Example of a testing scenario checking fire resist
:
- Dress a unit into magic gear with skill increase(fire). You need to reach 208 skill points for overflow to happen.
- Check you reached duration time longer than 4095. If client is not fixed, it will show low duration ~80 sec.
- Apply the fire resist spell and run stopwatch.
- Make sure fire resist stat increased.
- Monitor the fire stat. Once the spell expired, measure the actual time.
Actual time should be around 4095 sec (1h 8min). Since it is too much to watch a single stat for an hour, it might be better to do steps 1-4, then set the alarm for an hour and 5 mins and watch the stat for the remaining 3 mins. Another thing to keep in mind. The actual real-world time depends on speed setting on server. If speen is 'Normal', then game time corresponds to real-world time. If speed is maximum, game is twice as speed.