Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

1–10 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#3
The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1...

They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#4

The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1... They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.

I just scrolled to the bottom and all I see is } } } } } } } } } } } } } } } } } } } } } } } } } } } } } }

What the fuck

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#5

The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1... They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.

Wow, I just glanced at the how they're generating random names and it's incomprehensible. What a bizarre way to do something rather simple.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#6

The real Terraria code isn't much better. Here's their 3MB [decompiled] NPC.cs: https://raw.githubusercontent.com/csnxs/Terraria/67de21a27e1... They had serious problems implementing multiplayer because they had to synchronize objects with 50KB of state every frame.

Surely this file can't be edited by humans as is, right?

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#7
That actually doesn't look too bad to me. Sure, it's verbose, repetitive, and deeply nested, but just from skimming it, it looks quite comprehensible. Load all the data from files instead of filling huge arrays and maps in code, abstract similar code into methods, tame the usual mess when dealing with grids with some helper functions taking care of clamping or wrapping around coordinates, replace all the parallel arrays with structures, and you should be able to have some reasonable good code in no time. Might be a nice exercise in refactoring.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#10
post #9

I love DoubleContainer: https://github.com/raxod502/TerrariaClone/blob/master/src/Do... which is fortunately only used in a comment here: https://github.com/raxod502/TerrariaClone/blob/9ea04b15add48...

I'm sure there was a good reason for that.
Post reply on HN