From c0938cca01f6ba806f319c5e93b94a60c99873be Mon Sep 17 00:00:00 2001 From: larentoun <31931237+larentoun@users.noreply.github.com> Date: Thu, 27 Jul 2023 22:06:34 +0900 Subject: [PATCH] Initial Modularity Support (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit В чейнджлоге Первый шаг к светлому будущему :cl: code: Добавлена поддержка модпаков config: Добавлен файл конфига для модпаков code: Обновлен CI под модпаки code: Изменен метод обнаружения мердж конфликтов /:cl: --- .github/workflows/ci_suite.yml | 5 ++ code/_compile_options.dm | 2 +- config/bandastation/bandastation_config.txt | 0 config/config.txt | 1 + modular_bandastation/_modpack.dm | 17 ++++++ modular_bandastation/_modpacks.dm | 60 +++++++++++++++++++ modular_bandastation/example/_example.dm | 16 +++++ modular_bandastation/example/_example.dme | 3 + modular_bandastation/example/code/example.dm | 2 + modular_bandastation/modular_bandastation.dme | 4 ++ tgstation.dme | 1 + tools/bandastation_check_grep.sh | 12 ++++ tools/build/build.js | 1 + 13 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 config/bandastation/bandastation_config.txt create mode 100644 modular_bandastation/_modpack.dm create mode 100644 modular_bandastation/_modpacks.dm create mode 100644 modular_bandastation/example/_example.dm create mode 100644 modular_bandastation/example/_example.dme create mode 100644 modular_bandastation/example/code/example.dm create mode 100644 modular_bandastation/modular_bandastation.dme create mode 100644 tools/bandastation_check_grep.sh diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 39b5d7b222445..0eb8ae7d10837 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -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 diff --git a/code/_compile_options.dm b/code/_compile_options.dm index 2a4854c37b858..99989e5cb849e 100644 --- a/code/_compile_options.dm +++ b/code/_compile_options.dm @@ -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; diff --git a/config/bandastation/bandastation_config.txt b/config/bandastation/bandastation_config.txt new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/config/config.txt b/config/config.txt index a26b6938496f0..e54a43497bd2b 100644 --- a/config/config.txt +++ b/config/config.txt @@ -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 diff --git a/modular_bandastation/_modpack.dm b/modular_bandastation/_modpack.dm new file mode 100644 index 0000000000000..5569426fa6404 --- /dev/null +++ b/modular_bandastation/_modpack.dm @@ -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 diff --git a/modular_bandastation/_modpacks.dm b/modular_bandastation/_modpacks.dm new file mode 100644 index 0000000000000..347fcd019b6b9 --- /dev/null +++ b/modular_bandastation/_modpacks.dm @@ -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)) + . = "

Список модификаций



" + for(var/datum/modpack/M as anything in SSmodpacks.loaded_modpacks) + if(M.name) + . += "
" + . += "
[M.name]
" + + if(M.desc || M.author) + . += "
" + if(M.desc) + . += "
Описание: [M.desc]" + if(M.author) + . += "
Автор: [M.author]" + . += "

" + + var/datum/browser/popup = new(mob, "modpacks_list", "Список Модификаций", 480, 580) + popup.set_content(.) + popup.open() + else + to_chat(src, "Этот сервер не использует какие-либо модификации.") diff --git a/modular_bandastation/example/_example.dm b/modular_bandastation/example/_example.dm new file mode 100644 index 0000000000000..2343367184030 --- /dev/null +++ b/modular_bandastation/example/_example.dm @@ -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() + . = ..() diff --git a/modular_bandastation/example/_example.dme b/modular_bandastation/example/_example.dme new file mode 100644 index 0000000000000..5540c273b03ba --- /dev/null +++ b/modular_bandastation/example/_example.dme @@ -0,0 +1,3 @@ +#include "_example.dm" + +#include "code/example.dm" diff --git a/modular_bandastation/example/code/example.dm b/modular_bandastation/example/code/example.dm new file mode 100644 index 0000000000000..ff327270a515d --- /dev/null +++ b/modular_bandastation/example/code/example.dm @@ -0,0 +1,2 @@ +/turf/closed/wall/example + name = "Example wall" diff --git a/modular_bandastation/modular_bandastation.dme b/modular_bandastation/modular_bandastation.dme new file mode 100644 index 0000000000000..6cceb1b51b5c4 --- /dev/null +++ b/modular_bandastation/modular_bandastation.dme @@ -0,0 +1,4 @@ +#include "_modpack.dm" +#include "_modpacks.dm" + +// #include "example/_example.dme" diff --git a/tgstation.dme b/tgstation.dme index 9446949bf2f5f..65ce2b7836aaf 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -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 diff --git a/tools/bandastation_check_grep.sh b/tools/bandastation_check_grep.sh new file mode 100644 index 0000000000000..1167fa5691f69 --- /dev/null +++ b/tools/bandastation_check_grep.sh @@ -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"