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

TPinballComponent: replaced calloc operator new with member initialization.

This commit is contained in:
Muzychenko Andrey 2021-10-02 18:58:54 +03:00
parent 93de90b680
commit 261457a959
30 changed files with 119 additions and 142 deletions

View file

@ -17,21 +17,20 @@ public :
static void throw_ball(TBall* ball, struct vector_type* acceleration, float angleMult, float speedMult1, static void throw_ball(TBall* ball, struct vector_type* acceleration, float angleMult, float speedMult1,
float speedMult2); float speedMult2);
vector_type Position; vector_type Position{};
vector_type Acceleration; vector_type Acceleration{};
float Speed; float Speed;
float RayMaxDistance; float RayMaxDistance;
float TimeDelta; float TimeDelta;
float TimeNow; float TimeNow;
vector_type InvAcceleration; vector_type InvAcceleration{};
vector_type RampFieldForce; vector_type RampFieldForce{};
TCollisionComponent* CollisionComp; TCollisionComponent* CollisionComp;
int FieldFlag; int FieldFlag;
TEdgeSegment* Collisions[5]; TEdgeSegment* Collisions[5]{};
int EdgeCollisionCount; int EdgeCollisionCount;
vector_type CollisionOffset; vector_type CollisionOffset{};
int CollisionFlag; int CollisionFlag;
float Offset; float Offset;
int Unknown29; float VisualZArray[50]{};
float VisualZArray[50];
}; };

View file

@ -28,6 +28,6 @@ public:
float OriginalThreshold; float OriginalThreshold;
int SoundIndex4; int SoundIndex4;
int SoundIndex3; int SoundIndex3;
int Scores[4]; int Scores[4]{};
TBumper_player_backup PlayerData[4]; TBumper_player_backup PlayerData[4]{};
}; };

View file

@ -6,7 +6,7 @@ class TCircle :
public TEdgeSegment public TEdgeSegment
{ {
public: public:
circle_type Circle; circle_type Circle{};
TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, vector_type* center, TCircle(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup, vector_type* center,
float radius); float radius);

View file

@ -35,5 +35,5 @@ public:
float X; float X;
float Y; float Y;
TEdgeBox* BoxArray; TEdgeBox* BoxArray;
TEdgeSegment* EdgeArray[1000]; TEdgeSegment* EdgeArray[1000]{};
}; };

View file

@ -16,7 +16,7 @@ public:
TCollisionComponent* CollisionComponent; TCollisionComponent* CollisionComponent;
char* ActiveFlag; char* ActiveFlag;
char ProcessedFlag; char ProcessedFlag;
void* WallValue; void* WallValue{};
unsigned int CollisionGroup; unsigned int CollisionGroup;
TEdgeSegment(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup); TEdgeSegment(TCollisionComponent* collComp, char* activeFlag, unsigned int collisionGroup);

View file

@ -15,14 +15,14 @@ public:
static void SpinTimer(int timerId, void* caller); static void SpinTimer(int timerId, void* caller);
float Speed; float Speed{};
float MaxSpeed; float MaxSpeed;
float MinSpeed; float MinSpeed;
float SpeedDecrement; float SpeedDecrement;
int SpinDirection; int SpinDirection{};
int BmpIndex; int BmpIndex{};
int Timer; int Timer;
TEdgeSegment* PrevCollider; TEdgeSegment* PrevCollider;
int Scores[2]; int Scores[2]{};
}; };

View file

@ -19,8 +19,8 @@ public:
int BmpIndex; int BmpIndex;
TFlipperEdge* FlipperEdge; TFlipperEdge* FlipperEdge;
int Timer; int Timer;
float BmpCoef1; float BmpCoef1{};
float BmpCoef2; float BmpCoef2{};
float TimerTime; float TimerTime{};
float InputTime; float InputTime;
}; };

View file

@ -23,7 +23,7 @@ public:
int FlipperFlag; int FlipperFlag;
float Elasticity; float Elasticity;
float Smoothness; float Smoothness;
vector_type RotOrigin; vector_type RotOrigin{};
float CirclebaseRadius; float CirclebaseRadius;
float CircleT1Radius; float CircleT1Radius;
float CirclebaseRadiusSq; float CirclebaseRadiusSq;
@ -31,28 +31,28 @@ public:
float CirclebaseRadiusMSq; float CirclebaseRadiusMSq;
float CircleT1RadiusMSq; float CircleT1RadiusMSq;
float AngleMax; float AngleMax;
float Angle2; float Angle2{};
float Angle1; float Angle1;
int CollisionFlag1; int CollisionFlag1;
int CollisionFlag2; int CollisionFlag2{};
vector_type CollisionLinePerp; vector_type CollisionLinePerp{};
vector_type A1Src; vector_type A1Src{};
vector_type A2Src; vector_type A2Src{};
vector_type B1Src; vector_type B1Src{};
vector_type B2Src; vector_type B2Src{};
float CollisionMult; float CollisionMult;
vector_type T1Src; vector_type T1Src{};
vector_type T2Src; vector_type T2Src{};
float DistanceDivSq; float DistanceDivSq;
float CollisionTimeAdvance; float CollisionTimeAdvance;
vector_type CollisionDirection; vector_type CollisionDirection{};
int EdgeCollisionFlag; int EdgeCollisionFlag;
float InputTime; float InputTime;
float AngleStopTime; float AngleStopTime;
float AngleMult; float AngleMult;
float BmpCoef1; float BmpCoef1;
float BmpCoef2; float BmpCoef2;
vector_type NextBallPosition; vector_type NextBallPosition{};
static float flipper_sin_angle, flipper_cos_angle; static float flipper_sin_angle, flipper_cos_angle;
static vector_type A1, A2, B1, B2, T1; static vector_type A1, A2, B1, B2, T1;

View file

@ -16,7 +16,7 @@ public:
static void TimerExpired(int timerId, void* caller); static void TimerExpired(int timerId, void* caller);
int BallCapturedFlag; int BallCapturedFlag;
int BallCapturedSecondStage; int BallCapturedSecondStage{};
int Timer; int Timer;
float Unknown3; float Unknown3;
float Unknown4; float Unknown4;
@ -24,6 +24,6 @@ public:
float ZSetValue; float ZSetValue;
int FieldFlag; int FieldFlag;
float GravityPull; float GravityPull;
circle_type Circle; circle_type Circle{};
field_effect_type Field; field_effect_type Field{};
}; };

View file

@ -13,8 +13,8 @@ TKickback::TKickback(TPinballTable* table, int groupIndex): TCollisionComponent(
{ {
MessageField = 0; MessageField = 0;
Timer = 0; Timer = 0;
ActiveFlag = 0; KickActiveFlag = 0;
TimerTime = 0.69999999f; TimerTime = 0.7f;
TimerTime2 = 0.1f; TimerTime2 = 0.1f;
Threshold = 1000000000.0f; Threshold = 1000000000.0f;
} }
@ -27,7 +27,7 @@ int TKickback::Message(int code, float value)
if (ListBitmap) if (ListBitmap)
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
Timer = 0; Timer = 0;
ActiveFlag = 0; KickActiveFlag = 0;
Threshold = 1000000000.0; Threshold = 1000000000.0;
} }
return 0; return 0;
@ -43,14 +43,14 @@ void TKickback::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
} }
else else
{ {
if (!ActiveFlag) if (!KickActiveFlag)
{ {
Threshold = 1000000000.0; Threshold = 1000000000.0;
ActiveFlag = 1; KickActiveFlag = 1;
Timer = timer::set(TimerTime, this, TimerExpired); Timer = timer::set(TimerTime, this, TimerExpired);
} }
if (DefaultCollision(ball, nextPosition, direction)) if (DefaultCollision(ball, nextPosition, direction))
ActiveFlag = 0; KickActiveFlag = 0;
} }
} }
@ -58,7 +58,7 @@ void TKickback::TimerExpired(int timerId, void* caller)
{ {
auto kick = static_cast<TKickback*>(caller); auto kick = static_cast<TKickback*>(caller);
if (kick->ActiveFlag) if (kick->KickActiveFlag)
{ {
kick->Threshold = 0.0; kick->Threshold = 0.0;
kick->Timer = timer::set(kick->TimerTime2, kick, TimerExpired); kick->Timer = timer::set(kick->TimerTime2, kick, TimerExpired);

View file

@ -15,5 +15,5 @@ public:
float TimerTime; float TimerTime;
float TimerTime2; float TimerTime2;
int Timer; int Timer;
int ActiveFlag; int KickActiveFlag;
}; };

View file

@ -24,14 +24,14 @@ public:
float TimerTime1; float TimerTime1;
float TimerTime2; float TimerTime2;
float CollisionBallSetZ; float CollisionBallSetZ;
TBall* Ball; TBall* Ball{};
float FieldMult; float FieldMult;
circle_type Circle; circle_type Circle{};
float OriginalBallZ; float OriginalBallZ{};
vector_type BallAcceleration; vector_type BallAcceleration{};
float ThrowAngleMult; float ThrowAngleMult;
float ThrowSpeedMult1; float ThrowSpeedMult1;
float ThrowSpeedMult2; float ThrowSpeedMult2;
field_effect_type Field; field_effect_type Field{};
int Scores[5]; int Scores[5]{};
}; };

View file

@ -40,17 +40,16 @@ public:
static void flasher_start(struct flasher_type* flash, int bmpIndex); static void flasher_start(struct flasher_type* flash, int bmpIndex);
static void flasher_callback(int timerId, void* caller); static void flasher_callback(int timerId, void* caller);
flasher_type Flasher; flasher_type Flasher{};
int BmpIndex1; int BmpIndex1{};
int FlasherActive; int FlasherActive;
int FlasherFlag1; int FlasherFlag1{};
int FlasherFlag2; int FlasherFlag2{};
int TurnOffAfterFlashingFg; int TurnOffAfterFlashingFg{};
int BmpIndex2; int BmpIndex2{};
float FlasherDelay[2]; float FlasherDelay[2]{};
int Timer1; int Timer1;
int Timer2; int Timer2;
int Unknown19; float Unknown20F{};
float Unknown20F; TLight_player_backup PlayerData[4]{};
TLight_player_backup PlayerData[4];
}; };

View file

@ -13,7 +13,7 @@ public:
static void BargraphTimerExpired(int timerId, void* caller); static void BargraphTimerExpired(int timerId, void* caller);
float* TimerTimeArray; float* TimerTimeArray;
int TimerBargraph; int TimerBargraph{};
int TimeIndex; int TimeIndex{};
int PlayerTimerIndexBackup[4]; int PlayerTimerIndexBackup[4]{};
}; };

View file

@ -28,10 +28,6 @@ TLightGroup::TLightGroup(TPinballTable* table, int groupIndex) : TPinballCompone
} }
} }
TLightGroup::~TLightGroup()
{
}
int TLightGroup::Message(int code, float value) int TLightGroup::Message(int code, float value)
{ {
auto count = static_cast<int>(List.size()); auto count = static_cast<int>(List.size());

View file

@ -18,7 +18,7 @@ class TLightGroup :
{ {
public: public:
TLightGroup(TPinballTable* table, int groupIndex); TLightGroup(TPinballTable* table, int groupIndex);
~TLightGroup() override; ~TLightGroup() override = default;
int Message(int code, float value) override; int Message(int code, float value) override;
virtual void Reset(); virtual void Reset();
void reschedule_animation(float time); void reschedule_animation(float time);
@ -30,11 +30,11 @@ public:
static void NotifyTimerExpired(int timerId, void* caller); static void NotifyTimerExpired(int timerId, void* caller);
std::vector<TLight*> List; std::vector<TLight*> List;
float Timer1Time; float Timer1Time{};
float Timer1TimeDefault; float Timer1TimeDefault;
int MessageField2; int MessageField2{};
int AnimationFlag; int AnimationFlag{};
int NotifyTimer; int NotifyTimer;
int Timer; int Timer;
TLightGroup_player_backup PlayerData[4]; TLightGroup_player_backup PlayerData[4]{};
}; };

View file

@ -6,7 +6,7 @@ class TLine :
public TEdgeSegment public TEdgeSegment
{ {
public: public:
line_type Line; line_type Line{};
float X0, Y0, X1, Y1; float X0, Y0, X1, Y1;
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1); TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, float x0, float y0, float x1, float y1);
TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector_type* start, vector_type* end); TLine(TCollisionComponent* collCmp, char* activeFlag, unsigned int collisionGroup, vector_type* start, vector_type* end);

View file

@ -14,5 +14,5 @@ public:
int get_scoring(int index) override; int get_scoring(int index) override;
TLine* Line; TLine* Line;
int Scores[6]; int Scores[6]{};
}; };

View file

@ -111,13 +111,3 @@ int TPinballComponent::get_scoring(int index)
{ {
return 0; return 0;
} }
void* TPinballComponent::operator new(size_t Size)
{
return calloc(1u, Size);
}
void TPinballComponent::operator delete(void* p)
{
free(p); /*Original does not have this*/
}

View file

@ -24,9 +24,6 @@ public:
virtual void put_scoring(int index, int score); virtual void put_scoring(int index, int score);
virtual int get_scoring(int index); virtual int get_scoring(int index);
void* operator new(size_t Size);
void operator delete(void* p);
char UnusedBaseFlag; char UnusedBaseFlag;
char ActiveFlag; char ActiveFlag;
int MessageField; int MessageField;

View file

@ -45,54 +45,54 @@ public:
scoreStruct* CurScoreStruct; scoreStruct* CurScoreStruct;
scoreStruct* ScoreBallcount; scoreStruct* ScoreBallcount;
scoreStruct* ScorePlayerNumber1; scoreStruct* ScorePlayerNumber1;
int CheatsUsed; int CheatsUsed{};
int SoundIndex1; int SoundIndex1{};
int SoundIndex2; int SoundIndex2{};
int SoundIndex3; int SoundIndex3{};
int BallInSink; int BallInSink;
int CurScore; int CurScore{};
int CurScoreE9; int CurScoreE9{};
int LightShowTimer; int LightShowTimer;
int EndGameTimeoutTimer; int EndGameTimeoutTimer;
int TiltTimeoutTimer; int TiltTimeoutTimer;
score_struct_super PlayerScores[4]; score_struct_super PlayerScores[4]{};
int PlayerCount; int PlayerCount;
int CurrentPlayer; int CurrentPlayer;
TPlunger* Plunger; TPlunger* Plunger;
TDrain* Drain; TDrain* Drain;
TDemo* Demo; TDemo* Demo{};
int XOffset; int XOffset{};
int YOffset; int YOffset{};
int Width; int Width{};
int Height; int Height{};
std::vector<TPinballComponent*> ComponentList; std::vector<TPinballComponent*> ComponentList;
std::vector<TBall*> BallList; std::vector<TBall*> BallList;
TLightGroup* LightGroup; TLightGroup* LightGroup;
float GravityDirVectMult; float GravityDirVectMult{};
float GravityAngleX; float GravityAngleX{};
float GravityAnglY; float GravityAnglY{};
float CollisionCompOffset; float CollisionCompOffset{};
float PlungerPositionX; float PlungerPositionX{};
float PlungerPositionY; float PlungerPositionY{};
int ScoreMultiplier; int ScoreMultiplier{};
int ScoreAdded; int ScoreAdded{};
int ScoreSpecial1; int ScoreSpecial1{};
int ScoreSpecial2; int ScoreSpecial2{};
int ScoreSpecial2Flag; int ScoreSpecial2Flag{};
int ScoreSpecial3; int ScoreSpecial3{};
int ScoreSpecial3Flag; int ScoreSpecial3Flag{};
int UnknownP71; int UnknownP71{};
int BallCount; int BallCount{};
int MaxBallCount; int MaxBallCount;
int ExtraBalls; int ExtraBalls{};
int UnknownP75; int UnknownP75{};
int BallLockedCounter; int BallLockedCounter{};
int MultiballFlag; int MultiballFlag;
int UnknownP78; int UnknownP78{};
int ReplayActiveFlag; int ReplayActiveFlag{};
int ReplayTimer; int ReplayTimer;
int UnknownP81; int UnknownP81{};
int UnknownP82; int UnknownP82{};
int TiltLockFlag; int TiltLockFlag;
private: private:

View file

@ -16,6 +16,6 @@ public:
int Timer; int Timer;
float TimerTime; float TimerTime;
int Scores[3]; int Scores[3]{};
int PlayerMessagefieldBackup[4]; int PlayerMessagefieldBackup[4]{};
}; };

View file

@ -17,8 +17,8 @@ public:
int FieldEffect(TBall* ball, vector_type* vecDst) override; int FieldEffect(TBall* ball, vector_type* vecDst) override;
void port_draw() override; void port_draw() override;
int Scores[4]; int Scores[4]{};
field_effect_type Field; field_effect_type Field{};
int CollisionGroup; int CollisionGroup;
int RampFlag1; int RampFlag1;
int RampPlaneCount; int RampPlaneCount;

View file

@ -19,7 +19,6 @@ TRollover::TRollover(TPinballTable* table, int groupIndex, bool createWall) : TC
TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false) TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
{ {
RolloverFlag = 0;
if (ListBitmap) if (ListBitmap)
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0)); render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
build_walls(groupIndex); build_walls(groupIndex);

View file

@ -18,6 +18,6 @@ public:
static void TimerExpired(int timerId, void* caller); static void TimerExpired(int timerId, void* caller);
char RolloverFlag; char RolloverFlag{};
int Scores[2]; int Scores[2]{};
}; };

View file

@ -17,13 +17,13 @@ public:
int Timer; int Timer;
float TimerTime; float TimerTime;
vector_type BallPosition; vector_type BallPosition{};
vector_type BallAcceleration; vector_type BallAcceleration{};
float ThrowAngleMult; float ThrowAngleMult;
float ThrowSpeedMult1; float ThrowSpeedMult1;
float ThrowSpeedMult2; float ThrowSpeedMult2;
int SoundIndex4; int SoundIndex4;
int SoundIndex3; int SoundIndex3;
int Scores[3]; int Scores[3]{};
int PlayerMessagefieldBackup[4]; int PlayerMessagefieldBackup[4]{};
}; };

View file

@ -14,9 +14,8 @@ public:
static void TimerExpired(int timerId, void* caller); static void TimerExpired(int timerId, void* caller);
int Unknown0;
int Timer; int Timer;
float TimerTime; float TimerTime;
int SoundIndex4; int SoundIndex4;
int Scores[1]; int Scores[1]{};
}; };

View file

@ -27,9 +27,8 @@ public:
float Unknown4F; float Unknown4F;
float GraityDirX; float GraityDirX;
float GraityDirY; float GraityDirY;
int Unknown7;
float GraityMult; float GraityMult;
field_effect_type Field; field_effect_type Field{};
static TEdgeManager* edge_manager; static TEdgeManager* edge_manager;
}; };

View file

@ -12,7 +12,6 @@ TWall::TWall(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
render::sprite_set_bitmap(RenderSprite, nullptr); render::sprite_set_bitmap(RenderSprite, nullptr);
if (ListBitmap) if (ListBitmap)
BmpPtr = ListBitmap->at(0); BmpPtr = ListBitmap->at(0);
Timer = 0;
} }
int TWall::Message(int code, float value) int TWall::Message(int code, float value)

View file

@ -17,7 +17,7 @@ public:
static void TimerExpired(int timerId, void* caller); static void TimerExpired(int timerId, void* caller);
int Timer; int Timer{};
gdrv_bitmap8* BmpPtr; gdrv_bitmap8* BmpPtr{};
int Scores[1]; int Scores[1]{};
}; };