From b01c03d0b9e56fc925aa7ecfbd8ede6c63f77b68 Mon Sep 17 00:00:00 2001 From: recroom2016 Date: Sat, 19 Feb 2022 16:02:47 -0500 Subject: [PATCH] Version 0.2 --- APIServer.cs | 4 ++-- Config2.cs | 2 +- GameSessions.cs | 42 ++++++++++++++++++------------------------ GetCachedLogin.cs | 2 +- LoginCached.cs | 2 +- Program.cs | 41 ++++++++++++++++++++++++++++++++++------- Setup.cs | 5 +++++ 7 files changed, 62 insertions(+), 36 deletions(-) diff --git a/APIServer.cs b/APIServer.cs index a4a8655..cf78243 100644 --- a/APIServer.cs +++ b/APIServer.cs @@ -264,9 +264,9 @@ namespace server s = PlayerEventsResponse; } if (Url == "gamesessions/v2/joinrandom") - { + { s = gamesessions2018.GameSessions.JoinRandom(text); - } + } Console.WriteLine("API Response: " + s); byte[] bytes = Encoding.UTF8.GetBytes(s); response.ContentLength64 = (long)bytes.Length; diff --git a/Config2.cs b/Config2.cs index 54b9414..301f5c1 100644 --- a/Config2.cs +++ b/Config2.cs @@ -52,7 +52,7 @@ namespace api return JsonConvert.SerializeObject(new Config2 { MessageOfTheDay = "Default MOTD", - CdnBaseUri = "http://img.rec.net/", + CdnBaseUri = "http://localhost:20182/", LevelProgressionMaps = new List { new LevelProgressionEntry diff --git a/GameSessions.cs b/GameSessions.cs index f25baf2..fedc49f 100644 --- a/GameSessions.cs +++ b/GameSessions.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using api; using server; - +using System.IO; namespace gamesessions2018 { // Token: 0x02000020 RID: 32 @@ -11,14 +11,18 @@ namespace gamesessions2018 // Token: 0x060000BE RID: 190 RVA: 0x00004C08 File Offset: 0x00002E08 public static string JoinRandom(string jsonData) { - + bool sandboxmode = false; GameSessions.JoinRandomRequest joinRandomRequest = JsonConvert.DeserializeObject(jsonData); - if (Config.localGameSession == null) + if (File.ReadAllText("SaveData\\App\\sandbox.txt") == "Enabled") { + sandboxmode = true; + } + + { Config.localGameSession = new GameSessions.SessionInstance { - GameSessionId = 2842L, - RegionId = "au", + GameSessionId = 2018L, + RegionId = "us", RoomId = joinRandomRequest.ActivityLevelIds[0], RecRoomId = null, EventId = null, @@ -26,7 +30,7 @@ namespace gamesessions2018 Name = "OpenRec", ActivityLevelId = joinRandomRequest.ActivityLevelIds[0], Private = false, - Sandbox = false, + Sandbox = sandboxmode, SupportsScreens = true, SupportsVR = true, GameInProgress = false, @@ -34,12 +38,7 @@ namespace gamesessions2018 IsFull = false }; } - else - { - Config.localGameSession.RoomId = joinRandomRequest.ActivityLevelIds[0]; - Config.localGameSession.ActivityLevelId = joinRandomRequest.ActivityLevelIds[0]; - Config.localGameSession.Sandbox = false; - } + return JsonConvert.SerializeObject(new GameSessions.JoinResult { Result = 0, @@ -64,20 +63,20 @@ namespace gamesessions2018 { Console.WriteLine("[API][GameSession] Creating Room..."); GameSessions.CreateRequest createRequest = JsonConvert.DeserializeObject(jsonData); - if (Config.localGameSession == null) + { Config.localGameSession = new GameSessions.SessionInstance { - GameSessionId = 2842L, - RegionId = "au", + GameSessionId = 2017L, + RegionId = "us", RoomId = createRequest.ActivityLevelIds, RecRoomId = null, EventId = null, CreatorPlayerId = (long?)APIServer.CachedPlayerID, - Name = "Dorm Room", + Name = "Custom Room", ActivityLevelId = createRequest.ActivityLevelIds, - Private = true, - Sandbox = true, + Private = false, + Sandbox = createRequest.IsSandbox, SupportsScreens = true, SupportsVR = true, GameInProgress = false, @@ -85,12 +84,7 @@ namespace gamesessions2018 IsFull = false }; } - else - { - Config.localGameSession.RoomId = createRequest.ActivityLevelIds; - Config.localGameSession.ActivityLevelId = createRequest.ActivityLevelIds; - Config.localGameSession.Sandbox = createRequest.IsSandbox; - } + return JsonConvert.SerializeObject(new GameSessions.JoinResult { Result = 0, diff --git a/GetCachedLogin.cs b/GetCachedLogin.cs index 5d662d4..451023c 100644 --- a/GetCachedLogin.cs +++ b/GetCachedLogin.cs @@ -23,7 +23,7 @@ namespace api2018 XP = 9999, Level = 10, RegistrationStatus = 2, - Developer = false, + Developer = true, CanReceiveInvites = false, ProfileImageName = name, JuniorProfile = false, diff --git a/LoginCached.cs b/LoginCached.cs index eccb881..343464a 100644 --- a/LoginCached.cs +++ b/LoginCached.cs @@ -53,7 +53,7 @@ namespace api2018 XP = 9999, Level = 10, RegistrationStatus = 2, - Developer = false, + Developer = true, CanReceiveInvites = false, ProfileImageName = name, JuniorProfile = false, diff --git a/Program.cs b/Program.cs index eae0694..284c10c 100644 --- a/Program.cs +++ b/Program.cs @@ -3,6 +3,7 @@ using server; using System.IO; using ws; using api; +using System.Net; namespace start { @@ -14,16 +15,42 @@ namespace start goto Start; Start: - Console.WriteLine("OpenRec - Open source RecNet server software."); + Console.WriteLine("OpenRec - Open source RecNet server software. (Version: " + version + ")"); Console.WriteLine("Made and provided by RecRoom 2016."); Console.WriteLine("Download source code here: https://github.com/recroom2016/OpenRec"); Console.WriteLine("Discord: https://discord.gg/daC8QUhnFP" + Environment.NewLine); - Console.WriteLine("1) Modify Settings" + Environment.NewLine + "2) Modify Profile" + Environment.NewLine + "3) Start Server"); + if (!(new WebClient().DownloadString("https://raw.githubusercontent.com/recroom2016/OpenRec/master/Download/version.txt").Contains(version))) + { + Console.WriteLine("This version of OpenRec is outdated. We recommend you install the latest version, OpenRec " + new WebClient().DownloadString("https://raw.githubusercontent.com/recroom2016/OpenRec/master/Download/version.txt") + Environment.NewLine); + } + Console.WriteLine("1) Change Settings" + Environment.NewLine + "2) Modify Profile" + Environment.NewLine + "3) Start Server"); string readline = Console.ReadLine(); if (readline == "1") { - Console.WriteLine("Not yet added in..."); - goto Start; + goto TrueFalse; + + TrueFalse: + Console.Clear(); + Console.WriteLine("1) Sandbox Mode: " + File.ReadAllText("SaveData\\App\\sandbox.txt") + Environment.NewLine + "2) Go Back"); + string readline4 = Console.ReadLine(); + if (readline4 == "1") + { + if (File.ReadAllText("SaveData\\App\\sandbox.txt") == "Disabled") + { + File.WriteAllText("SaveData\\App\\sandbox.txt", "Enabled"); + } + else + { + File.WriteAllText("SaveData\\App\\sandbox.txt", "Disabled"); + } + goto TrueFalse; + } + if (readline4 == "2") + { + Console.Clear(); + goto Start; + } + } if (readline == "2") { @@ -36,7 +63,7 @@ namespace start Console.WriteLine("Current Username: " + File.ReadAllText("SaveData\\Profile\\username.txt")); Console.WriteLine("New Username: "); string newusername = Console.ReadLine(); - File.WriteAllText("SaveData\\Profile\\username.txt)", newusername); + File.WriteAllText("SaveData\\Profile\\username.txt", newusername); Console.Clear(); goto Start; } @@ -48,7 +75,7 @@ namespace start } if (readline == "3") { - Console.WriteLine("Please select the version of RecRoom the server should host: (2016, 2017, 2018)"); + Console.WriteLine("Please select the version of RecRoom the server should host: (2018)"); string readline2 = Console.ReadLine(); if (readline2 == "2016") { @@ -79,7 +106,7 @@ namespace start } } - public static string version = "0.1"; + public static string version = "0.2"; } } diff --git a/Setup.cs b/Setup.cs index 2df2962..207a54b 100644 --- a/Setup.cs +++ b/Setup.cs @@ -11,6 +11,7 @@ namespace start public static void setup() { Console.WriteLine("Setting up..."); + Directory.CreateDirectory("SaveData\\App\\"); Directory.CreateDirectory("SaveData\\Profile\\"); if (!(File.Exists("SaveData\\avatar.txt"))) { @@ -40,6 +41,10 @@ namespace start { File.WriteAllText("SaveData\\settings.txt", Newtonsoft.Json.JsonConvert.SerializeObject(api.Settings.CreateDefaultSettings())); } + if (!(File.Exists("SaveData\\App\\sandbox.txt"))) + { + File.WriteAllText("SaveData\\App\\sandbox.txt", "Disabled"); + } if (!(File.Exists("SaveData\\profileimage.png"))) { File.WriteAllBytes("SaveData\\profileimage.png", new WebClient().DownloadData("https://github.com/OpenRecRoom/OpenRec/raw/main/profileimage.png"));