1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-17 15:20:17 +01:00

Code from FT: simplified score access in TPinballComponent.

This commit is contained in:
Muzychenko Andrey 2022-08-18 16:23:29 +03:00
parent e9a4791322
commit 7feba1e947
24 changed files with 13 additions and 170 deletions

View file

@ -109,18 +109,6 @@ void TBumper::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
}
}
void TBumper::put_scoring(int index, int score)
{
if (index < 4)
Scores[index] = score;
}
int TBumper::get_scoring(int index)
{
return index < 4 ? Scores[index] : 0;
}
void TBumper::TimerExpired(int timerId, void* caller)
{
auto bump = static_cast<TBumper*>(caller);

View file

@ -16,8 +16,6 @@ public:
int Message(int code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Fire();
static void TimerExpired(int timerId, void* caller);
@ -28,6 +26,5 @@ public:
float OriginalThreshold;
int SoundIndex4;
int SoundIndex3;
int Scores[4]{};
TBumper_player_backup PlayerData[4]{};
};

View file

@ -92,17 +92,6 @@ void TFlagSpinner::Collision(TBall* ball, vector2* nextPosition, vector2* direct
NextFrame();
}
void TFlagSpinner::put_scoring(int index, int score)
{
if (index < 2)
Scores[index] = score;
}
int TFlagSpinner::get_scoring(int index)
{
return index < 2 ? Scores[index] : 0;
}
void TFlagSpinner::NextFrame()
{
BmpIndex += SpinDirection;

View file

@ -9,8 +9,6 @@ public:
int Message(int code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void NextFrame();
static void SpinTimer(int timerId, void* caller);
@ -23,6 +21,5 @@ public:
int BmpIndex{};
int Timer;
TEdgeSegment* PrevCollider;
int Scores[2]{};
};

View file

@ -93,17 +93,6 @@ int TKickout::Message(int code, float value)
return 0;
}
void TKickout::put_scoring(int index, int score)
{
if (index < 5)
Scores[index] = score;
}
int TKickout::get_scoring(int index)
{
return index < 5 ? Scores[index] : 0;
}
void TKickout::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance, TEdgeSegment* edge)
{
if (!KickFlag1)

View file

@ -9,8 +9,6 @@ class TKickout :
public:
TKickout(TPinballTable* table, int groupIndex, bool someFlag);
int Message(int code, float value) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
int FieldEffect(TBall* ball, vector2* vecDst) override;
@ -33,5 +31,4 @@ public:
float ThrowSpeedMult1;
float ThrowSpeedMult2;
field_effect_type Field{};
int Scores[5]{};
};

View file

@ -72,14 +72,3 @@ void TOneway::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
loader::play_sound(SoftHitSoundId, ball, "TOneway2");
}
}
void TOneway::put_scoring(int index, int score)
{
if (index < 6)
Scores[index] = score;
}
int TOneway::get_scoring(int index)
{
return index < 6 ? Scores[index] : 0;
}

View file

@ -10,9 +10,6 @@ public:
~TOneway() override = default;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
TLine* Line;
int Scores[6]{};
};

View file

@ -1,5 +1,7 @@
#include "pch.h"
#include "TPinballComponent.h"
#include "control.h"
#include "loader.h"
#include "proj.h"
#include "render.h"
@ -115,13 +117,9 @@ void TPinballComponent::port_draw()
{
}
void TPinballComponent::put_scoring(int index, int score)
int TPinballComponent::get_scoring(unsigned int index) const
{
}
int TPinballComponent::get_scoring(int index)
{
return 0;
return Control == nullptr || index >= Control->ScoreCount ? 0 : Control->Scores[index];
}
vector2 TPinballComponent::get_coordinates()

View file

@ -22,8 +22,7 @@ public:
virtual ~TPinballComponent();
virtual int Message(int code, float value);
virtual void port_draw();
virtual void put_scoring(int index, int score);
virtual int get_scoring(int index);
int get_scoring(unsigned int index) const;
virtual vector2 get_coordinates();
char UnusedBaseFlag;

View file

@ -51,17 +51,6 @@ int TPopupTarget::Message(int code, float value)
return 0;
}
void TPopupTarget::put_scoring(int index, int score)
{
if (index < 3)
Scores[index] = score;
}
int TPopupTarget::get_scoring(int index)
{
return index < 3 ? Scores[index] : 0;
}
void TPopupTarget::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge)
{

View file

@ -7,8 +7,6 @@ class TPopupTarget :
public:
TPopupTarget(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
@ -16,6 +14,5 @@ public:
int Timer;
float TimerTime;
int Scores[3]{};
int PlayerMessagefieldBackup[4]{};
};

View file

@ -127,17 +127,6 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
TTableLayer::edges_insert_square(y0, x0, y1, x1, nullptr, &Field);
}
void TRamp::put_scoring(int index, int score)
{
if (index < 4)
Scores[index] = score;
}
int TRamp::get_scoring(int index)
{
return index < 4 ? Scores[index] : 0;
}
void TRamp::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance, TEdgeSegment* edge)
{
ball->not_again(edge);

View file

@ -10,14 +10,11 @@ class TRamp :
{
public:
TRamp(TPinballTable* table, int groupIndex);
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
int FieldEffect(TBall* ball, vector2* vecDst) override;
void port_draw() override;
int Scores[4]{};
field_effect_type Field{};
int CollisionGroup;
bool BallZOffsetFlag;

View file

@ -67,18 +67,6 @@ void TRollover::Collision(TBall* ball, vector2* nextPosition, vector2* direction
}
}
void TRollover::put_scoring(int index, int score)
{
if (index < 2)
Scores[index] = score;
}
int TRollover::get_scoring(int index)
{
return index < 2 ? Scores[index] : 0;
}
void TRollover::build_walls(int groupIndex)
{
visualStruct visual{};

View file

@ -12,12 +12,9 @@ public:
int Message(int code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void build_walls(int groupIndex);
static void TimerExpired(int timerId, void* caller);
char RolloverFlag{};
int Scores[2]{};
};

View file

@ -64,17 +64,6 @@ int TSink::Message(int code, float value)
return 0;
}
void TSink::put_scoring(int index, int score)
{
if (index < 3)
Scores[index] = score;
}
int TSink::get_scoring(int index)
{
return index < 3 ? Scores[index] : 0;
}
void TSink::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance, TEdgeSegment* edge)
{
Timer = 0;

View file

@ -8,8 +8,6 @@ class TSink :
public:
TSink(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
@ -24,6 +22,5 @@ public:
float ThrowSpeedMult2;
int SoundIndex4;
int SoundIndex3;
int Scores[3]{};
int PlayerMessagefieldBackup[4]{};
};

View file

@ -53,17 +53,6 @@ int TSoloTarget::Message(int code, float value)
return 0;
}
void TSoloTarget::put_scoring(int index, int score)
{
if (index < 1)
Scores[index] = score;
}
int TSoloTarget::get_scoring(int index)
{
return index < 1 ? Scores[index] : 0;
}
void TSoloTarget::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge)
{

View file

@ -7,8 +7,6 @@ class TSoloTarget :
public:
TSoloTarget(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
@ -17,5 +15,4 @@ public:
int Timer;
float TimerTime;
int SoundIndex4;
int Scores[1]{};
};

View file

@ -37,17 +37,6 @@ void TWall::Collision(TBall* ball, vector2* nextPosition, vector2* direction, fl
}
}
void TWall::put_scoring(int index, int score)
{
if (index < 1)
Scores[index] = score;
}
int TWall::get_scoring(int index)
{
return index < 1 ? Scores[index] : 0;
}
void TWall::TimerExpired(int timerId, void* caller)
{
auto wall = static_cast<TWall*>(caller);

View file

@ -12,12 +12,9 @@ public:
int Message(int code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void put_scoring(int index, int score) override;
int get_scoring(int index) override;
static void TimerExpired(int timerId, void* caller);
int Timer{};
gdrv_bitmap8* BmpPtr{};
int Scores[1]{};
};

View file

@ -806,22 +806,17 @@ void control::make_links(TPinballTable* table)
{
TableG = table;
for (int index = 0; index < 88; index++)
for (auto& score_component : score_components)
{
auto compPtr = &score_components[index];
TPinballComponent* comp = make_component_link(compPtr->Tag);
if (comp)
auto linkedComp = make_component_link(score_component.Tag);
if (linkedComp)
{
comp->Control = &compPtr->Control;
for (int scoreId = 0; scoreId < compPtr->Control.ScoreCount; scoreId++)
{
comp->put_scoring(scoreId, compPtr->Control.Scores[scoreId]);
}
linkedComp->Control = &score_component.Control;
}
}
for (int i = 0; i < 142; ++i)
make_component_link(*simple_components[i]);
for (auto& simple_component : simple_components)
make_component_link(*simple_component);
}
void control::ClearLinks()
@ -859,13 +854,6 @@ void control::handler(int code, TPinballComponent* cmp)
if (control)
{
if (code == 1019)
{
for (auto scoreInd = 0; scoreInd < control->ScoreCount; ++scoreInd)
{
cmp->put_scoring(scoreInd, control->Scores[scoreInd]);
}
}
control->ControlFunc(code, cmp);
}
MissionControl(code, cmp);

View file

@ -47,8 +47,8 @@ struct component_tag : component_tag_base
struct component_control
{
void (* ControlFunc)(int, TPinballComponent*);
int ScoreCount;
int* Scores;
unsigned int ScoreCount;
const int* Scores;
};
struct component_info