Skip to content

Commit

Permalink
Initial Modularity Support (#1)
Browse files Browse the repository at this point in the history
<!-- 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. -->

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

В чейнджлоге

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

Первый шаг к светлому будущему

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

:cl:
code: Добавлена поддержка модпаков
config: Добавлен файл конфига для модпаков
code: Обновлен CI под модпаки
code: Изменен метод обнаружения мердж конфликтов
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: 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. -->
  • Loading branch information
larentoun committed Nov 3, 2023
1 parent 615ed74 commit c0938cc
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ jobs:
- name: Ticked File Enforcement
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: |
bash tools/ci/check_filedirs.sh tgstation.dme
bash tools/ci/check_changelogs.sh
bash tools/ci/check_grep.sh
bash tools/ci/check_misc.sh
bash tools/bandastation_check_grep.sh # BANDASTATION EDIT ADDITION - checking modular_bandastation code
tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/tgstation_dme.json
tools/bootstrap/python tools/ticked_file_enforcement/ticked_file_enforcement.py < tools/ticked_file_enforcement/schemas/unit_tests.json
- name: Check Define Sanity
Expand Down
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#endif

#ifndef PRELOAD_RSC //set to:
#define PRELOAD_RSC 1 // 0 to allow using external resources or on-demand behaviour;
#define PRELOAD_RSC 0 // 0 to allow using external resources or on-demand behaviour; BANDASTATION EDIT - Original: 1
#endif // 1 to use the default behaviour;
// 2 for preloading absolutely everything;

Expand Down
Empty file.
1 change: 1 addition & 0 deletions config/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $include dbconfig.txt
$include comms.txt
$include logging.txt
$include resources.txt
$include bandastation/bandastation-config.txt
$include interviews.txt
$include lua.txt
$include auxtools.txt
Expand Down
17 changes: 17 additions & 0 deletions modular_bandastation/_modpack.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/datum/modpack
/// A string name for the modpack. Used for looking up other modpacks in init.
var/name
/// A string desc for the modpack. Can be used for modpack verb list as description.
var/desc
/// A string with authors of this modpack.
var/author

/datum/modpack/proc/pre_initialize()
if(!name)
return "Modpack name is unset."

/datum/modpack/proc/initialize()
return

/datum/modpack/proc/post_initialize()
return
60 changes: 60 additions & 0 deletions modular_bandastation/_modpacks.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#define INIT_ORDER_MODPACKS 84

SUBSYSTEM_DEF(modpacks)
name = "Modpacks"
init_order = INIT_ORDER_MODPACKS
flags = SS_NO_FIRE
var/list/loaded_modpacks = list()

/datum/controller/subsystem/modpacks/Initialize()
var/list/all_modpacks = list()
for(var/modpack in subtypesof(/datum/modpack/))
all_modpacks.Add(new modpack)
// Pre-init and register all compiled modpacks.
for(var/datum/modpack/package as anything in all_modpacks)
var/fail_msg = package.pre_initialize()
if(QDELETED(package))
CRASH("Modpack of type [package.type] is null or queued for deletion.")
if(fail_msg)
CRASH("Modpack [package.name] failed to pre-initialize: [fail_msg].")
if(loaded_modpacks[package.name])
CRASH("Attempted to register duplicate modpack name [package.name].")
loaded_modpacks.Add(package)

// Handle init and post-init (two stages in case a modpack needs to implement behavior based on the presence of other packs).
for(var/datum/modpack/package as anything in all_modpacks)
var/fail_msg = package.initialize()
if(fail_msg)
CRASH("Modpack [(istype(package) && package.name) || "Unknown"] failed to initialize: [fail_msg]")
for(var/datum/modpack/package as anything in all_modpacks)
var/fail_msg = package.post_initialize()
if(fail_msg)
CRASH("Modpack [(istype(package) && package.name) || "Unknown"] failed to post-initialize: [fail_msg]")

/client/verb/modpacks_list()
set name = "Modpacks List"
set category = "OOC"

if(!mob || !SSmodpacks.initialized)
return

if(length(SSmodpacks.loaded_modpacks))
. = "<hr><br><center><b><font size = 3>Список модификаций</font></b></center><br><hr><br>"
for(var/datum/modpack/M as anything in SSmodpacks.loaded_modpacks)
if(M.name)
. += "<div class = 'statusDisplay'>"
. += "<center><b>[M.name]</b></center>"

if(M.desc || M.author)
. += "<br>"
if(M.desc)
. += "<br>Описание: [M.desc]"
if(M.author)
. += "<br><i>Автор: [M.author]</i>"
. += "</div><br>"

var/datum/browser/popup = new(mob, "modpacks_list", "Список Модификаций", 480, 580)
popup.set_content(.)
popup.open()
else
to_chat(src, "Этот сервер не использует какие-либо модификации.")
16 changes: 16 additions & 0 deletions modular_bandastation/example/_example.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/datum/modpack/example
/// A string name for the modpack. Used for looking up other modpacks in init.
name = "Example modpack"
/// A string desc for the modpack. Can be used for modpack verb list as description.
desc = "its useless"
/// A string with authors of this modpack.
author = "furior"

/datum/modpack/example/pre_initialize()
. = ..()

/datum/modpack/example/initialize()
. = ..()

/datum/modpack/example/post_initialize()
. = ..()
3 changes: 3 additions & 0 deletions modular_bandastation/example/_example.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "_example.dm"

#include "code/example.dm"
2 changes: 2 additions & 0 deletions modular_bandastation/example/code/example.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/turf/closed/wall/example
name = "Example wall"
4 changes: 4 additions & 0 deletions modular_bandastation/modular_bandastation.dme
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "_modpack.dm"
#include "_modpacks.dm"

// #include "example/_example.dme"
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -5898,4 +5898,5 @@
#include "interface\fonts\spess_font.dm"
#include "interface\fonts\tiny_unicode.dm"
#include "interface\fonts\vcr_osd_mono.dm"
#include "modular_bandastation\modular_bandastation.dme" // BANDASTATION EDIT
// END_INCLUDE
12 changes: 12 additions & 0 deletions tools/bandastation_check_grep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#ANSI Escape Codes for colors to increase contrast of errors
RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
NC="\033[0m" # No Color

echo -e "${BLUE}Re-running grep checks, but looking in modular_bandastation...${NC}"

# Run the linters again, but modular bandastation code.
sed "s|code/\*\*/\*\.dm|modular_bandastation/\*\*/\*\.dm|g" <tools/ci/check_grep.sh | bash
1 change: 1 addition & 0 deletions tools/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const DmTarget = new Juke.Target({
'html/**',
'icons/**',
'interface/**',
'modular_bandastation/**', // BANDASTATION EDIT ADDITION - Making the CBT work
`${DME_NAME}.dme`,
NamedVersionFile,
],
Expand Down

0 comments on commit c0938cc

Please sign in to comment.