The master perf's opening scan maxes the myomer chain's speedEffect into the mobility scale and applies it straight to the pilot's command cells: the throttle is multiplied by it, and a scale inside the 1e-4 deadzone zeroes the turn outright -- a mech with dead muscles cannot even pivot. It is the same cell the duck driver already read as "the legs still work", so that gate stops being a constant. THE CHAIN IDENTITY IS NOW PROVEN RATHER THAN INFERRED. My 5.3.122 note pinned mech+0x7ac to Myomers "by adjacency to the string pool", which nearly went wrong: the very cell the scan reads, +0x31c, is a MechWeapon trigger over in the weapon TU. The decisive evidence is arithmetic -- the Myomers cap-raise reads seekVoltage at +0x330 indexed by maxSeekVoltageIndex at +0x32c, and walking our own member order backwards from there lands speedEffect exactly on +0x31c. The ctor's myomer sweep also carries the other half: walking the chain is what sets the "I computed my own top speed" flag, so a mech WITH myomers broadcasts its cap and one without adopts the streamed value. Safe by construction against the obvious hazard: the mapper reassigns its demands from scratch in InterpretControls, which ticks before the mech's performance, so multiplying its cell in place cannot compound frame to frame. Soak: [mobility] scale 1 over 1 myomers on an undamaged bhk1 -- throttle unscaled, drive unchanged, zero faults. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
249 lines
8.0 KiB
C++
249 lines
8.0 KiB
C++
//===========================================================================//
|
|
// File: mechmppr.hpp //
|
|
// Project: BattleTech //
|
|
// Contents: Implementation details for the mech controls mapper //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(MECHMPPR_HPP)
|
|
# define MECHMPPR_HPP
|
|
|
|
# if !defined(SUBSYSTM_HPP)
|
|
# include <subsystm.hpp>
|
|
# endif
|
|
|
|
# if !defined(CSTR_HPP)
|
|
# include <cstr.hpp>
|
|
# endif
|
|
|
|
# if !defined(CONTROLS_HPP)
|
|
# include <controls.hpp>
|
|
# endif
|
|
|
|
# if !defined(VECTOR2D_HPP)
|
|
# include <vector2d.hpp>
|
|
# endif
|
|
|
|
//##################### Forward Class Declarations #######################
|
|
class Mech;
|
|
|
|
//###########################################################################
|
|
//######################## MechControlsMapper ###########################
|
|
//###########################################################################
|
|
|
|
class MechControlsMapper:
|
|
public Subsystem
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// The duck button cell (binary mapper+0x25c) -- a device-poll write
|
|
// destination like the torso command cells; the master perf's duck
|
|
// driver reads it as the held-button gate. The streamed attribute
|
|
// binding id is still to be audited (BT_MAP_LOG) -- until a RES table
|
|
// binds it, BT_FORCE_DUCK drives it.
|
|
//
|
|
public:
|
|
int
|
|
DuckCommand()
|
|
{ Check(this); return duckCommand; }
|
|
int duckCommand;
|
|
|
|
//
|
|
// The ejection latch (binary mapper+0x258, right beside the duck
|
|
// cell): EjectPilot sets it 1 as the pilot punches out; the cockpit
|
|
// side reads it (consumer still to be identified).
|
|
//
|
|
int ejectLatch;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Shared Data Support
|
|
//
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
static const IndexEntry AttributePointers[];
|
|
static AttributeIndexSet AttributeIndex;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Attribute IDs -- the control inputs the streamed mappings bind to.
|
|
// The chain ends at Subsystem::NextAttributeID == 2.
|
|
//
|
|
public:
|
|
enum {
|
|
MechControlsMapperPadFirstAttributeID = 2,
|
|
StickPositionAttributeID, // 3
|
|
ThrottlePositionAttributeID, // 4
|
|
PedalsPositionAttributeID, // 5
|
|
ReverseThrustAttributeID, // 6
|
|
SpeedDemandAttributeID, // 7
|
|
TurnDemandAttributeID, // 8
|
|
LookForwardAttributeID, // 9
|
|
LookLeftAttributeID, // a
|
|
LookRightAttributeID, // b
|
|
LookBehindAttributeID, // c
|
|
LookDownAttributeID, // d
|
|
TorsoUpAttributeID, // e
|
|
TorsoDownAttributeID, // f
|
|
TorsoLeftAttributeID, // 10
|
|
TorsoRightAttributeID, // 11
|
|
TorsoCenterAttributeID, // 12
|
|
ControlModeAttributeID, // 13
|
|
DisplayModeAttributeID, // 14
|
|
PilotArrayPageAttributeID, // 15
|
|
PilotArrayAttributeID, // 16
|
|
TargetRangeExponentAttributeID, // authored watcher
|
|
NextAttributeID
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Control modes
|
|
//
|
|
public:
|
|
enum ControlMode {
|
|
BasicMode = 0,
|
|
StandardMode,
|
|
VeteranMode
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Look states. A five-state machine off the pod's look buttons; on a state
|
|
// change InterpretControls calls Mech::CommitLookState, which re-aims the
|
|
// eyepoint from the model's authored look angles (and, once the weapon wave
|
|
// lands, re-arms the per-view weapon fire enables).
|
|
//
|
|
public:
|
|
enum LookState {
|
|
LookNone = 0,
|
|
LookLeftState,
|
|
LookRightState,
|
|
LookBehindState,
|
|
LookDownState
|
|
};
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction and Destruction
|
|
//
|
|
public:
|
|
MechControlsMapper(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
CString subsystem_name,
|
|
RegisteredClass::ClassID class_ID,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
|
|
~MechControlsMapper();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Per-frame control interpretation (the mapper's Performance): reads the
|
|
// engine-pushed raw input attributes (throttle / stick / pedals / buttons)
|
|
// and publishes the locomotion + aim demands the mech drive consumes.
|
|
//
|
|
public:
|
|
typedef void
|
|
(MechControlsMapper::*Performance)(Scalar time_slice);
|
|
void
|
|
SetPerformance(Performance performance)
|
|
{
|
|
Check(this);
|
|
activePerformance = (Simulation::Performance)performance;
|
|
}
|
|
|
|
void
|
|
InterpretControls(Scalar time_slice);
|
|
|
|
Mech*
|
|
GetMech() { Check(this); return (Mech *)GetEntity(); }
|
|
Scalar
|
|
GetSpeedDemand() const { Check(this); return speedDemand; }
|
|
Scalar
|
|
GetTurnDemand() const { Check(this); return turnDemand; }
|
|
|
|
//
|
|
// The master perf writes the mobility scale straight into the
|
|
// mapper's command cells (binary @0x4a9d5d: throttle *= scale, and
|
|
// a scale inside the 1e-4 deadzone zeroes the turn outright -- a
|
|
// mech with dead myomers cannot even pivot). Applied here so the
|
|
// cells stay owned by the mapper.
|
|
//
|
|
void
|
|
ApplyMobilityScale(Scalar scale)
|
|
{
|
|
Check(this);
|
|
speedDemand *= scale;
|
|
if (scale <= 0.0001f && scale >= -0.0001f)
|
|
{
|
|
turnDemand = 0.0f;
|
|
}
|
|
}
|
|
|
|
//
|
|
// The LIMP machines write the demand cell DOWN to the damaged side's
|
|
// speed cap (binary GimpLegClipFinished @004a7970 preamble writes
|
|
// mapper+0x128 directly) -- a limping mech cannot command more speed
|
|
// than its limp figure carries.
|
|
//
|
|
void
|
|
SetSpeedDemand(Scalar demand)
|
|
{ Check(this); speedDemand = demand; }
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Local Data -- the published control inputs (the streamed mappings write
|
|
// these; InterpretControls, phase 5.3, reads them to drive the mech).
|
|
//
|
|
public:
|
|
//
|
|
// The POD ROSTER (binary mapper attributes PilotArrayPage/PilotArray,
|
|
// ids 15/16): the comm scoreboard's row source. Zero = no roster
|
|
// authored (a solo mission), which is why the shipped cockpit leaves
|
|
// that page blank.
|
|
//
|
|
int
|
|
GetPilotArray() const { Check(this); return pilotArray; }
|
|
int
|
|
GetPilotArrayPage() const { Check(this); return pilotArrayPage; }
|
|
|
|
|
|
protected:
|
|
ControlsJoystick stickPosition;
|
|
Scalar throttlePosition;
|
|
Scalar pedalsPosition;
|
|
ControlsButton reverseThrust;
|
|
Scalar speedDemand;
|
|
Scalar turnDemand;
|
|
ControlsButton lookForward;
|
|
ControlsButton lookLeft;
|
|
ControlsButton lookRight;
|
|
ControlsButton lookBehind;
|
|
ControlsButton lookDown;
|
|
ControlsButton torsoUp;
|
|
ControlsButton torsoDown;
|
|
ControlsButton torsoLeft;
|
|
ControlsButton torsoRight;
|
|
ControlsButton torsoCenter;
|
|
int controlMode;
|
|
int displayMode;
|
|
int pilotArrayPage;
|
|
int pilotArray;
|
|
int lookState;
|
|
int previousLookState;
|
|
//
|
|
// Takes one reserved word (Scalar and int are both 4 bytes here), so
|
|
// the class size and every existing offset stay exactly as they were.
|
|
//
|
|
Scalar targetRangeExponent; // authored watcher
|
|
int reserved[21];
|
|
};
|
|
|
|
#endif
|