Very specific question about bg_lib.c readability

A while ago a friend of mine started to re-format parts of the ioquake3 code a bit, to enhance readability. There is one file in the game code that is really very badly formatted (lot of missing brackets, no new lines, whitespace etc.)
There are two places inside bg_lib.c where we can’t really understand how to read them because of missing brackets.
It’s from line 1815 to 1827
and from line 1940 to 1947

Can some developer/programmer please tell us how those specific lines of code are working? Where would be brackets like ‘{’ and ‘}’?
In other words if you have a look at the specific parts of code, where is it meant to be an ‘else if’ and where is an ‘else’ and ‘if’?

Here is where a friend of mine did it: https://github.com/ioid3-games/ioid3-q3/blob/master/code/game/bg_lib.c#L2025 respectively https://github.com/ioid3-games/ioid3-q3/blob/master/code/game/bg_lib.c#L2164

Unfortunately I think he did it wrong. Both of us aren’t programmers, so maybe I am wrong.

Well, I know this is a somehow weird/useless question but nevertheless any help would be appreciated!
Thanks in advance!

You can check if the generated asm matches like this.

Just at a glance, it seems correct. Brackets are only necessary when combining multiple statements under the if , so adding brackets around a single statement is optional and doesn’t change anything. It tends to be considered good practice to add brackets even around a single statement, mainly for readability and to defend against the possibility the statement could be macroed into no statement or multiple statements.

You probably already figured it out, but I’ll

The existing formatting

  if(!(flags & DP_F_UNSIGNED))
  {
    if( value < 0 ) {
      signvalue = '-';
      uvalue = -value;
    }
    else
      if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
	signvalue = '+';
    else
      if (flags & DP_F_SPACE)
	signvalue = ' ';
  }

The correct interpretation

 if(!(flags & DP_F_UNSIGNED))
 {
    if( value < 0 )
    {
        signvalue = '-';
        uvalue = -value;
    }
    else if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
    {
	    signvalue = '+';
    }
    else if (flags & DP_F_SPACE)
    {
	    signvalue = ' ';
    }
}