1
0
Fork 0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-12-18 10:37:53 +01:00

winmain: converted int to bool.

Cleaned up some of the PR changes.
This commit is contained in:
Muzychenko Andrey 2021-10-23 09:02:51 +03:00
parent 57af3af800
commit 5cd01807b2
6 changed files with 39 additions and 48 deletions

View file

@ -39,23 +39,16 @@ 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);
int index = 0; for (auto index = 0; index < visualCount; ++index)
if (visualCount > 0)
{ {
auto visualZPtr = VisualZArray; loader::query_visual(groupIndex, index, &visual);
do if (ListBitmap)
{ ListBitmap->push_back(visual.Bitmap);
loader::query_visual(groupIndex, index, &visual); auto visVec = reinterpret_cast<vector_type*>(loader::query_float_attribute(groupIndex, index, 501));
if (ListBitmap) auto zDepth = proj::z_distance(visVec);
ListBitmap->push_back(visual.Bitmap); VisualZArray[index] = zDepth;
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

@ -81,15 +81,11 @@ 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;
/*Full Tilt hack - ball doesn't delay at the ramp hole*/
if (pb::FullTiltMode) // Ramp hole has no delay in FT.
{ auto captureTime = pb::FullTiltMode ? 0 : 0.5f;
BallCapturedSecondStage = 1; Timer = timer::set(captureTime, this, TimerExpired);
}
else
{
Timer = timer::set(0.5f, this, TimerExpired);
}
if (!PinballTable->TiltLockFlag) if (!PinballTable->TiltLockFlag)
{ {
loader::play_sound(HardHitSoundId); loader::play_sound(HardHitSoundId);

View file

@ -94,7 +94,7 @@ int TPlunger::Message(int code, float value)
if (PullbackTimer_) if (PullbackTimer_)
timer::kill(PullbackTimer_); timer::kill(PullbackTimer_);
PullbackTimer_ = 0; PullbackTimer_ = 0;
if (code == 1005) // intended that this can never be reached (same as original) if (code == 1005)
loader::play_sound(SoundIndexP2); loader::play_sound(SoundIndexP2);
auto bmp = ListBitmap->at(0); auto bmp = ListBitmap->at(0);
auto zMap = ListZMap->at(0); auto zMap = ListZMap->at(0);

View file

@ -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 = (winmain::single_step == 0) ? 1 : 0; winmain::single_step ^= true;
pinball::InfoTextBox->Clear(); pinball::InfoTextBox->Clear();
pinball::MissTextBox->Clear(); pinball::MissTextBox->Clear();
if (winmain::single_step) if (winmain::single_step)
@ -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 + 1; j < playerCount; ++j)
{ {
if (scores[j] > scores[i]) if (scores[j] > scores[i])
{ {

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;
int winmain::bQuit = 0; bool winmain::bQuit = false;
int winmain::activated; bool winmain::activated = false;
int winmain::DispFrameRate = 0; int winmain::DispFrameRate = 0;
int winmain::DispGRhistory = 0; int winmain::DispGRhistory = 0;
int winmain::single_step = 0; bool winmain::single_step = false;
int winmain::has_focus = 1; bool winmain::has_focus = true;
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;
int winmain::no_time_loss; bool winmain::no_time_loss = false;
bool winmain::restart = false; bool winmain::restart = false;
@ -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) if (!single_step && !no_time_loss)
{ {
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,6 +243,7 @@ int winmain::WinMain(LPCSTR lpCmdLine)
} }
updateCounter++; updateCounter++;
} }
no_time_loss = false;
if (UpdateToFrameCounter >= UpdateToFrameRatio) if (UpdateToFrameCounter >= UpdateToFrameRatio)
{ {
@ -595,7 +596,7 @@ int winmain::event_handler(const SDL_Event* event)
{ {
case SDL_QUIT: case SDL_QUIT:
end_pause(); end_pause();
bQuit = 1; bQuit = true;
fullscrn::shutdown(); fullscrn::shutdown();
return_value = 0; return_value = 0;
return 0; return 0;
@ -655,9 +656,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 = (single_step == 0) ? 1 : 0; single_step ^= true;
if (single_step == 0) if (!single_step)
no_time_loss = 1; no_time_loss = true;
break; break;
default: default:
break; break;
@ -713,21 +714,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 = 1; activated = true;
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 = 1; no_time_loss = true;
has_focus = 1; has_focus = true;
break; break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_HIDDEN:
activated = 0; activated = false;
fullscrn::activate(0); fullscrn::activate(0);
Options.FullScreen = false; Options.FullScreen = false;
Sound::Deactivate(); Sound::Deactivate();
midi::music_stop(); midi::music_stop();
has_focus = 0; has_focus = false;
pb::loose_focus(); pb::loose_focus();
break; break;
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
@ -846,7 +847,7 @@ void winmain::end_pause()
if (single_step) if (single_step)
{ {
pb::pause_continue(); pb::pause_continue();
no_time_loss = 1; no_time_loss = true;
} }
} }
@ -859,7 +860,7 @@ void winmain::new_game()
void winmain::pause() void winmain::pause()
{ {
pb::pause_continue(); pb::pause_continue();
no_time_loss = 1; no_time_loss = true;
} }
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 int single_step; static bool 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,8 +62,9 @@ public:
static bool RestartRequested() { return restart; } static bool RestartRequested() { return restart; }
static void UpdateFrameRate(); static void UpdateFrameRate();
private: private:
static int return_value, bQuit, DispFrameRate, DispGRhistory, activated; static int return_value, DispFrameRate, DispGRhistory;
static int has_focus, mouse_down, last_mouse_x, last_mouse_y, no_time_loss; static int mouse_down, last_mouse_x, last_mouse_y;
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;