Skip to content

Commit b773f86

Browse files
committedJan 5, 2012
More RPC Reworking.
Friend list working better. Can now invite to group and start multiplayer games. Missing ReportService added in. ActorId fixes to MessageViewer.
1 parent afa870e commit b773f86

19 files changed

+724
-296
lines changed
 

‎Compatibility

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Currently supported:
66
* .NET Framework Version: .NET FX 4.0
77
* Microsoft Runtime: .NET 4.0
88
* Mono Runtime: 2.10.5
9-
* Game Version: Patch6 (7841)
9+
* Game Version: Patch9 (8101)
1010

1111
Requirements:
1212

‎src/Mooege/Core/GS/Players/Player.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ public PlayerBannerMessage GetPlayerBanner()
11611161
{
11621162
var playerBanner = D3.GameMessage.PlayerBanner.CreateBuilder()
11631163
.SetPlayerIndex((uint)this.PlayerIndex)
1164-
.SetBanner(this.Toon.GameAccount.BannerConfiguration)
1164+
.SetBanner(this.Toon.GameAccount.BannerConfigurationField.Value)
11651165
.Build();
11661166

11671167
return new PlayerBannerMessage() { PlayerBanner = playerBanner };

‎src/Mooege/Core/MooNet/Accounts/Account.cs

+94-82
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,60 @@ namespace Mooege.Core.MooNet.Accounts
3333
{
3434
public class Account : PersistentRPCObject
3535
{
36-
public D3.PartyMessage.ScreenStatus ScreenStatus { get; set; }
36+
//public D3.PartyMessage.ScreenStatus ScreenStatus { get; set; }
3737

38-
//public MooNetClient LoggedInClient { get; set; }
39-
public bool IsOnline
40-
{
41-
get
38+
39+
public ByteStringPresenceField<D3.OnlineService.EntityId> SelectedGameAccountField
40+
= new ByteStringPresenceField<D3.OnlineService.EntityId>(FieldKeyHelper.Program.D3, FieldKeyHelper.OriginatingClass.Account, 2, 0);
41+
42+
public StringPresenceField RealIDTagField
43+
= new StringPresenceField(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 1, 0);
44+
45+
public ByteStringPresenceField<D3.OnlineService.EntityId> LastSelectedHeroField
46+
= new ByteStringPresenceField<D3.OnlineService.EntityId>(FieldKeyHelper.Program.D3, FieldKeyHelper.OriginatingClass.Account, 1, 0);
47+
48+
public BoolPresenceField AccountOnlineField
49+
= new BoolPresenceField(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 2, 0);
50+
51+
public StringPresenceField AccountBattleTagField
52+
= new StringPresenceField(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 5, 0);
53+
54+
public EntityIdPresenceFieldList GameAccountListField
55+
= new EntityIdPresenceFieldList(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 4, 0);
56+
57+
public bool IsOnline
58+
{
59+
get
4260
{
4361
//check if anygameAccounts are online
4462
foreach (var gameAccount in GameAccounts)
4563
{
4664
if (gameAccount.Value.IsOnline) return true;
4765
}
4866
return false;
49-
}
67+
}
5068
}
5169

5270
public string Email { get; private set; } // I - Username
5371
public byte[] Salt { get; private set; } // s- User's salt.
5472
public byte[] PasswordVerifier { get; private set; } // v - password verifier.
55-
public string Name { get; private set; }
73+
74+
//TODO: Eliminate this variable as it is used inside the Field property
75+
private string _name;
76+
public string Name
77+
{
78+
get
79+
{
80+
return this._name;
81+
}
82+
private set
83+
{
84+
this._name = value;
85+
this.RealIDTagField.Value = this.Name;
86+
this.AccountBattleTagField.Value = Name + "#" + HashCode.ToString("D4");
87+
}
88+
}
89+
5690
public int HashCode { get; private set; }
5791
public string BattleTag
5892
{
@@ -68,6 +102,7 @@ public string BattleTag
68102
var split = value.Split('#');
69103
this.Name = split[0];
70104
this.HashCode = Convert.ToInt32(split[1]);
105+
this.AccountBattleTagField.Value = Name + "#" + HashCode.ToString("D4");
71106
}
72107
}
73108

@@ -78,21 +113,44 @@ public Dictionary<ulong, GameAccount> GameAccounts
78113
get { return GameAccountManager.GetGameAccountsForAccount(this); }
79114
}
80115

81-
public GameAccount CurrentGameAccount { get; set; }
116+
//TODO: Eliminate completly this variable as it is stored already in the persistence field;
117+
private GameAccount _currentGameAccount;
118+
public GameAccount CurrentGameAccount
119+
{
120+
get
121+
{
122+
return this._currentGameAccount;
123+
}
124+
set
125+
{
126+
this.LastSelectedGameAccount = value.D3GameAccountId;
127+
this.SelectedGameAccountField.Value = value.D3GameAccountId;
128+
this._currentGameAccount = value;
129+
}
130+
}
82131

83132
public static readonly D3.OnlineService.EntityId AccountHasNoToons =
84133
D3.OnlineService.EntityId.CreateBuilder().SetIdHigh(0).SetIdLow(0).Build();
85134

135+
//TODO: Eliminate this variable as it is stored already in the persistence field;
86136
private D3.OnlineService.EntityId _lastSelectedHero = AccountHasNoToons;
87137
public D3.OnlineService.EntityId LastSelectedHero
88138
{
89139
get
90140
{
141+
if (_lastSelectedHero == AccountHasNoToons)
142+
{
143+
var gameAccount = GameAccountManager.GetAccountByPersistentID(this.LastSelectedGameAccount.IdLow);
144+
if (gameAccount.Toons.Count > 0)
145+
_lastSelectedHero = gameAccount.Toons.First().Value.D3EntityID;
146+
this.LastSelectedHeroField.Value = _lastSelectedHero;
147+
}
91148
return _lastSelectedHero;
92149
}
93150
set
94151
{
95152
_lastSelectedHero = value;
153+
this.LastSelectedHeroField.Value = value;
96154
}
97155
}
98156

@@ -101,11 +159,15 @@ public D3.OnlineService.EntityId LastSelectedGameAccount
101159
{
102160
get
103161
{
162+
if (_lastSelectedGameAccount == AccountHasNoToons && this.GameAccounts.Count > 0)
163+
_lastSelectedGameAccount = this.SelectedGameAccountField.Value = this.GameAccounts.First().Value.D3GameAccountId;
104164
return _lastSelectedGameAccount;
105165
}
106166
set
107167
{
108168
_lastSelectedGameAccount = value;
169+
this.SelectedGameAccountField.Value = value;
170+
109171
}
110172
}
111173

@@ -146,6 +208,7 @@ private void SetFields(string email, byte[] salt, byte[] passwordVerifier, strin
146208

147209
this.Name = battleTagName;
148210
this.HashCode = hashCode;
211+
this.AccountBattleTagField.Value = Name + "#" + HashCode.ToString("D4");
149212
}
150213

151214
public bnet.protocol.presence.Field QueryField(bnet.protocol.presence.FieldKey queryKey)
@@ -176,6 +239,13 @@ public bnet.protocol.presence.Field QueryField(bnet.protocol.presence.FieldKey q
176239

177240
#region Notifications
178241

242+
public override void NotifyUpdate()
243+
{
244+
var operations = ChangedFields.GetChangedFieldList();
245+
ChangedFields.ClearChanged();
246+
base.MakeRPC(this.CurrentGameAccount.LoggedInClient, operations);
247+
}
248+
179249
//account class generated
180250
//D3, Account,1,0 -> D3.OnlineService.EntityId: Last Played Hero
181251
//D3, Account,2,0 -> LastSelectedGameAccount
@@ -186,90 +256,32 @@ public bnet.protocol.presence.Field QueryField(bnet.protocol.presence.FieldKey q
186256

187257
public override List<bnet.protocol.presence.FieldOperation> GetSubscriptionNotifications()
188258
{
259+
//TODO: Create delegate inside Persistence field so IsOnline can be removed
260+
this.AccountOnlineField.Value = this.IsOnline;
261+
//TODO: Create delegate-move this out
262+
this.GameAccountListField.Value.Clear();
263+
foreach (var pair in this.GameAccounts.Values)
264+
{
265+
this.GameAccountListField.Value.Add(pair.BnetEntityId);
266+
}
267+
268+
189269
var operationList = new List<bnet.protocol.presence.FieldOperation>();
190270

191271
if (this.LastSelectedHero != AccountHasNoToons)
192-
operationList.Add(GetCurrentlySelectedHeroNotification());
272+
operationList.Add(this.LastSelectedHeroField.GetFieldOperation());
193273
if (this.LastSelectedGameAccount != AccountHasNoToons)
194-
operationList.Add(GetSelectedGameAccount());
195-
operationList.Add(GetAccountIsOnlineNotification());
196-
operationList.AddRange(GetGameAccountListNotification());
197-
operationList.Add(GetAccountBattleTagNotification());
274+
operationList.Add(this.SelectedGameAccountField.GetFieldOperation());
275+
operationList.Add(this.RealIDTagField.GetFieldOperation());
276+
operationList.Add(this.AccountOnlineField.GetFieldOperation());
277+
operationList.AddRange(this.GameAccountListField.GetFieldOperationList());
278+
operationList.Add(this.AccountBattleTagField.GetFieldOperation());
198279

199280
return operationList;
200281
}
201282

202-
/// <summary>
203-
/// D3, Account, 2, 0: Selected Game Account
204-
/// </summary>
205-
/// <returns></returns>
206-
public bnet.protocol.presence.FieldOperation GetSelectedGameAccount()
207-
{
208-
var GameAccountKey = FieldKeyHelper.Create(FieldKeyHelper.Program.D3, FieldKeyHelper.OriginatingClass.Account, 2, 0);
209-
var GameAccountField = bnet.protocol.presence.Field.CreateBuilder().SetKey(GameAccountKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(this.CurrentGameAccount.D3GameAccountId.ToByteString()).Build()).Build();
210-
return bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(GameAccountField).Build();
211-
}
212-
213-
/// <summary>
214-
/// BNet, Account, 1, 0: RealIDTag
215-
/// </summary>
216-
/// <returns></returns>
217-
public bnet.protocol.presence.FieldOperation GetRealIDName()
218-
{
219-
var realNameKey = FieldKeyHelper.Create(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 1, 0);
220-
var realNameField = bnet.protocol.presence.Field.CreateBuilder().SetKey(realNameKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetStringValue(this.Name).Build()).Build();
221-
return (bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(realNameField).Build());
222-
}
223283

224-
/// <summary>
225-
/// D3, Account, 1, 0: Currently Selected Hero
226-
/// </summary>
227-
/// <returns></returns>
228-
public bnet.protocol.presence.FieldOperation GetCurrentlySelectedHeroNotification()
229-
{
230-
var ToonKey = FieldKeyHelper.Create(FieldKeyHelper.Program.D3, FieldKeyHelper.OriginatingClass.Account, 1, 0);
231-
var ToonField = bnet.protocol.presence.Field.CreateBuilder().SetKey(ToonKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(this.LastSelectedHero.ToByteString()).Build()).Build();
232-
return bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(ToonField).Build();
233-
}
234284

235-
/// <summary>
236-
/// BNet, Account, 2, 0: Account Online
237-
/// </summary>
238-
/// <returns></returns>
239-
public bnet.protocol.presence.FieldOperation GetAccountIsOnlineNotification()
240-
{
241-
var accountOnlineKey = FieldKeyHelper.Create(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 2, 0);
242-
var accountOnlineField = bnet.protocol.presence.Field.CreateBuilder().SetKey(accountOnlineKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetBoolValue(this.IsOnline).Build()).Build();
243-
return bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(accountOnlineField).Build();
244-
}
245-
246-
/// <summary>
247-
/// BNet, Account, 5, 0: Account BattleTag
248-
/// </summary>
249-
/// <returns></returns>
250-
public bnet.protocol.presence.FieldOperation GetAccountBattleTagNotification()
251-
{
252-
var tempNameKey = FieldKeyHelper.Create(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 5, 0);
253-
var tempNameField = bnet.protocol.presence.Field.CreateBuilder().SetKey(tempNameKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetStringValue(this.BattleTag).Build()).Build();
254-
return bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(tempNameField).Build();
255-
}
256-
257-
/// <summary>
258-
/// BNet, Account, 4, index: Account GameAccountList
259-
/// </summary>
260-
/// <returns></returns>
261-
public List<bnet.protocol.presence.FieldOperation> GetGameAccountListNotification()
262-
{
263-
var operationList = new List<bnet.protocol.presence.FieldOperation>();
264-
265-
foreach (var pair in this.GameAccounts.Values)
266-
{
267-
var gameAccountKey = FieldKeyHelper.Create(FieldKeyHelper.Program.BNet, FieldKeyHelper.OriginatingClass.Account, 4, pair.BnetEntityId.High);
268-
var gameAccountField = bnet.protocol.presence.Field.CreateBuilder().SetKey(gameAccountKey).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetEntityidValue(pair.BnetEntityId).Build()).Build();
269-
operationList.Add(bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(gameAccountField).Build());
270-
}
271-
return operationList;
272-
}
273285
#endregion
274286

275287
public bool VerifyPassword(string password)

0 commit comments

Comments
 (0)
Please sign in to comment.