- Joined
- Aug 1, 2017
Terraria 1.0 had zero concept of prototypes and implemented all of its items via two massive functions, one to create the item (including setting all of its properties piecewise) and another to implement the action performed when the item was used. These were both absolutely gigantic switch statements, IIRC 1800+ lines each, and each switch was on a numeric ID.Just a reminder, if you think those case statements as the beginning of video 2 are bad. I'll remind people that the entirety of Undertale's dialogue is written in a single case statement that goes for 3,000 lines.
Very little in regards to functionality, extreme problems in regards to maintainability. There are lots of code generators that'll generate huge switches and such like that at compile time and they're not considered 'bad' because you never actually edit the code they emit, you just regenerate it from your source files which are completely authoritative. In Undertale's case changing an NPC or any given message would mean updating the function in every single locale (since there's gotta be a copy of it for each language).As someone who knows very little about modern programming, what issues does this cause?
For comparison's sake, a game I worked on handled this by having unique entity names and localization files per scene, so interactions would just pull the conversation from the current locale dictionary by the entity's name. The locale files were each baked from a spreadsheet with a column for each language and the importer script that read the spreadsheet and emitted locale dictionaries would complain if it found lines that weren't tied to an entity in that scene or vice versa. Made the whole thing very easy to maintain and validate and since all the localization was handled per-scene entity names could be very descriptive (eg 'left_exit_sign') since they only applied to that scene instead of the entire game.