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

Cheats: flipped literals, made some toggle, added GUI.

This commit is contained in:
Muzychenko Andrey 2021-10-05 16:48:13 +03:00
parent 167a2c2bd1
commit 8c4f38c0af
5 changed files with 55 additions and 35 deletions

View File

@ -29,8 +29,6 @@
#include "TWall.h"
#include "TTextBox.h"
int control::pbctrl_state;
int control_bump_scores1[] = {500, 1000, 1500, 2000};
int control_roll_scores1[] = {2000};
int control_bump_scores2[] = {1500, 2500, 3500, 4500};
@ -529,7 +527,8 @@ component_tag_base* control::simple_components[142]
&control_soundwave7_tag
};
int control::table_unlimited_balls, control::waiting_deployment_flag;
int control::waiting_deployment_flag;
bool control::table_unlimited_balls = false;
int control::extraball_light_flag;
int control::RankRcArray[9] = {84, 85, 86, 87, 88, 89, 90, 91, 92};
int control::MissionRcArray[17] = {60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76};
@ -638,9 +637,11 @@ void control::handler(int code, TPinballComponent* cmp)
MissionControl(code, cmp);
}
void control::pbctrl_bdoor_controller(int key)
void control::pbctrl_bdoor_controller(char key)
{
static char buffer[11 + 1]{};
// Buffer large enough for longest cheat + null
static char cheatBuffer[11 + 1]{};
static char* bufferEnd = &cheatBuffer[11];
static const char* quotes[8]
{
"Hey, is that a screen saver?",
@ -653,43 +654,36 @@ void control::pbctrl_bdoor_controller(int key)
"World's most expensive flippers"
};
if (control_lite198_tag.Component->MessageField || !key)
{
return;
}
// Original allowed to enter cheats only before the first launch.
std::memmove(&cheatBuffer[0], &cheatBuffer[1], 10);
cheatBuffer[10] = key;
std::memmove(&buffer[1], &buffer[0], 10);
buffer[0] = static_cast<char>(key);
if (strncmp(buffer, "tset neddih", 11) == 0)
if (strcmp(bufferEnd - 11, "hidden test") == 0)
{
pb::cheat_mode = 1;
pb::cheat_mode ^= true;
}
else if (strncmp(buffer, "xamg", 4) == 0)
else if (strcmp(bufferEnd - 4, "gmax") == 0)
{
GravityWellKickoutControl(64, nullptr);
}
else if (strncmp(buffer, "xam1", 4) == 0)
else if (strcmp(bufferEnd - 4, "1max") == 0)
{
table_add_extra_ball(2.0);
}
else if (strncmp(buffer, "xamb", 4) == 0)
else if (strcmp(bufferEnd - 4, "bmax") == 0)
{
table_unlimited_balls = 1;
table_unlimited_balls ^= true;
}
else if (strncmp(buffer, "xamr", 4) == 0)
else if (strcmp(bufferEnd - 4, "rmax") == 0)
{
cheat_bump_rank();
}
else if (strncmp(buffer, "etouq", 5) == 0)
else if (pb::FullTiltMode && strcmp(bufferEnd - 5, "quote") == 0)
{
// A sad developer easter egg type 'cheat' from Full Tilt
if (pb::FullTiltMode)
{
float time = 0;
for (auto quote : quotes)
control_mission_text_box_tag.Component->Display(quote, time += 3);
}
float time = 0;
for (auto quote : quotes)
control_mission_text_box_tag.Component->Display(quote, time += 3);
return;
}
else
@ -2200,7 +2194,7 @@ void control::PlungerControl(int code, TPinballComponent* caller)
}
else if (code == 1016)
{
table_unlimited_balls = 0;
table_unlimited_balls = false;
if (!control_middle_circle_tag.Component->Message(37, 0.0))
control_middle_circle_tag.Component->Message(32, 0.0);
if (!light_on(&control_lite200_tag))
@ -2499,7 +2493,7 @@ void control::table_control_handler(int code)
{
if (code == 1011)
{
table_unlimited_balls = 0;
table_unlimited_balls = false;
control_lite77_tag.Component->Message(7, 0.0);
}
}

View File

@ -65,7 +65,8 @@ public:
static TPinballTable* TableG;
static component_info score_components[88];
static component_tag_base* simple_components[142];
static int table_unlimited_balls, waiting_deployment_flag;
static int waiting_deployment_flag;
static bool table_unlimited_balls;
static int RankRcArray[9], MissionRcArray[17], mission_select_scores[17];
static component_tag_base *wormhole_tag_array1[3], *wormhole_tag_array2[3], *wormhole_tag_array3[3];
@ -73,7 +74,7 @@ public:
static void ClearLinks();
static TPinballComponent* make_component_link(component_tag_base* tag);
static void handler(int code, TPinballComponent* cmp);
static void pbctrl_bdoor_controller(int key);
static void pbctrl_bdoor_controller(char key);
static void table_add_extra_ball(float count);
static void table_set_bonus_hold();
static void table_set_bonus();
@ -183,6 +184,5 @@ public:
static void UnselectMissionController(int code, TPinballComponent* caller);
static void WaitingDeploymentController(int code, TPinballComponent* caller);
private:
static int pbctrl_state;
static int extraball_light_flag;
};

View File

@ -29,10 +29,10 @@
TPinballTable* pb::MainTable = nullptr;
DatFile* pb::record_table = nullptr;
int pb::time_ticks = 0, pb::demo_mode = 0, pb::cheat_mode = 0, pb::game_mode = 2, pb::mode_countdown_;
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;
bool pb::FullTiltMode = false, pb::cheat_mode = false;
int pb::init()
@ -399,7 +399,7 @@ void pb::keydown(int key)
mode_countdown(-1);
return;
}
control::pbctrl_bdoor_controller(key);
control::pbctrl_bdoor_controller(static_cast<char>(key));
if (key == options::Options.Key.LeftFlipper)
{
MainTable->Message(1000, time_now);
@ -640,3 +640,9 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
}
return timeDelta;
}
void pb::PushCheat(const std::string& cheat)
{
for (auto ch : cheat)
control::pbctrl_bdoor_controller(ch);
}

View File

@ -34,7 +34,8 @@ class pb
public:
static int time_ticks;
static float ball_speed_limit, time_now, time_next, time_ticks_remainder;
static int cheat_mode, game_mode;
static int game_mode;
static bool cheat_mode;
static DatFile* record_table;
static TPinballTable* MainTable;
static high_score_struct highscore_table[5];
@ -62,6 +63,7 @@ public:
static void tilt_no_more();
static bool chk_highscore();
static float collide(float timeNow, float timeDelta, TBall* ball);
static void PushCheat(const std::string& cheat);
private:
static int demo_mode, mode_countdown_;
};

View File

@ -1,6 +1,7 @@
#include "pch.h"
#include "winmain.h"
#include "control.h"
#include "fullscrn.h"
#include "midi.h"
#include "pinball.h"
@ -505,6 +506,23 @@ void winmain::RenderUi()
pause();
ShowSpriteViewer ^= true;
}
if (ImGui::BeginMenu("Cheats"))
{
if (ImGui::MenuItem("hidden test", nullptr, pb::cheat_mode))
pb::PushCheat("hidden test");
if (ImGui::MenuItem("1max"))
pb::PushCheat("1max");
if (ImGui::MenuItem("bmax", nullptr, control::table_unlimited_balls))
pb::PushCheat("bmax");
if (ImGui::MenuItem("gmax"))
pb::PushCheat("gmax");
if (ImGui::MenuItem("rmax"))
pb::PushCheat("rmax");
if (pb::FullTiltMode && ImGui::MenuItem("quote"))
pb::PushCheat("quote");
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::MenuItem("About Pinball"))