From 3fc337afbafce50c44086ea047befb18c93f649a Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Fri, 30 Mar 2018 01:34:06 -0700 Subject: [PATCH 01/52] Fix client crash --- TGS.ControlPanel/Login.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TGS.ControlPanel/Login.cs b/TGS.ControlPanel/Login.cs index ff496f167c..40da36cd8c 100644 --- a/TGS.ControlPanel/Login.cs +++ b/TGS.ControlPanel/Login.cs @@ -46,11 +46,10 @@ namespace TGS.ControlPanel if (updatingFields || currentLoginInfo == null) return; updatingFields = true; - currentLoginInfo = null; switch (start) { case 1: IPComboBox.Text = ""; - goto case 2; + goto case 2; //reason number #3 why you shouldn't use c# case 2: PortSelector.Value = 38607; goto case 3; @@ -58,10 +57,11 @@ namespace TGS.ControlPanel UsernameTextBox.Text = ""; goto case 4; case 4: - if (currentLoginInfo.HasPassword) + if (currentLoginInfo?.HasPassword ?? false) //reason number #749 why you shouldn't use c# PasswordTextBox.Text = ""; break; } + currentLoginInfo = null; updatingFields = false; } From 2668ffed434bcde889c837639701be1a5891d5b3 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 5 Apr 2018 17:48:37 -0400 Subject: [PATCH 02/52] Fixes python stderr not being logged --- TGS.Server/Instance/Repository.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index 0a7a7a60f9..c1d4b7b571 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -1338,12 +1338,12 @@ namespace TGS.Server python.StartInfo.UseShellExecute = false; python.StartInfo.WorkingDirectory = new DirectoryInfo(RelativePath(RepoPath)).FullName; python.StartInfo.RedirectStandardOutput = true; + python.StartInfo.RedirectStandardError = true; python.Start(); using (StreamReader reader = python.StandardOutput) - { result = reader.ReadToEnd(); - - } + using (StreamReader reader = python.StandardError) + result += reader.ReadToEnd(); python.WaitForExit(); exitCode = python.ExitCode; } @@ -1364,11 +1364,12 @@ namespace TGS.Server pip.StartInfo.Arguments = "install " + I; pip.StartInfo.UseShellExecute = false; pip.StartInfo.RedirectStandardOutput = true; + pip.StartInfo.RedirectStandardError = true; pip.Start(); using (StreamReader reader = pip.StandardOutput) - { result += "\r\n---BEGIN-PIP-OUTPUT---\r\n" + reader.ReadToEnd(); - } + using (StreamReader reader = pip.StandardError) + result += reader.ReadToEnd(); pip.WaitForExit(); if (pip.ExitCode != 0) { From 0c804b673f9238c79fca19468aed1e6ce6d109c2 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 5 Apr 2018 17:55:18 -0400 Subject: [PATCH 03/52] Version bump to 3.2.2.1 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 13a8d67ebd..f85f91a029 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.2.0")] -[assembly: AssemblyFileVersion("3.2.2.0")] -[assembly: AssemblyInformationalVersion("3.2.2.0")] +[assembly: AssemblyVersion("3.2.2.1")] +[assembly: AssemblyFileVersion("3.2.2.1")] +[assembly: AssemblyInformationalVersion("3.2.2.1")] [assembly: InternalsVisibleTo("TGS.Tests")] From 382a15a916364c3fa412c93c2ac211fe94701680 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 25 Apr 2018 12:14:46 -0400 Subject: [PATCH 04/52] Add DMAPI compatibility layer --- .travis.yml | 2 +- DMAPI/server_tools.dm | 129 ---------- DMAPI/st_interface.dm | 135 ---------- DMAPI/tgs.dm | 202 +++++++++++++++ DMAPI/tgs/core/_definitions.dm | 2 + DMAPI/tgs/core/core.dm | 139 ++++++++++ DMAPI/tgs/core/datum.dm | 74 ++++++ DMAPI/tgs/core/default_event_handler.dm | 30 +++ DMAPI/tgs/includes.dm | 6 + DMAPI/tgs/v3210/api.dm | 242 ++++++++++++++++++ .../{st_commands.dm => tgs/v3210/commands.dm} | 53 ++-- TGS.Tests/TGS.Tests.csproj | 10 +- TGStationServer3.sln | 29 ++- Tools/Config.dm | 18 +- Tools/Test.dm | 28 +- ...DMAPITravisTester.dme => travistester.dme} | 5 +- 16 files changed, 768 insertions(+), 336 deletions(-) delete mode 100644 DMAPI/server_tools.dm delete mode 100644 DMAPI/st_interface.dm create mode 100644 DMAPI/tgs.dm create mode 100644 DMAPI/tgs/core/_definitions.dm create mode 100644 DMAPI/tgs/core/core.dm create mode 100644 DMAPI/tgs/core/datum.dm create mode 100644 DMAPI/tgs/core/default_event_handler.dm create mode 100644 DMAPI/tgs/includes.dm create mode 100644 DMAPI/tgs/v3210/api.dm rename DMAPI/{st_commands.dm => tgs/v3210/commands.dm} (51%) rename Tools/{DMAPITravisTester.dme => travistester.dme} (71%) diff --git a/.travis.yml b/.travis.yml index df970b29e7..b54966f76b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ env: global: - BYOND_MAJOR="511" - BYOND_MINOR="1385" - - DMEName="Tools/DMAPITravisTester.dme" + - DMEName="Tools/travistester.dme" matrix: - BUILD_CLIENT=true - BUILD_CLIENT=false diff --git a/DMAPI/server_tools.dm b/DMAPI/server_tools.dm deleted file mode 100644 index 2540dac4ba..0000000000 --- a/DMAPI/server_tools.dm +++ /dev/null @@ -1,129 +0,0 @@ -// /tg/station 13 server tools API -#define SERVICE_API_VERSION_STRING "3.2.0.3" - -//CONFIGURATION -//use this define if you want to do configuration outside of this file -#ifndef SERVER_TOOLS_EXTERNAL_CONFIGURATION -//Comment this out once you've filled in the below -#error /tg/station server tools interface unconfigured - -//Required interfaces (fill in with your codebase equivalent): - -//create a global variable named `Name` and set it to `Value` -//These globals must not be modifiable from anywhere outside of the server tools -#define SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(Name, Value) -//Read the value in the global variable `Name` -#define SERVER_TOOLS_READ_GLOBAL(Name) -//Set the value in the global variable `Name` to `Value` -#define SERVER_TOOLS_WRITE_GLOBAL(Name, Value) -//display an announcement `message` from the server to all players -#define SERVER_TOOLS_WORLD_ANNOUNCE(message) -//Write a string `message` to a server log -#define SERVER_TOOLS_LOG(message) -//Notify current in-game administrators of a string `event` -#define SERVER_TOOLS_NOTIFY_ADMINS(event) -//The current amount of connected clients -#define SERVER_TOOLS_CLIENT_COUNT -#endif - -//Required hooks: - -//Put this somewhere in /world/New() that is always run -#define SERVER_TOOLS_ON_NEW ServiceInit() -//Put this somewhere in /world/Topic(T, Addr, Master, Keys) that is always run before T is modified -#define SERVER_TOOLS_ON_TOPIC var/service_topic_return = ServiceCommand(params2list(T)); if(service_topic_return) return service_topic_return -//Put at the beginning of world/Reboot(reason) -#define SERVER_TOOLS_ON_REBOOT ServiceReboot() - -//Optional callable functions: - -//Returns the string version of the API -#define SERVER_TOOLS_API_VERSION ServiceAPIVersion() -//Returns TRUE if the world was launched under the server tools and the API matches, FALSE otherwise -//No function below this succeed if this is FALSE -#define SERVER_TOOLS_PRESENT RunningService() -//Gets the current version of the service running the server -#define SERVER_TOOLS_VERSION ServiceVersion() -//Forces a hard reboot of BYOND by ending the process -//unlike del(world) clients will try to reconnect -//If the service has not requested a shutdown, the world will reboot shortly after -#define SERVER_TOOLS_REBOOT_BYOND(silent) world.ServiceEndProcess(silent) -/* - Gets the list of any testmerged github pull requests - - "[PR Number]" => list( - "title" -> PR title - "commit" -> Full hash of commit merged - "author" -> Github username of the author of the PR - ) -*/ -#define SERVER_TOOLS_PR_LIST GetTestMerges() -//Sends a message to connected game chats -#define SERVER_TOOLS_CHAT_BROADCAST(message) world.ChatBroadcast(message) -//Sends a message to connected admin chats -#define SERVER_TOOLS_RELAY_BROADCAST(message) world.AdminBroadcast(message) - -//IMPLEMENTATION - -#define REBOOT_MODE_NORMAL 0 -#define REBOOT_MODE_HARD 1 -#define REBOOT_MODE_SHUTDOWN 2 - -#define SERVICE_WORLD_PARAM "server_service" -#define SERVICE_VERSION_PARAM "server_service_version" -#define SERVICE_INSTANCE_PARAM "server_instance" -#define SERVICE_PR_TEST_JSON "prtestjob.json" -#define SERVICE_INTERFACE_DLL "TGDreamDaemonBridge.dll" -#define SERVICE_INTERFACE_FUNCTION "DDEntryPoint" - -#define SERVICE_CMD_HARD_REBOOT "hard_reboot" -#define SERVICE_CMD_GRACEFUL_SHUTDOWN "graceful_shutdown" -#define SERVICE_CMD_WORLD_ANNOUNCE "world_announce" -#define SERVICE_CMD_LIST_CUSTOM "list_custom_commands" -#define SERVICE_CMD_API_COMPATIBLE "api_compat" -#define SERVICE_CMD_PLAYER_COUNT "client_count" - -#define SERVICE_CMD_PARAM_KEY "serviceCommsKey" -#define SERVICE_CMD_PARAM_COMMAND "command" -#define SERVICE_CMD_PARAM_SENDER "sender" -#define SERVICE_CMD_PARAM_CUSTOM "custom" - -#define SERVICE_JSON_PARAM_HELPTEXT "help_text" -#define SERVICE_JSON_PARAM_ADMINONLY "admin_only" -#define SERVICE_JSON_PARAM_REQUIREDPARAMETERS "required_parameters" - -#define SERVICE_REQUEST_KILL_PROCESS "killme" -#define SERVICE_REQUEST_KILL_PROCESS_SILENT "killmesilent" -#define SERVICE_REQUEST_IRC_BROADCAST "irc" -#define SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE "send2irc" -#define SERVICE_REQUEST_WORLD_REBOOT "worldreboot" -#define SERVICE_REQUEST_API_VERSION "api_ver" - -#define SERVICE_RETURN_SUCCESS "SUCCESS" - -/* -The MIT License - -Copyright (c) 2017 Jordan Brown - -Permission is hereby granted, free of charge, -to any person obtaining a copy of this software and -associated documentation files (the "Software"), to -deal in the Software without restriction, including -without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom -the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ diff --git a/DMAPI/st_interface.dm b/DMAPI/st_interface.dm deleted file mode 100644 index 931ab10ff3..0000000000 --- a/DMAPI/st_interface.dm +++ /dev/null @@ -1,135 +0,0 @@ -SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(reboot_mode, REBOOT_MODE_NORMAL) -SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(server_tools_api_compatible, FALSE) - -/proc/GetTestMerges() - if(RunningService(TRUE) && fexists(SERVICE_PR_TEST_JSON)) - . = json_decode(file2text(SERVICE_PR_TEST_JSON)) - if(.) - return - return list() - -/world/proc/ServiceInit() - if(!RunningService(TRUE)) - return - ListServiceCustomCommands(TRUE) - ExportService("[SERVICE_REQUEST_API_VERSION] [SERVER_TOOLS_API_VERSION]", TRUE) - -/proc/RunningService(skip_compat_check = FALSE) - if(!skip_compat_check && !SERVER_TOOLS_READ_GLOBAL(server_tools_api_compatible)) - return FALSE - . = world.params[SERVICE_WORLD_PARAM] != null - if(. && world.system_type != MS_WINDOWS) - SERVER_TOOLS_LOG("Warning: Server tools world parameter detected but not running on Windows. Aborting initialization!") - return FALSE - -/proc/ServiceVersion() - if(RunningService(TRUE)) - return world.params[SERVICE_VERSION_PARAM] - -/proc/ServiceAPIVersion() - return SERVICE_API_VERSION_STRING - -/world/proc/ExportService(command, skip_compat_check = FALSE) - . = FALSE - if(!RunningService(skip_compat_check)) - return - if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL)) - CRASH("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.") - var/instance = params[SERVICE_INSTANCE_PARAM] - if(!instance) - instance = "TG Station Server" //maybe just upgraded - call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance, command) //trust no retval - return TRUE - -/world/proc/ChatBroadcast(message) - ExportService("[SERVICE_REQUEST_IRC_BROADCAST] [message]") - -/world/proc/AdminBroadcast(message) - ExportService("[SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE] [message]") - -/world/proc/ServiceEndProcess(silent = FALSE) - SERVER_TOOLS_LOG("Sending shutdown request!"); - sleep(world.tick_lag) //flush the buffers - ExportService(silent ? SERVICE_REQUEST_KILL_PROCESS_SILENT : SERVICE_REQUEST_KILL_PROCESS) - -//called at the exact moment the world is supposed to reboot -/world/proc/ServiceReboot() - switch(SERVER_TOOLS_READ_GLOBAL(reboot_mode)) - if(REBOOT_MODE_HARD) - SERVER_TOOLS_WORLD_ANNOUNCE("Hard reboot triggered, you will automatically reconnect...") - ServiceEndProcess() - if(REBOOT_MODE_SHUTDOWN) - SERVER_TOOLS_WORLD_ANNOUNCE("The server is shutting down...") - ServiceEndProcess() - else - ExportService(SERVICE_REQUEST_WORLD_REBOOT) //just let em know - -/world/proc/ServiceCommand(list/params) - var/their_sCK = params[SERVICE_CMD_PARAM_KEY] - if(!their_sCK || !RunningService(TRUE)) - return FALSE //continue world/Topic - - var/sCK = world.params[SERVICE_WORLD_PARAM] - if(their_sCK != sCK) - return "Invalid comms key!"; - - var/command = params[SERVICE_CMD_PARAM_COMMAND] - if(!command) - return "No command!" - - switch(command) - if(SERVICE_CMD_API_COMPATIBLE) - SERVER_TOOLS_WRITE_GLOBAL(server_tools_api_compatible, TRUE) - return SERVICE_RETURN_SUCCESS - if(SERVICE_CMD_HARD_REBOOT) - if(SERVER_TOOLS_READ_GLOBAL(reboot_mode) != REBOOT_MODE_HARD) - SERVER_TOOLS_WRITE_GLOBAL(reboot_mode, REBOOT_MODE_HARD) - SERVER_TOOLS_LOG("Hard reboot requested by service") - SERVER_TOOLS_NOTIFY_ADMINS("The world will hard reboot at the end of the game. Requested by service.") - if(SERVICE_CMD_GRACEFUL_SHUTDOWN) - if(SERVER_TOOLS_READ_GLOBAL(reboot_mode) != REBOOT_MODE_SHUTDOWN) - SERVER_TOOLS_WRITE_GLOBAL(reboot_mode, REBOOT_MODE_SHUTDOWN) - SERVER_TOOLS_LOG("Shutdown requested by service") - message_admins("The world will shutdown at the end of the game. Requested by service.") - if(SERVICE_CMD_WORLD_ANNOUNCE) - var/msg = params["message"] - if(!istext(msg) || !msg) - return "No message set!" - SERVER_TOOLS_WORLD_ANNOUNCE(msg) - return SERVICE_RETURN_SUCCESS - if(SERVICE_CMD_PLAYER_COUNT) - return "[SERVER_TOOLS_CLIENT_COUNT]" - if(SERVICE_CMD_LIST_CUSTOM) - return json_encode(ListServiceCustomCommands(FALSE)) - else - var/custom_command_result = HandleServiceCustomCommand(lowertext(command), params[SERVICE_CMD_PARAM_SENDER], params[SERVICE_CMD_PARAM_CUSTOM]) - if(custom_command_result) - return istext(custom_command_result) ? custom_command_result : SERVICE_RETURN_SUCCESS - return "Unknown command: [command]" - -/* -The MIT License - -Copyright (c) 2017 Jordan Brown - -Permission is hereby granted, free of charge, -to any person obtaining a copy of this software and -associated documentation files (the "Software"), to -deal in the Software without restriction, including -without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom -the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ diff --git a/DMAPI/tgs.dm b/DMAPI/tgs.dm new file mode 100644 index 0000000000..e885b06397 --- /dev/null +++ b/DMAPI/tgs.dm @@ -0,0 +1,202 @@ +//tgstation-server DMAPI + +//All functions and datums outside this document are subject to change with any version and should not be relied on + +//CONFIGURATION + +//create this define if you want to do configuration outside of this file +#ifndef TGS_EXTERNAL_CONFIGURATION + +//Comment this out once you've filled in the below +#error TGS API unconfigured + +//Required interfaces (fill in with your codebase equivalent): + +//create a global variable named `Name` and set it to `Value` +//These globals must not be modifiable from anywhere outside of the server tools +#define TGS_DEFINE_AND_SET_GLOBAL(Name, Value) + +//Read the value in the global variable `Name` +#define TGS_READ_GLOBAL(Name) + +//Set the value in the global variable `Name` to `Value` +#define TGS_WRITE_GLOBAL(Name, Value) + +//Disallow ANYONE from reflecting a given `path`, security measure to prevent in-game priveledge escalation +#define TGS_PROTECT_DATUM(Path) + +//display an announcement `message` from the server to all players +#define TGS_WORLD_ANNOUNCE(message) + +//Notify current in-game administrators of a string `event` +#define TGS_NOTIFY_ADMINS(event) + +//Write an info `message` to a server log +#define TGS_INFO_LOG(message) + +//Write an error `message` to a server log +#define TGS_ERROR_LOG(message) + +//Get the number of connected /clients +#define TGS_CLIENT_COUNT + +#endif + +//EVENT CODES + +//TODO + +//REQUIRED HOOKS + +//Call this somewhere in /world/New() that is always run +//event_handler: optional user defined event handler. The default behaviour is to broadcast the event in english to all connected admin channels +/world/proc/TgsNew(datum/tgs_event_handler/event_handler) + return + +//Call this when your initializations are complete and your game is ready to play before any player interactions happen +//This may use world.sleep_offline to make this happen so ensure no changes are made to it while this call is running +/world/proc/TgsInitializationComplete() + return + +//Put this somewhere in /world/Topic(T, Addr, Master, Keys) that is always run before T is modified +#define TGS_TOPIC var/tgs_topic_return = TgsTopic(T); if(tgs_topic_return) return tgs_topic_return + +//Call this at the beginning of world/Reboot(reason) +/world/proc/TgsReboot() + return + +//DATUM DEFINITIONS +//unless otherwise specified all datums defined here should be considered read-only, warranty void if written + +//represents git revision information about the current world build +/datum/tgs_revision_information + var/commit //full sha of compiled commit + var/origin_commit //full sha of last known remote commit. This may be null if the TGS repository is not currently tracking a remote branch + +//represents a merge of a GitHub pull request +/datum/tgs_revision_information/test_merge + var/number //pull request number + var/title //pull request title + var/body //pull request body + var/author //pull request github author + var/url //link to pull request html + var/pull_request_commit //commit of the pull request when it was merged + var/time_merged //timestamp of when the merge commit for the pull request was created + var/comment //optional comment left by the one who initiated the test merge + +//represents a connected chat channel +/datum/tgs_chat_channel + var/id //internal channel representation + var/friendly_name //user friendly channel name + var/server_name //server name the channel resides on + var/provider_name //chat provider for the channel + var/is_admin_channel //if the server operator has marked this channel for game admins only + var/is_private_channel //if this is a private chat channel + +//represents a chat user +/datum/tgs_chat_user + var/id //Internal user representation + var/friendly_name //The user's public name + var/mention //The text to use to ping this user in a message + var/datum/tgs_chat_channel/channel //The /datum/tgs_chat_channel this user was from + +//user definable callback for handling events +/datum/tgs_event_handler/proc/HandleEvent(event_code) + return + +//user definable chat command +/datum/tgs_chat_command + var/name = "" //the string to trigger this command on a chat bot. e.g. TGS3_BOT: do_this_command + var/help_text = "" //help text for this command + var/admin_only = FALSE //set to TRUE if this command should only be usable by registered chat admins + +//override to implement command +//sender: The tgs_chat_user who send to command +//params: The trimmed string following the command name +//The return value will be stringified and sent to the appropriate chat +/datum/tgs_chat_command/proc/Run(datum/tgs_chat_user/sender, params) + CRASH("[type] has no implementation for Run()") + +//FUNCTIONS + +//Returns the respective string version of the API +/world/proc/TgsMaximumAPIVersion() + return + +/world/proc/TgsMinimumAPIVersion() + return + +//Gets the current version of the server tools running the server +/world/proc/TgsVersion() + return + +//Returns TRUE if the world was launched under the server tools and the API matches, FALSE otherwise +//No function below this succeeds if it returns FALSE +/world/proc/TgsAvailable() + return + +/world/proc/TgsInstanceName() + return + +//Get the current `/datum/tgs_revision_information` +/world/proc/TgsRevision() + return + +//Gets a list of active `/datum/tgs_revision_information/test_merge`s +/world/proc/TgsTestMerges() + return + +//Forces a hard reboot of BYOND by ending the process +//unlike del(world) clients will try to reconnect +//If the service has not requested a shutdown, the next server will take over +/world/proc/TgsEndProcess() + return + +//Gets a list of connected tgs_chat_channel +/world/proc/TgsChatChannelInfo() + return + +//Sends a message to connected game chats +//message: The message to send +//channels: optional channels to limit the broadcast to +/world/proc/TgsChatBroadcast(message, list/channels) + return + +//Send a message to non-admin connected chats +//message: The message to send +//admin_only: If TRUE, message will instead be sent to only admin connected chats +/world/proc/TgsTargetedChatBroadcast(message, admin_only) + return + +//Send a private message to a specific user +//message: The message to send +//user: The /datum/tgs_chat_user to send to +/world/proc/TgsChatPrivateMessage(message, datum/tgs_chat_user/user) + return + +/* +The MIT License + +Copyright (c) 2017 Jordan Brown + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/DMAPI/tgs/core/_definitions.dm b/DMAPI/tgs/core/_definitions.dm new file mode 100644 index 0000000000..ebf6d17c2a --- /dev/null +++ b/DMAPI/tgs/core/_definitions.dm @@ -0,0 +1,2 @@ +#define TGS_UNIMPLEMENTED "___unimplemented" +#define TGS_VERSION_PARAMETER "server_service_version" diff --git a/DMAPI/tgs/core/core.dm b/DMAPI/tgs/core/core.dm new file mode 100644 index 0000000000..ffeab4289b --- /dev/null +++ b/DMAPI/tgs/core/core.dm @@ -0,0 +1,139 @@ +/world/TgsNew(datum/tgs_event_handler/event_handler) + var/tgs_version = world.params[TGS_VERSION_PARAMETER] + if(!tgs_version) + return + + var/path = SelectTgsApi(tgs_version) + if(!path) + TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.") + + var/datum/tgs_api/new_api = new path + TGS_INFO_LOG("Activated tgstation-server API for version [tgs_version]") + + var/result = new_api.OnWorldNew(event_handler ? event_handler : new /datum/tgs_event_handler/tgs_default) + if(result && result != TGS_UNIMPLEMENTED) + TGS_WRITE_GLOBAL(tgs, new_api) + +/world/proc/SelectTgsApi(tgs_version) + var/list/version_bits = splittext(tgs_version, ".") + + var/super = text2num(version_bits[0]) + var/major = text2num(version_bits[1]) + var/minor = text2num(version_bits[2]) + var/patch = text2num(version_bits[3]) + + switch(super) + if(3) + switch(major) + if(2) + return /datum/tgs_api/v3210 + + if(super != null && major != null && minor != null && patch != null && tgs_version > TgsMaximumAPIVersion()) + TGS_ERROR_LOG("Detected unknown API version! Defaulting to latest. Update the DMAPI to fix this problem.") + return /datum/tgs_api/latest + +/world/TgsMaximumAPIVersion() + return "4.0.0.0" + +/world/TgsMinimumAPIVersion() + return "3.2.0.0" + +/world/TgsInitializationComplete() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.OnInitializationComplete() + +/world/proc/TgsTopic(T) + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + var/result = api.OnTopic(T) + if(result != TGS_UNIMPLEMENTED) + return result + +/world/TgsRevision() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + var/result = api.Revision() + if(result != TGS_UNIMPLEMENTED) + return result + +/world/TgsReboot() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.OnReboot() + +/world/TgsAvailable() + return TGS_READ_GLOBAL(tgs) != null + +/world/TgsVersion() + return world.params[TGS_VERSION_PARAMETER] + +/world/TgsInstanceName() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + var/result = api.InstanceName() + if(result != TGS_UNIMPLEMENTED) + return result + +/world/TgsTestMerges() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + var/result = api.TestMerges() + if(result != TGS_UNIMPLEMENTED) + return result + return list() + +/world/TgsEndProcess() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.EndProcess() + +/world/TgsChatChannelInfo() + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + var/result = api.ChatChannelInfo() + if(result != TGS_UNIMPLEMENTED) + return result + return list() + +/world/TgsChatBroadcast(message, list/channels) + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.ChatBroadcast(message, channels) + +/world/TgsTargetedChatBroadcast(message, admin_only) + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.ChatTargetedBroadcast(message, admin_only) + +/world/TgsChatPrivateMessage(message, datum/tgs_chat_user/user) + var/datum/tgs_api/api = TGS_READ_GLOBAL(tgs) + if(api) + api.ChatPrivateMessage(message, user) + +/* +The MIT License + +Copyright (c) 2017 Jordan Brown + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/DMAPI/tgs/core/datum.dm b/DMAPI/tgs/core/datum.dm new file mode 100644 index 0000000000..0a8782529e --- /dev/null +++ b/DMAPI/tgs/core/datum.dm @@ -0,0 +1,74 @@ +TGS_DEFINE_AND_SET_GLOBAL(datum/tgs_api/tgs, null) + +/datum/tgs_api + +/datum/tgs_api/latest + parent_type = /datum/tgs_api/v3210 + +TGS_PROTECT_DATUM(/datum/tgs_api) + +/datum/tgs_api/proc/ApiVersion() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/OnWorldNew(datum/tgs_event_handler/event_handler) + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/OnInitializationComplete() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/OnTopic(T) + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/OnReboot() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/InstanceName() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/TestMerges() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/EndProcess() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/Revision() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/ChatChannelInfo() + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/ChatBroadcast(message, list/channels) + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/ChatTargetedBroadcast(message, admin_only) + return TGS_UNIMPLEMENTED + +/datum/tgs_api/proc/ChatPrivateMessage(message, admin_only) + return TGS_UNIMPLEMENTED + +/* +The MIT License + +Copyright (c) 2017 Jordan Brown + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/DMAPI/tgs/core/default_event_handler.dm b/DMAPI/tgs/core/default_event_handler.dm new file mode 100644 index 0000000000..716715bb26 --- /dev/null +++ b/DMAPI/tgs/core/default_event_handler.dm @@ -0,0 +1,30 @@ +/datum/tgs_event_handler/tgs_default/HandleEvent(event_code) + //TODO + return + +/* +The MIT License + +Copyright (c) 2017 Jordan Brown + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/DMAPI/tgs/includes.dm b/DMAPI/tgs/includes.dm new file mode 100644 index 0000000000..7ca906c840 --- /dev/null +++ b/DMAPI/tgs/includes.dm @@ -0,0 +1,6 @@ +#include "core\_definitions.dm" +#include "core\core.dm" +#include "core\datum.dm" +#include "core\default_event_handler.dm" +#include "v3210\api.dm" +#include "v3210\commands.dm" diff --git a/DMAPI/tgs/v3210/api.dm b/DMAPI/tgs/v3210/api.dm new file mode 100644 index 0000000000..7de257f9b4 --- /dev/null +++ b/DMAPI/tgs/v3210/api.dm @@ -0,0 +1,242 @@ +#define REBOOT_MODE_NORMAL 0 +#define REBOOT_MODE_HARD 1 +#define REBOOT_MODE_SHUTDOWN 2 + +#define SERVICE_WORLD_PARAM "server_service" +#define SERVICE_INSTANCE_PARAM "server_instance" +#define SERVICE_PR_TEST_JSON "prtestjob.json" +#define SERVICE_INTERFACE_DLL "TGDreamDaemonBridge.dll" +#define SERVICE_INTERFACE_FUNCTION "DDEntryPoint" + +#define SERVICE_CMD_HARD_REBOOT "hard_reboot" +#define SERVICE_CMD_GRACEFUL_SHUTDOWN "graceful_shutdown" +#define SERVICE_CMD_WORLD_ANNOUNCE "world_announce" +#define SERVICE_CMD_LIST_CUSTOM "list_custom_commands" +#define SERVICE_CMD_API_COMPATIBLE "api_compat" +#define SERVICE_CMD_PLAYER_COUNT "client_count" + +#define SERVICE_CMD_PARAM_KEY "serviceCommsKey" +#define SERVICE_CMD_PARAM_COMMAND "command" +#define SERVICE_CMD_PARAM_SENDER "sender" +#define SERVICE_CMD_PARAM_CUSTOM "custom" + +#define SERVICE_REQUEST_KILL_PROCESS "killme" +#define SERVICE_REQUEST_IRC_BROADCAST "irc" +#define SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE "send2irc" +#define SERVICE_REQUEST_WORLD_REBOOT "worldreboot" +#define SERVICE_REQUEST_API_VERSION "api_ver" + +#define SERVICE_RETURN_SUCCESS "SUCCESS" + +/datum/tgs_api/v3210 + var/reboot_mode = REBOOT_MODE_NORMAL + var/comms_key + var/instance_name + var/originmastercommit + var/commit + var/list/cached_custom_tgs_chat_commands + var/warned_revison = FALSE + var/warned_custom_commands = FALSE + +/datum/tgs_api/v3210/ApiVersion() + return "3.2.1.0" + +/datum/tgs_api/v3210/proc/trim_left(text) + for (var/i = 1 to length(text)) + if (text2ascii(text, i) > 32) + return copytext(text, i) + return "" + +/datum/tgs_api/v3210/proc/trim_right(text) + for (var/i = length(text), i > 0, i--) + if (text2ascii(text, i) > 32) + return copytext(text, 1, i + 1) + return "" + +/datum/tgs_api/v3210/OnWorldNew(datum/tgs_event_handler/event_handler) //don't use event handling in this version + comms_key = world.params[SERVICE_WORLD_PARAM] + instance_name = world.params[SERVICE_INSTANCE_PARAM] + if(!instance_name) + instance_name = "TG Station Server" //maybe just upgraded + + var/list/logs = splittext(trim_left(trim_right(file2text(".git/logs/HEAD"))), "\n") + if(logs.len) + logs = splittext(logs[logs.len - 1], " ") + commit = logs[2] + logs = world.file2list(".git/logs/refs/remotes/origin/master") + if(logs.len) + originmastercommit = splittext(logs[logs.len - 1], " ")[2] + + if(world.system_type != MS_WINDOWS) + TGS_ERROR_LOG("This API version is only supported on Windows. Not running on Windows. Aborting initialization!") + return FALSE + ListServiceCustomCommands(TRUE) + ExportService("[SERVICE_REQUEST_API_VERSION] [ApiVersion()]", TRUE) + +/world/proc/file2list(filename, seperator="\n", trim = TRUE) + +//nothing to do for v3 +/datum/tgs_api/v3210/OnInitializationComplete() + return + +/datum/tgs_api/v3210/InstanceName() + return world.params[SERVICE_INSTANCE_PARAM] + +/datum/tgs_api/v3210/proc/ExportService(command, skip_compat_check = FALSE) + . = FALSE + if(skip_compat_check && !fexists(SERVICE_INTERFACE_DLL)) + TGS_ERROR_LOG("Service parameter present but no interface DLL detected. This is symptomatic of running a service less than version 3.1! Please upgrade.") + return + call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(instance_name, command) //trust no retval + return TRUE + +/datum/tgs_api/v3210/OnTopic(T) + var/list/params = params2list(T) + var/their_sCK = params[SERVICE_CMD_PARAM_KEY] + if(!their_sCK) + return FALSE //continue world/Topic + + if(their_sCK != comms_key) + return "Invalid comms key!"; + + var/command = params[SERVICE_CMD_PARAM_COMMAND] + if(!command) + return "No command!" + + switch(command) + if(SERVICE_CMD_API_COMPATIBLE) + return SERVICE_RETURN_SUCCESS + if(SERVICE_CMD_HARD_REBOOT) + if(reboot_mode != REBOOT_MODE_HARD) + reboot_mode = REBOOT_MODE_HARD + TGS_INFO_LOG("Hard reboot requested by service") + TGS_NOTIFY_ADMINS("The world will hard reboot at the end of the game. Requested by TGS.") + if(SERVICE_CMD_GRACEFUL_SHUTDOWN) + if(reboot_mode != REBOOT_MODE_SHUTDOWN) + reboot_mode = REBOOT_MODE_SHUTDOWN + TGS_INFO_LOG("Shutdown requested by service") + TGS_NOTIFY_ADMINS("The world will shutdown at the end of the game. Requested by TGS.") + if(SERVICE_CMD_WORLD_ANNOUNCE) + var/msg = params["message"] + if(!istext(msg) || !msg) + return "No message set!" + TGS_WORLD_ANNOUNCE(msg) + return SERVICE_RETURN_SUCCESS + if(SERVICE_CMD_PLAYER_COUNT) + return "[TGS_CLIENT_COUNT]" + if(SERVICE_CMD_LIST_CUSTOM) + return json_encode(ListServiceCustomCommands(FALSE)) + else + var/custom_command_result = HandleServiceCustomCommand(lowertext(command), params[SERVICE_CMD_PARAM_SENDER], params[SERVICE_CMD_PARAM_CUSTOM]) + if(custom_command_result) + return istext(custom_command_result) ? custom_command_result : SERVICE_RETURN_SUCCESS + return "Unknown command: [command]" + +/datum/tgs_api/v3210/OnReboot() + switch(reboot_mode) + if(REBOOT_MODE_HARD) + TGS_WORLD_ANNOUNCE("Hard reboot triggered, you will automatically reconnect...") + EndProcess() + if(REBOOT_MODE_SHUTDOWN) + TGS_WORLD_ANNOUNCE("The server is shutting down...") + EndProcess() + else + ExportService(SERVICE_REQUEST_WORLD_REBOOT) //just let em know + +/datum/tgs_api/v3210/TestMerges() + //do the best we can here as the datum can't be completed using the v3 api + . = list() + if(!fexists(SERVICE_PR_TEST_JSON)) + return + var/list/json = json_decode(file2text(SERVICE_PR_TEST_JSON)) + if(!json) + return + for(var/I in json) + var/datum/tgs_revision_information/test_merge/tm = new + tm.number = text2num(I) + var/list/entry = json[I] + tm.pull_request_commit = entry["commit"] + tm.author = entry["author"] + tm.title = entry["title"] + . += tm + +/datum/tgs_api/v3210/Revision() + if(!warned_revison) + TGS_ERROR_LOG("Use of TgsRevision on [ApiVersion()] origin_commit only points to master!") + warned_revison = TRUE + var/datum/tgs_revision_information/ri = new + ri.commit = commit + ri.origin_commit = originmastercommit + +/datum/tgs_api/v3210/EndProcess() + sleep(world.tick_lag) //flush the buffers + ExportService(SERVICE_REQUEST_KILL_PROCESS) + +/datum/tgs_api/v3210/ChatChannelInfo() + return list() + +/datum/tgs_api/v3210/ChatBroadcast(message, list/channels) + return TGS_UNIMPLEMENTED + +/datum/tgs_api/v3210/ChatTargetedBroadcast(message, admin_only) + ExportService("[admin_only ? SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE : SERVICE_REQUEST_IRC_BROADCAST] [message]") + +/datum/tgs_api/v3210/ChatPrivateMessage(message, admin_only) + return TGS_UNIMPLEMENTED + +#undef REBOOT_MODE_NORMAL +#undef REBOOT_MODE_HARD +#undef REBOOT_MODE_SHUTDOWN + +#undef SERVICE_WORLD_PARAM +#undef SERVICE_INSTANCE_PARAM +#undef SERVICE_PR_TEST_JSON +#undef SERVICE_INTERFACE_DLL +#undef SERVICE_INTERFACE_FUNCTION + +#undef SERVICE_CMD_HARD_REBOOT +#undef SERVICE_CMD_GRACEFUL_SHUTDOWN +#undef SERVICE_CMD_WORLD_ANNOUNCE +#undef SERVICE_CMD_LIST_CUSTOM +#undef SERVICE_CMD_API_COMPATIBLE +#undef SERVICE_CMD_PLAYER_COUNT + +#undef SERVICE_CMD_PARAM_KEY +#undef SERVICE_CMD_PARAM_COMMAND +#undef SERVICE_CMD_PARAM_SENDER +#undef SERVICE_CMD_PARAM_CUSTOM + +#undef SERVICE_REQUEST_KILL_PROCESS +#undef SERVICE_REQUEST_IRC_BROADCAST +#undef SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE +#undef SERVICE_REQUEST_WORLD_REBOOT +#undef SERVICE_REQUEST_API_VERSION + +#undef SERVICE_RETURN_SUCCESS + +/* +The MIT License + +Copyright (c) 2017 Jordan Brown + +Permission is hereby granted, free of charge, +to any person obtaining a copy of this software and +associated documentation files (the "Software"), to +deal in the Software without restriction, including +without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom +the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/DMAPI/st_commands.dm b/DMAPI/tgs/v3210/commands.dm similarity index 51% rename from DMAPI/st_commands.dm rename to DMAPI/tgs/v3210/commands.dm index ce3fb1bb75..e823c16d26 100644 --- a/DMAPI/st_commands.dm +++ b/DMAPI/tgs/v3210/commands.dm @@ -1,54 +1,53 @@ -/datum/server_tools_command - var/name = "" //the string to trigger this command on a chat bot. e.g. TGS3_BOT: do_this_command - var/help_text = "" //help text for this command - var/required_parameters = 0 //number of parameters required for this command - var/admin_only = FALSE //set to TRUE if this command should only be usable by registered chat admins +#define SERVICE_JSON_PARAM_HELPTEXT "help_text" +#define SERVICE_JSON_PARAM_ADMINONLY "admin_only" +#define SERVICE_JSON_PARAM_REQUIREDPARAMETERS "required_parameters" -//override to implement command -//sender is the display name of who sent the command -//params is the trimmed string following the command name -/datum/server_tools_command/proc/Run(sender, params) - CRASH("[type] has no implementation for Run()") - -/world/proc/ListServiceCustomCommands(warnings_only) +/datum/tgs_api/v3210/proc/ListServiceCustomCommands(warnings_only) if(!warnings_only) . = list() var/list/command_name_types = list() var/list/warned_command_names = warnings_only ? list() : null - for(var/I in typesof(/datum/server_tools_command) - /datum/server_tools_command) - var/datum/server_tools_command/stc = I + var/warned_about_the_dangers_of_robutussin = !warnings_only + for(var/I in typesof(/datum/tgs_chat_command) - /datum/tgs_chat_command) + if(!warned_about_the_dangers_of_robutussin) + TGS_ERROR_LOG("Custom chat commands in [ApiVersion()] lacks the /datum/tgs_chat_user/sender.channel field!") + warned_about_the_dangers_of_robutussin = TRUE + var/datum/tgs_chat_command/stc = I var/command_name = initial(stc.name) - var/static/list/warned_server_tools_names = list() if(!command_name || findtext(command_name, " ") || findtext(command_name, "'") || findtext(command_name, "\"")) if(warnings_only && !warned_command_names[command_name]) - SERVER_TOOLS_LOG("WARNING: Custom command [command_name] can't be used as it is empty or contains illegal characters!") + TGS_ERROR_LOG("Custom command [command_name] can't be used as it is empty or contains illegal characters!") warned_command_names[command_name] = TRUE continue if(command_name_types[command_name]) if(warnings_only) - SERVER_TOOLS_LOG("WARNING: Custom commands [command_name_types[command_name]] and [stc] have the same name, only [command_name_types[command_name]] will be available!") + TGS_ERROR_LOG("Custom commands [command_name_types[command_name]] and [stc] have the same name, only [command_name_types[command_name]] will be available!") continue command_name_types[stc] = command_name if(!warnings_only) - .[command_name] = list(SERVICE_JSON_PARAM_HELPTEXT = initial(stc.help_text), SERVICE_JSON_PARAM_ADMINONLY = initial(stc.admin_only), SERVICE_JSON_PARAM_REQUIREDPARAMETERS = initial(stc.required_parameters)) + .[command_name] = list(SERVICE_JSON_PARAM_HELPTEXT = initial(stc.help_text), SERVICE_JSON_PARAM_ADMINONLY = initial(stc.admin_only), SERVICE_JSON_PARAM_REQUIREDPARAMETERS = 0) -/world/proc/HandleServiceCustomCommand(command, sender, params) - var/static/list/cached_custom_server_tools_commands - if(!cached_custom_server_tools_commands) - cached_custom_server_tools_commands = list() - for(var/I in typesof(/datum/server_tools_command) - /datum/server_tools_command) - var/datum/server_tools_command/stc = I - cached_custom_server_tools_commands[lowertext(initial(stc.name))] = stc +/datum/tgs_api/v3210/proc/HandleServiceCustomCommand(command, sender, params) + if(!cached_custom_tgs_chat_commands) + cached_custom_tgs_chat_commands = list() + for(var/I in typesof(/datum/tgs_chat_command) - /datum/tgs_chat_command) + var/datum/tgs_chat_command/stc = I + cached_custom_tgs_chat_commands[lowertext(initial(stc.name))] = stc - var/command_type = cached_custom_server_tools_commands[command] + var/command_type = cached_custom_tgs_chat_commands[command] if(!command_type) return FALSE - var/datum/server_tools_command/stc = new command_type + var/datum/tgs_chat_command/stc = new command_type return stc.Run(sender, params) || TRUE /* + +#undef SERVICE_JSON_PARAM_HELPTEXT +#undef SERVICE_JSON_PARAM_ADMINONLY +#undef SERVICE_JSON_PARAM_REQUIREDPARAMETERS + The MIT License Copyright (c) 2017 Jordan Brown diff --git a/TGS.Tests/TGS.Tests.csproj b/TGS.Tests/TGS.Tests.csproj index df98e93aeb..c0cc4f3a84 100644 --- a/TGS.Tests/TGS.Tests.csproj +++ b/TGS.Tests/TGS.Tests.csproj @@ -79,23 +79,23 @@ {89191f69-b18e-4b59-b72e-e12f9b6811a0} - TGCommandLine + TGS.CommandLine {394e7643-6b8c-416f-ab18-95ac12648cdc} - TGControlPanel + TGS.ControlPanel {8956d4c3-bfb9-448e-bf5f-ee7e6f9996f9} - TGInstallerWrapper + TGS.Installer.UI {f32eda25-0855-411c-af5e-f0d042917e2d} - TGServerService + TGS.Server {ac4e7e8b-f83a-481c-a8b0-8fa4e8ae59ab} - TGServiceInterface + TGS.Interface diff --git a/TGStationServer3.sln b/TGStationServer3.sln index 8b72b2546b..c31cc7e5ac 100644 --- a/TGStationServer3.sln +++ b/TGStationServer3.sln @@ -65,10 +65,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{3BB3DA66-970 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DMAPI", "DMAPI", "{9032B448-5E2B-4E71-8ECB-D5FB828E049C}" ProjectSection(SolutionItems) = preProject - DMAPI\server_tools.dm = DMAPI\server_tools.dm - DMAPI\st_commands.dm = DMAPI\st_commands.dm - DMAPI\st_interface.dm = DMAPI\st_interface.dm - TGS3.json = TGS3.json + DMAPI\tgs.dm = DMAPI\tgs.dm EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{081BB0BB-2E84-47D4-9419-A2AB8E814ABF}" @@ -77,7 +74,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{081BB0BB Tools\BuildDox.ps1 = Tools\BuildDox.ps1 Tools\Config.dm = Tools\Config.dm Tools\CoverageExclusions.runsettings = Tools\CoverageExclusions.runsettings - Tools\DMAPITravisTester.dme = Tools\DMAPITravisTester.dme Tools\Doxyfile = Tools\Doxyfile Tools\install_byond.sh = Tools\install_byond.sh Tools\PostCIBuild.ps1 = Tools\PostCIBuild.ps1 @@ -85,6 +81,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{081BB0BB Tools\SignMSI.ps1 = Tools\SignMSI.ps1 Tools\Test.dm = Tools\Test.dm Tools\tgstation13.org.pfx = Tools\tgstation13.org.pfx + Tools\travistester.dme = Tools\travistester.dme Tools\UploadCoverage.ps1 = Tools\UploadCoverage.ps1 EndProjectSection EndProject @@ -101,6 +98,25 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TGS.Server.Service", "TGS.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TGS.Server.Console", "TGS.Server.Console\TGS.Server.Console.csproj", "{509433F6-AEFB-44CA-BFE3-C782166D2CC3}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tgs", "tgs", "{E7103B1A-8097-4BD4-B642-E7A2FAB1B0F3}" + ProjectSection(SolutionItems) = preProject + DMAPI\tgs\includes.dm = DMAPI\tgs\includes.dm + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "core", "core", "{D30454E2-ABAF-4698-B5EC-D2E7C9641F43}" + ProjectSection(SolutionItems) = preProject + DMAPI\tgs\core\_definitions.dm = DMAPI\tgs\core\_definitions.dm + DMAPI\tgs\core\core.dm = DMAPI\tgs\core\core.dm + DMAPI\tgs\core\datum.dm = DMAPI\tgs\core\datum.dm + DMAPI\tgs\core\default_event_handler.dm = DMAPI\tgs\core\default_event_handler.dm + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "v3210", "v3210", "{FFECCA21-8B4A-4A70-B524-33DDDCA04850}" + ProjectSection(SolutionItems) = preProject + DMAPI\tgs\v3210\api.dm = DMAPI\tgs\v3210\api.dm + DMAPI\tgs\v3210\commands.dm = DMAPI\tgs\v3210\commands.dm + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -181,6 +197,9 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {3BB3DA66-970C-4AAE-A77C-9E40F5E7E56A} = {0DDF886A-7ABB-4DCA-96A3-349B2DA00016} + {E7103B1A-8097-4BD4-B642-E7A2FAB1B0F3} = {9032B448-5E2B-4E71-8ECB-D5FB828E049C} + {D30454E2-ABAF-4698-B5EC-D2E7C9641F43} = {E7103B1A-8097-4BD4-B642-E7A2FAB1B0F3} + {FFECCA21-8B4A-4A70-B524-33DDDCA04850} = {E7103B1A-8097-4BD4-B642-E7A2FAB1B0F3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1B511D10-AB55-43E0-B363-7F8838E9E977} diff --git a/Tools/Config.dm b/Tools/Config.dm index 2a65e3b036..6c7a2564ef 100644 --- a/Tools/Config.dm +++ b/Tools/Config.dm @@ -1,8 +1,10 @@ -#define SERVER_TOOLS_EXTERNAL_CONFIGURATION -#define SERVER_TOOLS_DEFINE_AND_SET_GLOBAL(Name, Value) var/##Name = ##Value -#define SERVER_TOOLS_READ_GLOBAL(Name) global.##Name -#define SERVER_TOOLS_WRITE_GLOBAL(Name, Value) global.##Name = ##Value -#define SERVER_TOOLS_WORLD_ANNOUNCE(message) world << ##message -#define SERVER_TOOLS_LOG(message) world.log << ##message -#define SERVER_TOOLS_NOTIFY_ADMINS(event) message_admins(event) -#define SERVER_TOOLS_CLIENT_COUNT clients.len \ No newline at end of file +#define TGS_EXTERNAL_CONFIGURATION +#define TGS_DEFINE_AND_SET_GLOBAL(Name, Value) var/##Name = ##Value +#define TGS_READ_GLOBAL(Name) global.##Name +#define TGS_WRITE_GLOBAL(Name, Value) global.##Name = ##Value +#define TGS_PROTECT_DATUM(Path) +#define TGS_WORLD_ANNOUNCE(message) world << ##message +#define TGS_INFO_LOG(message) world.log << "Info: [##message]" +#define TGS_ERROR_LOG(message) world.log << "Error: [##message]" +#define TGS_NOTIFY_ADMINS(event) message_admins(event) +#define TGS_CLIENT_COUNT clients.len diff --git a/Tools/Test.dm b/Tools/Test.dm index 91c97a26d6..addf8c7603 100644 --- a/Tools/Test.dm +++ b/Tools/Test.dm @@ -1,36 +1,18 @@ /world/New() - SERVER_TOOLS_ON_NEW - world.log << "Service API Version: [SERVER_TOOLS_API_VERSION]" - WaitForAPICompatResponse() + TgsNew() + TgsInitializationComplete() /world/Topic(T, Addr, Master, Keys) - SERVER_TOOLS_ON_TOPIC + TGS_TOPIC /world/Reboot(reason) - SERVER_TOOLS_ON_REBOOT - SERVER_TOOLS_REBOOT_BYOND(FALSE) + TgsReboot() /proc/message_admins(event) + event = "Admins: [event]" world << event world.log << event -/proc/WaitForAPICompatResponse() - set waitfor = FALSE - sleep(50) - if(!SERVER_TOOLS_PRESENT) - world.log << "No running service detected" - del(world) - return - world.log << "Running service version: [SERVER_TOOLS_VERSION]" - var/list/prs = SERVER_TOOLS_PR_LIST - for(var/I in prs) - var/data = prs[I] - world.log << "Testmerge: #[I]: [data["title"]] by [data["author"]] at commit [data["commit"]]" - var/checks_complete = "Server tools API checks complete! Rebooting..." - SERVER_TOOLS_CHAT_BROADCAST(checks_complete) - SERVER_TOOLS_RELAY_BROADCAST(checks_complete) - world.Reboot() - var/list/clients = list() /client/New() diff --git a/Tools/DMAPITravisTester.dme b/Tools/travistester.dme similarity index 71% rename from Tools/DMAPITravisTester.dme rename to Tools/travistester.dme index dd468a6dfe..94a15e4bc6 100644 --- a/Tools/DMAPITravisTester.dme +++ b/Tools/travistester.dme @@ -12,8 +12,7 @@ // BEGIN_INCLUDE #include "Config.dm" -#include "..\DMAPI\server_tools.dm" -#include "..\DMAPI\st_commands.dm" -#include "..\DMAPI\st_interface.dm" +#include "..\DMAPI\tgs.dm" +#include "..\DMAPI\tgs\includes.dm" #include "Test.dm" // END_INCLUDE From a7e5ff1867fc87fcb89bacd6f3579bc5d9b726b8 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 25 Apr 2018 12:50:20 -0400 Subject: [PATCH 05/52] Removes randomass file2list declaration --- DMAPI/tgs/v3210/api.dm | 2 -- 1 file changed, 2 deletions(-) diff --git a/DMAPI/tgs/v3210/api.dm b/DMAPI/tgs/v3210/api.dm index 7de257f9b4..8823aa6da0 100644 --- a/DMAPI/tgs/v3210/api.dm +++ b/DMAPI/tgs/v3210/api.dm @@ -73,8 +73,6 @@ ListServiceCustomCommands(TRUE) ExportService("[SERVICE_REQUEST_API_VERSION] [ApiVersion()]", TRUE) -/world/proc/file2list(filename, seperator="\n", trim = TRUE) - //nothing to do for v3 /datum/tgs_api/v3210/OnInitializationComplete() return From bbfc1a0af5f1303b334589a662156a70a12c5cbf Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 25 Apr 2018 12:54:35 -0400 Subject: [PATCH 06/52] Fixes master --- DMAPI/tgs/v3210/api.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DMAPI/tgs/v3210/api.dm b/DMAPI/tgs/v3210/api.dm index 8823aa6da0..38e264df98 100644 --- a/DMAPI/tgs/v3210/api.dm +++ b/DMAPI/tgs/v3210/api.dm @@ -53,17 +53,20 @@ return copytext(text, 1, i + 1) return "" +/datum/tgs_api/v3210/proc/file2list(filename) + return splittext(trim_left(trim_right(file2text(filename))), "\n") + /datum/tgs_api/v3210/OnWorldNew(datum/tgs_event_handler/event_handler) //don't use event handling in this version comms_key = world.params[SERVICE_WORLD_PARAM] instance_name = world.params[SERVICE_INSTANCE_PARAM] if(!instance_name) instance_name = "TG Station Server" //maybe just upgraded - var/list/logs = splittext(trim_left(trim_right(file2text(".git/logs/HEAD"))), "\n") + var/list/logs = sfile2list(".git/logs/HEAD") if(logs.len) logs = splittext(logs[logs.len - 1], " ") commit = logs[2] - logs = world.file2list(".git/logs/refs/remotes/origin/master") + logs = file2list(".git/logs/refs/remotes/origin/master") if(logs.len) originmastercommit = splittext(logs[logs.len - 1], " ")[2] From a8b373f2fb95bf16a045088db4f8277803fa3d4e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 25 Apr 2018 12:59:14 -0400 Subject: [PATCH 07/52] Further fixes --- DMAPI/tgs/v3210/api.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DMAPI/tgs/v3210/api.dm b/DMAPI/tgs/v3210/api.dm index 38e264df98..5f69889f07 100644 --- a/DMAPI/tgs/v3210/api.dm +++ b/DMAPI/tgs/v3210/api.dm @@ -62,7 +62,7 @@ if(!instance_name) instance_name = "TG Station Server" //maybe just upgraded - var/list/logs = sfile2list(".git/logs/HEAD") + var/list/logs = file2list(".git/logs/HEAD") if(logs.len) logs = splittext(logs[logs.len - 1], " ") commit = logs[2] @@ -177,7 +177,10 @@ return list() /datum/tgs_api/v3210/ChatBroadcast(message, list/channels) - return TGS_UNIMPLEMENTED + if(channels) + return TGS_UNIMPLEMENTED + ChatTargetedBroadcast(message, TRUE) + ChatTargetedBroadcast(message, FALSE) /datum/tgs_api/v3210/ChatTargetedBroadcast(message, admin_only) ExportService("[admin_only ? SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE : SERVICE_REQUEST_IRC_BROADCAST] [message]") From 303448457e1529c900fa183a8b3c7f2e5459acf1 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 25 Apr 2018 13:12:11 -0400 Subject: [PATCH 08/52] Fix global declaration --- DMAPI/tgs/core/datum.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DMAPI/tgs/core/datum.dm b/DMAPI/tgs/core/datum.dm index 0a8782529e..6af39a75df 100644 --- a/DMAPI/tgs/core/datum.dm +++ b/DMAPI/tgs/core/datum.dm @@ -1,4 +1,4 @@ -TGS_DEFINE_AND_SET_GLOBAL(datum/tgs_api/tgs, null) +TGS_DEFINE_AND_SET_GLOBAL(tgs, null) /datum/tgs_api From 0f25d03068a250575cdc0f09db4428e3cd9cace6 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 27 Apr 2018 10:06:46 -0400 Subject: [PATCH 09/52] Fix the command line being dense af --- TGS.CommandLine/Program.cs | 1 + TGS.CommandLine/RootCommands.cs | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TGS.CommandLine/Program.cs b/TGS.CommandLine/Program.cs index 369652de33..40e2ae456b 100644 --- a/TGS.CommandLine/Program.cs +++ b/TGS.CommandLine/Program.cs @@ -243,6 +243,7 @@ namespace TGS.CommandLine else { Console.WriteLine("Connected remotely"); + Console.WriteLine("Type 'instance' to connect to a server instance"); if (currentInterface.VersionMismatch(out error)) { SentVMMWarning = true; diff --git a/TGS.CommandLine/RootCommands.cs b/TGS.CommandLine/RootCommands.cs index 0de21674cd..309ebca351 100644 --- a/TGS.CommandLine/RootCommands.cs +++ b/TGS.CommandLine/RootCommands.cs @@ -8,14 +8,13 @@ namespace TGS.CommandLine { public CLICommand(IClient I) { - var tmp = new List { new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand() }; - if (ConsoleCommand.Instance.Administration != null) + var tmp = ConsoleCommand.Instance != null ? new List { new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand() } : new List(); + if (ConsoleCommand.Instance?.Administration != null) tmp.Add(new AdminCommand()); if (ConsoleCommand.Server.Management != null) tmp.Add(new ServiceCommand()); Children = tmp.ToArray(); } - public override void PrintHelp() { OutputProc("/tg/station 13 Server Command Line"); From d35693d554ae8f601ab0ce690ee1303050c9be75 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 27 Apr 2018 10:17:34 -0400 Subject: [PATCH 10/52] Version bump to 3.2.2.2 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index f85f91a029..9c37574541 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.2.1")] -[assembly: AssemblyFileVersion("3.2.2.1")] -[assembly: AssemblyInformationalVersion("3.2.2.1")] +[assembly: AssemblyVersion("3.2.2.2")] +[assembly: AssemblyFileVersion("3.2.2.2")] +[assembly: AssemblyInformationalVersion("3.2.2.2")] [assembly: InternalsVisibleTo("TGS.Tests")] From ca3d4b54139250dd3d7264ccb001ebc4c8850bab Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 28 Apr 2018 12:43:26 -0400 Subject: [PATCH 11/52] Remove old tgs_version header while processing --- DMAPI/tgs/core/core.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DMAPI/tgs/core/core.dm b/DMAPI/tgs/core/core.dm index ffeab4289b..faea16e3b9 100644 --- a/DMAPI/tgs/core/core.dm +++ b/DMAPI/tgs/core/core.dm @@ -15,6 +15,9 @@ TGS_WRITE_GLOBAL(tgs, new_api) /world/proc/SelectTgsApi(tgs_version) + //remove the old 3.0 header + tgs_version = replacetext(tgs_version, "/tg/station 13 Server v", "") + var/list/version_bits = splittext(tgs_version, ".") var/super = text2num(version_bits[0]) From 3dd51ae91780d7fed9f2ef350ebddfdad0989327 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 1 May 2018 17:44:55 -0400 Subject: [PATCH 12/52] Fix version indexing --- DMAPI/tgs/core/core.dm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DMAPI/tgs/core/core.dm b/DMAPI/tgs/core/core.dm index faea16e3b9..b15fd2c261 100644 --- a/DMAPI/tgs/core/core.dm +++ b/DMAPI/tgs/core/core.dm @@ -6,6 +6,7 @@ var/path = SelectTgsApi(tgs_version) if(!path) TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.") + return var/datum/tgs_api/new_api = new path TGS_INFO_LOG("Activated tgstation-server API for version [tgs_version]") @@ -20,10 +21,10 @@ var/list/version_bits = splittext(tgs_version, ".") - var/super = text2num(version_bits[0]) - var/major = text2num(version_bits[1]) - var/minor = text2num(version_bits[2]) - var/patch = text2num(version_bits[3]) + var/super = text2num(version_bits[1]) + var/major = text2num(version_bits[2]) + var/minor = text2num(version_bits[3]) + var/patch = text2num(version_bits[4]) switch(super) if(3) From b9ebff0259e0e2fa5185e4573cf7fb03f7a3a406 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 4 May 2018 11:56:38 -0400 Subject: [PATCH 13/52] Code quality CONTRIBUTING update --- .github/CONTRIBUTING.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 71f8dd3c10..15f8ebe73a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -53,10 +53,15 @@ As mentioned before, you are expected to follow these specifications in order to ### Object Oriented Code As C# is an object-oriented language, code must be object-oriented when possible in order to be more flexible when adding content to it. If you don't know what "object-oriented" means, we highly recommend you do some light research to grasp the basics. -### Tabs, not spaces -You must use tabs to indent your code, NOT SPACES. +### Follow the [C# coding guidelines](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions) -(You may use spaces to align something, but you should tab to the block level first, then add the remaining spaces) +With the following amendments for a focus on minimal code + +- Tabs, not spaces +- Use `var` whenever possible +- Prefer `using` statements to inline namespace imports +- One line blocks should not have braces where unneccessary (nested `if` statements may circumvent this to avoid confusion) +- Do not use the LINQ query syntax (The functions are acceptable) ### 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.) @@ -68,8 +73,8 @@ Copying code from one place to another may be suitable for small, short-time pro Instead you can use object orientation, or simply placing repeated code in a function, to obey this specification easily. -### No magic numbers or strings -This means stuff like having a "mode" variable for an object set to "1" or "2" with no clear indicator of what that means. Make these #defines with a name that more clearly states what it's for. This is clearer and enhances readability of your code! Get used to doing it! +### No duplicated magic numbers or strings +This means stuff like having a "mode" variable for an object set to "1" or "2" with no clear indicator of what that means. If it's used in more than one place, make these consts with a name that more clearly states what it's for. This is clearer and enhances readability of your code! Get used to doing it! ### Do not commit modifications to the version numbers in AssemblyInfo.global.cs This file will be updated by maintainers when they deem it prudent to release a new version. For reference here is the version format we use 3.\.\.\ The criteria for changing a version number is as follows @@ -110,13 +115,9 @@ void Hello() This prevents nesting levels from getting deeper then they need to be. ### 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. - -* Bloated code may be necessary to add a certain feature, which means there has to be a judgement over whether the feature is worth having or not. You can help make this decision easier by making sure your code is modular. - -* You are expected to help maintain the code that you add, meaning that if there is a problem then you are likely to be approached in order to fix any issues, runtimes, or bugs. - -* 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. +* Code should always be modular +* You are expected to help maintain the code that you add, meaning that if there is a problem then you are likely to be approached in order to fix any bugs. +* Non-prototype code must be unit tested with 100% code coverage ## Pull Request Process From 13f6c8deb87ed3241b771f63bb50840506997331 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 6 May 2018 09:12:26 -0400 Subject: [PATCH 14/52] Add missing TRUE return to v3202 API --- DMAPI/tgs/v3210/api.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DMAPI/tgs/v3210/api.dm b/DMAPI/tgs/v3210/api.dm index 5f69889f07..2302249763 100644 --- a/DMAPI/tgs/v3210/api.dm +++ b/DMAPI/tgs/v3210/api.dm @@ -57,6 +57,8 @@ return splittext(trim_left(trim_right(file2text(filename))), "\n") /datum/tgs_api/v3210/OnWorldNew(datum/tgs_event_handler/event_handler) //don't use event handling in this version + . = FALSE + comms_key = world.params[SERVICE_WORLD_PARAM] instance_name = world.params[SERVICE_INSTANCE_PARAM] if(!instance_name) @@ -72,9 +74,10 @@ if(world.system_type != MS_WINDOWS) TGS_ERROR_LOG("This API version is only supported on Windows. Not running on Windows. Aborting initialization!") - return FALSE + return ListServiceCustomCommands(TRUE) ExportService("[SERVICE_REQUEST_API_VERSION] [ApiVersion()]", TRUE) + return TRUE //nothing to do for v3 /datum/tgs_api/v3210/OnInitializationComplete() From bf57f9193a050c9a44dc67ff56d44442e0d52a79 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 6 May 2018 09:13:53 -0400 Subject: [PATCH 15/52] Fix activation message occuring for failed instatiations --- DMAPI/tgs/core/core.dm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DMAPI/tgs/core/core.dm b/DMAPI/tgs/core/core.dm index b15fd2c261..d24bc2c9ae 100644 --- a/DMAPI/tgs/core/core.dm +++ b/DMAPI/tgs/core/core.dm @@ -8,12 +8,14 @@ TGS_ERROR_LOG("Found unsupported API version: [tgs_version]. If this is a valid version please report this, backporting is done on demand.") return + TGS_INFO_LOG("Activating API for version [tgs_version]") var/datum/tgs_api/new_api = new path - TGS_INFO_LOG("Activated tgstation-server API for version [tgs_version]") var/result = new_api.OnWorldNew(event_handler ? event_handler : new /datum/tgs_event_handler/tgs_default) if(result && result != TGS_UNIMPLEMENTED) TGS_WRITE_GLOBAL(tgs, new_api) + else + TGS_ERROR_LOG("Failed to activate API!") /world/proc/SelectTgsApi(tgs_version) //remove the old 3.0 header From adaaa24fd2a6e3da64d57cf12cf0d1156924903e Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 6 May 2018 12:31:31 -0400 Subject: [PATCH 16/52] Fix v3 api not building chat user datum --- DMAPI/tgs/v3210/commands.dm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DMAPI/tgs/v3210/commands.dm b/DMAPI/tgs/v3210/commands.dm index e823c16d26..5046631981 100644 --- a/DMAPI/tgs/v3210/commands.dm +++ b/DMAPI/tgs/v3210/commands.dm @@ -40,7 +40,10 @@ if(!command_type) return FALSE var/datum/tgs_chat_command/stc = new command_type - return stc.Run(sender, params) || TRUE + var/datum/tgs_chat_user/user = new + user.friendly_name = sender + user.mention = sender + return stc.Run(user, params) || TRUE /* From 39e1b7b55c1f9c2181b9c3401e899f954086edb5 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 7 May 2018 12:04:31 -0400 Subject: [PATCH 17/52] Add ServerStartupTimeout to instance config --- TGS.Server/DeprecatedInstanceConfig.cs | 8 +++++++- TGS.Server/Instance/DreamDaemon.cs | 9 +++------ TGS.Server/InstanceConfig.cs | 10 +++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/TGS.Server/DeprecatedInstanceConfig.cs b/TGS.Server/DeprecatedInstanceConfig.cs index 8f06074e44..22affc940a 100644 --- a/TGS.Server/DeprecatedInstanceConfig.cs +++ b/TGS.Server/DeprecatedInstanceConfig.cs @@ -39,7 +39,13 @@ namespace TGS.Server /// void Migrate() { - //Not needed so far + switch (Version) + { + //add this field + case 0: + ServerStartupTimeout = 60; + break; + } } } } diff --git a/TGS.Server/Instance/DreamDaemon.cs b/TGS.Server/Instance/DreamDaemon.cs index 347514d1c7..e59b1d4f27 100644 --- a/TGS.Server/Instance/DreamDaemon.cs +++ b/TGS.Server/Instance/DreamDaemon.cs @@ -30,10 +30,6 @@ namespace TGS.Server /// const string ResourceDiagnosticsDir = DiagnosticsDir + "/Resources"; /// - /// Time until DD is considered DOA on startup - /// - const int DDHangStartTime = 60; - /// /// If DreamDaemon crashes before this time it is considered a bad startup /// const int DDBadStartTime = 10; @@ -625,14 +621,15 @@ namespace TGS.Server Proc.Start(); Proc.PriorityClass = ProcessPriorityClass.AboveNormal; - if (!Proc.WaitForInputIdle(DDHangStartTime * 1000)) + var timeout = Config.ServerStartupTimeout; + if (!Proc.WaitForInputIdle(timeout * 1000)) { Proc.Kill(); Proc.WaitForExit(); Proc.Close(); currentStatus = DreamDaemonStatus.Offline; currentPort = 0; - return String.Format("Server start is taking more than {0}s! Aborting!", DDHangStartTime); + return String.Format("Server start is taking more than {0}s! Aborting!", timeout); } currentPort = Config.Port; currentStatus = DreamDaemonStatus.Online; diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index 2e8bd592a3..e64f8edec3 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -113,6 +113,11 @@ namespace TGS.Server /// bool PushTestmergeCommits { get; set; } + /// + /// Time in seconds before DD is considered dead in the water + /// + int ServerStartupTimeout { get; set; } + /// /// Saves the to it's /// @@ -132,7 +137,7 @@ namespace TGS.Server /// The current version of the config /// [JsonIgnore] - protected const ulong CurrentVersion = 0; //Literally any time you add/deprecated a field, this number needs to be bumped + protected const ulong CurrentVersion = 1; //Literally any time you add/deprecated a field, this number needs to be bumped /// [JsonIgnore] @@ -198,6 +203,9 @@ namespace TGS.Server /// public bool PushTestmergeCommits { get; set; } = false; + /// + public int ServerStartupTimeout { get; set; } = 60; + /// /// Construct a for a at /// From 65e19d73904dc51aba0ad6b18257367cb4489c00 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 7 May 2018 12:56:23 -0400 Subject: [PATCH 18/52] Version bump to 3.2.2.3 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 9c37574541..8aed7cff80 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.2.2")] -[assembly: AssemblyFileVersion("3.2.2.2")] -[assembly: AssemblyInformationalVersion("3.2.2.2")] +[assembly: AssemblyVersion("3.2.2.3")] +[assembly: AssemblyFileVersion("3.2.2.3")] +[assembly: AssemblyInformationalVersion("3.2.2.3")] [assembly: InternalsVisibleTo("TGS.Tests")] From 5724e4c4c6fe1ffea724557cbdabcd1a03d55be4 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 4 Jun 2018 14:51:11 -0400 Subject: [PATCH 19/52] Moves the TLS 1.2 meme to global startup --- TGS.Server/Instance/Repository.cs | 2 -- TGS.Server/Server.cs | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index c1d4b7b571..a36eda4bb1 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -1016,8 +1016,6 @@ namespace TGS.Server prAPI = prAPI.Replace("github.com", "api.github.com/repos"); prAPI += "/pulls/" + PRNumberString + ".json"; string json; - //tls1.2 meme - ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; using (var wc = new WebClient()) { wc.Headers.Add("user-agent", "TGS.Server"); diff --git a/TGS.Server/Server.cs b/TGS.Server/Server.cs index 42351977b7..c907261038 100644 --- a/TGS.Server/Server.cs +++ b/TGS.Server/Server.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Net; using System.Reflection; using System.Security.Principal; using System.ServiceModel; @@ -89,6 +90,9 @@ namespace TGS.Server /// The to use public Server(string[] args, ILogger logger) { + //tls1.2 meme + ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; + Logger = logger; Environment.CurrentDirectory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Assembly.GetExecutingAssembly().GetName().Name)).FullName; //MOVE THIS POINTER BECAUSE ONE TIME I ALMOST ACCIDENTALLY NUKED MYSELF BY REFACTORING! http://imgur.com/zvGEpJD.png From 72a22245de47283b2e241188c828346647551d5c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 4 Jun 2018 15:18:54 -0400 Subject: [PATCH 20/52] Version bump to 3.2.2.4 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 8aed7cff80..fb6299a16b 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.2.3")] -[assembly: AssemblyFileVersion("3.2.2.3")] -[assembly: AssemblyInformationalVersion("3.2.2.3")] +[assembly: AssemblyVersion("3.2.2.4")] +[assembly: AssemblyFileVersion("3.2.2.4")] +[assembly: AssemblyInformationalVersion("3.2.2.4")] [assembly: InternalsVisibleTo("TGS.Tests")] From 478980ed65148b0e5304faffb8860006440c2e22 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 14 Jun 2018 15:59:40 -0400 Subject: [PATCH 21/52] Fix not deleting revision downloads --- TGS.Server/Instance/Byond.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TGS.Server/Instance/Byond.cs b/TGS.Server/Instance/Byond.cs index 768443aa77..91a8fca46d 100644 --- a/TGS.Server/Instance/Byond.cs +++ b/TGS.Server/Instance/Byond.cs @@ -268,7 +268,7 @@ namespace TGS.Server Directory.CreateDirectory(RelativePath(ByondConfigDir)); File.WriteAllText(RelativePath(ByondDDConfig), ByondNoPromptTrustedMode); } - File.Delete(RevisionDownloadPath); + File.Delete(rrdp); lock (ByondLock) { From 7d54a1b75e02bfdfb79e01a2780d17a0a1d79801 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 14 Jun 2018 16:00:50 -0400 Subject: [PATCH 22/52] Better handling of the staging directory --- TGS.Server/Instance/Byond.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/TGS.Server/Instance/Byond.cs b/TGS.Server/Instance/Byond.cs index 91a8fca46d..81bbc02352 100644 --- a/TGS.Server/Instance/Byond.cs +++ b/TGS.Server/Instance/Byond.cs @@ -261,14 +261,13 @@ namespace TGS.Server //STAGING ZipFile.ExtractToDirectory(rrdp, RelativePath(StagingDirectory)); - lock (ByondLock) - { - File.WriteAllText(RelativePath(StagingDirectoryInner + VersionFile), String.Format("{0}.{1}", major, minor)); - //IMPORTANT: SET THE BYOND CONFIG TO NOT PROMPT FOR TRUSTED MODE REEE - Directory.CreateDirectory(RelativePath(ByondConfigDir)); - File.WriteAllText(RelativePath(ByondDDConfig), ByondNoPromptTrustedMode); - } File.Delete(rrdp); + //IMPORTANT: SET THE BYOND CONFIG TO NOT PROMPT FOR TRUSTED MODE REEE + Directory.CreateDirectory(RelativePath(ByondConfigDir)); + File.WriteAllText(RelativePath(ByondDDConfig), ByondNoPromptTrustedMode); + + lock (ByondLock) + File.WriteAllText(RelativePath(StagingDirectoryInner + VersionFile), String.Format("{0}.{1}", major, minor)); lock (ByondLock) { From dc95bea143696ef0a48e8138234e9dd0bbd6b756 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 14 Jun 2018 16:18:39 -0400 Subject: [PATCH 23/52] Auto install included DX redis if upgrading to a byond version >= 512.1427 --- TGS.Server/Instance/Byond.cs | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/TGS.Server/Instance/Byond.cs b/TGS.Server/Instance/Byond.cs index 81bbc02352..59d1bc4606 100644 --- a/TGS.Server/Instance/Byond.cs +++ b/TGS.Server/Instance/Byond.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Net; +using System.Diagnostics; using System.Text.RegularExpressions; using System.Threading; using TGS.Interface; @@ -43,7 +44,11 @@ namespace TGS.Server /// /// The instance directory to modify the BYOND cfg before installation /// - const string ByondConfigDir = StagingDirectory + "/BYOND/cfg"; + const string ByondConfigDir = StagingDirectoryInner + "/cfg"; + /// + /// The instance that contains the BYOND directx redistributable + /// + const string ByondDXDir = StagingDirectoryInner + "/directx"; /// /// BYOND's DreamDaemon config file in the cfg modification directory /// @@ -76,6 +81,11 @@ namespace TGS.Server /// Thread RevisionStaging; + /// + /// Global lock for installing DirectX if necessary + /// + static object DirectXInstallLock = new object(); + /// /// Called when the is setup. Prepares the BYOND updater /// @@ -266,6 +276,44 @@ namespace TGS.Server Directory.CreateDirectory(RelativePath(ByondConfigDir)); File.WriteAllText(RelativePath(ByondDDConfig), ByondNoPromptTrustedMode); + if (major >= 512 && minor >= 1427) + { + if (Monitor.TryEnter(DirectXInstallLock)) + try + { + //always install it, it's pretty fast and will do better redundancy checking than us + using (var p = new Process()) + { + p.StartInfo.Arguments = "/silent"; + var rbdx = RelativePath(ByondDXDir); + p.StartInfo.FileName = rbdx + "/DXSETUP.exe"; + p.StartInfo.UseShellExecute = false; + p.StartInfo.WorkingDirectory = rbdx; + p.Start(); + try + { + p.WaitForExit(); + } + finally + { + try + { + p.Kill(); + p.WaitForExit(); + } + catch (InvalidOperationException) { } + } + + if(p.ExitCode != 0) + throw new Exception("Failed to install included DirectX! Exit code: " + p.ExitCode); + } + } + finally + { + Monitor.Exit(DirectXInstallLock); + } + } + lock (ByondLock) File.WriteAllText(RelativePath(StagingDirectoryInner + VersionFile), String.Format("{0}.{1}", major, minor)); From e49a95ba3c00959b6ad75f7ad38c30a1ad9e748b Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 14 Jun 2018 16:30:56 -0400 Subject: [PATCH 24/52] Version bump to 3.2.3.0 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index fb6299a16b..b25eb2006a 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.2.4")] -[assembly: AssemblyFileVersion("3.2.2.4")] -[assembly: AssemblyInformationalVersion("3.2.2.4")] +[assembly: AssemblyVersion("3.2.3.0")] +[assembly: AssemblyFileVersion("3.2.3.0")] +[assembly: AssemblyInformationalVersion("3.2.3.0")] [assembly: InternalsVisibleTo("TGS.Tests")] From aae178995323a4c2afb877eb3132afa0a22ccd14 Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Wed, 27 Jun 2018 18:07:19 +0300 Subject: [PATCH 25/52] Save configuration after modification --- TGS.Server/InstanceConfig.cs | 269 ++++++++++++++++++++++++----------- 1 file changed, 185 insertions(+), 84 deletions(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index e64f8edec3..906c4e6905 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -19,109 +19,210 @@ namespace TGS.Server /// ulong Version { get; } - /// - /// The name of the - /// - string Name { get; set; } + /// + /// The name of the + /// + string Name + { + get { return _name; } + set { _committername = value; Save(); } + } + private string _name; - /// - /// If the is active - /// - bool Enabled { get; set; } + /// + /// If the is active + /// + bool Enabled + { + get { return _enabled; } + set { _enabled = value; Save(); } + } + private bool _enabled; - /// - /// The name of the .dme/.dmb the uses - /// - string ProjectName { get; set; } + /// + /// The name of the .dme/.dmb the uses + /// + string ProjectName + { + get { return _projectname; } + set { _projectname = value; Save(); } + } + private string _projectname; - /// - /// The port the runs on - /// - ushort Port { get; set; } + /// + /// The port the runs on + /// + ushort Port + { + get { return _port; } + set { _port = value; Save(); } + } + private ushort _port; - /// - /// The level for the - /// - DreamDaemonSecurity Security { get; set; } + /// + /// The level for the + /// + DreamDaemonSecurity Security + { + get { return _dreamdaemonsecurity; } + set { _dreamdaemonsecurity = value; Save(); } + } + private DreamDaemonSecurity _security; - /// - /// Whether or not the should immediately start DreamDaemon when activated - /// - bool Autostart { get; set; } + /// + /// Whether or not the should immediately start DreamDaemon when activated + /// + bool Autostart + { + get { return _autostart; } + set { _autostart = value; Save(); } + } + private bool _autostart; - /// - /// Whether or not DreamDaemon allows connections from webclients - /// - bool Webclient { get; set; } + /// + /// Whether or not DreamDaemon allows connections from webclients + /// + bool Webclient + { + get { return _webclient; } + set { _webclient = value; Save(); } + } + private bool _webclient; - /// - /// Author and committer name for synchronize commits - /// - string CommitterName { get; set; } - /// - /// Author and committer e-mail for synchronize commits - /// - string CommitterEmail { get; set; } + /// + /// Author and committer name for synchronize commits + /// + string CommitterName + { + get { return _committername; } + set { _committername = value; Save(); } + } + private string _committername; - /// - /// Encrypted serialized s - /// - string ChatProviderData { get; set; } + /// + /// Author and committer e-mail for synchronize commits + /// + string CommitterEmail + { + get { return _committeremail; } + set { _committeremail = value; Save(); } + } + private string _committeremail; - /// - /// Entropy for - /// - string ChatProviderEntropy { get; set; } + /// + /// Encrypted serialized s + /// + string ChatProviderData + { + get { return _chatproviderdata; } + set { _chatproviderdata = value; Save(); } + } + private string _chatproviderdata; - /// - /// If the should reattach to a running DreamDaemon - /// - bool ReattachRequired { get; set; } + /// + /// Entropy for + /// + string ChatProviderEntropy + { + get { return _chatproviderentropy; } + set { _chatproviderentropy = value; Save(); } + } + private string _chatproviderentropy; - /// - /// The of the runnning DreamDaemon - /// - int ReattachProcessID { get; set; } + /// + /// If the should reattach to a running DreamDaemon + /// + bool ReattachRequired + { + get { return _reattachrequired; } + set { _reattachrequired = value; Save(); } + } + private bool _reattachrequired; - /// - /// The port the runnning DreamDaemon was launched on - /// - ushort ReattachPort { get; set; } + /// + /// The of the runnning DreamDaemon + /// + int ReattachProcessID + { + get { return _reattachprocessid; } + set { _reattachprocessid = value; Save(); } + } + private int _reattachprocessid; - /// - /// The serviceCommsKey the runnning DreamDaemon was launched on - /// - string ReattachCommsKey { get; set; } + /// + /// The port the runnning DreamDaemon was launched on + /// + ushort ReattachPort + { + get { return _reattachport; } + set { _reattachport = value; Save(); } + } + private ushort _reattachport; - /// - /// The API version of the runnning DreamDaemon - /// - string ReattachAPIVersion { get; set; } + /// + /// The serviceCommsKey the runnning DreamDaemon was launched on + /// + string ReattachCommsKey + { + get { return _reattachcommskey; } + set { _reattachcommskey = value; Save(); } + } + private string _reattachcommskey; - /// - /// The user group allowed to use the - /// - string AuthorizedUserGroupSID { get; set; } + /// + /// The API version of the runnning DreamDaemon + /// + string ReattachAPIVersion + { + get { return _reattachapiversion; } + set { _reattachapiversion = value; Save(); } + } + private string _reattachapiversion; - /// - /// The auto update interval for the - /// - ulong AutoUpdateInterval { get; set; } + /// + /// The user group allowed to use the + /// + string AuthorizedUserGroupSID + { + get { return _authorizedusergroupsid; } + set { _authorizedusergroupsid = value; Save(); } + } + private string _authorizedusergroupsid; - /// - /// Whether or not testmerge commits are published to a temporary remote branch - /// - bool PushTestmergeCommits { get; set; } + /// + /// The auto update interval for the + /// + ulong AutoUpdateInterval + { + get { return _autoupdateinterval; } + set { _autoupdateinterval = value; Save(); } + } + private private ulong _autoupdateinterval; - /// - /// Time in seconds before DD is considered dead in the water - /// - int ServerStartupTimeout { get; set; } + /// + /// Whether or not testmerge commits are published to a temporary remote branch + /// + bool PushTestmergeCommits + { + get { return _pushtestmergecommits; } + set { _pushtestmergecommits = value; Save(); } + } + private bool _pushtestmergecommits; - /// - /// Saves the to it's - /// - void Save(); + /// + /// Time in seconds before DD is considered dead in the water + /// + int ServerStartupTimeout + { + get { return _serverstartuptimeout; } + set { _serverstartuptimeout = value; Save(); } + } + private int _serverstartuptimeout; + + /// + /// Saves the to it's + /// + void Save(); } /// From c6fa8878987bb26d99868126db60636d05f5153c Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Wed, 27 Jun 2018 18:20:05 +0300 Subject: [PATCH 26/52] Revert "Save configuration after modification" This reverts commit aae178995323a4c2afb877eb3132afa0a22ccd14. --- TGS.Server/InstanceConfig.cs | 269 +++++++++++------------------------ 1 file changed, 84 insertions(+), 185 deletions(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index 906c4e6905..e64f8edec3 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -19,210 +19,109 @@ namespace TGS.Server /// ulong Version { get; } - /// - /// The name of the - /// - string Name - { - get { return _name; } - set { _committername = value; Save(); } - } - private string _name; + /// + /// The name of the + /// + string Name { get; set; } - /// - /// If the is active - /// - bool Enabled - { - get { return _enabled; } - set { _enabled = value; Save(); } - } - private bool _enabled; + /// + /// If the is active + /// + bool Enabled { get; set; } - /// - /// The name of the .dme/.dmb the uses - /// - string ProjectName - { - get { return _projectname; } - set { _projectname = value; Save(); } - } - private string _projectname; + /// + /// The name of the .dme/.dmb the uses + /// + string ProjectName { get; set; } - /// - /// The port the runs on - /// - ushort Port - { - get { return _port; } - set { _port = value; Save(); } - } - private ushort _port; + /// + /// The port the runs on + /// + ushort Port { get; set; } - /// - /// The level for the - /// - DreamDaemonSecurity Security - { - get { return _dreamdaemonsecurity; } - set { _dreamdaemonsecurity = value; Save(); } - } - private DreamDaemonSecurity _security; + /// + /// The level for the + /// + DreamDaemonSecurity Security { get; set; } - /// - /// Whether or not the should immediately start DreamDaemon when activated - /// - bool Autostart - { - get { return _autostart; } - set { _autostart = value; Save(); } - } - private bool _autostart; + /// + /// Whether or not the should immediately start DreamDaemon when activated + /// + bool Autostart { get; set; } - /// - /// Whether or not DreamDaemon allows connections from webclients - /// - bool Webclient - { - get { return _webclient; } - set { _webclient = value; Save(); } - } - private bool _webclient; + /// + /// Whether or not DreamDaemon allows connections from webclients + /// + bool Webclient { get; set; } - /// - /// Author and committer name for synchronize commits - /// - string CommitterName - { - get { return _committername; } - set { _committername = value; Save(); } - } - private string _committername; + /// + /// Author and committer name for synchronize commits + /// + string CommitterName { get; set; } + /// + /// Author and committer e-mail for synchronize commits + /// + string CommitterEmail { get; set; } - /// - /// Author and committer e-mail for synchronize commits - /// - string CommitterEmail - { - get { return _committeremail; } - set { _committeremail = value; Save(); } - } - private string _committeremail; + /// + /// Encrypted serialized s + /// + string ChatProviderData { get; set; } - /// - /// Encrypted serialized s - /// - string ChatProviderData - { - get { return _chatproviderdata; } - set { _chatproviderdata = value; Save(); } - } - private string _chatproviderdata; + /// + /// Entropy for + /// + string ChatProviderEntropy { get; set; } - /// - /// Entropy for - /// - string ChatProviderEntropy - { - get { return _chatproviderentropy; } - set { _chatproviderentropy = value; Save(); } - } - private string _chatproviderentropy; + /// + /// If the should reattach to a running DreamDaemon + /// + bool ReattachRequired { get; set; } - /// - /// If the should reattach to a running DreamDaemon - /// - bool ReattachRequired - { - get { return _reattachrequired; } - set { _reattachrequired = value; Save(); } - } - private bool _reattachrequired; + /// + /// The of the runnning DreamDaemon + /// + int ReattachProcessID { get; set; } - /// - /// The of the runnning DreamDaemon - /// - int ReattachProcessID - { - get { return _reattachprocessid; } - set { _reattachprocessid = value; Save(); } - } - private int _reattachprocessid; + /// + /// The port the runnning DreamDaemon was launched on + /// + ushort ReattachPort { get; set; } - /// - /// The port the runnning DreamDaemon was launched on - /// - ushort ReattachPort - { - get { return _reattachport; } - set { _reattachport = value; Save(); } - } - private ushort _reattachport; + /// + /// The serviceCommsKey the runnning DreamDaemon was launched on + /// + string ReattachCommsKey { get; set; } - /// - /// The serviceCommsKey the runnning DreamDaemon was launched on - /// - string ReattachCommsKey - { - get { return _reattachcommskey; } - set { _reattachcommskey = value; Save(); } - } - private string _reattachcommskey; + /// + /// The API version of the runnning DreamDaemon + /// + string ReattachAPIVersion { get; set; } - /// - /// The API version of the runnning DreamDaemon - /// - string ReattachAPIVersion - { - get { return _reattachapiversion; } - set { _reattachapiversion = value; Save(); } - } - private string _reattachapiversion; + /// + /// The user group allowed to use the + /// + string AuthorizedUserGroupSID { get; set; } - /// - /// The user group allowed to use the - /// - string AuthorizedUserGroupSID - { - get { return _authorizedusergroupsid; } - set { _authorizedusergroupsid = value; Save(); } - } - private string _authorizedusergroupsid; + /// + /// The auto update interval for the + /// + ulong AutoUpdateInterval { get; set; } - /// - /// The auto update interval for the - /// - ulong AutoUpdateInterval - { - get { return _autoupdateinterval; } - set { _autoupdateinterval = value; Save(); } - } - private private ulong _autoupdateinterval; + /// + /// Whether or not testmerge commits are published to a temporary remote branch + /// + bool PushTestmergeCommits { get; set; } - /// - /// Whether or not testmerge commits are published to a temporary remote branch - /// - bool PushTestmergeCommits - { - get { return _pushtestmergecommits; } - set { _pushtestmergecommits = value; Save(); } - } - private bool _pushtestmergecommits; + /// + /// Time in seconds before DD is considered dead in the water + /// + int ServerStartupTimeout { get; set; } - /// - /// Time in seconds before DD is considered dead in the water - /// - int ServerStartupTimeout - { - get { return _serverstartuptimeout; } - set { _serverstartuptimeout = value; Save(); } - } - private int _serverstartuptimeout; - - /// - /// Saves the to it's - /// - void Save(); + /// + /// Saves the to it's + /// + void Save(); } /// From a13cd0abef56874343d5c8829073ff28af215152 Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Wed, 27 Jun 2018 18:33:55 +0300 Subject: [PATCH 27/52] Maybe it works better if i actually modify the class and not the fucking interface --- TGS.Server/InstanceConfig.cs | 160 ++++++++++++++++++++++++++++------- 1 file changed, 130 insertions(+), 30 deletions(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index e64f8edec3..540483756f 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -147,64 +147,164 @@ namespace TGS.Server public ulong Version { get; protected set; } = CurrentVersion; /// - public string Name { get; set; } = "TG Station Server"; + public string Name + { + get { return _name; } + set { _name = value; Save(); } + } + private string _name = "TG Station Server"; /// - public bool Enabled { get; set; } = true; + public bool Enabled + { + get { return _enabled; } + set { _enabled = value; Save(); } + } + private string _enabled = true; /// - public string ProjectName { get; set; } = "tgstation"; + public string ProjectName + { + get { return _projectname; } + set { _projectname = value; Save(); } + } + private string _projectname = "tgstation"; /// - public ushort Port { get; set; } = 1337; + public ushort Port + { + get { return _port; } + set { _port = value; Save(); } + } + private ushort _port = 1337; /// - public DreamDaemonSecurity Security { get; set; } = DreamDaemonSecurity.Trusted; + public DreamDaemonSecurity Security + { + get { return _security; } + set { _security = value; Save(); } + } + private _security = DreamDaemonSecurity.Trusted; /// - public bool Autostart { get; set; } = false; + public bool Autostart + { + get { return _autostart; } + set { _autostart = value; Save(); } + } + private bool _autostart = false; /// - public bool Webclient { get; set; } = false; + public bool Webclient + { + get { return _webclient; } + set { _webclient = value; Save(); } + } + private bool _webclient = false; /// - public string CommitterName { get; set; } = "tgstation-server"; + public string CommitterName + { + get { return _committername; } + set { _committername = value; Save(); } + } + private string _committername = "tgstation-server"; /// - public string CommitterEmail { get; set; } = "tgstation-server@tgstation13.org"; + public string CommitterEmail + { + get { return _committeremail; } + set { _committeremail = value; Save(); } + } + private string _committeremail = "tgstation-server@tgstation13.org"; /// - public string ChatProviderData { get; set; } = Instance.UninitializedString; + public string ChatProviderData + { + get { return _chatproviderdata; } + set { _chatproviderdata = value; Save(); } + } + private string _chatproviderdata = Instance.UninitializedString; /// - public string ChatProviderEntropy { get; set; } + public string ChatProviderEntropy + { + get { return _chatproviderentropy; } + set { _chatproviderentropy = value; Save(); } + } + private string _chatproviderentropy; + + /// + public bool ReattachRequired + { + get { return _reattachrequired; } + set { _reattachrequired = value; Save(); } + } + private string _reattachrequired = false; /// - public bool ReattachRequired { get; set; } = false; + public int ReattachProcessID + { + get { return _reattachprocessid; } + set { _reattachprocessid = value; Save(); } + } + private int _reattachprocessid; + + /// + public ushort ReattachPort + { + get { return _reattachport; } + set { _reattachport = value; Save(); } + } + private int _reattachport; + + /// + public string ReattachCommsKey + { + get { return _reattachcommskey; } + set { _reattachcommskey = value; Save(); } + } + private int _reattachcommskey; + + /// + public string ReattachAPIVersion + { + get { return _reattachapiversion; } + set { _reattachapiversion = value; Save(); } + } + private string _reattachapiversion; + + /// + public string AuthorizedUserGroupSID + { + get { return _authorizedusergroupsid; } + set { _authorizedusergroupsid = value; Save(); } + } + private string _authorizedusergroupsid = null; /// - public int ReattachProcessID { get; set; } + public ulong AutoUpdateInterval + { + get { return _autoupdateinterval; } + set { _autoupdateinterval = value; Save(); } + } + private ulong _autoupdateinterval = 0; /// - public ushort ReattachPort { get; set; } + public bool PushTestmergeCommits + { + get { return _pushtestmergecommits; } + set { _pushtestmergecommits = value; Save(); } + } + private bool _pushtestmergecommits = false; /// - public string ReattachCommsKey { get; set; } - - /// - public string ReattachAPIVersion { get; set; } - - /// - public string AuthorizedUserGroupSID { get; set; } = null; - - /// - public ulong AutoUpdateInterval { get; set; } = 0; - - /// - public bool PushTestmergeCommits { get; set; } = false; - - /// - public int ServerStartupTimeout { get; set; } = 60; + public int ServerStartupTimeout + { + get { return _serverstartuptimeout; } + set { _serverstartuptimeout = value; Save(); } + } + private int _serverstartuptimeout = 60; /// /// Construct a for a at From 74855768d4c47dea098c9fd94f3aaba873c72bad Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Wed, 27 Jun 2018 18:36:46 +0300 Subject: [PATCH 28/52] oof --- TGS.Server/InstanceConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index 540483756f..817df86f07 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -184,7 +184,7 @@ namespace TGS.Server get { return _security; } set { _security = value; Save(); } } - private _security = DreamDaemonSecurity.Trusted; + private DreamDaemonSecurity _security = DreamDaemonSecurity.Trusted; /// public bool Autostart From f645a735e62d391c5c83a84b20999e5653f14136 Mon Sep 17 00:00:00 2001 From: vuonojenmustaturska Date: Wed, 27 Jun 2018 18:41:51 +0300 Subject: [PATCH 29/52] maybe now? --- TGS.Server/InstanceConfig.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index 817df86f07..5705b4fe7a 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -160,7 +160,7 @@ namespace TGS.Server get { return _enabled; } set { _enabled = value; Save(); } } - private string _enabled = true; + private bool _enabled = true; /// public string ProjectName @@ -240,7 +240,7 @@ namespace TGS.Server get { return _reattachrequired; } set { _reattachrequired = value; Save(); } } - private string _reattachrequired = false; + private bool _reattachrequired = false; /// public int ReattachProcessID @@ -256,7 +256,7 @@ namespace TGS.Server get { return _reattachport; } set { _reattachport = value; Save(); } } - private int _reattachport; + private ushort _reattachport; /// public string ReattachCommsKey @@ -264,7 +264,7 @@ namespace TGS.Server get { return _reattachcommskey; } set { _reattachcommskey = value; Save(); } } - private int _reattachcommskey; + private string _reattachcommskey; /// public string ReattachAPIVersion From 4909d9136affb6ca33d3898429ec1403b1e7bfd0 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 7 Jul 2018 00:30:31 -0400 Subject: [PATCH 30/52] Version bump to 3.2.3.1 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index b25eb2006a..539130b729 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.0")] -[assembly: AssemblyFileVersion("3.2.3.0")] -[assembly: AssemblyInformationalVersion("3.2.3.0")] +[assembly: AssemblyVersion("3.2.3.1")] +[assembly: AssemblyFileVersion("3.2.3.1")] +[assembly: AssemblyInformationalVersion("3.2.3.1")] [assembly: InternalsVisibleTo("TGS.Tests")] From a5ef2dd89fc6f82fe01f49f45016772fe2011984 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 7 Jul 2018 16:47:01 -0400 Subject: [PATCH 31/52] Revert "Save configuration after modification" --- TGS.Server/InstanceConfig.cs | 160 +++++++---------------------------- 1 file changed, 30 insertions(+), 130 deletions(-) diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index 5705b4fe7a..e64f8edec3 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -147,164 +147,64 @@ namespace TGS.Server public ulong Version { get; protected set; } = CurrentVersion; /// - public string Name - { - get { return _name; } - set { _name = value; Save(); } - } - private string _name = "TG Station Server"; + public string Name { get; set; } = "TG Station Server"; /// - public bool Enabled - { - get { return _enabled; } - set { _enabled = value; Save(); } - } - private bool _enabled = true; + public bool Enabled { get; set; } = true; /// - public string ProjectName - { - get { return _projectname; } - set { _projectname = value; Save(); } - } - private string _projectname = "tgstation"; + public string ProjectName { get; set; } = "tgstation"; /// - public ushort Port - { - get { return _port; } - set { _port = value; Save(); } - } - private ushort _port = 1337; + public ushort Port { get; set; } = 1337; /// - public DreamDaemonSecurity Security - { - get { return _security; } - set { _security = value; Save(); } - } - private DreamDaemonSecurity _security = DreamDaemonSecurity.Trusted; + public DreamDaemonSecurity Security { get; set; } = DreamDaemonSecurity.Trusted; /// - public bool Autostart - { - get { return _autostart; } - set { _autostart = value; Save(); } - } - private bool _autostart = false; + public bool Autostart { get; set; } = false; /// - public bool Webclient - { - get { return _webclient; } - set { _webclient = value; Save(); } - } - private bool _webclient = false; + public bool Webclient { get; set; } = false; /// - public string CommitterName - { - get { return _committername; } - set { _committername = value; Save(); } - } - private string _committername = "tgstation-server"; + public string CommitterName { get; set; } = "tgstation-server"; /// - public string CommitterEmail - { - get { return _committeremail; } - set { _committeremail = value; Save(); } - } - private string _committeremail = "tgstation-server@tgstation13.org"; + public string CommitterEmail { get; set; } = "tgstation-server@tgstation13.org"; /// - public string ChatProviderData - { - get { return _chatproviderdata; } - set { _chatproviderdata = value; Save(); } - } - private string _chatproviderdata = Instance.UninitializedString; + public string ChatProviderData { get; set; } = Instance.UninitializedString; /// - public string ChatProviderEntropy - { - get { return _chatproviderentropy; } - set { _chatproviderentropy = value; Save(); } - } - private string _chatproviderentropy; - - /// - public bool ReattachRequired - { - get { return _reattachrequired; } - set { _reattachrequired = value; Save(); } - } - private bool _reattachrequired = false; + public string ChatProviderEntropy { get; set; } /// - public int ReattachProcessID - { - get { return _reattachprocessid; } - set { _reattachprocessid = value; Save(); } - } - private int _reattachprocessid; - - /// - public ushort ReattachPort - { - get { return _reattachport; } - set { _reattachport = value; Save(); } - } - private ushort _reattachport; - - /// - public string ReattachCommsKey - { - get { return _reattachcommskey; } - set { _reattachcommskey = value; Save(); } - } - private string _reattachcommskey; - - /// - public string ReattachAPIVersion - { - get { return _reattachapiversion; } - set { _reattachapiversion = value; Save(); } - } - private string _reattachapiversion; - - /// - public string AuthorizedUserGroupSID - { - get { return _authorizedusergroupsid; } - set { _authorizedusergroupsid = value; Save(); } - } - private string _authorizedusergroupsid = null; + public bool ReattachRequired { get; set; } = false; /// - public ulong AutoUpdateInterval - { - get { return _autoupdateinterval; } - set { _autoupdateinterval = value; Save(); } - } - private ulong _autoupdateinterval = 0; + public int ReattachProcessID { get; set; } /// - public bool PushTestmergeCommits - { - get { return _pushtestmergecommits; } - set { _pushtestmergecommits = value; Save(); } - } - private bool _pushtestmergecommits = false; + public ushort ReattachPort { get; set; } /// - public int ServerStartupTimeout - { - get { return _serverstartuptimeout; } - set { _serverstartuptimeout = value; Save(); } - } - private int _serverstartuptimeout = 60; + public string ReattachCommsKey { get; set; } + + /// + public string ReattachAPIVersion { get; set; } + + /// + public string AuthorizedUserGroupSID { get; set; } = null; + + /// + public ulong AutoUpdateInterval { get; set; } = 0; + + /// + public bool PushTestmergeCommits { get; set; } = false; + + /// + public int ServerStartupTimeout { get; set; } = 60; /// /// Construct a for a at From 145a1622f03feeba3266304e198ca1a10249b651 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 9 Jul 2018 14:35:22 -0400 Subject: [PATCH 32/52] Brute force config saving --- TGS.Server/Instance/Chat.cs | 19 +++++++++++++------ TGS.Server/Instance/Compiler.cs | 1 + TGS.Server/Instance/DreamDaemon.cs | 4 ++++ TGS.Server/Instance/Repository.cs | 4 ++++ TGS.Server/InstanceConfig.cs | 4 +++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/TGS.Server/Instance/Chat.cs b/TGS.Server/Instance/Chat.cs index 75ebc44ea6..205241bfd4 100644 --- a/TGS.Server/Instance/Chat.cs +++ b/TGS.Server/Instance/Chat.cs @@ -102,20 +102,23 @@ namespace TGS.Server /// Properly shuts down all /// void DisposeChat() + { + SaveChatConfig(); + foreach (var ChatProvider in ChatProviders) + ChatProvider.Dispose(); + ChatProviders = null; + } + + void SaveChatConfig() { var infosList = new List>(); foreach (var ChatProvider in ChatProviders) - { infosList.Add(ChatProvider.ProviderInfo().DataFields); - ChatProvider.Dispose(); - } - ChatProviders = null; - var rawdata = JsonConvert.SerializeObject(infosList, Formatting.Indented); - Config.ChatProviderData = Interface.Helpers.EncryptData(rawdata, out string entrp); Config.ChatProviderEntropy = entrp; + Config.Save(); } /// @@ -166,6 +169,7 @@ namespace TGS.Server catch { Config.ChatProviderData = UninitializedString; + Config.Save(); } } //if we get here we want to retry @@ -186,7 +190,10 @@ namespace TGS.Server { foreach (var ChatProvider in ChatProviders) if (info.Provider == ChatProvider.ProviderInfo().Provider) + { + SaveChatConfig(); return ChatProvider.SetProviderInfo(info); + } return "Error: Invalid provider: " + info.Provider.ToString(); } } diff --git a/TGS.Server/Instance/Compiler.cs b/TGS.Server/Instance/Compiler.cs index db03e40940..3596a1068a 100644 --- a/TGS.Server/Instance/Compiler.cs +++ b/TGS.Server/Instance/Compiler.cs @@ -663,6 +663,7 @@ namespace TGS.Server lock (CompilerLock) { Config.ProjectName = projectName; + Config.Save(); } } diff --git a/TGS.Server/Instance/DreamDaemon.cs b/TGS.Server/Instance/DreamDaemon.cs index e59b1d4f27..69b03306df 100644 --- a/TGS.Server/Instance/DreamDaemon.cs +++ b/TGS.Server/Instance/DreamDaemon.cs @@ -237,6 +237,7 @@ namespace TGS.Server lock (watchdogLock) { Config.Port = new_port; + Config.Save(); RequestRestart(); } } @@ -665,6 +666,7 @@ namespace TGS.Server { needReboot = Config.Security != level; Config.Security = level; + Config.Save(); } if (needReboot) RequestRestart(); @@ -681,6 +683,7 @@ namespace TGS.Server public void SetAutostart(bool on) { Config.Autostart = on; + Config.Save(); } /// @@ -757,6 +760,7 @@ namespace TGS.Server if (diff) { Config.Webclient = on; + Config.Save(); RequestRestart(); } } diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index a36eda4bb1..df92b1a5a2 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -1093,6 +1093,7 @@ namespace TGS.Server public void SetCommitterName(string newName) { Config.CommitterName = newName; + Config.Save(); } /// @@ -1105,6 +1106,7 @@ namespace TGS.Server public void SetCommitterEmail(string newEmail) { Config.CommitterEmail = newEmail; + Config.Save(); } /// @@ -1403,6 +1405,7 @@ namespace TGS.Server } } Config.AutoUpdateInterval = newInterval; + Config.Save(); } /// @@ -1458,6 +1461,7 @@ namespace TGS.Server public void SetPushTestmergeCommits(bool newValue) { Config.PushTestmergeCommits = newValue; + Config.Save(); } } } diff --git a/TGS.Server/InstanceConfig.cs b/TGS.Server/InstanceConfig.cs index e64f8edec3..5cf13fcaf0 100644 --- a/TGS.Server/InstanceConfig.cs +++ b/TGS.Server/InstanceConfig.cs @@ -218,7 +218,9 @@ namespace TGS.Server /// public void Save() { - var data = JsonConvert.SerializeObject(this, Formatting.Indented); + string data; + lock(this) + data = JsonConvert.SerializeObject(this, Formatting.Indented); var path = Path.Combine(Directory, JSONFilename); File.WriteAllText(path, data); } From 3be963005537a4948bcd5386413b3ce8660703ed Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 9 Jul 2018 14:44:10 -0400 Subject: [PATCH 33/52] Version bump to 3.2.3.2 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 539130b729..58b068390b 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.1")] -[assembly: AssemblyFileVersion("3.2.3.1")] -[assembly: AssemblyInformationalVersion("3.2.3.1")] +[assembly: AssemblyVersion("3.2.3.2")] +[assembly: AssemblyFileVersion("3.2.3.2")] +[assembly: AssemblyInformationalVersion("3.2.3.2")] [assembly: InternalsVisibleTo("TGS.Tests")] From 2ed1ae8f8ef990c23d1f676f2fa8b90c7815abf6 Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 9 Jul 2018 17:54:39 -0400 Subject: [PATCH 34/52] Change Default Repo URL --- TGS.ControlPanel/ControlPanel/RepoPage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TGS.ControlPanel/ControlPanel/RepoPage.cs b/TGS.ControlPanel/ControlPanel/RepoPage.cs index 5743cc5d17..1a3f011341 100644 --- a/TGS.ControlPanel/ControlPanel/RepoPage.cs +++ b/TGS.ControlPanel/ControlPanel/RepoPage.cs @@ -91,7 +91,7 @@ namespace TGS.ControlPanel if (!Repo.Exists()) { //repo unavailable - RepoRemoteTextBox.Text = "https://github.com/tgstation/tgstation"; + RepoRemoteTextBox.Text = "git://github.com/tgstation/tgstation.git"; RepoBranchTextBox.Text = "master"; RepoProgressBarLabel.Text = "Unable to locate repository"; CloneRepositoryButton.Visible = true; From b1385c0da00fd6c8b5a87b485816bec226a5af8c Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 9 Jul 2018 17:57:10 -0400 Subject: [PATCH 35/52] Added Python and Repo Notes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd2e6d2d93..a43a5e51e1 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Requires python 2.7/3.6 to be installed for changelog generation ## Installing (GUI): 1. Launch `TGControlPanel.exe` as an administrator. A shortcut can be found on your desktop 1. Use the `Create Instance` button to create a new server instance -1. Go to the `Repository` Tab and set the remote address and branch of the git you with to track +1. Go to the `Repository` Tab and set the remote address and branch of the git you with to track. Note: To grab the tgstation repo, use the following URL: git://github.com/tgstation/tgstation.git 1. Hit the clone button 1. While waiting go to the `BYOND` tab and install the BYOND version you wish 1. You may also configure an IRC and/or discord bot for the server on the chat tab @@ -40,7 +40,7 @@ Requires python 2.7/3.6 to be installed for changelog generation ## Installing (CL example): This process is identical to the above steps in command line mode. You can always learn more about a command using `?` i.e. `repo ?` 1. Launch TGCommandLine.exe as an administrator (running with no parameters puts you in interactive mode) -1. `service set-python-path C:\Python27` +1. `service set-python-path C:\Python27` (If Your Python Install is in Program Files, You must encase the path in Quotes, Ex: "C:\Program Files\Python36") 1. `service create-instance "TGS" D:\tgstation` 1. `instance` And enter `TGS`. If you aren't using interactive mode, the following commands must be suffixed with `--instance TGS` 1. `repo setup https://github.com/tgstation/tgstation master` From a0bc4de8890de4e4521318451ed2298deef1f16b Mon Sep 17 00:00:00 2001 From: Ralph Date: Mon, 9 Jul 2018 18:06:50 -0400 Subject: [PATCH 36/52] Changed background color to lighter gray I've changed the System.Drawing.Color from a dark gray with black text, to a lighter gray making the text easier to read. --- .../ControlPanel/ControlPanel.Designer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs b/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs index ba5d05108f..e07fcf934f 100644 --- a/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs +++ b/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs @@ -1,4 +1,4 @@ -namespace TGS.ControlPanel +namespace TGS.ControlPanel { partial class ControlPanel { @@ -179,7 +179,7 @@ // // ChatPanel // - this.ChatPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.ChatPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.ChatPanel.Controls.Add(this.label5); this.ChatPanel.Controls.Add(this.label4); this.ChatPanel.Controls.Add(this.label3); @@ -623,7 +623,7 @@ // // ServerPanel // - this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.ServerPanel.Controls.Add(this.AutoUpdateMLabel); this.ServerPanel.Controls.Add(this.AutoUpdateInterval); this.ServerPanel.Controls.Add(this.AutoUpdateCheckbox); @@ -1061,7 +1061,7 @@ // // BYONDPanel // - this.BYONDPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.BYONDPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.BYONDPanel.Controls.Add(this.BYONDRefreshButton); this.BYONDPanel.Controls.Add(this.LatestVersionLabel); this.BYONDPanel.Controls.Add(this.LatestVersionTitle); @@ -1246,7 +1246,7 @@ // // RepoPanel // - this.RepoPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.RepoPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.RepoPanel.Controls.Add(this.SyncCommitsCheckBox); this.RepoPanel.Controls.Add(this.TGSJsonUpdate); this.RepoPanel.Controls.Add(this.RepoRefreshButton); @@ -1592,7 +1592,7 @@ // // StaticPanel // - this.StaticPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.StaticPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.StaticPanel.Controls.Add(this.RecreateStaticButton); this.StaticPanel.Controls.Add(this.StaticFileDownloadButton); this.StaticPanel.Controls.Add(this.StaticFilesRefreshButton); @@ -1723,7 +1723,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); this.ClientSize = new System.Drawing.Size(900, 415); this.Controls.Add(this.Panels); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); From b600b81c1a9a44d6b32f8166f5c1828f548f5cdb Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Tue, 10 Jul 2018 14:32:09 -0700 Subject: [PATCH 37/52] Fix port command in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd2e6d2d93..804c7c0534 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Note: Due to internal functionality, a user who has access to at least one serve ## Setting up Remote access 1. Obtain an SSL certificate to secure the connection (this is beyond the scope of this guide) -1. Either stick with the default port `38607` or change it with `admin set-port ` +1. Either stick with the default port `38607` or change it with `service set-port ` 1. [Bind the SSL certificate to the port](https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-a-port-with-an-ssl-certificate) - e.g. `netsh http add sslcert ipport=0.0.0.0: certhash= appid={F32EDA25-0855-411C-AF5E-F0D042917E2D}` - The `appid` GUID actually doesn't matter, but for sanity, you should use the GUID of TGServerService.exe as printed above From 0a08323a541e4458b8ca0ddc2dfebde48c00afb2 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 11 Jul 2018 20:26:11 -0400 Subject: [PATCH 38/52] Add IServer.RebuildhInstanceList() --- TGS.Interface/IServer.cs | 5 +++++ TGS.Interface/Server.cs | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/TGS.Interface/IServer.cs b/TGS.Interface/IServer.cs index a81c6de744..e9234f9a58 100644 --- a/TGS.Interface/IServer.cs +++ b/TGS.Interface/IServer.cs @@ -35,5 +35,10 @@ namespace TGS.Interface /// The name of the to get /// The named on success, on failure IInstance GetInstance(string name); + + /// + /// Rebuilds the internal cached list + /// + void RebuildInstanceList(); } } diff --git a/TGS.Interface/Server.cs b/TGS.Interface/Server.cs index d934528832..d5c953ee1f 100644 --- a/TGS.Interface/Server.cs +++ b/TGS.Interface/Server.cs @@ -15,7 +15,7 @@ namespace TGS.Interface { lock (this) if (knownInstances == null) - knownInstances = serverInterface.GetComponent(null).ListInstances(); + RebuildInstanceList(); foreach (var I in knownInstances) { IInstance nextInstance; @@ -92,5 +92,12 @@ namespace TGS.Interface { return new Instance(serverInterface, new InstanceMetadata { Name = name, Enabled = false }); } + + /// + public void RebuildInstanceList() + { + lock (this) + knownInstances = serverInterface.GetComponent(null).ListInstances(); + } } } From 9dc1088873f0e8d1671bb8160557e6fb8f9f5ee0 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 11 Jul 2018 20:26:32 -0400 Subject: [PATCH 39/52] Fix instance selector being unable to refresh --- TGS.ControlPanel/InstanceSelector.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TGS.ControlPanel/InstanceSelector.cs b/TGS.ControlPanel/InstanceSelector.cs index 6794995db2..09264953a9 100644 --- a/TGS.ControlPanel/InstanceSelector.cs +++ b/TGS.ControlPanel/InstanceSelector.cs @@ -58,6 +58,7 @@ namespace TGS.ControlPanel void RefreshInstances() { InstanceListBox.Items.Clear(); + server.RebuildInstanceList(); foreach(var I in server.Instances) InstanceListBox.Items.Add(I); var HasServerAdmin = server.InstanceManager != null; From 0ef5888437e17536e4eabdde7ecb9b12b3cace39 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 12 Jul 2018 12:23:40 -0400 Subject: [PATCH 40/52] Version bump to 3.2.3.3 [TGSDeploy] [NugetDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 58b068390b..73a0f54936 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.2")] -[assembly: AssemblyFileVersion("3.2.3.2")] -[assembly: AssemblyInformationalVersion("3.2.3.2")] +[assembly: AssemblyVersion("3.2.3.3")] +[assembly: AssemblyFileVersion("3.2.3.3")] +[assembly: AssemblyInformationalVersion("3.2.3.3")] [assembly: InternalsVisibleTo("TGS.Tests")] From febe4c85e72639b34d5d28b2da53d99d7cbfb1b1 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Fri, 13 Jul 2018 18:28:05 -0400 Subject: [PATCH 41/52] Revert "Changed background color to lighter gray" --- .../ControlPanel/ControlPanel.Designer.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs b/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs index e07fcf934f..ba5d05108f 100644 --- a/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs +++ b/TGS.ControlPanel/ControlPanel/ControlPanel.Designer.cs @@ -1,4 +1,4 @@ -namespace TGS.ControlPanel +namespace TGS.ControlPanel { partial class ControlPanel { @@ -179,7 +179,7 @@ namespace TGS.ControlPanel // // ChatPanel // - this.ChatPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.ChatPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.ChatPanel.Controls.Add(this.label5); this.ChatPanel.Controls.Add(this.label4); this.ChatPanel.Controls.Add(this.label3); @@ -623,7 +623,7 @@ namespace TGS.ControlPanel // // ServerPanel // - this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.ServerPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.ServerPanel.Controls.Add(this.AutoUpdateMLabel); this.ServerPanel.Controls.Add(this.AutoUpdateInterval); this.ServerPanel.Controls.Add(this.AutoUpdateCheckbox); @@ -1061,7 +1061,7 @@ namespace TGS.ControlPanel // // BYONDPanel // - this.BYONDPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.BYONDPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.BYONDPanel.Controls.Add(this.BYONDRefreshButton); this.BYONDPanel.Controls.Add(this.LatestVersionLabel); this.BYONDPanel.Controls.Add(this.LatestVersionTitle); @@ -1246,7 +1246,7 @@ namespace TGS.ControlPanel // // RepoPanel // - this.RepoPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.RepoPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.RepoPanel.Controls.Add(this.SyncCommitsCheckBox); this.RepoPanel.Controls.Add(this.TGSJsonUpdate); this.RepoPanel.Controls.Add(this.RepoRefreshButton); @@ -1592,7 +1592,7 @@ namespace TGS.ControlPanel // // StaticPanel // - this.StaticPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.StaticPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.StaticPanel.Controls.Add(this.RecreateStaticButton); this.StaticPanel.Controls.Add(this.StaticFileDownloadButton); this.StaticPanel.Controls.Add(this.StaticFilesRefreshButton); @@ -1723,7 +1723,7 @@ namespace TGS.ControlPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(133)))), ((int)(((byte)(143)))), ((int)(((byte)(160))))); + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34))))); this.ClientSize = new System.Drawing.Size(900, 415); this.Controls.Add(this.Panels); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); From 64ef5c9ce78385d3b96070de2b0fb2ea2b0a51b3 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sat, 14 Jul 2018 10:58:39 -0400 Subject: [PATCH 42/52] Confirm prompt for Remove All Test Merges button --- TGS.ControlPanel/ControlPanel/ServerPage.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TGS.ControlPanel/ControlPanel/ServerPage.cs b/TGS.ControlPanel/ControlPanel/ServerPage.cs index dee3c04e36..fcca62a386 100644 --- a/TGS.ControlPanel/ControlPanel/ServerPage.cs +++ b/TGS.ControlPanel/ControlPanel/ServerPage.cs @@ -404,6 +404,8 @@ namespace TGS.ControlPanel /// The async void RemoveAllTestMergesButton_Click(object sender, EventArgs e) { + if (MessageBox.Show("Are you sure you want to remove all test merges?", "Confirm", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; try { UseWaitCursor = true; From 42650839b3393db271eb6e1bc0564940ccee18b6 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 15 Jul 2018 17:23:49 -0400 Subject: [PATCH 43/52] Adds more watchdog logs --- TGS.Server/Instance/DreamDaemon.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/TGS.Server/Instance/DreamDaemon.cs b/TGS.Server/Instance/DreamDaemon.cs index 69b03306df..dff55061cc 100644 --- a/TGS.Server/Instance/DreamDaemon.cs +++ b/TGS.Server/Instance/DreamDaemon.cs @@ -374,7 +374,9 @@ namespace TGS.Server } } - WriteCurrentDDLog("Crash detected!"); + WriteCurrentDDLog("Crash detected! Exit code: ": Proc.ExitCode); + var runtimeS = (DateTime.Now - starttime).TotalSeconds; + WriteWarning("DD crashed: Exit Code: " + Proc.ExitCode + " Seconds running: " + runtimeS); lock (watchdogLock) { @@ -384,7 +386,7 @@ namespace TGS.Server if (AwaitingShutdown == ShutdownRequestPhase.Pinged) return; - var BadStart = (DateTime.Now - starttime).TotalSeconds < DDBadStartTime; + var BadStart = runtimeS < DDBadStartTime; if (BadStart) { ++retries; @@ -619,6 +621,7 @@ namespace TGS.Server { GameAPIVersion = null; //needs updating } + WriteInfo("Starting DD: " + Proc.StartInfo.FileName + " " + Proc.StartInfo.Arguments); Proc.Start(); Proc.PriorityClass = ProcessPriorityClass.AboveNormal; From 4476b3a723fd0b0934b243a894fbe2e5cce97d31 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 15 Jul 2018 17:43:28 -0400 Subject: [PATCH 44/52] Fix --- TGS.Server/EventID.cs | 8 ++++++++ TGS.Server/Instance/DreamDaemon.cs | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/TGS.Server/EventID.cs b/TGS.Server/EventID.cs index 9981fd199f..7f04860da9 100644 --- a/TGS.Server/EventID.cs +++ b/TGS.Server/EventID.cs @@ -331,5 +331,13 @@ namespace TGS.Server /// Warning: When a testmerge commit failed to be published /// ReferencePush = 7700, + /// + /// Warning: When the server exits unexpectedly + /// + DDServerCrash = 7800, + /// + /// Info: When the DreamDaemon process is about to be launched + /// + DDServerStart = 7800, } } diff --git a/TGS.Server/Instance/DreamDaemon.cs b/TGS.Server/Instance/DreamDaemon.cs index dff55061cc..78815061d2 100644 --- a/TGS.Server/Instance/DreamDaemon.cs +++ b/TGS.Server/Instance/DreamDaemon.cs @@ -374,9 +374,10 @@ namespace TGS.Server } } - WriteCurrentDDLog("Crash detected! Exit code: ": Proc.ExitCode); + WriteCurrentDDLog("Crash detected! Exit code: " + Proc.ExitCode); var runtimeS = (DateTime.Now - starttime).TotalSeconds; - WriteWarning("DD crashed: Exit Code: " + Proc.ExitCode + " Seconds running: " + runtimeS); + WriteWarning("DD crashed: Exit Code: " + Proc.ExitCode + " Seconds running: " + runtimeS, EventID.DDServerCrash); + lock (watchdogLock) { @@ -621,7 +622,7 @@ namespace TGS.Server { GameAPIVersion = null; //needs updating } - WriteInfo("Starting DD: " + Proc.StartInfo.FileName + " " + Proc.StartInfo.Arguments); + WriteInfo("Starting DD: " + Proc.StartInfo.FileName + " " + Proc.StartInfo.Arguments, EventID.DDServerStart); Proc.Start(); Proc.PriorityClass = ProcessPriorityClass.AboveNormal; From 324b6b05fc4a4ed04c51b4bca63eadd4a2deb266 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 15 Jul 2018 17:58:28 -0400 Subject: [PATCH 45/52] Version bump to 3.2.3.4 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 73a0f54936..ec8ca78134 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.3")] -[assembly: AssemblyFileVersion("3.2.3.3")] -[assembly: AssemblyInformationalVersion("3.2.3.3")] +[assembly: AssemblyVersion("3.2.3.4")] +[assembly: AssemblyFileVersion("3.2.3.4")] +[assembly: AssemblyInformationalVersion("3.2.3.4")] [assembly: InternalsVisibleTo("TGS.Tests")] From 4a3f31edef6170197e2c1510dcce84f3da7999ee Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 17 Jul 2018 14:30:15 -0400 Subject: [PATCH 46/52] Remove static reset from repo recloning --- TGS.Server/Instance/Repository.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index df92b1a5a2..0333f8e513 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -228,10 +228,11 @@ namespace TGS.Server DisposeRepo(); Helpers.DeleteDirectory(RelativePath(RepoPath)); DeletePRList(); + /* lock (configLock) { BackupAndDeleteStaticDirectory(); - } + }*/ var Opts = new CloneOptions() { @@ -251,7 +252,8 @@ namespace TGS.Server //create an ssh remote for pushing Repo.Network.Remotes.Add(SSHPushRemote, RepoURL.Replace("git://", "ssh://").Replace("https://", "ssh://")); - InitialConfigureRepository(); + if (!Directory.Exists(RelativePath(StaticDirs))) + InitialConfigureRepository(); SendMessage("REPO: Clone complete!", MessageType.DeveloperInfo); WriteInfo("Repository {0}:{1} successfully cloned", EventID.RepoClone); From b0cd89320f15602d767aadc19e5391c98f71e132 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Tue, 17 Jul 2018 14:43:19 -0400 Subject: [PATCH 47/52] Version bump to 3.2.3.5 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index ec8ca78134..36f9604587 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.4")] -[assembly: AssemblyFileVersion("3.2.3.4")] -[assembly: AssemblyInformationalVersion("3.2.3.4")] +[assembly: AssemblyVersion("3.2.3.5")] +[assembly: AssemblyFileVersion("3.2.3.5")] +[assembly: AssemblyInformationalVersion("3.2.3.5")] [assembly: InternalsVisibleTo("TGS.Tests")] From 6565b9cf0a628af25882756d7a29871c931f3c21 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 19 Jul 2018 14:25:49 -0400 Subject: [PATCH 48/52] Removes DD check from repo recloning What could go wrong? --- TGS.Server/Instance/Repository.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index 0333f8e513..00fc1e03e6 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -390,8 +390,6 @@ namespace TGS.Server if (!CompilerIdleNoLock()) return "Compiler is running!"; } - if (DaemonStatus() != DreamDaemonStatus.Offline) - return "DreamDaemon is running!"; if (RepoURL.Contains("ssh://") && !SSHAuth()) return String.Format("SSH url specified but either {0} or {1} does not exist in the server directory!", PrivateKeyPath, PublicKeyPath); RepoBusy = true; From f1ca65a3e588147ff3496fa639f9d5ace75c679c Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 19 Jul 2018 14:57:17 -0400 Subject: [PATCH 49/52] Version bump to 3.2.3.6 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 36f9604587..13e2136663 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.5")] -[assembly: AssemblyFileVersion("3.2.3.5")] -[assembly: AssemblyInformationalVersion("3.2.3.5")] +[assembly: AssemblyVersion("3.2.3.6")] +[assembly: AssemblyFileVersion("3.2.3.6")] +[assembly: AssemblyInformationalVersion("3.2.3.6")] [assembly: InternalsVisibleTo("TGS.Tests")] From 63d7a9b301e4660a088abd7973081409cb804e67 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 19 Jul 2018 14:57:52 -0400 Subject: [PATCH 50/52] Create releases as drafts until I stop being lazy and add auto release nots --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index d2b9fde6fa..79b3fb9596 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -56,7 +56,7 @@ deploy: auth_token: secure: lJNGAXwiB5HlWdthz3K4PetqpTG5IEAyRgKaiKxFMQ8HW8CcOjRtB97B05op7BsK artifact: TGS3Server,MD5SHA1Server,TGS3Client,MD5SHA1Client,TGS3ServerConsole,MD5SHA1ServerConsole - draft: false + draft: true on: TGSDeploy: "Do it." - provider: NuGet From 468ad759da7943b491c51c4170bb742fe9b06ad5 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 30 Jul 2018 11:23:39 -0400 Subject: [PATCH 51/52] Adds IRC nick correcting --- TGS.Server/ChatProviders/IRCChatProvider.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TGS.Server/ChatProviders/IRCChatProvider.cs b/TGS.Server/ChatProviders/IRCChatProvider.cs index df453f4f11..34bfff55c3 100644 --- a/TGS.Server/ChatProviders/IRCChatProvider.cs +++ b/TGS.Server/ChatProviders/IRCChatProvider.cs @@ -101,9 +101,6 @@ namespace TGS.Server.ChatProviders } else if (serverChange || !Connected()) return Reconnect(); - - if (IRCConfig.Nickname != irc.Nickname) - irc.RfcNick(convertedInfo.Nickname); Login(); JoinChannels(); return null; @@ -268,7 +265,11 @@ namespace TGS.Server.ChatProviders while (irc != null && Connected()) try { - irc.Listen(); + irc.ListenOnce(true); + irc.Listen(false); + //ensure we have the correct nick + if (irc.Nickname != IRCConfig.Nickname && irc.GetIrcUser(IRCConfig.Nickname) == null) + irc.RfcNick(IRCConfig.Nickname); } catch { } } From 64ba5706c23cd7cc840afa863c511ee7dd7bd3ba Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Mon, 30 Jul 2018 13:05:33 -0400 Subject: [PATCH 52/52] Version bump to 3.2.3.7 [TGSDeploy] --- AssemblyInfo.global.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssemblyInfo.global.cs b/AssemblyInfo.global.cs index 13e2136663..333df9ca5d 100644 --- a/AssemblyInfo.global.cs +++ b/AssemblyInfo.global.cs @@ -3,8 +3,8 @@ using System.Runtime.CompilerServices; //You cannot one definition the version number //Believe me, I've tried, the compiler hates it so much -[assembly: AssemblyVersion("3.2.3.6")] -[assembly: AssemblyFileVersion("3.2.3.6")] -[assembly: AssemblyInformationalVersion("3.2.3.6")] +[assembly: AssemblyVersion("3.2.3.7")] +[assembly: AssemblyFileVersion("3.2.3.7")] +[assembly: AssemblyInformationalVersion("3.2.3.7")] [assembly: InternalsVisibleTo("TGS.Tests")]