Files
BT412/engine/MUNGA_L4/L4AUDWTR.cpp
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

188 lines
4.8 KiB
C++

#include "mungal4.h"
#pragma hdrstop
#include "l4audwtr.h"
#include "..\munga\objstrm.h"
#include "..\munga\namelist.h"
//#############################################################################
//######################## L4AudioCollisionTrigger ######################
//#############################################################################
#if 0
L4AudioCollisionTrigger::L4AudioCollisionTrigger(
StateIndicator *state_attribute_ptr,
Normal *normal_attribute_ptr,
Static3DPatchSource *audio_source,
Enumeration trigger_state,
AudioControlID control_ID,
AudioControlValue control_value,
Logical dump_value
):
AudioStateWatcher(
state_attribute_ptr,
audio_source,
L4AudioCollisionTriggerClassID,
dump_value
)
{
Check(normal_attribute_ptr);
normalAttributePtr = normal_attribute_ptr;
triggerState = trigger_state;
controlID = control_ID;
controlValue = control_value;
PrimeWatcher();
}
#endif
//
//#############################################################################
//#############################################################################
//
L4AudioCollisionTrigger::~L4AudioCollisionTrigger()
{
}
//
//#############################################################################
//#############################################################################
//
L4AudioCollisionTrigger::L4AudioCollisionTrigger(
PlugStream *stream,
Entity *entity
):
AudioStateWatcher(stream, entity)
{
//
// HACK - Get "normal" attribute pointer with names
//
CString attribute_name;
void *attribute_ptr;
MemoryStream_Read(stream, &attribute_name);
Check(entity);
attribute_ptr = entity->GetAttributePointer(attribute_name);
normalAttributePtr = Cast_Object(Normal*, attribute_ptr);
//
// Get other fields
//
MemoryStream_Read(stream, &triggerState);
MemoryStream_Read(stream, &controlID);
MemoryStream_Read(stream, &controlValue);
PrimeWatcher();
}
//
//#############################################################################
//#############################################################################
//
void
L4AudioCollisionTrigger::BuildFromPage(
PlugStream *stream,
NameList *name_list,
ClassID class_ID,
ObjectID object_ID
)
{
AudioStateWatcher::BuildFromPage(stream, name_list, class_ID, object_ID);
//
// HACK - Store "normal" attribute pointer with names
//
MEM_STRM_WRITE_ENTRY(*stream, name_list, CString, normal_attribute);
//
// Store fields
//
MEM_STRM_WRITE_ENTRY(*stream, name_list, Enumeration, trigger_state);
MEM_STRM_WRITE_ENTRY(*stream, name_list, Enumeration, control_ID);
MEM_STRM_WRITE_ENTRY(*stream, name_list, AudioControlValue, control_value);
}
//
//#############################################################################
//#############################################################################
//
Logical
L4AudioCollisionTrigger::TestInstance() const
{
AudioStateWatcher::TestInstance();
Check(normalAttributePtr);
return True;
}
//
//#############################################################################
//#############################################################################
//
void
L4AudioCollisionTrigger::StateChanged(
Enumeration,
Enumeration new_state
)
{
if (new_state == triggerState)
{
//
// Get static 3D source
//
AudioComponent *audio_component;
Static3DPatchSource *audio_source;
Check(&audioComponentSocket);
audio_component = audioComponentSocket.GetCurrent();
Check(audio_component);
audio_source = Cast_Object(Static3DPatchSource*, audio_component);
Check(audio_source);
//
// Get collision direction
//
Vector3D collision_direction(0.0f, 0.0f, 0.0f);
Check(normalAttributePtr);
collision_direction -= *normalAttributePtr;
Check(&collision_direction);
audio_source->SetPosition(collision_direction);
//
// Send control value
//
#if 1
audio_component->ReceiveControl(controlID, controlValue);
#else
audio_component->PostReceiveControl(controlID, controlValue);
#endif
}
}
//
//#############################################################################
//#############################################################################
//
#if DEBUG_LEVEL>0
void
L4AudioCollisionTrigger::DumpValue(const StateIndicator *state_attribute_ptr)
#else
void
L4AudioCollisionTrigger::DumpValue(const StateIndicator*)
#endif
{
//
// Get collision direction
//
Vector3D collision_direction(0.0f, 0.0f, 0.0f);
Check(normalAttributePtr);
collision_direction -= *normalAttributePtr;
Check(&collision_direction);
Tell(
"*state_attribute_ptr = " << *state_attribute_ptr << " : " <<
"collision_direction = " << collision_direction << "\n"
);
}