Skip to content

Commit 31cc7ca

Browse files
committed
remove the memory reader to allow it to work with EAAC
1 parent d48443d commit 31cc7ca

File tree

19 files changed

+200
-954
lines changed

19 files changed

+200
-954
lines changed

Battlefield rich presence/Api.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -72,35 +72,5 @@ public static ServerInfo GetCurrentServer(string playerName, Resources.Statics.G
7272
}
7373
return JsonConvert.DeserializeObject<ServerInfo>(responseContent);
7474
}
75-
76-
public static void PostPlayerlist(GameReader.CurrentServerReader currentServerReader, Guid guid)
77-
{
78-
var payload = new
79-
{
80-
guid = guid.ToString(),
81-
serverinfo = new
82-
{
83-
name = currentServerReader.ServerName,
84-
gameId = currentServerReader.GameId
85-
},
86-
teams = new
87-
{
88-
team1 = currentServerReader.PlayerListsTeam1,
89-
team2 = currentServerReader.PlayerListsTeam2,
90-
scoreteam1 = currentServerReader.ServerScoreTeam1,
91-
scoreteam2 = currentServerReader.ServerScoreTeam2,
92-
scoreteam1FromKills = currentServerReader.Team1ScoreFromKill,
93-
scoreteam2FromKills = currentServerReader.Team2ScoreFromKill,
94-
scoreteam1FromFlags = currentServerReader.Team1ScoreFromFlags,
95-
scoreteam2FromFlags = currentServerReader.Team2ScoreFromFlags,
96-
}
97-
};
98-
string dataString = JsonConvert.SerializeObject(payload);
99-
string jwtData = Jwt.Create(dataString);
100-
string stringPayload = JsonConvert.SerializeObject(new { data = jwtData });
101-
StringContent httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
102-
HttpResponseMessage httpResponse = new HttpClient().PostAsync("https://api.gametools.network/seederplayerlist/bf1", httpContent).Result;
103-
_ = httpResponse.Content.ReadAsStringAsync().Result;
104-
}
10575
}
10676
}

Battlefield rich presence/App.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@
5353
<setting name="Guid" serializeAs="String">
5454
<value>00000000-0000-0000-0000-000000000000</value>
5555
</setting>
56-
<setting name="GatherServerInfo" serializeAs="String">
57-
<value>False</value>
58-
</setting>
5956
<setting name="bf2042" serializeAs="String">
6057
<value />
6158
</setting>
59+
<setting name="bf1" serializeAs="String">
60+
<value />
61+
</setting>
6262
</BattlefieldRichPresence.Properties.Settings>
6363
</userSettings>
6464
</configuration>

Battlefield rich presence/Battlefield rich presence.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net7.0-windows</TargetFramework>
3+
<TargetFramework>net8.0-windows</TargetFramework>
44
<OutputType>WinExe</OutputType>
55
<RootNamespace>BattlefieldRichPresence</RootNamespace>
66
<IsWebBootstrapper>false</IsWebBootstrapper>
@@ -66,8 +66,8 @@
6666
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
6767
<PackageReference Include="System.Console" Version="4.3.1" />
6868
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
69-
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="7.0.2" />
70-
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.0.3" />
69+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="8.0.1" />
70+
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.1.2" />
7171
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
7272
<PackageReference Include="System.Linq.Expressions" Version="4.3.0" />
7373
<PackageReference Include="System.Memory" Version="4.5.5" />

Battlefield rich presence/ChangePrensence/Frostbite3.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ public static void Update(DiscordRpcClient client, DateTime startTime, GameInfo
6060
{
6161
buttons.Add(new Button { Label = "View server", Url = $"https://gametools.network/servers/{apiName}/gameid/{extraInfo.GameId}/pc" });
6262
}
63-
6463

6564
presence.Buttons = buttons.ToArray();
6665
client.SetPresence(presence);

Battlefield rich presence/Config.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace BattlefieldRichPresence
66
internal class Config
77
{
88
public Structs.GamesPlayerName PlayerNames;
9-
public bool GatherServerInfo;
109
public Guid Guid;
1110

1211
public Config()
@@ -24,27 +23,27 @@ public Config()
2423
public void Refresh()
2524
{
2625
Guid = Settings.Default.Guid;
27-
GatherServerInfo = Settings.Default.GatherServerInfo;
2826
PlayerNames = new Structs.GamesPlayerName()
2927
{
3028
Bfbc2 = Settings.Default.bfbc2,
3129
Bf3 = Settings.Default.bf3,
3230
Bf4 = Settings.Default.bf4,
3331
Bfh = Settings.Default.bfh,
32+
Bf1 = Settings.Default.bf1,
3433
Bf5 = Settings.Default.bf5,
3534
Bf2042 = Settings.Default.bf2042
3635
};
3736
}
3837

3938
public void Update()
4039
{
41-
Settings.Default.GatherServerInfo = GatherServerInfo;
4240
Settings.Default.Guid = Guid;
4341

4442
Settings.Default.bfbc2 = PlayerNames.Bfbc2;
4543
Settings.Default.bf3 = PlayerNames.Bf3;
4644
Settings.Default.bf4 = PlayerNames.Bf4;
4745
Settings.Default.bfh = PlayerNames.Bfh;
46+
Settings.Default.bf1 = PlayerNames.Bf1;
4847
Settings.Default.bf5 = PlayerNames.Bf5;
4948
Settings.Default.bf2042 = PlayerNames.Bf2042;
5049
Settings.Default.Save();

Battlefield rich presence/DiscordPresence.cs

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using BattlefieldRichPresence.ChangePrensence;
3-
using BattlefieldRichPresence.GameReader;
43
using BattlefieldRichPresence.Resources;
54
using BattlefieldRichPresence.Structs;
65
using DiscordRPC;
@@ -122,42 +121,7 @@ public void Update()
122121
{
123122
GameInfo gameInfo = Game.IsRunning();
124123
StartStopDiscord(gameInfo);
125-
if (gameInfo.Game == Statics.Game.Bf1)
126-
{
127-
CurrentServerReader currentServerReader = new CurrentServerReader();
128-
if (currentServerReader.HasResults)
129-
{
130-
if (currentServerReader.PlayerListsAll.Count > 0 && currentServerReader.ServerName != "")
131-
{
132-
ServerInfo serverInfo = new ServerInfo
133-
{
134-
Name = currentServerReader.ServerName,
135-
NumPlayers = currentServerReader.PlayerListsAll.Count,
136-
MaxPlayers = 0,
137-
JoinLinkWeb = ""
138-
};
139-
UpdatePresence(gameInfo, serverInfo);
140-
141-
// send info to gametools about server to show in detailed serverinfo page when enabled (privacy reasons)
142-
if (_config.GatherServerInfo)
143-
{
144-
try
145-
{
146-
Api.PostPlayerlist(currentServerReader, this._config.Guid);
147-
}
148-
catch (Exception)
149-
{
150-
151-
}
152-
}
153-
}
154-
else
155-
{
156-
UpdatePresenceInMenu(gameInfo);
157-
}
158-
}
159-
}
160-
else if (Statics.NewTitles.Contains(gameInfo.Game))
124+
if (Statics.NewTitles.Contains(gameInfo.Game))
161125
{
162126
try
163127
{

0 commit comments

Comments
 (0)