Skip to content

Commit

Permalink
Replace int with enum
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Feb 25, 2024
1 parent 10c1a55 commit e57ebdd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions common/fractint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ long g_l_at_rad; // finite attractor radius
double g_f_at_rad; // finite attractor radius
int g_bit_shift; // fudgefactor

int g_bad_config = 0; // 'fractint.cfg' ok?
config_status g_bad_config{}; // 'fractint.cfg' ok?
bool g_has_inverse = false;
// note that integer grid is set when integerfractal && !invert;
// otherwise the floating point grid is set; never both at once
Expand Down Expand Up @@ -218,7 +218,7 @@ static void main_restart(int const argc, char const *const argv[], bool &stacked
g_save_dac = 0; // don't save the VGA DAC

#ifndef XFRACT
if (g_bad_config < 0) // fractint.cfg bad, no msg yet
if (g_bad_config == config_status::BAD_NO_MESSAGE)
{
bad_fractint_cfg_msg();
}
Expand Down
6 changes: 3 additions & 3 deletions common/miscovl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ int select_video_mode(int curmode)
{
// update fractint.cfg for new key assignments
if (modes_changed
&& g_bad_config == 0
&& g_bad_config == config_status::OK
&& stopmsg(STOPMSG_CANCEL | STOPMSG_NO_BUZZER | STOPMSG_INFO_ONLY,
"Save new function key assignments or cancel changes?") == 0)
{
Expand Down Expand Up @@ -2041,7 +2041,7 @@ int select_video_mode(int curmode)
}

// update fractint.cfg for new key assignments
if (modes_changed && g_bad_config == 0)
if (modes_changed && g_bad_config == config_status::OK)
{
update_fractint_cfg();
}
Expand Down Expand Up @@ -2089,7 +2089,7 @@ static int check_modekey(int curkey, int choice)
if ((curkey == '-' || curkey == '+')
&& (g_video_table[i].keynum == 0 || g_video_table[i].keynum >= 1084))
{
if (g_bad_config)
if (g_bad_config != config_status::OK)
{
stopmsg(STOPMSG_NONE, "Missing or bad FRACTINT.CFG file. Can't reassign keys.");
}
Expand Down
4 changes: 2 additions & 2 deletions common/realdos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ void load_fractint_config()
return;

bad_fractint_cfg:
g_bad_config = -1; // bad, no message issued yet
g_bad_config = config_status::BAD_NO_MESSAGE;
}

void bad_fractint_cfg_msg()
Expand All @@ -2078,7 +2078,7 @@ void bad_fractint_cfg_msg()
"File FRACTINT.CFG is missing or invalid.\n"
"See Hardware Support and Video Modes in the full documentation for help.\n"
"I will continue with only the built-in video modes available.");
g_bad_config = 1; // bad, message issued
g_bad_config = config_status::BAD_WITH_MESSAGE;
}

int check_vidmode_key(int option, int k)
Expand Down
9 changes: 8 additions & 1 deletion headers/id_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ enum class calc_status_value
COMPLETED = 4
};

enum class config_status
{
OK = 0,
BAD_WITH_MESSAGE = 1,
BAD_NO_MESSAGE = -1
};

enum class help_labels;

extern int g_adapter; // index into g_video_table[]
extern bool g_auto_browse;
extern int g_bad_config;
extern config_status g_bad_config;
extern int g_bit_shift;
extern int g_box_count;
extern std::string g_browse_mask;
Expand Down

0 comments on commit e57ebdd

Please sign in to comment.