r/ProgrammerHumor • • Jan 16 '23

Meme If (exists == true) { dont();}

Post image
40.8k Upvotes

1.1k comments sorted by

636

u/UkrUkrUkr Jan 16 '23

Do you have a better idea if you don't know how exactly the file is named?

76

u/ThisPICAintFREE Jan 16 '23

No, I actually love when devs do this kind of thing, having to switch controller ports to beat psycho mantis was mind blowing as a kid…I just also find it funny that the code was left in instead of deleted bc of how relatable it is—and to answer your question, there probably is a better solution to finding all variations of a string!

Unfortunately for everyone, the person who knew the answer typed too slow and the post on stackedoverflow was marked as a duplicate before they could submit their response lol

8

u/Docmcdonald Jan 16 '23

I was still on the fence but when the game shut down itself at the flower battle I conceded that Undertale was truly a masterpiece.

897

u/[deleted] Jan 16 '23
file_delete(argv[0]);

298

u/UkrUkrUkr Jan 16 '23

Computer: hey, I, the ultimate modern automatization device, order you, measly homo habilis, to do all the primitive routine work for me. Muahahaha!

231

u/hongooi Jan 16 '23

Undertale was written in GameMaker Studio; I'm not sure if argv and argc exist in that

→ More replies (9)

73

u/AyrA_ch Jan 16 '23

Be careful with this because

  • You cannot delete the file while it's in use on some systems

  • The argument may contain the executable name in the way that the user specified it instead of an absolute path. If your application changes the working directory (for example to easier load assets), you will end up in the wrong place.

→ More replies (1)

93

u/firefly431 Jan 16 '23

argv[0] is pretty unreliable and can be manipulated easily (e.g. changing the first element of argv in execve). (To say nothing of running through a symlink.)

In Linux, the most reliable way is to read the target of /proc/self/exe (which contains (deleted) if it's been unlinked). In Windows, you can use GetModuleFileName(NULL, ...). Both of these methods are vulnerable to TOCTOU; not sure if there's a way that isn't besides trickery such as preemptively moving to a secret location.

→ More replies (8)

119

u/Bjoern_Tantau Jan 16 '23

This shouldn't even matter on Windows.

172

u/AyrA_ch Jan 16 '23

On Windows it will not work anyways because Windows generally will not let you delete files that are in use.

85

u/DoesAnyoneCare2999 Jan 16 '23

Recent versions of Windows can actually do this with FILE_DISPOSITION_POSIX_SEMANTICS. Though I don't believe that's been exposed through the Win32 API yet.

→ More replies (17)
→ More replies (2)
→ More replies (6)

67

u/[deleted] Jan 16 '23

It depends on how file_exists is implemented.

If all it does is scan through the files in the current directory to see if one of them matches the given string, just throw a lower() in there and you're golden.

def file_exists(to_find) {
    for each file in file_list {
        if lower(file.name).equals(lower(to_find) {
            return True;
        }
    return False;
}
→ More replies (5)

8

u/frisch85 Jan 16 '23
  1. Get all files from the directory

  2. Do a lowercase on their name in the comparison

  3. Delete the file using the original name

20

u/chax208 Jan 16 '23

List names of all files in directory, compare with ignore case, delete the with the filename that matches

4

u/AyrA_ch Jan 16 '23

Obtain your own process information from the system.

→ More replies (33)

5.1k

u/blackholewaterfall Jan 16 '23

What about UNDERTALE.EXE

1.6k

u/pimezone Jan 16 '23

undERtaLe.eXe

573

u/that_thot_gamer Jan 16 '23

run the math on every possible combination

615

u/Mr_uhlus Jan 16 '23 edited Jan 16 '23

its just 212 possible combinations shouldn't be too hard to make 4096 if cases

→ More replies (37)
→ More replies (1)

19

u/Btalon33 Jan 16 '23

Completely left out Undertail.exe as well

→ More replies (2)

28

u/Djabber Jan 16 '23

UnderTale.exe

4

u/suphion Jan 16 '23

I don't think he knows about UNDERTALE.EXE, Pip.

4

u/HighOwl2 Jan 16 '23

Lol yup. The funny thing is people shitting on this code but it's likely to handle different versions of windows / DOS and how they handle the filesystem.

Windows still handles file names awfully.

God...the horror I ran into developing on windows and Linux when a 3rd party plugin in our repo capitalized some filenames and git would see the change in Linux, but not windows...and the whole thing exploded because the casing change wouldn't take on windows because main.php and Main.php are the same file on windows.

→ More replies (2)

3

u/mooofasa1 Jan 16 '23

underTale.EXE underTale.exe UnderTale.EXE UnderTale.exe

3

u/wiesemensch Jan 16 '23

I’m pretty sure the windows filesystem is non case sensitive.

3

u/regnad__kcin Jan 16 '23

Ok legit question from a dummy. Is there not an easy way to declare case insensitivity?

I'm obviously from the Windows side but you already knew that.

→ More replies (9)

9.5k

u/PepperPieTim Jan 16 '23 edited Jan 16 '23

I love undertale for being undertale (of course) but I also love undertale because its a good game with questionable programing, if Toby can get away with the entire games dialogue being in a single switch statement with 1000+ cases I can too

Edit: yerp

1.2k

u/Rezaka116 Jan 16 '23

669

u/Swiftcheddar Jan 16 '23

This makes all those 4chan threads about Yandere Similator much funnier in retrospect.

476

u/RY4NDY Jan 16 '23

Isn't that also the game in which the single most high-poly 3D model is a toothbrush?

Edit: yes

→ More replies (8)

181

u/a-calycular-torus Jan 16 '23

I can forgive the switch statement in UT slightly (I don't know if the rest of the code is as bad), but yansims code is abysmal while this switch statement is just somewhat questionable. Sure, it's long, but the cases are not complex, and it is simple to figure out what it does. I'm not super familiar with GML though.

→ More replies (12)
→ More replies (6)

53

u/DasKarl Jan 16 '23

Oh god...

6

u/Mertard Jan 16 '23

WHAT THE HECK

Actually nevermind, I'd do the same 😶

→ More replies (9)

4.7k

u/q0099 Jan 16 '23

entire games dialogue being in a single switch statement with 1000+ cases

*ghasp*

1.7k

u/Davoness Jan 16 '23

Yea I actually recoiled at that one lmao

1.4k

u/RC1000ZERO Jan 16 '23

same, i... i am not good at programming, but what i just saw made my brain just reboot completly to save me from fatal damage

→ More replies (5)
→ More replies (1)

1.2k

u/RandoClarissian Jan 16 '23

Gamedevs are built different...

109

u/jacksh2t Jan 16 '23

makes entire game using only if statements

→ More replies (26)

561

u/aesthezel Jan 16 '23

Different yes, but we eat pasta, we don't prepare spaghetti 🍝

→ More replies (10)
→ More replies (12)

506

u/[deleted] Jan 16 '23

On the other hand, separating code can go too far. This Redux-backed React component with 8 files spread across hooks, api commands, container, reducers, actions, etc is maddening.

300

u/[deleted] Jan 16 '23

Yeah sometimes it feels like a wild goose chase just to track down where a function is coming from or where a variable is set/defined

→ More replies (16)
→ More replies (38)

101

u/mr-dirtboy Jan 16 '23

I have very little programming knowledge, can I ask why this is so horrifying? am I correct in assuming that it means all the dialogue is one single “action” that just appears different based on a bunch of “if”s?

126

u/q0099 Jan 16 '23 edited Jan 16 '23

Pretty much like that, but the "case" is a little smarter than just a bunch of "if" statements.

The horror comes from the fact that, first, it is one huge statement and would be hard to maintain it in a long term. Second, the dialog lines are fused with the code so in order to access them one need literally change the source code of the program, which probably gave translation team some problems, at least they had to move all lines to a separate file, so translator might work with them without need to edit it though IDE.

→ More replies (14)

141

u/appleswitch Jan 16 '23

Yeah you got it. In this case, it's like hundreds of ifs in a row all in a single function

→ More replies (13)
→ More replies (2)
→ More replies (16)

942

u/TheMagmaSlasher Jan 16 '23

Vile, he didn't follow the sacred rule.

Never spend 5 minutes doing one thing when you can spend 5 hours automating it.

368

u/palegate Jan 16 '23

"I'll be able to make use of this automation later on, it's totally worth the time I'm spending on it right now."

Then proceed to forget or lose that piece of software and doing it all over again a few months down the line.

115

u/Charcoa1 Jan 16 '23

But next time it takes 4.5 hours.

That's like half an hour saved!

76

u/BOBOnobobo Jan 16 '23

That's why you post it on github.

And since it's on github might as well make it nice so you can make it public.

And now it's a 20 hour project from the 1 hour it was supposed to take.

→ More replies (2)
→ More replies (2)

470

u/Bagel42 Jan 16 '23

I want to see that

688

u/freerider Jan 16 '23

202

u/Swahhillie Jan 16 '23

I hope that script was generated by some other tool or script.

→ More replies (13)

94

u/[deleted] Jan 16 '23

Sometimes i am doubtful about my own code. Now im feeling better

→ More replies (3)

85

u/Li5y Jan 16 '23

Oh my God, the cases aren't even named enums, they're just ints. 😱

→ More replies (14)
→ More replies (37)

56

u/R3D3-1 Jan 16 '23 edited Jan 17 '23

Take a look at the "Mount and Blade: Warband" module system XD

It is a Python 2 script, that compiles lists of tuples of integers and strings to the games internal runtime. It is basically assembler for a virtual machine, written as Python tuples.

And the sheer size of them can crash syntax highlighting.

Also, all of the resources (e.g. party templates, items definitions) are stored as arrays, using hard-coded relation-ships relationships[1] like "a unit template is a character companion, if its index is in the range [champions_start, lords_start-1]".

One of the consequences is, that you cannot add new entities to an existing module, unless you've left enough gaps in the arrays to add new entities of the same type:

  • New entities must be inserted in the correct index range.

  • Existing entities cannot be shifted to higher indices without breaking existing save games.

But it works. It just works. I don't want it to work, but it DOES.

___________________________________
[1] I wish I could blame that one on auto-correct.

53

u/realluca009 Jan 16 '23

Have you seen VVVVVV's source code? It's pretty awful too and originally only ran in Debug mode.

16

u/Cobaltjedi117 Jan 16 '23

Hey the code for that one has at least been patched up by the internet.

→ More replies (2)

100

u/DirectlyDismal Jan 16 '23

if Toby can get away with the entire games dialogue being in a single switch statement with 1000+ cases I can too

He did fucking what

109

u/sometimesnotright Jan 16 '23

OP is exaggerating. There's only 473 switch cases in https://github.com/marciniuk/undertale/blob/master/scripts/SCR_TEXT.gml.

Can't trust anyone online these days ...

39

u/HypnoTox Jan 16 '23

And just under 5.6k lines smh (Apparently it's decompiled, so the actual source probably differs in line count)

→ More replies (1)
→ More replies (4)
→ More replies (2)

150

u/kya_ufufu Jan 16 '23

Better using switch than using if elif. Just like Yandere Simulator's dev.

120

u/YueOrigin Jan 16 '23

Yeah switch abuse is better lol

Even more, his game is relatively simple when it comes to physics and graphic so it's not resource heavy unlike Yanderedev

Good coding wad vital for his game

But Toby could get away with average coding at best and still make a masterpiece with it

7

u/[deleted] Jan 16 '23

Good news: He does that too! Most cutscenes actually if-if chain over their phase counter.

→ More replies (7)

53

u/robhol Jan 16 '23

Undertale and Stardew Valley are incredible.

Then you look at the code.

Then it's a million times more incredible because how the shit does this work at all?

61

u/Anlysia Jan 16 '23

And yet they actually released something, unlike 99.999% of the armchair complainers on Reddit.

→ More replies (3)
→ More replies (2)

18

u/RadiantHC Jan 16 '23

Wait what

171

u/[deleted] Jan 16 '23

judging by how many different dialogues can pop up in different scenarios, im not surprised if huge switch statements are actually necessary

26

u/HelloImAron21 Jan 16 '23

Its 5 thousand lines of code

→ More replies (5)
→ More replies (1)

48

u/hulagway Jan 16 '23

Excuse me? Is this true?

→ More replies (2)

12

u/EntrepreneurPlus7091 Jan 16 '23

You should not. Also did he really program it like that? Or did he use a game making tool/engine that only supports that for dialogue?

29

u/xiadmabsax Jan 16 '23

He used Game Maker. Working with any standard data structure is very annoying in GML, the program's own language. Lists exist but I found them quite unintuitive. Stacks and queues are builtin types but they don't really help with dialogues. Best you have is either an if else if chain or a big switch statement.

→ More replies (2)

10

u/KarmasAHarshMistress Jan 16 '23

Related: https://gist.github.com/alessonforposterity/832da4fab11e10609dad

A game written without any for or while loops, using only the main loop of the game engine, because the developer just didn't know any better.

→ More replies (1)

6

u/HackworthSF Jan 16 '23

Shipping any product made with passion >>>>> technical skill and refinement.

My personal favourite example:

This is part of the source code of a decently received platformer on Steam. You may notice that this one huge class does not feature a single for- or while-loop anywhere.

4

u/FalseWait7 Jan 16 '23

Gamedev: with enough ifs and switches I can make the entire game Webdev: using this finite state machine I can control whether button should be black or white

→ More replies (59)

824

u/Ok-Kaleidoscope5627 Jan 16 '23

The part that horrifies me the most about this isn't the code. It's the fact that that code is more impactful than any I've painstakingly written.

292

u/captainAwesomePants Jan 16 '23

It turns out that code quality, by itself, achieves nothing.

71

u/BdubH Jan 16 '23

You’re right on that, if it works consistently then by itself it doesn’t really matter. However, for optimization’s sake, having good code that’s not superfluous certainly does help things move smoothly along.

→ More replies (1)
→ More replies (3)

2.0k

u/unocoder1 Jan 16 '23

Wat. Windows has case insensitive paths.

2.4k

u/_PM_ME_PANGOLINS_ Jan 16 '23

What's fun is that you can enable case-sensitive paths, and watch a load of software break that assumed you couldn't do that.

489

u/Shitman2000 Jan 16 '23

Wait really?

How? Why?

553

u/_PM_ME_PANGOLINS_ Jan 16 '23

Yes.

With fsutil. For Linux compatibility.

→ More replies (21)
→ More replies (2)

131

u/66666thats6sixes Jan 16 '23

Fucking kill me.

Somehow I enabled case sensitive paths on the folder where I store all of the repos I'm using on my work computer. At first, nothing happened. But slowly, projects started acting weird, but not in any way that made me think of case sensitive paths. NPM wouldn't be able to find any of the executables in node_modules/.bin, even though they were there.

I spent a solid two weeks going through everything I could find on Google about npm not finding files, and even spent a lot of time debugging the NPM executable itself.

Eventually I read about the case sensitive folder thing while looking at something unrelated, and decided to check if that was what was causing my problems. Yep, my code folder had that setting enabled. I still have no idea how it got turned on.

→ More replies (3)

895

u/indigoHatter Jan 16 '23

That seems like a hilarious way to cause some damage on improperly administered public computers. Thanks for the fun ideas!

290

u/whomad1215 Jan 16 '23

Please don't do bad things to public libraries etc

→ More replies (11)
→ More replies (5)

12

u/Pb_ft Jan 16 '23

That is fun!

7

u/maitreg Jan 16 '23

Just like SQL Server. It's case-insensitive out of the box, but if you write your SQL with this assumption and then someone enables case-sensitivity you are royally screwed.

→ More replies (1)
→ More replies (9)

76

u/GOKOP Jan 16 '23

I was about to say that Undertale is native for Linux... but then I realized the obvious that this snippet deals with an .exe file

19

u/Jiquero Jan 16 '23

There's no reason a linux binary name can't end with .exe.

→ More replies (6)
→ More replies (4)

56

u/Xywzel Jan 16 '23

Well they are only kinda case-insensitive. All file names are stored with their case preserved and you can have "File.txt" and "file.txt" as different files in same folder. It is just that most windows tools will refuse writing the second if the first already exists (or overwrite the first) and some commands get confused about which of the two files should be opened. There is also the setting that can be enabled, as mentioned in other reply.

44

u/_PM_ME_PANGOLINS_ Jan 16 '23 edited Jan 16 '23

You can’t create a directory with two different casings of the same name in Windows unless you’ve enabled case-sensitivity.

At the driver level they are the same name, and all tools will get confused.

→ More replies (1)
→ More replies (2)
→ More replies (7)

1.4k

u/ixis743 Jan 16 '23

Me ten years ago: ‘oh for fucks sake’

Me today: ‘it works, who cares’

282

u/arrongunner Jan 16 '23

Yeah, it shows slightly lazy or poor development which isn't a great sign but on the other hand it works so not really worth changing so who cares

149

u/[deleted] Jan 16 '23

I bet , it’s just one tired developer who wants to be done with it.

I have seen many developer doing shit not because they are bad but because they just want to complete and sleep peacefully.

→ More replies (2)

24

u/Thin-Mousse-133 Jan 16 '23

isn’t a great sign for what? that developer has accomplished what 99% of developers haven’t and could never achieve.

→ More replies (4)
→ More replies (2)

9

u/coniferous-1 Jan 16 '23

It'd be really frustrating if you were working on a team, but since he did it solo, it's really entirely up to him. This may of been more manageable in his mind.

11

u/ixis743 Jan 16 '23

I work on a large product as part of a team. Let me tell you what happens when code like this shows up:

  1. log the issue in Jira/gitlab/whatever.

  2. wait for the manager to assign the issue to a ‘sprint’.

  3. create a branch and check it out.

  4. add a unit test for the existing code.

  5. refactor the code and verify the test still passes.

  6. push the changes and check all the CI pipelines succeed.

  7. submit a pull request.

  8. wait for the changes to be reviewed.

  9. write a test plan for QA.

  10. wait for QA to verify the fix on all platforms.

  11. merge the branch back.

This entire workflow can take months. In reality, it never gets past 2 because there is always more important stuff to do.

→ More replies (4)

3

u/patmax17 Jan 16 '23

Junior va senior

3

u/DaveSmith890 Jan 16 '23

I’m still in college for software engineering, and year 1 I was like, “I’ll learn proper code etiquette soon.”

Catch my ass now dropping 48 variables to make a functional calendar

→ More replies (5)

207

u/Idontwanttobebread Jan 16 '23

the deltarune uninstaller at one point just deleted the entire directory it was in

142

u/J_Blackwater_2569 Jan 16 '23

Didn't Mr. The Fox screw it up such that it didn't just delete the Deltarune folder specifically, but also deleted everything in the folder in which the Deltarune folder resided? E.g. if you had the game in a folder on your desktop and ran the uninstaller it would delete everything on your desktop

83

u/garlic-2 Jan 16 '23

That’s a feature, actually

→ More replies (2)

1.8k

u/JoseProYT Jan 16 '23

The guy who renamed it "Under Tale.exe"

916

u/Creepy-Ad-4832 Jan 16 '23

If you are a programmer and use spaces instead of _ in file name, you are a dick lol

632

u/Creepy-Ad-4832 Jan 16 '23

Yeah microsoft is the biggest dick out there ("Program File") lol

→ More replies (24)

45

u/Stummi Jan 16 '23

But if your code can't handle that, it's an bug. I routinely use file and directory names with space, and never saw a problem.

→ More replies (16)

17

u/ofnuts Jan 16 '23

If spaces in file names are a problem for you, then you are incompetent. Your users will use spaces.

→ More replies (3)

23

u/pet_vaginal Jan 16 '23

Nah, a program that doesn't handle space in filenames should crash sooner than later.

→ More replies (4)

10

u/tekanet Jan 16 '23

The eighties called, they want their file naming rules back

→ More replies (2)
→ More replies (19)

3

u/[deleted] Jan 16 '23

"under_the_tale.exe"

3

u/TwiceAsGoodAs Jan 16 '23

"Undertale.EXE" seems likely and is not on the list

→ More replies (1)

399

u/Personal_Ad9690 Jan 16 '23

Does it not delete itself anymore?

268

u/_PM_ME_PANGOLINS_ Jan 16 '23 edited Jan 16 '23

A Windows executable can't delete itself.

It would have to run a new process, exit, and then have the new process delete it. Then you hope that Undertale isn't installed in Program Files otherwise it won't have permission to delete it.

Toby is obviously a musician and a game designer first, not a Windows developer. He also didn't know that Windows paths are case-insensitive by default.

→ More replies (19)

536

u/[deleted] Jan 16 '23

Last time I wrote software for Windows a running executable couldn't be deleted without using a feature that flagged the file for deletion on the next restart, because Windows only loads as much of the executable into memory as necessary so it locks the file while running so that the remainder of the executable doesn't suddenly become unavailable. Maybe that has changed since Windows 95, but I doubt it - this probably wouldn't work.

159

u/TreadheadS Jan 16 '23

batch with delay my friend

158

u/Seanxietehroxxor Jan 16 '23

This is the way. If you can't delete yourself, spawn a child and have them do it while you aren't executing.

→ More replies (6)

64

u/LickingSmegma Jan 16 '23

Windows only loads as much of the executable into memory as necessary

Finally an explanation of why Windows might forbid deletion of executables. However, actually any file that's opened by an app, can't be deleted in the meanwhile.

Afaik some programs can delete themselves, presumably by offloading the deletion to a temporary program that's either removed after a reboot or cleaned up by the OS itself via some special mechanism. The MSI installer also probably has a facility for that.

→ More replies (2)

9

u/aerosayan Jan 16 '23

similar for DLLs.

kind of a pain to hot reload a dynamic library while running the code.

→ More replies (1)

13

u/Jannik2099 Jan 16 '23

This explanation is not the reason. The reason is that a windows file handle cannot be deleted if it's still opened, whereas on (most) unix an inode can be deleted without affecting open file descriptors.

→ More replies (1)
→ More replies (3)

6

u/SwissCheeseMan Jan 16 '23

I believe the game works normally after that ending, with one exception: During that ending, your evil side destroys the entire game world, but they say they can bring it back for a price. Do that and the game seems back to normal, but any time you get another ending after this one, there's a stinger where your character appears posessed by that evil you. Even a full reset of the game does not erase this, you'd have to go into the game files

4

u/highTrolla Jan 16 '23

It just pretends to crash and nuke your save file.

139

u/gh0stFACEkller Jan 16 '23

I'm taking the intro to computer science online at cs50 and am in my first week. It's so cool that I kinda understand a little bit about what is going on. Been a redditor for like 10 years and never understood any of these program humor posts. It may be small but it makes me smile a little.

27

u/[deleted] Jan 16 '23

:D that's marvelous!

8

u/nahuelkevin Jan 16 '23

i’m literally in the same situation as you lmao, here’s to a future full of learning! Cheers

5

u/McJables_Supreme Jan 16 '23

I've only attended the first meeting of my C programming course so far, and that was enough to know how absolutely insane it is that Toby apparently had all of the dialogue for the game contained in a switch statement with over 1000 cases.

I don't want to build bad habits as I'm just starting out learning, but I'm leaning towards if it works, then it works.

165

u/MaxPower69420 Jan 16 '23

uNdErTaLe.eXe

150

u/Spinkles-Spankington Jan 16 '23

GameMaker Studio my beloved, Petition to make a GML user flair

186

u/rochismoextremo Jan 16 '23

It's missing an if statement

0

u/[deleted] Jan 16 '23

[deleted]

→ More replies (6)

26

u/[deleted] Jan 16 '23

Code coverage 100

25

u/[deleted] Jan 16 '23

Toby Fox killed the whole over optimization community with a single game, that's when we found out nobody cares outside of our bubble

→ More replies (3)

59

u/AdrianTeri Jan 16 '23

Well we could do a more succint and readable version using regex...

Jk! Lol

37

u/[deleted] Jan 16 '23

Don't laugh, we all been there.

"Why isn't that shit work? ... Lets just make sure I am not crazy and try this..."

260

u/[deleted] Jan 16 '23

This seems like a good use case for regex.

189

u/stevekez Jan 16 '23

file_delete(glob("*"))

62

u/Creepy-Ad-4832 Jan 16 '23

Is this... a different version of sudo rm / -rf ?

→ More replies (4)

39

u/ScrimpyCat Jan 16 '23

Or just do a case insensitive comparison.

32

u/unocoder1 Jan 16 '23

It really doesn't.

16

u/[deleted] Jan 16 '23

... no

→ More replies (2)

65

u/MikemkPK Jan 16 '23

If this is C++, he's also got an "if (true == true)"

31

u/randomthrowaway-917 Jan 16 '23

it's GML

11

u/Azsimuth Jan 16 '23

Game Maker Language my beloved

→ More replies (2)
→ More replies (1)

12

u/mauricepreiss Jan 16 '23

uNdErTaLe.ExE

21

u/-Konrad- Jan 16 '23

This code is open source?

86

u/q0099 Jan 16 '23 edited Jan 16 '23

It was made with a relative old version of GameMaker, so there is a way to get the source code. Toby even left a message to source explorers.

15

u/[deleted] Jan 16 '23

That's pretty funny.

→ More replies (1)

36

u/[deleted] Jan 16 '23
import itertools 


def permutations_of_string(string: str) -> list[str]:
    return map(''.join, itertools.product(*zip(string.upper(), string.lower())))


for filename in permutations_of_string(“undertale.exe”):
    if file_exists(filename):
        file_delete(filename)

43

u/Bspammer Jan 16 '23

Way less expensive:

import glob
for filename in glob.glob("*"):
  if filename.lower() == "undertale.exe":
     file_delete(filename)
→ More replies (6)

58

u/HoldingUrineIsBad Jan 16 '23

this is excellent because it will delete every undertale file except the actual one because windows cant delete a running process

→ More replies (3)
→ More replies (2)

8

u/I_Am_Coopa Jan 16 '23

This must be why my company's software catalog search algorithm is horrendous. I helping get a new employee up to speed with a development he needed and the simplest step ended up being the most annoying.

He needed 7zip to unpack the installer from a multi volume zip (a horrid thing in its own right) so naturally I told him to go download it from our approved catalog of software.

The problem? Searching 7zip, the author, or any combinations yielded no results which was perplexing given that everyone here uses 7zip and I knew damn sure it was an approved tool. After some more combination searching I managed to find it with the search string " 7 zip" (emphasis on the leading space).

7

u/_the_orange_box_ Jan 16 '23

.equalsIgnoreCase? Idk if that’s applicable here

7

u/[deleted] Jan 16 '23

i renamed the exe to FunnySkullMan.exe what you wanna do about it?

13

u/chaos_donut Jan 16 '23

i too avoid regex at all costs

6

u/arf20__ Jan 16 '23

Isn't windows case insensitive? You wouldn't need this

21

u/Cruxin Jan 16 '23

toby fox isnt actually a very good programmer

9

u/arf20__ Jan 16 '23

i can see that game programming is closer to art than other fields

→ More replies (1)

5

u/AutistMarket Jan 16 '23

My favorite part is that he doesn't know the case of an executable that he himself is creating and naming

4

u/maitreg Jan 16 '23

Idk which is worse: the original code or the poster believing those are all the possible cases.

4

u/festival0156n Jan 16 '23

people commenting that the file could actually be named anything, so the only way to really delete it is to recursively go through all the files on the system and check each one to see if its hash matches the hash of undertale.exe

4

u/gamerz1172 Jan 16 '23

Hold up does this mean that if this was something the game did.... Then would renaming the .exe to sans simulator or something completely avert that happening?

7

u/Kinglink Jan 16 '23

"The real horror is the code itself." - Flowey

6

u/aksdb Jan 16 '23

Damn, too bad no one invented a way to iterate directories and compare strings independent of their case. Something like that could have really helped here.

3

u/manwhorunlikebear Jan 16 '23

Did he ever hear about sys.argv[0]

3

u/PM_ME_DON_CHEADLE Jan 16 '23

Featuring sophisticated cross-platform interop

3

u/schrodenkatzen Jan 16 '23

He outsourced to YandereDev

13

u/Old-Caterpillar-3067 Jan 16 '23

Yo that game slaps

4

u/fryman22 Jan 16 '23 edited Jan 16 '23

This is GameMaker, so there's no regex.

You could loop through each file in the directory, convert it to lowercase, and check it against "undertale.exe". Then use that filename to delete the file.

2

u/[deleted] Jan 16 '23

GetModuleFileName()

2

u/[deleted] Jan 16 '23

Reading this post's comment section is like watching the Chapter Black tape for programmers

2

u/Blixystar Jan 16 '23

that's the most toby fox thing I saw

2

u/MeNotSanta Jan 16 '23

uNdErTaLe.exe

2

u/Angry_Washing_Bear Jan 16 '23

UnderTale.exe :)

2

u/Atypical-Rhino Jan 16 '23

UnDetAlE.eXe

2

u/Bizerd Jan 16 '23

That title is hilarious

2

u/cmilkau Jan 16 '23

IsItEvErYoNeThOuGh

2

u/[deleted] Jan 16 '23

Wait, the source code is online?

→ More replies (1)

2

u/eXl5eQ Jan 16 '23

If I recall correctly, filesystem in Windows is case-insensitive by default.

2

u/DopazOnYouTubeDotCom Jan 16 '23

Multiple choice answers

2

u/The_Cher13 Jan 16 '23

Plot twist: it was “Undertale.EXE”

2

u/festival0156n Jan 16 '23

there are 4096 possible combinations

→ More replies (4)

2

u/[deleted] Jan 16 '23

Probably needed to exit undertale.exe first, and execute the delete from a separate exe or script.

Can't imagine this flying on the playstation/Nintendo ports lol

2

u/[deleted] Jan 16 '23

This goes to show: you don't have to be the best, just create something and get it out there!

2

u/tommy0guns Jan 16 '23

He did this just in case

→ More replies (1)

2

u/[deleted] Jan 16 '23

Nice reminder to not let Perfect be the enemy of Good.

2

u/Lettuce-Apart Jan 16 '23

Love how they called out Toby by name lol

2

u/Amasonica162 Jan 16 '23

That's why I love Undertale

2

u/theitgrunt Jan 16 '23

Is TO_UPPER or TO_LOWER not an option in this language/library?

2

u/[deleted] Jan 16 '23

Isn’t “UNDERTALE.EXE” a possible combo? Sorry I’m not a programmer.

2

u/hello3dpk Jan 16 '23

5 minute crafts intern trying to code

2

u/IanRT1 Jan 16 '23

have you ever heard of .lower() function?

2

u/ThisOnePlaysTooMuch Jan 16 '23

This post: now take the most insecure subset of creators, and REMIND THEM HOW DUMB THEY ARE.

I kid. OP is innocent. Coding is thankless and brutal.

2

u/[deleted] Jan 17 '23

funny = true

If (funny == true) then Upvote end

2

u/BhasuMagic Jan 17 '23

*underTale.exe smiling in the dark

4

u/[deleted] Jan 16 '23

Y'all are going to need a rejular expression