Commit Graph

5 Commits

Author SHA1 Message Date
PowerfulBacon
aacb26313e Adds 'required_neighbors' to maplint and conditional lints (#86640)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Allows us to test for atoms that are required to be placed alongside
another atom, such as APCs to cables.
There are many situations where a structure spawner is not good enough:
- APC cables need to be in any colour or any direction
- Airlock mapping helpers may be any access to any airlock and would
create too many subtypes.

## Why It's Good For The Game

This allows us to have more comprehensive linting added to future
mapping changes.

This is needed to support the following lints:
- Airlocks should not have an access helper if they have access
requirement variables set.
- Access requirement helpers MUST have an airlock placed on their tile.

Needed to satisfy the following review:
https://github.com/BeeStation/BeeStation-Hornet/pull/11469#discussion_r1757608360

## Testing Photographs and Procedure

### Test required neighbors


![image](https://github.com/user-attachments/assets/ea79aa85-048f-40ca-b27b-2a1da0e1ba2e)

### Conditional Rulesets

(I know this rule is useless since it mimics banned_variables, but we
can make more complex rules with the other ones and with
banned_neighbors)


![image](https://github.com/user-attachments/assets/a607a4cd-0e97-4557-8129-7cf5875a2ebd)


![image](https://github.com/user-attachments/assets/81e43bb6-acc8-441f-97a3-936f5bc88203)

Test a more complex query with set operations:


![image](https://github.com/user-attachments/assets/2d309060-8360-4b55-a4d2-2a5d11d7bad5)


![image](https://github.com/user-attachments/assets/33b30d70-3971-40d8-97d5-2f610d73cf86)


![image](https://github.com/user-attachments/assets/50e564eb-9b82-413f-99c3-4655e6c23c75)

Super complex query:


![image](https://github.com/user-attachments/assets/0d12c56f-6ff5-4663-bd5b-738c12c3f085)


![image](https://github.com/user-attachments/assets/a46afaa8-4385-4017-a452-a3a624d968c4)


![image](https://github.com/user-attachments/assets/7a6f5fe5-9a0c-4f55-afc9-2fb1777c8a7d)

Test like:


![image](https://github.com/user-attachments/assets/2f0187e2-c7f1-4631-8f40-c8d8ae68942b)


![image](https://github.com/user-attachments/assets/1d63faf1-934f-4d6d-8091-f484fcd44c7a)


![image](https://github.com/user-attachments/assets/86dd3593-a3de-47bf-8061-ff206366d387)

Not set:

![image](https://github.com/user-attachments/assets/2ae61dfe-4214-42a5-96a9-37ae5e91e6b0)

Test is:


![image](https://github.com/user-attachments/assets/ace87258-f9cd-4898-86ba-1cf86bf52a3a)


![image](https://github.com/user-attachments/assets/067acb26-1bf7-4038-9d2f-3e304810fadd)


## Changelog
🆑
add: Implements the ability to lint for required neighbors in maplint.
add: Adds conditional linting rules in maplint, allowing a lint to apply
only if certain conditions are met (Variable is/isn't set, Variable
is/isn't a value, Variable matches a regex).
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2024-09-16 11:16:25 -07:00
Tim
193e399bb7 Add mapping linter to check for duplicate machinery stacked on same tile (#79394)
This has happened quite a few times in the past and it'd be a good idea
to have a linter catch this common mistake. After digging through the
Python code for the mapping linter, it appears the linter wasn't
correctly identifying two duplicate objects. I tweaked the code to fix
this.
2023-11-10 05:35:08 +00:00
Mothblocks
4725f2e4a1 Fix maplint help messages (#73528) 2023-02-19 22:35:47 -08:00
Tastyfish
50a9d4c54d Maplint tool now has proper github action error messages (#72920)
## About The Pull Request

The tool added in #72372 is pretty awesome. The output is uhh cryptic
though. I had to read the source code to realize the (line 382) or
whatever part of the message was the dmm line number and there's stack
traces everywhere. I've made it support github action error messages so
now you get this beauty if you mess up:

![Example cable
error](https://user-images.githubusercontent.com/1185434/214156870-d73ffba0-f79a-43ed-9574-e74cc2ee2057.png)

Or, in the run summary:


![image](https://user-images.githubusercontent.com/1185434/214157201-e392a6d6-a8a8-4d8a-ac74-c65ae97438c8.png)

Errors parsing the lint yml's will also output github action errors,
although the line number will always be 1 since the yaml parser discards
line numbers to my knowledge.

In the midst of doing this, I made the error type contain the file and
line info, and added a bunch of type hints in the midst of trying to
understand Mothblock's code.

Note that for power users, the default behavior is still colored
terminal text; `--github` is added by the CI suite to enable this
behavior.
## Why It's Good For The Game

Much easier to see where the errors are and what they are (who even
knows what a 'pop' is? The tg game code calls them grid models.)
## Changelog
Nothing player-facing.
2023-01-28 18:56:24 -05:00
Mothblocks
6f07ae305b Replace nearly every map grep with a YML file that actually respects structure, and fixes the massive amount of failures that were never caught (#72372)
[Documentation
here](https://github.com/Mothblocks/tgstation/blob/maplint/tools/maplint/README.md)

We should not be using greps to the capacity that we currently are. If
you are not smarter than a parser, then you should not try to beat one.
DMM files should NOT be treated as text files that can be parsed with
any old Unix tool. They are a structured language. Because of our abuse
of greps, check_greps is full of hard to read, hard to maintain checks
that do not consistently work, because they all make very specific
assumptions about how TGM works, which are provably untrue.

This format is mostly straightforward for the lints people write, and
easily extensible to the ones people will want to write.

🆑
fix: Fixes a bunch of cases of windows not being where they were
supposed to be, tables/chairs stacking on each other, and other very
small stuff you've never noticed before.
/🆑
2023-01-03 21:21:37 -08:00