Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Aliotroph?

Ugly DOOM Code?

Recommended Posts

If Doom's code's sloppiness surprises you, then indeed you haven't looked at it for too long.

Here's the code in question. It actually looks fine on the forum, but not necessarily in text editors...

// wipegamestate can be set to -1 to force a wipe on the next draw
gamestate_t     wipegamestate = GS_DEMOSCREEN;
extern  boolean setsizeneeded;
extern  int             showMessages;
void R_ExecuteSetViewSize (void);

void D_Display (void)
{
    static  boolean		viewactivestate = false;
    static  boolean		menuactivestate = false;
    static  boolean		inhelpscreensstate = false;
    static  boolean		fullscreen = false;
    static  gamestate_t		oldgamestate = -1;
    static  int			borderdrawcount;
    int				nowtime;
    int				tics;
    int				wipestart;
    int				y;
    boolean			done;
    boolean			wipe;
    boolean			redrawsbar;

    if (nodrawers)
	return;                    // for comparative timing / profiling
		
    redrawsbar = false;
    
    // change the view size if needed
    if (setsizeneeded)
    {
	R_ExecuteSetViewSize ();
	oldgamestate = -1;                      // force background redraw
	borderdrawcount = 3;
    }

    // save the current screen if about to wipe
    if (gamestate != wipegamestate)
    {
	wipe = true;
	wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
    }
    else
	wipe = false;

    if (gamestate == GS_LEVEL && gametic)
	HU_Erase();

Share this post


Link to post

Yeah, different programs handle tabs/spaces differently. There's a good chance that if you're viewing code in an environment other than it was written in, it's not going to look as pristine. Happens to me all the time when I use a diff program to compare source code files with older versions.

Share this post


Link to post

Well, I often tend to change my mind on what is better, tabs or spaces, :) I prefer working with tabs, but I know they're poorly standardized.

Share this post


Link to post

The haphazard mixture of tabs and spaces in the original Doom source is almost impossible to work with. For Chocolate Strife we decided to normalize anything we had to touch to a 4-spaces indentation, and eliminate all tabs.

Share this post


Link to post
Maes said:

Looks like Carmack was a fan of the Allman style at the time :-)


I like Allman style and Horstmann style; but Stallman style is awful. (Worst is Whitesman, I mean, Whitesmiths style.)

Share this post


Link to post
printz said:

Well, I often tend to change my mind on what is better, tabs or spaces, :) I prefer working with tabs, but I know they're poorly standardized.

Don't forget the third option of using both! Tabs for indentation, spaces for alignment. Then it doesn't matter what the tab size is set to. Unless you're one of those who insists on breaking lines at the 80 character mark of course.

Share this post


Link to post

Ahh. I see their editor got confused by the spaces in some of the lines. That is sloppy. The code otherwise looks a lot like much of my recent code because VS enforces Allman style much to the chagrin of Java programmers and people who want to see more lines at a time. (This is a serious consideration for those of us who use 20pt fonts in our editors.)

Share this post


Link to post
Aliotroph? said:

(This is a serious consideration for those of us who use 20pt fonts in our editors.)

20pt font? How frequently? More importantly, how come?

Share this post


Link to post
Kirby said:

20pt font? How frequently? More importantly, how come?


Eyesight issues I suppose.

Share this post


Link to post

20pt, bold, light text on dark. Only way I have any chance of seeing my code. It's not even enough anymore since my focal point moved out past the where my retina (yes, just the one) has sufficient resolution. Looking into building a custom monitor stand and then mounting an arm on it so my display can literally be in my face and I don't have to learn over my keyboard.

Bad eyesight makes me kind of hate IDEs. It's hard to blow up the text in all the little windows most of the time, and in tools where I manage that it's then hard to fit it on the screen. They're better when the windows can be undocked an the non-code ones can live on my other monitor.

Share this post


Link to post
Gez said:

I like Allman style and Horstmann style; but Stallman style is awful. (Worst is Whitesman, I mean, Whitesmiths style.)

So Allman style is what I've been using all this time. Can finally put a name on it :P

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×