war crimes in programming - A thread to discuss and share horrifying programming ideas/code

  • 🐕 I am attempting to get the site runnning as fast as possible. If you are experiencing slow page load times, please report it.
9 times out of 10 an else if is unnecessary and indicative of logic that could be condensed into something cleaner. Might be an unpopular opinion.
 
Pried from Road to Vostok.
The game is anal and fiddly when requiring 5 keys pressed in a specific order to reload and chamber a round for a pump-action shotgun.
The game can't properly set the MSAA type to the engine when restarting the game.


I found this snippet sorta dumb and weird.
[sub_resource type="Resource" id="Resource_etinr"]
script = ExtResource("1")
itemData = ExtResource("2")
condition = 32
index = 0
ammo = 14
chamber = 0
firemode = 1
position = 0.0
zoom = 1
[sub_resource type="Resource" id="Resource_uec2s"]
script = ExtResource("1")
itemData = ExtResource("3")
condition = 77
index = 1
ammo = 7
chamber = 0
firemode = 1
position = 0.0
zoom = 1
[sub_resource type="Resource" id="Resource_ybuld"]
script = ExtResource("1")
itemData = ExtResource("23")
condition = 100.0
index = 17
ammo = 0
chamber = 0
firemode = 1
position = 0.0
zoom = 1
 
The game is anal and fiddly when requiring 5 keys pressed in a specific order to reload and chamber a round for a pump-action shotgun.
Dunno why retards keep fiddling with how bolt action, lever action and pump action guns work in games. The only compromise i can live with is maybe pressing one button to re-chamber (the shooting button) and/or having to press reload for every cartridge inserted into the magazine. Having one button for everything related to reloading is dumb and stupid for a keybaord and mouse game. If you still want to do it then make it a VR game you massive fucking gorilla nigger retard (and you will still fuck it up because you have no idea how to optimize your game).
 
Only true C whales will know this one offhand (I didn't) - this is actually a NaN check, since by the IEEE754 rules, NaNs are the only values where x == x is false. (Why isn't this the way isnan is implemented in standard libs then?)
It's actually extremely obvious - the first version of IEEE754 was ratified in 1985, more than a decade and a half after C entered common usage. The C standard does not assume that float and double conform to IEEE754 because so much of the existing C code at the time when C was standardized in 1989 was written before IEEE754 was widely implemented. The C standard instead leaves details about how the floating point types work up to the implementation.
 
First function in a spec for "managed strings":
isNull.webp
 
All the hallmarks of cursed C-code - returning a value smaller in size than a register via pointer indirection, errno that doesn't tell you anything, and way too many fucking underscores
... I cannot stop laughing when I see:
_Bool *nullstr

genius.webp

BTW.: This function MAY or MAY NOT return. Just sayin', sometimes you may want to know
Code:
if (str)
but it's a managed str, and well then one day the function just won't return - and it'll be end of program for you. It's happened to real people, it will happen again, all bets are off in managed string territory.

Please keep this in mind at all times.
CERT
 
So this string library actually has its own internal representation of "strings that are null", separate from the string pointer itself being null? :sighduck:
 
So this string library actually has its own internal representation of "strings that are null", separate from the string pointer itself being null? :sighduck:
It's a managed strings library so it handles allocation of memory for the strings behind the scenes apart from things like *alloc. So a pointer to a managed string might not actually be null valued and it might actually be in use by the managed strings library but there's no actual string allocated by the library at that pointer currently and is therefore 'null.'

Managed strings aren't a terrible idea as memory allocation headaches and various bugs pop up with classic C-style strings all the time. For example, GLib (which is the underlying object system used by GTK) has its own special managed string stuff. However the one referenced above isn't very good.
 
  • Agree
Reactions: Free4Ever
but it's a managed str, and well then one day the function just won't return - and it'll be end of program for you. It's happened to real people, it will happen again, all bets are off in managed string territory.
if i understand that right the runtime constraint violation handler whatever thing is essentially a handler for potential undefined behavior and you shouldn't encounter it unless things get fucky, right? so i could give that a pass.
however this entire spec is still fucking cursed for all the other reasons youve mentioned.

>this function may or may not set errno, i dunno lmao, depends on how its feeling on a given day
>managed strings can still be null lol fuck you
>how to check if it isnt null:
>1. check if the pointer isnt null
>2. prepare a bool variable
>3. call the isnull_m function, pass the string ptr and the bool ptr
>4. now you have the res--LOL NO GOTTA CHECK ERRNO FIRST, you know, what if the null check fails??
>4.1. if your implementation chooses not to set errno, good luck faggot
>5. now you know if your "managed string" is really a string or not
>6. time to read the 200 page law book to learn how to address the string, maybe even copy it if youre really brave

im a cnile myself and i want to shoot my brains out reading that
 
The whole on-the-fly width conversion (in everyone's favorite locale, "I Dunno Whatever") seems a little squirrelly to me too. Particularly since it, too, can fail.
 
  • Like
Reactions: Kuroyuri
The whole on-the-fly width conversion (in everyone's favorite locale, "I Dunno Whatever") seems a little squirrelly to me too. Particularly since it, too, can fail.
I know... it's just... I can't be going back to the coal mines, not this soon!



This is the valgrind coal I found yesterday:
Bash:
valgrind --run-libc-freeres=no <bin>
This site gets into it for a bit, before assuming glibc to be "le standard universities should strive for":
 
  • Informative
Reactions: Kuroyuri
GIMP sucks now, at least with converting colors to indexed. Colors can look like ass, and dithering can easily make hideous lines. Also, even if an image is already 2 colors (black and white), converting it to an indexed 2 color space can auto-adjust some pixels, making that image look like ass. Worked fine before. Why did the dev team break it?
 
Why did the dev team break it?
probably because they touched unholy nigger demons in the old color management code when updating gimp's internal color space logic and somebody had to make one of those good-enough-for-now temporary quick hacks

it will probably be fixed in gimp 4.19 in 2091 unless you complain enough on the issue tracker and have a patch ready too
 
Pajeet contractor, wrote a django app for something, every function was structured like this
Python:
def saar(bobs, and_, vagene):
    try:
        # ............
        try:
            # ........
        except Exception:
            print("An error occurred")
            return None
        # .........
    except Exception:
        print("An error occurred")
        return None
 
Pajeet contractor, wrote a django app for something, every function was structured like this
Python:
def saar(bobs, and_, vagene):
    try:
        # ............
        try:
            # ........
        except Exception:
            print("An error occurred")
            return None
        # .........
    except Exception:
        print("An error occurred")
        return None
11/10 he needlessly duplicates a bunch of shit, uses a catch-all exception handler, reports absolutely nothing about the exception other than "an error happened while doing the needful good sar", he (presumably?) prints it to stdout instead of stderr, and to cap it all off he proceeds to return null
and we all know that making every function able to return null is a great idea, right?
i bet half his code uses gigantic towers of if statements and the other half doesn't but the inevitable dynamic typing errors don't matter because they get caught by the catch-all exceptions and get passed as another null which will probably cause anoth...
...
wait did this guy just use exceptions to make exceptions but completely fucked up
I've seen multiple levels of try-catch blocks sort of accrete over time, which is bad enough, but writing it that way from the start is some next-level jeetery.
he found a way that worked for one of the functions he wrote once, and since he doesn't understand anything about what things do or what they are supposed to prevent, by god he's going to cargo cult it into every single thing he ever writes
 
he found a way that worked for one of the functions he wrote once, and since he doesn't understand anything about what things do or what they are supposed to prevent, by god he's going to cargo cult it into every single thing he ever writes
For some reason I can actually hear the Indian national anthem playing right now.
 
The biggest war crime ever committed in programming is the invention of JavaScript. Brendan Eich is permanently hiding in the USA to avoid getting extradited to The Hague so that he can face trial and die in custody awaiting his next hearing like Milosevic did. Having said that: the entire team GNOME development team proliferating JavaScript outside of a web browser deserve to be beaten with an oar until they're unconscious and transported by black ops agents to The Hague to face trial for their crimes against humanity and technology.
 
Back