1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-24 18:00:18 +01:00

Compare commits

..

No commits in common. "5cd01807b2737103845c4977ced36857159e3b1f" and "0076f8947c5e8642b30edc058418cbc6b69a1434" have entirely different histories.

16 changed files with 62 additions and 60 deletions

View file

@ -39,16 +39,23 @@ TBall::TBall(TPinballTable* table) : TPinballComponent(table, -1, false)
auto groupIndex = loader::query_handle(ballGroupName); auto groupIndex = loader::query_handle(ballGroupName);
Offset = *loader::query_float_attribute(groupIndex, 0, 500); Offset = *loader::query_float_attribute(groupIndex, 0, 500);
auto visualCount = loader::query_visual_states(groupIndex); auto visualCount = loader::query_visual_states(groupIndex);
for (auto index = 0; index < visualCount; ++index) auto index = 0;
if (visualCount > 0)
{ {
loader::query_visual(groupIndex, index, &visual); auto visualZPtr = VisualZArray;
if (ListBitmap) do
ListBitmap->push_back(visual.Bitmap); {
auto visVec = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, index, 501)); loader::query_visual(groupIndex, index, &visual);
auto zDepth = proj::z_distance(visVec); if (ListBitmap)
VisualZArray[index] = zDepth; ListBitmap->push_back(visual.Bitmap);
auto visVec = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, index, 501));
auto zDepth = proj::z_distance(visVec);
++index;
*visualZPtr = zDepth;
++visualZPtr;
}
while (index < visualCount);
} }
RenderSprite = render::create_sprite(VisualTypes::Ball, nullptr, nullptr, 0, 0, nullptr); RenderSprite = render::create_sprite(VisualTypes::Ball, nullptr, nullptr, 0, 0, nullptr);
PinballTable->CollisionCompOffset = Offset; PinballTable->CollisionCompOffset = Offset;

View file

@ -65,7 +65,7 @@ TFlipper::~TFlipper()
int TFlipper::Message(int code, float value) 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; float timerTime;
int command = code; int command = code;

View file

@ -109,6 +109,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
{ {
if (FlipperFlag == 0) if (FlipperFlag == 0)
{ {
EdgeCollisionFlag = 0;
CollisionFlag1 = 0; CollisionFlag1 = 0;
CollisionFlag2 = 0; CollisionFlag2 = 0;
set_control_points(ogRay->TimeNow); set_control_points(ogRay->TimeNow);

View file

@ -81,11 +81,7 @@ void THole::Collision(TBall* ball, vector_type* nextPosition, vector_type* direc
ball->Position.X = Circle.Center.X; ball->Position.X = Circle.Center.X;
ball->Position.Y = Circle.Center.Y; ball->Position.Y = Circle.Center.Y;
ball->Acceleration.Z = 0.0; ball->Acceleration.Z = 0.0;
Timer = timer::set(0.5f, this, TimerExpired);
// Ramp hole has no delay in FT.
auto captureTime = pb::FullTiltMode ? 0 : 0.5f;
Timer = timer::set(captureTime, this, TimerExpired);
if (!PinballTable->TiltLockFlag) if (!PinballTable->TiltLockFlag)
{ {
loader::play_sound(HardHitSoundId); loader::play_sound(HardHitSoundId);

View file

@ -432,7 +432,7 @@ int TLightGroup::next_light_up()
{ {
for (auto index = 0u; index < List.size(); ++index) for (auto index = 0u; index < List.size(); ++index)
{ {
if (!List[index]->BmpIndex1) if (!List.at(index)->BmpIndex1)
return static_cast<int>(index); return static_cast<int>(index);
} }
return -1; return -1;

View file

@ -368,7 +368,7 @@ int TPinballTable::Message(int code, float value)
LightGroup->Message(34, 0.0); LightGroup->Message(34, 0.0);
LightGroup->Message(20, 0.0); LightGroup->Message(20, 0.0);
Plunger->Message(1016, 0.0); Plunger->Message(1016, 0.0);
if (Demo && Demo->ActiveFlag) if (Demo->ActiveFlag)
rc_text = pinball::get_rc_string(30, 0); rc_text = pinball::get_rc_string(30, 0);
else else
rc_text = pinball::get_rc_string(26, 0); rc_text = pinball::get_rc_string(26, 0);

View file

@ -37,7 +37,7 @@ void TPlunger::Collision(TBall* ball, vector_type* nextPosition, vector_type* di
{ {
if (PinballTable->TiltLockFlag) if (PinballTable->TiltLockFlag)
Message(1017, 0.0); Message(1017, 0.0);
coef = RandFloat() * Boost * 0.1f + Boost; // it is intended that the passed in coef is never used! coef = RandFloat() * Boost * 0.1f + Boost;
maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, coef); maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, coef);
} }

View file

@ -6,7 +6,7 @@
#include "TBall.h" #include "TBall.h"
#include "TPinballTable.h" #include "TPinballTable.h"
TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, true) TTripwire::TTripwire(TPinballTable* table, int groupIndex) : TRollover(table, groupIndex, 1)
{ {
} }

View file

@ -3923,7 +3923,9 @@ void control::SelectMissionController(int code, TPinballComponent* caller)
if (light_on(&control_lite319_tag)) if (light_on(&control_lite319_tag))
control_lite319_tag.Component->Message(20, 0.0); control_lite319_tag.Component->Message(20, 0.0);
if (!light_on(&control_lite317_tag)) if (!light_on(&control_lite317_tag))
{
control_lite317_tag.Component->Message(7, 0.0); control_lite317_tag.Component->Message(7, 0.0);
}
} }
else else
{ {
@ -4156,7 +4158,6 @@ void control::TimeWarpPartTwoController(int code, TPinballComponent* caller)
control_lite317_tag.Component->Message(20, 0.0); control_lite317_tag.Component->Message(20, 0.0);
control_lite198_tag.Component->MessageField = 1; control_lite198_tag.Component->MessageField = 1;
MissionControl(66, nullptr); MissionControl(66, nullptr);
// SpecialAddScore sets the score dirty flag. So next tick it will be redrawn.
} }
void control::UnselectMissionController(int code, TPinballComponent* caller) void control::UnselectMissionController(int code, TPinballComponent* caller)

View file

@ -299,7 +299,7 @@ float maths::basic_collision(TBall* ball, vector_type* nextPosition, vector_type
return projSpeed; 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); return (vec1.Y - vec2.Y) * (vec1.Y - vec2.Y) + (vec1.X - vec2.X) * (vec1.X - vec2.X);
} }

View file

@ -87,7 +87,7 @@ public:
static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity, static float basic_collision(TBall* ball, vector_type* nextPosition, vector_type* direction, float elasticity,
float smoothness, float smoothness,
float threshold, float boost); 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 float DotProduct(vector_type* vec1, vector_type* vec2);
static void vswap(vector_type* vec1, vector_type* vec2); static void vswap(vector_type* vec1, vector_type* vec2);
static float Distance(vector_type* vec1, vector_type* vec2); static float Distance(vector_type* vec1, vector_type* vec2);

View file

@ -29,8 +29,8 @@
TPinballTable* pb::MainTable = nullptr; TPinballTable* pb::MainTable = nullptr;
DatFile* pb::record_table = nullptr; DatFile* pb::record_table = nullptr;
int pb::time_ticks = 0, pb::demo_mode = 0, pb::game_mode = 2; int pb::time_ticks = 0, pb::demo_mode = 0, pb::game_mode = 2, pb::mode_countdown_;
float pb::mode_countdown_, pb::time_now = 0, pb::time_next = 0, pb::ball_speed_limit, pb::time_ticks_remainder = 0; 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]; high_score_struct pb::highscore_table[5];
bool pb::FullTiltMode = false, pb::cheat_mode = false; bool pb::FullTiltMode = false, pb::cheat_mode = false;
@ -169,7 +169,7 @@ void pb::mode_change(int mode)
case 4: case 4:
winmain::LaunchBallEnabled = false; winmain::LaunchBallEnabled = false;
winmain::HighScoresEnabled = false; winmain::HighScoresEnabled = false;
mode_countdown_ = 5000.f; mode_countdown_ = 5000;
break; break;
} }
game_mode = mode; game_mode = mode;
@ -215,7 +215,7 @@ void pb::frame(float dtMilliSec)
{ {
if (dtMilliSec > 100) if (dtMilliSec > 100)
dtMilliSec = 100; dtMilliSec = 100;
if (dtMilliSec <= 0) if (dtMilliSec < 0)
return; return;
float dtSec = dtMilliSec * 0.001f; float dtSec = dtMilliSec * 0.001f;
if (!mode_countdown(dtMilliSec)) if (!mode_countdown(dtMilliSec))
@ -317,7 +317,7 @@ void pb::window_size(int* width, int* height)
void pb::pause_continue() void pb::pause_continue()
{ {
winmain::single_step ^= true; winmain::single_step = winmain::single_step == 0;
pinball::InfoTextBox->Clear(); pinball::InfoTextBox->Clear();
pinball::MissTextBox->Clear(); pinball::MissTextBox->Clear();
if (winmain::single_step) if (winmain::single_step)
@ -399,7 +399,7 @@ void pb::InputDown(GameInput input)
if (game_mode != 1) if (game_mode != 1)
{ {
mode_countdown(-1.f); mode_countdown(-1);
return; 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) if (!game_mode || game_mode <= 0)
return 1; return 1;
@ -494,13 +494,13 @@ int pb::mode_countdown(float time)
if (game_mode == 3) if (game_mode == 3)
{ {
mode_countdown_ -= time; mode_countdown_ -= time;
if (mode_countdown_ < 0.f || time < 0.f) if (mode_countdown_ < 0 || time < 0)
mode_change(4); mode_change(4);
} }
else if (game_mode == 4) else if (game_mode == 4)
{ {
mode_countdown_ -= time; mode_countdown_ -= time;
if (mode_countdown_ < 0.f || time < 0.f) if (mode_countdown_ < 0 || time < 0)
mode_change(1); mode_change(1);
} }
return 1; return 1;
@ -532,7 +532,7 @@ void pb::end_game()
for (auto i = 0; i < playerCount; ++i) 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]) if (scores[j] > scores[i])
{ {

View file

@ -57,7 +57,7 @@ public:
static void loose_focus(); static void loose_focus();
static void InputUp(GameInput input); static void InputUp(GameInput input);
static void InputDown(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 launch_ball();
static void end_game(); static void end_game();
static void high_scores(); static void high_scores();
@ -66,8 +66,7 @@ public:
static float collide(float timeNow, float timeDelta, TBall* ball); static float collide(float timeNow, float timeDelta, TBall* ball);
static void PushCheat(const std::string& cheat); static void PushCheat(const std::string& cheat);
private: private:
static int demo_mode; static int demo_mode, mode_countdown_;
static float mode_countdown_;
static bool AnyBindingMatchesInput(GameInput (&options)[3], GameInput key); static bool AnyBindingMatchesInput(GameInput (&options)[3], GameInput key);
}; };

View file

@ -420,7 +420,7 @@ void render::build_occlude_list()
} }
} }
if (mainSprite->Bmp && spriteArr->size() < 2) if (!mainSprite->UnknownFlag && mainSprite->Bmp && spriteArr->size() < 2)
spriteArr->clear(); spriteArr->clear();
if (!spriteArr->empty()) if (!spriteArr->empty())
{ {

View file

@ -15,16 +15,16 @@ SDL_Renderer* winmain::Renderer = nullptr;
ImGuiIO* winmain::ImIO = nullptr; ImGuiIO* winmain::ImIO = nullptr;
int winmain::return_value = 0; int winmain::return_value = 0;
bool winmain::bQuit = false; int winmain::bQuit = 0;
bool winmain::activated = false; int winmain::activated;
int winmain::DispFrameRate = 0; int winmain::DispFrameRate = 0;
int winmain::DispGRhistory = 0; int winmain::DispGRhistory = 0;
bool winmain::single_step = false; int winmain::single_step = 0;
bool winmain::has_focus = true; int winmain::has_focus = 1;
int winmain::last_mouse_x; int winmain::last_mouse_x;
int winmain::last_mouse_y; int winmain::last_mouse_y;
int winmain::mouse_down; int winmain::mouse_down;
bool winmain::no_time_loss = false; int winmain::no_time_loss;
bool winmain::restart = false; bool winmain::restart = false;
@ -180,7 +180,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
if (!gfr_display) if (!gfr_display)
{ {
auto plt = static_cast<ColorRgba*>(malloc(1024u)); 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) for (int i1 = 0, i2 = 0; i1 < 256 - 10; ++i1, i2 += 8)
{ {
unsigned char blue = i2, redGreen = i2; unsigned char blue = i2, redGreen = i2;
@ -215,8 +215,8 @@ int winmain::WinMain(LPCSTR lpCmdLine)
int x, y, w, h; int x, y, w, h;
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
float dx = static_cast<float>(last_mouse_x - x) / static_cast<float>(w); float dx = (last_mouse_x - x) / static_cast<float>(w);
float dy = static_cast<float>(y - last_mouse_y) / static_cast<float>(h); float dy = (y - last_mouse_y) / static_cast<float>(h);
pb::ballset(dx, dy); pb::ballset(dx, dy);
SDL_WarpMouseInWindow(window, last_mouse_x, last_mouse_y); SDL_WarpMouseInWindow(window, last_mouse_x, last_mouse_y);
@ -225,7 +225,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
//last_mouse_x = x; //last_mouse_x = x;
//last_mouse_y = y; //last_mouse_y = y;
} }
if (!single_step && !no_time_loss) if (!single_step)
{ {
auto dt = static_cast<float>(frameDuration.count()); auto dt = static_cast<float>(frameDuration.count());
auto dtWhole = static_cast<int>(std::round(dt)); auto dtWhole = static_cast<int>(std::round(dt));
@ -243,7 +243,6 @@ int winmain::WinMain(LPCSTR lpCmdLine)
} }
updateCounter++; updateCounter++;
} }
no_time_loss = false;
if (UpdateToFrameCounter >= UpdateToFrameRatio) if (UpdateToFrameCounter >= UpdateToFrameRatio)
{ {
@ -596,7 +595,7 @@ int winmain::event_handler(const SDL_Event* event)
{ {
case SDL_QUIT: case SDL_QUIT:
end_pause(); end_pause();
bQuit = true; bQuit = 1;
fullscrn::shutdown(); fullscrn::shutdown();
return_value = 0; return_value = 0;
return 0; return 0;
@ -656,9 +655,9 @@ int winmain::event_handler(const SDL_Event* event)
pb::frame(10); pb::frame(10);
break; break;
case SDLK_F10: case SDLK_F10:
single_step ^= true; single_step = single_step == 0;
if (!single_step) if (single_step == 0)
no_time_loss = true; no_time_loss = 1;
break; break;
default: default:
break; break;
@ -714,21 +713,21 @@ int winmain::event_handler(const SDL_Event* event)
case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_FOCUS_GAINED:
case SDL_WINDOWEVENT_TAKE_FOCUS: case SDL_WINDOWEVENT_TAKE_FOCUS:
case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_SHOWN:
activated = true; activated = 1;
Sound::Activate(); Sound::Activate();
if (Options.Music && !single_step) if (Options.Music && !single_step)
midi::play_pb_theme(); midi::play_pb_theme();
no_time_loss = true; no_time_loss = 1;
has_focus = true; has_focus = 1;
break; break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_HIDDEN:
activated = false; activated = 0;
fullscrn::activate(0); fullscrn::activate(0);
Options.FullScreen = false; Options.FullScreen = false;
Sound::Deactivate(); Sound::Deactivate();
midi::music_stop(); midi::music_stop();
has_focus = false; has_focus = 0;
pb::loose_focus(); pb::loose_focus();
break; break;
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
@ -847,7 +846,7 @@ void winmain::end_pause()
if (single_step) if (single_step)
{ {
pb::pause_continue(); pb::pause_continue();
no_time_loss = true; no_time_loss = 1;
} }
} }
@ -860,7 +859,7 @@ void winmain::new_game()
void winmain::pause() void winmain::pause()
{ {
pb::pause_continue(); pb::pause_continue();
no_time_loss = true; no_time_loss = 1;
} }
void winmain::Restart() void winmain::Restart()

View file

@ -41,7 +41,7 @@ class winmain
public: public:
static std::string DatFileName; static std::string DatFileName;
static bool single_step; static int single_step;
static SDL_Window* MainWindow; static SDL_Window* MainWindow;
static SDL_Renderer* Renderer; static SDL_Renderer* Renderer;
static ImGuiIO* ImIO; static ImGuiIO* ImIO;
@ -62,9 +62,8 @@ public:
static bool RestartRequested() { return restart; } static bool RestartRequested() { return restart; }
static void UpdateFrameRate(); static void UpdateFrameRate();
private: private:
static int return_value, DispFrameRate, DispGRhistory; static int return_value, bQuit, DispFrameRate, DispGRhistory, activated;
static int mouse_down, last_mouse_x, last_mouse_y; static int has_focus, mouse_down, last_mouse_x, last_mouse_y, no_time_loss;
static bool no_time_loss, activated, bQuit, has_focus;
static gdrv_bitmap8* gfr_display; static gdrv_bitmap8* gfr_display;
static std::string FpsDetails; static std::string FpsDetails;
static bool restart; static bool restart;