From 40672845e417e02c56989705c04d8c340211ce43 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:51:33 +0300 Subject: [PATCH] Message code enum part 6: final touches + control light cleanup. MessageField is often used as int, so it stays unchanged. --- SpaceCadetPinball/TFlipper.cpp | 4 +- SpaceCadetPinball/TFlipperEdge.cpp | 32 ++--- SpaceCadetPinball/TFlipperEdge.h | 5 +- SpaceCadetPinball/TLight.cpp | 5 + SpaceCadetPinball/TLight.h | 1 + SpaceCadetPinball/TLightGroup.cpp | 2 +- SpaceCadetPinball/TPinballComponent.cpp | 2 +- SpaceCadetPinball/TPinballComponent.h | 9 +- SpaceCadetPinball/control.cpp | 148 ++++++++++++------------ SpaceCadetPinball/control.h | 5 +- 10 files changed, 103 insertions(+), 110 deletions(-) diff --git a/SpaceCadetPinball/TFlipper.cpp b/SpaceCadetPinball/TFlipper.cpp index 70b0f65..21d65b1 100644 --- a/SpaceCadetPinball/TFlipper.cpp +++ b/SpaceCadetPinball/TFlipper.cpp @@ -83,14 +83,14 @@ int TFlipper::Message(MessageCode code, float value) code = MessageCode::TFlipperRetract; } - MessageField = FlipperEdge->SetMotion(~code, value); + MessageField = FlipperEdge->SetMotion(code, value); break; case MessageCode::PlayerChanged: case MessageCode::Reset: if (MessageField) { MessageField = 0; - FlipperEdge->SetMotion(1024, value); + FlipperEdge->SetMotion(MessageCode::Reset, value); UpdateSprite(0); } break; diff --git a/SpaceCadetPinball/TFlipperEdge.cpp b/SpaceCadetPinball/TFlipperEdge.cpp index 8f9d807..f53799a 100644 --- a/SpaceCadetPinball/TFlipperEdge.cpp +++ b/SpaceCadetPinball/TFlipperEdge.cpp @@ -45,7 +45,7 @@ TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsi maths::cross(vecDir1, vecDir2, crossProd); if (crossProd.Z < 0.0f) AngleMax = -AngleMax; - FlipperFlag = 0; + FlipperFlag = MessageCode::TFlipperNull; AngleDst = 0.0; // 3DPB and FT have different formats for flipper speed: @@ -109,11 +109,11 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray) if (ogRay->TimeNow > AngleStopTime) { - FlipperFlag = 0; + FlipperFlag = MessageCode::TFlipperNull; } if (EdgeCollisionFlag == 0) { - if (FlipperFlag == 0) + if (FlipperFlag == MessageCode::TFlipperNull) { CollisionFlag1 = 0; CollisionFlag2 = 0; @@ -205,7 +205,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray) if (ballInside != 0) { vector2* linePtr; - if (FlipperFlag == 1 && ballInside != 5) + if (FlipperFlag == MessageCode::TFlipperExtend && ballInside != 5) { linePtr = &lineA.PerpendicularC; srcRay.Direction.Y = lineA.PerpendicularC.Y; @@ -213,7 +213,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray) } else { - if (FlipperFlag != 2 || ballInside == 4) + if (FlipperFlag != MessageCode::TFlipperRetract || ballInside == 4) { CollisionFlag1 = 0; CollisionFlag2 = 1; @@ -276,7 +276,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray) NextBallPosition.X -= srcRay.Direction.X * 1e-05f; NextBallPosition.Y -= srcRay.Direction.Y * 1e-05f; vector2* linePtr; - if (FlipperFlag == 2) + if (FlipperFlag == MessageCode::TFlipperRetract) { linePtr = &lineB.PerpendicularC; CollisionFlag1 = AngleMax <= 0.0f; @@ -305,7 +305,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray) void TFlipperEdge::EdgeCollision(TBall* ball, float distance) { EdgeCollisionFlag = 1; - if (!FlipperFlag || !CollisionFlag2 || CollisionFlag1) + if (FlipperFlag == MessageCode::TFlipperNull || !CollisionFlag2 || CollisionFlag1) { float boost = 0.0; if (CollisionFlag1) @@ -414,7 +414,7 @@ void TFlipperEdge::set_control_points(float timeNow) float TFlipperEdge::flipper_angle(float timeNow) { // When not moving, flipper is at destination angle. - if (!FlipperFlag) + if (FlipperFlag == MessageCode::TFlipperNull) return AngleDst; // How much time it takes to go from source to destination angle, in sec. @@ -441,9 +441,9 @@ int TFlipperEdge::is_ball_inside(float x, float y) (T1.Y - y) * (T1.Y - y) + (T1.X - x) * (T1.X - x) < CircleT1RadiusSq) { float flipperLR = AngleMax < 0.0f ? -1.0f : 1.0f; - if (FlipperFlag == 1) + if (FlipperFlag == MessageCode::TFlipperExtend) testPoint = AngleMax < 0.0f ? B1 : B2; - else if (FlipperFlag == 2) + else if (FlipperFlag == MessageCode::TFlipperRetract) testPoint = AngleMax < 0.0f ? A2 : A1; else testPoint = T1; @@ -456,21 +456,21 @@ int TFlipperEdge::is_ball_inside(float x, float y) return 0; } -int TFlipperEdge::SetMotion(int code, float value) +int TFlipperEdge::SetMotion(MessageCode code, float value) { switch (code) { - case 1: + case MessageCode::TFlipperExtend: AngleSrc = flipper_angle(value); AngleDst = AngleMax; AngleAdvanceTime = ExtendTime; break; - case 2: + case MessageCode::TFlipperRetract: AngleSrc = flipper_angle(value); AngleDst = 0.0f; AngleAdvanceTime = RetractTime; break; - case ~MessageCode::Reset: + case MessageCode::Reset: AngleSrc = 0.0f; AngleDst = 0.0f; break; @@ -478,10 +478,10 @@ int TFlipperEdge::SetMotion(int code, float value) } if (AngleSrc == AngleDst) - code = 0; + code = MessageCode::TFlipperNull; InputTime = value; FlipperFlag = code; AngleStopTime = AngleAdvanceTime + InputTime; - return code; + return static_cast(code); } diff --git a/SpaceCadetPinball/TFlipperEdge.h b/SpaceCadetPinball/TFlipperEdge.h index ac7b80a..4d567f7 100644 --- a/SpaceCadetPinball/TFlipperEdge.h +++ b/SpaceCadetPinball/TFlipperEdge.h @@ -1,6 +1,7 @@ #pragma once #include "maths.h" #include "TEdgeSegment.h" +#include "TPinballComponent.h" class TPinballTable; @@ -17,9 +18,9 @@ public: void set_control_points(float timeNow); float flipper_angle(float timeNow); int is_ball_inside(float x, float y); - int SetMotion(int code, float value); + int SetMotion(MessageCode code, float value); - int FlipperFlag; + MessageCode FlipperFlag{}; float Elasticity; float Smoothness; vector2 RotOrigin{}; diff --git a/SpaceCadetPinball/TLight.cpp b/SpaceCadetPinball/TLight.cpp index 0fecbe6..ce41917 100644 --- a/SpaceCadetPinball/TLight.cpp +++ b/SpaceCadetPinball/TLight.cpp @@ -343,3 +343,8 @@ void TLight::UndoTmpOverride(int timerId, void* caller) auto light = static_cast(caller); light->Message(MessageCode::TLightFtResetOverride, 0.0f); } + +bool TLight::light_on() const +{ + return LightOnFlag || ToggledOnFlag || FlasherOnFlag; +} diff --git a/SpaceCadetPinball/TLight.h b/SpaceCadetPinball/TLight.h index 4012900..5ddd0c3 100644 --- a/SpaceCadetPinball/TLight.h +++ b/SpaceCadetPinball/TLight.h @@ -23,6 +23,7 @@ public: void flasher_stop(int bmpIndex); void flasher_start(bool bmpIndex); void SetSpriteBmp(gdrv_bitmap8* bmp); + bool light_on() const; static void TimerExpired(int timerId, void* caller); static void flasher_callback(int timerId, void* caller); diff --git a/SpaceCadetPinball/TLightGroup.cpp b/SpaceCadetPinball/TLightGroup.cpp index 04f9fca..514e5b1 100644 --- a/SpaceCadetPinball/TLightGroup.cpp +++ b/SpaceCadetPinball/TLightGroup.cpp @@ -305,7 +305,7 @@ int TLightGroup::Message(MessageCode code, float value) case MessageCode::TLightGroupGetLightCount: return count; case MessageCode::TLightGroupGetMessage2: - return ~MessageField2; + return static_cast(MessageField2); case MessageCode::TLightGroupGetAnimationFlag: return AnimationFlag; case MessageCode::TLightGroupResetAndTurnOn: diff --git a/SpaceCadetPinball/TPinballComponent.cpp b/SpaceCadetPinball/TPinballComponent.cpp index 0d2dfdf..516495c 100644 --- a/SpaceCadetPinball/TPinballComponent.cpp +++ b/SpaceCadetPinball/TPinballComponent.cpp @@ -107,7 +107,7 @@ TPinballComponent::~TPinballComponent() int TPinballComponent::Message(MessageCode code, float value) { - MessageField = ~code; + MessageField = static_cast(code); if (code == MessageCode::Reset) MessageField = 0; return 0; diff --git a/SpaceCadetPinball/TPinballComponent.h b/SpaceCadetPinball/TPinballComponent.h index e92eddd..ec4c1e2 100644 --- a/SpaceCadetPinball/TPinballComponent.h +++ b/SpaceCadetPinball/TPinballComponent.h @@ -11,6 +11,7 @@ class TPinballTable; enum class MessageCode { // Private codes <1000, different meaning for each component + TFlipperNull = 0, TFlipperExtend = 1, TFlipperRetract = 2, @@ -128,14 +129,6 @@ enum class MessageCode Reset = 1024, }; -// Temporary hacks for int -> enum class migration. -template ::type> -constexpr typename std::enable_if::value, X>::type operator~(T value) -{ - return static_cast(value); -} - - class TPinballComponent { public: diff --git a/SpaceCadetPinball/control.cpp b/SpaceCadetPinball/control.cpp index ba53068..2d8acea 100644 --- a/SpaceCadetPinball/control.cpp +++ b/SpaceCadetPinball/control.cpp @@ -826,17 +826,17 @@ int control::mission_select_scores[17] = 30000 }; -std::reference_wrapper control::wormhole_tag_array1[3] = +std::reference_wrapper control::WormholeSinkArray[3] = { sink1, sink2, sink3 }; -std::reference_wrapper control::wormhole_tag_array2[3] = +std::reference_wrapper control::WormholeLightArray1[3] = { lite5, lite6, lite7 }; -std::reference_wrapper control::wormhole_tag_array3[3] = +std::reference_wrapper control::WormholeLightArray2[3] = { lite4, lite2, lite3 }; @@ -1050,12 +1050,6 @@ void control::cheat_bump_rank() } } -bool control::light_on(component_tag* tag) -{ - auto light = tag->Component; - return light->LightOnFlag || light->ToggledOnFlag || light->FlasherOnFlag; -} - int control::SpecialAddScore(int score) { int prevFlag1 = TableG->ScoreSpecial3Flag; @@ -1124,7 +1118,7 @@ void control::AdvanceWormHoleDestination(int flag) } bsink_arrow_lights->Message(MessageCode::TLightSetMessageField, static_cast(val2)); bsink_arrow_lights->Message(MessageCode::TLightSetOnStateBmpIndex, static_cast(3 - val1)); - if (!light_on(&control_lite4_tag)) + if (!lite4->light_on()) { worm_hole_lights->Message(MessageCode::TLightResetAndTurnOn, 0.0); bsink_arrow_lights->Message(MessageCode::TLightResetAndTurnOn, 0.0); @@ -1221,7 +1215,7 @@ void control::DeploymentChuteToEscapeChuteOneWayControl(MessageCode code, TPinba int score = TableG->AddScore(caller->get_scoring(count - 1)); snprintf(Buffer, sizeof Buffer, pb::get_rc_string(Msg::STRING122), score); info_text_box->Display(Buffer, 2.0); - if (!light_on(&control_lite56_tag)) + if (!lite56->light_on()) { l_trek_lights->Message(MessageCode::TLightGroupReset, 0.0); l_trek_lights->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -1278,16 +1272,16 @@ void control::LaunchRampControl(MessageCode code, TPinballComponent* caller) if (code == MessageCode::ControlCollision) { int someFlag = 0; - if (light_on(&control_lite54_tag)) + if (lite54->light_on()) { someFlag = 1; int addedScore = SpecialAddScore(TableG->ScoreSpecial1); snprintf(Buffer, sizeof Buffer, pb::get_rc_string(Msg::STRING111), addedScore); info_text_box->Display(Buffer, 2.0); } - if (light_on(&control_lite55_tag)) + if (lite55->light_on()) someFlag |= 2u; - if (light_on(&control_lite56_tag)) + if (lite56->light_on()) someFlag |= 4u; if (someFlag) { @@ -1332,7 +1326,7 @@ void control::ReentryLanesRolloverControl(MessageCode code, TPinballComponent* c { if (code == MessageCode::ControlCollision) { - if (!light_on(&control_lite56_tag) && l_trek_lights->Message(MessageCode::TLightGroupGetMessage2, 0.0)) + if (!lite56->light_on() && l_trek_lights->Message(MessageCode::TLightGroupGetMessage2, 0.0)) { l_trek_lights->Message(MessageCode::TLightGroupReset, 0.0); l_trek_lights->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -1434,7 +1428,7 @@ void control::OutLaneRolloverControl(MessageCode code, TPinballComponent* caller { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite17_tag) || light_on(&control_lite18_tag)) + if (lite17->light_on() || lite18->light_on()) { table_add_extra_ball(2.0); lite17->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -1446,13 +1440,13 @@ void control::OutLaneRolloverControl(MessageCode code, TPinballComponent* caller } if (roll4 == caller) { - if (light_on(&control_lite30_tag)) + if (lite30->light_on()) { lite30->Message(MessageCode::TLightFlasherStart, 0.0); lite196->Message(MessageCode::TLightFlasherStart, 0.0); } } - else if (light_on(&control_lite29_tag)) + else if (lite29->light_on()) { lite29->Message(MessageCode::TLightFlasherStart, 0.0); lite195->Message(MessageCode::TLightFlasherStart, 0.0); @@ -1486,7 +1480,7 @@ void control::ReturnLaneRolloverControl(MessageCode code, TPinballComponent* cal { if (roll6 == caller) { - if (light_on(&control_lite27_tag)) + if (lite27->light_on()) { lite59->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite27->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -1497,7 +1491,7 @@ void control::ReturnLaneRolloverControl(MessageCode code, TPinballComponent* cal } else if (roll7 == caller) { - if (light_on(&control_lite28_tag)) + if (lite28->light_on()) { lite59->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite28->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -1515,7 +1509,7 @@ void control::BonusLaneRolloverControl(MessageCode code, TPinballComponent* call if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite16_tag)) + if (lite16->light_on()) { int addedScore = SpecialAddScore(TableG->ScoreSpecial2); snprintf(Buffer, sizeof Buffer, pb::get_rc_string(Msg::STRING104), addedScore); @@ -1700,10 +1694,10 @@ void control::WormHoleControl(MessageCode code, TPinballComponent* caller) } info_text_box->Display(pb::get_rc_string(Msg::STRING150), 2.0); - wormhole_tag_array2[sinkFlag].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); - wormhole_tag_array3[sinkFlag].get()->Message(MessageCode::TLightSetOnStateBmpIndex, static_cast(2 - sinkFlag)); - wormhole_tag_array3[sinkFlag].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); - wormhole_tag_array1[sinkFlag].get()->Message(MessageCode::TSinkResetTimer, sink->TimerTime); + WormholeLightArray1[sinkFlag].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); + WormholeLightArray2[sinkFlag].get()->Message(MessageCode::TLightSetOnStateBmpIndex, static_cast(2 - sinkFlag)); + WormholeLightArray2[sinkFlag].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); + WormholeSinkArray[sinkFlag].get()->Message(MessageCode::TSinkResetTimer, sink->TimerTime); return; } TableG->AddScore(sink->get_scoring(2)); @@ -1715,10 +1709,10 @@ void control::WormHoleControl(MessageCode code, TPinballComponent* caller) sinkFlag2 = sinkFlag; } - wormhole_tag_array2[sinkFlag2].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); - wormhole_tag_array3[sinkFlag2].get()->Message(MessageCode::TLightSetOnStateBmpIndex, static_cast(2 - sinkFlag2)); - wormhole_tag_array3[sinkFlag2].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); - wormhole_tag_array1[sinkFlag2].get()->Message(MessageCode::TSinkResetTimer, sink->TimerTime); + WormholeLightArray1[sinkFlag2].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); + WormholeLightArray2[sinkFlag2].get()->Message(MessageCode::TLightSetOnStateBmpIndex, static_cast(2 - sinkFlag2)); + WormholeLightArray2[sinkFlag2].get()->Message(MessageCode::TLightFlasherStartTimedThenStayOff, sink->TimerTime); + WormholeSinkArray[sinkFlag2].get()->Message(MessageCode::TSinkResetTimer, sink->TimerTime); info_text_box->Display(pb::get_rc_string(Msg::STRING150), 2.0); } } @@ -1767,13 +1761,13 @@ void control::BoosterTargetControl(MessageCode code, TPinballComponent* caller) TableG->AddScore(caller->get_scoring(0)); return; } - if (light_on(&control_lite61_tag)) + if (lite61->light_on()) { - if (light_on(&control_lite60_tag)) + if (lite60->light_on()) { - if (light_on(&control_lite59_tag)) + if (lite59->light_on()) { - if (light_on(&control_lite58_tag)) + if (lite58->light_on()) { TableG->AddScore(caller->get_scoring(1)); } @@ -1926,7 +1920,7 @@ void control::MissionSpotTargetControl(MessageCode code, TPinballComponent* call lite->Message(MessageCode::TLightFlasherStartTimedThenStayOn, 2.0); TSound* sound; - if (!light_on(&control_lite198_tag) || lite198->FlasherOnFlag) + if (!lite198->light_on() || lite198->FlasherOnFlag) { sound = soundwave52; } @@ -2015,7 +2009,7 @@ void control::WormHoleDestinationControl(MessageCode code, TPinballComponent* ca { if (code == MessageCode::ControlCollision) { - if (!light_on(&control_lite110_tag)) + if (!lite110->light_on()) { lite110->Message(MessageCode::TLightFlasherStartTimedThenStayOn, 3.0); info_text_box->Display(pb::get_rc_string(Msg::STRING194), 2.0); @@ -2046,7 +2040,7 @@ void control::FlagControl(MessageCode code, TPinballComponent* caller) } else if (code == MessageCode::ControlCollision) { - int score = caller->get_scoring(light_on(&control_lite20_tag)); + int score = caller->get_scoring(lite20->light_on()); TableG->AddScore(score); } } @@ -2095,7 +2089,7 @@ void control::SkillShotGate1Control(MessageCode code, TPinballComponent* caller) if (code == MessageCode::ControlCollision) { lite200->Message(MessageCode::TLightTurnOnTimed, 5.0); - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { skill_shot_lights->Message(MessageCode::TLightGroupReset, 0.0); skill_shot_lights->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -2112,7 +2106,7 @@ void control::SkillShotGate2Control(MessageCode code, TPinballComponent* caller) { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { lite68->Message(MessageCode::TLightResetAndTurnOn, 0.0); soundwave14_2->Play(lite68, "SkillShotGate2Control"); @@ -2124,7 +2118,7 @@ void control::SkillShotGate3Control(MessageCode code, TPinballComponent* caller) { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { lite69->Message(MessageCode::TLightResetAndTurnOn, 0.0); soundwave14_2->Play(lite69, "SkillShotGate3Control"); @@ -2136,7 +2130,7 @@ void control::SkillShotGate4Control(MessageCode code, TPinballComponent* caller) { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { lite131->Message(MessageCode::TLightResetAndTurnOn, 0.0); soundwave14_2->Play(lite131, "SkillShotGate4Control"); @@ -2148,7 +2142,7 @@ void control::SkillShotGate5Control(MessageCode code, TPinballComponent* caller) { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { lite132->Message(MessageCode::TLightResetAndTurnOn, 0.0); soundwave14_2->Play(lite132, "SkillShotGate5Control"); @@ -2160,7 +2154,7 @@ void control::SkillShotGate6Control(MessageCode code, TPinballComponent* caller) { if (code == MessageCode::ControlCollision) { - if (light_on(&control_lite67_tag)) + if (lite67->light_on()) { lite133->Message(MessageCode::TLightResetAndTurnOn, 0.0); soundwave14_2->Play(lite133, "SkillShotGate6Control"); @@ -2389,16 +2383,16 @@ void control::HyperspaceKickOutControl(MessageCode code, TPinballComponent* call } int someFlag = 0; - if (light_on(&control_lite25_tag)) + if (lite25->light_on()) { someFlag = 1; auto addedScore = SpecialAddScore(TableG->ScoreSpecial1); snprintf(Buffer, sizeof Buffer, pb::get_rc_string(Msg::STRING111), addedScore); info_text_box->Display(Buffer, 2.0); } - if (light_on(&control_lite26_tag)) + if (lite26->light_on()) someFlag |= 2u; - if (light_on(&control_lite130_tag)) + if (lite130->light_on()) { someFlag |= 4u; lite130->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -2483,7 +2477,7 @@ void control::PlungerControl(MessageCode code, TPinballComponent* caller) table_unlimited_balls = false; if (!middle_circle->Message(MessageCode::TLightGroupGetOnCount, 0.0)) middle_circle->Message(MessageCode::TLightGroupOffsetAnimationForward, 0.0); - if (!light_on(&control_lite200_tag)) + if (!lite200->light_on()) { skill_shot_lights->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite67->Message(MessageCode::TLightResetAndTurnOn, 0.0); @@ -2627,14 +2621,14 @@ void control::BallDrainControl(MessageCode code, TPinballComponent* caller) lite199->Message(MessageCode::TLightResetAndTurnOff, 0.0); midi::play_track(MidiTracks::Track1, false); } - if (light_on(&control_lite200_tag)) + if (lite200->light_on()) { soundwave27->Play(nullptr, "BallDrainControl2"); lite200->Message(MessageCode::TLightResetAndTurnOn, 0.0); info_text_box->Display(pb::get_rc_string(Msg::STRING197), -1.0); soundwave59->Play(nullptr, "BallDrainControl3"); } - else if (light_on(&control_lite199_tag)) + else if (lite199->light_on()) { soundwave27->Play(nullptr, "BallDrainControl4"); lite199->Message(MessageCode::TLightResetAndTurnOff, 0.0); @@ -2771,7 +2765,7 @@ void control::BallDrainControl(MessageCode code, TPinballComponent* caller) lite198->MessageField = 0; MissionControl(MessageCode::ControlMissionComplete, nullptr); TableG->Message(MessageCode::ClearTiltLock, 0.0); - if (light_on(&control_lite58_tag)) + if (lite58->light_on()) lite58->Message(MessageCode::TLightResetAndTurnOff, 0.0); else TableG->ScoreSpecial2 = 25000; @@ -2891,9 +2885,9 @@ void control::BlackHoleThreatController(MessageCode code, TPinballComponent* cal if (kickout3 == caller && bump5->BmpIndex) { - if (light_on(&control_lite316_tag)) + if (lite316->light_on()) lite316->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite314_tag)) + if (lite314->light_on()) lite314->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite198->MessageField = 1; MissionControl(MessageCode::ControlMissionComplete, nullptr); @@ -2920,9 +2914,9 @@ void control::BlackHoleThreatController(MessageCode code, TPinballComponent* cal if (bump5->BmpIndex) { mission_text_box->Display(pb::get_rc_string(Msg::STRING224), -1.0); - if (light_on(&control_lite316_tag)) + if (lite316->light_on()) lite316->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite314_tag)) + if (!lite314->light_on()) { lite314->Message(MessageCode::TLightFlasherStartTimed, 0.0); } @@ -2930,9 +2924,9 @@ void control::BlackHoleThreatController(MessageCode code, TPinballComponent* cal else { mission_text_box->Display(pb::get_rc_string(Msg::STRING223), -1.0); - if (light_on(&control_lite314_tag)) + if (lite314->light_on()) lite314->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite316_tag)) + if (!lite316->light_on()) { lite316->Message(MessageCode::TLightFlasherStartTimed, 0.0); } @@ -3767,7 +3761,7 @@ void control::RescueMissionController(MessageCode code, TPinballComponent* calle MissionControl(MessageCode::ControlMissionStarted, caller); return; } - if (kickout2 != caller || !light_on(&control_lite20_tag)) + if (kickout2 != caller || !lite20->light_on()) return; lite56->MessageField = lite56->MessageField - 1; if (lite56->MessageField) @@ -3775,9 +3769,9 @@ void control::RescueMissionController(MessageCode code, TPinballComponent* calle MissionControl(MessageCode::ControlMissionStarted, caller); return; } - if (light_on(&control_lite303_tag)) + if (lite303->light_on()) lite303->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite304_tag)) + if (lite304->light_on()) lite304->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite198->MessageField = 1; MissionControl(MessageCode::ControlMissionComplete, nullptr); @@ -3797,12 +3791,12 @@ void control::RescueMissionController(MessageCode code, TPinballComponent* calle lite56->MessageField = 1; break; case MessageCode::ControlMissionStarted: - if (light_on(&control_lite20_tag)) + if (lite20->light_on()) { mission_text_box->Display(pb::get_rc_string(Msg::STRING229), -1.0); - if (light_on(&control_lite303_tag)) + if (lite303->light_on()) lite303->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite304_tag)) + if (!lite304->light_on()) { lite304->Message(MessageCode::TLightFlasherStartTimed, 0.0); } @@ -3810,9 +3804,9 @@ void control::RescueMissionController(MessageCode code, TPinballComponent* calle else { mission_text_box->Display(pb::get_rc_string(Msg::STRING228), -1.0); - if (light_on(&control_lite304_tag)) + if (lite304->light_on()) lite304->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite303_tag)) + if (!lite303->light_on()) { lite303->Message(MessageCode::TLightFlasherStartTimed, 0.0); } @@ -4053,17 +4047,17 @@ void control::SelectMissionController(MessageCode code, TPinballComponent* calle if (!missionLevel) { if (ramp == caller - && light_on(&control_lite56_tag) + && lite56->light_on() && fuel_bargraph->Message(MessageCode::TLightGroupGetOnCount, 0.0)) { lite56->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite198->Message(MessageCode::TLightResetAndTurnOn, 0.0); outer_circle->Message(MessageCode::TLightGroupAnimationBackward, -1.0); - if (light_on(&control_lite317_tag)) + if (lite317->light_on()) lite317->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite318_tag)) + if (lite318->light_on()) lite318->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite319_tag)) + if (lite319->light_on()) lite319->Message(MessageCode::TLightResetAndTurnOff, 0.0); lite198->MessageField = lite56->MessageField; auto scoreId = lite56->MessageField - 2; @@ -4207,26 +4201,26 @@ void control::SelectMissionController(MessageCode code, TPinballComponent* calle if (fuel_bargraph->Message(MessageCode::TLightGroupGetOnCount, 0.0)) { - if (light_on(&control_lite56_tag)) + if (lite56->light_on() && lite56->MessageField >= 2) { auto missionText = pb::get_rc_string(MissionRcArray[lite56->MessageField - 2]); snprintf(Buffer, sizeof Buffer, pb::get_rc_string(Msg::STRING207), missionText); mission_text_box->Display(Buffer, -1.0); - if (light_on(&control_lite318_tag)) + if (lite318->light_on()) lite318->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite319_tag)) + if (lite319->light_on()) lite319->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite317_tag)) + if (!lite317->light_on()) lite317->Message(MessageCode::TLightFlasherStartTimed, 0.0); } else { mission_text_box->Display(pb::get_rc_string(Msg::STRING205), -1.0); - if (light_on(&control_lite317_tag)) + if (lite317->light_on()) lite317->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite318_tag)) + if (lite318->light_on()) lite318->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite319_tag)) + if (!lite319->light_on()) { lite319->Message(MessageCode::TLightFlasherStartTimed, 0.0); } @@ -4235,11 +4229,11 @@ void control::SelectMissionController(MessageCode code, TPinballComponent* calle else { mission_text_box->Display(pb::get_rc_string(Msg::STRING206), -1.0); - if (light_on(&control_lite317_tag)) + if (lite317->light_on()) lite317->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (light_on(&control_lite319_tag)) + if (lite319->light_on()) lite319->Message(MessageCode::TLightResetAndTurnOff, 0.0); - if (!light_on(&control_lite318_tag)) + if (!lite318->light_on()) { lite318->Message(MessageCode::TLightFlasherStartTimed, 0.0); } diff --git a/SpaceCadetPinball/control.h b/SpaceCadetPinball/control.h index 0a12a77..71894e7 100644 --- a/SpaceCadetPinball/control.h +++ b/SpaceCadetPinball/control.h @@ -71,8 +71,8 @@ public: static bool table_unlimited_balls; static Msg RankRcArray[9], MissionRcArray[17]; static int mission_select_scores[17]; - static std::reference_wrapper wormhole_tag_array1[3]; - static std::reference_wrapper wormhole_tag_array2[3], wormhole_tag_array3[3]; + static std::reference_wrapper WormholeSinkArray[3]; + static std::reference_wrapper WormholeLightArray1[3], WormholeLightArray2[3]; static void make_links(TPinballTable* table); static void ClearLinks(); @@ -88,7 +88,6 @@ public: static void table_bump_ball_sink_lock(); static void table_set_replay(float value); static void cheat_bump_rank(); - static bool light_on(component_tag* tag); static int SpecialAddScore(int score); static int AddRankProgress(int rank); static void AdvanceWormHoleDestination(int flag);