revert changes to have a new cleaner PR after review/cherry picks
This commit is contained in:
parent
efd4dc1d9e
commit
d106f0f771
|
@ -27,7 +27,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
#if _WIN32
|
||||
#include <Windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
// Windows subsystem main
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
|
|
|
@ -40,10 +40,10 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
|
|||
|
||||
Offset = *loader::query_float_attribute(groupIndex, 0, 500);
|
||||
auto visualCount = loader::query_visual_states(groupIndex);
|
||||
auto index = 0;
|
||||
if (visualCount > 0)
|
||||
{
|
||||
auto visualZPtr = VisualZArray;
|
||||
int index = 0;
|
||||
do
|
||||
{
|
||||
loader::query_visual(groupIndex, index, &visual);
|
||||
|
|
|
@ -20,7 +20,7 @@ void TEdgeSegment::port_draw()
|
|||
TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* collComp, char* activeFlagPtr,
|
||||
unsigned int collisionGroup, float offset, size_t wallValue)
|
||||
{
|
||||
vector_type center{}, start{}, end{}, vec1{}, vec2{}, dstVec{};
|
||||
vector_type center{}, start{}, end{}, prevCenter{}, vec1{}, vec2{}, dstVec{};
|
||||
TEdgeSegment* edge = nullptr;
|
||||
|
||||
wall_type wallType = static_cast<wall_type>(static_cast<int>(floor(*floatArr) - 1.0f));
|
||||
|
@ -31,14 +31,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
|||
center.X = floatArr[1];
|
||||
center.Y = floatArr[2];
|
||||
auto radius = offset + floatArr[3];
|
||||
TCircle* circle = nullptr;
|
||||
try
|
||||
{
|
||||
circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
edge = circle;
|
||||
|
||||
if (circle)
|
||||
|
@ -56,14 +49,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
|||
start.Y = floatArr[2];
|
||||
end.X = floatArr[3];
|
||||
end.Y = floatArr[4];
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
|
||||
edge = line;
|
||||
|
||||
if (line)
|
||||
|
@ -79,7 +65,6 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
|||
{
|
||||
int wallTypeI = static_cast<int>(wallType);
|
||||
auto floatArrPtr = floatArr + 1;
|
||||
vector_type prevCenter{};
|
||||
prevCenter.X = floatArr[2 * wallTypeI - 1];
|
||||
prevCenter.Y = floatArr[2 * wallTypeI];
|
||||
|
||||
|
@ -112,14 +97,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
|||
dstVec.Z < 0.0f && offset < 0.0f)
|
||||
{
|
||||
float radius = offset * 1.001f;
|
||||
TCircle* circle = nullptr;
|
||||
try
|
||||
{
|
||||
circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, ¢er, radius);
|
||||
|
||||
if (circle)
|
||||
{
|
||||
|
@ -134,14 +112,7 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
|
|||
start.Y = floatArrPtr[1];
|
||||
end.X = floatArrPtr[2];
|
||||
end.Y = floatArrPtr[3];
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto line = new TLine(collComp, activeFlagPtr, collisionGroup, &start, &end);
|
||||
edge = line;
|
||||
|
||||
if (line)
|
||||
|
|
|
@ -21,28 +21,14 @@ TFlagSpinner::TFlagSpinner(TPinballTable* table, int groupIndex) : TCollisionCom
|
|||
end.Y = visual.FloatArr[1];
|
||||
start.X = visual.FloatArr[2];
|
||||
start.Y = visual.FloatArr[3];
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &start, &end);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &start, &end);
|
||||
if (line)
|
||||
{
|
||||
line->place_in_grid();
|
||||
EdgeList.push_back(line);
|
||||
}
|
||||
|
||||
line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &end, &start);
|
||||
PrevCollider = line;
|
||||
if (line)
|
||||
{
|
||||
|
|
|
@ -34,26 +34,20 @@ TFlipper::TFlipper(TPinballTable* table, int groupIndex) : TCollisionComponent(t
|
|||
auto vecT2 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 802));
|
||||
auto vecT1 = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 801));
|
||||
auto origin = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, 0, 800));
|
||||
TFlipperEdge* flipperEdge = nullptr;
|
||||
try
|
||||
{
|
||||
flipperEdge = new TFlipperEdge(
|
||||
this,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
table,
|
||||
origin,
|
||||
vecT1,
|
||||
vecT2,
|
||||
extendTime,
|
||||
retractTime,
|
||||
collMult,
|
||||
Elasticity,
|
||||
Smoothness);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto flipperEdge = new TFlipperEdge(
|
||||
this,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
table,
|
||||
origin,
|
||||
vecT1,
|
||||
vecT2,
|
||||
extendTime,
|
||||
retractTime,
|
||||
collMult,
|
||||
Elasticity,
|
||||
Smoothness);
|
||||
|
||||
FlipperEdge = flipperEdge;
|
||||
if (flipperEdge)
|
||||
{
|
||||
|
@ -71,7 +65,7 @@ TFlipper::~TFlipper()
|
|||
|
||||
int TFlipper::Message(int code, float value)
|
||||
{
|
||||
if (code == 1 || code == 2 || (code > 1008 && code <= 1011) || code == 1022)
|
||||
if (code == 1 || code == 2 || code > 1008 && code <= 1011 || code == 1022)
|
||||
{
|
||||
float timerTime;
|
||||
int command = code;
|
||||
|
|
|
@ -109,6 +109,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
|
|||
{
|
||||
if (FlipperFlag == 0)
|
||||
{
|
||||
EdgeCollisionFlag = 0;
|
||||
CollisionFlag1 = 0;
|
||||
CollisionFlag2 = 0;
|
||||
set_control_points(ogRay->TimeNow);
|
||||
|
@ -435,6 +436,7 @@ float TFlipperEdge::flipper_angle(float timeNow)
|
|||
|
||||
int TFlipperEdge::is_ball_inside(float x, float y)
|
||||
{
|
||||
vector_type testPoint{};
|
||||
float dx = RotOrigin.X - x;
|
||||
float dy = RotOrigin.Y - y;
|
||||
if ((A2.X - A1.X) * (y - A1.Y) - (A2.Y - A1.Y) * (x - A1.X) >= 0.0f &&
|
||||
|
@ -445,7 +447,6 @@ int TFlipperEdge::is_ball_inside(float x, float y)
|
|||
(T1.Y - y) * (T1.Y - y) + (T1.X - x) * (T1.X - x) < CircleT1RadiusSq)
|
||||
{
|
||||
float flipperLR = AngleMax < 0.0f ? -1.0f : 1.0f;
|
||||
vector_type testPoint{};
|
||||
if (FlipperFlag == 1)
|
||||
testPoint = AngleMax < 0.0f ? B1 : B2;
|
||||
else if (FlipperFlag == 2)
|
||||
|
|
|
@ -30,16 +30,9 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
if (Circle.RadiusSq == 0.0f)
|
||||
Circle.RadiusSq = 0.001f;
|
||||
|
||||
TCircle* tCircle = nullptr;
|
||||
try
|
||||
{
|
||||
tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||
reinterpret_cast<vector_type*>(visual.FloatArr),
|
||||
Circle.RadiusSq);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||
reinterpret_cast<vector_type*>(visual.FloatArr),
|
||||
Circle.RadiusSq);
|
||||
if (tCircle)
|
||||
{
|
||||
tCircle->place_in_grid();
|
||||
|
|
|
@ -35,15 +35,8 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
|
|||
Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2];
|
||||
if (Circle.RadiusSq == 0.0f)
|
||||
Circle.RadiusSq = 0.001f;
|
||||
TCircle* tCircle = nullptr;
|
||||
try
|
||||
{
|
||||
tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
|
||||
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
|
||||
if (tCircle)
|
||||
{
|
||||
tCircle->place_in_grid();
|
||||
|
|
|
@ -17,13 +17,7 @@ TLightBargraph::TLightBargraph(TPinballTable* table, int groupIndex) : TLightGro
|
|||
if (floatArr)
|
||||
{
|
||||
auto count = 2 * List.size();
|
||||
try
|
||||
{
|
||||
TimerTimeArray = new float[count];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
TimerTimeArray = new float[count];
|
||||
if (TimerTimeArray)
|
||||
{
|
||||
for (auto i = 0u; i < count; ++floatArr)
|
||||
|
|
|
@ -432,7 +432,7 @@ int TLightGroup::next_light_up()
|
|||
{
|
||||
for (auto index = 0u; index < List.size(); ++index)
|
||||
{
|
||||
if (!List[index]->BmpIndex1)
|
||||
if (!List.at(index)->BmpIndex1)
|
||||
return static_cast<int>(index);
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -20,14 +20,8 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
|||
linePt2.Y = visual.FloatArr[1];
|
||||
linePt1.X = visual.FloatArr[2];
|
||||
linePt1.Y = visual.FloatArr[3];
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt2, &linePt1);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
auto line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt2, &linePt1);
|
||||
if (line)
|
||||
{
|
||||
line->Offset(table->CollisionCompOffset);
|
||||
|
@ -35,14 +29,7 @@ TOneway::TOneway(TPinballTable* table, int groupIndex) : TCollisionComponent(tab
|
|||
EdgeList.push_back(line);
|
||||
}
|
||||
|
||||
line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
line = new TLine(this, &ActiveFlag, visual.CollisionGroup, &linePt1, &linePt2);
|
||||
Line = line;
|
||||
if (line)
|
||||
{
|
||||
|
|
|
@ -58,14 +58,7 @@ TPinballTable::TPinballTable(): TPinballComponent(nullptr, -1, false)
|
|||
MultiballFlag = 0;
|
||||
PlayerCount = 0;
|
||||
|
||||
TBall* ballObj = nullptr;
|
||||
try
|
||||
{
|
||||
ballObj = new TBall(this);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto ballObj = new TBall(this);
|
||||
BallList.push_back(ballObj);
|
||||
if (ballObj)
|
||||
ballObj->ActiveFlag = 0;
|
||||
|
@ -375,7 +368,7 @@ int TPinballTable::Message(int code, float value)
|
|||
LightGroup->Message(34, 0.0);
|
||||
LightGroup->Message(20, 0.0);
|
||||
Plunger->Message(1016, 0.0);
|
||||
if (Demo && Demo->ActiveFlag)
|
||||
if (Demo->ActiveFlag)
|
||||
rc_text = pinball::get_rc_string(30, 0);
|
||||
else
|
||||
rc_text = pinball::get_rc_string(26, 0);
|
||||
|
|
|
@ -37,7 +37,7 @@ void TPlunger::Collision(TBall* ball, vector_type* nextPosition, vector_type* di
|
|||
{
|
||||
if (PinballTable->TiltLockFlag)
|
||||
Message(1017, 0.0);
|
||||
coef = RandFloat() * Boost * 0.1f + Boost; //!! passed in coef is never used
|
||||
coef = RandFloat() * Boost * 0.1f + Boost;
|
||||
maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, coef);
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ int TPlunger::Message(int code, float value)
|
|||
if (PullbackTimer_)
|
||||
timer::kill(PullbackTimer_);
|
||||
PullbackTimer_ = 0;
|
||||
if (code == 1005) //!!
|
||||
if (code == 1005)
|
||||
loader::play_sound(SoundIndexP2);
|
||||
auto bmp = ListBitmap->at(0);
|
||||
auto zMap = ListZMap->at(0);
|
||||
|
|
|
@ -116,14 +116,7 @@ TRamp::TRamp(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
|
|||
}
|
||||
if (collisionGroup)
|
||||
{
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto line = new TLine(this, &ActiveFlag, collisionGroup, point1, point2);
|
||||
EdgeList.push_back(line);
|
||||
if (line)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
|
|||
ball->Position.Y = nextPosition->Y;
|
||||
ball->RayMaxDistance -= coef;
|
||||
ball->not_again(edge);
|
||||
gdrv_bitmap8* bmp = nullptr;
|
||||
if (!PinballTable->TiltLockFlag)
|
||||
{
|
||||
if (RolloverFlag)
|
||||
|
@ -59,7 +60,6 @@ void TRollover::Collision(TBall* ball, vector_type* nextPosition, vector_type* d
|
|||
RolloverFlag = RolloverFlag == 0;
|
||||
if (ListBitmap)
|
||||
{
|
||||
gdrv_bitmap8* bmp = nullptr;
|
||||
if (!RolloverFlag)
|
||||
bmp = ListBitmap->at(0);
|
||||
render::sprite_set_bitmap(RenderSprite, bmp);
|
||||
|
|
|
@ -80,20 +80,13 @@ TTableLayer::TTableLayer(TPinballTable* table): TCollisionComponent(table, -1, f
|
|||
|
||||
for (auto visFloatArrCount = visual.FloatArrCount; visFloatArrCount > 0; visFloatArrCount--)
|
||||
{
|
||||
TLine* line = nullptr;
|
||||
try
|
||||
{
|
||||
line = new TLine(this,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
visArrPtr[2],
|
||||
visArrPtr[3],
|
||||
visArrPtr[0],
|
||||
visArrPtr[1]);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto line = new TLine(this,
|
||||
&ActiveFlag,
|
||||
visual.CollisionGroup,
|
||||
visArrPtr[2],
|
||||
visArrPtr[3],
|
||||
visArrPtr[0],
|
||||
visArrPtr[1]);
|
||||
if (line)
|
||||
{
|
||||
line->place_in_grid();
|
||||
|
|
|
@ -123,14 +123,7 @@ void TTextBox::Display(const char* text, float time)
|
|||
if (Timer == -1)
|
||||
Clear();
|
||||
|
||||
TTextBoxMessage* message = nullptr;
|
||||
try
|
||||
{
|
||||
message = new TTextBoxMessage(text, time);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
auto message = new TTextBoxMessage(text, time);
|
||||
if (message)
|
||||
{
|
||||
if (message->Text)
|
||||
|
|
|
@ -10,14 +10,7 @@ TTextBoxMessage::TTextBoxMessage(const char* text, float time)
|
|||
if (text)
|
||||
{
|
||||
const auto textLen = strlen(text) + 1;
|
||||
Text = nullptr;
|
||||
try
|
||||
{
|
||||
Text = new char[textLen];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
Text = new char[textLen];
|
||||
if (Text)
|
||||
strncpy(Text, text, textLen);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "TBall.h"
|
||||
#include "TPinballTable.h"
|
||||
|
||||
TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, true)
|
||||
TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, 1)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1019,7 +1019,7 @@ void control::LaunchRampControl(int code, TPinballComponent* caller)
|
|||
{
|
||||
sound = control_soundwave21_tag.Component;
|
||||
}
|
||||
else if (someFlag <= 1 || someFlag > 3) //!! <1 ?
|
||||
else if (someFlag <= 1 || someFlag > 3)
|
||||
{
|
||||
sound = control_soundwave24_tag.Component;
|
||||
}
|
||||
|
@ -2148,7 +2148,7 @@ void control::HyperspaceKickOutControl(int code, TPinballComponent* caller)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (someFlag <= 1 || someFlag > 3) //!! <1 ?
|
||||
if (someFlag <= 1 || someFlag > 3)
|
||||
{
|
||||
auto duration = control_soundwave41_tag.Component->Play();
|
||||
control_soundwave36_1_tag.Component->Play();
|
||||
|
@ -2919,7 +2919,7 @@ void control::GameoverController(int code, TPinballComponent* caller)
|
|||
|
||||
if (missionMsg & 0x200)
|
||||
{
|
||||
int highscoreId = missionMsg % 4; //!! %5 ?
|
||||
int highscoreId = missionMsg % 4;
|
||||
int highScore = pb::highscore_table[highscoreId].Score;
|
||||
auto nextHidhscoreId = highscoreId + 1;
|
||||
if (highScore > 0)
|
||||
|
@ -3923,7 +3923,9 @@ void control::SelectMissionController(int code, TPinballComponent* caller)
|
|||
if (light_on(&control_lite319_tag))
|
||||
control_lite319_tag.Component->Message(20, 0.0);
|
||||
if (!light_on(&control_lite317_tag))
|
||||
{
|
||||
control_lite317_tag.Component->Message(7, 0.0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4156,7 +4158,6 @@ void control::TimeWarpPartTwoController(int code, TPinballComponent* caller)
|
|||
control_lite317_tag.Component->Message(20, 0.0);
|
||||
control_lite198_tag.Component->MessageField = 1;
|
||||
MissionControl(66, nullptr);
|
||||
//!! Display score?
|
||||
}
|
||||
|
||||
void control::UnselectMissionController(int code, TPinballComponent* caller)
|
||||
|
|
|
@ -58,7 +58,7 @@ int fullscrn::enableFullscreen()
|
|||
if (!display_changed)
|
||||
{
|
||||
SDL_SetWindowFullscreen(winmain::MainWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
display_changed = 1; //!!
|
||||
display_changed = 1;
|
||||
if (display_changed)
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -206,6 +206,9 @@ void maths::line_init(line_type* line, float x0, float y0, float x1, float y1)
|
|||
|
||||
float maths::ray_intersect_line(ray_type* ray, line_type* line)
|
||||
{
|
||||
bool v5;
|
||||
bool v6;
|
||||
|
||||
float perpDot = line->PerpendicularL.Y * ray->Direction.Y + ray->Direction.X * line->PerpendicularL.X;
|
||||
if (perpDot < 0.0f)
|
||||
{
|
||||
|
@ -221,8 +224,8 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
|
|||
{
|
||||
if (v4 >= line->OriginX)
|
||||
{
|
||||
bool v5 = v4 < line->OriginY;
|
||||
bool v6 = v4 == line->OriginY;
|
||||
v5 = v4 < line->OriginY;
|
||||
v6 = v4 == line->OriginY;
|
||||
if (v5 || v6)
|
||||
return result;
|
||||
return 1000000000.0;
|
||||
|
@ -231,8 +234,8 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
|
|||
else if (line->OriginX <= line->RayIntersect.X)
|
||||
{
|
||||
float v7 = line->RayIntersect.X;
|
||||
bool v5 = v7 < line->OriginY;
|
||||
bool v6 = v7 == line->OriginY;
|
||||
v5 = v7 < line->OriginY;
|
||||
v6 = v7 == line->OriginY;
|
||||
if (v5 || v6)
|
||||
return result;
|
||||
return 1000000000.0;
|
||||
|
@ -296,7 +299,7 @@ float maths::basic_collision(TBall* ball, vector_type* nextPosition, vector_type
|
|||
return projSpeed;
|
||||
}
|
||||
|
||||
float maths::Distance_Squared(vector_type& vec1, vector_type& vec2)
|
||||
float maths::Distance_Squared(vector_type vec1, vector_type vec2)
|
||||
{
|
||||
return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
|
||||
float smoothness,
|
||||
float threshold, float boost);
|
||||
static float Distance_Squared(vector_type& vec1, vector_type& vec2);
|
||||
static float Distance_Squared(vector_type vec1, vector_type vec2);
|
||||
static float DotProduct(vector_type* vec1, vector_type* vec2);
|
||||
static void vswap(vector_type* vec1, vector_type* vec2);
|
||||
static float Distance(vector_type* vec1, vector_type* vec2);
|
||||
|
|
|
@ -318,5 +318,5 @@ std::vector<uint8_t>* midi::MdsToMidi(std::string file)
|
|||
delete[] fileBuf;
|
||||
if (returnCode && midiOut)
|
||||
delete midiOut;
|
||||
return midiOut; //!! could be already deleted
|
||||
return midiOut;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,8 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
DatFile* datFile;
|
||||
try
|
||||
{
|
||||
datFile = new DatFile();
|
||||
}
|
||||
catch (...)
|
||||
auto datFile = new DatFile();
|
||||
if (!datFile)
|
||||
{
|
||||
fclose(fileHandle);
|
||||
return nullptr;
|
||||
|
@ -43,12 +39,8 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
|
||||
if (header.Unknown)
|
||||
{
|
||||
char* unknownBuf;
|
||||
try
|
||||
{
|
||||
unknownBuf = new char[header.Unknown];
|
||||
}
|
||||
catch (...)
|
||||
auto unknownBuf = new char[header.Unknown];
|
||||
if (!unknownBuf)
|
||||
{
|
||||
fclose(fileHandle);
|
||||
delete datFile;
|
||||
|
@ -115,18 +107,13 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
|
|||
}
|
||||
else
|
||||
{
|
||||
char* entryBuffer;
|
||||
try
|
||||
auto entryBuffer = new char[fieldSize];
|
||||
entryData->Buffer = entryBuffer;
|
||||
if (!entryBuffer)
|
||||
{
|
||||
entryBuffer = new char[fieldSize];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
entryData->Buffer = nullptr;
|
||||
abort = true;
|
||||
break;
|
||||
}
|
||||
entryData->Buffer = entryBuffer;
|
||||
fread(entryBuffer, 1, fieldSize, fileHandle);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
TPinballTable* pb::MainTable = nullptr;
|
||||
DatFile* pb::record_table = nullptr;
|
||||
int pb::time_ticks = 0, pb::demo_mode = 0, pb::game_mode = 2;
|
||||
float pb::mode_countdown_, pb::time_now = 0, pb::time_next = 0, pb::ball_speed_limit, pb::time_ticks_remainder = 0;
|
||||
int pb::time_ticks = 0, pb::demo_mode = 0, pb::game_mode = 2, pb::mode_countdown_;
|
||||
float pb::time_now = 0, pb::time_next = 0, pb::ball_speed_limit, pb::time_ticks_remainder = 0;
|
||||
high_score_struct pb::highscore_table[5];
|
||||
bool pb::FullTiltMode = false, pb::cheat_mode = false;
|
||||
|
||||
|
@ -169,7 +169,7 @@ void pb::mode_change(int mode)
|
|||
case 4:
|
||||
winmain::LaunchBallEnabled = false;
|
||||
winmain::HighScoresEnabled = false;
|
||||
mode_countdown_ = 5000.f;
|
||||
mode_countdown_ = 5000;
|
||||
break;
|
||||
}
|
||||
game_mode = mode;
|
||||
|
@ -399,7 +399,7 @@ void pb::InputDown(GameInput input)
|
|||
|
||||
if (game_mode != 1)
|
||||
{
|
||||
mode_countdown(-1.f);
|
||||
mode_countdown(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ void pb::InputDown(GameInput input)
|
|||
}
|
||||
}
|
||||
|
||||
int pb::mode_countdown(float time)
|
||||
int pb::mode_countdown(int time)
|
||||
{
|
||||
if (!game_mode || game_mode <= 0)
|
||||
return 1;
|
||||
|
@ -494,13 +494,13 @@ int pb::mode_countdown(float time)
|
|||
if (game_mode == 3)
|
||||
{
|
||||
mode_countdown_ -= time;
|
||||
if (mode_countdown_ < 0.f || time < 0.f)
|
||||
if (mode_countdown_ < 0 || time < 0)
|
||||
mode_change(4);
|
||||
}
|
||||
else if (game_mode == 4)
|
||||
{
|
||||
mode_countdown_ -= time;
|
||||
if (mode_countdown_ < 0.f || time < 0.f)
|
||||
if (mode_countdown_ < 0 || time < 0)
|
||||
mode_change(1);
|
||||
}
|
||||
return 1;
|
||||
|
@ -517,6 +517,7 @@ void pb::end_game()
|
|||
{
|
||||
int scores[4]{};
|
||||
int scoreIndex[4]{};
|
||||
char String1[200];
|
||||
|
||||
mode_change(2);
|
||||
int playerCount = MainTable->PlayerCount;
|
||||
|
@ -531,7 +532,7 @@ void pb::end_game()
|
|||
|
||||
for (auto i = 0; i < playerCount; ++i)
|
||||
{
|
||||
for (auto j = i+1; j < playerCount; ++j)
|
||||
for (auto j = i; j < playerCount; ++j)
|
||||
{
|
||||
if (scores[j] > scores[i])
|
||||
{
|
||||
|
@ -553,7 +554,6 @@ void pb::end_game()
|
|||
int position = high_score::get_score_position(highscore_table, scores[i]);
|
||||
if (position >= 0)
|
||||
{
|
||||
char String1[200];
|
||||
strncpy(String1, pinball::get_rc_string(scoreIndex[i] + 26, 0), sizeof String1 - 1);
|
||||
high_score::show_and_set_high_score_dialog(highscore_table, scores[i], position, String1);
|
||||
}
|
||||
|
@ -593,6 +593,9 @@ bool pb::chk_highscore()
|
|||
|
||||
float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
||||
{
|
||||
ray_type ray{};
|
||||
vector_type positionMod{};
|
||||
|
||||
if (ball->ActiveFlag && !ball->CollisionComp)
|
||||
{
|
||||
if (ball_speed_limit < ball->Speed)
|
||||
|
@ -603,7 +606,6 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
|||
ball->RayMaxDistance = maxDistance;
|
||||
ball->TimeNow = timeNow;
|
||||
|
||||
ray_type ray{};
|
||||
ray.Origin.X = ball->Position.X;
|
||||
ray.Origin.Y = ball->Position.Y;
|
||||
ray.Origin.Z = ball->Position.Z;
|
||||
|
@ -623,7 +625,6 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
|
|||
{
|
||||
maxDistance = timeDelta * ball->Speed;
|
||||
ball->RayMaxDistance = maxDistance;
|
||||
vector_type positionMod{};
|
||||
positionMod.X = maxDistance * ball->Acceleration.X;
|
||||
positionMod.Y = maxDistance * ball->Acceleration.Y;
|
||||
positionMod.Z = 0.0;
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
static void loose_focus();
|
||||
static void InputUp(GameInput input);
|
||||
static void InputDown(GameInput input);
|
||||
static int mode_countdown(float time);
|
||||
static int mode_countdown(int time);
|
||||
static void launch_ball();
|
||||
static void end_game();
|
||||
static void high_scores();
|
||||
|
@ -66,8 +66,7 @@ public:
|
|||
static float collide(float timeNow, float timeDelta, TBall* ball);
|
||||
static void PushCheat(const std::string& cheat);
|
||||
private:
|
||||
static int demo_mode;
|
||||
static float mode_countdown_;
|
||||
static int demo_mode, mode_countdown_;
|
||||
|
||||
static bool AnyBindingMatchesInput(GameInput (&options)[3], GameInput key);
|
||||
};
|
||||
|
|
|
@ -142,15 +142,9 @@ void render::sprite_modified(render_sprite_type_struct* sprite)
|
|||
render_sprite_type_struct* render::create_sprite(VisualTypes visualType, gdrv_bitmap8* bmp, zmap_header_type* zMap,
|
||||
int xPosition, int yPosition, rectangle_type* rect)
|
||||
{
|
||||
render_sprite_type_struct* sprite;
|
||||
try
|
||||
{
|
||||
sprite = new render_sprite_type_struct();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
auto sprite = new render_sprite_type_struct();
|
||||
if (!sprite)
|
||||
return nullptr;
|
||||
}
|
||||
sprite->BmpRect.YPosition = yPosition;
|
||||
sprite->BmpRect.XPosition = xPosition;
|
||||
sprite->Bmp = bmp;
|
||||
|
@ -426,7 +420,7 @@ void render::build_occlude_list()
|
|||
}
|
||||
}
|
||||
|
||||
if (mainSprite->Bmp && spriteArr->size() < 2)
|
||||
if (!mainSprite->UnknownFlag && mainSprite->Bmp && spriteArr->size() < 2)
|
||||
spriteArr->clear();
|
||||
if (!spriteArr->empty())
|
||||
{
|
||||
|
|
|
@ -18,15 +18,9 @@ int score::init()
|
|||
|
||||
scoreStruct* score::create(LPCSTR fieldName, gdrv_bitmap8* renderBgBmp)
|
||||
{
|
||||
scoreStruct* score;
|
||||
try
|
||||
{
|
||||
score = new scoreStruct();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
auto score = new scoreStruct();
|
||||
if (!score)
|
||||
return nullptr;
|
||||
}
|
||||
score->Score = -9999;
|
||||
score->BackgroundBmp = renderBgBmp;
|
||||
|
||||
|
|
|
@ -12,17 +12,10 @@ timer_struct* timer::TimerBuffer;
|
|||
|
||||
int timer::init(int count)
|
||||
{
|
||||
timer_struct* buf;
|
||||
try
|
||||
{
|
||||
buf = new timer_struct[count];
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
TimerBuffer = nullptr;
|
||||
return 1;
|
||||
}
|
||||
auto buf = new timer_struct[count];
|
||||
TimerBuffer = buf;
|
||||
if (!buf)
|
||||
return 1;
|
||||
Count = 0;
|
||||
MaxCount = count;
|
||||
SetCount = 1;
|
||||
|
|
|
@ -19,7 +19,7 @@ int winmain::bQuit = 0;
|
|||
int winmain::activated;
|
||||
int winmain::DispFrameRate = 0;
|
||||
int winmain::DispGRhistory = 0;
|
||||
int winmain::single_step = 0; //!! is constant
|
||||
int winmain::single_step = 0;
|
||||
int winmain::has_focus = 1;
|
||||
int winmain::last_mouse_x;
|
||||
int winmain::last_mouse_y;
|
||||
|
@ -180,7 +180,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||
if (!gfr_display)
|
||||
{
|
||||
auto plt = static_cast<ColorRgba*>(malloc(1024u));
|
||||
auto pltPtr = &plt[10]; // first 10 entries are system colors hardcoded in display_palette()
|
||||
auto pltPtr = &plt[10];
|
||||
for (int i1 = 0, i2 = 0; i1 < 256 - 10; ++i1, i2 += 8)
|
||||
{
|
||||
unsigned char blue = i2, redGreen = i2;
|
||||
|
@ -215,8 +215,8 @@ int winmain::WinMain(LPCSTR lpCmdLine)
|
|||
int x, y, w, h;
|
||||
SDL_GetMouseState(&x, &y);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
float dx = static_cast<float>(last_mouse_x - x) / static_cast<float>(w);
|
||||
float dy = static_cast<float>(y - last_mouse_y) / static_cast<float>(h);
|
||||
float dx = (last_mouse_x - x) / static_cast<float>(w);
|
||||
float dy = (y - last_mouse_y) / static_cast<float>(h);
|
||||
pb::ballset(dx, dy);
|
||||
|
||||
SDL_WarpMouseInWindow(window, last_mouse_x, last_mouse_y);
|
||||
|
|
Loading…
Reference in New Issue