Skip to content
Permalink
Browse files

Replace subdivision as a string instead of a string array.

Reduces memory usage by 400 kilobytes on my test server with 2900 players, and by 10 megabytes on my test server with 371,500 players.
  • Loading branch information...
UnknownShadow200 committed Aug 3, 2017
1 parent d3fd25f commit 215878e89f005b186008c0b3fe852aaa432edb23
Showing with 5 additions and 9 deletions.
  1. +2 −2 fCraft/Commands/InfoCommands.cs
  2. +3 −7 fCraft/Player/PlayerInfo.cs
@@ -1819,7 +1819,7 @@ static void EmotesHandler(Player player, CommandReader cmd)
player.Message( "Geo Info about: {0}&S ({1})", info.ClassyName, info.GeoIP ?? "N/A" );
player.Message(" Country: &f{1}&S ({0})", info.CountryCode ?? "N/A", info.CountryName ?? "N/A");
player.Message(" Continent: &f{0}", info.Continent ?? "N/A");
player.Message(" Subdivisions: &f{0}", info.Subdivision.JoinToString(", "));
player.Message(" Subdivisions: &f{0}", info.Subdivision);
player.Message(" Latitude: &f{0}", info.Latitude ?? "N/A");
player.Message(" Longitude: &f{0}", info.Longitude ?? "N/A");
player.Message(" Time Zone: &f{0}", info.TimeZone ?? "N/A");
@@ -1891,7 +1891,7 @@ static void EmotesHandler(Player player, CommandReader cmd)
info.CountryName = result.Get("country") ?? "N/A";
info.CountryCode = result.Get("country_abbr") ?? "N/A";
info.Continent = result.Get("continent") ?? "N/A";
info.Subdivision = nan.Replace(result.Get("subdivision"), "").Split(',');
info.Subdivision = nan.Replace(result.Get("subdivision"), "");
info.Latitude = result.Get("latitude") ?? "N/A";
info.Longitude = result.Get("longitude") ?? "N/A";
info.TimeZone = result.Get("timezone") ?? "N/A";
@@ -459,7 +459,7 @@ public string BlocksDrawnString
/// <summary> Players longitude based on geoip</summary>
public string Longitude;
/// <summary> List of subdivisions (City, State, etc) sorting by accuracy from left to right. </summary>
public string[] Subdivision = new string[] {"NA"};
public string Subdivision = "NA";
/// <summary> Players geoip accuracy</summary>
public byte Accuracy = 0;
/// <summary> Players hostname</summary>
@@ -756,7 +756,7 @@ public PlayerInfo( [NotNull] string name, [NotNull] IPAddress lastIP, [NotNull]

if (count > 81) info.skinName = PlayerDB.Unescape(fields[81]);

if (count > 82) info.Subdivision = PlayerDB.Unescape(fields[82]).Split();
if (count > 82) info.Subdivision = PlayerDB.Unescape(fields[82]);
if (count > 83) byte.TryParse(fields[83], out info.Accuracy);
if (count > 84) info.Hostname = fields[84];
if (count > 85) info.Continent = fields[85];
@@ -1273,12 +1273,8 @@ public PlayerInfo( [NotNull] string name, [NotNull] IPAddress lastIP, [NotNull]
sb.Append(',');
sb.AppendEscaped(skinName); // 81


sb.Append(',');
string divs = "";
if (Subdivision.Length == 1) divs = Subdivision[0];
else if(Subdivision.Length > 1) divs = String.Join(", ", Subdivision);
sb.AppendEscaped(divs); // 82
sb.AppendEscaped(Subdivision); // 82
sb.Append(',');
sb.Append(Accuracy); // 83
sb.Append(',');

0 comments on commit 215878e

Please sign in to comment.
You can’t perform that action at this time.