Skip to content

Commit cbf3d11

Browse files
committed
Implement ISerialize for Player entity
1 parent 3dc02bf commit cbf3d11

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

src/MHServerEmu.Games/Entities/Player.cs

+56-1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,59 @@ public Player(EntityBaseData baseData, ByteString archiveData) : base(baseData,
132132
_gameplayOptions.SetOwner(this);
133133
}
134134

135+
public override bool Serialize(Archive archive)
136+
{
137+
bool success = base.Serialize(archive);
138+
139+
success &= Serializer.Transfer(archive, ref _missionManager);
140+
success &= Serializer.Transfer(archive, ref _avatarProperties);
141+
142+
// archive.IsTransient
143+
success &= Serializer.Transfer(archive, ref _shardId);
144+
success &= Serializer.Transfer(archive, ref _playerName);
145+
success &= Serializer.Transfer(archive, ref _consoleAccountIds[0]);
146+
success &= Serializer.Transfer(archive, ref _consoleAccountIds[1]);
147+
success &= Serializer.Transfer(archive, ref _secondaryPlayerName);
148+
success &= Serializer.Transfer(archive, ref _matchQueueStatus);
149+
success &= Serializer.Transfer(archive, ref _emailVerified);
150+
success &= Serializer.Transfer(archive, ref _accountCreationTimestamp);
151+
152+
// archive.IsReplication
153+
success &= Serializer.Transfer(archive, ref _partyId);
154+
success &= GuildMember.SerializeReplicationRuntimeInfo(archive, ref _guildId, ref _guildName, ref _guildMembership);
155+
156+
// There is a string here that is always empty and is immediately discarded after reading, purpose unknown
157+
string emptyString = string.Empty;
158+
success &= Serializer.Transfer(archive, ref emptyString);
159+
if (emptyString != string.Empty) Logger.Warn($"Serialize(): emptyString is not empty!");
160+
161+
//bool hasCommunityData = archive.IsPersistent || archive.IsMigration
162+
// || (archive.IsReplication && ((AOINetworkPolicyValues)archive.ReplicationPolicy).HasFlag(AOINetworkPolicyValues.AOIChannelOwner));
163+
bool hasCommunityData = true;
164+
success &= Serializer.Transfer(archive, ref hasCommunityData);
165+
if (hasCommunityData)
166+
success &= Serializer.Transfer(archive, ref _community);
167+
168+
// Unknown bool, always false
169+
bool unkBool = false;
170+
success &= Serializer.Transfer(archive, ref unkBool);
171+
if (unkBool) Logger.Warn($"Serialize(): unkBool is true!");
172+
173+
success &= Serializer.Transfer(archive, ref _unlockedInventoryList);
174+
175+
//if (archive.IsMigration || (archive.IsReplication && ((AOINetworkPolicyValues)archive.ReplicationPolicy).HasFlag(AOINetworkPolicyValues.AOIChannelOwner)))
176+
success &= Serializer.Transfer(archive, ref _badges);
177+
178+
success &= Serializer.Transfer(archive, ref _gameplayOptions);
179+
180+
//if (archive.IsMigration || (archive.IsReplication && ((AOINetworkPolicyValues)archive.ReplicationPolicy).HasFlag(AOINetworkPolicyValues.AOIChannelOwner)))
181+
success &= Serializer.Transfer(archive, ref _achievementState);
182+
183+
success &= Serializer.Transfer(archive, ref _stashTabOptionsDict);
184+
185+
return success;
186+
}
187+
135188
protected override void Decode(CodedInputStream stream)
136189
{
137190
base.Decode(stream);
@@ -189,7 +242,9 @@ protected override void Decode(CodedInputStream stream)
189242
for (ulong i = 0; i < numStashTabOptions; i++)
190243
{
191244
PrototypeId stashTabRef = stream.ReadPrototypeRef<Prototype>();
192-
_stashTabOptionsDict.Add(stashTabRef, new(stream));
245+
StashTabOptions options = new();
246+
options.Decode(stream);
247+
_stashTabOptionsDict.Add(stashTabRef, options);
193248
}
194249
}
195250

0 commit comments

Comments
 (0)