Ok, so I've finished a code review on the patch
I updated to the patch to apply to r10084, and added two fixes as part of that:
1) Minor update to code/object/object.cpp:148 (new code added as part of converting struct object to a class)
2) Minor update to code/ship/ship.cpp:2524 (gcc failed to compile, changed the SCP_string to the const char * in the Warning())
(both these are included in the attached patch)
Also note that I haven't run any tests with models that include the new shieldpoints, I don't know my way around PCS2 well enough to add them, and I figure that the FotG team has already tested this extensively.
Now, my questions/comments about the patch:
(1)
hull_hit_index used to be set to the same value as the number of quadrants. (i.e. #define HULL_HIT_OFFSET 4)
With the patch it's set to one less than the number of quadrants. I think this means that the last point shield quadrant will be treated as being the hull? e.g. for flashing the escort list, or the ship shields icon? (see the linked mission for a test case)
This would also affect shield_info_reset() / NUM_SHIELD_HIT_MEMBERS (originally 5)
(2)
It could be more robust to move "Assert(objp->type == OBJ_SHIP);" to be prior to creating *shipp in hud_augment_shield_quadrant()?
(3)
I don't think the added comparison here will have any effect:
hud_shield_show_mini() ~line 409
- if ( objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f ) {
+ if ( Quadrant_xlate[i] > objp->n_quadrants || objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f ) {
Quadrant_xlate[ i ] will never be greater than objp->n_quadrants:
n_quadrants = 1, MAX Quadrant_xlate = 1
n_quadrants = 2, MAX Quadrant_xlate = 1
n_quadrants = 3, MAX Quadrant_xlate = 2
n_quadrants = 4, MAX Quadrant_xlate = 3
I guess the intent is to avoid accessing beyond the vector size, perhaps it should be >= instead of >?
(4)
In HudGaugeShield::showShields(), it seems that ships with SIF2_SHIELD_POINTS will draw a shield quadrant/section even if it has been reduced to zero? (I'd guess that it would be faint, but still there)
i.e. there's no equivalent to this for ships with SIF2_SHIELD_POINTS
- if ( objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f ) {
+ if ( !(sip->flags2 & SIF2_SHIELD_POINTS) && objp->shield_quadrant[Quadrant_xlate[i]] < 0.1f ) {
continue;
}
(5)
I think the LUA shields type will be partly broken for any ships that use model shield points. It's hardcoded to expect 4 quadrants. I'm not sure of the best way to fix this, given that the quadrants are all hardcoded in the big LUA enumerations array.
ade_obj<object_h> l_Shields("shields", "Shields handle");
Anyway, let me know what you think about these questions/comments.
New patch:
http://www.mediafire.com/download/nk4bckkk1rj8q22/model_point_shields_v2-svn.patch (apologies, my version of SVN is old and doesn't alphabetically order the files in the patch)
Test mission for point 1:
http://www.mediafire.com/view/yenhdxfq9o86y1s/hull_idx_tst.fs2 (with thanks to Yarn for the original mission)