aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Server
diff options
context:
space:
mode:
authorAShifter <[email protected]>2017-06-05 09:49:46 -0600
committerAShifter <[email protected]>2017-06-05 09:49:46 -0600
commit61c906e596145bbedd60725c6dcee68c34a27907 (patch)
treecd7a00d501affe96028bfb21a8dec90c2ee63f2c /ShiftOS.Server
parent66ea2cf2fdeeaa025bd22961a0400423233c505d (diff)
parent3e11eca70481841b6e2f2253d667944779cfd5fb (diff)
downloadshiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.tar.gz
shiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.tar.bz2
shiftos_thereturn-61c906e596145bbedd60725c6dcee68c34a27907.zip
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.Server')
-rw-r--r--ShiftOS.Server/Program.cs40
-rw-r--r--ShiftOS.Server/RandomUserGenerator.cs2
-rw-r--r--ShiftOS.Server/SaveManager.cs48
3 files changed, 52 insertions, 38 deletions
diff --git a/ShiftOS.Server/Program.cs b/ShiftOS.Server/Program.cs
index 97c8a66..5170ccd 100644
--- a/ShiftOS.Server/Program.cs
+++ b/ShiftOS.Server/Program.cs
@@ -55,17 +55,6 @@ namespace ShiftOS.Server
public class Program
{
/// <summary>
- /// The admin username.
- /// </summary>
- public static string AdminUsername = "admin";
-
- /// <summary>
- /// The admin password.
- /// </summary>
- public static string AdminPassword = "admin";
-
-
- /// <summary>
/// The server.
/// </summary>
public static NetObjectServer server;
@@ -86,16 +75,28 @@ namespace ShiftOS.Server
/// <param name="args">The command-line arguments.</param>
public static void Main(string[] args)
{
+ Thread.Sleep(2000);
+ AppDomain.CurrentDomain.UnhandledException += (o, a) =>
+ {
+ System.Diagnostics.Process.Start("ShiftOS.Server.exe");
+ Environment.Exit(0);
+ };
+ UserConfig.Get();
System.Timers.Timer tmr = new System.Timers.Timer(5000);
tmr.Elapsed += (o, a) =>
{
if (server.IsOnline)
{
- server.DispatchAll(new NetObject("heartbeat", new ServerMessage
+
+ try
{
- Name = "heartbeat",
- GUID = "server"
- }));
+ server.DispatchAll(new NetObject("heartbeat", new ServerMessage
+ {
+ Name = "heartbeat",
+ GUID = "server"
+ }));
+ }
+ catch { }
}
};
if (!Directory.Exists("saves"))
@@ -154,13 +155,7 @@ namespace ShiftOS.Server
Console.WriteLine("FUCK. Something HORRIBLE JUST HAPPENED.");
};
- AppDomain.CurrentDomain.UnhandledException += (o, a) =>
- {
- if(server.IsOnline == true)
- server.Stop();
- System.Diagnostics.Process.Start("ShiftOS.Server.exe");
- };
-
+
server.OnReceived += (o, a) =>
{
var obj = a.Data.Object;
@@ -207,7 +202,6 @@ namespace ShiftOS.Server
task.Wait();
*/
- RandomUserGenerator.StartThread();
while (server.IsOnline)
{
diff --git a/ShiftOS.Server/RandomUserGenerator.cs b/ShiftOS.Server/RandomUserGenerator.cs
index 3a62f9c..6da891d 100644
--- a/ShiftOS.Server/RandomUserGenerator.cs
+++ b/ShiftOS.Server/RandomUserGenerator.cs
@@ -111,7 +111,7 @@ namespace ShiftOS.Server
break;
}
- sve.Codepoints = rnd.Next(startCP, maxAmt);
+ sve.Codepoints = (ulong)rnd.Next(startCP, maxAmt);
//FS treasure generation.
/*
diff --git a/ShiftOS.Server/SaveManager.cs b/ShiftOS.Server/SaveManager.cs
index 63aa2bf..cb2e1ba 100644
--- a/ShiftOS.Server/SaveManager.cs
+++ b/ShiftOS.Server/SaveManager.cs
@@ -189,7 +189,7 @@ namespace ShiftOS.Server
//Update the shiftos website with the user's codepoints.
if (!string.IsNullOrWhiteSpace(sav.UniteAuthToken))
{
- var wreq = WebRequest.Create("http://getshiftos.ml/API/SetCodepoints/" + sav.Codepoints.ToString());
+ var wreq = WebRequest.Create(UserConfig.Get().UniteUrl + "/API/SetCodepoints/" + sav.Codepoints.ToString());
wreq.Headers.Add("Authentication: Token " + sav.UniteAuthToken);
wreq.GetResponse();
}
@@ -207,8 +207,7 @@ namespace ShiftOS.Server
{
var save = JsonConvert.DeserializeObject<Save>(ReadEncFile(savefile));
-
- if (save.UniteAuthToken==token)
+ if (save.UniteAuthToken == token)
{
if (save.ID == new Guid())
{
@@ -216,6 +215,31 @@ namespace ShiftOS.Server
WriteEncFile(savefile, JsonConvert.SerializeObject(save));
}
+ var wr = HttpWebRequest.Create(UserConfig.Get().UniteUrl + "/API/GetCodepoints");
+ wr.Headers.Add("Authentication: Token " + save.UniteAuthToken);
+ try
+ {
+ using (var resp = wr.GetResponse())
+ {
+ using (var str = resp.GetResponseStream())
+ {
+ using (var reader = new StreamReader(str))
+ {
+ Console.WriteLine("This user has " + reader.ReadToEnd() + " Codepoint(s).");
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage
+ {
+ Name = "mud_login_denied",
+ GUID = "server"
+ }));
+ return;
+ }
Program.server.DispatchTo(new Guid(guid), new NetObject("mud_savefile", new ServerMessage
{
@@ -228,15 +252,11 @@ namespace ShiftOS.Server
}
catch { }
}
- try
+ Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage
{
- Program.server.DispatchTo(new Guid(guid), new NetObject("auth_failed", new ServerMessage
- {
- Name = "mud_login_denied",
- GUID = "server"
- }));
- }
- catch { }
+ Name = "mud_login_denied",
+ GUID = "server"
+ }));
}
[MudRequest("delete_save", typeof(ClientSave))]
@@ -268,7 +288,7 @@ namespace ShiftOS.Server
{
args["username"] = args["username"].ToString().ToLower();
string userName = args["username"] as string;
- long cpAmount = (long)args["amount"];
+ ulong cpAmount = (ulong)args["amount"];
if (Directory.Exists("saves"))
{
@@ -302,7 +322,7 @@ namespace ShiftOS.Server
args["username"] = args["username"].ToString().ToLower();
string userName = args["username"] as string;
string passw = args["password"] as string;
- int cpAmount = (int)args["amount"];
+ ulong cpAmount = (ulong)args["amount"];
if (Directory.Exists("saves"))
{
@@ -315,7 +335,7 @@ namespace ShiftOS.Server
WriteEncFile(saveFile, JsonConvert.SerializeObject(saveFileContents, Formatting.Indented));
Program.ClientDispatcher.Broadcast("update_your_cp", new {
username = userName,
- amount = -cpAmount
+ amount = -(long)cpAmount
});
Program.ClientDispatcher.DispatchTo("update_your_cp", guid, new
{