Search titles only. Search Advanced search…. New posts. Search forums. Log in. Install the app. More info here. Report bugs here. There are lines of block comments at the top of TerraFrame. We Terraria modders had no such thing, so the table must be made manually or rather, we used some code to generate it.
Some methods exist such as Item. SetDefaults to give an Item's fields not properties, but raw fields the desired values. Note that it uses if without else or return , drastically slowing it down, but it got changed to a switch in 1. More on SetDefaults later. Terraria entities also have a netID , which slightly differs from their type : entities with the same type have the same texture, but they can have differing netIDs. The latter defines the actual properties max life, damage, Thus, separate netDefaults methods exist as well So as to avoid needing to declare local variables and loop indices, all of the variables for everything are declared globally at the class level.
Here is one of the several hundred lines of declarations in TerraFrame. Terraria didn't do this, but the compiler mangled the variable names enough, and the combination with huge methods and the usage of next to no non-primitive types resulted in lots of occurrences of locals called num etc. Although there are a few other classes, the bulk of the code is in the God Class TerraFrame , which spans over 6, lines of code. This is nothing compared to Main , spanning several 10 s of lines of code.
The TerraFrame. The solution? Copy half of the init code into a new method, called codeTooLarge , and call that from init. The compiler manages to live with extremely huge methods, but the decompiler chokes on them. I don't know anything about the compilation of the original source code side of things, but some badness might happen there as well.
SetDefaults is one of them, and it is split in 4! This was done by the dev team. If this wasn't the case, we the modders would have to fix the binary using Mono. AI , WorldGen. As of 1. This does happen, however, when loading textures ingame Those were all over the place, especially for tiles which didn't even have a SetDefaults method.
This only got worse in 1. Over 1, lines of filling globally declared HashMaps and ArrayLists with magic numbers and strings one by one. Map data, localised strings, FillRecipes or something like that, my memory is a bit hazy is the absolute worst in this regard. The control flow is so labyrinthine that some of the code is actually indented by 23 tabs. This is commonplace. AI , Player. ItemCheck , Projectile. Update , WorldGen. It's written in C with XNA.
Kay-free View Profile View Posts. Originally posted by kidsfreej. Since they don't have C support. Tal View Profile View Posts. Originally posted by WWW :. Originally posted by Talvysh :. Juan View Profile View Posts. This is a very popular approach, taken by most games that support modding. You don't have to support modding to use a scripting language, but most moddable games support modding through a scripting language. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. What language should I write my 2D game in? Asked 9 years, 11 months ago.
Active 9 years, 11 months ago.
0コメント