modular_tannhauser/readme.md
Basically follow skyrat directions but Relabel to Tannhauser-Gate or Sea of Lost Souls as apropriate instead The modularization handbook - Skyrat style, v0.1Failure to follow this guide will result in your PR being denied. IntroductionTo develop and maintain a separate codebase is a big task, that many have failed and suffered the consequences of, such as outdated, and messy code. It's not necessarily the fault of lack of skill of the people maintaining it, merely the lack of resources and how much continuous effort such an endeavor takes. One of the solutions for such, is to base our server on a solid codebase, that is primarily maintained by somebody else, in this case tgstation, and insert our content in a modular fashion, while following the general direction of the upstream, mirroring any changes they do for parity. Git, as a version control system, is very useful, however it is just a very methodical thing, that follows its many algorithms, that sadly cannot always intelligently resolve certain changes in the code in an unambiguous way, giving us conflicts, that need to be resolved in a manual fashion. Due to maintainability being one of the main reasons behind our rebase to another codebase, this protocol will seriously be enforced. A well organized, documented and atomized code saves our maintainers a lot of headache, when being reviewed. Don't dump on them the work that you could have done yourself. This document is meant to be updated and changed, whenever any new exceptions are added onto it. It might be worth it to check, from time to time, whether we didn't define a more unique standardized way of handling some common change. The nature of conflictsFor example, let's have an original
in the core code, that we decide to change from 1 to 2 on our end,
but then our upstream introduces a change in their codebase, changing it from 1 to 4
As easy of an example as it is, it results in a relatively simple conflict, in the form of
where we pick the preferable option manually. The solutionThat is something that cannot and likely shouldn't be resolved automatically, because it might introduce errors and bugs that will be very hard to track down, not to even bring up more complex examples of conflicts, such as ones that involve changes that add, remove and move lines of code all over the place. tl;dr it tries its best but ultimately is just a dumb program, therefore, we must ourselves do work to ensure that it can do most of the work, while minimizing the effort spent on manual involvement, in the cases where the conflicts will be inevitable. Our answer to this is modularization of the code. Modularization means, that most of the changes and additions we do, will be kept in a separate The modularization protocolAlways start by thinking of the theme/purpose of your work. It's oftentimes a good idea to see if there isn't an already existing one, that you should append to. If it's a tgcode-specific tweak or bugfix, first course of action should be an attempt to discuss and PR it upstream, instead of needlessly modularizing it here. Otherwise, pick a new ID for your module. E.g. And then you'll want to establish your core folder that you'll be working out of which is normally your module ID. E.g. MapsThe major station maps have their equivalents in the same folder as the originals, but with their filename having a If you wanted to add some location to the CentCom z-level, a'la whatever off-station location that isn't meant to be reachable or escapable through normal means, we have our own separate z-level, in If you plan to edit space ruins and so on, currently, it should be discussed with a maintainer and likely should be PRed upstream, to tgstation repository. Assets: images, sounds, icons and binariesGit doesn't handle conflicts of binary files well at all, therefore changes to core binary files are absolutely forbidden, unless you have a really really really good reason to do otherwise. All assets added by us should be placed into the same modular folder as your code. This means everything is kept inside your module folder, sounds, icons and code files.
Fully modular portions of your codeThis section will be fairly straightforward, however, I will try to go over the basics and give simple examples, as the guide is aimed at new contributors likewise. The rule of thumb is that if you don't absolutely have to, you shouldn't make any changes to core codebase files. In short, most of the modular code will be placed in the subfolders of your main module folder Such modules, unless very simple, need to have a
Template:
Each such feature/content set should be considered a separate module, and each of its files should be marked with an uppercase comment
Important:
Note, that it is possible to append code in front, or behind a core proc, in a modular fashion, without editing the original proc, through referring the parent proc, using To keep it simple, let's assume you wanted to make guns spark when shot, for simulating muzzle flash or whatever other reasons, and you want potentially to use it with all kinds of guns. You could start, in a modular file, by adding a var
And it will work just fine. Afterwards, let's say you want to check that var and spawn your sparks after firing a shot. Knowing the original proc being called by shooting is
you can define a child proc for it, that will get inserted into the inheritance chain of the related procs (big words, but in simple cases like this, you don't need to worry)
And that wraps the basics of it up. Non-modular changes to the core code - IMPORTANTEvery once in a while, there comes a time, where editing the core files becomes inevitable. Please be sure to log these in the module readme.dm. Any file changes. In those cases, we've decided to apply the following convention, with examples:
Exceptional cases of modular codeFrom every rule, there's exceptions, due to many circumstances. Don't think about it too much. DefinesDue to the way byond loads files, it has become necessary to make a different folder for handling our modular defines.
That folder is Exemplary PR'sHere are a couple PR's that are great examples of the guide being followed, reference them if you are stuck: AfterwordIt might seem like a lot to take in, but if we remain consistent, it will save us a lot of headache in the long run, once we start having to resolve conflicts manually. Thanks to a bit more scrupulous documentation, it will be immediately obvious what changes were done and where and by which features, things will be a lot less ambiguous and messy. Best of luck in your coding. Remember that the community is there for you, if you ever need help. |