Touhou Patch Center:Servers

== Mirrors == To ensure the availability of our translations, the patch data used by the Touhou Community Reliant Automatic Patcher is mirrored across multiple servers.

As the main server, srv.thpatch.net is the most up-to-date resource and directly receives translations after they were made in the wiki. The other mirrors pull the latest state from there every minute.

Just like the content on the wiki, the translations and images on this server are licensed under.

== Neighbors == This list contains links to third-party patch repositories not under our control. When pointed to, the configuration tool will offer to choose patches from these repositories as well.

If you want your repository to be included in this list, please send a mail to [mailto:submissions@thpatch.net submissions@thpatch.net], containing the public path to your repository (this is the "servers" value in repo.js). In case you use Git to manage your server, you can also request it to be automatically mirrored on mirrors.thpatch.net. This is highly recommended in order to keep your patches available in case the original host happens to go down.

== Building your own patch server ==

As of the 2014-01-26 build, thcrap includes a Python script to assist in building your own self-updating patch server, where you can publish your own patches while having full control over them. While this may sound pretty involved, it really is not that complex – we deliberately designed the system in such a way that no specific server software is required. Anything that uses the HTTP protocol and allows for arbitrary files to be stored and served to the Web while retaining their file names and directory structure can be used.

You don't even have to pay for webspace in order to do this; there are a number of free cloud storage providers that work just as well. Below, you can find tutorials on how to set up your own repository on one of these. All these tutorials are written for Windows only, but if you use a different operating system, you should have no trouble adapting them. ☺

=== Overview === To explain the terminology:


 * First, we have patches. These are basically just unordered collections of files that provide replacements for certain original game data. One patch can provide data for an unlimited number of games.
 * Patches are grouped in repositories. These are in turn collections of all the different patches offered and controlled by one person or community.

You start by creating a repository, then one or more patches, which you then regularly publish on a server.

=== Local setup === First, you need to think of a globally unique, short ID for your repository. This could simply be your name, or the name of your community. For the sake of this tutorial, we'll call it RepoDir.

You also need to do the following:

(This is the programming language the repository build script is written in.) This will be your local repository path, where all your patch development will take place.
 * 1) Download and install Python.svg Python 3, if you don't have it already. Be sure to make a note of the path it gets installed to.
 * 1) Create a new directory named RepoDir inside your thcrap directory.
 * 1) Inside RepoDir, create a new directory for each of your patches, named after their respective short ID. We'll use PatchDir as an example.

=== Patch setup === For each patch, create a file named patch.js</tt> in RepoDir\PatchDir</tt>. This is mandatory, the build script won't recognize the patch otherwise.

All files with a JS extension are JSON format files. You can validate their syntax using sites like JSONLint.

==== Dependencies ==== These are set using the dependencies</tt> array in patch.js</tt>, and ensure that the configuration tool automatically pulls in all required functionality for your patch.

Dependency statements have the form repo_id/patch_id</tt>. repo_id</tt> is optional - leaving it out will resolve the given patch first on your repository, then globally across all repositories a user has discovered. Be careful, this might have unintended consequences when used with a patch not in your repository.

Some of the patches from the network you may want to bundle are:
 * nmlgc/base_tsa</tt>: The basic technical support for Windows Touhou games. If your patch targets any of these games, make absolutely sure to include this one in some way! Otherwise, the configuration tool may not pull it in and the resulting configurations may not work!
 * nmlgc/script_latin</tt>: Contains a font with sufficient Unicode coverage for Latin, Greek and Cyrillic scripts, some settings to make it look as nice as possible for every game, as well as Hepburn romanizations for common terms and images.
 * nmlgc/western_name_order</tt>: Exactly what it says – Western name order for the enemy names during boss battles.
 * thpatch/lang_en</tt>: Not only does this give you our up-to-date English translation, it also ensures that any other dependencies for a translation patch (such as all three patches mentioned above) will be present when selecting your patch in the configuration tool.

===== Examples ===== A basic configuration for a translation patch using a non-English Latin script language:

Pulls in all of the above (and maybe even more in the future) plus the English translations:

Fonts
If your patch includes custom fonts, register them using the fonts</tt> object. This is a simple list of every font file name to load before starting the patched game:

(thcrap does not look at the actual value of the key, true in this example.)

==== OK, and how do I do X? ==== Well, thcrap can do a lot of things. ☺ Until we have described them all, your best bet is to look at how our patches do the things you intend to do. If you still have questions, just visit our IRC chat, ask us, and we'll be glad to help you.

Server setup
The rest of this tutorial differs depending on the webspace or server provider you use.

==== Using GitHub ==== This is the recommended option. It will keep your repository under a revision control system and thus store the entire history of your patches, which can then be viewed nicely on the GitHub website. We are also thinking about adding direct Git support to the thcrap updater in the future, which would make this setup even simpler.

If you're already familiar with Git: Just run repo_update.py</tt> every time before you commit. If you aren't, how to set it up on Windows:

If your local repository directory shares its name with the one on GitHub, this will fail. In that case, just rename your local directory temporarily, then move all of its contents into the newly created directory after the cloning process is complete.
 * 1) Make sure you have version 2014-05-08 or later of thcrap. This build introduces some important changes to the repository script which make GitHub support possible in the first place. Also make sure that thcrap.zip and it's contents are in the same directory as your patches. Otherwise you will get an error that repo_update is missing.
 * 2) Register a new free account on GitHub if you don't have one yet.
 * 3) On your dashboard, create a new repository with the default settings. Its name does not necessarily have to correspond with the name you chose for RepoDir</tt> in your local setup.  GitHub Tutorial 02 - Dashboard.png  GitHub Tutorial 03 - New repo.png
 * 4) Download and install the GitHub Windows client and log in with your GitHub account.
 * 5) In the Options menu, set the default storage directory to your thcrap directory, and put your name and e-mail address in the configure git section.  GitHub Tutorial 05 - Login.png
 * 6) Clone the repository you created on GitHub into your thcrap directory.
 * 1) In the newly cloned directory, create a file named Update.bat</tt>, which you will use to launch thcrap's update script:
 * Then run Update.bat</tt> and set the basic parameters of your repository. The repository ID should be the same as its directory name, and the public URL for GitHub is:
 *  https://raw.githubusercontent.com/ GitHub-user-name/GitHub-repository-name/master/</tt>
 * GitHub Tutorial 07 - repo_update.png

That's it for the basic setup. After you have made some edits to your patches, this is how you publish them: Be sure to do this immediately after running the update script! If you run thcrap with the patch you are editing before committing, the updater will overwrite your changes with the last state on the server! As of 2017-02-05, automatic updates are automatically disabled if the patch is located inside a git repository.
 * 1) Run <tt>Update.bat</tt>.
 * 2) Open the GitHub client and navigate to your patch repository. This should give you all changes since the last commit as well as the option to create a new one.
 * 1) Verify the changes you are about to commit. If everything went fine, each file  you changed should now have a different checksum in the <tt>files.js</tt> file of the affected patches:  GitHub Tutorial 08 - Commit.png
 * 2) Then, simply click commit to master, followed by publish, and your changes are live.

Making your repository known
In order for your patch to be seen and able to be used by others globally, there are generally three methods:
 * After your repository has been uploaded, anyone else can then discover it by calling <tt>thcrap_configure</tt> with your URL as a command-line parameter.
 * If you have a own website, blog, etc., you can upload a custom version of the thcrap archive containing the <tt>repo.js</tt> file inside your local repository directory. This is generally not recommended, though
 * The best method, however, is to contact us on https://thpatch.net/w/logos/discord.png Discord and tell us your repository URL to get listed in the     network as one of our neighbors.