diff --git a/.gitignore b/.gitignore index 2daa302ddd..5dee86e7ae 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ packages/* *.user +*.dmb +*.int diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..4085bed57e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: generic +sudo: false + +env: + global: + - BYOND_MAJOR="511" + - BYOND_MINOR="1385" + - DMEName="DMAPITravisTester.dme" + +cache: + directories: + - $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} + +addons: + apt: + packages: + - libc6-i386 + - libstdc++6:i386 + +install: + - ./install_byond.sh + +script: + - ./build_byond.sh diff --git a/Config.dm b/Config.dm new file mode 100644 index 0000000000..6ea3f64cc3 --- /dev/null +++ b/Config.dm @@ -0,0 +1,7 @@ +#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) diff --git a/DMAPI/server_tools.dm b/DMAPI/server_tools.dm new file mode 100644 index 0000000000..6640ff13df --- /dev/null +++ b/DMAPI/server_tools.dm @@ -0,0 +1,123 @@ +// /tg/station 13 server tools API v3.1 + +//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) +#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 world.ServiceEndProcess() +/* + 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 SERVICE_API_VERSION_STRING "3.1.0.0" + +#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_PR_TEST_JSON "prtestjob.json" +#define SERVICE_INTERFACE_DLL "TGServiceInterface.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_PARAM_KEY "serviceCommsKey" +#define SERVICE_CMD_PARAM_COMMAND "command" +#define SERVICE_CMD_PARAM_SENDER "sender" +#define SERVICE_CMD_PARAM_CUSTOM "custom" +#define SERVICE_CMD_API_COMPATIBLE "api_compat" + +#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_IRC_BROADCAST "irc" +#define SERVICE_REQUEST_IRC_ADMIN_CHANNEL_MESSAGE "send2irc" +#define SERVICE_REQUEST_WORLD_REBOOT "worldreboot" +#define SERVICE_REQUEST_API_VERSION "api_ver" + +/* +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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/st_commands.dm new file mode 100644 index 0000000000..5334e41eac --- /dev/null +++ b/DMAPI/st_commands.dm @@ -0,0 +1,76 @@ +/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 + +//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) + 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/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!") + 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!") + 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)) + +/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 + + var/command_type = cached_custom_server_tools_commands[command] + if(!command_type) + return FALSE + var/datum/server_tools_command/stc = new command_type + return stc.Run(sender, params) || TRUE + +/* +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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 new file mode 100644 index 0000000000..b7bdda3364 --- /dev/null +++ b/DMAPI/st_interface.dm @@ -0,0 +1,126 @@ +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() && 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) + return (skip_compat_check || SERVER_TOOLS_READ_GLOBAL(server_tools_api_compatible)) && world.params[SERVICE_WORLD_PARAM] != null + +/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.") + call(SERVICE_INTERFACE_DLL, SERVICE_INTERFACE_FUNCTION)(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() + SERVER_TOOLS_LOG("Sending shutdown request!"); + sleep(world.tick_lag) //flush the buffers + ExportService(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/sCK = RunningService() + var/their_sCK = params[SERVICE_CMD_PARAM_KEY] + + if(!their_sCK) + return FALSE //continue world/Topic + + 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 "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 "SUCCESS" + 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 : "SUCCESS" + return "Unknown command: [command]" + +/* +The MIT License + +Copyright (c) 2011 Dominic Tarr + +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/DMAPITravisTester.dme b/DMAPITravisTester.dme new file mode 100644 index 0000000000..e1f4f19dac --- /dev/null +++ b/DMAPITravisTester.dme @@ -0,0 +1,21 @@ +// DM Environment file for DMAPITravisTester.dme. +// All manual changes should be made outside the BEGIN_ and END_ blocks. +// New source code should be placed in .dm files: choose File/New --> Code File. + +// BEGIN_INTERNALS +// END_INTERNALS + +// BEGIN_FILE_DIR +#define FILE_DIR . +// END_FILE_DIR + +// BEGIN_PREFERENCES +// END_PREFERENCES + +// BEGIN_INCLUDE +#include "Config.dm" +#include "DMAPI\server_tools.dm" +#include "DMAPI\st_commands.dm" +#include "DMAPI\st_interface.dm" +#include "Test.dm" +// END_INCLUDE diff --git a/README.md b/README.md index abc3e3943f..cbe383f14c 100644 --- a/README.md +++ b/README.md @@ -180,3 +180,11 @@ You can clear all active test merges using `Reset to Origin Branch` in the `Repo ## CONTRIBUTING * Version numbers and releases will be handled by maintainers, do not modify these in your PR + +## LICENSING + +* The DM API for the project is licensed under the MIT license. +* The /tg/station 13 icon is licensed under [Creative Commons 3.0 BY-SA](http://creativecommons.org/licenses/by-sa/3.0/). +* The remainder of the project is licensed under [GNU AGPL v3](http://www.gnu.org/licenses/agpl-3.0.html) + +See the bottom of each file in the /DMAPI tree for the MIT license diff --git a/TGServerService/Interop.cs b/TGServerService/Interop.cs index e4ec5796cc..5cf968e842 100644 --- a/TGServerService/Interop.cs +++ b/TGServerService/Interop.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Net; using System.Net.Sockets; using System.Text; -using System.Threading; using System.Web.Script.Serialization; using System.Web.Security; using TGServiceInterface; @@ -13,20 +12,27 @@ namespace TGServerService //handles talking between the world and us partial class TGStationServer : ITGServiceBridge { + object topicLock = new object(); const int CommsKeyLen = 64; string serviceCommsKey; //regenerated every DD restart + //range of supported api versions + const string MinAPIVersion = "3.1.0.0"; + const string MaxAPIVersion = "3.1.0.99"; + //See code/modules/server_tools/server_tools.dm for command switch const string SCHardReboot = "hard_reboot"; //requests that dreamdaemon restarts when the round ends const string SCGracefulShutdown = "graceful_shutdown"; //requests that dreamdaemon stops when the round ends const string SCWorldAnnounce = "world_announce"; //sends param 'message' to the world const string SCListCustomCommands = "list_custom_commands"; //Get a list of commands supported by the server + const string SCAPICompat = "api_compat"; //Tells the server we understand each other const string SRKillProcess = "killme"; const string SRIRCBroadcast = "irc"; const string SRIRCAdminChannelMessage = "send2irc"; const string SRWorldReboot = "worldreboot"; + const string SRAPIVersion = "api_ver"; const string CCPHelpText = "help_text"; const string CCPAdminOnly = "admin_only"; @@ -82,6 +88,21 @@ namespace TGServerService } } break; + case SRAPIVersion: + try + { + var theirs = new Version(splits[1]); + var minimum = new Version(MinAPIVersion); + var maximum = new Version(MaxAPIVersion); + if (theirs < minimum || theirs > maximum) + throw new Exception(); + SendCommand(SCAPICompat); + } + catch + { + TGServerService.WriteWarning("API version of the game ({0}) is incompatible with the current supported API versions (Min: {1}. Max: {2})", TGServerService.EventID.APIVersionMismatch); + } + break; } } diff --git a/TGServerService/ServerService.cs b/TGServerService/ServerService.cs index d32c8bbb5a..3241c4c295 100644 --- a/TGServerService/ServerService.cs +++ b/TGServerService/ServerService.cs @@ -79,6 +79,7 @@ namespace TGServerService PreactionEvent = 6800, PreactionFail = 6900, InteropCallException = 7000, + APIVersionMismatch = 7100, } static TGServerService ActiveService; //So everyone else can write to our eventlog diff --git a/TGStationServer3.sln b/TGStationServer3.sln index 77d969b67f..5d14e44608 100644 --- a/TGStationServer3.sln +++ b/TGStationServer3.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26430.15 +VisualStudioVersion = 15.0.26730.3 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TGServerService", "TGServerService\TGServerService.csproj", "{F32EDA25-0855-411C-AF5E-F0D042917E2D}" EndProject @@ -16,8 +16,14 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D8FC6AA-1D33-44B6-81C2-35ED7A87EDBC}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore + .travis.yml = .travis.yml appveyor.yml = appveyor.yml + build_byond.sh = build_byond.sh + Config.dm = Config.dm + DMAPITravisTester.dme = DMAPITravisTester.dme + install_byond.sh = install_byond.sh README.md = README.md + Test.dm = Test.dm tgs.ico = tgs.ico TGS3Release.ps1 = TGS3Release.ps1 Version.cs = Version.cs @@ -29,7 +35,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TGInstallerWrapper", "TGIns {154435F6-0890-42D4-9AEC-B743D4FBC1CB} = {154435F6-0890-42D4-9AEC-B743D4FBC1CB} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TGS2", "TGS2", "{0DDF886A-7ABB-4DCA-96A3-349B2DA00016}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "legacy", "legacy", "{0DDF886A-7ABB-4DCA-96A3-349B2DA00016}" ProjectSection(SolutionItems) = preProject legacy\config.bat = legacy\config.bat legacy\copyexclude.txt = legacy\copyexclude.txt @@ -62,6 +68,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bin", "bin", "{3BB3DA66-970 legacy\bin\updategit.bat = legacy\bin\updategit.bat EndProjectSection 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 + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -99,4 +112,7 @@ Global GlobalSection(NestedProjects) = preSolution {3BB3DA66-970C-4AAE-A77C-9E40F5E7E56A} = {0DDF886A-7ABB-4DCA-96A3-349B2DA00016} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1B511D10-AB55-43E0-B363-7F8838E9E977} + EndGlobalSection EndGlobal diff --git a/Test.dm b/Test.dm new file mode 100644 index 0000000000..7df062b584 --- /dev/null +++ b/Test.dm @@ -0,0 +1,36 @@ +#ifndef SERVER_TOOLS_ON_NEW +#error DreamMaker rearranges the intentionally weird file layout of this project. Compile using dm.exe instead +#endif + +/world/New() + SERVER_TOOLS_ON_NEW + world.log << "Service API Version: [SERVER_TOOLS_API_VERSION]" + WaitForAPICompatResponse() + +/world/Topic(T, Addr, Master, Keys) + SERVER_TOOLS_ON_TOPIC + +/world/Reboot(reason) + SERVER_TOOLS_ON_REBOOT + SERVER_TOOLS_REBOOT_BYOND + +/proc/message_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() diff --git a/build_byond.sh b/build_byond.sh new file mode 100755 index 0000000000..ac4473ad9a --- /dev/null +++ b/build_byond.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +retval=1 +source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup + +if hash DreamMaker 2>/dev/null +then + DreamMaker $DMEName 2>&1 | tee result.log + retval=$? + if ! grep '\- 0 errors, 0 warnings' result.log + then + retval=1 #hard fail, due to warnings or errors + fi +else + echo "Couldn't find the DreamMaker executable, aborting." + retval=2 +fi +exit $retval \ No newline at end of file diff --git a/install_byond.sh b/install_byond.sh new file mode 100755 index 0000000000..b2da430247 --- /dev/null +++ b/install_byond.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +if [ -d "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin" ]; +then + echo "Using cached directory." + exit 0 +else + echo "Setting up BYOND." + mkdir -p "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}" + cd "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}" + curl "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip + unzip byond.zip + cd byond + make here + cd ~/ + exit 0 +fi + +#some variable not set correctly, panic +exit 1