2020-11-01 16:45:29 +01:00
|
|
|
#include "pch.h"
|
|
|
|
#include "TPinballTable.h"
|
|
|
|
|
|
|
|
|
2020-12-19 15:49:31 +01:00
|
|
|
#include "control.h"
|
2020-11-01 16:45:29 +01:00
|
|
|
#include "loader.h"
|
2020-12-25 14:46:06 +01:00
|
|
|
#include "pb.h"
|
2020-11-01 16:45:29 +01:00
|
|
|
#include "pinball.h"
|
2020-12-25 14:46:06 +01:00
|
|
|
#include "render.h"
|
2020-11-01 16:45:29 +01:00
|
|
|
#include "TBall.h"
|
|
|
|
#include "TBlocker.h"
|
|
|
|
#include "TBumper.h"
|
|
|
|
#include "TComponentGroup.h"
|
|
|
|
#include "TDemo.h"
|
|
|
|
#include "TFlagSpinner.h"
|
|
|
|
#include "TGate.h"
|
|
|
|
#include "THole.h"
|
2020-12-25 14:46:06 +01:00
|
|
|
#include "timer.h"
|
2020-11-01 16:45:29 +01:00
|
|
|
#include "TKickback.h"
|
|
|
|
#include "TKickout.h"
|
|
|
|
#include "TLight.h"
|
|
|
|
#include "TLightBargraph.h"
|
|
|
|
#include "TLightGroup.h"
|
|
|
|
#include "TLightRollover.h"
|
|
|
|
#include "TOneway.h"
|
|
|
|
#include "TPopupTarget.h"
|
|
|
|
#include "TRamp.h"
|
|
|
|
#include "TRollover.h"
|
|
|
|
#include "TSink.h"
|
|
|
|
#include "TSoloTarget.h"
|
|
|
|
#include "TSound.h"
|
|
|
|
#include "TTableLayer.h"
|
|
|
|
#include "TTextBox.h"
|
|
|
|
#include "TTimer.h"
|
|
|
|
#include "TTripwire.h"
|
2020-11-28 13:59:42 +01:00
|
|
|
#include "TWall.h"
|
2020-12-25 14:46:06 +01:00
|
|
|
#include "TPlunger.h"
|
|
|
|
#include "TFlipper.h"
|
|
|
|
#include "TDrain.h"
|
|
|
|
|
|
|
|
int TPinballTable::score_multipliers[5] = {1, 2, 3, 5, 10};
|
|
|
|
|
2020-11-01 16:45:29 +01:00
|
|
|
|
|
|
|
TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|
|
|
{
|
|
|
|
int shortArrLength;
|
|
|
|
|
2020-12-25 14:46:06 +01:00
|
|
|
CurScoreStruct = nullptr;
|
|
|
|
ScoreBallcount = nullptr;
|
|
|
|
ScorePlayerNumber1 = nullptr;
|
2021-01-17 16:26:03 +01:00
|
|
|
BallInSink = 0;
|
2021-01-28 16:01:26 +01:00
|
|
|
ActiveFlag = 1;
|
2020-12-25 14:46:06 +01:00
|
|
|
TiltLockFlag = 0;
|
|
|
|
EndGameTimeoutTimer = 0;
|
|
|
|
LightShowTimer = 0;
|
|
|
|
ReplayTimer = 0;
|
|
|
|
TiltTimeoutTimer = 0;
|
|
|
|
MultiballFlag = 0;
|
2021-01-05 13:12:54 +01:00
|
|
|
PlayerCount = 0;
|
2020-12-25 14:46:06 +01:00
|
|
|
|
|
|
|
auto ballObj = new TBall(this);
|
2021-10-01 17:55:44 +02:00
|
|
|
BallList.push_back(ballObj);
|
2020-11-01 16:45:29 +01:00
|
|
|
if (ballObj)
|
2021-01-28 16:01:26 +01:00
|
|
|
ballObj->ActiveFlag = 0;
|
2020-12-20 12:13:12 +01:00
|
|
|
new TTableLayer(this);
|
2020-12-25 14:46:06 +01:00
|
|
|
LightGroup = new TLightGroup(this, 0);
|
2020-11-01 16:45:29 +01:00
|
|
|
|
2020-11-15 15:39:00 +01:00
|
|
|
auto score1 = score::create("score1", render::background_bitmap);
|
2020-12-25 14:46:06 +01:00
|
|
|
CurScoreStruct = score1;
|
|
|
|
PlayerScores[0].ScoreStruct = score1;
|
|
|
|
for (int scoreIndex = 1; scoreIndex < 4; scoreIndex++)
|
2020-11-01 16:45:29 +01:00
|
|
|
{
|
2020-12-25 14:46:06 +01:00
|
|
|
PlayerScores[scoreIndex].ScoreStruct = score::dup(CurScoreStruct, scoreIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
}
|
2020-12-25 14:46:06 +01:00
|
|
|
|
|
|
|
CurrentPlayer = 0;
|
|
|
|
MaxBallCount = 3;
|
|
|
|
ScoreBallcount = score::create("ballcount1", render::background_bitmap);
|
|
|
|
ScorePlayerNumber1 = score::create("player_number1", render::background_bitmap);
|
2020-11-01 16:45:29 +01:00
|
|
|
int groupIndexObjects = loader::query_handle("table_objects");
|
|
|
|
|
|
|
|
short* shortArr = loader::query_iattribute(groupIndexObjects, 1025, &shortArrLength);
|
|
|
|
if (shortArrLength > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < shortArrLength / 2; ++i)
|
|
|
|
{
|
|
|
|
int objectType = *shortArr;
|
|
|
|
short* shortArrPlus1 = shortArr + 1;
|
|
|
|
int groupIndex = *shortArrPlus1;
|
|
|
|
shortArr = shortArrPlus1 + 1;
|
|
|
|
switch (objectType)
|
|
|
|
{
|
|
|
|
case 1000:
|
|
|
|
case 1010:
|
2020-12-19 15:49:31 +01:00
|
|
|
new TWall(this, groupIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1001:
|
2020-12-25 14:46:06 +01:00
|
|
|
Plunger = new TPlunger(this, groupIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1002:
|
2021-10-01 17:55:44 +02:00
|
|
|
LightGroup->List.push_back(new TLight(this, groupIndex));
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1003:
|
2020-12-25 14:46:06 +01:00
|
|
|
FlipperL = new TFlipper(this, groupIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1004:
|
2020-12-25 14:46:06 +01:00
|
|
|
FlipperR = new TFlipper(this, groupIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1005:
|
|
|
|
new TBumper(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1006:
|
|
|
|
new TPopupTarget(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1007:
|
2020-12-25 14:46:06 +01:00
|
|
|
Drain = new TDrain(this, groupIndex);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1011:
|
|
|
|
new TBlocker(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1012:
|
2021-01-17 16:26:03 +01:00
|
|
|
new TKickout(this, groupIndex, true);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1013:
|
|
|
|
new TGate(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1014:
|
|
|
|
new TKickback(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1015:
|
|
|
|
new TRollover(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1016:
|
|
|
|
new TOneway(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1017:
|
|
|
|
new TSink(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1018:
|
|
|
|
new TFlagSpinner(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1019:
|
|
|
|
new TSoloTarget(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1020:
|
|
|
|
new TLightRollover(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1021:
|
|
|
|
new TRamp(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1022:
|
|
|
|
new THole(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1023:
|
|
|
|
new TDemo(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1024:
|
|
|
|
new TTripwire(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1026:
|
|
|
|
new TLightGroup(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1028:
|
|
|
|
new TComponentGroup(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1029:
|
2021-01-17 16:26:03 +01:00
|
|
|
new TKickout(this, groupIndex, false);
|
2020-11-01 16:45:29 +01:00
|
|
|
break;
|
|
|
|
case 1030:
|
|
|
|
new TLightBargraph(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1031:
|
|
|
|
new TSound(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1032:
|
|
|
|
new TTimer(this, groupIndex);
|
|
|
|
break;
|
|
|
|
case 1033:
|
|
|
|
new TTextBox(this, groupIndex);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-27 16:19:36 +01:00
|
|
|
render::build_occlude_list();
|
2020-12-19 15:49:31 +01:00
|
|
|
pinball::InfoTextBox = dynamic_cast<TTextBox*>(find_component("info_text_box"));
|
|
|
|
pinball::MissTextBox = dynamic_cast<TTextBox*>(find_component("mission_text_box"));
|
|
|
|
control::make_links(this);
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TPinballTable::~TPinballTable()
|
|
|
|
{
|
2021-10-02 16:45:31 +02:00
|
|
|
for (auto& PlayerScore : PlayerScores)
|
2020-11-04 14:22:52 +01:00
|
|
|
{
|
2021-10-02 16:45:31 +02:00
|
|
|
delete PlayerScore.ScoreStruct;
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
|
|
|
if (ScorePlayerNumber1)
|
|
|
|
{
|
2021-10-02 16:45:31 +02:00
|
|
|
delete ScorePlayerNumber1;
|
2020-11-04 14:22:52 +01:00
|
|
|
ScorePlayerNumber1 = nullptr;
|
|
|
|
}
|
|
|
|
if (ScoreBallcount)
|
|
|
|
{
|
2021-10-02 16:45:31 +02:00
|
|
|
delete ScoreBallcount;
|
2020-11-04 14:22:52 +01:00
|
|
|
ScoreBallcount = nullptr;
|
|
|
|
}
|
2020-12-20 12:13:12 +01:00
|
|
|
delete LightGroup;
|
2021-10-01 17:55:44 +02:00
|
|
|
while (!ComponentList.empty())
|
2020-11-04 14:22:52 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
// Component destructor removes it from the list.
|
|
|
|
delete ComponentList[0];
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
2021-09-22 14:50:07 +02:00
|
|
|
control::ClearLinks();
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TPinballComponent* TPinballTable::find_component(LPCSTR componentName)
|
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-11-04 14:22:52 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
const char* groupName = component->GroupName;
|
|
|
|
if (groupName && !strcmp(groupName, componentName))
|
2020-11-04 14:22:52 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
return component;
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
|
|
|
}
|
2021-10-01 17:55:44 +02:00
|
|
|
|
2021-09-06 15:27:58 +02:00
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find:", componentName, nullptr);
|
2020-11-04 14:22:52 +01:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TPinballComponent* TPinballTable::find_component(int groupIndex)
|
|
|
|
{
|
2021-02-02 16:29:54 +01:00
|
|
|
char Buffer[40]{};
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-11-04 14:22:52 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
if (component->GroupIndex == groupIndex)
|
|
|
|
return component;
|
2020-11-04 14:22:52 +01:00
|
|
|
}
|
2021-10-01 17:55:44 +02:00
|
|
|
|
2021-09-09 10:40:54 +02:00
|
|
|
snprintf(Buffer, sizeof Buffer, "%d", groupIndex);
|
2021-09-06 15:27:58 +02:00
|
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Table cant find (lh):", Buffer, nullptr);
|
2020-11-04 14:22:52 +01:00
|
|
|
return nullptr;
|
2020-11-01 16:45:29 +01:00
|
|
|
}
|
2020-11-29 16:50:49 +01:00
|
|
|
|
2020-12-25 14:46:06 +01:00
|
|
|
int TPinballTable::AddScore(int score)
|
|
|
|
{
|
2021-01-05 10:02:43 +01:00
|
|
|
if (ScoreSpecial3Flag)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-01-05 10:02:43 +01:00
|
|
|
ScoreSpecial3 += score;
|
|
|
|
if (ScoreSpecial3 > 5000000)
|
|
|
|
ScoreSpecial3 = 5000000;
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
2021-01-05 10:02:43 +01:00
|
|
|
if (ScoreSpecial2Flag)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-01-05 10:02:43 +01:00
|
|
|
ScoreSpecial2 += score;
|
|
|
|
if (ScoreSpecial2 > 5000000)
|
|
|
|
ScoreSpecial2 = 5000000;
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
2021-01-05 10:02:43 +01:00
|
|
|
int addedScore = ScoreAdded + score * score_multipliers[ScoreMultiplier];
|
|
|
|
CurScore += addedScore;
|
|
|
|
if (CurScore > 1000000000)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-01-05 10:02:43 +01:00
|
|
|
++CurScoreE9;
|
|
|
|
CurScore = CurScore - 1000000000;
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
2021-01-05 10:02:43 +01:00
|
|
|
score::set(CurScoreStruct, CurScore);
|
2020-12-25 14:46:06 +01:00
|
|
|
return addedScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::ChangeBallCount(int count)
|
|
|
|
{
|
|
|
|
BallCount = count;
|
|
|
|
if (count <= 0)
|
|
|
|
{
|
|
|
|
score::erase(ScoreBallcount, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
score::set(ScoreBallcount, MaxBallCount - count + 1);
|
|
|
|
score::update(ScoreBallcount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::tilt(float time)
|
|
|
|
{
|
2021-01-17 16:26:03 +01:00
|
|
|
if (!TiltLockFlag && !BallInSink)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
|
|
|
pinball::InfoTextBox->Clear();
|
|
|
|
pinball::MissTextBox->Clear();
|
|
|
|
pinball::InfoTextBox->Display(pinball::get_rc_string(35, 0), -1.0);
|
2021-01-05 10:02:43 +01:00
|
|
|
loader::play_sound(SoundIndex3);
|
|
|
|
TiltTimeoutTimer = timer::set(30.0, this, tilt_timeout);
|
2020-12-25 14:46:06 +01:00
|
|
|
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->Message(1011, time);
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
2021-01-05 10:02:43 +01:00
|
|
|
LightGroup->Message(8, 0);
|
|
|
|
TiltLockFlag = 1;
|
2020-12-25 14:46:06 +01:00
|
|
|
control::table_control_handler(1011);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-29 16:50:49 +01:00
|
|
|
|
|
|
|
void TPinballTable::port_draw()
|
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-11-29 16:50:49 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->port_draw();
|
2020-11-29 16:50:49 +01:00
|
|
|
}
|
2020-12-19 15:49:31 +01:00
|
|
|
}
|
2020-12-25 14:46:06 +01:00
|
|
|
|
|
|
|
int TPinballTable::Message(int code, float value)
|
|
|
|
{
|
|
|
|
LPSTR rc_text;
|
|
|
|
switch (code)
|
|
|
|
{
|
|
|
|
case 1000:
|
|
|
|
if (!TiltLockFlag)
|
|
|
|
{
|
|
|
|
FlipperL->Message(1, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1001:
|
|
|
|
if (!TiltLockFlag)
|
|
|
|
{
|
|
|
|
FlipperL->Message(2, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1002:
|
|
|
|
if (!TiltLockFlag)
|
|
|
|
{
|
|
|
|
FlipperR->Message(1, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1003:
|
|
|
|
if (!TiltLockFlag)
|
|
|
|
{
|
|
|
|
FlipperR->Message(2, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1004:
|
|
|
|
case 1005:
|
|
|
|
Plunger->Message(code, value);
|
|
|
|
break;
|
|
|
|
case 1008:
|
|
|
|
case 1009:
|
|
|
|
case 1010:
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->Message(code, value);
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1012:
|
|
|
|
LightGroup->Message(14, 0.0);
|
|
|
|
if (TiltLockFlag)
|
|
|
|
{
|
|
|
|
TiltLockFlag = 0;
|
|
|
|
if (TiltTimeoutTimer)
|
|
|
|
timer::kill(TiltTimeoutTimer);
|
|
|
|
TiltTimeoutTimer = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1013:
|
|
|
|
LightGroup->Message(34, 0.0);
|
|
|
|
LightGroup->Message(20, 0.0);
|
|
|
|
Plunger->Message(1016, 0.0);
|
2021-10-23 06:33:04 +02:00
|
|
|
if (Demo && Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
rc_text = pinball::get_rc_string(30, 0);
|
|
|
|
else
|
|
|
|
rc_text = pinball::get_rc_string(26, 0);
|
|
|
|
pinball::InfoTextBox->Display(rc_text, -1.0);
|
|
|
|
if (Demo)
|
|
|
|
Demo->Message(1014, 0.0);
|
|
|
|
break;
|
|
|
|
case 1014:
|
|
|
|
if (EndGameTimeoutTimer)
|
|
|
|
{
|
|
|
|
timer::kill(EndGameTimeoutTimer);
|
|
|
|
EndGame_timeout(0, this);
|
|
|
|
pb::mode_change(1);
|
|
|
|
}
|
|
|
|
if (LightShowTimer)
|
|
|
|
{
|
|
|
|
timer::kill(LightShowTimer);
|
|
|
|
LightShowTimer = 0;
|
|
|
|
Message(1013, 0.0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-01-06 15:06:13 +01:00
|
|
|
CheatsUsed = 0;
|
2020-12-25 14:46:06 +01:00
|
|
|
Message(1024, 0.0);
|
2021-10-01 17:55:44 +02:00
|
|
|
auto ball = BallList[0];
|
2020-12-27 16:19:36 +01:00
|
|
|
ball->Position.Y = 0.0;
|
|
|
|
ball->Position.X = 0.0;
|
|
|
|
ball->Position.Z = -0.8f;
|
2020-12-25 14:46:06 +01:00
|
|
|
|
|
|
|
auto playerCount = static_cast<int>(floor(value));
|
|
|
|
PlayerCount = playerCount;
|
|
|
|
if (playerCount >= 1)
|
|
|
|
{
|
|
|
|
if (playerCount > 4)
|
|
|
|
PlayerCount = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlayerCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto plr1Score = PlayerScores[0].ScoreStruct;
|
|
|
|
CurrentPlayer = 0;
|
|
|
|
CurScoreStruct = plr1Score;
|
|
|
|
CurScore = 0;
|
|
|
|
score::set(plr1Score, 0);
|
|
|
|
ScoreMultiplier = 0;
|
|
|
|
|
|
|
|
for (int plrIndex = 1; plrIndex < PlayerCount; ++plrIndex)
|
|
|
|
{
|
|
|
|
auto scorePtr = &PlayerScores[plrIndex];
|
|
|
|
score::set(scorePtr->ScoreStruct, 0);
|
|
|
|
scorePtr->Score = 0;
|
|
|
|
scorePtr->ScoreE9Part = 0;
|
|
|
|
scorePtr->BallCount = MaxBallCount;
|
|
|
|
scorePtr->ExtraBalls = ExtraBalls;
|
|
|
|
scorePtr->BallLockedCounter = BallLockedCounter;
|
|
|
|
scorePtr->Unknown2 = ScoreSpecial3;
|
|
|
|
}
|
|
|
|
|
|
|
|
BallCount = MaxBallCount;
|
|
|
|
ChangeBallCount(BallCount);
|
|
|
|
score::set(ScorePlayerNumber1, CurrentPlayer + 1);
|
|
|
|
score::update(ScorePlayerNumber1);
|
|
|
|
|
|
|
|
for (auto scoreIndex = 4 - PlayerCount; scoreIndex > 0; scoreIndex--)
|
|
|
|
{
|
|
|
|
score::set(PlayerScores[scoreIndex].ScoreStruct, -1);
|
|
|
|
}
|
2021-10-01 17:55:44 +02:00
|
|
|
|
2020-12-25 14:46:06 +01:00
|
|
|
ScoreSpecial3Flag = 0;
|
|
|
|
ScoreSpecial2Flag = 0;
|
|
|
|
UnknownP71 = 0;
|
|
|
|
pinball::InfoTextBox->Clear();
|
|
|
|
pinball::MissTextBox->Clear();
|
|
|
|
LightGroup->Message(28, 0.2f);
|
|
|
|
auto time = loader::play_sound(SoundIndex1);
|
|
|
|
LightShowTimer = timer::set(time, this, LightShow_timeout);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1018:
|
|
|
|
if (ReplayTimer)
|
|
|
|
timer::kill(ReplayTimer);
|
|
|
|
ReplayTimer = timer::set(floor(value), this, replay_timer_callback);
|
|
|
|
ReplayActiveFlag = 1;
|
|
|
|
break;
|
|
|
|
case 1021:
|
|
|
|
{
|
|
|
|
if (PlayerCount <= 1)
|
|
|
|
{
|
|
|
|
char* textboxText;
|
2021-01-28 16:01:26 +01:00
|
|
|
if (Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
textboxText = pinball::get_rc_string(30, 0);
|
|
|
|
else
|
|
|
|
textboxText = pinball::get_rc_string(26, 0);
|
|
|
|
pinball::InfoTextBox->Display(textboxText, -1.0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto nextPlayer = (CurrentPlayer + 1) % PlayerCount;
|
|
|
|
auto nextScorePtr = &PlayerScores[nextPlayer];
|
|
|
|
if (nextScorePtr->BallCount <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
PlayerScores[CurrentPlayer].Score = CurScore;
|
|
|
|
PlayerScores[CurrentPlayer].ScoreE9Part = CurScoreE9;
|
|
|
|
PlayerScores[CurrentPlayer].BallCount = BallCount;
|
|
|
|
PlayerScores[CurrentPlayer].ExtraBalls = ExtraBalls;
|
|
|
|
PlayerScores[CurrentPlayer].BallLockedCounter = BallLockedCounter;
|
|
|
|
PlayerScores[CurrentPlayer].Unknown2 = ScoreSpecial3;
|
|
|
|
|
|
|
|
CurScore = nextScorePtr->Score;
|
|
|
|
CurScoreE9 = nextScorePtr->ScoreE9Part;
|
|
|
|
BallCount = nextScorePtr->BallCount;
|
|
|
|
ExtraBalls = nextScorePtr->ExtraBalls;
|
|
|
|
BallLockedCounter = nextScorePtr->BallLockedCounter;
|
|
|
|
ScoreSpecial3 = nextScorePtr->Unknown2;
|
|
|
|
|
|
|
|
CurScoreStruct = nextScorePtr->ScoreStruct;
|
|
|
|
score::set(CurScoreStruct, CurScore);
|
|
|
|
CurScoreStruct->DirtyFlag = true;
|
|
|
|
|
|
|
|
ChangeBallCount(BallCount);
|
|
|
|
score::set(ScorePlayerNumber1, nextPlayer + 1);
|
|
|
|
score::update(ScorePlayerNumber1);
|
|
|
|
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->Message(1020, static_cast<float>(nextPlayer));
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
char* textboxText = nullptr;
|
|
|
|
switch (nextPlayer)
|
|
|
|
{
|
|
|
|
case 0:
|
2021-01-28 16:01:26 +01:00
|
|
|
if (Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
textboxText = pinball::get_rc_string(30, 0);
|
|
|
|
else
|
|
|
|
textboxText = pinball::get_rc_string(26, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
2021-01-28 16:01:26 +01:00
|
|
|
if (Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
textboxText = pinball::get_rc_string(31, 0);
|
|
|
|
else
|
|
|
|
textboxText = pinball::get_rc_string(27, 0);
|
|
|
|
break;
|
|
|
|
case 2:
|
2021-01-28 16:01:26 +01:00
|
|
|
if (Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
textboxText = pinball::get_rc_string(32, 0);
|
|
|
|
else
|
|
|
|
textboxText = pinball::get_rc_string(28, 0);
|
|
|
|
break;
|
|
|
|
case 3:
|
2021-01-28 16:01:26 +01:00
|
|
|
if (Demo->ActiveFlag)
|
2020-12-25 14:46:06 +01:00
|
|
|
textboxText = pinball::get_rc_string(33, 0);
|
|
|
|
else
|
|
|
|
textboxText = pinball::get_rc_string(29, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (textboxText != nullptr)
|
|
|
|
pinball::InfoTextBox->Display(textboxText, -1);
|
|
|
|
ScoreSpecial3Flag = 0;
|
|
|
|
ScoreSpecial2Flag = 0;
|
|
|
|
UnknownP71 = 0;
|
|
|
|
CurrentPlayer = nextPlayer;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1022:
|
|
|
|
loader::play_sound(SoundIndex2);
|
|
|
|
pinball::MissTextBox->Clear();
|
|
|
|
pinball::InfoTextBox->Display(pinball::get_rc_string(34, 0), -1.0);
|
|
|
|
EndGameTimeoutTimer = timer::set(3.0, this, EndGame_timeout);
|
|
|
|
break;
|
|
|
|
case 1024:
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : ComponentList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->Message(1024, 0);
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
|
|
|
if (ReplayTimer)
|
|
|
|
timer::kill(ReplayTimer);
|
|
|
|
ReplayTimer = 0;
|
|
|
|
if (LightShowTimer)
|
|
|
|
{
|
|
|
|
timer::kill(LightShowTimer);
|
|
|
|
LightGroup->Message(34, 0.0);
|
|
|
|
}
|
|
|
|
LightShowTimer = 0;
|
|
|
|
ScoreMultiplier = 0;
|
|
|
|
ScoreAdded = 0;
|
|
|
|
ScoreSpecial1 = 0;
|
|
|
|
ScoreSpecial2 = 10000;
|
|
|
|
ScoreSpecial2Flag = 0;
|
|
|
|
ScoreSpecial3 = 20000;
|
|
|
|
ScoreSpecial3Flag = 0;
|
|
|
|
UnknownP71 = 0;
|
|
|
|
ExtraBalls = 0;
|
|
|
|
UnknownP75 = 0;
|
|
|
|
BallLockedCounter = 0;
|
|
|
|
MultiballFlag = 0;
|
|
|
|
UnknownP78 = 0;
|
|
|
|
ReplayActiveFlag = 0;
|
|
|
|
ReplayTimer = 0;
|
|
|
|
TiltLockFlag = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
control::table_control_handler(code);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::EndGame_timeout(int timerId, void* caller)
|
|
|
|
{
|
|
|
|
auto table = static_cast<TPinballTable*>(caller);
|
|
|
|
table->EndGameTimeoutTimer = 0;
|
|
|
|
pb::end_game();
|
|
|
|
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto component : table->ComponentList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
component->Message(1022, 0);
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
|
|
|
if (table->Demo)
|
|
|
|
table->Demo->Message(1022, 0.0);
|
|
|
|
control::handler(67, pinball::MissTextBox);
|
|
|
|
pinball::InfoTextBox->Display(pinball::get_rc_string(24, 0), -1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::LightShow_timeout(int timerId, void* caller)
|
|
|
|
{
|
|
|
|
auto table = static_cast<TPinballTable*>(caller);
|
|
|
|
table->LightShowTimer = 0;
|
|
|
|
table->Message(1013, 0.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::replay_timer_callback(int timerId, void* caller)
|
|
|
|
{
|
|
|
|
auto table = static_cast<TPinballTable*>(caller);
|
|
|
|
table->ReplayActiveFlag = 0;
|
|
|
|
table->ReplayTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TPinballTable::tilt_timeout(int timerId, void* caller)
|
|
|
|
{
|
|
|
|
auto table = static_cast<TPinballTable*>(caller);
|
2021-01-19 16:28:48 +01:00
|
|
|
vector_type vec{};
|
|
|
|
|
2020-12-25 14:46:06 +01:00
|
|
|
table->TiltTimeoutTimer = 0;
|
|
|
|
if (table->TiltLockFlag)
|
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
for (auto ball : table->BallList)
|
2020-12-25 14:46:06 +01:00
|
|
|
{
|
2021-10-01 17:55:44 +02:00
|
|
|
table->Drain->Collision(ball, &vec, &vec, 0.0, nullptr);
|
2021-01-19 16:28:48 +01:00
|
|
|
}
|
2020-12-25 14:46:06 +01:00
|
|
|
}
|
|
|
|
}
|