//===========================================================================// // File: ammobin.cpp // // Project: BattleTech Brick: Mech weapons // // Contents: AmmoBin -- ammunition store with cook-off heat // //---------------------------------------------------------------------------// // Copyright (C) 1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(AMMOBIN_HPP) # include #endif #if !defined(MECH_HPP) # include #endif Derivation AmmoBin::ClassDerivations( HeatWatcher::ClassDerivations, "AmmoBin" ); const AmmoBin::IndexEntry AmmoBin::AttributePointers[]= { ATTRIBUTE_ENTRY(AmmoBin, AmmoCount, ammoCount), ATTRIBUTE_ENTRY(AmmoBin, TimeToReady, feedTimer), ATTRIBUTE_ENTRY(AmmoBin, AmmoClassID, ammoClassID), ATTRIBUTE_ENTRY(AmmoBin, AmmoState, ammoAlarm), ATTRIBUTE_ENTRY(AmmoBin, FireCountdownStarted, fireCountdownStarted) }; AmmoBin::AttributeIndexSet AmmoBin::AttributeIndex( ELEMENTS(AmmoBin::AttributePointers), AmmoBin::AttributePointers, MechSubsystem::AttributeIndex ); AmmoBin::SharedData AmmoBin::DefaultData( AmmoBin::ClassDerivations, Subsystem::MessageHandlers, AmmoBin::AttributeIndex, Subsystem::StateCount ); AmmoBin::AmmoBin( Mech *owner, int subsystem_ID, SubsystemResource *resource, SharedData &shared_data ): HeatWatcher(owner, subsystem_ID, resource, shared_data), ammoAlarm(6) { Check(owner); Check_Pointer(resource); ammoCount = resource->ammoCount; initialAmmoCount = resource->ammoCount; feedRate = resource->feedRate; feedTimer = 0.0f; ammoClassID = resource->ammoClassID; ammoModelFile = resource->ammoModelFile; explosionModelFile = resource->explosionModelFile; heatPerRound = resource->heatPerRound; cookOffArmed = 0; cookOffTime = 0; fireCountdownStarted = 0; // was: reserved for (int i = 0; i < 12; ++i) { cookOffState[i] = 0; } Check_Fpu(); } AmmoBin::~AmmoBin() { } Logical AmmoBin::TestClass(Mech &) { return True; } Logical AmmoBin::TestInstance() const { return IsDerivedFrom(ClassDerivations); } // //############################################################################# // DeathReset -- the respawn restock: base heal + refill from the authored // resource count (the launchers' NoAmmo state releases in their own reset). //############################################################################# // void AmmoBin::DeathReset(Logical full_reset) { Check(this); HeatWatcher::DeathReset(full_reset); // // Restock from the CTOR-CACHED authored count -- NEVER through the // `resource` member: it points into the Mech ctor's padded stream copy, // which is delete[]d before the ctor returns (a respawn-time deref // reads freed heap -- caught by the 5.3.24 adversarial review). // ammoCount = initialAmmoCount; }