Project

General

Profile

Actions

Bug #1676

open

hitpoints = 0 in units.ruleset causes divide by 0 crash

Added by Dean Brown about 1 month ago. Updated 8 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Server
Target version:
Start date:
09/08/2025
Due date:
% Done:

0%

Estimated time:

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

1676_S3_3_Main.patch (3.85 KB) 1676_S3_3_Main.patch Dean Brown, 09/13/2025 11:44 PM
1676_S3_2.patch (3.8 KB) 1676_S3_2.patch Dean Brown, 09/13/2025 11:44 PM
Actions #1

Updated by Dean Brown about 1 month ago

  • File 1676.patch added

Patch should be good for all branches.

Actions #2

Updated by Marko Lindqvist about 1 month 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.

Actions #3

Updated by Marko Lindqvist about 1 month ago

secfile_lookup_int_default_min_max() would be your friend.

Actions #4

Updated by Dean Brown about 1 month ago

  • File deleted (1676.patch)
Actions #5

Updated by Dean Brown about 1 month ago

  • File 1676_S3_2.patch added
  • File 1676_S3_3_Main.patch added

Agree, better to fix the cause instead of the symptom.

Actions #6

Updated by Marko Lindqvist 26 days 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.

Actions #7

Updated by Dean Brown 25 days ago

  • File deleted (1676_S3_2.patch)
Actions #8

Updated by Dean Brown 25 days ago

  • File deleted (1676_S3_3_Main.patch)

Updated by Dean Brown 25 days ago

I wasn't sure about what max value to set, thanks for the suggestion. Updated the patches.

Actions #10

Updated by Marko Lindqvist 8 days ago

  • Category changed from client-common to Server
  • Target version set to 3.2.2
Actions

Also available in: Atom PDF