Server Help

Trash Talk - Quake3 is open sourced now

Mine GO BOOM - Sat Aug 20, 2005 11:02 pm
Post subject: Quake3 is open sourced now
id Software has released Quake3's source code. A fun read if you are into learning to write games.

Since their servers are being hammered, you can download a copy here (5.45 MB).
Dr Brain - Sat Aug 20, 2005 11:20 pm
Post subject:
Hrm, I thought it already was. Maybe that's the other two quakes. Can't say that I've ever played any of them.
CypherJF - Sat Aug 20, 2005 11:48 pm
Post subject:
Never played it either. But, I guess this is good?
Purge - Sun Aug 21, 2005 12:04 am
Post subject:
Yes, we can all stare at it now.
Solo Ace - Sun Aug 21, 2005 7:25 am
Post subject:
I'd actually enjoy reading it.
My friends have been playing it a lot, and well, I didn't, because I... sucked. icon_sad.gif
Anyway, I was forced to run a server for them.
The game really made me wonder what it'd look like "behind the scene".
Too bad this is 1.32, not 1.16j, but I guess the real difference would only be the Punkbuster protection and the updates in the menu.
Thanks though, I'll read it, as far as I can understand it.
Mine GO BOOM - Sun Aug 21, 2005 11:47 am
Post subject:
I still like the cool hacks used to help speed up the game.
Code: Show/Hide
int Q_log2( int val ) {
   int answer;

   answer = 0;
   while ( ( val>>=1 ) != 0 ) {
      answer++;
   }
   return answer;
}
Code: Show/Hide
float Q_rsqrt( float number )
{
   long i;
   float x2, y;
   const float threehalfs = 1.5F;

   x2 = number * 0.5F;
   y  = number;
   i  = * ( long * ) &y;                  // evil floating point bit level hacking
   i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
   y  = * ( float * ) &i;
   y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//   y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed

#ifndef Q3_VM
#ifdef __linux__
   assert( !isnan(y) ); // bk010122 - FPE?
#endif
#endif
   return y;
}

Cyan~Fire - Sun Aug 21, 2005 2:19 pm
Post subject:
Optimizers can't do that? I hate micro-optimized C. icon_sad.gif
Mine GO BOOM - Sun Aug 21, 2005 10:30 pm
Post subject:
Cyan~Fire wrote:
Optimizers can't do that? I hate micro-optimized C. :-(

Can't do what? Speed up a precompiled library, such as all the math functions? Sin/cose/sqrt/etc all are designed to be acurate. Those optimizations are done with the assumption that you don't need 6 digits of precision if 4 would do. In my tests, it actually is slower for that Q_rsqrt than it is to just do 1/sqrt() on my AMD 2500, but only by a small margin. As for older hardware, that Q_rsqrt is almost twice as fast as sqrt. Why? Because older processor's floating point units sucked. And since you design a game to work on slow machines, you need to optimize for them.

As for the interger log function, that thing is lightspeed ahead of doing a floating point log calculation.
Cyan~Fire - Mon Aug 22, 2005 5:08 pm
Post subject:
Well, if I ever write an optimizing compiler, I'm going to detect if someone needs a floating pt/integer function and call different code.
Mr Ekted - Mon Aug 22, 2005 5:31 pm
Post subject:
Cyan~Fire wrote:
Well, if I ever write an optimizing compiler, I'm going to detect if someone needs a floating pt/integer function and call different code.


I know you are being sarcastic, but do you have any idea how complicated that is? Take a look at the Intel/AMD specs for instruction timing, pipelining, level-1/2 cache interface, North Bridge interface, RAM timing. Frankly, it sounds like the geek version of Fear Factor.
Gravitron - Mon Aug 22, 2005 5:48 pm
Post subject:
I thought fear factor was the geek version.
Mine GO BOOM - Mon Aug 22, 2005 10:54 pm
Post subject:
Cyan~Fire wrote:
if someone needs a floating pt/integer function and call different code.

Or you could, you know, overload functions? It is the programmer's job to know what they need. A compiler doesn't know if you need 20 digits of accuracy for that sqrt function or 2.
Mr Ekted - Tue Aug 23, 2005 12:07 am
Post subject:
In hardware design languages optimizations of this kind are much easier for the compilers because the use of the inputs and outputs is explicit. If you have an add "function" that takes 2 8-bit values, adds the upper 7 bits, then outputs only the lower 6 of those...In C it would look kinda like this:

Code: Show/Hide
wire[6:0] add (wire [7:0] a, wire [7:0] b)
{
wire [7:0] c;

c = a[7:1] + b[7:1];
add = c[6:0];
}


One bit of each input, and one bit of the output are not used, so they are completely removed from the final compiled result, including "outside the function". No wires will exist for them. It's much more explicit but much more of a pain in the ass.

I'm glad C is the way it is.
Dr Brain - Tue Aug 23, 2005 9:39 am
Post subject:
Here's some VHDL code for a circuit that adds two 3 bit lines and puts the output on a 4 bit line. This is straight from a calculator circuit I did last semester.

Code: Show/Hide
entity summer is
  port(input1, input2: in std_logic_vector(2 downto 0); output: out std_logic_vector(3 downto 0));
end summer;

architecture algorithmic of summer is
begin
  process(input1, input2)
  begin
    -- the ampersand is concatenation. it's used here to change
    -- the three wide inputs to four wide.
    output <= ('0' & input1) + ('0' & input2);
  end process;
end algorithmic;

Mr Ekted - Tue Aug 23, 2005 10:28 am
Post subject:
I've only ever used Verilog.
Cyan~Fire - Tue Aug 23, 2005 4:38 pm
Post subject:
I was just talking about floating point of integer. Yes, I guess overloading functions would work just as well, but a compiler should be able to detect a typecast from, say, int to double for a log or sqrt function.
SamHughes - Tue Aug 23, 2005 4:49 pm
Post subject:
Depending on your distribution of numbers for val, this log2 function might run significantly faster. It works faster for higher values of val -- the border is at 128 or 256.

Code: Show/Hide
int log2(unsigned long val) {

    int ret = 0;

    if (val >> 16) {
        ret |= 16;
        val >>= 16;
    }

    if (val >> 8) {
        ret |= 8;
        val >>= 8;
    }

    if (val >> 4) {
        ret |= 4;
        val >>= 4;
    }
   
    if (val >> 2) {
        ret |= 2;
        val >>= 2;
    }

    ret |= val >> 1;

    return ret;
}

Mr Ekted - Tue Aug 23, 2005 5:43 pm
Post subject:
Something tells me this is wrong, but I don't want to spend the time to figure it out. icon_wink.gif
SamHughes - Tue Aug 23, 2005 7:46 pm
Post subject:
Or maybe this version, which in my testing beats or ties Q_log2 for like, all inputs except 0 and 1.

Code: Show/Hide
int log2quick(unsigned long val) {

   int ret;

   if (val >> 8) {
      val >>= 8;

      ret = 8;

      if (val >> 12) {
         ret = 20;
         val >>= 12;
      }

      if (val >> 6) {
         ret += 6;
         val >>= 6;
      }

      if (val >> 3) {
         ret += 3;
         val >>= 3;
      }

      ret += (val >> 1) & 1 + (val >> 2);

   } else {
      ret = 0;
      if (val >> 4) {
         ret = 4;
         val >>= 4;
      }

      if (val >> 2) {
         ret |= 2;
         val >>= 2;
      }

      ret |= val >> 1;
   }

   return ret;

}

All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group