Lynx: "You can destroy an upper arm, and the gun pod is intact and can still fire." Conn Man's audit: three chassis, both arms, reproducible. And the user is right that this family was claimed fixed before: #86 gated fire on the WEAPON's own destruction and was verified by destroying the weapon directly (BT_KILL_SUBSYS) -- the field scenario was the ARM ZONE dying with the weapon subsystem healthy, which that bench never reproduced. Oracle's 693-night "I can still fire destroyed energy weapons" was almost certainly this mechanism. ROOT CAUSE -- a silent stub. Mech__DamageZone::RecurseSegmentTable @0049cad4 was transcribed faithfully... against three local shim types whose iterators unconditionally return NULL: struct SegmentIterator { DZRef *Next() { return 0; } }; struct SegTableX { SegmentRecord *operator[](int) { return 0; } }; The cascade fired on zone death (bench: 72 [cascade] lines), "descended", and touched nothing. Every line read correct; none of it did anything. THE REAL WALK (decomp re-read, FUN_0049cad4): iterate the mech's segment table (mech+0x300, vtbl+0x34 GetNth) to this zone's segment, then destroySiblingsOnDestruction (Wword 0x68): recurse every other zone on the SAME segment (seg+0xD0), setting graphic state 2 (Gone) descendOnDestruction (Wword 0x67): recurse every zone on every CHILD segment (seg+0xE8 -> child+0xD0) -- the arm takes the gun The engine ALREADY HAS both structures: EntitySegment::damageZoneTable @0xD0 / childIndexTable @0xE8 (TableOf is 0x18 -- byte-identical to the decomp offsets), populated at stream time by JMOVER.cpp:373 [T0]. The stub was never necessary. Implemented with the engine iterators via two new read accessors on EntitySegment (SEGMENT.h); the binary's asymmetry is reproduced as-is (the sibling loop checks graphic state != 1, the child loop does not; re-hits on a 1.0 zone re-run the cascade -- idempotent in effect). VERIFIED (ava1, self-damage to one zone, autofire everything): dz_rarm -> [cascade] zone 9 -> zone 17; AFC100 + AmmoBinAFC100 + Condenser6 ForceCriticalFailure'd; "[ammo] AFC100 -> NoAmmo (gate1): destroyed=1"; torso LRM5/SRM2 keep firing (correct) dz_larm -> [cascade] zone 2 -> zone 6; PPC + Condenser4 force-failed; "[emitter] 'PPC' fire REFUSED (destroyed=1)" x4998 -- the emitter gate now logs refusals BY NAME (the FIRED line never named its weapon, which is how #86's verification gap survived) regression smoke: frame time 7.13/7.20ms, 0 asserts, 0 cascades in ordinary combat (they fire only on genuine zone deaths) Authored data (now dumped under BT_DMG_LOG): descend=1 on exactly the four arm zones (ava1: 2/6/9/17), destroySibs=0 everywhere -- so legs/torso behavior is untouched by this change. KB: combat-damage.md cascade section; reconstruction-gotchas #26 (the silent-stub trap: a shim that returns EMPTY converts a reconstruction into fiction that reads correct -- shims must Fail() loudly or log their emptiness). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
251 lines
5.4 KiB
C++
251 lines
5.4 KiB
C++
#pragma once
|
|
|
|
#include "table.h"
|
|
#include "linmtrx.h"
|
|
#include "cstr.h"
|
|
#include "vchain.h"
|
|
|
|
class DamageZone;
|
|
class Joint;
|
|
class JointedMover;
|
|
|
|
//##########################################################################
|
|
//##################### Segment::VideoObjectNames ##########################
|
|
//##########################################################################
|
|
|
|
class EntitySegment__VideoObjectNames :
|
|
public Plug
|
|
{
|
|
public:
|
|
CString*
|
|
GetVideoObjectName(Enumeration damage_graphic_state);
|
|
|
|
void
|
|
AddVideoObjectName(
|
|
const CString &new_name,
|
|
Enumeration damage_graphic_state
|
|
);
|
|
|
|
|
|
EntitySegment__VideoObjectNames();
|
|
~EntitySegment__VideoObjectNames();
|
|
|
|
protected:
|
|
|
|
typedef PlugOf<CString> CStringPlug;
|
|
|
|
typedef VChainOf<CStringPlug*, Enumeration>
|
|
VideoObjectNamesSocket;
|
|
|
|
VideoObjectNamesSocket videoObjectNames;
|
|
};
|
|
|
|
//##########################################################################
|
|
//########################## Segment ###############################
|
|
//##########################################################################
|
|
|
|
class EntitySegment :
|
|
public Plug
|
|
{
|
|
friend class JointedMover;
|
|
|
|
public:
|
|
typedef EntitySegment__VideoObjectNames VideoObjectNames;
|
|
typedef TableOf<EntitySegment*, int> SegmentTable;
|
|
typedef TableIteratorOf<EntitySegment*, int> SegmentTableIterator;
|
|
typedef PlugOf<int> IntegerPlug;
|
|
typedef TableOf<IntegerPlug*, int> IntegerTable;
|
|
typedef TableIteratorOf<IntegerPlug*, int> IntegerTableIterator;
|
|
|
|
enum SkeletonType {
|
|
SkeletonType_N, // Exterior
|
|
SkeletonType_S, // Interior
|
|
SkeletonType_T,
|
|
SkeletonType_O,
|
|
SkeletonType_A,
|
|
SkeletonType_B,
|
|
SkeletonType_C,
|
|
SkeletonType_D,
|
|
SkeletonTypeCount
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Segment Data
|
|
//
|
|
protected:
|
|
Logical
|
|
segmentModified,
|
|
siteSegment;
|
|
|
|
LinearMatrix
|
|
segmentToParent,
|
|
segmentToEntity,
|
|
baseOffset;
|
|
|
|
typedef PlugOf<CString> CStringPlug;
|
|
typedef TableOf<VideoObjectNames*, Enumeration> VideoObjectTable;
|
|
typedef TableIteratorOf<VideoObjectNames*, Enumeration> VideoTableIterator;
|
|
|
|
VideoObjectTable
|
|
videoObjectTable;
|
|
|
|
Joint
|
|
*jointPointer;
|
|
int
|
|
jointIndex;
|
|
EntitySegment
|
|
*parentSegment;
|
|
int
|
|
parentIndex;
|
|
int
|
|
thisIndex;
|
|
|
|
IntegerTable
|
|
damageZoneTable,
|
|
childIndexTable;
|
|
int
|
|
primaryDamageZone;
|
|
|
|
SegmentTable
|
|
childPointerTable;
|
|
|
|
CString
|
|
segmentName;
|
|
|
|
const LinearMatrix&
|
|
GetSegmentToParent();
|
|
|
|
void
|
|
SetSegmentToEntity(LinearMatrix& new_matrix)
|
|
{Check(this); segmentToEntity = new_matrix;}
|
|
void
|
|
SetSegmentToParent(LinearMatrix& new_matrix)
|
|
{Check(this); segmentToParent = new_matrix;}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Accessors
|
|
//
|
|
public:
|
|
// #110 (BT reconstruction): read access to the two streamed tables the
|
|
// binary's zone-destruction cascade walks (Mech__DamageZone::
|
|
// RecurseSegmentTable @0049cad4 -- seg+0xD0 damage zones, seg+0xE8 child
|
|
// indices). Read-only; population stays with JointedMover streaming.
|
|
IntegerTable&
|
|
GetDamageZoneTable()
|
|
{Check(this); return damageZoneTable;}
|
|
IntegerTable&
|
|
GetChildIndexTable()
|
|
{Check(this); return childIndexTable;}
|
|
|
|
void
|
|
ModifySegment(Logical modified = True)
|
|
{Check(this); segmentModified = modified;}
|
|
|
|
const LinearMatrix&
|
|
GetBaseOffset() const
|
|
{Check(this); return baseOffset;}
|
|
|
|
const LinearMatrix&
|
|
GetSegmentToEntity();
|
|
|
|
int
|
|
GetPrimaryDamageZone() const
|
|
{Check(this); return primaryDamageZone;}
|
|
int
|
|
GetParentIndex() const
|
|
{Check(this); return parentIndex;}
|
|
|
|
const EntitySegment*
|
|
GetParent() const
|
|
{Check(this); return parentSegment;}
|
|
|
|
int
|
|
GetIndex() const
|
|
{Check(this); return thisIndex;}
|
|
|
|
int
|
|
IsSiteSegment()
|
|
{Check(this); return siteSegment;}
|
|
|
|
CString
|
|
GetName() const
|
|
{Check(this); return segmentName;}
|
|
|
|
int
|
|
GetJointIndex() const
|
|
{Check(this); return jointIndex;}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Children of Segments Support
|
|
//
|
|
public:
|
|
CString*
|
|
GetVideoObjectName(
|
|
SkeletonType skl_type = SkeletonType_N,
|
|
Enumeration damage_graphic_state = 0
|
|
);
|
|
|
|
void
|
|
AddChildIndex(int child_index, int index);
|
|
|
|
void
|
|
AddChildPointer(EntitySegment *child_pointer, int index);
|
|
|
|
void
|
|
AddDamageZone(int damage_index, int index);
|
|
|
|
void
|
|
AddVideoObjectName(
|
|
CString video_object_name,
|
|
Enumeration skl_type,
|
|
Enumeration damage_graphic_state = 0
|
|
);
|
|
|
|
IntegerTableIterator*
|
|
MakeChildIndexTable()
|
|
{
|
|
Check(this);
|
|
Check_Pointer(&childIndexTable);
|
|
IntegerTableIterator *iterator = new
|
|
IntegerTableIterator(&childIndexTable);
|
|
return iterator;
|
|
}
|
|
|
|
IntegerTableIterator*
|
|
MakeDamageZoneIndexTable()
|
|
{
|
|
Check(this);
|
|
Check_Pointer(&damageZoneTable);
|
|
IntegerTableIterator *iterator = new
|
|
IntegerTableIterator(&damageZoneTable);
|
|
return iterator;
|
|
}
|
|
|
|
EntitySegment(
|
|
CString segment_name,
|
|
int this_index,
|
|
int parent_index,
|
|
int joint_index,
|
|
Joint *joint_ptr,
|
|
LinearMatrix &lin_matrix,
|
|
EntitySegment *parent_segment,
|
|
Logical is_site,
|
|
int primary_damage_zone
|
|
|
|
);
|
|
~EntitySegment();
|
|
};
|
|
|
|
inline MemoryStream&
|
|
MemoryStream_Read(
|
|
MemoryStream* stream,
|
|
EntitySegment::SkeletonType *output
|
|
)
|
|
{return stream->ReadBytes(output, sizeof(*output));}
|
|
inline MemoryStream&
|
|
MemoryStream_Write(
|
|
MemoryStream* stream,
|
|
const EntitySegment::SkeletonType *input
|
|
)
|
|
{return stream->WriteBytes(input, sizeof(*input));}
|