1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-07-21 16:23:34 +02:00

Message code enum part 2: all components except for lights.

This commit is contained in:
Muzychenko Andrey 2022-09-06 11:58:35 +03:00
parent 44d5fd5097
commit 803ca14ef2
42 changed files with 329 additions and 303 deletions

View file

@ -11,7 +11,7 @@
#include "TPinballTable.h"
#include "TTableLayer.h"
TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
TBall::TBall(TPinballTable* table) : TPinballComponent2(table, -1, false)
{
visualStruct visual{};
char ballGroupName[10]{"ball"};
@ -106,9 +106,9 @@ bool TBall::already_hit(TEdgeSegment* edge)
return false;
}
int TBall::Message(int code, float value)
int TBall::Message2(MessageCode code, float value)
{
if (code == 1024)
if (code == MessageCode::Reset)
{
render::ball_set(RenderSprite, nullptr, 0.0, 0, 0);
Position.X = 0.0;

View file

@ -5,14 +5,14 @@
class TCollisionComponent;
class TEdgeSegment;
class TBall : public TPinballComponent
class TBall : public TPinballComponent2
{
public :
TBall(TPinballTable* table);
void Repaint();
void not_again(TEdgeSegment* edge);
bool already_hit(TEdgeSegment* edge);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
vector2 get_coordinates() override;
void Disable();

View file

@ -7,15 +7,15 @@
#include "render.h"
#include "timer.h"
TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
visualStruct visual{};
loader::query_visual(groupIndex, 0, &visual);
SoundIndex4 = visual.SoundIndex4;
SoundIndex3 = visual.SoundIndex3;
TurnOnMsgValue = 55;
TurnOffMsgValue = 5;
InitialDuration = 55;
ExtendedDuration = 5;
Threshold = 1000000000.0f;
Timer = 0;
MessageField = 0;
@ -23,14 +23,14 @@ TBlocker::TBlocker(TPinballTable* table, int groupIndex) : TCollisionComponent(t
render::sprite_set_bitmap(RenderSprite, nullptr);
}
int TBlocker::Message(int code, float value)
int TBlocker::Message2(MessageCode code, float value)
{
switch (code)
{
case ~MessageCode::SetTiltLock:
case ~MessageCode::PlayerChanged:
case ~MessageCode::Reset:
case 51:
case MessageCode::SetTiltLock:
case MessageCode::PlayerChanged:
case MessageCode::Reset:
case MessageCode::TBlockerDisable:
if (Timer)
{
timer::kill(Timer);
@ -39,28 +39,26 @@ int TBlocker::Message(int code, float value)
MessageField = 0;
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
if (code == 51)
if (code == MessageCode::TBlockerDisable)
loader::play_sound(SoundIndex3, this, "TBlocker1");
return 0;
case 52:
break;
case MessageCode::TBlockerEnable:
ActiveFlag = 1;
loader::play_sound(SoundIndex4, this, "TBlocker2");
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
if (Timer)
timer::kill(Timer);
Timer = timer::set(std::max(value, 0.0f), this, TimerExpired);
break;
case 59:
case MessageCode::TBlockerRestartTimeout:
if (Timer)
timer::kill(Timer);
Timer = timer::set(std::max(value, 0.0f), this, TimerExpired);
break;
default:
return 0;
break;
}
if (Timer)
timer::kill(Timer);
float timerTime;
if (value <= 0.0f)
timerTime = 0.0;
else
timerTime = value;
Timer = timer::set(timerTime, this, TimerExpired);
return 0;
}

View file

@ -2,16 +2,16 @@
#include "TCollisionComponent.h"
class TBlocker :
public TCollisionComponent
public TCollisionComponent2
{
public:
TBlocker(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
static void TimerExpired(int timerId, void* caller);
int TurnOnMsgValue;
int TurnOffMsgValue;
int InitialDuration;
int ExtendedDuration;
int Timer;
int SoundIndex4;
int SoundIndex3;

View file

@ -8,7 +8,7 @@
#include "timer.h"
#include "TPinballTable.h"
TBumper::TBumper(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TBumper::TBumper(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
visualStruct visual{};
@ -21,11 +21,11 @@ TBumper::TBumper(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
OriginalThreshold = Threshold;
}
int TBumper::Message(int code, float value)
int TBumper::Message2(MessageCode code, float value)
{
switch (code)
{
case 11:
case MessageCode::TBumperSetBmpIndex:
{
auto nextBmp = static_cast<int>(floor(value));
auto maxBmp = static_cast<int>(ListBitmap->size()) - 1;
@ -45,24 +45,24 @@ int TBumper::Message(int code, float value)
}
break;
}
case 12:
case MessageCode::TBumperIncBmpIndex:
{
auto nextBmp = BmpIndex + 1;
auto maxBmp = static_cast<int>(ListBitmap->size()) - 1;
if (2 * nextBmp > maxBmp)
nextBmp = maxBmp / 2;
TBumper::Message(11, static_cast<float>(nextBmp));
TBumper::Message2(MessageCode::TBumperSetBmpIndex, static_cast<float>(nextBmp));
break;
}
case 13:
case MessageCode::TBumperDecBmpIndex:
{
auto nextBmp = BmpIndex - 1;
if (nextBmp < 0)
nextBmp = 0;
TBumper::Message(11, static_cast<float>(nextBmp));
TBumper::Message2(MessageCode::TBumperSetBmpIndex, static_cast<float>(nextBmp));
break;
}
case ~MessageCode::PlayerChanged:
case MessageCode::PlayerChanged:
{
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
playerPtr->BmpIndex = BmpIndex;
@ -71,10 +71,10 @@ int TBumper::Message(int code, float value)
playerPtr = &PlayerData[static_cast<int>(floor(value))];
BmpIndex = playerPtr->BmpIndex;
MessageField = playerPtr->MessageField;
TBumper::Message(11, static_cast<float>(BmpIndex));
TBumper::Message2(MessageCode::TBumperSetBmpIndex, static_cast<float>(BmpIndex));
break;
}
case ~MessageCode::Reset:
case MessageCode::Reset:
{
if (Timer)
{
@ -83,12 +83,10 @@ int TBumper::Message(int code, float value)
}
BmpIndex = 0;
MessageField = 0;
auto playerPtr = PlayerData;
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
for (auto& playerPtr : PlayerData)
{
playerPtr->BmpIndex = 0;
playerPtr->MessageField = 0;
++playerPtr;
playerPtr.BmpIndex = 0;
playerPtr.MessageField = 0;
}
TimerExpired(0, this);
break;

View file

@ -8,12 +8,12 @@ struct TBumper_player_backup
};
class TBumper :
public TCollisionComponent
public TCollisionComponent2
{
public:
TBumper(TPinballTable* table, int groupIndex);
~TBumper() override = default;
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void Fire();

View file

@ -7,7 +7,7 @@
#include "timer.h"
#include "TPinballTable.h"
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, false)
TComponentGroup::TComponentGroup(TPinballTable* table, int groupIndex) : TPinballComponent2(table, groupIndex, false)
{
Timer = 0;
if (groupIndex > 0)
@ -33,9 +33,9 @@ TComponentGroup::~TComponentGroup()
}
}
int TComponentGroup::Message(int code, float value)
int TComponentGroup::Message2(MessageCode code, float value)
{
if (code == 48)
if (code == MessageCode::TComponentGroupResetNotifyTimer)
{
if (this->Timer)
{
@ -45,11 +45,12 @@ int TComponentGroup::Message(int code, float value)
if (value > 0.0f)
this->Timer = timer::set(value, this, NotifyTimerExpired);
}
else if (code <= 1007 || (code > 1011 && code != 1020 && code != 1022))
else if (code < MessageCode::Pause || (code > MessageCode::SetTiltLock &&
code != MessageCode::PlayerChanged && code != MessageCode::GameOver))
{
for (auto component : List)
{
component->Message(code, value);
component->Message2(code, value);
}
}
return 0;

View file

@ -3,12 +3,12 @@
class TComponentGroup :
public TPinballComponent
public TPinballComponent2
{
public:
TComponentGroup(TPinballTable* table, int groupIndex);
~TComponentGroup() override;
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
static void NotifyTimerExpired(int timerId, void* caller);
std::vector<TPinballComponent*> List;

View file

@ -10,7 +10,7 @@
#include "TBall.h"
TDemo::TDemo(TPinballTable* table, int groupIndex)
: TCollisionComponent(table, groupIndex, false)
: TCollisionComponent2(table, groupIndex, false)
{
visualStruct visual{};
@ -56,23 +56,23 @@ TDemo::TDemo(TPinballTable* table, int groupIndex)
Edge3 = TEdgeSegment::install_wall(v9, this, &ActiveFlag, visual.CollisionGroup, table->CollisionCompOffset, 1404);
}
int TDemo::Message(int code, float value)
int TDemo::Message2(MessageCode code, float value)
{
switch (code)
{
case ~MessageCode::NewGame:
case MessageCode::NewGame:
if (RestartGameTimer)
timer::kill(RestartGameTimer);
RestartGameTimer = 0;
break;
case ~MessageCode::GameOver:
case MessageCode::GameOver:
if (RestartGameTimer)
timer::kill(RestartGameTimer);
RestartGameTimer = 0;
if (ActiveFlag != 0)
RestartGameTimer = timer::set(5.0, this, NewGameRestartTimer);
break;
case ~MessageCode::Reset:
case MessageCode::Reset:
if (FlipLeftTimer)
timer::kill(FlipLeftTimer);
FlipLeftTimer = 0;

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TDemo :
public TCollisionComponent
public TCollisionComponent2
{
public:
TDemo(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -8,15 +8,15 @@
#include "timer.h"
#include "TPinballTable.h"
TDrain::TDrain(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TDrain::TDrain(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
Timer = 0;
TimerTime = *loader::query_float_attribute(groupIndex, 0, 407);
}
int TDrain::Message(int code, float value)
int TDrain::Message2(MessageCode code, float value)
{
if (code == 1024)
if (code == MessageCode::Reset)
{
if (Timer)
{

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TDrain :
public TCollisionComponent
public TCollisionComponent2
{
public:
TDrain(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -10,7 +10,7 @@
#include "TLine.h"
#include "TPinballTable.h"
TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, false)
{
visualStruct visual{};
vector2 end{}, start{};
@ -50,9 +50,9 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
MinSpeed = *minSpeed;
}
int TFlagSpinner::Message(int code, float value)
int TFlagSpinner::Message2(MessageCode code, float value)
{
if (code == 1024)
if (code == MessageCode::Reset)
{
if (Timer)
{

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TFlagSpinner :
public TCollisionComponent
public TCollisionComponent2
{
public:
TFlagSpinner(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void NextFrame();

View file

@ -6,7 +6,7 @@
#include "loader.h"
#include "render.h"
TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
visualStruct visual{};
@ -18,24 +18,25 @@ TGate::TGate(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
control::handler(1024, this);
}
int TGate::Message(int code, float value)
int TGate::Message2(MessageCode code, float value)
{
if (code != 1020)
switch (code)
{
if (code == 53)
{
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
loader::play_sound(SoundIndex3, this, "TGate1");
}
else if (code == 54 || code == 1024)
{
ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
if (code == 54)
loader::play_sound(SoundIndex4, this, "TGate2");
}
control::handler(code, this);
case MessageCode::TGateDisable:
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
loader::play_sound(SoundIndex3, this, "TGate1");
break;
case MessageCode::Reset:
case MessageCode::TGateEnable:
ActiveFlag = 1;
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
if (code == MessageCode::TGateEnable)
loader::play_sound(SoundIndex4, this, "TGate2");
break;
default: break;
}
control::handler(~code, this);
return 0;
}

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TGate :
public TCollisionComponent
public TCollisionComponent2
{
public:
TGate(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
int SoundIndex4;
int SoundIndex3;

View file

@ -10,7 +10,7 @@
#include "TPinballTable.h"
#include "TTableLayer.h"
THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, false)
{
visualStruct visual{};
circle_type circle{};
@ -57,9 +57,9 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
}
int THole::Message(int code, float value)
int THole::Message2(MessageCode code, float value)
{
if (code == 1024 && BallCapturedFlag)
if (code == MessageCode::Reset && BallCapturedFlag)
{
if (Timer)
timer::kill(Timer);

View file

@ -4,11 +4,11 @@
#include "TEdgeManager.h"
class THole :
public TCollisionComponent
public TCollisionComponent2
{
public:
THole(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
int FieldEffect(TBall* ball, vector2* vecDst) override;

View file

@ -9,7 +9,7 @@
#include "timer.h"
#include "TPinballTable.h"
TKickback::TKickback(TPinballTable* table, int groupIndex): TCollisionComponent(table, groupIndex, true)
TKickback::TKickback(TPinballTable* table, int groupIndex): TCollisionComponent2(table, groupIndex, true)
{
MessageField = 0;
Timer = 0;
@ -19,9 +19,9 @@ TKickback::TKickback(TPinballTable* table, int groupIndex): TCollisionComponent(
Threshold = 1000000000.0f;
}
int TKickback::Message(int code, float value)
int TKickback::Message2(MessageCode code, float value)
{
if ((code == 1011 || code == 1024) && Timer)
if ((code == MessageCode::SetTiltLock || code == MessageCode::Reset) && Timer)
{
timer::kill(Timer);
if (ListBitmap)

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TKickback :
public TCollisionComponent
public TCollisionComponent2
{
public:
TKickback(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -11,7 +11,7 @@
#include "TPinballTable.h"
#include "TTableLayer.h"
TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollisionComponent(
TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollisionComponent2(
table, groupIndex, false)
{
visualStruct visual{};
@ -24,7 +24,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
TimerTime2 = 0.05f;
MessageField = 0;
Timer = 0;
KickFlag1 = 0;
BallCaputeredFlag = 0;
FieldMult = *loader::query_float_attribute(groupIndex, 0, 305);
loader::query_visual(groupIndex, 0, &visual);
SoftHitSoundId = visual.SoftHitSoundId;
@ -60,24 +60,24 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
TTableLayer::edges_insert_circle(&circle, nullptr, &Field);
}
int TKickout::Message(int code, float value)
int TKickout::Message2(MessageCode code, float value)
{
switch (code)
{
case 55:
if (KickFlag1)
case MessageCode::TKickoutRestartTimer:
if (BallCaputeredFlag)
{
if (value < 0.0f)
value = TimerTime1;
Timer = timer::set(value, this, TimerExpired);
}
break;
case ~MessageCode::SetTiltLock:
case MessageCode::SetTiltLock:
if (NotSomeFlag)
ActiveFlag = 0;
break;
case ~MessageCode::Reset:
if (KickFlag1)
case MessageCode::Reset:
if (BallCaputeredFlag)
{
if (Timer)
timer::kill(Timer);
@ -95,11 +95,11 @@ int TKickout::Message(int code, float value)
void TKickout::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance, TEdgeSegment* edge)
{
if (!KickFlag1)
if (!BallCaputeredFlag)
{
Ball = ball;
Threshold = 1000000000.0;
KickFlag1 = 1;
BallCaputeredFlag = 1;
ball->CollisionComp = this;
ball->Position.X = Circle.Center.X;
ball->Position.Y = Circle.Center.Y;
@ -107,7 +107,7 @@ void TKickout::Collision(TBall* ball, vector2* nextPosition, vector2* direction,
ball->Position.Z = CollisionBallSetZ;
if (PinballTable->TiltLockFlag)
{
Message(55, 0.1f);
Message2(MessageCode::TKickoutRestartTimer, 0.1f);
}
else
{
@ -121,7 +121,7 @@ int TKickout::FieldEffect(TBall* ball, vector2* dstVec)
{
vector2 direction{};
if (KickFlag1)
if (BallCaputeredFlag)
return 0;
direction.X = Circle.Center.X - ball->Position.X;
direction.Y = Circle.Center.Y - ball->Position.Y;
@ -136,9 +136,9 @@ int TKickout::FieldEffect(TBall* ball, vector2* dstVec)
void TKickout::TimerExpired(int timerId, void* caller)
{
auto kick = static_cast<TKickout*>(caller);
if (kick->KickFlag1)
if (kick->BallCaputeredFlag)
{
kick->KickFlag1 = 0;
kick->BallCaputeredFlag = 0;
kick->Timer = timer::set(kick->TimerTime2, kick, ResetTimerExpired);
if (kick->Ball)
{

View file

@ -4,11 +4,11 @@
#include "TEdgeManager.h"
class TKickout :
public TCollisionComponent
public TCollisionComponent2
{
public:
TKickout(TPinballTable* table, int groupIndex, bool someFlag);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
int FieldEffect(TBall* ball, vector2* vecDst) override;
@ -16,7 +16,7 @@ public:
static void TimerExpired(int timerId, void* caller);
static void ResetTimerExpired(int timerId, void* caller);
int KickFlag1;
int BallCaputeredFlag;
int NotSomeFlag;
int Timer;
float TimerTime1;

View file

@ -19,9 +19,9 @@ TLightRollover::TLightRollover(TPinballTable* table, int groupIndex) : TRollover
FloatArr = *loader::query_float_attribute(groupIndex, 0, 407);
}
int TLightRollover::Message(int code, float value)
int TLightRollover::Message2(MessageCode code, float value)
{
if (code == 1024)
if (code == MessageCode::Reset)
{
ActiveFlag = 1;
RolloverFlag = 0;

View file

@ -7,7 +7,7 @@ class TLightRollover :
public:
TLightRollover(TPinballTable* table, int groupIndex);
~TLightRollover() override = default;
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -108,7 +108,7 @@ TPinballComponent::~TPinballComponent()
int TPinballComponent::Message(int code, float value)
{
MessageField = code;
if (code == 1024)
if (code == ~MessageCode::Reset)
MessageField = 0;
return 0;
}

View file

@ -13,7 +13,7 @@ enum class MessageCode
// Private codes <1000, different meaning for each component
TFlipperExtend = 1,
TFlipperRetract = 2,
TLightTurnOff = 0,
TLightTurnOn = 1,
TLightGetLightOnFlag = 2,
@ -65,6 +65,32 @@ enum class MessageCode
TLightGroupToggleSplitIndex = 45,
TLightGroupStartFlasher = 46,
TBlockerDisable = 51,
TBlockerEnable = 52,
TBlockerRestartTimeout = 59,
TBumperSetBmpIndex = 11,
TBumperIncBmpIndex = 12,
TBumperDecBmpIndex = 13,
TComponentGroupResetNotifyTimer = 48,
TGateDisable = 53,
TGateEnable = 54,
TKickoutRestartTimer = 55,
TPopupTargetDisable = 49,
TPopupTargetEnable = 50,
TSinkUnknown7 = 7,
TSinkResetTimer = 56,
TSoloTargetDisable = 49,
TSoloTargetEnable = 50,
TTimerResetTimer = 59,
// Public codes 1000+, apply to all components
LeftFlipperInputPressed = 1000,
LeftFlipperInputReleased = 1001,
@ -76,7 +102,7 @@ enum class MessageCode
Resume = 1009,
LooseFocus = 1010,
SetTiltLock = 1011,
ResetTiltLock = 1012,
ClearTiltLock = 1012,
StartGamePlayer1 = 1013,
NewGame = 1014,
PlungerFeedBall = 1015,

View file

@ -356,7 +356,7 @@ int TPinballTable::Message2(MessageCode code, float value)
component->Message2(code, value);
}
break;
case MessageCode::ResetTiltLock:
case MessageCode::ClearTiltLock:
LightGroup->Message(14, 0.0);
if (TiltLockFlag)
{

View file

@ -8,40 +8,40 @@
#include "timer.h"
#include "TPinballTable.h"
TPopupTarget::TPopupTarget(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TPopupTarget::TPopupTarget(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
this->Timer = 0;
this->TimerTime = *loader::query_float_attribute(groupIndex, 0, 407);
Timer = 0;
TimerTime = *loader::query_float_attribute(groupIndex, 0, 407);
}
int TPopupTarget::Message(int code, float value)
int TPopupTarget::Message2(MessageCode code, float value)
{
switch (code)
{
case 49:
this->ActiveFlag = 0;
render::sprite_set_bitmap(this->RenderSprite, nullptr);
case MessageCode::TPopupTargetDisable:
ActiveFlag = 0;
render::sprite_set_bitmap(RenderSprite, nullptr);
break;
case 50:
this->Timer = timer::set(this->TimerTime, this, TimerExpired);
case MessageCode::TPopupTargetEnable:
Timer = timer::set(TimerTime, this, TimerExpired);
break;
case ~MessageCode::PlayerChanged:
this->PlayerMessagefieldBackup[this->PinballTable->CurrentPlayer] = this->MessageField;
this->MessageField = this->PlayerMessagefieldBackup[static_cast<int>(floor(value))];
TPopupTarget::Message(50 - (MessageField != 0), 0.0);
case MessageCode::PlayerChanged:
PlayerMessagefieldBackup[PinballTable->CurrentPlayer] = MessageField;
MessageField = PlayerMessagefieldBackup[static_cast<int>(floor(value))];
TPopupTarget::Message2(MessageField ? MessageCode::TPopupTargetDisable : MessageCode::TPopupTargetEnable, 0.0);
break;
case ~MessageCode::Reset:
{
this->MessageField = 0;
int* playerPtr = this->PlayerMessagefieldBackup;
for (auto index = 0; index < this->PinballTable->PlayerCount; ++index)
case MessageCode::Reset:
{
MessageField = 0;
int* playerPtr = PlayerMessagefieldBackup;
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
{
*playerPtr = 0;
++playerPtr;
}
if (this->Timer)
timer::kill(this->Timer);
if (Timer)
timer::kill(Timer);
TimerExpired(0, this);
break;
}
@ -54,22 +54,22 @@ int TPopupTarget::Message(int code, float value)
void TPopupTarget::Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge)
{
if (this->PinballTable->TiltLockFlag)
if (PinballTable->TiltLockFlag)
{
maths::basic_collision(ball, nextPosition, direction, this->Elasticity, this->Smoothness, 1000000000.0, 0.0);
maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, 1000000000.0, 0.0);
}
else if (maths::basic_collision(
ball,
nextPosition,
direction,
this->Elasticity,
this->Smoothness,
this->Threshold,
this->Boost) > this->Threshold)
Elasticity,
Smoothness,
Threshold,
Boost) > Threshold)
{
if (this->HardHitSoundId)
loader::play_sound(this->HardHitSoundId, this, "TPopupTarget1");
this->Message(49, 0.0);
if (HardHitSoundId)
loader::play_sound(HardHitSoundId, this, "TPopupTarget1");
Message2(MessageCode::TPopupTargetDisable, 0.0);
control::handler(63, this);
}
}

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TPopupTarget :
public TCollisionComponent
public TCollisionComponent2
{
public:
TPopupTarget(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -11,13 +11,13 @@
#include "timer.h"
#include "TPinballTable.h"
TRollover::TRollover(TPinballTable* table, int groupIndex, bool createWall) : TCollisionComponent(
TRollover::TRollover(TPinballTable* table, int groupIndex, bool createWall) : TCollisionComponent2(
table, groupIndex, createWall)
{
}
TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, false)
TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, false)
{
if (ListBitmap)
render::sprite_set_bitmap(RenderSprite, ListBitmap->at(0));
@ -25,9 +25,9 @@ TRollover::TRollover(TPinballTable* table, int groupIndex) : TCollisionComponent
}
int TRollover::Message(int code, float value)
int TRollover::Message2(MessageCode code, float value)
{
if (code == 1024)
if (code == MessageCode::Reset)
{
this->ActiveFlag = 1;
this->RolloverFlag = 0;

View file

@ -2,14 +2,14 @@
#include "TCollisionComponent.h"
class TRollover :
public TCollisionComponent
public TCollisionComponent2
{
protected:
TRollover(TPinballTable* table, int groupIndex, bool createWall);
public:
TRollover(TPinballTable* table, int groupIndex);
~TRollover() override = default;
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;
void build_walls(int groupIndex);

View file

@ -9,7 +9,7 @@
#include "TBall.h"
#include "timer.h"
TSink::TSink(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TSink::TSink(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
visualStruct visual{};
@ -27,21 +27,21 @@ TSink::TSink(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
TimerTime = *loader::query_float_attribute(groupIndex, 0, 407);
}
int TSink::Message(int code, float value)
int TSink::Message2(MessageCode code, float value)
{
switch (code)
{
case 56:
case MessageCode::TSinkResetTimer:
if (value < 0.0f)
value = TimerTime;
timer::set(value, this, TimerExpired);
break;
case ~MessageCode::PlayerChanged:
case MessageCode::PlayerChanged:
timer::kill(TimerExpired);
PlayerMessagefieldBackup[PinballTable->CurrentPlayer] = MessageField;
MessageField = PlayerMessagefieldBackup[static_cast<int>(floor(value))];
break;
case ~MessageCode::Reset:
case MessageCode::Reset:
{
timer::kill(TimerExpired);
MessageField = 0;

View file

@ -3,11 +3,11 @@
#include "TCollisionComponent.h"
class TSink :
public TCollisionComponent
public TCollisionComponent2
{
public:
TSink(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -8,7 +8,7 @@
#include "timer.h"
#include "TPinballTable.h"
TSoloTarget::TSoloTarget(TPinballTable* table, int groupIndex) : TCollisionComponent(table, groupIndex, true)
TSoloTarget::TSoloTarget(TPinballTable* table, int groupIndex) : TCollisionComponent2(table, groupIndex, true)
{
visualStruct visual{};
@ -16,18 +16,18 @@ TSoloTarget::TSoloTarget(TPinballTable* table, int groupIndex) : TCollisionCompo
TimerTime = 0.1f;
loader::query_visual(groupIndex, 0, &visual);
SoundIndex4 = visual.SoundIndex4;
TSoloTarget::Message(50, 0.0);
TSoloTarget::Message2(MessageCode::TSoloTargetEnable, 0.0);
}
int TSoloTarget::Message(int code, float value)
int TSoloTarget::Message2(MessageCode code, float value)
{
switch (code)
{
case 49:
case 50:
ActiveFlag = code == 50;
case MessageCode::TSoloTargetDisable:
case MessageCode::TSoloTargetEnable:
ActiveFlag = code == MessageCode::TSoloTargetEnable;
break;
case ~MessageCode::Reset:
case MessageCode::Reset:
if (Timer)
timer::kill(Timer);
Timer = 0;
@ -58,7 +58,7 @@ void TSoloTarget::Collision(TBall* ball, vector2* nextPosition, vector2* directi
{
if (DefaultCollision(ball, nextPosition, direction))
{
Message(49, 0.0);
Message2(MessageCode::TSoloTargetDisable, 0.0);
Timer = timer::set(TimerTime, this, TimerExpired);
control::handler(63, this);
}
@ -67,6 +67,6 @@ void TSoloTarget::Collision(TBall* ball, vector2* nextPosition, vector2* directi
void TSoloTarget::TimerExpired(int timerId, void* caller)
{
auto target = static_cast<TSoloTarget*>(caller);
target->Message(50, 0.0);
target->Message2(MessageCode::TSoloTargetEnable, 0.0);
target->Timer = 0;
}

View file

@ -2,11 +2,11 @@
#include "TCollisionComponent.h"
class TSoloTarget :
public TCollisionComponent
public TCollisionComponent2
{
public:
TSoloTarget(TPinballTable* table, int groupIndex);
int Message(int code, float value) override;
int Message2(MessageCode code, float value) override;
void Collision(TBall* ball, vector2* nextPosition, vector2* direction, float distance,
TEdgeSegment* edge) override;

View file

@ -10,7 +10,7 @@
#include "timer.h"
TTextBox::TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
TTextBox::TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent2(table, groupIndex, true)
{
OffsetX = 0;
OffsetY = 0;
@ -18,8 +18,8 @@ TTextBox::TTextBox(TPinballTable* table, int groupIndex) : TPinballComponent(tab
Height = 0;
BgBmp = render::background_bitmap;
Font = score::msg_fontp;
Message1 = nullptr;
Message2 = nullptr;
CurrentMessage = nullptr;
PreviousMessage = nullptr;
Timer = 0;
if (groupIndex > 0)
@ -42,16 +42,16 @@ TTextBox::~TTextBox()
timer::kill(Timer);
Timer = 0;
}
while (Message1)
while (CurrentMessage)
{
TTextBoxMessage* message = Message1;
TTextBoxMessage* message = CurrentMessage;
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
Message1 = nextMessage;
CurrentMessage = nextMessage;
}
}
int TTextBox::Message(int code, float value)
int TTextBox::Message2(MessageCode code, float value)
{
return 0;
}
@ -59,13 +59,13 @@ int TTextBox::Message(int code, float value)
void TTextBox::TimerExpired(int timerId, void* caller)
{
auto tb = static_cast<TTextBox*>(caller);
TTextBoxMessage* message = tb->Message1;
TTextBoxMessage* message = tb->CurrentMessage;
tb->Timer = 0;
if (message)
{
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
tb->Message1 = nextMessage;
tb->CurrentMessage = nextMessage;
tb->Draw();
control::handler(60, tb);
}
@ -92,12 +92,12 @@ void TTextBox::Clear()
timer::kill(Timer);
Timer = 0;
}
while (Message1)
while (CurrentMessage)
{
TTextBoxMessage* message = Message1;
TTextBoxMessage* message = CurrentMessage;
TTextBoxMessage* nextMessage = message->NextMessage;
delete message;
Message1 = nextMessage;
CurrentMessage = nextMessage;
}
}
@ -106,10 +106,10 @@ void TTextBox::Display(const char* text, float time)
if (!text)
return;
if (Message1 && !strcmp(text, Message2->Text))
if (CurrentMessage && !strcmp(text, PreviousMessage->Text))
{
Message2->Refresh(time);
if (Message2 == Message1)
PreviousMessage->Refresh(time);
if (PreviousMessage == CurrentMessage)
{
if (Timer && Timer != -1)
timer::kill(Timer);
@ -129,11 +129,11 @@ void TTextBox::Display(const char* text, float time)
{
if (message->Text)
{
if (Message1)
Message2->NextMessage = message;