Skip to content

Commit 64846fe

Browse files
committed
fix
1 parent 7ecd441 commit 64846fe

18 files changed

Lines changed: 331 additions & 100 deletions

File tree

ChobbyLauncher/ChobbyLoopbackMessages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public class SteamOffline
139139
public class WrapperOnline
140140
{
141141
public string UserID { get; set;}
142+
public string InstallID { get; set; }
142143
public string DefaultServerHost { get; set; }
143144
public int DefaultServerPort { get; set; }
144145
public bool IsSteamFolder { get; set; }

ChobbyLauncher/Chobbyla.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ public bool Run(ulong initialConnectLobbyID, TextWriter writer)
196196
return ret;
197197
}
198198
}
199-
200199

201200
private string GetSteamEngine()
202201
{

ChobbyLauncher/ChobbylaLocalListener.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ private async Task OnConnected()
737737
DefaultServerHost = GlobalConst.LobbyServerHost,
738738
DefaultServerPort = GlobalConst.LobbyServerPort,
739739
UserID = Utils.GetMyUserID().ToString(),
740+
InstallID = Utils.GetMyInstallID(),
740741
IsSteamFolder = chobbyla.IsSteamFolder
741742

742743
});

Fixer/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ public static void MassBan(string name, int startIndex, int endIndex, string rea
10081008
if (acc != null)
10091009
{
10101010
int? userID = banID ? (int?)acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault().UserID : null;
1011+
string installID = banID ? acc.AccountUserIDs.OrderByDescending(x => x.LastLogin).FirstOrDefault().InstallID : null;
10111012
string userIP = banIP ? acc.AccountIPs.OrderByDescending(x => x.LastLogin).FirstOrDefault().IP : null;
10121013
System.Console.WriteLine(acc.Name, userID, userIP);
10131014
Punishment punishment = new Punishment
@@ -1020,6 +1021,7 @@ public static void MassBan(string name, int startIndex, int endIndex, string rea
10201021
BanIP = userIP,
10211022
CreatedAccountID = 5806,
10221023
UserID = userID,
1024+
InstallID = installID,
10231025
};
10241026
acc.PunishmentsByAccountID.Add(punishment);
10251027
}

Shared/LobbyClient/Protocol/Messages.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public enum ClientTypes
133133

134134
public long UserID { get; set; }
135135

136+
public string InstallID { get; set; }
137+
136138
public List<ulong> Dlc { get; set; }
137139
}
138140

@@ -156,6 +158,7 @@ public class Register
156158
public string Email { get; set; }
157159

158160
public long UserID { get; set; }
161+
public string InstallID { get; set; }
159162
}
160163

161164
[Message(Origin.Server)]

Shared/PlasmaShared/Utils.cs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public static string MakePath(params string[] directories)
438438
return Path.Combine(directories);
439439
}
440440

441-
441+
442442
public static string PrintByteLength(long bytes)
443443
{
444444
if (bytes < 1024) return bytes.ToString();
@@ -517,7 +517,7 @@ public static U Get<T, U>(this IDictionary<T, U> dict, T key)
517517
return val;
518518
}
519519

520-
520+
521521
public static List<T> Shuffle<T>(this IEnumerable<T> source)
522522
{
523523
var list = source.ToList();
@@ -576,7 +576,7 @@ public static void StartAsync(Action action)
576576
});
577577
}
578578

579-
579+
580580

581581
public static byte[] ToBytes(this Image image, int size)
582582
{
@@ -595,7 +595,7 @@ public static byte[] ToBytes(this Image image, int size)
595595
return stream.ToArray();
596596
}
597597

598-
598+
599599

600600
/// <summary>
601601
/// Hash password with default hash used by remote server
@@ -628,7 +628,7 @@ public static void SafeDelete(string path)
628628
}
629629
catch { }
630630
}
631-
631+
632632

633633
public static string ToHex(this byte[] array)
634634
{
@@ -700,22 +700,26 @@ public static async Task<FileResponse<byte[]>> DownloadFileAsync(string url, Dat
700700
var ms = new MemoryStream();
701701
var wc = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
702702
var ret = new FileResponse<byte[]>();
703-
703+
704704
if (ifModifiedSince != null) wc.IfModifiedSince = ifModifiedSince.Value;
705705

706-
try {
707-
using (var response = (HttpWebResponse)await wc.GetResponseAsync().ConfigureAwait(false)) {
706+
try
707+
{
708+
using (var response = (HttpWebResponse)await wc.GetResponseAsync().ConfigureAwait(false))
709+
{
708710
ret.WasModified = true;
709711
ret.DateModified = response.LastModified;
710712

711-
using (var stream = response.GetResponseStream()) {
713+
using (var stream = response.GetResponseStream())
714+
{
712715
await stream.CopyToAsync(ms).ConfigureAwait(false);
713716
ret.Content = ms.ToArray();
714717
return ret;
715718
}
716719
}
717720
}
718-
catch (WebException e) {
721+
catch (WebException e)
722+
{
719723
if (e.Response != null && ((HttpWebResponse)e.Response).StatusCode == HttpStatusCode.NotModified) return ret;
720724
throw;
721725
}
@@ -724,7 +728,8 @@ public static async Task<FileResponse<byte[]>> DownloadFileAsync(string url, Dat
724728
public static async Task<FileResponse<string>> DownloadStringAsync(string url, DateTime? ifModifiedSince = null)
725729
{
726730
var file = await DownloadFileAsync(url, ifModifiedSince).ConfigureAwait(false);
727-
return new FileResponse<string>() {
731+
return new FileResponse<string>()
732+
{
728733
WasModified = file.WasModified,
729734
DateModified = file.DateModified,
730735
Content = file.Content != null ? Encoding.UTF8.GetString(file.Content) : null
@@ -754,10 +759,10 @@ public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
754759
public static IEnumerable<Type> GetAllTypesWithAttribute<T>()
755760
{
756761
return from a in AppDomain.CurrentDomain.GetAssemblies().AsParallel()
757-
from t in a.GetLoadableTypes()
758-
let attributes = t.GetCustomAttributes(typeof(T), true)
759-
where attributes != null && attributes.Length > 0
760-
select t;
762+
from t in a.GetLoadableTypes()
763+
let attributes = t.GetCustomAttributes(typeof(T), true)
764+
where attributes != null && attributes.Length > 0
765+
select t;
761766
}
762767

763768
/// <summary>
@@ -821,7 +826,8 @@ public static string Truncate(this string input, int length)
821826
return input.Substring(0, length);
822827
}
823828

824-
public static bool ValidLobbyNameCharacter(char c) {
829+
public static bool ValidLobbyNameCharacter(char c)
830+
{
825831
if (c >= 'a' && c <= 'z') return true;
826832
if (c >= 'A' && c <= 'Z') return true;
827833
if (c >= '0' && c <= '9') return true;
@@ -830,13 +836,26 @@ public static bool ValidLobbyNameCharacter(char c) {
830836
return false;
831837
}
832838

833-
public static string StripInvalidLobbyNameChars(string name) {
839+
public static string StripInvalidLobbyNameChars(string name)
840+
{
834841
if (String.IsNullOrEmpty(name)) return name;
835842
var sb = new StringBuilder();
836843
foreach (var c in name.Where(Utils.ValidLobbyNameCharacter)) sb.Append(c);
837844
return sb.ToString();
838845
}
839846

847+
public static string GetMyInstallID()
848+
{
849+
850+
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "chobbyla", "id.txt");
851+
if (!File.Exists(path))
852+
{
853+
string guid = Guid.NewGuid().ToString();
854+
File.WriteAllText(path, guid);
855+
}
856+
return File.ReadAllText(path);
857+
}
858+
840859
public static long GetMyUserID()
841860
{
842861
try
@@ -854,7 +873,7 @@ public static long GetMyUserID()
854873
}
855874
catch (Exception ex)
856875
{
857-
Trace.TraceWarning("Failed to get the userID: {0}",ex);
876+
Trace.TraceWarning("Failed to get the userID: {0}", ex);
858877
}
859878
return 0;
860879
}
@@ -899,7 +918,7 @@ public static T ReadStruct<T>(this BinaryReader reader)
899918
return reader.ReadBytes(Marshal.SizeOf(typeof(T))).ToStruct<T>();
900919
}
901920

902-
public static DateTime UnixToDateTime(this UInt64 secondsFrom1970)
921+
public static DateTime UnixToDateTime(this UInt64 secondsFrom1970)
903922
{
904923
var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
905924
dtDateTime = dtDateTime.AddSeconds(secondsFrom1970).ToLocalTime();

Zero-K.info/Controllers/ForumController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public ActionResult NewPost(int? categoryID, int? threadID, int? forumPostID, st
195195
var res = new NewPostResult();
196196
var db = new ZkDataContext();
197197

198-
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, x => x.BanForum);
198+
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, null, x => x.BanForum);
199199
if (penalty != null)
200200
{
201201
return
@@ -268,7 +268,7 @@ public ActionResult SubmitPost(
268268
forumPostID == null && string.IsNullOrWhiteSpace(title)) return Content("Cannot post new thread with blank title");
269269
if (string.IsNullOrWhiteSpace(text)) return Content("Please type some text :)");
270270

271-
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, x => x.BanForum);
271+
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, null, x => x.BanForum);
272272
if (penalty != null)
273273
{
274274
return
@@ -526,7 +526,7 @@ public ActionResult VotePost(int forumPostID, int delta) {
526526
var db = new ZkDataContext();
527527
var myAcc = Global.Account;
528528

529-
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, x => x.BanForum);
529+
var penalty = Punishment.GetActivePunishment(Global.AccountID, Request.UserHostAddress, 0, null, x => x.BanForum);
530530
if (penalty != null)
531531
return Content(string.Format("You cannot vote while banned from forum!\nExpires: {0} UTC\nReason: {1}", penalty.BanExpires, penalty.Reason));
532532

0 commit comments

Comments
 (0)