Files
TeslaRel410/restoration/source410/BT/MECHMPPR.CPP
T
CydandClaude Fable 5 11680bcb3e Phase 5.1: mapper attributes VERIFIED resolving (throttle/controlMode non-NULL)
Trace confirms the MechControlsMapper (slot 0) publishes its control attributes
correctly: throttleAttr/controlModeAttr resolve to non-NULL pointers. So the
mapper's AttributeIndex works. The post-construction crash (GetAttributePointer
attr=0x13) is on a DIFFERENT object (EAX heap addr after the mapper) -- a streamed
watcher targeting another simulation, not the mapper. Localizing next. (BT_MECH_LOG
mapper trace retained.)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 11:14:34 -05:00

139 lines
4.4 KiB
C++

//===========================================================================//
// File: mechmppr.cpp //
// Project: BattleTech //
// Contents: Implementation details for the mech controls mapper //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <bt.hpp>
#pragma hdrstop
#if !defined(MECHMPPR_HPP)
# include <mechmppr.hpp>
#endif
Derivation
MechControlsMapper::ClassDerivations(
Subsystem::ClassDerivations,
"MechControlsMapper"
);
//
//#############################################################################
// Published control-input attributes. The streamed control mappings bind (by
// name) to these; the pad entry fills the chain-vs-id gap at id 2.
//#############################################################################
//
const MechControlsMapper::IndexEntry
MechControlsMapper::AttributePointers[]=
{
{ (int)MechControlsMapper::MechControlsMapperPadFirstAttributeID,
"MechControlsMapperPad02",
(Simulation::AttributePointer)&MechControlsMapper::throttlePosition },
ATTRIBUTE_ENTRY(MechControlsMapper, StickPosition, stickPosition),
ATTRIBUTE_ENTRY(MechControlsMapper, ThrottlePosition, throttlePosition),
ATTRIBUTE_ENTRY(MechControlsMapper, PedalsPosition, pedalsPosition),
ATTRIBUTE_ENTRY(MechControlsMapper, ReverseThrust, reverseThrust),
ATTRIBUTE_ENTRY(MechControlsMapper, SpeedDemand, speedDemand),
ATTRIBUTE_ENTRY(MechControlsMapper, TurnDemand, turnDemand),
ATTRIBUTE_ENTRY(MechControlsMapper, LookForward, lookForward),
ATTRIBUTE_ENTRY(MechControlsMapper, LookLeft, lookLeft),
ATTRIBUTE_ENTRY(MechControlsMapper, LookRight, lookRight),
ATTRIBUTE_ENTRY(MechControlsMapper, LookBehind, lookBehind),
ATTRIBUTE_ENTRY(MechControlsMapper, LookDown, lookDown),
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoUp, torsoUp),
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoDown, torsoDown),
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoLeft, torsoLeft),
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoRight, torsoRight),
ATTRIBUTE_ENTRY(MechControlsMapper, TorsoCenter, torsoCenter),
ATTRIBUTE_ENTRY(MechControlsMapper, ControlMode, controlMode),
ATTRIBUTE_ENTRY(MechControlsMapper, DisplayMode, displayMode),
ATTRIBUTE_ENTRY(MechControlsMapper, PilotArrayPage, pilotArrayPage),
ATTRIBUTE_ENTRY(MechControlsMapper, PilotArray, pilotArray)
};
MechControlsMapper::AttributeIndexSet
MechControlsMapper::AttributeIndex(
ELEMENTS(MechControlsMapper::AttributePointers),
MechControlsMapper::AttributePointers,
Subsystem::AttributeIndex
);
MechControlsMapper::SharedData
MechControlsMapper::DefaultData(
MechControlsMapper::ClassDerivations,
Subsystem::MessageHandlers,
MechControlsMapper::AttributeIndex,
1
);
MechControlsMapper::MechControlsMapper(
Mech *owner,
int subsystem_ID,
CString subsystem_name,
RegisteredClass::ClassID class_ID,
SharedData &shared_data
):
Subsystem(
(Entity *)owner,
subsystem_ID,
subsystem_name,
class_ID,
shared_data
)
{
Check(owner);
//
// Prime the published control inputs to neutral. Per-frame interpretation
// (InterpretControls) is reconstructed with the mech2/3/4 sim (phase 5.3).
//
stickPosition.x = 0.0f;
stickPosition.y = 0.0f;
throttlePosition = 0.0f;
pedalsPosition = 0.0f;
reverseThrust = 0;
speedDemand = 0.0f;
turnDemand = 0.0f;
lookForward = 0;
lookLeft = 0;
lookRight = 0;
lookBehind = 0;
lookDown = 0;
torsoUp = 0;
torsoDown = 0;
torsoLeft = 0;
torsoRight = 0;
torsoCenter = 0;
controlMode = BasicMode;
displayMode = 0;
pilotArrayPage = 0;
pilotArray = 0;
{
for (int i = 0; i < 24; ++i)
{
reserved[i] = 0;
}
}
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[mapper] ctor id=" << subsystem_ID
<< " throttleAttr=" << GetAttributePointer(ThrottlePositionAttributeID)
<< " controlModeAttr=" << GetAttributePointer(ControlModeAttributeID)
<< endl << flush;
}
Check_Fpu();
}
MechControlsMapper::~MechControlsMapper()
{
}
Logical
MechControlsMapper::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}