mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2023-12-30 21:52:56 +00:00
TLight: cleanup, code from FT, new test commands.
This commit is contained in:
parent
acd1ad34b2
commit
14a8d64b67
@ -10,17 +10,17 @@
|
||||
|
||||
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
|
||||
{
|
||||
Timer1 = 0;
|
||||
FlasherActive = 0;
|
||||
Timer2 = 0;
|
||||
Flasher.Timer = 0;
|
||||
TimeoutTimer = 0;
|
||||
FlasherOnFlag = false;
|
||||
UndoOverrideTimer = 0;
|
||||
FlashTimer = 0;
|
||||
Reset();
|
||||
float* floatArr1 = loader::query_float_attribute(groupIndex, 0, 900);
|
||||
Flasher.TimerDelay[0] = *floatArr1;
|
||||
FlasherDelay[0] = *floatArr1;
|
||||
FlashDelay[0] = *floatArr1;
|
||||
SourceDelay[0] = *floatArr1;
|
||||
float* floatArr2 = loader::query_float_attribute(groupIndex, 0, 901);
|
||||
Flasher.TimerDelay[1] = *floatArr2;
|
||||
FlasherDelay[1] = *floatArr2;
|
||||
FlashDelay[1] = *floatArr2;
|
||||
SourceDelay[1] = *floatArr2;
|
||||
}
|
||||
|
||||
int TLight::Message(int code, float value)
|
||||
@ -34,183 +34,177 @@ int TLight::Message(int code, float value)
|
||||
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
|
||||
{
|
||||
auto playerPtr = &PlayerData[index];
|
||||
playerPtr->FlasherActive = FlasherActive;
|
||||
playerPtr->BmpIndex2 = BmpIndex2;
|
||||
playerPtr->BmpIndex1 = BmpIndex1;
|
||||
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||
playerPtr->LightOnBmpIndex = LightOnBmpIndex;
|
||||
playerPtr->LightOnFlag = LightOnFlag;
|
||||
playerPtr->MessageField = MessageField;
|
||||
}
|
||||
break;
|
||||
case 1020:
|
||||
{
|
||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||
playerPtr->FlasherActive = FlasherActive;
|
||||
playerPtr->BmpIndex2 = BmpIndex2;
|
||||
playerPtr->BmpIndex1 = BmpIndex1;
|
||||
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||
playerPtr->LightOnBmpIndex = LightOnBmpIndex;
|
||||
playerPtr->LightOnFlag = LightOnFlag;
|
||||
playerPtr->MessageField = MessageField;
|
||||
|
||||
Reset();
|
||||
|
||||
playerPtr = &PlayerData[static_cast<int>(floor(value))];
|
||||
FlasherActive = playerPtr->FlasherActive;
|
||||
BmpIndex2 = playerPtr->BmpIndex2;
|
||||
BmpIndex1 = playerPtr->BmpIndex1;
|
||||
FlasherOnFlag = playerPtr->FlasherOnFlag;
|
||||
LightOnBmpIndex = playerPtr->LightOnBmpIndex;
|
||||
LightOnFlag = playerPtr->LightOnFlag;
|
||||
MessageField = playerPtr->MessageField;
|
||||
if (BmpIndex2)
|
||||
if (LightOnBmpIndex)
|
||||
{
|
||||
Message(11, static_cast<float>(BmpIndex2));
|
||||
Message(11, static_cast<float>(LightOnBmpIndex));
|
||||
}
|
||||
if (BmpIndex1)
|
||||
if (LightOnFlag)
|
||||
Message(1, 0.0);
|
||||
if (FlasherActive)
|
||||
if (FlasherOnFlag)
|
||||
Message(4, 0.0);
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
BmpIndex1 = 0;
|
||||
if (FlasherActive == 0 && !FlasherFlag1 && !FlasherFlag2)
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[0]);
|
||||
LightOnFlag = false;
|
||||
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||
SetSpriteBmp(BmpArr[0]);
|
||||
break;
|
||||
case 1:
|
||||
BmpIndex1 = 1;
|
||||
if (FlasherActive == 0 && !FlasherFlag1 && !FlasherFlag2)
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[1]);
|
||||
LightOnFlag = true;
|
||||
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||
SetSpriteBmp(BmpArr[1]);
|
||||
break;
|
||||
case 2:
|
||||
return BmpIndex1;
|
||||
return LightOnFlag;
|
||||
case 3:
|
||||
return FlasherActive;
|
||||
return FlasherOnFlag;
|
||||
case 4:
|
||||
schedule_timeout(0.0);
|
||||
if (!FlasherActive || !Flasher.Timer)
|
||||
if (!FlasherOnFlag || !FlashTimer)
|
||||
{
|
||||
FlasherActive = 1;
|
||||
FlasherFlag2 = 0;
|
||||
FlasherFlag1 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
flasher_start(&Flasher, BmpIndex1);
|
||||
FlasherOnFlag = true;
|
||||
ToggledOnFlag = false;
|
||||
ToggledOffFlag = false;
|
||||
TurnOffAfterFlashingFg = false;
|
||||
flasher_start(LightOnFlag);
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
Flasher.TimerDelay[0] = value * FlasherDelay[0];
|
||||
Flasher.TimerDelay[1] = value * FlasherDelay[1];
|
||||
FlashDelay[0] = value * SourceDelay[0];
|
||||
FlashDelay[1] = value * SourceDelay[1];
|
||||
break;
|
||||
case 6:
|
||||
Flasher.TimerDelay[0] = FlasherDelay[0];
|
||||
Flasher.TimerDelay[1] = FlasherDelay[1];
|
||||
FlashDelay[0] = SourceDelay[0];
|
||||
FlashDelay[1] = SourceDelay[1];
|
||||
break;
|
||||
case 7:
|
||||
if (!FlasherActive)
|
||||
flasher_start(&Flasher, BmpIndex1);
|
||||
FlasherActive = 1;
|
||||
FlasherFlag2 = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
FlasherFlag1 = 0;
|
||||
if (!FlasherOnFlag)
|
||||
flasher_start(LightOnFlag);
|
||||
FlasherOnFlag = true;
|
||||
ToggledOnFlag = false;
|
||||
TurnOffAfterFlashingFg = false;
|
||||
ToggledOffFlag = false;
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 8:
|
||||
if (!FlasherFlag1)
|
||||
if (!ToggledOffFlag)
|
||||
{
|
||||
if (FlasherActive)
|
||||
if (FlasherOnFlag)
|
||||
{
|
||||
flasher_stop(&Flasher, 0);
|
||||
FlasherActive = 0;
|
||||
flasher_stop(0);
|
||||
FlasherOnFlag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[0]);
|
||||
SetSpriteBmp(BmpArr[0]);
|
||||
}
|
||||
FlasherFlag1 = 1;
|
||||
FlasherFlag2 = 0;
|
||||
ToggledOffFlag = true;
|
||||
ToggledOnFlag = false;
|
||||
}
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 9:
|
||||
if (!FlasherFlag2)
|
||||
if (!ToggledOnFlag)
|
||||
{
|
||||
if (FlasherActive)
|
||||
if (FlasherOnFlag)
|
||||
{
|
||||
flasher_stop(&Flasher, 1);
|
||||
FlasherActive = 0;
|
||||
flasher_stop(1);
|
||||
FlasherOnFlag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[1]);
|
||||
SetSpriteBmp(BmpArr[1]);
|
||||
}
|
||||
FlasherFlag2 = 1;
|
||||
FlasherFlag1 = 0;
|
||||
ToggledOnFlag = true;
|
||||
ToggledOffFlag = false;
|
||||
}
|
||||
schedule_timeout(value);
|
||||
break;
|
||||
case 11:
|
||||
bmpIndex = 0;
|
||||
BmpIndex2 = static_cast<int>(floor(value));
|
||||
if (BmpIndex2 > static_cast<int>(ListBitmap->size()))
|
||||
BmpIndex2 = ListBitmap->size();
|
||||
if (BmpIndex2 < 0)
|
||||
BmpIndex2 = 0;
|
||||
Flasher.BmpArr[0] = nullptr;
|
||||
Flasher.BmpArr[1] = ListBitmap->at(BmpIndex2);
|
||||
if (FlasherActive == 0)
|
||||
LightOnBmpIndex = Clamp(static_cast<int>(floor(value)), 0, static_cast<int>(ListBitmap->size()) - 1);
|
||||
BmpArr[0] = nullptr;
|
||||
BmpArr[1] = ListBitmap->at(LightOnBmpIndex);
|
||||
if (!FlasherOnFlag)
|
||||
{
|
||||
if (!FlasherFlag1)
|
||||
{
|
||||
if (FlasherFlag2)
|
||||
bmpIndex = 1;
|
||||
else
|
||||
bmpIndex = BmpIndex1;
|
||||
}
|
||||
if (ToggledOffFlag)
|
||||
bmpIndex = 0;
|
||||
else if (ToggledOnFlag)
|
||||
bmpIndex = 1;
|
||||
else
|
||||
bmpIndex = LightOnFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
bmpIndex = Flasher.BmpIndex;
|
||||
bmpIndex = FlashLightOnFlag;
|
||||
}
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[bmpIndex]);
|
||||
SetSpriteBmp(BmpArr[bmpIndex]);
|
||||
break;
|
||||
case 12:
|
||||
bmpIndex = BmpIndex2 + 1;
|
||||
if (bmpIndex > static_cast<int>(ListBitmap->size()))
|
||||
bmpIndex = ListBitmap->size();
|
||||
bmpIndex = LightOnBmpIndex + 1;
|
||||
if (bmpIndex >= static_cast<int>(ListBitmap->size()))
|
||||
bmpIndex = static_cast<int>(ListBitmap->size()) - 1;
|
||||
Message(11, static_cast<float>(bmpIndex));
|
||||
break;
|
||||
case 13:
|
||||
bmpIndex = BmpIndex2 - 1;
|
||||
bmpIndex = LightOnBmpIndex - 1;
|
||||
if (bmpIndex < 0)
|
||||
bmpIndex = 0;
|
||||
Message(11, static_cast<float>(bmpIndex));
|
||||
break;
|
||||
case 14:
|
||||
if (Timer1)
|
||||
timer::kill(Timer1);
|
||||
Timer1 = 0;
|
||||
if (FlasherActive != 0)
|
||||
flasher_stop(&Flasher, -1);
|
||||
FlasherActive = 0;
|
||||
FlasherFlag1 = 0;
|
||||
FlasherFlag2 = 0;
|
||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[BmpIndex1]);
|
||||
if (TimeoutTimer)
|
||||
timer::kill(TimeoutTimer);
|
||||
TimeoutTimer = 0;
|
||||
if (FlasherOnFlag)
|
||||
flasher_stop(-1);
|
||||
FlasherOnFlag = false;
|
||||
ToggledOffFlag = false;
|
||||
ToggledOnFlag = false;
|
||||
SetSpriteBmp(BmpArr[LightOnFlag]);
|
||||
break;
|
||||
case 15:
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
if (Timer2)
|
||||
timer::kill(Timer2);
|
||||
Timer2 = 0;
|
||||
TurnOffAfterFlashingFg = false;
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
Message(1, 0.0);
|
||||
Message(7, value);
|
||||
break;
|
||||
case 16:
|
||||
if (Timer2)
|
||||
timer::kill(Timer2);
|
||||
Timer2 = 0;
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
Message(7, value);
|
||||
TurnOffAfterFlashingFg = 1;
|
||||
TurnOffAfterFlashingFg = true;
|
||||
break;
|
||||
case 17:
|
||||
Message(static_cast<int>(floor(value)) != 0, 0.0);
|
||||
return BmpIndex1;
|
||||
return LightOnFlag;
|
||||
case 18:
|
||||
Message(17, value);
|
||||
Message(14, 0.0);
|
||||
return BmpIndex1;
|
||||
return LightOnFlag;
|
||||
case 19:
|
||||
Message(1, 0.0);
|
||||
Message(14, 0.0);
|
||||
@ -220,14 +214,34 @@ int TLight::Message(int code, float value)
|
||||
Message(14, 0.0);
|
||||
break;
|
||||
case 21:
|
||||
Message(17, static_cast<float>(BmpIndex1 == 0));
|
||||
return BmpIndex1;
|
||||
Message(17, !LightOnFlag);
|
||||
return LightOnFlag;
|
||||
case 22:
|
||||
Message(18, static_cast<float>(BmpIndex1 == 0));
|
||||
return BmpIndex1;
|
||||
Message(18, !LightOnFlag);
|
||||
return LightOnFlag;
|
||||
case 23:
|
||||
MessageField = static_cast<int>(floor(value));
|
||||
break;
|
||||
case -24:
|
||||
case -25:
|
||||
// FT codes in negative to avoid overlap with 3DPB TLightGroup codes
|
||||
render::sprite_set_bitmap(RenderSprite, BmpArr[code == -24]);
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
if (value > 0)
|
||||
{
|
||||
TemporaryOverrideFlag = true;
|
||||
UndoOverrideTimer = timer::set(value, this, UndoTmpOverride);
|
||||
}
|
||||
break;
|
||||
case -26:
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
UndoOverrideTimer = 0;
|
||||
TemporaryOverrideFlag = false;
|
||||
render::sprite_set_bitmap(RenderSprite, PreviousBitmap);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -237,55 +251,53 @@ int TLight::Message(int code, float value)
|
||||
|
||||
void TLight::Reset()
|
||||
{
|
||||
if (Timer1)
|
||||
timer::kill(Timer1);
|
||||
if (Timer2)
|
||||
timer::kill(Timer2);
|
||||
if (FlasherActive)
|
||||
flasher_stop(&Flasher, -1);
|
||||
Unknown20F = 1.0;
|
||||
Timer1 = 0;
|
||||
Timer2 = 0;
|
||||
BmpIndex1 = 0;
|
||||
BmpIndex2 = 0;
|
||||
FlasherFlag1 = 0;
|
||||
FlasherFlag2 = 0;
|
||||
FlasherActive = 0;
|
||||
TurnOffAfterFlashingFg = 0;
|
||||
if (TimeoutTimer)
|
||||
timer::kill(TimeoutTimer);
|
||||
if (UndoOverrideTimer)
|
||||
timer::kill(UndoOverrideTimer);
|
||||
if (FlasherOnFlag)
|
||||
flasher_stop(-1);
|
||||
TimeoutTimer = 0;
|
||||
UndoOverrideTimer = 0;
|
||||
LightOnFlag = false;
|
||||
LightOnBmpIndex = 0;
|
||||
ToggledOffFlag = false;
|
||||
ToggledOnFlag = false;
|
||||
FlasherOnFlag = false;
|
||||
TemporaryOverrideFlag = false;
|
||||
TurnOffAfterFlashingFg = false;
|
||||
PreviousBitmap = nullptr;
|
||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||
Flasher.Sprite = RenderSprite;
|
||||
Flasher.BmpArr[0] = nullptr;
|
||||
BmpArr[0] = nullptr;
|
||||
if (ListBitmap)
|
||||
Flasher.BmpArr[1] = ListBitmap->at(0);
|
||||
Flasher.Unknown4 = 0;
|
||||
Flasher.Unknown3 = 0;
|
||||
BmpArr[1] = ListBitmap->at(0);
|
||||
MessageField = 0;
|
||||
}
|
||||
|
||||
void TLight::schedule_timeout(float time)
|
||||
{
|
||||
Flasher.TimerDelay[0] = FlasherDelay[0];
|
||||
Flasher.TimerDelay[1] = FlasherDelay[1];
|
||||
if (Timer1)
|
||||
timer::kill(Timer1);
|
||||
Timer1 = 0;
|
||||
FlashDelay[0] = SourceDelay[0];
|
||||
FlashDelay[1] = SourceDelay[1];
|
||||
if (TimeoutTimer)
|
||||
timer::kill(TimeoutTimer);
|
||||
TimeoutTimer = 0;
|
||||
if (time > 0.0f)
|
||||
Timer1 = timer::set(time, this, TimerExpired);
|
||||
TimeoutTimer = timer::set(time, this, TimerExpired);
|
||||
}
|
||||
|
||||
void TLight::TimerExpired(int timerId, void* caller)
|
||||
{
|
||||
auto light = static_cast<TLight*>(caller);
|
||||
if (light->FlasherActive)
|
||||
flasher_stop(&light->Flasher, -1);
|
||||
render::sprite_set_bitmap(light->RenderSprite, light->Flasher.BmpArr[light->BmpIndex1]);
|
||||
light->FlasherFlag1 = 0;
|
||||
light->FlasherFlag2 = 0;
|
||||
light->FlasherActive = 0;
|
||||
light->Timer1 = 0;
|
||||
if (light->TurnOffAfterFlashingFg != 0)
|
||||
if (light->FlasherOnFlag)
|
||||
light->flasher_stop(-1);
|
||||
light->SetSpriteBmp(light->BmpArr[light->LightOnFlag]);
|
||||
light->ToggledOffFlag = false;
|
||||
light->ToggledOnFlag = false;
|
||||
light->FlasherOnFlag = false;
|
||||
light->TimeoutTimer = 0;
|
||||
if (light->TurnOffAfterFlashingFg)
|
||||
{
|
||||
light->TurnOffAfterFlashingFg = 0;
|
||||
light->TurnOffAfterFlashingFg = false;
|
||||
light->Message(20, 0.0);
|
||||
}
|
||||
if (light->Control)
|
||||
@ -293,29 +305,41 @@ void TLight::TimerExpired(int timerId, void* caller)
|
||||
}
|
||||
|
||||
|
||||
void TLight::flasher_stop(flasher_type* flash, int bmpIndex)
|
||||
void TLight::flasher_stop(int bmpIndex)
|
||||
{
|
||||
if (flash->Timer)
|
||||
timer::kill(flash->Timer);
|
||||
flash->Timer = 0;
|
||||
if (FlashTimer)
|
||||
timer::kill(FlashTimer);
|
||||
FlashTimer = 0;
|
||||
if (bmpIndex >= 0)
|
||||
{
|
||||
flash->BmpIndex = bmpIndex;
|
||||
render::sprite_set_bitmap(flash->Sprite, flash->BmpArr[bmpIndex]);
|
||||
FlashLightOnFlag = bmpIndex;
|
||||
SetSpriteBmp(BmpArr[FlashLightOnFlag]);
|
||||
}
|
||||
}
|
||||
|
||||
void TLight::flasher_start(flasher_type* flash, int bmpIndex)
|
||||
void TLight::flasher_start(bool bmpIndex)
|
||||
{
|
||||
flash->BmpIndex = bmpIndex;
|
||||
flasher_callback(0, flash);
|
||||
FlashLightOnFlag = bmpIndex;
|
||||
flasher_callback(0, this);
|
||||
}
|
||||
|
||||
void TLight::SetSpriteBmp(gdrv_bitmap8* bmp)
|
||||
{
|
||||
PreviousBitmap = bmp;
|
||||
if (!TemporaryOverrideFlag)
|
||||
render::sprite_set_bitmap(RenderSprite, bmp);
|
||||
}
|
||||
|
||||
void TLight::flasher_callback(int timerId, void* caller)
|
||||
{
|
||||
auto flash = static_cast<flasher_type*>(caller);
|
||||
auto index = 1 - flash->BmpIndex;
|
||||
flash->BmpIndex = index;
|
||||
render::sprite_set_bitmap(flash->Sprite, flash->BmpArr[index]);
|
||||
flash->Timer = timer::set(flash->TimerDelay[flash->BmpIndex], flash, flasher_callback);
|
||||
auto light = static_cast<TLight*>(caller);
|
||||
light->FlashLightOnFlag ^= true;
|
||||
light->SetSpriteBmp(light->BmpArr[light->FlashLightOnFlag]);
|
||||
light->FlashTimer = timer::set(light->FlashDelay[light->FlashLightOnFlag], light, flasher_callback);
|
||||
}
|
||||
|
||||
void TLight::UndoTmpOverride(int timerId, void* caller)
|
||||
{
|
||||
auto light = static_cast<TLight*>(caller);
|
||||
light->Message(-26, 0.0f);
|
||||
}
|
||||
|
@ -3,26 +3,12 @@
|
||||
|
||||
struct gdrv_bitmap8;
|
||||
|
||||
struct flasher_type
|
||||
{
|
||||
render_sprite_type_struct* Sprite;
|
||||
gdrv_bitmap8* BmpArr[2];
|
||||
int Unknown3;
|
||||
int Unknown4;
|
||||
float TimerDelay[2];
|
||||
int Timer;
|
||||
int BmpIndex;
|
||||
};
|
||||
|
||||
|
||||
struct TLight_player_backup
|
||||
{
|
||||
int MessageField;
|
||||
int BmpIndex1;
|
||||
int FlasherActive;
|
||||
int Unknown3;
|
||||
int Unknown4;
|
||||
int BmpIndex2;
|
||||
bool LightOnFlag;
|
||||
int LightOnBmpIndex;
|
||||
bool FlasherOnFlag;
|
||||
};
|
||||
|
||||
|
||||
@ -34,22 +20,28 @@ public:
|
||||
int Message(int code, float value) override;
|
||||
void Reset();
|
||||
void schedule_timeout(float time);
|
||||
void flasher_stop(int bmpIndex);
|
||||
void flasher_start(bool bmpIndex);
|
||||
void SetSpriteBmp(gdrv_bitmap8* bmp);
|
||||
|
||||
static void TimerExpired(int timerId, void* caller);
|
||||
static void flasher_stop(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 UndoTmpOverride(int timerId, void* caller);
|
||||
|
||||
flasher_type Flasher{};
|
||||
int BmpIndex1{};
|
||||
int FlasherActive;
|
||||
int FlasherFlag1{};
|
||||
int FlasherFlag2{};
|
||||
int TurnOffAfterFlashingFg{};
|
||||
int BmpIndex2{};
|
||||
float FlasherDelay[2]{};
|
||||
int Timer1;
|
||||
int Timer2;
|
||||
float Unknown20F{};
|
||||
gdrv_bitmap8* BmpArr[2];
|
||||
float FlashDelay[2];
|
||||
int FlashTimer;
|
||||
bool FlashLightOnFlag;
|
||||
bool LightOnFlag{};
|
||||
bool FlasherOnFlag;
|
||||
bool ToggledOffFlag{};
|
||||
bool ToggledOnFlag{};
|
||||
bool TurnOffAfterFlashingFg{};
|
||||
int LightOnBmpIndex{};
|
||||
float SourceDelay[2]{};
|
||||
int TimeoutTimer;
|
||||
int UndoOverrideTimer;
|
||||
bool TemporaryOverrideFlag{};
|
||||
gdrv_bitmap8* PreviousBitmap{};
|
||||
TLight_player_backup PlayerData[4]{};
|
||||
};
|
||||
|
@ -66,7 +66,7 @@ int TLightGroup::Message(int code, float value)
|
||||
case 24:
|
||||
{
|
||||
auto lastLight = List.at(count - 1);
|
||||
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
|
||||
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||
break;
|
||||
if (MessageField2)
|
||||
{
|
||||
@ -75,16 +75,16 @@ int TLightGroup::Message(int code, float value)
|
||||
AnimationFlag = 1;
|
||||
MessageField2 = code;
|
||||
auto lightMessageField = lastLight->MessageField;
|
||||
auto bmpIndex1 = lastLight->BmpIndex1;
|
||||
auto lightStatusBefore = lastLight->LightOnFlag;
|
||||
for (auto index = count - 1; index > 0; --index)
|
||||
{
|
||||
auto lightCur = List.at(index);
|
||||
auto lightPrev = List.at(index - 1);
|
||||
lightCur->Message(lightPrev->BmpIndex1 != 0, 0.0);
|
||||
lightCur->Message(lightPrev->LightOnFlag, 0.0);
|
||||
lightCur->MessageField = lightPrev->MessageField;
|
||||
}
|
||||
auto firstLight = List.at(0);
|
||||
firstLight->Message(bmpIndex1 != 0, 0.0);
|
||||
firstLight->Message(lightStatusBefore, 0.0);
|
||||
firstLight->MessageField = lightMessageField;
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
@ -92,7 +92,7 @@ int TLightGroup::Message(int code, float value)
|
||||
case 25:
|
||||
{
|
||||
auto lastLight = List.at(count - 1);
|
||||
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
|
||||
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||
break;
|
||||
if (MessageField2)
|
||||
{
|
||||
@ -102,15 +102,15 @@ int TLightGroup::Message(int code, float value)
|
||||
AnimationFlag = 1;
|
||||
MessageField2 = code;
|
||||
auto lightMessageField = firstLight->MessageField;
|
||||
auto bmpIndex1 = firstLight->BmpIndex1;
|
||||
auto lightStatusBefore = firstLight->LightOnFlag;
|
||||
for (auto index = 0; index < count - 1; index++)
|
||||
{
|
||||
auto lightCur = List.at(index);
|
||||
auto lightNext = List.at(index + 1);
|
||||
lightCur->Message(lightNext->BmpIndex1 != 0, 0.0);
|
||||
lightCur->Message(lightNext->LightOnFlag, 0.0);
|
||||
lightCur->MessageField = lightNext->MessageField;
|
||||
}
|
||||
lastLight->Message(bmpIndex1 != 0, 0.0);
|
||||
lastLight->Message(lightStatusBefore, 0.0);
|
||||
lastLight->MessageField = lightMessageField;
|
||||
reschedule_animation(value);
|
||||
break;
|
||||
@ -122,12 +122,12 @@ int TLightGroup::Message(int code, float value)
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
auto lastLight = List.at(count - 1);
|
||||
auto flasherFlag2 = lastLight->FlasherFlag2;
|
||||
auto flasherFlag2 = lastLight->ToggledOnFlag;
|
||||
for (auto i = count - 1; i > 0; --i)
|
||||
{
|
||||
auto lightCur = List.at(i);
|
||||
auto lightPrev = List.at(i - 1);
|
||||
lightCur->Message((lightPrev->FlasherFlag2 != 0) + 8, 0.0);
|
||||
lightCur->Message(lightPrev->ToggledOnFlag + 8, 0.0);
|
||||
}
|
||||
auto firstLight = List.at(0);
|
||||
firstLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||
@ -141,12 +141,12 @@ int TLightGroup::Message(int code, float value)
|
||||
MessageField2 = code;
|
||||
AnimationFlag = 0;
|
||||
auto firstLight = List.at(0);
|
||||
auto flasherFlag2 = firstLight->FlasherFlag2;
|
||||
auto flasherFlag2 = firstLight->ToggledOnFlag;
|
||||
for (auto i = 0; i < count - 1; i++)
|
||||
{
|
||||
auto lightCur = List.at(i);
|
||||
auto lightNext = List.at(i + 1);
|
||||
lightCur->Message((lightNext->FlasherFlag2 != 0) + 8, 0.0);
|
||||
lightCur->Message(lightNext->ToggledOnFlag + 8, 0.0);
|
||||
}
|
||||
auto lastLight = List.at(count - 1);
|
||||
lastLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||
@ -189,7 +189,7 @@ int TLightGroup::Message(int code, float value)
|
||||
auto noBmpInd1Count = 0;
|
||||
for (auto light : List)
|
||||
{
|
||||
if (!light->BmpIndex1)
|
||||
if (!light->LightOnFlag)
|
||||
++noBmpInd1Count;
|
||||
}
|
||||
if (!noBmpInd1Count)
|
||||
@ -199,7 +199,7 @@ int TLightGroup::Message(int code, float value)
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
auto light = *it;
|
||||
if (!light->BmpIndex1 && randModCount-- == 0)
|
||||
if (!light->LightOnFlag && randModCount-- == 0)
|
||||
{
|
||||
light->Message(1, 0.0);
|
||||
break;
|
||||
@ -215,7 +215,7 @@ int TLightGroup::Message(int code, float value)
|
||||
auto bmpInd1Count = 0;
|
||||
for (auto light : List)
|
||||
{
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
++bmpInd1Count;
|
||||
}
|
||||
if (!bmpInd1Count)
|
||||
@ -225,7 +225,7 @@ int TLightGroup::Message(int code, float value)
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
auto light = *it;
|
||||
if (light->BmpIndex1 && randModCount-- == 0)
|
||||
if (light->LightOnFlag && randModCount-- == 0)
|
||||
{
|
||||
light->Message(0, 0.0);
|
||||
break;
|
||||
@ -296,7 +296,7 @@ int TLightGroup::Message(int code, float value)
|
||||
auto bmp1Count = 0;
|
||||
for (auto light : List)
|
||||
{
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
++bmp1Count;
|
||||
}
|
||||
return bmp1Count;
|
||||
@ -339,7 +339,7 @@ int TLightGroup::Message(int code, float value)
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
auto light = *it;
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
{
|
||||
light->Message(0, 0.0);
|
||||
light->Message(16, value);
|
||||
@ -421,7 +421,7 @@ void TLightGroup::start_animation()
|
||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||
{
|
||||
auto light = *it;
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
light->Message(9, 0.0);
|
||||
else
|
||||
light->Message(8, 0.0);
|
||||
@ -432,7 +432,7 @@ int TLightGroup::next_light_up()
|
||||
{
|
||||
for (auto index = 0u; index < List.size(); ++index)
|
||||
{
|
||||
if (!List[index]->BmpIndex1)
|
||||
if (!List[index]->LightOnFlag)
|
||||
return static_cast<int>(index);
|
||||
}
|
||||
return -1;
|
||||
@ -442,7 +442,7 @@ int TLightGroup::next_light_down()
|
||||
{
|
||||
for (auto index = static_cast<int>(List.size()) - 1; index >= 0; --index)
|
||||
{
|
||||
if (List.at(index)->BmpIndex1)
|
||||
if (List.at(index)->LightOnFlag)
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
|
@ -999,7 +999,7 @@ void control::cheat_bump_rank()
|
||||
bool control::light_on(component_tag<TLight>* tag)
|
||||
{
|
||||
auto light = tag->Component;
|
||||
return light->BmpIndex1 || light->FlasherFlag2 || light->FlasherActive;
|
||||
return light->LightOnFlag || light->ToggledOnFlag || light->FlasherOnFlag;
|
||||
}
|
||||
|
||||
int control::SpecialAddScore(int score)
|
||||
@ -1297,9 +1297,9 @@ void control::ReentryLanesRolloverControl(int code, TPinballComponent* caller)
|
||||
if (roll2 != caller)
|
||||
light = lite10;
|
||||
}
|
||||
if (!light->FlasherActive)
|
||||
if (!light->FlasherOnFlag)
|
||||
{
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
{
|
||||
light->Message(20, 0.0);
|
||||
}
|
||||
@ -1353,9 +1353,9 @@ void control::LaunchLanesRolloverControl(int code, TPinballComponent* caller)
|
||||
if (roll111 != caller)
|
||||
light = lite169;
|
||||
}
|
||||
if (!light->FlasherActive)
|
||||
if (!light->FlasherOnFlag)
|
||||
{
|
||||
if (light->BmpIndex1)
|
||||
if (light->LightOnFlag)
|
||||
{
|
||||
light->Message(20, 0.0);
|
||||
}
|
||||
@ -1865,7 +1865,7 @@ void control::MissionSpotTargetControl(int code, TPinballComponent* caller)
|
||||
lite->Message(15, 2.0);
|
||||
|
||||
TSound* sound;
|
||||
if (!light_on(&control_lite198_tag) || lite198->FlasherActive)
|
||||
if (!light_on(&control_lite198_tag) || lite198->FlasherOnFlag)
|
||||
{
|
||||
sound = soundwave52;
|
||||
}
|
||||
|
@ -513,6 +513,12 @@ void pb::InputDown(GameInput input)
|
||||
case SDLK_F12:
|
||||
MainTable->port_draw();
|
||||
break;
|
||||
case 'i':
|
||||
MainTable->LightGroup->Message(-24, 1.0f);
|
||||
break;
|
||||
case 'j':
|
||||
MainTable->LightGroup->Message(-25, 1.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user