Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Scaevolus
Apr 16, 2007

Melonhead posted:

What the hell is a Unicode keyboard? I am imagining a keyboard with over 100,000 buttons here.
I bet he means an APL keyboard.

Additional characters:

\ _ ¨ ¯ × ÷ ← ↑ → ↓ ∆ ∇ ∘ ∣ ∧ ∨
∩ ∪ ∼ ≠ ≤ ≥ ≬ ⊂ ⊃ ⌈ ⌊ ⊤ ⊥ ⋆ ⌶ ⌷
⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇
⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗
⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧
⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷
⍸ ⍹ ⍺ ⎕ ○

Let's stick to ASCII.

Adbot
ADBOT LOVES YOU

biznatchio
Mar 31, 2001


Buglord

Milde posted:

Anything but ASCII in source code is infuriating as hell though. :)

Back in like 2002 when I was still following Perl 6 development, they had decided that several operators would be Unicode characters.

...I wonder if they ever changed their minds.

Allie
Jan 17, 2004

biznatchio posted:

Back in like 2002 when I was still following Perl 6 development, they had decided that several operators would be Unicode characters.

...I wonder if they ever changed their minds.

Python 3.0 will be allowing non-ASCII characters in identifiers, which I think is crazy enough. I don't know if it has proven itself not to be that much of a detriment in C#, but it irks me out thinking about not being able to easily edit someone else's code because it has characters that I can't type.

It could just be that I have a bias with English being my native language, but I do write in other languages that use characters that aren't on my keyboard (I use my compose key for that) and I can't imagine ever wanting special characters in my source code either way - I'd just as rather type out escape codes for them. I do like writing translation files in UTF-8 though.

But honestly I wouldn't be surprised at Perl doing something like that.

ohgodwhat
Aug 6, 2005

Scaevolus posted:

I bet he means an APL keyboard.

Additional characters:

\ _ ¨ ¯ × ÷ ← ↑ → ↓ ∆ ∇ ∘ ∣ ∧ ∨
∩ ∪ ∼ ≠ ≤ ≥ ≬ ⊂ ⊃ ⌈ ⌊ ⊤ ⊥ ⋆ ⌶ ⌷
⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇
⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗
⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧
⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷
⍸ ⍹ ⍺ ⎕ ○

Let's stick to ASCII.

And I have to learn APL. Wish me luck. :(

kalleboo
Jan 13, 2001

Hjälp

TRex EaterofCars posted:

As for the rest of that, I can't wait for Unicode keyboards. Using proper symbols would be a godsend, not some ==== bullshit. I know you can do Unicode in C# but typing in the codes is a pain in the dick.
Get a Mac?

Twitchy
May 27, 2005

My Internet Programming module (which was bollocks :argh: ) had an assignment of implementing a traditional game that you'd usually find in a Sunday newspaper or something. A friend of mine implemented a stamp game with rules something like:

- There are 12 stamps in a 4x3 grid
- You have to select combinations of 4 stamps, but they need to be connected to each other. For example 1,2,3,7 is a combination.

So it seems pretty simple right (probably the simplest out of the selection); a method to check whether the 4 selected stamps were connected and if it had been found before? Wrong...

She manually entered every combination of 4 into its own ArrayList even though we hadn't been givin the combinations. To make it worse every time she called sequenceCheck() (basically every time a button was pressed) she instantiated 65 seperate ArrayLists with the combinations in them rather than just having them set up in the constructor or something. The garbage collector must have been having a panic attack.

It ended up being something like 2,500 lines even though it should have been 200 or so.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Scaevolus posted:

I bet he means an APL keyboard.

Additional characters:

\ _ ¨ ¯ × ÷ ← ↑ → ↓ ∆ ∇ ∘ ∣ ∧ ∨
∩ ∪ ∼ ≠ ≤ ≥ ≬ ⊂ ⊃ ⌈ ⌊ ⊤ ⊥ ⋆ ⌶ ⌷
⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇
⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗
⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧
⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷
⍸ ⍹ ⍺ ⎕ ○

Let's stick to ASCII.

Look at all those beautiful, succinct glyphs... just waiting to be used :(

heeen
May 14, 2005

CAT NEVER STOPS

TRex EaterofCars posted:

Look at all those beautiful, succinct glyphs... just waiting to be used :(

Trying to find a bug when someone typed [233D] instead of [2330] is going to be fun.

StickGuy
Dec 9, 2000

We are on an expedicion. Find the moon is our mission.
This snippet comes from the clusterfuck known as GPUFFTW:
code:
glMultiTexCoord2f(GL_TEXTURE3, 1,cos(-sign*2*pi/(4.0)));
glMultiTexCoord2f(GL_TEXTURE4, 0,sin(-sign*2*pi/(4.0)));
sign is either 1 or -1. I can only hope that this is a holdover from some previous version of the code that actually worked.

Moetic Justice
Feb 14, 2004

by Fistgrrl

Milde posted:

A keyboard with a compose key? Maybe four or five different compose keys?

Anything but ASCII in source code is infuriating as hell though. :)

Might as well have a bigass knob that goes from 0-255. If you want to call a variable א, just set the knob to 05 and you're good to go!

Evis
Feb 28, 2007
Flying Spaghetti Monster

Found very late in a project, just before it was to be released.

code:
class Foo{
     unsigned char bar;
     //other stuff
};
The max value bar could take was 270, so it would (extremely rarely) wrap around at 255+1. The best part is the class was only instantiated once so the coder saved almost no space. With padding and/or depending on the compiler they probably didn't save any space at all. I had an argument with him and one other person about this, and they both still think it's better to optimize this stuff all over the program. Even if they did this all over every piece of code they wrote correctly it'd probably only save a couple of kilobytes out of a pool several orders of magnitude larger. I'm all for optimization but not until it's actually needed.

Another bit from an ex-programmer:

code:
for(int i=0;i<iMax;i++)
{
     switch(i)
     {
     case 0:
          //do stuff
          break;
     case 1:
          //do other stuff
          break;
     //etc.
     }
}
That guy got an awful lot of ribbing for that one.

MORE CURLY FRIES
Apr 8, 2004

Evis posted:

code:
for(int i=0;i<iMax;i++)
{
     switch(i)
     {
     case 0:
          //do stuff
          break;
     case 1:
          //do other stuff
          break;
     //etc.
     }
}
That guy got an awful lot of ribbing for that one.

Sorry if I'm being a bit groggy here, but what's wrong with a switch in a for statement?

1337JiveTurkey
Feb 17, 2005

MORE CURLY FRIES posted:

Sorry if I'm being a bit groggy here, but what's wrong with a switch in a for statement?

Just write them sequentially instead since all that code does is call case 0 and then case 1, but in an obfuscated manner.

take boat
Jul 8, 2006
boat: TAKEN

MORE CURLY FRIES posted:

Sorry if I'm being a bit groggy here, but what's wrong with a switch in a for statement?
http://thedailywtf.com/Articles/The_FOR-CASE_paradigm.aspx

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.
Sadly, this is almost too common to be worth mentioning. But look:

code:
class Foo {
  typedef enum { CONSTANT, CONSTANT2 } Constants;

};
Ok? Pretty clear? Now, watch closely:

code:
if (someVal == Foo::CONSTANT)
CONSTANT is part of the class. You don't need an instance. There's no need for this:

code:
Foo f;
if (someVal == f.CONSTANT)

Vanadium posted:

Why did you instantiate the enum then? :colbert:

Oops, forgot "typedef".

JoeNotCharles fucked around with this message at 22:12 on May 29, 2008

Vanadium
Jan 8, 2005

Why did you instantiate the enum then? :colbert:

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!

JoeNotCharles posted:

code:
Foo f;
if (someVal == f.CONSTANT)

This reminds me of my very early Java days before I was entirely clear on the concept of static members :shobon:

rotor
Jun 11, 2001

classic case of pineapple derangement syndrome

Scaevolus posted:

I bet he means an APL keyboard.

Additional characters:

\ _ ¨ ¯ × ÷ ← ↑ → ↓ ∆ ∇ ∘ ∣ ∧ ∨
∩ ∪ ∼ ≠ ≤ ≥ ≬ ⊂ ⊃ ⌈ ⌊ ⊤ ⊥ ⋆ ⌶ ⌷
⌸ ⌹ ⌺ ⌻ ⌼ ⌽ ⌾ ⌿ ⍀ ⍁ ⍂ ⍃ ⍄ ⍅ ⍆ ⍇
⍈ ⍉ ⍊ ⍋ ⍌ ⍍ ⍎ ⍏ ⍐ ⍑ ⍒ ⍓ ⍔ ⍕ ⍖ ⍗
⍘ ⍙ ⍚ ⍛ ⍜ ⍝ ⍞ ⍟ ⍠ ⍡ ⍢ ⍣ ⍤ ⍥ ⍦ ⍧
⍨ ⍩ ⍪ ⍫ ⍬ ⍭ ⍮ ⍯ ⍰ ⍱ ⍲ ⍳ ⍴ ⍵ ⍶ ⍷
⍸ ⍹ ⍺ ⎕ ○

Let's stick to ASCII.

No way. I want intersection/union glyphs. I've been typing .contains and .concat for 12 goddamn years like some kind of loving caveman. It's 2008, let's start acting like it people. :mad:

Smackbilly
Jan 3, 2001
What kind of a name is Pizza Organ! anyway?

rotor posted:

No way. I want intersection/union glyphs. I've been typing .contains and .concat for 12 goddamn years like some kind of loving caveman. It's 2008, let's start acting like it people. :mad:

Agreed. We don't need a full whacko APL keyboard, but it would be pretty nice to at least have characters for basic set operations (intersect, union, subset, superset), and a single glyph for -> on normal keyboards. I'd even be happy with settling for a bigraph for subset-or-equal and superset-or-equal.

take boat
Jul 8, 2006
boat: TAKEN

Smackbilly posted:

Agreed. We don't need a full whacko APL keyboard, but it would be pretty nice to at least have characters for basic set operations (intersect, union, subset, superset), and a single glyph for -> on normal keyboards. I'd even be happy with settling for a bigraph for subset-or-equal and superset-or-equal.
I'm holding out for a λ
I'm also excited about Fortress, though it seems way more trouble than it's worth.

take boat fucked around with this message at 23:38 on May 29, 2008

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Smackbilly posted:

Agreed. We don't need a full whacko APL keyboard, but it would be pretty nice to at least have characters for basic set operations (intersect, union, subset, superset), and a single glyph for -> on normal keyboards. I'd even be happy with settling for a bigraph for subset-or-equal and superset-or-equal.

Python would like a word with you.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

deimos posted:

Python would like a word with you.

I'd like a word with python.

Fenderbender
Oct 10, 2003

You have the right to remain silent.

TRex EaterofCars posted:

I'd like a word with python.

My python has a word: huge.

:whatup:

schnarf
Jun 1, 2002
I WIN.

StickGuy posted:

This snippet comes from the clusterfuck known as GPUFFTW:
code:
glMultiTexCoord2f(GL_TEXTURE3, 1,cos(-sign*2*pi/(4.0)));
glMultiTexCoord2f(GL_TEXTURE4, 0,sin(-sign*2*pi/(4.0)));
sign is either 1 or -1. I can only hope that this is a holdover from some previous version of the code that actually worked.
If this is in the FFT where I think it is, then this isn't uncommon. It's probably being used for doing an inverse FFT if necessary. This is because the inverse FFT is almost exactly the same as the forward FFT, you just flip the sign of the imaginary part, I believe.

ohgodwhat
Aug 6, 2005

schnarf posted:

If this is in the FFT where I think it is, then this isn't uncommon. It's probably being used for doing an inverse FFT if necessary. This is because the inverse FFT is almost exactly the same as the forward FFT, you just flip the sign of the imaginary part, I believe.

Except:
cos(-sign*2*pi/(4.0)) = 0
sin(-sign*2*pi/(4.0)) = -sign

when sign = -1,1

Gumbercules
Jan 12, 2004

These aren't my lamps. These have feet.
More horrors from the endless chest of horrors that is Progress 4GL (this is a rant):

Error handling in Progress 4GL:

I have been tasked with designing a system for creating automated QA tests for our application. Unit tests are not possible, so I have created a "workflow"-based testing system which records user-interface events (which are sent from a thin client to the server) and plays them back later. These scripts are recorded as new 4GL procedure files (it's is an interpreted language), which the QA team can modify to directly query the database in the middle of the script for various purposes. In the right hands, it might actually work.

As part of this, I need to detect errors in the program and store them in a log file. Now, capturing problems with the user-interface (missing fields or messages) is easy - however, Progress's own internal error systems are rear end. Here's the breakdown:

Progress procedures are either "internal" or "external". An external procedure is a physical ".p" file in the file system, which contains a sequence of progress commands. An internal procedures is a declared Procedure within an external procedure (internal procedures cannot be nested). The syntax looks like this:

code:
/* In file external.p */
DEF INPUT PARAMETER my-string AS CHAR NO-UNDO.  /* Input parameter */

/* Main procedure body */

PROCEDURE intern-procedure:
   DEF INPUT PARAM x AS CHAR NO-UNDO.
   /* Internal procedure body */
END PROCEDURE.
To call either an internal or external procedure, you use the RUN statement:

code:
RUN external.p (INPUT "Hello").   /* Run an external procedure */
RUN my-procedure (INPUT "Hello").  /* Run an internal procedure */
Note that this is always dynamic: procedure names and parameters for RUN statements are not resolved at compile time.

Now, lets look at the following code:

code:
/* in file "error.p" */

PROCEDURE my-procedure:
   DEF INPUT PARAM ip-char1 AS CHAR NO-UNDO.
   DEF INPUT PARAM ip-char2 AS CHAR NO-UNDO.
   /* Do something */
END PROCEDURE.

RUN my-procedure (INPUT "Hello").  /* Parameters don't match. */

/* different file "test.p" */
RUN error.p.
/* More code */
So what happens when you run test.p? Test.p calls run.p, which compiles and runs succesfully. However, when error.p calls its own internal procedure "my-procedure", the parameters don't match, which raises a runtime error. The default behavior in progress 4GL is the following:
1.) log the error to the log file ("Mismatched Parameters")
2.) The "RUN my-procedure" statement raises the ERROR condition inside of "error.p".
3.) error.p sees the ERROR condition.
4.) error.p rolls back its database transaction, and returns to test.p Without raising the ERROR condition in test.p.
5.) test.p continues on, with no indication that error.p experienced an error.

That's right: ERROR conditions do not propagate up the stack by default. If any statement returns an "ERROR" condition, by default the containing block simply rolls back its transaction and returns normally. This is horrible.

If, for some crazy reason, you would need to reliably propagate errors to the top of the call stack, here are your two options:

code:
/* in file "error.p" */
PROCEDURE my-procedure:
   DEF INPUT PARAM ip-char1 AS CHAR NO-UNDO.
   DEF INPUT PARAM ip-char2 AS CHAR NO-UNDO.
   /* Do something */
END PROCEDURE.

RUN my-procedure (INPUT "Hello") NO-ERROR.  /* Parameters don't match. */
IF ERROR-STATUS:ERROR THEN
   RETURN ERROR.
The "NO-ERROR" keyword suppresses any and all errors for that one statement and then lets you explicitly check the error status through the ERROR-STATUS system handle.

Note that the above code does NOT suppress errors that occur within "my-procedure" - it only occurs if the "RUN" statement actually fails to execute, or if "my-procedure" explicitly calls RETURN ERROR. Therefore, you must repeat this process for every single statement in the program.

Here is the other method I came up with, which could possibly take less to implement:

code:
/* in file "error.p" */
PROCEDURE my-procedure:
   DEF INPUT PARAM ip-char1 AS CHAR NO-UNDO.
   DEF INPUT PARAM ip-char2 AS CHAR NO-UNDO.
   DEF VAR op-valid AS LOG INIT FALSE.   /* This value can be undone with transactions */
   DO TRANSACTION ON ERROR UNDO, LEAVE:
      ASSIGN op-valid = TRUE.
      /* Procedure body */
   END.
   IF NOT op-valid THEN
      RETURN ERROR.
END PROCEDURE.

DEF VAR op-valid AS LOG INIT FALSE.   /* This value can be undone with transactions */
DO TRANSACTION ON ERROR UNDO, LEAVE:
   ASSIGN op-valid = TRUE.
   /* Main procedure body */
   RUN my-procedure(INPUT "Hello").
END.

IF NOT op-valid THEN
  RETURN ERROR.
Here, I've enclosed the body of each procedure in a "DO" block, which lets me override the default ERROR behavior of each block. However, in order to tell that an error actually occurred, I need to rely on the transaction being undone to unset my "op-valid" flag - Progress doesn't give you the means internally to tell if the previous transaction was undone or not. Finally, no indication of what actually caused the error is available (although you can find out later manually by checking the servers log file).

If you want an indication of WHAT error actually occured, instead of always using RETURN ERROR, you could also give every procedure in the system a "success" output parameter. This is, of course, a practical and excellent solution.

So there you go, Progress provides two excellent error-handling options:
#1.) Check for errors explictly throughout your program
#2.) Ignore errors within the program entirely and manually check your log file later to see if anything bad happened.

Guess which one our system is using? -_-

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Gumbercules posted:

Note that the above code does NOT suppress errors that occur within "my-procedure" - it only occurs if the "RUN" statement actually fails to execute, or if "my-procedure" explicitly calls RETURN ERROR. Therefore, you must repeat this process for every single statement in the program.

Sounds like this would be pretty easy to automate, though - just run your code through a filter that adds the error check after every statement.

Gumbercules
Jan 12, 2004

These aren't my lamps. These have feet.

JoeNotCharles posted:

Sounds like this would be pretty easy to automate, though - just run your code through a filter that adds the error check after every statement.

Despite difficulties parsing this language and automating something like that, the real problem is simply that the code would become slow and unreadable at that point.

Not that it isn't unreadable already.

Gumbercules fucked around with this message at 02:46 on Jun 1, 2008

No Safe Word
Feb 26, 2005

Not a specific piece of code per se, but a sadly not-uncommon practice I've seen.

developer assigned to take my place on old project posted:

The query returns 70 rows – when I put a DISTINCT on the query it brings back 35 – that removes the dupes...is there more to this issue??

:sigh:

Sadly, people think the only way to eliminate rows that give you duplicate data is to use DISTINCT. Surely we couldn't have messed up some other constraint, right? Like a JOIN or WHERE or GROUP BY or HAVING or anything else, right? Just slap a DISTINCT on there!

Victor
Jun 18, 2004
We should just rename DISTINCT to FIX.

blorpy
Jan 5, 2005

The javascript embedded in http://www.rockband.com resizes your browser. I thought we got past this years ago :sigh:

Aredna
Mar 17, 2007
Nap Ghost

Chain Chomp posted:

The javascript embedded in http://www.rockband.com resizes your browser. I thought we got past this years ago :sigh:

Even worse, when you're watching shows on http://www.southparkstudios.com full screen* it will resize your browser for commercials and then resize it back again for full screen, but never maximized even if it started that way.

*not really full screen, just the biggest it can fit in your browser window

Jo
Jan 24, 2005

:allears:
Soiled Meat
Is there a reason someone would write
code:
if( ((num-1) & (num)) == 0 )
...rather than...
code:
if( num%2 == 0 )
Or am I being dense?

heeen
May 14, 2005

CAT NEVER STOPS

Jo posted:

Is there a reason someone would write
code:
if( ((num-1) & (num)) == 0 )
...rather than...
code:
if( num%2 == 0 )
Or am I being dense?

I'd guess the latter involves a division which is a rather lengthy operation, whereas the former is just bit juggling.
Isn't (num & 1)==0 even simpler? I'm not sure the former is doing the right thing at all.

TSDK
Nov 24, 2003

I got a wooden uploading this one

Jo posted:

Is there a reason someone would write
code:
if( ((num-1) & (num)) == 0 )
...rather than...
code:
if( num%2 == 0 )
Or am I being dense?
The first test is checking to see if a number is a power of two:
http://aggregate.org/MAGIC/#Is%20Power%20of%202

The second one is testing for an even number, so the tests are not the same.

ashgromnies
Jun 19, 2004

heeen posted:

I'd guess the latter involves a division which is a rather lengthy operation, whereas the former is just bit juggling.
Isn't (num & 1)==0 even simpler? I'm not sure the former is doing the right thing at all.

(num & 1)==0 is correct.

What he posted in his example is incorrect.

code:
[b]First method:[/b]

Let n = 0111 (7 in decimal)

0110 &
0111
----
0110

Not equal to 0, therefore 7 is odd

Let n = 1010 (10 in decimal)

1001 &
1010
----
1000

Not equal to 0, therefore 10 is odd... WAITAMINUTE


[b]Second method:[/b]
Let n = 0111 (7 in decimal)

0111 &
0001
----
0001

Not equal to 0 therefore 7 is odd

Let n = 1010 (10 in decimal)

1010 &
0001
----
0000

Equal to 0 therefore 10 is even

ijustam
Jun 20, 2005

Chain Chomp posted:

The javascript embedded in http://www.rockband.com resizes your browser. I thought we got past this years ago :sigh:

Is there a good reason to enable JavaScript's ability to resize windows? Firefox lets you disable it (under "Advanced" next to "Enable JavaScript" in the Content tab of your preferences)

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
GtkRadiant is a monstrous clusterfuck of code. Individual snippets don't really do it justice since it's basically one overthought design decision after another. It's some bloated new APIs layered on top of the Q3Radiant code which is an upgrade to QERadiant which was an upgrade to QE4. I'm not sure what the Windows Me source code looked like, but I think I have an idea now.

:downs: "Hey guys, how should we relay console output from the tools to the editor feedback window? Using the native piping stuff sounds like a good idea, right?"

:pcgaming: "NO, WE MUST MAKE THE EDITOR SPAWN A SERVER AND HAVE THE MAP COMPILER CONNECT TO IT AND SEND THEM OVER TCP!"

:downs: "Well that sounds slightly bloated, might be useful for remote compilation. So it'll just send raw strings?"

:pcgaming: "NO YOU FOOL, WE SHALL SEND THEM PACKAGED IN XML!"

:downs: "You mean we're going to stuff strings into XML tags to send them via TCP, which is the only thing the map compiler will be sending over TCP, and parse them out of the XML string when it's received."

:pcgaming: "YES!!"

:downs: "OK. So what about plug-ins? The current API is pretty good, let's just add a few functions to that and--"

:pcgaming: "NO! WE WILL CREATE AN ELABORATE AND CONFUSING API DERIVED FROM COM+! AND IT MUST USE XML!"

:downs: ".... anything else?"

:pcgaming: "YES! WE WILL CHANGE RANDOM CONTROLS AND FEATURES TO WORK LIKE MAYA! AND CONVERT THE MAP FORMAT TO XML!"


A little closer to the goal though: q3map2 has some nice features, except it's bloated and whoever wrote the lighting code really needs to learn how to split their functions up better.

https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk/tools/quake3/q3map2/light_ydnar.c
https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk/tools/quake3/q3map2/lightmaps_ydnar.c

IlluminateRawLightmap: 666 lines of code
StoreSurfaceLightmaps: 1024 lines of code

OneEightHundred fucked around with this message at 06:05 on Jun 4, 2008

Mikey-San
Nov 3, 2005

I'm Edith Head!
Holy poo poo, ydnar. There is a name I have not seen in years.

http://www.ydnar.com/
http://www.shaderlab.com/

Marathon fans (all seven of you) in the room may recognize the name.

Mikey-San fucked around with this message at 06:39 on Jun 4, 2008

Adbot
ADBOT LOVES YOU

return0
Apr 11, 2007

ashgromnies posted:

(num & 1)==0 is correct.

What he posted in his example is incorrect.

code:
[b]First method:[/b]

Let n = 0111 (7 in decimal)

0110 &
0111
----
0110

Not equal to 0, therefore 7 is odd

Let n = 1010 (10 in decimal)

1001 &
1010
----
1000

Not equal to 0, therefore 10 is odd... WAITAMINUTE


[b]Second method:[/b]
Let n = 0111 (7 in decimal)

0111 &
0001
----
0001

Not equal to 0 therefore 7 is odd

Let n = 1010 (10 in decimal)

1010 &
0001
----
0000

Equal to 0 therefore 10 is even



if( ((num-1) & (num)) == 0 ) is not a test for evenness, it's checking for if num is a power of two.

It is however slightly incorrect in that zero is incorrectly considered to be a power of two, I think this can be used to fix that:

if(!(num & (num - 1)) && num )

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply