-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eb965b5
Showing
14 changed files
with
316 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
name: Preset | ||
about: new shard preset | ||
title: "<SHARD_NAME> preset" | ||
labels: new-preset | ||
assignees: '' | ||
|
||
--- | ||
|
||
name= | ||
ip= | ||
port= | ||
encryption= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: CI | ||
|
||
on: | ||
schedule: | ||
- cron: "0 * * * *" | ||
#push: | ||
# branches: | ||
# - main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup .NET 6 | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: 6.0.* | ||
|
||
- name: Build presets.xml | ||
run: dotnet run PresetsGenerator.csproj | ||
|
||
- name: Upload binaries to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: presets.xml | ||
asset_name: presets.xml | ||
tag: release-${{ github.ref }} | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
bin/ | ||
obj/ | ||
|
||
.suo | ||
.vs | ||
presets.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Xml; | ||
|
||
namespace PresetsGenerator | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
GenerateXML(AnalyzeAllPresets()); | ||
} | ||
|
||
|
||
|
||
|
||
static List<PresetEntry> AnalyzeAllPresets() | ||
{ | ||
List<PresetEntry> list = new List<PresetEntry>(); | ||
|
||
var dirs = Directory.GetDirectories("./presets"); | ||
|
||
Trace($"found {dirs.Length} directories"); | ||
|
||
foreach (var dir in dirs) | ||
{ | ||
Trace("reading dir --> " + dir); | ||
|
||
var files = Directory.GetFiles(dir); | ||
|
||
Trace($"found {files.Length} files"); | ||
|
||
foreach (var file in files) | ||
{ | ||
if (file.EndsWith(".txt")) | ||
{ | ||
var content = File.ReadAllText(file); | ||
|
||
if (!string.IsNullOrWhiteSpace(content)) | ||
{ | ||
var name = ReadValue(content, "name"); | ||
var ip = ReadValue(content, "ip"); | ||
var port = ReadValue(content, "port"); | ||
var clientVersion = ReadValue(content, "client_version"); | ||
var encryption = ReadValue(content, "encryption"); | ||
|
||
bool error = false; | ||
|
||
if (name.IsEmpty) | ||
{ | ||
Error("invalid name value"); | ||
error = true; | ||
} | ||
|
||
if (ip.IsEmpty) | ||
{ | ||
Error("invalid ip value"); | ||
error = true; | ||
} | ||
|
||
if (port.IsEmpty || !ushort.TryParse(port, out var _)) | ||
{ | ||
Error("invalid port value"); | ||
error = true; | ||
} | ||
|
||
if (clientVersion.IsEmpty) | ||
{ | ||
Error("invalid client_version value"); | ||
error = true; | ||
} | ||
|
||
bool useEncryption = false; | ||
if (encryption == "yes") | ||
{ | ||
useEncryption = true; | ||
} | ||
else if (encryption == "no") | ||
{ | ||
useEncryption = false; | ||
} | ||
else if (encryption.IsEmpty || !bool.TryParse(encryption, out useEncryption)) | ||
{ | ||
Warn("invalid encryption value. Value will be set to 'false'"); | ||
} | ||
|
||
if (!error) | ||
{ | ||
Trace("storing data to the list"); | ||
|
||
list.Add(new PresetEntry() | ||
{ | ||
Name = name.ToString(), | ||
IP = ip.ToString(), | ||
Port = port.ToString(), | ||
ClientVersion = clientVersion.ToString(), | ||
Encryption = useEncryption | ||
}); | ||
} | ||
else | ||
{ | ||
Warn("error :("); | ||
} | ||
} | ||
else | ||
{ | ||
Error($"file '{file}' does not contains valid data"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return list; | ||
} | ||
|
||
static void GenerateXML(List<PresetEntry> list) | ||
{ | ||
using System.Xml.XmlTextWriter xml = new XmlTextWriter("presets.xml", Encoding.UTF8) | ||
{ | ||
Formatting = Formatting.Indented, | ||
IndentChar = '\t', | ||
Indentation = 1 | ||
}; | ||
|
||
xml.WriteStartDocument(true); | ||
|
||
xml.WriteStartElement("presets"); | ||
|
||
foreach (var e in list) | ||
{ | ||
xml.WriteStartElement("preset"); | ||
|
||
xml.WriteAttributeString("name", e.Name); | ||
xml.WriteAttributeString("ip", e.IP); | ||
xml.WriteAttributeString("port", e.Port); | ||
xml.WriteAttributeString("client_version", e.ClientVersion); | ||
xml.WriteAttributeString("encryption", e.Encryption.ToString()); | ||
|
||
xml.WriteEndElement(); | ||
} | ||
|
||
xml.WriteEndElement(); | ||
|
||
xml.WriteEndDocument(); | ||
} | ||
|
||
|
||
static ReadOnlySpan<char> ReadValue(string entry, string key) | ||
{ | ||
int keyIdx = entry.IndexOf(key); | ||
if (keyIdx >= 0) | ||
{ | ||
int valueIdx = entry.IndexOf('=', keyIdx); | ||
|
||
if (valueIdx >= 0) | ||
{ | ||
valueIdx++; | ||
int endOfLineIdx = entry.IndexOf('\n', valueIdx); | ||
|
||
if (endOfLineIdx <= 0) | ||
{ | ||
endOfLineIdx = entry.Length; | ||
} | ||
|
||
var span = entry.AsSpan(valueIdx, endOfLineIdx - valueIdx); | ||
|
||
int rnIdx = span.IndexOf('\r'); | ||
if (rnIdx >= 0) | ||
{ | ||
span = span.Slice(0, rnIdx); | ||
} | ||
|
||
if (!span.IsWhiteSpace()) | ||
{ | ||
return span; | ||
} | ||
} | ||
} | ||
|
||
return default; | ||
} | ||
|
||
class PresetEntry | ||
{ | ||
public string Name = string.Empty; | ||
public string IP = string.Empty; | ||
public string Port = string.Empty; | ||
public string ClientVersion = string.Empty; | ||
public bool Encryption; | ||
} | ||
|
||
|
||
static void Trace(string msg) => Console.WriteLine("[TRACE] {0}", msg); | ||
static void Warn(string msg) => Console.WriteLine("[WARN] {0}", msg); | ||
static void Error(string msg) => Console.WriteLine("[ERROR] {0}", msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ClassicUO shard presets for the Launcher | ||
A collection of UO presets for the ClassicUO Launcher app | ||
|
||
|
||
# Template | ||
- Fork the repo | ||
- Create a folder in "presets" | ||
- Save the "preset.txt" using the template below in the folder created the step before | ||
- Send the PR | ||
|
||
|
||
``` | ||
name= | ||
ip= | ||
port= | ||
client_version= | ||
encryption= | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Eclipse | ||
ip=play.uoeclipse.com | ||
port=2593 | ||
client_version=7.0.95.0 | ||
encryption=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Elemental | ||
ip=login.uoelemental.com | ||
port=2593 | ||
client_version=7.0.88.1 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Heritage | ||
ip=play.trueuo.com | ||
port=2593 | ||
client_version=7.0.90.16 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=LegenD | ||
ip=login.legendshard.com.br | ||
port=2593 | ||
client_version=7.0.20.0 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Millenia | ||
ip=millenia.ultimaonline-freeshard.de | ||
port=2011 | ||
client_version=6.0.1.10 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=UO: Felucca | ||
ip=login.uofelucca.com | ||
port=2593 | ||
client_version=7.0.97.25 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=UOAlive | ||
ip=login.uoalive.com | ||
port=2593 | ||
client_version=7.0.99.0 | ||
encryption=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name=Utopia | ||
ip=login.uoutopia.com | ||
port=2593 | ||
client_version=7.0.31.0 | ||
encryption=false |