mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-09 16:07:40 +00:00
fixes
This commit is contained in:
108
.github/AUTODOC_GUIDE.md
vendored
Normal file
108
.github/AUTODOC_GUIDE.md
vendored
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
# dmdoc
|
||||||
|
[DOCUMENTATION]: http://codedocs.tgstation13.org
|
||||||
|
|
||||||
|
[BYOND]: https://secure.byond.com/
|
||||||
|
|
||||||
|
[DMDOC]: https://github.com/SpaceManiac/SpacemanDMM/tree/master/src/dmdoc
|
||||||
|
|
||||||
|
[DMDOC] is a documentation generator for DreamMaker, the scripting language
|
||||||
|
of the [BYOND] game engine. It produces simple static HTML files based on
|
||||||
|
documented files, macros, types, procs, and vars.
|
||||||
|
|
||||||
|
We use **dmdoc** to generate [DOCUMENTATION] for our code, and that documentation
|
||||||
|
is automatically generated and built on every new commit to the master branch
|
||||||
|
|
||||||
|
This gives new developers a clickable reference [DOCUMENTATION] they can browse to better help
|
||||||
|
gain understanding of the /tg/station codebase structure and api reference.
|
||||||
|
|
||||||
|
## Documenting code on /tg/station
|
||||||
|
We use block comments to document procs and classes, and we use `///` line comments
|
||||||
|
when documenting individual variables.
|
||||||
|
|
||||||
|
It is required that all new code be covered with DMdoc code, according to the [Requirements](#Required)
|
||||||
|
|
||||||
|
We also require that when you touch older code, you must document the functions that you
|
||||||
|
have touched in the process of updating that code
|
||||||
|
|
||||||
|
### Required
|
||||||
|
A class *must* always be autodocumented, and all public functions *must* be documented
|
||||||
|
|
||||||
|
All class level defined variables *must* be documented
|
||||||
|
|
||||||
|
Internal functions *should* be documented, but may not be
|
||||||
|
|
||||||
|
A public function is any function that a developer might reasonably call while using
|
||||||
|
or interacting with your object. Internal functions are helper functions that your
|
||||||
|
public functions rely on to implement logic
|
||||||
|
|
||||||
|
|
||||||
|
### Documenting a proc
|
||||||
|
When documenting a proc, we give a short one line description (as this is shown
|
||||||
|
next to the proc definition in the list of all procs for a type or global
|
||||||
|
namespace), then a longer paragraph which will be shown when the user clicks on
|
||||||
|
the proc to jump to it's definition
|
||||||
|
```
|
||||||
|
/**
|
||||||
|
* Short description of the proc
|
||||||
|
*
|
||||||
|
* Longer detailed paragraph about the proc
|
||||||
|
* including any relevant detail
|
||||||
|
* Arguments:
|
||||||
|
* * arg1 - Relevance of this argument
|
||||||
|
* * arg2 - Relevance of this argument
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documenting a class
|
||||||
|
We first give the name of the class as a header, this can be omitted if the name is
|
||||||
|
just going to be the typepath of the class, as dmdoc uses that by default
|
||||||
|
|
||||||
|
Then we give a short oneline description of the class
|
||||||
|
|
||||||
|
Finally we give a longer multi paragraph description of the class and it's details
|
||||||
|
```
|
||||||
|
/**
|
||||||
|
* # Classname (Can be omitted if it's just going to be the typepath)
|
||||||
|
*
|
||||||
|
* The short overview
|
||||||
|
*
|
||||||
|
* A longer
|
||||||
|
* paragraph of functionality about the class
|
||||||
|
* including any assumptions/special cases
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Documenting a variable/define
|
||||||
|
Give a short explanation of what the variable, in the context of the class, or define is.
|
||||||
|
```
|
||||||
|
/// Type path of item to go in suit slot
|
||||||
|
var/suit = null
|
||||||
|
```
|
||||||
|
|
||||||
|
## Module level description of code
|
||||||
|
Modules are the best way to describe the structure/intent of a package of code
|
||||||
|
where you don't want to be tied to the formal layout of the class structure.
|
||||||
|
|
||||||
|
On /tg/station we do this by adding markdown files inside the `code` directory
|
||||||
|
that will also be rendered and added to the modules tree. The structure for
|
||||||
|
these is deliberately not defined, so you can be as freeform and as wheeling as
|
||||||
|
you would like.
|
||||||
|
|
||||||
|
[Here is a representative example of what you might write](http://codedocs.tgstation13.org/code/modules/keybindings/readme.html)
|
||||||
|
|
||||||
|
## Special variables
|
||||||
|
You can use certain special template variables in DM DOC comments and they will be expanded
|
||||||
|
```
|
||||||
|
[DEFINE_NAME] - Expands to a link to the define definition if documented
|
||||||
|
[/mob] - Expands to a link to the docs for the /mob class
|
||||||
|
[/mob/proc/Dizzy] - Expands to a link that will take you to the /mob class and anchor you to the dizzy proc docs
|
||||||
|
[/mob/var/stat] - Expands to a link that will take you to the /mob class and anchor you to the stat var docs
|
||||||
|
```
|
||||||
|
|
||||||
|
You can customise the link name by using `[link name][link shorthand].`
|
||||||
|
|
||||||
|
eg. `[see more about dizzy here] [/mob/proc/Dizzy]`
|
||||||
|
|
||||||
|
This is very useful to quickly link to other parts of the autodoc code to expand
|
||||||
|
upon a comment made, or reasoning about code
|
||||||
435
.github/CONTRIBUTING.md
vendored
435
.github/CONTRIBUTING.md
vendored
@@ -1,8 +1,29 @@
|
|||||||
# CONTRIBUTING
|
# CONTRIBUTING
|
||||||
|
|
||||||
## Reporting Issues
|
1. [Reporting Issues](#reporting-issues)
|
||||||
|
2. [Introduction](#introduction)
|
||||||
|
3. [Getting Started](#getting-started)
|
||||||
|
4. [Meet the Team](#meet-the-team)
|
||||||
|
1. [Headcoder](#headcoder)
|
||||||
|
2. [Maintainers](#maintainers)
|
||||||
|
3. [Issue Managers](#issue-managers)
|
||||||
|
5. [Specifications](#specifications)
|
||||||
|
6. [Pull Request Process](#pull-request-process)
|
||||||
|
7. [Porting features/sprites/sounds/tools from other codebases](#porting-featuresspritessoundstools-from-other-codebases)
|
||||||
|
8. [Banned content](#banned-content)
|
||||||
|
9. [A word on Git](#a-word-on-git)
|
||||||
|
|
||||||
See [this page](http://tgstation13.org/wiki/Reporting_Issues) for a guide and format to issue reports.
|
## Reporting Issues
|
||||||
|
If you ever encounter a bug in-game, the best way to let a coder know about it is with our GitHub Issue Tracker. Please make sure you use the supplied issue template, and include the round ID for the server.
|
||||||
|
|
||||||
|
(If you don't have an account, making a new one takes only one minute.)
|
||||||
|
|
||||||
|
If you have difficulty, ask for help in the #coding-general channel on our discord.
|
||||||
|
|
||||||
|
## Citadel Station 13
|
||||||
|
Notice: We are currently using a near-copy of /tg/station's CONTRIBUTING.md file. Keep in mind which codebase you are on.
|
||||||
|
Any questions regarding help for development/spriting/coding/etc should go on #development-discussion-main on our discord.
|
||||||
|
https://discord.gg/fkVVfVH48n
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
@@ -15,35 +36,63 @@ First things first, we want to make it clear how you can contribute (if you've n
|
|||||||
/tg/station doesn't have a list of goals and features to add; we instead allow freedom for contributors to suggest and create their ideas for the game. That doesn't mean we aren't determined to squash bugs, which unfortunately pop up a lot due to the deep complexity of the game. Here are some useful starting guides, if you want to contribute or if you want to know what challenges you can tackle with zero knowledge about the game's code structure.
|
/tg/station doesn't have a list of goals and features to add; we instead allow freedom for contributors to suggest and create their ideas for the game. That doesn't mean we aren't determined to squash bugs, which unfortunately pop up a lot due to the deep complexity of the game. Here are some useful starting guides, if you want to contribute or if you want to know what challenges you can tackle with zero knowledge about the game's code structure.
|
||||||
|
|
||||||
If you want to contribute the first thing you'll need to do is [set up Git](http://tgstation13.org/wiki/Setting_up_git) so you can download the source code.
|
If you want to contribute the first thing you'll need to do is [set up Git](http://tgstation13.org/wiki/Setting_up_git) so you can download the source code.
|
||||||
|
After setting it up, optionally navigate your git commandline to the project folder and run the command: `git config blame.ignoreRevsFile .git-blame-ignore-revs`.
|
||||||
|
|
||||||
We have a [list of guides on the wiki](http://www.tgstation13.org/wiki/index.php/Guides#Development_and_Contribution_Guides) that will help you get started contributing to /tg/station with Git and Dream Maker. For beginners, it is recommended you work on small projects like bugfixes at first. If you need help learning to program in BYOND, check out this [repository of resources](http://www.byond.com/developer/articles/resources).
|
We have a [list of guides on the wiki](http://www.tgstation13.org/wiki/Guides#Development_and_Contribution_Guides) that will help you get started contributing to /tg/station with Git and Dream Maker. For beginners, it is recommended you work on small projects like bugfixes at first. If you need help learning to program in BYOND, check out this [repository of resources](http://www.byond.com/developer/articles/resources).
|
||||||
|
|
||||||
There is an open list of approachable issues for [your inspiration here](https://github.com/tgstation/-tg-station/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22).
|
There is an open list of approachable issues for [your inspiration here](https://github.com/Citadel-Station-13/Citadel-Station-13/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22).
|
||||||
|
|
||||||
You can of course, as always, ask for help at [#coderbus](irc://irc.rizon.net/coderbus) on irc.rizon.net. We're just here to have fun and help out, so please don't expect professional support.
|
You can of course, as always, ask for help on the Discord channels or the forums. We're just here to have fun and help out, so please don't expect professional support.
|
||||||
|
|
||||||
## Meet the Team
|
## Meet the Team
|
||||||
|
|
||||||
**Design Lead**
|
### Headcoder
|
||||||
|
|
||||||
The Design Lead has the final say on what gameplay changes get into and out of the game. He or she has full veto power on any feature or balance additions, changes, or removals, and establishes a general, personally-preferred direction for the game.
|
|
||||||
|
|
||||||
**Headcoder**
|
|
||||||
|
|
||||||
The Headcoder is responsible for controlling, adding, and removing maintainers from the project. In addition to filling the role of a normal maintainer, they have sole authority on who becomes a maintainer, as well as who remains a maintainer and who does not.
|
The Headcoder is responsible for controlling, adding, and removing maintainers from the project. In addition to filling the role of a normal maintainer, they have sole authority on who becomes a maintainer, as well as who remains a maintainer and who does not.
|
||||||
|
|
||||||
**Art Director**
|
### Maintainers
|
||||||
|
|
||||||
The Art Director controls sprites and aesthetic that get into the game. While sprites for brand-new additions are generally accepted regardless of quality, modified current art assets fall to the Art Director, who can decide whether or not a sprite tweak is both merited and a suitable replacement.
|
|
||||||
|
|
||||||
They also control the general "perspective" of the game - how sprites should generally look, especially the angle from which they're viewed. An example of this is the [3/4 perspective](http://static.tvtropes.org/pmwiki/pub/images/kakarikovillage.gif), which is a bird's eye view from above the object being viewed.
|
|
||||||
|
|
||||||
**Maintainers**
|
|
||||||
|
|
||||||
Maintainers are quality control. If a proposed pull request doesn't meet the following specifications, they can request you to change it, or simply just close the pull request. Maintainers are required to give a reason for closing the pull request.
|
Maintainers are quality control. If a proposed pull request doesn't meet the following specifications, they can request you to change it, or simply just close the pull request. Maintainers are required to give a reason for closing the pull request.
|
||||||
|
|
||||||
Maintainers can revert your changes if they feel they are not worth maintaining or if they did not live up to the quality specifications.
|
Maintainers can revert your changes if they feel they are not worth maintaining or if they did not live up to the quality specifications.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Maintainer Guidelines</summary>
|
||||||
|
|
||||||
|
These are the few directives we have for project maintainers.
|
||||||
|
|
||||||
|
- Do not merge PRs you create.
|
||||||
|
- Do not merge PRs until 24 hours have passed since it was opened. Exceptions include:
|
||||||
|
- Emergency fixes.
|
||||||
|
- Try to get secondary maintainer approval before merging if you are able to.
|
||||||
|
- PRs with empty commits intended to generate a changelog.
|
||||||
|
- Do not merge PRs that contain content from the [banned content list](./CONTRIBUTING.md#banned-content).
|
||||||
|
|
||||||
|
These are not steadfast rules as maintainers are expected to use their best judgement when operating.
|
||||||
|
|
||||||
|
Our team is entirely voluntary, as such we extend our thanks to maintainers, issue managers, and contributors alike for helping keep the project alive.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Issue Managers
|
||||||
|
|
||||||
|
Issue Managers help out the project by labelling bug reports and PRs and closing bug reports which are duplicates or are no longer applicable.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>What You Can and Can't Do as an Issue Manager</summary>
|
||||||
|
|
||||||
|
This should help you understand what you can and can't do with your newfound github permissions.
|
||||||
|
|
||||||
|
Things you **CAN** do:
|
||||||
|
* Label issues appropriately
|
||||||
|
* Close issues when appropriate
|
||||||
|
* Label PRs when appropriate
|
||||||
|
|
||||||
|
Things you **CAN'T** do:
|
||||||
|
* [Close PRs](https://imgur.com/w2RqpX8.png): Only maintainers are allowed to close PRs. Do not hit that button.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
## Specifications
|
## Specifications
|
||||||
|
|
||||||
As mentioned before, you are expected to follow these specifications in order to make everyone's lives easier. It'll save both your time and ours, by making sure you don't have to make any changes and we don't have to ask you to. Thank you for reading this section!
|
As mentioned before, you are expected to follow these specifications in order to make everyone's lives easier. It'll save both your time and ours, by making sure you don't have to make any changes and we don't have to ask you to. Thank you for reading this section!
|
||||||
@@ -57,6 +106,7 @@ As BYOND's Dream Maker (henceforth "DM") is an object-oriented language, code mu
|
|||||||
DM will allow you nest almost any type keyword into a block, such as:
|
DM will allow you nest almost any type keyword into a block, such as:
|
||||||
|
|
||||||
```DM
|
```DM
|
||||||
|
// Not our style!
|
||||||
datum
|
datum
|
||||||
datum1
|
datum1
|
||||||
var
|
var
|
||||||
@@ -77,7 +127,7 @@ datum
|
|||||||
proc3()
|
proc3()
|
||||||
code
|
code
|
||||||
proc2()
|
proc2()
|
||||||
..()
|
. = ..()
|
||||||
code
|
code
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -86,6 +136,7 @@ The use of this is not allowed in this project as it makes finding definitions v
|
|||||||
The previous code made compliant:
|
The previous code made compliant:
|
||||||
|
|
||||||
```DM
|
```DM
|
||||||
|
// Matches /tg/station style.
|
||||||
/datum/datum1
|
/datum/datum1
|
||||||
var/varname1
|
var/varname1
|
||||||
var/varname2
|
var/varname2
|
||||||
@@ -101,18 +152,50 @@ The previous code made compliant:
|
|||||||
/datum/datum1/datum2/proc/proc3()
|
/datum/datum1/datum2/proc/proc3()
|
||||||
code
|
code
|
||||||
/datum/datum1/datum2/proc2()
|
/datum/datum1/datum2/proc2()
|
||||||
..()
|
. = ..()
|
||||||
code
|
code
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### All `process` procs need to make use of delta-time and be frame independent
|
||||||
|
|
||||||
|
In a lot of our older code, `process()` is frame dependent. Here's some example mob code:
|
||||||
|
|
||||||
|
```DM
|
||||||
|
/mob/testmob
|
||||||
|
var/health = 100
|
||||||
|
var/health_loss = 4 //We want to lose 2 health per second, so 4 per SSmobs process
|
||||||
|
|
||||||
|
/mob/testmob/process(delta_time) //SSmobs runs once every 2 seconds
|
||||||
|
health -= health_loss
|
||||||
|
```
|
||||||
|
|
||||||
|
As the mobs subsystem runs once every 2 seconds, the mob now loses 4 health every process, or 2 health per second. This is called frame dependent programming.
|
||||||
|
|
||||||
|
Why is this an issue? If someone decides to make it so the mobs subsystem processes once every second (2 times as fast), your effects in process() will also be two times as fast. Resulting in 4 health loss per second rather than 2.
|
||||||
|
|
||||||
|
How do we solve this? By using delta-time. Delta-time is the amount of seconds you would theoretically have between 2 process() calls. In the case of the mobs subsystem, this would be 2 (As there is 2 seconds between every call in `process()`). Here is a new example using delta-time:
|
||||||
|
|
||||||
|
```DM
|
||||||
|
/mob/testmob
|
||||||
|
var/health = 100
|
||||||
|
var/health_loss = 2 //Health loss every second
|
||||||
|
|
||||||
|
/mob/testmob/process(delta_time) //SSmobs runs once every 2 seconds
|
||||||
|
health -= health_loss * delta_time
|
||||||
|
```
|
||||||
|
|
||||||
|
In the above example, we made our health_loss variable a per second value rather than per process. In the actual process() proc we then make use of deltatime. Because SSmobs runs once every 2 seconds. Delta_time would have a value of 2. This means that by doing health_loss * delta_time, you end up with the correct amount of health_loss per process, but if for some reason the SSmobs subsystem gets changed to be faster or slower in a PR, your health_loss variable will work the same.
|
||||||
|
|
||||||
|
For example, if SSmobs is set to run once every 4 seconds, it would call process once every 4 seconds and multiply your health_loss var by 4 before subtracting it. Ensuring that your code is frame independent.
|
||||||
|
|
||||||
### No overriding type safety checks
|
### No overriding type safety checks
|
||||||
The use of the : operator to override type safety checks is not allowed. You must cast the variable to the proper type.
|
The use of the : operator to override type safety checks is not allowed. You must cast the variable to the proper type.
|
||||||
|
|
||||||
### Type paths must begin with a /
|
### Type paths must begin with a `/`
|
||||||
eg: `/datum/thing`, not `datum/thing`
|
eg: `/datum/thing`, not `datum/thing`
|
||||||
|
|
||||||
### Type paths must be lowercase
|
### Type paths must be snake case
|
||||||
eg: `/datum/thing/blue`, not `datum/thing/BLUE` or `datum/thing/Blue`
|
eg: `/datum/blue_bird`, not `/datum/BLUEBIRD` or `/datum/BlueBird` or `/datum/Bluebird` or `/datum/blueBird`
|
||||||
|
|
||||||
### Datum type paths must began with "datum"
|
### Datum type paths must began with "datum"
|
||||||
In DM, this is optional, but omitting it makes finding definitions harder.
|
In DM, this is optional, but omitting it makes finding definitions harder.
|
||||||
@@ -128,16 +211,28 @@ var/path_type = /obj/item/baseball_bat
|
|||||||
var/path_type = "/obj/item/baseball_bat"
|
var/path_type = "/obj/item/baseball_bat"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use var/name format when declaring variables
|
### Use `var/name` format when declaring variables
|
||||||
While DM allows other ways of declaring variables, this one should be used for consistency.
|
While DM allows other ways of declaring variables, this one should be used for consistency.
|
||||||
|
|
||||||
### Tabs, not spaces
|
### Tabs, not spaces
|
||||||
You must use tabs to indent your code, NOT SPACES.
|
You must use tabs to indent your code, NOT SPACES.
|
||||||
|
|
||||||
(You may use spaces to align something, but you should tab to the block level first, then add the remaining spaces)
|
Do not use tabs/spaces for indentation in the middle of a code line. Not only is this inconsistent because the size of a tab is undefined, but it means that, should the line you're aligning to change size at all, we have to adjust a ton of other code. Plus, it often time hurts readability.
|
||||||
|
|
||||||
|
```dm
|
||||||
|
// Bad
|
||||||
|
#define SPECIES_MOTH "moth"
|
||||||
|
#define SPECIES_LIZARDMAN "lizardman"
|
||||||
|
#define SPECIES_FELINID "felinid"
|
||||||
|
|
||||||
|
// Good
|
||||||
|
#define SPECIES_MOTH "moth"
|
||||||
|
#define SPECIES_LIZARDMAN "lizardman"
|
||||||
|
#define SPECIES_FELINID "felinid"
|
||||||
|
```
|
||||||
|
|
||||||
### No hacky code
|
### No hacky code
|
||||||
Hacky code, such as adding specific checks, is highly discouraged and only allowed when there is ***no*** other option. (Protip: 'I couldn't immediately think of a proper way so thus there must be no other option' is not gonna cut it here! If you can't think of anything else, say that outright and admit that you need help with it. Maintainers exist for exactly that reason.)
|
Hacky code, such as adding specific checks, is highly discouraged and only allowed when there is ***no*** other option. (Protip: "I couldn't immediately think of a proper way so thus there must be no other option" is not gonna cut it here! If you can't think of anything else, say that outright and admit that you need help with it. Maintainers exist for exactly that reason.)
|
||||||
|
|
||||||
You can avoid hacky code by using object-oriented methodologies, such as overriding a function (called "procs" in DM) or sectioning code into functions and then overriding them as required.
|
You can avoid hacky code by using object-oriented methodologies, such as overriding a function (called "procs" in DM) or sectioning code into functions and then overriding them as required.
|
||||||
|
|
||||||
@@ -158,7 +253,7 @@ There are two key points here:
|
|||||||
Remember: although this tradeoff makes sense in many cases, it doesn't cover them all. Think carefully about your addition before deciding if you need to use it.
|
Remember: although this tradeoff makes sense in many cases, it doesn't cover them all. Think carefully about your addition before deciding if you need to use it.
|
||||||
|
|
||||||
### Prefer `Initialize()` over `New()` for atoms
|
### Prefer `Initialize()` over `New()` for atoms
|
||||||
Our game controller is pretty good at handling long operations and lag, but it can't control what happens when the map is loaded, which calls `New` for all atoms on the map. If you're creating a new atom, use the `Initialize` proc to do what you would normally do in `New`. This cuts down on the number of proc calls needed when the world is loaded. See here for details on `Initialize`: https://github.com/tgstation/tgstation/blob/master/code/game/atoms.dm#L49
|
Our game controller is pretty good at handling long operations and lag, but it can't control what happens when the map is loaded, which calls `New` for all atoms on the map. If you're creating a new atom, use the `Initialize` proc to do what you would normally do in `New`. This cuts down on the number of proc calls needed when the world is loaded. See here for details on `Initialize`: https://github.com/tgstation/tgstation/blob/34775d42a2db4e0f6734560baadcfcf5f5540910/code/game/atoms.dm#L166
|
||||||
While we normally encourage (and in some cases, even require) bringing out of date code up to date when you make unrelated changes near the out of date code, that is not the case for `New` -> `Initialize` conversions. These systems are generally more dependant on parent and children procs so unrelated random conversions of existing things can cause bugs that take months to figure out.
|
While we normally encourage (and in some cases, even require) bringing out of date code up to date when you make unrelated changes near the out of date code, that is not the case for `New` -> `Initialize` conversions. These systems are generally more dependant on parent and children procs so unrelated random conversions of existing things can cause bugs that take months to figure out.
|
||||||
|
|
||||||
### No magic numbers or strings
|
### No magic numbers or strings
|
||||||
@@ -187,7 +282,7 @@ This is clearer and enhances readability of your code! Get used to doing it!
|
|||||||
### Control statements
|
### Control statements
|
||||||
(if, while, for, etc)
|
(if, while, for, etc)
|
||||||
|
|
||||||
* All control statements must not contain code on the same line as the statement (`if (blah) return`)
|
* No control statement may contain code on the same line as the statement (`if (blah) return`)
|
||||||
* All control statements comparing a variable to a number should use the formula of `thing` `operator` `number`, not the reverse (eg: `if (count <= 10)` not `if (10 >= count)`)
|
* All control statements comparing a variable to a number should use the formula of `thing` `operator` `number`, not the reverse (eg: `if (count <= 10)` not `if (10 >= count)`)
|
||||||
|
|
||||||
### Use early return
|
### Use early return
|
||||||
@@ -213,6 +308,97 @@ This is good:
|
|||||||
````
|
````
|
||||||
This prevents nesting levels from getting deeper then they need to be.
|
This prevents nesting levels from getting deeper then they need to be.
|
||||||
|
|
||||||
|
### Use our time defines
|
||||||
|
|
||||||
|
The codebase contains some defines which will automatically multiply a number by the correct amount to get a number in deciseconds. Using these is preffered over using a literal amount in deciseconds.
|
||||||
|
|
||||||
|
The defines are as follows:
|
||||||
|
* SECONDS
|
||||||
|
* MINUTES
|
||||||
|
* HOURS
|
||||||
|
|
||||||
|
This is bad:
|
||||||
|
````DM
|
||||||
|
/datum/datum1/proc/proc1()
|
||||||
|
if(do_after(mob, 15))
|
||||||
|
mob.dothing()
|
||||||
|
````
|
||||||
|
|
||||||
|
This is good:
|
||||||
|
````DM
|
||||||
|
/datum/datum1/proc/proc1()
|
||||||
|
if(do_after(mob, 1.5 SECONDS))
|
||||||
|
mob.dothing()
|
||||||
|
````
|
||||||
|
|
||||||
|
### Getters and setters
|
||||||
|
|
||||||
|
* Avoid getter procs. They are useful tools in languages with that properly enforce variable privacy and encapsulation, but DM is not one of them. The upfront cost in proc overhead is met with no benefits, and it may tempt to develop worse code.
|
||||||
|
|
||||||
|
This is bad:
|
||||||
|
```DM
|
||||||
|
/datum/datum1/proc/simple_getter()
|
||||||
|
return gotten_variable
|
||||||
|
```
|
||||||
|
Prefer to either access the variable directly or use a macro/define.
|
||||||
|
|
||||||
|
|
||||||
|
* Make usage of variables or traits, set up through condition setters, for a more maintainable alternative to compex and redefined getters.
|
||||||
|
|
||||||
|
These are bad:
|
||||||
|
```DM
|
||||||
|
/datum/datum1/proc/complex_getter()
|
||||||
|
return condition ? VALUE_A : VALUE_B
|
||||||
|
|
||||||
|
/datum/datum1/child_datum/complex_getter()
|
||||||
|
return condition ? VALUE_C : VALUE_D
|
||||||
|
```
|
||||||
|
|
||||||
|
This is good:
|
||||||
|
```DM
|
||||||
|
/datum/datum1
|
||||||
|
var/getter_turned_into_variable
|
||||||
|
|
||||||
|
/datum/datum1/proc/set_condition(new_value)
|
||||||
|
if(condition == new_value)
|
||||||
|
return
|
||||||
|
condition = new_value
|
||||||
|
on_condition_change()
|
||||||
|
|
||||||
|
/datum/datum1/proc/on_condition_change()
|
||||||
|
getter_turned_into_variable = condition ? VALUE_A : VALUE_B
|
||||||
|
|
||||||
|
/datum/datum1/child_datum/on_condition_change()
|
||||||
|
getter_turned_into_variable = condition ? VALUE_C : VALUE_D
|
||||||
|
```
|
||||||
|
|
||||||
|
### Avoid unnecessary type checks and obscuring nulls in lists
|
||||||
|
Typecasting in `for` loops carries an implied `istype()` check that filters non-matching types, nulls included. The `as anything` key can be used to skip the check.
|
||||||
|
|
||||||
|
If we know the list is supposed to only contain the desired type then we want to skip the check not only for the small optimization it offers, but also to catch any null entries that may creep into the list.
|
||||||
|
|
||||||
|
Nulls in lists tend to point to improperly-handled references, making hard deletes hard to debug. Generating a runtime in those cases is more often than not positive.
|
||||||
|
|
||||||
|
This is bad:
|
||||||
|
```DM
|
||||||
|
var/list/bag_of_atoms = list(new /obj, new /mob, new /atom, new /atom/movable, new /atom/movable)
|
||||||
|
var/highest_alpha = 0
|
||||||
|
for(var/atom/thing in bag_of_atoms)
|
||||||
|
if(thing.alpha <= highest_alpha)
|
||||||
|
continue
|
||||||
|
highest_alpha = thing.alpha
|
||||||
|
```
|
||||||
|
|
||||||
|
This is good:
|
||||||
|
```DM
|
||||||
|
var/list/bag_of_atoms = list(new /obj, new /mob, new /atom, new /atom/movable, new /atom/movable)
|
||||||
|
var/highest_alpha = 0
|
||||||
|
for(var/atom/thing as anything in bag_of_atoms)
|
||||||
|
if(thing.alpha <= highest_alpha)
|
||||||
|
continue
|
||||||
|
highest_alpha = thing.alpha
|
||||||
|
```
|
||||||
|
|
||||||
### Develop Secure Code
|
### Develop Secure Code
|
||||||
|
|
||||||
* Player input must always be escaped safely, we recommend you use stripped_input in all cases where you would use input. Essentially, just always treat input from players as inherently malicious and design with that use case in mind
|
* Player input must always be escaped safely, we recommend you use stripped_input in all cases where you would use input. Essentially, just always treat input from players as inherently malicious and design with that use case in mind
|
||||||
@@ -245,15 +431,24 @@ This prevents nesting levels from getting deeper then they need to be.
|
|||||||
|
|
||||||
* Primary keys are inherently immutable and you must never do anything to change the primary key of a row or entity. This includes preserving auto increment numbers of rows when copying data to a table in a conversion script. No amount of bitching about gaps in ids or out of order ids will save you from this policy.
|
* Primary keys are inherently immutable and you must never do anything to change the primary key of a row or entity. This includes preserving auto increment numbers of rows when copying data to a table in a conversion script. No amount of bitching about gaps in ids or out of order ids will save you from this policy.
|
||||||
|
|
||||||
|
* The ttl for data from the database is 10 seconds. You must have a compelling reason to store and reuse data for longer then this.
|
||||||
|
|
||||||
|
* Do not write stored and transformed data to the database, instead, apply the transformation to the data in the database directly.
|
||||||
|
* ie: SELECTing a number from the database, doubling it, then updating the database with the doubled number. If the data in the database changed between step 1 and 3, you'll get an incorrect result. Instead, directly double it in the update query. `UPDATE table SET num = num*2` instead of `UPDATE table SET num = [num]`.
|
||||||
|
* if the transformation is user provided (such as allowing a user to edit a string), you should confirm the value being updated did not change in the database in the intervening time before writing the new user provided data by checking the old value with the current value in the database, and if it has changed, allow the user to decide what to do next.
|
||||||
|
|
||||||
### Mapping Standards
|
### Mapping Standards
|
||||||
|
* Adding, Removing, or Replacing Station Maps
|
||||||
|
* All pull requests adding, removing, or replacing station maps must receive prior approval from a maptainer, or they will be closed without additional warning.
|
||||||
|
|
||||||
* TGM Format & Map Merge
|
* TGM Format & Map Merge
|
||||||
* All new maps submitted to the repo through a pull request must be in TGM format (unless there is a valid reason present to have it in the default BYOND format.) This is done using the [Map Merge](https://github.com/tgstation/tgstation/wiki/Map-Merger) utility included in the repo to convert the file to TGM format.
|
* All new maps submitted to the repo through a pull request must be in TGM format (unless there is a valid reason present to have it in the default BYOND format). This is done using the [Map Merge](https://tgstation13.org/wiki/Map_Merger) utility included in the repo to convert the file to TGM format.
|
||||||
* Likewise, you MUST run Map Merge prior to opening your PR when updating existing maps to minimize the change differences (even when using third party mapping programs such as FastDMM.)
|
* Likewise, you MUST run Map Merge prior to opening your PR when updating existing maps to minimize the change differences (even when using third party mapping programs such as FastDMM.)
|
||||||
* Failure to run Map Merge on a map after using third party mapping programs (such as FastDMM) greatly increases the risk of the map's key dictionary becoming corrupted by future edits after running map merge. Resolving the corruption issue involves rebuilding the map's key dictionary; id est rewriting all the keys contained within the map by reconverting it from BYOND to TGM format - which creates very large differences that ultimately delay the PR process and is extremely likely to cause merge conflicts with other pull requests.
|
* Failure to run Map Merge on a map after using third party mapping programs (such as FastDMM) greatly increases the risk of the map's key dictionary becoming corrupted by future edits after running map merge. Resolving the corruption issue involves rebuilding the map's key dictionary; id est rewriting all the keys contained within the map by reconverting it from BYOND to TGM format - which creates very large differences that ultimately delay the PR process and is extremely likely to cause merge conflicts with other pull requests.
|
||||||
|
|
||||||
* Variable Editing (Var-edits)
|
* Variable Editing (Var-edits)
|
||||||
* While var-editing an item within the editor is perfectly fine, it is preferred that when you are changing the base behavior of an item (how it functions) that you make a new subtype of that item within the code, especially if you plan to use the item in multiple locations on the same map, or across multiple maps. This makes it easier to make corrections as needed to all instances of the item at one time as opposed to having to find each instance of it and change them all individually.
|
* While var-editing an item within the editor is perfectly fine, it is preferred that when you are changing the base behavior of an item (how it functions) that you make a new subtype of that item within the code, especially if you plan to use the item in multiple locations on the same map, or across multiple maps. This makes it easier to make corrections as needed to all instances of the item at one time as opposed to having to find each instance of it and change them all individually.
|
||||||
* Subtypes only intended to be used on away mission or ruin maps should be contained within an .dm file with a name corresponding to that map within `code\modules\awaymissions` or `code\modules\ruins` respectively. This is so in the event that the map is removed, that subtype will be removed at the same time as well to minimize leftover/unused data within the repo.
|
* Subtypes only intended to be used on away mission or ruin maps should be contained within a .dm file with a name corresponding to that map within `code\modules\awaymissions` or `code\modules\ruins` respectively. This is so in the event that the map is removed, that subtype will be removed at the same time as well to minimize leftover/unused data within the repo.
|
||||||
* Please attempt to clean out any dirty variables that may be contained within items you alter through var-editing. For example, due to how DM functions, changing the `pixel_x` variable from 23 to 0 will leave a dirty record in the map's code of `pixel_x = 0`. Likewise this can happen when changing an item's icon to something else and then back. This can lead to some issues where an item's icon has changed within the code, but becomes broken on the map due to it still attempting to use the old entry.
|
* Please attempt to clean out any dirty variables that may be contained within items you alter through var-editing. For example, due to how DM functions, changing the `pixel_x` variable from 23 to 0 will leave a dirty record in the map's code of `pixel_x = 0`. Likewise this can happen when changing an item's icon to something else and then back. This can lead to some issues where an item's icon has changed within the code, but becomes broken on the map due to it still attempting to use the old entry.
|
||||||
* Areas should not be var-edited on a map to change it's name or attributes. All areas of a single type and it's altered instances are considered the same area within the code, and editing their variables on a map can lead to issues with powernets and event subsystems which are difficult to debug.
|
* Areas should not be var-edited on a map to change it's name or attributes. All areas of a single type and it's altered instances are considered the same area within the code, and editing their variables on a map can lead to issues with powernets and event subsystems which are difficult to debug.
|
||||||
|
|
||||||
@@ -264,6 +459,99 @@ This prevents nesting levels from getting deeper then they need to be.
|
|||||||
* [tgui/README.md](../tgui/README.md)
|
* [tgui/README.md](../tgui/README.md)
|
||||||
* [tgui/tutorial-and-examples.md](../tgui/docs/tutorial-and-examples.md)
|
* [tgui/tutorial-and-examples.md](../tgui/docs/tutorial-and-examples.md)
|
||||||
|
|
||||||
|
### Signal Handlers
|
||||||
|
All procs that are registered to listen for signals using `RegisterSignal()` must contain at the start of the proc `SIGNAL_HANDLER` eg;
|
||||||
|
```
|
||||||
|
/type/path/proc/signal_callback()
|
||||||
|
SIGNAL_HANDLER
|
||||||
|
// rest of the code
|
||||||
|
```
|
||||||
|
This is to ensure that it is clear the proc handles signals and turns on a lint to ensure it does not sleep.
|
||||||
|
|
||||||
|
There exists `SIGNAL_HANDLER_DOES_SLEEP`, but this is only for legacy signal handlers that still sleep, new/changed code should not use this.
|
||||||
|
|
||||||
|
### Enforcing parent calling
|
||||||
|
When adding new signals to root level procs, eg;
|
||||||
|
```
|
||||||
|
/atom/proc/setDir(newdir)
|
||||||
|
SHOULD_CALL_PARENT(TRUE)
|
||||||
|
SEND_SIGNAL(src, COMSIG_ATOM_DIR_CHANGE, dir, newdir)
|
||||||
|
dir = newdir
|
||||||
|
```
|
||||||
|
The `SHOULD_CALL_PARENT(TRUE)` lint should be added to ensure that overrides/child procs call the parent chain and ensure the signal is sent.
|
||||||
|
|
||||||
|
### Use descriptive and obvious names
|
||||||
|
Optimize for readability, not writability. While it is certainly easier to write `M` than `victim`, it will cause issues down the line for other developers to figure out what exactly your code is doing, even if you think the variable's purpose is obvious.
|
||||||
|
|
||||||
|
#### Don't use abbreviations
|
||||||
|
Avoid variables like C, M, and H. Prefer names like "user", "victim", "weapon", etc.
|
||||||
|
|
||||||
|
```dm
|
||||||
|
// What is M? The user? The target?
|
||||||
|
// What is A? The target? The item?
|
||||||
|
/proc/use_item(mob/M, atom/A)
|
||||||
|
|
||||||
|
// Much better!
|
||||||
|
/proc/use_item(mob/user, atom/target)
|
||||||
|
```
|
||||||
|
|
||||||
|
Unless it is otherwise obvious, try to avoid just extending variables like "C" to "carbon"--this is slightly more helpful, but does not describe the *context* of the use of the variable.
|
||||||
|
|
||||||
|
#### Naming things when typecasting
|
||||||
|
When typecasting, keep your names descriptive:
|
||||||
|
```dm
|
||||||
|
var/mob/living/living_target = target
|
||||||
|
var/mob/living/carbon/carbon_target = living_target
|
||||||
|
```
|
||||||
|
|
||||||
|
Of course, if you have a variable name that better describes the situation when typecasting, feel free to use it.
|
||||||
|
|
||||||
|
Note that it's okay, semantically, to use the same variable name as the type, e.g.:
|
||||||
|
```dm
|
||||||
|
var/atom/atom
|
||||||
|
var/client/client
|
||||||
|
var/mob/mob
|
||||||
|
```
|
||||||
|
|
||||||
|
Your editor may highlight the variable names, but BYOND, and we, accept these as variable names:
|
||||||
|
|
||||||
|
```dm
|
||||||
|
// This functions properly!
|
||||||
|
var/client/client = CLIENT_FROM_VAR(usr)
|
||||||
|
// vvv this may be highlighted, but it's fine!
|
||||||
|
client << browse(...)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Name things as directly as possible
|
||||||
|
`was_called` is better than `has_been_called`. `notify` is better than `do_notification`.
|
||||||
|
|
||||||
|
#### Avoid negative variable names
|
||||||
|
`is_flying` is better than `is_not_flying`. `late` is better than `not_on_time`.
|
||||||
|
This prevents double-negatives (such as `if (!is_not_flying)` which can make complex checks more difficult to parse.
|
||||||
|
|
||||||
|
#### Exceptions to variable names
|
||||||
|
|
||||||
|
Exceptions can be made in the case of inheriting existing procs, as it makes it so you can use named parameters, but *new* variable names must follow these standards. It is also welcome, and encouraged, to refactor existing procs to use clearer variable names.
|
||||||
|
|
||||||
|
Naming numeral iterator variables `i` is also allowed, but do remember to [Avoid unnecessary type checks and obscuring nulls in lists](#avoid-unnecessary-type-checks-and-obscuring-nulls-in-lists), and making more descriptive variables is always encouraged.
|
||||||
|
|
||||||
|
```dm
|
||||||
|
// Bad
|
||||||
|
for (var/datum/reagent/R as anything in reagents)
|
||||||
|
|
||||||
|
// Good
|
||||||
|
for (var/datum/reagent/deadly_reagent as anything in reagents)
|
||||||
|
|
||||||
|
// Allowed, but still has the potential to not be clear. What does `i` refer to?
|
||||||
|
for (var/i in 1 to 12)
|
||||||
|
|
||||||
|
// Better
|
||||||
|
for (var/month in 1 to 12)
|
||||||
|
|
||||||
|
// Bad, only use `i` for numeral loops
|
||||||
|
for (var/i in reagents)
|
||||||
|
```
|
||||||
|
|
||||||
### Other Notes
|
### Other Notes
|
||||||
* Code should be modular where possible; if you are working on a new addition, then strongly consider putting it in its own file unless it makes sense to put it with similar ones (i.e. a new tool would go in the "tools.dm" file)
|
* Code should be modular where possible; if you are working on a new addition, then strongly consider putting it in its own file unless it makes sense to put it with similar ones (i.e. a new tool would go in the "tools.dm" file)
|
||||||
|
|
||||||
@@ -273,6 +561,8 @@ This prevents nesting levels from getting deeper then they need to be.
|
|||||||
|
|
||||||
* Do not divide when you can easily convert it to multiplication. (ie `4/2` should be done as `4*0.5`)
|
* Do not divide when you can easily convert it to multiplication. (ie `4/2` should be done as `4*0.5`)
|
||||||
|
|
||||||
|
* Separating single lines into more readable blocks is not banned, however you should use it only where it makes new information more accessible, or aids maintainability. We do not have a column limit, and mass conversions will not be received well.
|
||||||
|
|
||||||
* If you used regex to replace code during development of your code, post the regex in your PR for the benefit of future developers and downstream users.
|
* If you used regex to replace code during development of your code, post the regex in your PR for the benefit of future developers and downstream users.
|
||||||
|
|
||||||
* Changes to the `/config` tree must be made in a way that allows for updating server deployments while preserving previous behaviour. This is due to the fact that the config tree is to be considered owned by the user and not necessarily updated alongside the remainder of the code. The code to preserve previous behaviour may be removed at some point in the future given the OK by maintainers.
|
* Changes to the `/config` tree must be made in a way that allows for updating server deployments while preserving previous behaviour. This is due to the fact that the config tree is to be considered owned by the user and not necessarily updated alongside the remainder of the code. The code to preserve previous behaviour may be removed at some point in the future given the OK by maintainers.
|
||||||
@@ -306,77 +596,43 @@ Math operators like +, -, /, *, etc are up in the air, just choose which version
|
|||||||
|
|
||||||
#### Use
|
#### Use
|
||||||
* Bitwise AND - '&'
|
* Bitwise AND - '&'
|
||||||
* Should be written as ```bitfield & bitflag``` NEVER ```bitflag & bitfield```, both are valid, but the latter is confusing and nonstandard.
|
* Should be written as `variable & CONSTANT` NEVER `CONSTANT & variable`. Both are valid, but the latter is confusing and nonstandard.
|
||||||
* Associated lists declarations must have their key value quoted if it's a string
|
* Associated lists declarations must have their key value quoted if it's a string
|
||||||
* WRONG: list(a = "b")
|
* WRONG: `list(a = "b")`
|
||||||
* RIGHT: list("a" = "b")
|
* RIGHT: `list("a" = "b")`
|
||||||
|
|
||||||
### Dream Maker Quirks/Tricks
|
### Dream Maker Quirks/Tricks
|
||||||
Like all languages, Dream Maker has its quirks, some of them are beneficial to us, like these
|
Like all languages, Dream Maker has its quirks, some of them are beneficial to us, like these
|
||||||
|
|
||||||
#### In-To for-loops
|
#### In-To for-loops
|
||||||
```for(var/i = 1, i <= some_value, i++)``` is a fairly standard way to write an incremental for loop in most languages (especially those in the C family), but DM's ```for(var/i in 1 to some_value)``` syntax is oddly faster than its implementation of the former syntax; where possible, it's advised to use DM's syntax. (Note, the ```to``` keyword is inclusive, so it automatically defaults to replacing ```<=```; if you want ```<``` then you should write it as ```1 to some_value-1```).
|
`for(var/i = 1, i <= some_value, i++)` is a fairly standard way to write an incremental for loop in most languages (especially those in the C family), but DM's `for(var/i in 1 to some_value)` syntax is oddly faster than its implementation of the former syntax; where possible, it's advised to use DM's syntax. (Note, the `to` keyword is inclusive, so it automatically defaults to replacing `<=`; if you want `<` then you should write it as `1 to some_value-1`).
|
||||||
|
|
||||||
HOWEVER, if either ```some_value``` or ```i``` changes within the body of the for (underneath the ```for(...)``` header) or if you are looping over a list AND changing the length of the list then you can NOT use this type of for-loop!
|
HOWEVER, if either `some_value` or `i` changes within the body of the for (underneath the `for(...)` header) or if you are looping over a list AND changing the length of the list then you can NOT use this type of for-loop!
|
||||||
|
|
||||||
### for(var/A in list) VS for(var/i in 1 to list.len)
|
#### `for(var/A in list)` versus `for(var/i in 1 to list.len)`
|
||||||
The former is faster than the latter, as shown by the following profile results:
|
The former is faster than the latter, as shown by the following profile results:
|
||||||
https://file.house/zy7H.png
|
https://file.house/zy7H.png
|
||||||
Code used for the test in a readable format:
|
Code used for the test in a readable format:
|
||||||
https://pastebin.com/w50uERkG
|
https://pastebin.com/w50uERkG
|
||||||
|
|
||||||
|
|
||||||
#### Istypeless for loops
|
|
||||||
A name for a differing syntax for writing for-each style loops in DM. It's NOT DM's standard syntax, hence why this is considered a quirk. Take a look at this:
|
|
||||||
```DM
|
|
||||||
var/list/bag_of_items = list(sword, apple, coinpouch, sword, sword)
|
|
||||||
var/obj/item/sword/best_sword
|
|
||||||
for(var/obj/item/sword/S in bag_of_items)
|
|
||||||
if(!best_sword || S.damage > best_sword.damage)
|
|
||||||
best_sword = S
|
|
||||||
```
|
|
||||||
The above is a simple proc for checking all swords in a container and returning the one with the highest damage, and it uses DM's standard syntax for a for-loop by specifying a type in the variable of the for's header that DM interprets as a type to filter by. It performs this filter using ```istype()``` (or some internal-magic similar to ```istype()``` - this is BYOND, after all). This is fine in its current state for ```bag_of_items```, but if ```bag_of_items``` contained ONLY swords, or only SUBTYPES of swords, then the above is inefficient. For example:
|
|
||||||
```DM
|
|
||||||
var/list/bag_of_swords = list(sword, sword, sword, sword)
|
|
||||||
var/obj/item/sword/best_sword
|
|
||||||
for(var/obj/item/sword/S in bag_of_swords)
|
|
||||||
if(!best_sword || S.damage > best_sword.damage)
|
|
||||||
best_sword = S
|
|
||||||
```
|
|
||||||
specifies a type for DM to filter by.
|
|
||||||
|
|
||||||
With the previous example that's perfectly fine, we only want swords, but here the bag only contains swords? Is DM still going to try to filter because we gave it a type to filter by? YES, and here comes the inefficiency. Wherever a list (or other container, such as an atom (in which case you're technically accessing their special contents list, but that's irrelevant)) contains datums of the same datatype or subtypes of the datatype you require for your loop's body,
|
|
||||||
you can circumvent DM's filtering and automatic ```istype()``` checks by writing the loop as such:
|
|
||||||
```DM
|
|
||||||
var/list/bag_of_swords = list(sword, sword, sword, sword)
|
|
||||||
var/obj/item/sword/best_sword
|
|
||||||
for(var/s in bag_of_swords)
|
|
||||||
var/obj/item/sword/S = s
|
|
||||||
if(!best_sword || S.damage > best_sword.damage)
|
|
||||||
best_sword = S
|
|
||||||
```
|
|
||||||
Of course, if the list contains data of a mixed type then the above optimisation is DANGEROUS, as it will blindly typecast all data in the list as the specified type, even if it isn't really that type, causing runtime errors.
|
|
||||||
|
|
||||||
#### Dot variable
|
#### Dot variable
|
||||||
Like other languages in the C family, DM has a ```.``` or "Dot" operator, used for accessing variables/members/functions of an object instance.
|
Like other languages in the C family, DM has a `.` or "Dot" operator, used for accessing variables/members/functions of an object instance.
|
||||||
eg:
|
eg:
|
||||||
```DM
|
```DM
|
||||||
var/mob/living/carbon/human/H = YOU_THE_READER
|
var/mob/living/carbon/human/H = YOU_THE_READER
|
||||||
H.gib()
|
H.gib()
|
||||||
```
|
```
|
||||||
However, DM also has a dot variable, accessed just as ```.``` on its own, defaulting to a value of null. Now, what's special about the dot operator is that it is automatically returned (as in the ```return``` statement) at the end of a proc, provided the proc does not already manually return (```return count``` for example.) Why is this special?
|
However, DM also has a dot variable, accessed just as `.` on its own, defaulting to a value of null. Now, what's special about the dot operator is that it is automatically returned (as in the `return` statement) at the end of a proc, provided the proc does not already manually return (`return count` for example.) Why is this special?
|
||||||
|
|
||||||
With ```.``` being everpresent in every proc, can we use it as a temporary variable? Of course we can! However, the ```.``` operator cannot replace a typecasted variable - it can hold data any other var in DM can, it just can't be accessed as one, although the ```.``` operator is compatible with a few operators that look weird but work perfectly fine, such as: ```.++``` for incrementing ```.'s``` value, or ```.[1]``` for accessing the first element of ```.```, provided that it's a list.
|
With `.` being everpresent in every proc, can we use it as a temporary variable? Of course we can! However, the `.` operator cannot replace a typecasted variable - it can hold data any other var in DM can, it just can't be accessed as one, although the `.` operator is compatible with a few operators that look weird but work perfectly fine, such as: `.++` for incrementing `.'s` value, or `.[1]` for accessing the first element of `.`, provided that it's a list.
|
||||||
|
|
||||||
## Globals versus static
|
### Globals versus static
|
||||||
|
|
||||||
DM has a var keyword, called global. This var keyword is for vars inside of types. For instance:
|
DM has a var keyword, called global. This var keyword is for vars inside of types. For instance:
|
||||||
|
|
||||||
```DM
|
```DM
|
||||||
mob
|
/mob
|
||||||
var
|
var/global/thing = TRUE
|
||||||
global
|
|
||||||
thing = TRUE
|
|
||||||
```
|
```
|
||||||
This does NOT mean that you can access it everywhere like a global var. Instead, it means that that var will only exist once for all instances of its type, in this case that var will only exist once for all mobs - it's shared across everything in its type. (Much more like the keyword `static` in other languages like PHP/C++/C#/Java)
|
This does NOT mean that you can access it everywhere like a global var. Instead, it means that that var will only exist once for all instances of its type, in this case that var will only exist once for all mobs - it's shared across everything in its type. (Much more like the keyword `static` in other languages like PHP/C++/C#/Java)
|
||||||
|
|
||||||
@@ -388,11 +644,13 @@ There is also an undocumented keyword called `static` that has the same behaviou
|
|||||||
|
|
||||||
There is no strict process when it comes to merging pull requests. Pull requests will sometimes take a while before they are looked at by a maintainer; the bigger the change, the more time it will take before they are accepted into the code. Every team member is a volunteer who is giving up their own time to help maintain and contribute, so please be courteous and respectful. Here are some helpful ways to make it easier for you and for the maintainers when making a pull request.
|
There is no strict process when it comes to merging pull requests. Pull requests will sometimes take a while before they are looked at by a maintainer; the bigger the change, the more time it will take before they are accepted into the code. Every team member is a volunteer who is giving up their own time to help maintain and contribute, so please be courteous and respectful. Here are some helpful ways to make it easier for you and for the maintainers when making a pull request.
|
||||||
|
|
||||||
* Make sure your pull request complies to the requirements outlined in [this guide](http://tgstation13.org/wiki/Getting_Your_Pull_Accepted)
|
* Make sure your pull request complies to the requirements outlined here
|
||||||
|
|
||||||
* You are going to be expected to document all your changes in the pull request. Failing to do so will mean delaying it as we will have to question why you made the change. On the other hand, you can speed up the process by making the pull request readable and easy to understand, with diagrams or before/after data.
|
* You are expected to have tested your pull requests if it is anything that would warrant testing. Text only changes, single number balance changes, and similar generally don't need testing, but anything else does. This means by extension web edits are disallowed for larger changes.
|
||||||
|
|
||||||
* We ask that you use the changelog system to document your change, which prevents our players from being caught unaware by changes - you can find more information about this [on this wiki page](http://tgstation13.org/wiki/Guide_to_Changelogs).
|
* You are going to be expected to document all your changes in the pull request. Failing to do so will mean delaying it as we will have to question why you made the change. On the other hand, you can speed up the process by making the pull request readable and easy to understand, with diagrams or before/after data. Should you be optimizing a routine you must provide proof by way of profiling that your changes are faster.
|
||||||
|
|
||||||
|
* We ask that you use the changelog system to document your player facing changes, which prevents our players from being caught unaware by said changes - you can find more information about this [on this wiki page](http://tgstation13.org/wiki/Guide_to_Changelogs).
|
||||||
|
|
||||||
* If you are proposing multiple changes, which change many different aspects of the code, you are expected to section them off into different pull requests in order to make it easier to review them and to deny/accept the changes that are deemed acceptable.
|
* If you are proposing multiple changes, which change many different aspects of the code, you are expected to section them off into different pull requests in order to make it easier to review them and to deny/accept the changes that are deemed acceptable.
|
||||||
|
|
||||||
@@ -400,10 +658,12 @@ There is no strict process when it comes to merging pull requests. Pull requests
|
|||||||
|
|
||||||
* Please explain why you are submitting the pull request, and how you think your change will be beneficial to the game. Failure to do so will be grounds for rejecting the PR.
|
* Please explain why you are submitting the pull request, and how you think your change will be beneficial to the game. Failure to do so will be grounds for rejecting the PR.
|
||||||
|
|
||||||
* If your pull request is not finished make sure it is at least testable in a live environment. Pull requests that do not at least meet this requirement will be closed. You may request a maintainer reopen the pull request when you're ready, or make a new one.
|
* If your pull request is not finished, you may open it as a draft for potential review. If you open it as a full-fledged PR make sure it is at least testable in a live environment. Pull requests that do not at least meet this requirement will be closed. You may request a maintainer reopen the pull request when you're ready, or make a new one.
|
||||||
|
|
||||||
* While we have no issue helping contributors (and especially new contributors) bring reasonably sized contributions up to standards via the pull request review process, larger contributions are expected to pass a higher bar of completeness and code quality *before* you open a pull request. Maintainers may close such pull requests that are deemed to be substantially flawed. You should take some time to discuss with maintainers or other contributors on how to improve the changes.
|
* While we have no issue helping contributors (and especially new contributors) bring reasonably sized contributions up to standards via the pull request review process, larger contributions are expected to pass a higher bar of completeness and code quality *before* you open a pull request. Maintainers may close such pull requests that are deemed to be substantially flawed. You should take some time to discuss with maintainers or other contributors on how to improve the changes.
|
||||||
|
|
||||||
|
* After leaving reviews on an open pull request, maintainers may convert it to a draft. Once you have addressed all their comments to the best of your ability, feel free to mark the pull as `Ready for Review` again.
|
||||||
|
|
||||||
## Porting features/sprites/sounds/tools from other codebases
|
## Porting features/sprites/sounds/tools from other codebases
|
||||||
|
|
||||||
If you are porting features/tools from other codebases, you must give them credit where it's due. Typically, crediting them in your pull request and the changelog is the recommended way of doing it. Take note of what license they use though, porting stuff from AGPLv3 and GPLv3 codebases are allowed.
|
If you are porting features/tools from other codebases, you must give them credit where it's due. Typically, crediting them in your pull request and the changelog is the recommended way of doing it. Take note of what license they use though, porting stuff from AGPLv3 and GPLv3 codebases are allowed.
|
||||||
@@ -413,19 +673,14 @@ Regarding sprites & sounds, you must credit the artist and possibly the codebase
|
|||||||
## Banned content
|
## Banned content
|
||||||
Do not add any of the following in a Pull Request or risk getting the PR closed:
|
Do not add any of the following in a Pull Request or risk getting the PR closed:
|
||||||
* National Socialist Party of Germany content, National Socialist Party of Germany related content, or National Socialist Party of Germany references
|
* National Socialist Party of Germany content, National Socialist Party of Germany related content, or National Socialist Party of Germany references
|
||||||
* Code where one line of code is split across mutiple lines (except for multiple, separate strings and comments; in those cases, existing longer lines must not be split up)
|
* Code adding, removing, or updating the availability of alien races/species/human mutants without prior approval. Pull requests attempting to add or remove features from said races/species/mutants require prior approval as well.
|
||||||
|
* Code which violates GitHub's [terms of service](https://github.com/site/terms).
|
||||||
|
|
||||||
Just because something isn't on this list doesn't mean that it's acceptable. Use common sense above all else.
|
Just because something isn't on this list doesn't mean that it's acceptable. Use common sense above all else.
|
||||||
|
|
||||||
## Content requiring prior approval
|
|
||||||
Certain types of changes may require prior approval from maintainers. This currently includes:
|
|
||||||
|
|
||||||
* Code adding, removing, or updating the availability of alien races/species/human mutants. This includes pull requests attempting to add or remove features from said races/species/mutants. (Requires approval from at least one maintainer)
|
|
||||||
* Code adding, removing, or modifying the functionality of adult-oriented features (such as, but not limited to: vore, genitals, MKUltra, and more). This also includes pull requests attempting to add or remove these features outright. (Requires approval from at least half of the formal maintainer team)
|
|
||||||
|
|
||||||
The above content requires approval from the specified amount of maintainers prior to PR creation. Seeking approval must be done via a @Maintainer ping in a relevant development/code or staff channel on the Discord, otherwise it will be considered insufficient. If a PR contains any of the above content, but the creator does not have sufficient approval prior to the PR's creation, then the PR may be closed by any maintainer, at any time, for any reason.
|
|
||||||
|
|
||||||
## A word on Git
|
## A word on Git
|
||||||
Yes, we know that the files have a tonne of mixed Windows and Linux line endings. Attempts to fix this have been met with less than stellar success, and as such we have decided to give up caring until there comes a time when it matters.
|
This repository uses `LF` line endings for all code as specified in the **.gitattributes** and **.editorconfig** files.
|
||||||
|
|
||||||
Therefore, EOF settings of main repo are forbidden territory one must avoid wandering into, at risk of losing body and/or mind to the Git gods.
|
Unless overridden or a non standard git binary is used the line ending settings should be applied to your clone automatically.
|
||||||
|
|
||||||
|
Note: VSC requires an [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig) to take advantage of editorconfig.
|
||||||
|
|||||||
10
.github/DOWNLOADING.md
vendored
Normal file
10
.github/DOWNLOADING.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
## DOWNLOADING
|
||||||
|
There are a number of ways to download the source code. Some are described here, an alternative all-inclusive guide is also located at https://www.tgstation13.org/wiki/Downloading_the_source_code
|
||||||
|
|
||||||
|
Option 1:
|
||||||
|
Follow this: https://www.tgstation13.org/wiki/Setting_up_git, only with Citadel Station's repository instead of /tg/'s.
|
||||||
|
|
||||||
|
Option 2: Download the source code as a zip by clicking the ZIP button in the
|
||||||
|
code tab of https://github.com/Citadel-Station-13/Citadel-Station-13
|
||||||
|
(note: this will use a lot of bandwidth if you wish to update and is a lot of
|
||||||
|
hassle if you want to make any changes at all, so it's not recommended.)
|
||||||
95
.github/RUNNING_A_SERVER.md
vendored
Normal file
95
.github/RUNNING_A_SERVER.md
vendored
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# INSTALLATION
|
||||||
|
First-time installation should be fairly straightforward. First, you'll need
|
||||||
|
BYOND installed. You can get it from https://www.byond.com/download. Once you've done
|
||||||
|
that, extract the game files to wherever you want to keep them. This is a
|
||||||
|
sourcecode-only release, so the next step is to compile the server files.
|
||||||
|
|
||||||
|
Double-click `BUILD.bat` in the root directory of the source code. This'll take
|
||||||
|
a little while, and if everything's done right you'll get a message like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
saving tgstation.dmb (DEBUG mode)
|
||||||
|
tgstation.dmb - 0 errors, 0 warnings
|
||||||
|
```
|
||||||
|
|
||||||
|
If you see any errors or warnings, something has gone wrong - possibly a corrupt
|
||||||
|
download or the files extracted wrong. If problems persist, ask for assistance
|
||||||
|
in irc://irc.rizon.net/coderbus
|
||||||
|
|
||||||
|
Once that's done, open up the config folder. You'll want to edit config.txt to
|
||||||
|
set the probabilities for different gamemodes in Secret and to set your server
|
||||||
|
location so that all your players don't get disconnected at the end of each
|
||||||
|
round. It's recommended you don't turn on the gamemodes with probability 0,
|
||||||
|
except Extended, as they have various issues and aren't currently being tested,
|
||||||
|
so they may have unknown and bizarre bugs. Extended is essentially no mode, and
|
||||||
|
isn't in the Secret rotation by default as it's just not very fun.
|
||||||
|
|
||||||
|
You'll also want to edit config/admins.txt to remove the default admins and add
|
||||||
|
your own. "Game Master" is the highest level of access, and probably the one
|
||||||
|
you'll want to use for now. You can set up your own ranks and find out more in
|
||||||
|
config/admin_ranks.txt
|
||||||
|
|
||||||
|
The format is
|
||||||
|
|
||||||
|
```
|
||||||
|
byondkey = Rank
|
||||||
|
```
|
||||||
|
|
||||||
|
where the admin rank must be properly capitalised.
|
||||||
|
|
||||||
|
This codebase also depends on a native library called rust-g. A precompiled
|
||||||
|
Windows DLL is included in this repository, but Linux users will need to build
|
||||||
|
and install it themselves. Directions can be found at the [rust-g
|
||||||
|
repo](https://github.com/tgstation/rust-g).
|
||||||
|
|
||||||
|
Finally, to start the server, run Dream Daemon and enter the path to your
|
||||||
|
compiled tgstation.dmb file. Make sure to set the port to the one you
|
||||||
|
specified in the config.txt, and set the Security box to 'Safe'. Then press GO
|
||||||
|
and the server should start up and be ready to join. It is also recommended that
|
||||||
|
you set up the SQL backend (see below).
|
||||||
|
|
||||||
|
## UPDATING
|
||||||
|
|
||||||
|
To update an existing installation, first back up your /config and /data folders
|
||||||
|
as these store your server configuration, player preferences and banlist.
|
||||||
|
|
||||||
|
Then, extract the new files (preferably into a clean directory, but updating in
|
||||||
|
place should work fine), copy your /config and /data folders back into the new
|
||||||
|
install, overwriting when prompted except if we've specified otherwise, and
|
||||||
|
recompile the game. Once you start the server up again, you should be running
|
||||||
|
the new version.
|
||||||
|
|
||||||
|
## HOSTING
|
||||||
|
|
||||||
|
If you'd like a more robust server hosting option for tgstation and its
|
||||||
|
derivatives. Check out our server tools suite at
|
||||||
|
https://github.com/tgstation/tgstation-server
|
||||||
|
|
||||||
|
If you decide to go this route, here are /tg/ specific details on hosting with TGS.
|
||||||
|
|
||||||
|
- We have two directories which should be setup in the instance's `Configuration/GameStaticFiles` directory:
|
||||||
|
- `config` should be where you place your production configuration. Overwrites the default contents of the repo's [config](../config) directory.
|
||||||
|
- `data` should be initially created as an empty directory. The game stores persistent data here.
|
||||||
|
- You should incorporate our [custom build scripts for TGS4](../tools/tgs4_scripts) in the instance's `Configuration/EventScripts` directory. These handle including TGUI in the build and setting up rust-g on Linux.
|
||||||
|
- Deployment security level must be set to `Trusted` or it will likely fail due to our native library usage.
|
||||||
|
- We highly recommend using the BYOND version specified in [dependencies.sh](../dependencies.sh) to avoid potential unrecorded issues.
|
||||||
|
|
||||||
|
## SQL SETUP
|
||||||
|
|
||||||
|
The SQL backend requires a Mariadb server running 10.2 or later. Mysql is not supported but Mariadb is a drop in replacement for mysql. SQL is required for the library, stats tracking, admin notes, and job-only bans, among other features, mostly related to server administration. Your server details go in /config/dbconfig.txt, and the SQL schema is in /SQL/tgstation_schema.sql and /SQL/tgstation_schema_prefix.sql depending on if you want table prefixes. More detailed setup instructions are located here: https://www.tgstation13.org/wiki/Downloading_the_source_code#Setting_up_the_database
|
||||||
|
|
||||||
|
If you are hosting a testing server on windows you can use a standalone version of MariaDB pre load with a blank (but initialized) tgdb database. Find them here: https://tgstation13.download/database/ Just unzip and run for a working (but insecure) database server. Includes a zipped copy of the data folder for easy resetting back to square one.
|
||||||
|
|
||||||
|
## WEB/CDN RESOURCE DELIVERY
|
||||||
|
|
||||||
|
Web delivery of game resources makes it quicker for players to join and reduces some of the stress on the game server.
|
||||||
|
|
||||||
|
1. Edit compile_options.dm to set the `PRELOAD_RSC` define to `0`
|
||||||
|
1. Add a url to config/external_rsc_urls pointing to a .zip file containing the .rsc.
|
||||||
|
* If you keep up to date with /tg/ you could reuse /tg/'s rsc cdn at http://tgstation13.download/byond/tgstation.zip. Otherwise you can use cdn services like CDN77 or cloudflare (requires adding a page rule to enable caching of the zip), or roll your own cdn using route 53 and vps providers.
|
||||||
|
* Regardless even offloading the rsc to a website without a CDN will be a massive improvement over the in game system for transferring files.
|
||||||
|
|
||||||
|
## IRC BOT SETUP
|
||||||
|
|
||||||
|
Included in the repository is a python3 compatible IRC bot capable of relaying adminhelps to a specified
|
||||||
|
IRC channel/server, see the /tools/minibot folder for more
|
||||||
20
.github/gbp.toml
vendored
Normal file
20
.github/gbp.toml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
no_balance_label = "GBP: No Update"
|
||||||
|
reset_label = "GBP: Reset"
|
||||||
|
|
||||||
|
[points]
|
||||||
|
"Atomic" = 2
|
||||||
|
"Balance/Rebalance" = -8
|
||||||
|
"Code Improvement" = 2
|
||||||
|
"Feature" = -10
|
||||||
|
"Feedback" = 2
|
||||||
|
"Fix" = 3
|
||||||
|
"Grammar and Formatting" = 1
|
||||||
|
"Logging" = 1
|
||||||
|
"Performance" = 12
|
||||||
|
"Priority: CRITICAL" = 20
|
||||||
|
"Priority: High" = 15
|
||||||
|
"Quality of Life" = 1
|
||||||
|
"Refactor" = 10
|
||||||
|
"Sound" = 3
|
||||||
|
"Sprites" = 3
|
||||||
|
"Unit Tests" = 6
|
||||||
14
.github/workflows/ci_suite.yml
vendored
14
.github/workflows/ci_suite.yml
vendored
@@ -58,8 +58,9 @@ jobs:
|
|||||||
bash tools/ci/install_byond.sh
|
bash tools/ci/install_byond.sh
|
||||||
source $HOME/BYOND/byond/bin/byondsetup
|
source $HOME/BYOND/byond/bin/byondsetup
|
||||||
python3 tools/ci/template_dm_generator.py
|
python3 tools/ci/template_dm_generator.py
|
||||||
tgui/bin/tgui --build
|
tools/build/build
|
||||||
bash tools/ci/dm.sh -DCIBUILDING -DCITESTING -DALL_MAPS tgstation.dme
|
env:
|
||||||
|
CBT_BUILD_MODE : ALL_MAPS
|
||||||
|
|
||||||
run_all_tests:
|
run_all_tests:
|
||||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||||
@@ -97,9 +98,10 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
bash tools/ci/install_byond.sh
|
bash tools/ci/install_byond.sh
|
||||||
source $HOME/BYOND/byond/bin/byondsetup
|
source $HOME/BYOND/byond/bin/byondsetup
|
||||||
tgui/bin/tgui --build
|
tools/build/build
|
||||||
bash tools/ci/dm.sh -DCIBUILDING tgstation.dme
|
# bash tools/ci/run_server.sh
|
||||||
# bash tools/ci/run_server.sh
|
env:
|
||||||
|
CBT_BUILD_MODE: TEST_RUN
|
||||||
|
|
||||||
test_windows:
|
test_windows:
|
||||||
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
if: "!contains(github.event.head_commit.message, '[ci skip]')"
|
||||||
@@ -109,6 +111,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Compile
|
- name: Compile
|
||||||
run: pwsh tools/ci/build.ps1
|
run: pwsh tools/ci/build.ps1
|
||||||
|
env:
|
||||||
|
DM_EXE: "C:\\byond\\bin\\dm.exe"
|
||||||
- name: Create artifact
|
- name: Create artifact
|
||||||
run: |
|
run: |
|
||||||
md deploy
|
md deploy
|
||||||
|
|||||||
1
.github/workflows/docker_publish.yml
vendored
1
.github/workflows/docker_publish.yml
vendored
@@ -20,4 +20,3 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
tags: "latest"
|
tags: "latest"
|
||||||
cache: true
|
|
||||||
|
|||||||
Reference in New Issue
Block a user