Skip to content

Commit

Permalink
Refactor: Replace integral type with bool
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Dec 14, 2014
1 parent c1b6646 commit a429ab1
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 47 deletions.
8 changes: 4 additions & 4 deletions common/cmdfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ static void initvars_fractal() /* init vars affecting calculation */
closeprox = 0.01;
ismand = true; /* default formula mand/jul toggle */
#ifndef XFRACT
usr_floatflag = 0; /* turn off the float flag */
usr_floatflag = false; /* turn off the float flag */
#else
usr_floatflag = 1; /* turn on the float flag */
usr_floatflag = true; /* turn on the float flag */
#endif
finattract = false; /* disable finite attractor logic */
fractype = 0; /* initial type Set flag */
Expand Down Expand Up @@ -2254,9 +2254,9 @@ int cmdarg(char *curarg, int mode) /* process a single argument */
if (yesnoval[0] < 0)
goto badarg;
#ifndef XFRACT
usr_floatflag = (char)yesnoval[0];
usr_floatflag = yesnoval[0] != 0;
#else
usr_floatflag = 1; /* must use floating point */
usr_floatflag = true; /* must use floating point */
#endif
return 3;
}
Expand Down
16 changes: 8 additions & 8 deletions common/fracsubr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ void calcfracinit() /* initialize a *pile* of stuff for fractal calculation */
/* space req for grid is 2(xdots+ydots)*sizeof(long or double) */
/* space available in extraseg is 65536 Bytes */
long xytemp = xdots + ydots;
if (((usr_floatflag == 0) && (xytemp*sizeof(long) > 32768)) ||
((usr_floatflag == 1) && (xytemp*sizeof(double) > 32768)) ||
if ((!usr_floatflag && (xytemp*sizeof(long) > 32768)) ||
(usr_floatflag && (xytemp*sizeof(double) > 32768)) ||
debugflag == 3800)
{
use_grid = false;
floatflag = true;
usr_floatflag = 1;
usr_floatflag = true;
}
else
use_grid = true;
Expand Down Expand Up @@ -184,35 +184,35 @@ void calcfracinit() /* initialize a *pile* of stuff for fractal calculation */
fractype=MANDELFP;
curfractalspecific = &fractalspecific[MANDELFP];
fractal_floattobf();
usr_floatflag = 1;
usr_floatflag = true;
}
else if ((fractype==JULIA || fractype==JULIAFP) && debugflag==3200)
{
fractype=JULIAFP;
curfractalspecific = &fractalspecific[JULIAFP];
fractal_floattobf();
usr_floatflag = 1;
usr_floatflag = true;
}
else if ((fractype==LMANDELZPOWER || fractype==FPMANDELZPOWER) && debugflag==3200)
{
fractype=FPMANDELZPOWER;
curfractalspecific = &fractalspecific[FPMANDELZPOWER];
fractal_floattobf();
usr_floatflag = 1;
usr_floatflag = true;
}
else if ((fractype==LJULIAZPOWER || fractype==FPJULIAZPOWER) && debugflag==3200)
{
fractype=FPJULIAZPOWER;
curfractalspecific = &fractalspecific[FPJULIAZPOWER];
fractal_floattobf();
usr_floatflag = 1;
usr_floatflag = true;
}
else
free_bf_vars();
if (bf_math)
floatflag = true;
else
floatflag = usr_floatflag != 0;
floatflag = usr_floatflag;
if (calc_status == CALCSTAT_RESUMABLE) { /* on resume, ensure floatflag correct */
if (curfractalspecific->isinteger)
floatflag = false;
Expand Down
10 changes: 5 additions & 5 deletions common/fractint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int integerfractal; /* TRUE if fractal uses integer math */
char usr_stdcalcmode;
int usr_periodicitycheck;
long usr_distest;
char usr_floatflag;
bool usr_floatflag;

bool viewwindow = false; /* false for full screen, true for window */
float viewreduction; /* window auto-sizing */
Expand Down Expand Up @@ -397,7 +397,7 @@ int main(int argc, char **argv)
stacked = 0;
}
#ifdef XFRACT
usr_floatflag = 1;
usr_floatflag = true;
#endif
got_status = -1; /* for tab_display */

Expand Down Expand Up @@ -488,10 +488,10 @@ int main(int argc, char **argv)
goto imagestart;
}
if (kbdchar == 'f') { /* floating pt toggle */
if (usr_floatflag == 0)
usr_floatflag = 1;
if (!usr_floatflag)
usr_floatflag = true;
else
usr_floatflag = 0;
usr_floatflag = false;
goto imagestart;
}
if (kbdchar == 'i') { /* set 3d fractal parms */
Expand Down
24 changes: 12 additions & 12 deletions common/framain2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ int big_while_loop(bool *kbdmore, bool *stacked, bool resumeflag)
if (debugflag == 2224)
{
char msg[MSGLEN];
sprintf(msg, "floatflag=%d", usr_floatflag);
sprintf(msg, "floatflag=%d", usr_floatflag ? 1 : 0);
stopmsg(STOPMSG_NO_BUZZER, (char *)msg);
}
i = funny_glasses_call(gifview);
Expand Down Expand Up @@ -923,10 +923,10 @@ int main_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bool *stacke
driver_unstack_screen();
break;
case 'f': /* floating pt toggle */
if (usr_floatflag == 0)
usr_floatflag = 1;
if (!usr_floatflag)
usr_floatflag = true;
else if (stdcalcmode != 'o') /* don't go there */
usr_floatflag = 0;
usr_floatflag = false;
g_init_mode = g_adapter;
return IMAGESTART;
case 'i': /* 3d fractal parms */
Expand Down Expand Up @@ -1180,10 +1180,10 @@ int main_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bool *stacke
g_init_mode = g_adapter;
if (curfractalspecific->isinteger != 0 &&
curfractalspecific->tofloat != NOFRACTAL)
usr_floatflag = 0;
usr_floatflag = false;
if (curfractalspecific->isinteger == 0 &&
curfractalspecific->tofloat != NOFRACTAL)
usr_floatflag = 1;
usr_floatflag = true;
historyflag = true; /* avoid re-store parms due to rounding errs */
return IMAGESTART;
}
Expand Down Expand Up @@ -1527,10 +1527,10 @@ static int evolver_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bo
break;

case 'f': /* floating pt toggle */
if (usr_floatflag == 0)
usr_floatflag = 1;
if (!usr_floatflag)
usr_floatflag = true;
else if (stdcalcmode != 'o') /* don't go there */
usr_floatflag = 0;
usr_floatflag = false;
g_init_mode = g_adapter;
return IMAGESTART;
case '\\': /* return to prev image */
Expand All @@ -1550,10 +1550,10 @@ static int evolver_menu_switch(int *kbdchar, bool *frommandel, bool *kbdmore, bo
g_init_mode = g_adapter;
if (curfractalspecific->isinteger != 0 &&
curfractalspecific->tofloat != NOFRACTAL)
usr_floatflag = 0;
usr_floatflag = false;
if (curfractalspecific->isinteger == 0 &&
curfractalspecific->tofloat != NOFRACTAL)
usr_floatflag = 1;
usr_floatflag = true;
historyflag = true; /* avoid re-store parms due to rounding errs */
return IMAGESTART;
}
Expand Down Expand Up @@ -2433,7 +2433,7 @@ static void restore_history_info(int i)
if (keep_scrn_coords)
set_orbit_corners = true;
drawmode = last.drawmode;
usr_floatflag = (char)((curfractalspecific->isinteger) ? 0 : 1);
usr_floatflag = curfractalspecific->isinteger ? false : true;
memcpy(g_dac_box,last.dac,256*3);
memcpy(olddacbox,last.dac,256*3);
if (mapdacbox)
Expand Down
7 changes: 3 additions & 4 deletions common/line3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,6 @@ static void line3d_cleanup()
if (!debugflag && Targa_Overlay)
dir_remove(workdir, targa_temp);
}
usr_floatflag &= 1; /* strip second bit */
error = 0;
T_Safe = false;
}
Expand Down Expand Up @@ -2087,7 +2086,7 @@ static int first_time(int linelen, VECTOR v)
/* aspect ratio calculation - assume screen is 4 x 3 */
aspect = (double) xdots *.75 / (double) ydots;

if (SPHERE == FALSE) /* skip this slow stuff in sphere case */
if (!SPHERE) /* skip this slow stuff in sphere case */
{
/*********************************************************************/
/* What is done here is to create a single matrix, m, which has */
Expand Down Expand Up @@ -2147,7 +2146,7 @@ static int first_time(int linelen, VECTOR v)
{
persp = true;
if (ZVIEWER < 80) /* force float */
usr_floatflag |= 2; /* turn on second bit */
usr_floatflag = true;
}

/* set up view vector, and put viewer in center of screen */
Expand All @@ -2168,7 +2167,7 @@ static int first_time(int linelen, VECTOR v)
lview[1] = lview[1] << 16;
lview[2] = lview[2] << 16;

if (SPHERE == FALSE) /* sphere skips this */
if (!SPHERE) /* sphere skips this */
{
/* translate back exactly amount we translated earlier plus enough to
* center image so maximum values are non-positive */
Expand Down
15 changes: 7 additions & 8 deletions common/loadfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ bool ldcheck = false;
int read_overlay() /* read overlay/3D files, if reqr'd */
{
struct fractal_info read_info;
char oldfloatflag;
char msg[110];
struct ext_blk_2 blk_2_info;
struct ext_blk_3 blk_3_info;
Expand All @@ -55,7 +54,7 @@ int read_overlay() /* read overlay/3D files, if reqr'd */

showfile = 1; /* for any abort exit, pretend done */
g_init_mode = -1; /* no viewing mode set yet */
oldfloatflag = usr_floatflag;
bool oldfloatflag = usr_floatflag;
loaded3d = false;
if (fastrestore)
{
Expand Down Expand Up @@ -174,7 +173,7 @@ int read_overlay() /* read overlay/3D files, if reqr'd */
usr_stdcalcmode = '3';
}
usr_distest = read_info.distestold;
usr_floatflag = (char)read_info.floatflag;
usr_floatflag = read_info.floatflag != 0;
bailout = read_info.bailoutold;
calctime = read_info.calctime;
trigndx[0] = read_info.trigndx[0];
Expand Down Expand Up @@ -275,7 +274,7 @@ int read_overlay() /* read overlay/3D files, if reqr'd */
{
LogFlag = 2;
}
usr_floatflag = (char)(curfractalspecific->isinteger ? 0 : 1);
usr_floatflag = curfractalspecific->isinteger ? false : true;
}

if (read_info.version < 5 && read_info.version != 0) /* pre-version 15.0? */
Expand Down Expand Up @@ -412,7 +411,7 @@ int read_overlay() /* read overlay/3D files, if reqr'd */
int const olddisplay3d = display3d;
bool const oldfloatflag = floatflag;
display3d = loaded3d ? 1 : 0; /* for <tab> display during next */
floatflag = usr_floatflag != 0; /* ditto */
floatflag = usr_floatflag; /* ditto */
int i = get_video_mode(&read_info, &blk_3_info);
#if defined(_WIN32)
_ASSERTE(_CrtCheckMemory());
Expand Down Expand Up @@ -1122,10 +1121,10 @@ void backwards_v18()
{
if (!functionpreloaded)
set_if_old_bif(); /* old bifs need function set */
if (fractype==MANDELTRIG && usr_floatflag==1
if (fractype==MANDELTRIG && usr_floatflag
&& save_release < 1800 && bailout == 0)
bailout = 2500;
if (fractype==LAMBDATRIG && usr_floatflag==1
if (fractype==LAMBDATRIG && usr_floatflag
&& save_release < 1800 && bailout == 0)
bailout = 2500;
}
Expand Down Expand Up @@ -1637,7 +1636,7 @@ int fgetwindow()
if (!oldbf_math)
free_bf_vars();
bf_math = oldbf_math;
floatflag = usr_floatflag != 0;
floatflag = usr_floatflag;

return (c);
}
Expand Down
2 changes: 1 addition & 1 deletion common/lorenz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ int plotorbits2dsetup()
if (tofloat == NOFRACTAL)
return (-1);
floatflag = true;
usr_floatflag = 1; /* force floating point */
usr_floatflag = true; /* force floating point */
curfractalspecific = &fractalspecific[tofloat];
fractype = tofloat;
}
Expand Down
2 changes: 1 addition & 1 deletion common/miscres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ int tab_display() /* display the status of the current image */
}
else if (floatflag)
{
j = (usr_floatflag) ? 1 : 2;
j = usr_floatflag ? 1 : 2;
}

if (bf_math == 0)
Expand Down
6 changes: 3 additions & 3 deletions common/prompts2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int get_toggles()
#ifndef XFRACT
choices[++k] = "Floating Point Algorithm";
uvalues[k].type = 'y';
uvalues[k].uval.ch.val = usr_floatflag;
uvalues[k].uval.ch.val = usr_floatflag ? 1 : 0;
#endif
choices[++k] = "Maximum Iterations (2 to 2,147,483,647)";
uvalues[k].type = 'L';
Expand Down Expand Up @@ -258,8 +258,8 @@ int get_toggles()
if (old_usr_stdcalcmode != usr_stdcalcmode) j++;
if (old_stoppass != stoppass) j++;
#ifndef XFRACT
if (uvalues[++k].uval.ch.val != usr_floatflag) {
usr_floatflag = (char)uvalues[k].uval.ch.val;
if ((uvalues[++k].uval.ch.val != 0) != usr_floatflag) {
usr_floatflag = uvalues[k].uval.ch.val != 0;
j++;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion headers/externs.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ extern bool use_old_period;
extern bool using_jiim;
extern int usr_biomorph;
extern long usr_distest;
extern char usr_floatflag;
extern bool usr_floatflag;
extern int usr_periodicitycheck;
extern char usr_stdcalcmode;
extern int g_vesa_x_res;
Expand Down

0 comments on commit a429ab1

Please sign in to comment.