Files
BT412/engine/MUNGA/SEGMENT.h
T
arcattackandClaude Opus 4.8 7b7d465e5e Initial commit: bt411 -- standalone Windows BattleTech (Tesla 4.10 port)
Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.

Layout:
  engine/   MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
            work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
            models) + image codec; the minimal rp/ headers the audio HAL needs
  game/     reconstructed BT logic + surviving-original BT source + fwd shims
            + WinMain launcher
  content/  full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
  docs/     format specs + reconstruction ledgers
  reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
  tools/    MP console emulator + map/resource scanners

One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:03:40 -05:00

240 lines
5.0 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:
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));}