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
Dicky B
Mar 23, 2004

That depends on the format of the file. If we're dealing with a human-readable, unordered, key-value config file, well how could you associate a string literal with a symbol at runtime?

Adbot
ADBOT LOVES YOU

Dicky B
Mar 23, 2004

litghost posted:

?
We're talking about populating primitive data fields though..

Janin posted:

Use a schema file to auto-generate both the storage class/struct and its serialisation procedure.
That's cheating :argh: but yeah ok. This could be situationally preferable to using a hash table or equivalent. I like it!

Dicky B
Mar 23, 2004

That is truly tragic.
code:
			While (ctr > 0) 
				Select Case (ctr) 
				    Case 100 : BackgroundWorker100.RunWorkerAsync() 
				    Case 99 : BackgroundWorker99.RunWorkerAsync() 
				    Case 98 : BackgroundWorker98.RunWorkerAsync() 
				    Case 97 : BackgroundWorker97.RunWorkerAsync() 
				    Case 96 : BackgroundWorker96.RunWorkerAsync() 
				    Case 95 : BackgroundWorker95.RunWorkerAsync() 
				    Case 94 : BackgroundWorker94.RunWorkerAsync() 
				    Case 93 : BackgroundWorker93.RunWorkerAsync() 
				    Case 92 : BackgroundWorker92.RunWorkerAsync() 
				    Case 91 : BackgroundWorker91.RunWorkerAsync() 
				    Case 90 : BackgroundWorker90.RunWorkerAsync() 
				    Case 89 : BackgroundWorker89.RunWorkerAsync() 
				    Case 88 : BackgroundWorker88.RunWorkerAsync() 
				    Case 87 : BackgroundWorker87.RunWorkerAsync() 
				    Case 86 : BackgroundWorker86.RunWorkerAsync() 
				    Case 85 : BackgroundWorker85.RunWorkerAsync() 
				    Case 84 : BackgroundWorker84.RunWorkerAsync() 
				    Case 83 : BackgroundWorker83.RunWorkerAsync() 
				    Case 82 : BackgroundWorker82.RunWorkerAsync() 
				    Case 81 : BackgroundWorker81.RunWorkerAsync() 
				    Case 80 : BackgroundWorker80.RunWorkerAsync() 
				    Case 79 : BackgroundWorker79.RunWorkerAsync() 
				    Case 78 : BackgroundWorker78.RunWorkerAsync() 
				    Case 77 : BackgroundWorker77.RunWorkerAsync() 
				    Case 76 : BackgroundWorker76.RunWorkerAsync() 
				    Case 75 : BackgroundWorker75.RunWorkerAsync() 
 _____     		            Case 74 : BackgroundWorker74.RunWorkerAsync() 
 \ U \__      _____                 Case 73 : BackgroundWorker73.RunWorkerAsync() 
  \   \/_______\___\_____________   Case 72 : BackgroundWorker72.RunWorkerAsync() 
  < /_/   .....................  `-.Case 71 : BackgroundWorker71.RunWorkerAsync() 
   `-----------,----,--------------'Case 70 : BackgroundWorker70.RunWorkerAsync() 
             _/____/		    Case 69 : BackgroundWorker69.RunWorkerAsync() 
				    Case 68 : BackgroundWorker68.RunWorkerAsync() 
				    Case 67 : BackgroundWorker67.RunWorkerAsync() 
				    Case 66 : BackgroundWorker66.RunWorkerAsync() 
				    Case 65 : BackgroundWorker65.RunWorkerAsync() 
				    Case 64 : BackgroundWorker64.RunWorkerAsync() 
				    Case 63 : BackgroundWorker63.RunWorkerAsync() 
				    Case 62 : BackgroundWorker62.RunWorkerAsync() 
				    Case 61 : BackgroundWorker61.RunWorkerAsync() 
				    Case 60 : BackgroundWorker60.RunWorkerAsync() 
				    Case 59 : BackgroundWorker59.RunWorkerAsync() 
				    Case 58 : BackgroundWorker58.RunWorkerAsync() 
				    Case 57 : BackgroundWorker57.RunWorkerAsync() 
				    Case 56 : BackgroundWorker56.RunWorkerAsync() 
				    Case 55 : BackgroundWorker55.RunWorkerAsync() 
				    Case 54 : BackgroundWorker54.RunWorkerAsync() 
				    Case 53 : BackgroundWorker53.RunWorkerAsync() 
				    Case 52 : BackgroundWorker52.RunWorkerAsync() 
				    Case 51 : BackgroundWorker51.RunWorkerAsync() 
				    Case 50 : BackgroundWorker50.RunWorkerAsync() 
				    Case 49 : BackgroundWorker49.RunWorkerAsync() 
				    Case 48 : BackgroundWorker48.RunWorkerAsync() 
				    Case 47 : BackgroundWorker47.RunWorkerAsync() 
				    Case 46 : BackgroundWorker46.RunWorkerAsync() 
				    Case 45 : BackgroundWorker45.RunWorkerAsync() 
				    Case 44 : BackgroundWorker44.RunWorkerAsync() 
				    Case 43 : BackgroundWorker43.RunWorkerAsync() 
				    Case 42 : BackgroundWorker42.RunWorkerAsync() 
				    Case 41 : BackgroundWorker41.RunWorkerAsync() 
				    Case 40 : BackgroundWorker40.RunWorkerAsync() 
				    Case 39 : BackgroundWorker39.RunWorkerAsync() 
				    Case 38 : BackgroundWorker38.RunWorkerAsync() 
				    Case 37 : BackgroundWorker37.RunWorkerAsync() 
				    Case 36 : BackgroundWorker36.RunWorkerAsync() 
				    Case 35 : BackgroundWorker35.RunWorkerAsync() 
				    Case 34 : BackgroundWorker34.RunWorkerAsync() 
				    Case 33 : BackgroundWorker33.RunWorkerAsync() 
				    Case 32 : BackgroundWorker32.RunWorkerAsync() 
				    Case 31 : BackgroundWorker31.RunWorkerAsync() 
				    Case 30 : BackgroundWorker30.RunWorkerAsync() 
				    Case 29 : BackgroundWorker29.RunWorkerAsync() 
				    Case 28 : BackgroundWorker28.RunWorkerAsync() 
				    Case 27 : BackgroundWorker27.RunWorkerAsync() 
				    Case 26 : BackgroundWorker26.RunWorkerAsync() 
				    Case 25 : BackgroundWorker25.RunWorkerAsync() 
				    Case 24 : BackgroundWorker24.RunWorkerAsync() 
				    Case 23 : BackgroundWorker23.RunWorkerAsync() 
				    Case 22 : BackgroundWorker22.RunWorkerAsync() 
				    Case 21 : BackgroundWorker21.RunWorkerAsync() 
				    Case 20 : BackgroundWorker20.RunWorkerAsync() 
				    Case 19 : BackgroundWorker19.RunWorkerAsync() 
				    Case 18 : BackgroundWorker18.RunWorkerAsync() 
				    Case 17 : BackgroundWorker17.RunWorkerAsync() 
				    Case 16 : BackgroundWorker16.RunWorkerAsync() 
				    Case 15 : BackgroundWorker15.RunWorkerAsync() 
				    Case 14 : BackgroundWorker14.RunWorkerAsync() 
				    Case 13 : BackgroundWorker13.RunWorkerAsync() 
				    Case 12 : BackgroundWorker12.RunWorkerAsync() 
				    Case 11 : BackgroundWorker11.RunWorkerAsync() 
				    Case 10 : BackgroundWorker10.RunWorkerAsync() 
				    Case 9 : BackgroundWorker9.RunWorkerAsync() 
				    Case 8 : BackgroundWorker8.RunWorkerAsync() 
				    Case 7 : BackgroundWorker7.RunWorkerAsync() 
				    Case 6 : BackgroundWorker6.RunWorkerAsync() 
				    Case 5 : BackgroundWorker5.RunWorkerAsync() 
				    Case 4 : BackgroundWorker4.RunWorkerAsync() 
				    Case 3 : BackgroundWorker3.RunWorkerAsync() 
				    Case 2 : BackgroundWorker2.RunWorkerAsync() 
				    Case 1 : BackgroundWorker1.RunWorkerAsync() 
				End Select 
				ctr -= 1 
			End While 
:911:

Dicky B
Mar 23, 2004

I would love a weekly "explain what the following obfuscated code does" contest. Kind of like ioccc but in reverse.

Dicky B
Mar 23, 2004

And I thought XSLT was horrible.

I want to know what the <cats>5</cats> at the end of that first example does.

Dicky B
Mar 23, 2004

This must be the coding horrors equivalent of Slow News Day.

Dicky B
Mar 23, 2004

Why you would choose string parsing over something like
code:
$.after(seconds(50), function() { ... }); // 50 seconds
$.after(minutes(7), function() { ... });  // 7 minutes
$.after(hours(33), function() { ... });   // 33 hours
is mind boggling.

Dicky B
Mar 23, 2004

I would guess that somebody just told them "tables are evil!" and forgot to add "except for tabular data!"

Dicky B
Mar 23, 2004

Fixed width fonts own because you can do stupid poo poo like this
pre:
struct transition_table : mpl::vector<
//    Start     Event        Target      Action                      Guard 
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Stopped , play       ,  Playing  , &player_::start_playback                               >,
a_row< Stopped , open_close ,  Open     , &player_::open_drawer                                  >,
 _row< Stopped , stop       ,  Stopped                                                           >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Open    , open_close ,  Empty    , &player_::close_drawer                                 >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Empty   , open_close ,  Open     , &player_::open_drawer                                  >,
  row< Empty   , cd_detected,  Stopped  , &player_::store_cd_info   , &player_::good_disk_format >,
  row< Empty   , cd_detected,  Playing  , &player_::store_cd_info   , &player_::auto_start       >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Playing , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Playing , pause      ,  Paused   , &player_::pause_playback                               >,
a_row< Playing , open_close ,  Open     , &player_::stop_and_open                                >,
//   +---------+------------+-----------+---------------------------+----------------------------+ 
a_row< Paused  , end_pause  ,  Playing  , &player_::resume_playback                              >,
a_row< Paused  , stop       ,  Stopped  , &player_::stop_playback                                >,
a_row< Paused  , open_close ,  Open     , &player_::stop_and_open                                >
//   +---------+------------+-----------+---------------------------+----------------------------+ 
> {};

Dicky B
Mar 23, 2004

Fun fact that code is part of the boost MSM library documentation.

Dicky B
Mar 23, 2004

code:
int *
do_the_evocollection
(
	int					count_of_things,
	float					*epsilon_ranges,
	const char *const			*format_ids,
	struct SOME_LONGEISH_STRUCT_NAME	*why_not_some_structs_as_well
)
{
	...
}
:f5: <- me adding tabs to my code

Dicky B
Mar 23, 2004

MrMoo posted:

lol, it's when you have to add restrict it gets even more entertaining.
Clearly we need to switch to a table based solution.

code:
#define IS_PTR *

/* RETURN TYPE:   */    int *
/* FUNCTION NAME: */    do_the_evocollection
(
/* -------------------------------- ARGUMENTS TABLE ---------------------------------- */
/* TYPE                              | OPTIONS          | NAME                         
   ----------------------------------------------------------------------------------- */
   int                                                    count_of_things              ,             
   float                               IS_PTR restrict    epsilon_ranges               ,              
   const char *const                   IS_PTR             format_ids                   ,                  
   struct SOME_LONGEISH_STRUCT_NAME    IS_PTR             why_not_some_structs_as_well 
/* ----------------------------------------------------------------------------------- */
)
{
/* FUNCTION BODY: */
	...
}

Dicky B
Mar 23, 2004

edit: never mind i'm not getting involved in this

Dicky B
Mar 23, 2004

Because:
code:
void fun() {
  some_type foo;
  if(something) {
    // do something with foo
  }
  else {
    // don't do anything with foo
  }
  // end of function.
  // we may have paid for the construction of foo even though we didn't use it!
}

Dicky B
Mar 23, 2004

Non c++ programmers talking about c++ :allears:

Dicky B
Mar 23, 2004

Zombywuf posted:

References being invisible and impossible to manipulate separately to values is the real horror.
This is why Pascal is probably the best beginner's language. The distinction between references and values and why that disparateness is so important gets hammered home early on, but in a relatively safe environment.

Dicky B
Mar 23, 2004

This seems like a good time to recommend this book http://www.elementsofprogramming.com/book.html

Dicky B
Mar 23, 2004

w00tz0r posted:

That was my lead. I had a shouting match with him that lasted at least half an hour.
Who won?

Dicky B
Mar 23, 2004

code:
switch (pname)
{
	case GL_TEXTURE_ENV_MODE:	if (p==GL_COMBINE)
								{
									bExtensionUsed = GL_TRUE;
								}
								break;

	case GL_COMBINE_RGB:
	case GL_COMBINE_ALPHA:		switch(p)
								{
									case GL_INTERPOLATE:    if (!gles::limits::inst().bOrthogonalTexEnvCombine)
															{
																static bool warning_displayed = false;
																if (!warning_displayed)
																{
																	logger << "implementation has limited support for GL_INTERPOLATE, which application will fail to represent.\n";
																	warning_displayed = true;
																}
															}
									case GL_REPLACE:
									case GL_MODULATE:
									case GL_ADD:
									case GL_ADD_SIGNED:
									case GL_SUBTRACT:
									case GL_DOT3_RGB:
									case GL_DOT3_RGBA:		bExtensionUsed = GL_TRUE; break;
									default:				gles::error::set(GL_INVALID_ENUM);
															return;
								}
								break;

	case host::GL::SOURCE0_RGB:
	case host::GL::SOURCE1_RGB:
	case host::GL::SOURCE2_RGB:
	case host::GL::SOURCE0_ALPHA:
	case host::GL::SOURCE1_ALPHA:
	case host::GL::SOURCE2_ALPHA:		switch(p)
								{
									case GL_TEXTURE:
									case GL_CONSTANT:
									case GL_PRIMARY_COLOR:
									case GL_PREVIOUS:       bExtensionUsed = GL_TRUE; break;
									default:				gles::error::set(GL_INVALID_ENUM);
															return;
								}
								break;

	case GL_OPERAND0_RGB:
	case GL_OPERAND1_RGB:
	case GL_OPERAND2_RGB:		switch(p)
								{
									case GL_SRC_COLOR:
									case GL_ONE_MINUS_SRC_COLOR:
									case GL_SRC_ALPHA:
									case GL_ONE_MINUS_SRC_ALPHA:	bExtensionUsed = GL_TRUE; break;
									default:						gles::error::set(GL_INVALID_ENUM);
																	return;
								}
								break;

	case GL_OPERAND0_ALPHA:
	case GL_OPERAND1_ALPHA:
	case GL_OPERAND2_ALPHA:		switch(p)
								{
									case GL_SRC_ALPHA:
									case GL_ONE_MINUS_SRC_ALPHA:	bExtensionUsed = GL_TRUE; break;
									default:						gles::error::set(GL_INVALID_ENUM);
																	return;
								}
								break;

	case GL_RGB_SCALE:
	case GL_ALPHA_SCALE:		bExtensionUsed = GL_TRUE;
								if (params[0]!=1.0f && params[0]!=2.0f && params[0]!=4.0f)
								{
									gles::error::set(GL_INVALID_ENUM);
									return;
								}
								break;
}

Dicky B
Mar 23, 2004

The code by itself is pretty horrible but the indentation is what made me laugh when I saw it.

This entire codebase is pretty wacko

code:
template <class ApiType, typename R,
          typename A1 = nil, typename A2 = nil, typename A3 = nil,
          typename A4 = nil, typename A5 = nil, typename A6 = nil,
          typename A7 = nil, typename A8 = nil, typename A9 = nil,
          typename A10 = nil,typename A11 = nil>
class Functor :
    public FunctorBase<ApiType, R(APIENTRY*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)>
{
    private:
        typedef FunctorBase<ApiType, R(APIENTRY*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)> BaseName;
        bool m_supported_within_context;
                                            
    public:
        typedef R(APIENTRY* proc_t)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11);


        Functor ( const char* proc_name
                  , const char* alt1 = 0
                  , const char* alt2 = 0
                  ) :
            FunctorBase<ApiType, R(APIENTRY*)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)>
                (proc_name, alt1, alt2), m_supported_within_context(true)
        {}

        void disactivate_call()
        {
            m_supported_within_context = false;
                                                   
            std::string nps = "WARNING: Your Hardware is not capable to run " + BaseName::proc_names[0] + "\n";
            myoutput(nps.c_str());
        }

        R operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11)
        {
            R ret = 0;
            if(!m_supported_within_context) {
                std::string nps = "ERROR: Your Hardware is not capable to run " + BaseName::proc_names[0] + "needed to emulate you App! \n";
                myoutput(nps.c_str());
                return ret;
            }
            this->pre_call();
            if (this->proc) ret = this->proc(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
            this->post_call();
            return ret;

        }
};

Dicky B
Mar 23, 2004

Post the login details on 4chan and let nature take its course.

Dicky B
Mar 23, 2004

quote:

Yeah, sadly that really hosed things up for a few hours in super meat world but it was all fixed before i even woke up today.

it sucks when people attempt to destroy the awesome creative things people make, and even more so when other people went out of their way to make this tool for fans as a thank you, asking nothing in return.

the good news is tommy had full backups of everyones levels, so even after they deleted everyones work he was able to return them with a single click and fully block all incoming attacks.

in the indie game the movie trailer im quoted saying that i desperately want to make friends but i dont want the actual interaction because i probably wont like them. this is one of many reasons why i feel that way.

there are a lot of sad people out there that love to destroy things to make themselves feel better, in the end it doesnt make them feel better but makes things worse for everyone else.

it really sucks that people are like this,
merry xmas i guess.
indie_game_developers.txt

Dicky B
Mar 23, 2004

Edmund McMillen School Of Security: Feel free to leave your databases wide open to the public. If anybody exploits it, then they're a jerk!!! It totally sucks!! WHy can't the world be a better place????

Dicky B
Mar 23, 2004

Nippashish posted:

"When she went out dressed like that pretty much the only thing that could have happened did. It's not a leap to figure out what a man would do after seeing her, and that's where the real problem is."

So yeah, it's an offensive analogy, but it's very accurate.
No.

Dicky B
Mar 23, 2004

Markov Chain Chomp posted:

How do they differ at all?
Directly connecting to a MySQL database leads to security vulnerabilities.
Dressing provocatively leads to a rape.

HOW DO THESE TWO THINGS DIFFER AT ALL

Dicky B
Mar 23, 2004

Markov Chain Chomp posted:

So any known security vulnerability deserves a great force of people hammering on it to exploit it? Even if the manpower behind the product is quite small and unable to deal with such an attack?
I don't understand what any of this has to do with rape and why rape is a good analogy? Shut up about rape is what I'm saying.

Dicky B
Mar 23, 2004

I'll start us off...
code:
THREAD_2803713
==============
ThreadTitle       PostID  Author           Content
Coding horrors    NULL    NULL             NULL
NULL              1       Ranma            I remember there used to be a thread like this,
NULL              2       CeciPipePasPipe  How come the guy is still employed?

Dicky B
Mar 23, 2004

code:
#define IS_NON_ZERO_0  0
#define IS_NON_ZERO_1  1
#define IS_NON_ZERO_2  1
#define IS_NON_ZERO_3  1
#define IS_NON_ZERO_4  1
#define IS_NON_ZERO_5  1
#define IS_NON_ZERO_6  1
#define IS_NON_ZERO_7  1
#define IS_NON_ZERO_8  1
#define IS_NON_ZERO_9  1
#define IS_NON_ZERO_10 1
#define IS_NON_ZERO_11 1
#define IS_NON_ZERO_12 1
#define IS_NON_ZERO_13 1
#define IS_NON_ZERO_14 1
#define IS_NON_ZERO_15 1
#define IS_NON_ZERO_16 1
#define IS_NON_ZERO_17 1
#define IS_NON_ZERO_18 1
#define IS_NON_ZERO_19 1
#define IS_NON_ZERO_20 1
#define IS_NON_ZERO_21 1

#define IS_NON_ZERO(n) IS_NON_ZERO_ ## n

Dicky B
Mar 23, 2004

mintskoal posted:

code:
<td class="cell">
                                    <table>
                                        <tr>
                                            <td>
                                            </td>
                                            <td>
                                                <asp:Label CssClass="" ID="label" runat="server" BackColor="" />
                                            </td>
                                            <td>
                                               
                                            </td>
                                        </tr>
                                    </table>
                                </td>
Frank is flipping you off.

Dicky B
Mar 23, 2004

I'm a fan of brainfuck. It is actually worth learning if you are the kind of person who enjoys pen and paper puzzles. Writing a simple program in brainfuck is like solving a sudoku or something.

Dicky B
Mar 23, 2004

Does this count as a coding horror?
http://www.youtube.com/watch?v=xF0-LGoXtaw

Dicky B
Mar 23, 2004

No, feeling strongly one way or another about it is retarded.

Dicky B
Mar 23, 2004

I've never understood this argument because:
- If you understand the syntax of the language then you will never make that mistake.
- If you don't understand the syntax of the language then making that mistake and learning from it is beneficial

Dicky B
Mar 23, 2004

Has anybody ever made that mistake more than once? Maybe if they code with their eyes closed.

If a conditional has no braces, it executes at most one line. It's an easy rule to learn. If you happen to add another line to a single-line if-statement then the error is right under your nose, because the problem area is at most three adjacent lines long. The above code sticks out like a sore thumb to me.

Dicky B
Mar 23, 2004

Ithaqua posted:

I always use curly braces, even if it could reasonably be fit onto a single line, for the sake of consistency. Obviously, I am horribly wrong.
It's perfectly consistent to always omit curly brackets when it's only one line.

Dicky B
Mar 23, 2004

What were you expecting from a library designed specifically for working with the C preprocessor? It's going to be horrible no matter what.

I would say the library itself is the horror but presumably it has its uses

Dicky B
Mar 23, 2004

This example is pretty nifty http://codepad.org/tU1ZUCJ5

If you can't tell, the FOR_EACH at the end is saying "run this CATCH macro for each of the tokens in BUILTIN_TYPES", and generates a catch() statement for each of them.

Dicky B
Mar 23, 2004

Keevon posted:

Perhaps you could excuse me for assuming people were angry by the fact that Notch is brought up a disproportionate amount in this thread.
Really?

Dicky B
Mar 23, 2004

It's ok that you said something incorrect and somebody called you out there's no need to be a dick about it "bro".

Adbot
ADBOT LOVES YOU

Dicky B
Mar 23, 2004

This must be what posting in the Minecraft thread is like.

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