Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

251–260 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#251
This reminds me of the original RuneScape codebase. It's a 16k line God class, with some utility classes for networking and graphics. Decompiled code floats around on the web under the name "runescape 317 deob" if you want to check it out.

it's a real "beauty" and hacking around in it to create bots was my first experience with programming.

Edit here it is: https://github.com/Rabrg/refactored-client/blob/master/src/c...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#252
post #220
post #210

Earlier quoted context omitted.

And for the problem of insufficient performance.

Cache are a level of indirection and they increase performance.

Some problems of insufficient performance can be solved by layers of indirection, but not all. The original quote quantifies over all problems:

> "Any problem in computer science can be solved with another layer of indirection"

Otherwise, good point – I did not think of this.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#254
post #63

Earlier quoted context omitted.

I disagree. I inherited an app that I'm maintaining that was written by one person over ~12 years. When requirements were added, he just cloned the app and started making the changes so the new app would meet the requirements. Repeat 2 more times, and you get to now, where there are 4 similar but not identical versions of the same code base, with inconsistently applied fixes to various bugs. All 4 still need to work…

I'd say one person over ~12 years is basically multiple developers working on it. I look back on code after a couple months and it often feels like someone else wrote it.

git blame regret: "who wrote this crap?...oh, right, I did"

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#255

                    if (left) {
                        if (right) {
                            if (up) {
                                if (down) {
                                    blockds[y][x] = 0;
                                }
                                else {
                                    if (upleft) {
                                        if (upright) {
                                            blockds[y][x] = 1;
                                        }
                                        else {
                                            blockds[y][x] = 2;
                                        }
                                    }
                                    else {
                                        if (upright) {
                                            blockds[y][x] = 3;
                                        }
                                        else {
                                            blockds[y][x] = 4;
                                        }
                                    }
                                }
                            }
                            else {
                                if (down) {
                                    if (downright) {
                                        if (downleft) {
                                            blockds[y][x] = 5;
                                        }
                                        else {
                                            blockds[y][x] = 6;
                                        }
                                    }
                                    else {
                                        if (downleft) {
                                            blockds[y][x] = 7;
                                        }
                                        else {
                                            blockds[y][x] = 8;
                                        }
                                    }
                                }
                                else {
                                    blockds[y][x] = 9;
                                }
                            }
                        }
                        else {
                            if (up) {
                                if (down) {
                                    if (downleft) {
                                        if (upleft) {
                                            blockds[y][x] = 10;
                                        }
                                        else {
                                            blockds[y][x] = 11;
                                        }
                                    }
                                    else {
                                        if (upleft) {
                                            blockds[y][x] = 12;
                                        }
                                        else {
                                            blockds[y][x] = 13;
                                        }
                                    }
                                }
                                else {
                                    if (upleft) {
                                        blockds[y][x] = 14;
                                    }
                                    else {
                                        blockds[y][x] = 15;
                                    }
                                }
                            }
                            else {
                                if (down) {
                                    if (downleft) {
                                        blockds[y][x] = 16;
                                    }
                                    else {
                                        blockds[y][x] = 17;
                                    }
                                }
                                else {
                                    blockds[y][x] = 18;
                                }
                            }
                        }
                    }
                    else {
                        if (right) {
                            if (up) {
                                if (down) {
                                    if (upright) {
                                        if (downright) {
                                            blockds[y][x] = 19;
                                        }
                                        else {
                                            blockds[y][x] = 20;
                                        }
                                    }
                                    else {
                                        if (downright) {
                                            blockds[y][x] = 21;
                                        }
                                        else {
                                            blockds[y][x] = 22;
                                        }
                                    }
                                }
                                else {
                                    if (upright) {
                                        blockds[y][x] = 23;
                                    }
                                    else {
                                        blockds[y][x] = 24;
                                    }
                                }
                            }
                            else {
                                if (down) {
                                    if (downright) {
                                        blockds[y][x] = 25;
                                    }
                                    else {
                                        blockds[y][x] = 26;
                                    }
                                }
                                else {
                                    blockds[y][x] = 27;
                                }
                            }
                        }
                        else {
                            if (up) {
                                if (down) {
                                    blockds[y][x] = 28;
                                }
                                else {
                                    blockds[y][x] = 29;
                                }
                            }
                            else {
                                if (down) {
                                    blockds[y][x] = 30;
                                }
                                else {
                                    blockds[y][x] = 31;
                                }
                            }
                        }
                    }

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#256

I have an implementation of Minecraft I'm pretty proud of: https://truecraft.io However, it is the evolution of several much more embarassing projects. In order from oldest to newest: https://libminecraft.codeplex.com/ https://github.com/sircmpwn/Craft.Net https://github.com/SirCmpwn/PartyCraft https://github.com/SirCmpwn/TrueCraft I still hate the client code of TrueCraft and it's due to be ripped out and rewritten…

So I see you everywhere on HN. You usually have the not-so-consensus opinion that I usually agree with. First off, so we have a baseline. I never thought to check your profile and look for projects or blogs or anything. But wow, you have written some super neat things I had no idea about. Though apart from just posting to comment praise, more to the topic, I love seeing developer's old work when they were new. It's a…

Thanks for the kind words :)

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#258
post #237

Earlier quoted context omitted.

The trouble is that in closely cooperating teams where I worked, people who did what you suggest ended up in submissive position against people who just do their thing ignoring others. If I proactive think about others and you don't, you get to work however you like it oftentimes making my work more difficult - while I am more restricted and have harder time to make my ideas reality.

What you describe doesn't really sound like a "closely cooperating" team.

I meant team without clear responsibilities and "turfs" supposed to work together :). Clear reasonable responsibilities are an awesome thing and kill whole bunch of insecurities and resulting behavior.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#259

Earlier quoted context omitted.

Wouldn’t “else if {“ and “else { if” compile to identical bytecode?

It does and at least the current dotPeek 2017.2.2 decompiles it to else if and does, other than I thought, not allow to customize it.

Obviously whatever decompiler was used here decided to do it the other way.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#260
post #198

Earlier quoted context omitted.

Wouldn’t “else if {“ and “else { if” compile to identical bytecode?

Sure, but the decompiler can choose to always decompile to "else if {", which is more readable and more likely to match the original source code.

That's my point. The compiler's choice of "else if {" or "else { if" is unrelated to the programmer's choice.
Post reply on HN