Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.0 Update #200

Merged
merged 38 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eb3aa79
Move gitignore
Dec 29, 2018
8a7eb66
Initial cleanup
Dec 29, 2018
947f7f7
More cleanup
Dec 29, 2018
07562f3
Even more cleanup and reworking
Dec 29, 2018
7ef1682
Move project to repo root
Dec 29, 2018
6db0809
Re-arrange project
Dec 30, 2018
aad2a01
Small code refractors and removals
Jan 3, 2019
a98dd00
Update README.md & add more configs
Jan 3, 2019
0cd85da
Minor changes and update README.me
Jan 3, 2019
337412f
Update README.md
Jan 3, 2019
f44911b
Begin implementation of multi-server execution
Jan 27, 2019
96be7eb
Update input and output threads from upstream
Jan 31, 2019
d3cc807
Renamed OutputThread & made it instance based
Jan 31, 2019
7ec2687
Large cleanup, read description
Jan 31, 2019
233d638
Check description for information
Jan 31, 2019
397ae6b
Implement multi-mode, check description
Feb 2, 2019
d4d05bf
Re-wrote "NEW" command
Feb 2, 2019
a07de79
Update README.md
Feb 2, 2019
03dfd8a
Update README.md
Feb 2, 2019
be7bfb3
Fixed server specific configs not loading
Feb 2, 2019
afbbeaa
Fix soft low memory restart restarting every round
Feb 2, 2019
b79edfc
Initialize features on server start
Feb 2, 2019
9349862
Merge branch 'master' of https://github.com/Dankrushen/MultiAdmin int…
Feb 3, 2019
671b709
Merge branch 'Dankrushen-master' into v3.0.0
Feb 3, 2019
2fc2bf9
Reformat code & other changes
Feb 4, 2019
70caa4d
Remove extra files
Feb 4, 2019
292bff2
Remove BOM from files
Feb 4, 2019
fe6deda
Check commit description for details
Feb 5, 2019
8744f90
Properly "StopServer" when "killGame = false"
Feb 5, 2019
70d5a02
Don't exit "MainLoop" until process ends
Feb 5, 2019
9430aaf
Fixed "Server#MainLoop()" never exiting
Feb 5, 2019
a3c3e43
Update README.md
Feb 5, 2019
e9f0162
Added new colored console printing system
Feb 7, 2019
ef897f8
InactivityShutdown UnixTime removal
Feb 8, 2019
a1f76a9
Standardized output reading
Feb 8, 2019
43e2795
Changed server status system
Feb 9, 2019
9f149b9
Removed process handle check
Feb 10, 2019
8f425d2
Reset "EXIT" command on restart
Feb 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
Expand All @@ -19,6 +20,8 @@
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
Expand Down Expand Up @@ -59,7 +62,7 @@ StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*_h.h
*.ilk
*.meta
*.obj
Expand All @@ -76,6 +79,7 @@ StyleCopReport.xml
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
Expand Down Expand Up @@ -207,7 +211,7 @@ _pkginfo.txt
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
!?*.[Cc]ache/

# Others
ClientBin/
Expand All @@ -220,13 +224,15 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
**/wwwroot/lib/

# RIA/Silverlight projects
Generated_Code/
Expand Down Expand Up @@ -290,8 +296,8 @@ paket-files/
.idea/
*.sln.iml

# CodeRush
.cr/
# CodeRush personal settings
.cr/personal

# Python Tools for Visual Studio (PTVS)
__pycache__/
Expand All @@ -316,7 +322,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -325,5 +331,46 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb

# Common IntelliJ Platform excludes

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

*.suo
*.user
.vs/
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
[Pp]ackages/

Thumbs.db
Desktop.ini
.DS_Store

2 changes: 1 addition & 1 deletion mutliadmin/MultiAdmin.sln → MultiAdmin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiAdmin", "MultiAdmin.csproj", "{8384BF3C-5FC8-4395-A3DE-440C6C531D36}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiAdmin", "MultiAdmin/MultiAdmin.csproj", "{8384BF3C-5FC8-4395-A3DE-440C6C531D36}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
126 changes: 126 additions & 0 deletions MultiAdmin/ColoredConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace MultiAdmin
{
public class ColoredConsole
{
public static readonly object WriteLock = new object();

public static void Write(string text, ConsoleColor textColor = ConsoleColor.White, ConsoleColor backgroundColor = ConsoleColor.Black)
{
lock (WriteLock)
{
if (text == null) return;

Console.ForegroundColor = textColor;
Console.BackgroundColor = backgroundColor;

Console.Write(text);

Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
}
}

public static void WriteLine(string text, ConsoleColor textColor = ConsoleColor.White, ConsoleColor backgroundColor = ConsoleColor.Black)
{
lock (WriteLock)
{
if (text != null)
Write(text, textColor, backgroundColor);

Console.WriteLine();
}
}

public static void Write(params ColoredMessage[] message)
{
lock (WriteLock)
{
foreach (ColoredMessage coloredMessage in message) Write(coloredMessage.text, coloredMessage.textColor, coloredMessage.backgroundColor);
}
}

public static void WriteLine(params ColoredMessage[] message)
{
lock (WriteLock)
{
Write(message);

Console.WriteLine();
}
}

public static void WriteLines(params ColoredMessage[] message)
{
lock (WriteLock)
{
foreach (ColoredMessage coloredMessage in message) WriteLine(coloredMessage);
}
}
}

public class ColoredMessage : ICloneable
{
public string text;
public ConsoleColor textColor;
public ConsoleColor backgroundColor;

public ColoredMessage(string text, ConsoleColor textColor = ConsoleColor.White, ConsoleColor backgroundColor = ConsoleColor.Black)
{
this.text = text;
this.textColor = textColor;
this.backgroundColor = backgroundColor;
}

public override string ToString()
{
return text;
}

public ColoredMessage Clone()
{
return new ColoredMessage(text.Clone() as string, textColor, backgroundColor);
}

object ICloneable.Clone()
{
return Clone();
}

public void Write()
{
ColoredConsole.Write(this);
}

public void WriteLine()
{
ColoredConsole.WriteLine(this);
}
}

public static class ColoredMessageEnumerableExtensions
{
public static string GetText(this IEnumerable<ColoredMessage> message)
{
return string.Join("", message);
}

public static void Write(this IEnumerable<ColoredMessage> message)
{
ColoredConsole.Write(message.ToArray());
}

public static void WriteLine(this IEnumerable<ColoredMessage> message)
{
ColoredConsole.WriteLine(message.ToArray());
}

public static void WriteLines(this IEnumerable<ColoredMessage> message)
{
ColoredConsole.WriteLines(message.ToArray());
}
}
}
116 changes: 116 additions & 0 deletions MultiAdmin/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System;
using System.IO;
using System.Linq;
using System.Text;

namespace MultiAdmin
{
public class Config
{
public string[] rawData;

public Config(string path)
{
ReadConfigFile(path);
}

public string Path { get; private set; }

public void ReadConfigFile(string path)
{
if (string.IsNullOrEmpty(path)) return;

rawData = File.Exists(path) ? File.ReadAllLines(path, Encoding.UTF8) : new string[] { };
Path = path;
}

public void ReadConfigFile()
{
ReadConfigFile(Path);
}

public bool Contains(string key)
{
return rawData != null && rawData.Any(entry => entry.ToLower().StartsWith(key.ToLower() + ":"));
}

private static string CleanValue(string value)
{
if (string.IsNullOrEmpty(value)) return value;

string newValue = value.Trim();

try
{
if (newValue.StartsWith("\"") && newValue.EndsWith("\""))
return newValue.Substring(1, newValue.Length - 2);
}
catch
{
// ignored
}

return newValue;
}

public string GetString(string key, string def = null)
{
try
{
foreach (string line in rawData)
{
if (!line.ToLower().StartsWith(key.ToLower() + ":")) continue;

try
{
return CleanValue(line.Substring(key.Length + 1));
}
catch
{
// ignored
}
}
}
catch
{
// ignored
}

return def;
}

public int GetInt(string key, int def = 0)
{
try
{
string value = GetString(key);

if (!string.IsNullOrEmpty(value))
return Convert.ToInt32(value);
}
catch
{
// ignored
}

return def;
}

public bool GetBool(string key, bool def = false)
{
try
{
string value = GetString(key);

if (!string.IsNullOrEmpty(value))
return Convert.ToBoolean(value);
}
catch
{
// ignored
}

return def;
}
}
}
Loading