Published and verified green on the pod rig: Condenser/CondenserState, Generator/GeneratorState, Emitter/LaserOn, ControlsMapper/TargetRangeExponent, plus the Torso and Myomers tables from the previous pass. Reservoir/ReservoirState CRASHES the pod on the DOS extender, and a bisect pins it to exactly that change: revert it and the run returns to a clean Fail, re-apply it alone and the crash returns. It is reverted; the tree is green and the ladder is blocked there. The important lesson is general: AttributeWatcherOf<T> does currentValue = *(T*)attributePointer AT CONSTRUCTION, so a published name is read the moment its watcher is built. My earlier staging note claimed the provisional types could not matter because nothing drives the values yet -- that is wrong, and this is the counterexample. Ruled out by measurement and recorded so they are not retried: the AlarmIndicator-vs-int type (a plain int got further, 232 -> 749 bytes of log, but still crashed), static-init order (reservr.obj sorts last, after heat), an id gap (contiguous at HeatSink::NextAttributeID), and the gauge rig (same binary runs clean there -- only the pod/arena context faults). Crash signature for whoever picks it up: 0044B4AD, mov eax,[edx+0x18] then call [eax+4], EAX=0x15, fault at 0x19 -- a small integer called through as an object, i.e. the AttributeIndexSet::Build uninitialised-slot pattern. Condenser is the control: same base class, plain int, no crash. Also fixed on the way: staged members must be appended at the END of a class (offset-sensitive readers exist -- condenserNumber is reached as master+0x1d4) and never added to a resource struct, which is a wire format. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
201 lines
6.2 KiB
C++
201 lines
6.2 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
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// 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; }
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// 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
|