Bug #1676
openhitpoints = 0 in units.ruleset causes divide by 0 crash
0%
Description
Careless rule set hacking strikes again, but there's nothing warning you not to set hitpoints = 0 in units.ruleset, and the ruleset loads OK.
In tilespec.c routine fill_unit_sprite_array()
  ihp = ((NUM_TILES_HP_BAR-1)*punit->hp) / ptype->hp;
Files
Updated by Dean Brown about 2 months ago
- File 1676.patch added
Patch should be good for all branches.
Updated by Marko Lindqvist about 2 months ago
That's unlikely to be the only place where such a zombie (unit dies when it reach 0 HP) causes problems. The fix should be in ruleset sanity checking.
Updated by Marko Lindqvist about 2 months ago
secfile_lookup_int_default_min_max() would be your friend.
Updated by Dean Brown about 2 months ago
- File 1676_S3_2.patch added
- File 1676_S3_3_Main.patch added
Agree, better to fix the cause instead of the symptom.
Updated by Marko Lindqvist about 2 months ago
For rulesets that play excessively with better firepower and hitpoints as game progresses, maximum hp of 100 is rather low upper limit, especially in S3_2 where we should not break any existing rulesets (d3f). I'd say 10000 would be safe value even as such absolute maximum.
Updated by Dean Brown about 2 months ago
- File 1676_S3_2.patch added
- File 1676_S3_3_Main.patch added
I wasn't sure about what max value to set, thanks for the suggestion. Updated the patches.
Updated by Marko Lindqvist about 1 month ago
- Category changed from client-common to Server
- Target version set to 3.2.2
Updated by Marko Lindqvist 20 days ago
You should also make it impossible to set hitpoints to zero (or other illegal value) from the ruledit. Otherwise one may accidentally changes hitpoints to zero, saves the ruleset, and the ruleset load time check makes it impossible to load ruleset back in for fixing the situation.
Updated by Dean Brown 18 days ago
- File 1676_ruledit.patch added
Good point. Turns out there's already code to set limits, just need to change the min value from 0 to 1.
1676_ruledit.patch good for all branches.
Updated by Marko Lindqvist 13 days ago
We don't want to knowingly introduce the bug in the git history, and only separately fix it. Please combine ruledit change with the rest of the patch (single patch for each branch)
Updated by Dean Brown 12 days ago
- File 1676_S3_2.patch 1676_S3_2.patch added
- File 1676_S3_3_Main.patch added
No problem.
Updated by Marko Lindqvist 10 days ago
The patch does not apply to main branch. The same patch does apply for S3_3, so I guess you just need a separate patch for main.
Updated by Dean Brown 9 days ago
- File 1676_S3_3.patch 1676_S3_3.patch added
- File 1676_Main.patch 1676_Main.patch added
no problem
Updated by Marko Lindqvist 8 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist