Reduce code duplication in extrinsics-protect-items code

The same checks were being repeated for every damage type; this
sends them through two centralised functions (one for checking
whether an extrinsic blocks a specific instance of item destruction
and one for the enlightenment message), so that new mechanisms of
item destruction prevention will need to change only one point in
the code.
This commit is contained in:
Alex Smith
2023-12-05 04:34:24 +00:00
parent 2d8ba944e1
commit 7ca9951996
5 changed files with 55 additions and 29 deletions

View File

@@ -2524,8 +2524,9 @@ breakobj(
}
/*
* Check to see if obj is going to break, but don't actually break it.
* Return 0 if the object isn't going to break, 1 if it is.
* Check to see if obj (which has just hit hard something at speed, e.g.
* thrown or dropped from height) is going to break, but don't actually
* break it. Return 0 if the object isn't going to break, 1 if it is.
*/
boolean
breaktest(struct obj *obj)