clark71822
Member
I thought I had the Serialize/Deserialize methods fixed, but I guess not. Here's the error it throws:
Here is my Serialize method:
and my Deserialize method:
Is there something I'm missing?
Code:
World: Loading...An error was encountered while loading a saved object
- Type: Server.Mobiles.PlayerMobile
- Serial: 0x0001A905
Delete the object? (y/n)
After pressing return an exception will be thrown and the server will terminate.
Error:
System.Exception: Load failed (items=False, mobiles=True, guilds=False, data=False, type=Server.Mobiles.PlayerMobile, serial=0x0001A905) ---> System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
at System.DateTime..ctor(Int64 ticks)
at Server.BinaryFileReader.ReadDateTime() in c:\ER-Redux-Server\Server\Serialization.cs:line 1322
at Server.Mobiles.PlayerMobile.Deserialize(GenericReader reader) in c:\ER-Redux-Server\Scripts\Mobiles\PlayerMobile.cs:line 4362
at Server.World.Load() in c:\ER-Redux-Server\Server\World.cs:line 597
--- End of inner exception stack trace ---
at Server.World.Load() in c:\ER-Redux-Server\Server\World.cs:line 864
at Server.Core.Main(String[] args) in c:\ER-Redux-Server\Server\Main.cs:line 556
This exception is fatal, press return to exit
Here is my Serialize method:
Code:
public override void Serialize(GenericWriter writer)
{
//cleanup our anti-macro table
foreach (Hashtable t in m_AntiMacroTable.Values)
{
ArrayList remove = new ArrayList();
foreach (CountAndTimeStamp time in t.Values)
{
if (time.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow)
{
remove.Add(time);
}
}
for (int i = 0; i < remove.Count; ++i)
{
t.Remove(remove[i]);
}
}
CheckKillDecay();
CheckAtrophies(this);
base.Serialize(writer);
writer.Write(36); // version
writer.Write(RewardStableSlots);
writer.Write(_BlessedItem);
writer.Write((int)m_ExploringTheDeepQuest);
// Version 35 FS:ATS
m_TamingBOBFilter.Serialize( writer );
// Version 34 FS:ATS
writer.Write( m_Bioenginer );
writer.Write( NextTamingBulkOrder );
// Version 31/32 Titles
writer.Write(m_ShowGuildAbbreviation);
writer.Write(m_FameKarmaTitle);
writer.Write(m_PaperdollSkillTitle);
writer.Write(m_OverheadTitle);
writer.Write(m_SubtitleSkillTitle);
writer.Write(m_CurrentChampTitle);
writer.Write(m_CurrentVeteranTitle);
// Version 30 open to take out old Queens Loyalty Info
// Version 29
writer.Write(m_GauntletPoints);
#region Plant System
writer.Write(m_SSNextSeed);
writer.Write(m_SSSeedExpire);
writer.Write(m_SSSeedLocation);
writer.Write(m_SSSeedMap);
#endregion
writer.Write(m_VASTotalMonsterFame);
#region Mondain's Legacy
QuestWriter.Quests(writer, m_Quests);
QuestWriter.Chains(writer, m_Chains);
if (m_Collections == null)
{
writer.Write(0);
}
else
{
writer.Write(m_Collections.Count);
foreach (var pair in m_Collections)
{
writer.Write((int)pair.Key);
writer.Write(pair.Value);
}
}
if (m_RewardTitles == null)
{
writer.Write(0);
}
else
{
writer.Write(m_RewardTitles.Count);
for (int i = 0; i < m_RewardTitles.Count; i++)
{
QuestWriter.Object(writer, m_RewardTitles[i]);
}
}
writer.Write(m_SelectedTitle);
#endregion
// Version 28
writer.Write(m_PeacedUntil);
writer.Write(m_AnkhNextUse);
writer.Write(m_AutoStabled, true);
if (m_AcquiredRecipes == null)
{
writer.Write(0);
}
else
{
writer.Write(m_AcquiredRecipes.Count);
foreach (var kvp in m_AcquiredRecipes)
{
writer.Write(kvp.Key);
writer.Write(kvp.Value);
}
}
writer.WriteDeltaTime(m_LastHonorLoss);
ChampionTitleInfo.Serialize(writer, m_ChampionTitles);
writer.Write(m_LastValorLoss);
writer.WriteEncodedInt(m_ToTItemsTurnedIn);
writer.Write(m_ToTTotalMonsterFame); //This ain't going to be a small #.
writer.WriteEncodedInt(m_AllianceMessageHue);
writer.WriteEncodedInt(m_GuildMessageHue);
writer.WriteEncodedInt(m_GuildRank.Rank);
writer.Write(m_LastOnline);
writer.WriteEncodedInt((int)m_SolenFriendship);
QuestSerializer.Serialize(m_Quest, writer);
if (m_DoneQuests == null)
{
writer.WriteEncodedInt(0);
}
else
{
writer.WriteEncodedInt(m_DoneQuests.Count);
for (int i = 0; i < m_DoneQuests.Count; ++i)
{
QuestRestartInfo restartInfo = m_DoneQuests[i];
QuestSerializer.Write(restartInfo.QuestType, QuestSystem.QuestTypes, writer);
writer.Write(restartInfo.RestartTime);
}
}
writer.WriteEncodedInt(m_Profession);
writer.WriteDeltaTime(m_LastCompassionLoss);
writer.WriteEncodedInt(m_CompassionGains);
if (m_CompassionGains > 0)
{
writer.WriteDeltaTime(m_NextCompassionDay);
}
bool useMods = (m_HairModID != -1 || m_BeardModID != -1);
writer.Write(useMods);
if (useMods)
{
writer.Write(m_HairModID);
writer.Write(m_HairModHue);
writer.Write(m_BeardModID);
writer.Write(m_BeardModHue);
}
writer.Write(SavagePaintExpiration);
writer.Write((int)m_NpcGuild);
writer.Write(m_NpcGuildJoinTime);
writer.Write(m_NpcGuildGameTime);
writer.Write(m_PermaFlags, true);
writer.WriteDeltaTime(m_LastJusticeLoss);
writer.Write(m_JusticeProtectors, true);
writer.WriteDeltaTime(m_LastSacrificeGain);
writer.WriteDeltaTime(m_LastSacrificeLoss);
writer.Write(m_AvailableResurrects);
writer.Write((int)m_Flags);
writer.Write(m_LongTermElapse);
writer.Write(m_ShortTermElapse);
writer.Write(GameTime);
}
and my Deserialize method:
Code:
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 36: // Reward Stable Slots
RewardStableSlots = reader.ReadInt();
_BlessedItem = reader.ReadItem();
m_ExploringTheDeepQuest = (ExploringTheDeepQuestChain)reader.ReadInt();
goto case 35;
case 35: // Siege Blessed Item
{
m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter( reader );
goto case 34;
}
// Version 34 - new BOD System
case 34:
{
m_Bioenginer = reader.ReadBool();
NextTamingBulkOrder = reader.ReadTimeSpan();
goto case 33;
}
case 33:
{
goto case 31;
}
case 32:
case 31:
{
m_ShowGuildAbbreviation = version > 31 ? reader.ReadBool() : false;
m_FameKarmaTitle = reader.ReadString();
m_PaperdollSkillTitle = reader.ReadString();
m_OverheadTitle = reader.ReadString();
m_SubtitleSkillTitle = reader.ReadString();
m_CurrentChampTitle = reader.ReadString();
m_CurrentVeteranTitle = reader.ReadInt();
goto case 30;
}
case 30: goto case 29;
case 29:
{
m_GauntletPoints = reader.ReadDouble();
m_SSNextSeed = reader.ReadDateTime();
m_SSSeedExpire = reader.ReadDateTime();
m_SSSeedLocation = reader.ReadPoint3D();
m_SSSeedMap = reader.ReadMap();
if (version < 30)
{
reader.ReadLong(); // Old m_LevelExp
int points = (int)reader.ReadLong();
if (points > 0)
{
Server.Engines.Points.PointsSystem.QueensLoyalty.ConvertFromOldSystem(this, points);
}
reader.ReadInt(); // Old m_Level
reader.ReadString(); // Old m_ExpTitle
}
m_VASTotalMonsterFame = reader.ReadInt();
m_Quests = QuestReader.Quests(reader, this);
m_Chains = QuestReader.Chains(reader);
m_Collections = new Dictionary<Collection, int>();
m_RewardTitles = new List<object>();
for (int i = reader.ReadInt(); i > 0; i--)
{
m_Collections.Add((Collection)reader.ReadInt(), reader.ReadInt());
}
for (int i = reader.ReadInt(); i > 0; i--)
{
m_RewardTitles.Add(QuestReader.Object(reader));
}
m_SelectedTitle = reader.ReadInt();
goto case 28;
}
case 28:
{
m_PeacedUntil = reader.ReadDateTime();
goto case 27;
}
case 27:
{
m_AnkhNextUse = reader.ReadDateTime();
goto case 26;
}
case 26:
{
m_AutoStabled = reader.ReadStrongMobileList();
goto case 25;
}
case 25:
{
int recipeCount = reader.ReadInt();
if (recipeCount > 0)
{
m_AcquiredRecipes = new Dictionary<int, bool>();
for (int i = 0; i < recipeCount; i++)
{
int r = reader.ReadInt();
if (reader.ReadBool()) //Don't add in recipies which we haven't gotten or have been removed
{
m_AcquiredRecipes.Add(r, true);
}
}
}
goto case 24;
}
case 24:
{
m_LastHonorLoss = reader.ReadDeltaTime();
goto case 23;
}
case 23:
{
m_ChampionTitles = new ChampionTitleInfo(reader);
goto case 22;
}
case 22:
{
m_LastValorLoss = reader.ReadDateTime();
goto case 21;
}
case 21:
{
m_ToTItemsTurnedIn = reader.ReadEncodedInt();
m_ToTTotalMonsterFame = reader.ReadInt();
goto case 20;
}
case 20:
{
m_AllianceMessageHue = reader.ReadEncodedInt();
m_GuildMessageHue = reader.ReadEncodedInt();
goto case 19;
}
case 19:
{
int rank = reader.ReadEncodedInt();
int maxRank = RankDefinition.Ranks.Length - 1;
if (rank > maxRank)
{
rank = maxRank;
}
m_GuildRank = RankDefinition.Ranks[rank];
m_LastOnline = reader.ReadDateTime();
goto case 18;
}
case 18:
{
m_SolenFriendship = (SolenFriendship)reader.ReadEncodedInt();
goto case 17;
}
case 17: // changed how DoneQuests is serialized
case 16:
{
m_Quest = QuestSerializer.DeserializeQuest(reader);
if (m_Quest != null)
{
m_Quest.From = this;
}
int count = reader.ReadEncodedInt();
if (count > 0)
{
m_DoneQuests = new List<QuestRestartInfo>();
for (int i = 0; i < count; ++i)
{
Type questType = QuestSerializer.ReadType(QuestSystem.QuestTypes, reader);
DateTime restartTime;
if (version < 17)
{
restartTime = DateTime.MaxValue;
}
else
{
restartTime = reader.ReadDateTime();
}
m_DoneQuests.Add(new QuestRestartInfo(questType, restartTime));
}
}
m_Profession = reader.ReadEncodedInt();
goto case 15;
}
case 15:
{
m_LastCompassionLoss = reader.ReadDeltaTime();
goto case 14;
}
case 14:
{
m_CompassionGains = reader.ReadEncodedInt();
if (m_CompassionGains > 0)
{
m_NextCompassionDay = reader.ReadDeltaTime();
}
goto case 13;
}
case 13: // just removed m_PayedInsurance list
case 12:
{
if(version < 34)
BulkOrderSystem.SetBOBFilter(this, new BOBFilter(reader));
goto case 11;
}
case 11:
{
if (version < 13)
{
var payed = reader.ReadStrongItemList();
for (int i = 0; i < payed.Count; ++i)
{
payed[i].PayedInsurance = true;
}
}
goto case 10;
}
case 10:
{
if (reader.ReadBool())
{
m_HairModID = reader.ReadInt();
m_HairModHue = reader.ReadInt();
m_BeardModID = reader.ReadInt();
m_BeardModHue = reader.ReadInt();
}
goto case 9;
}
case 9:
{
SavagePaintExpiration = reader.ReadTimeSpan();
if (SavagePaintExpiration > TimeSpan.Zero)
{
BodyMod = (Female ? 184 : 183);
HueMod = 0;
}
goto case 8;
}
case 8:
{
m_NpcGuild = (NpcGuild)reader.ReadInt();
m_NpcGuildJoinTime = reader.ReadDateTime();
m_NpcGuildGameTime = reader.ReadTimeSpan();
goto case 7;
}
case 7:
{
m_PermaFlags = reader.ReadStrongMobileList();
goto case 6;
}
case 6:
{
if(version < 34)
reader.ReadTimeSpan();
goto case 5;
}
case 5:
{
if(version < 34)
reader.ReadTimeSpan();
goto case 4;
}
case 4:
{
m_LastJusticeLoss = reader.ReadDeltaTime();
m_JusticeProtectors = reader.ReadStrongMobileList();
goto case 3;
}
case 3:
{
m_LastSacrificeGain = reader.ReadDeltaTime();
m_LastSacrificeLoss = reader.ReadDeltaTime();
m_AvailableResurrects = reader.ReadInt();
goto case 2;
}
case 2:
{
m_Flags = (PlayerFlag)reader.ReadInt();
goto case 1;
}
case 1:
{
m_LongTermElapse = reader.ReadTimeSpan();
m_ShortTermElapse = reader.ReadTimeSpan();
m_GameTime = reader.ReadTimeSpan();
goto case 0;
}
case 0:
{
if (version < 26)
{
m_AutoStabled = new List<Mobile>();
}
break;
}
}
if (version < 29)
{
m_SSNextSeed = m_SSSeedExpire = DateTime.UtcNow;
m_SSSeedLocation = Point3D.Zero;
}
if (m_RecentlyReported == null)
{
m_RecentlyReported = new List<Mobile>();
}
#region Mondain's Legacy
if (m_Quests == null)
{
m_Quests = new List<BaseQuest>();
}
if (m_Chains == null)
{
m_Chains = new Dictionary<QuestChain, BaseChain>();
}
if (m_DoneQuests == null)
{
m_DoneQuests = new List<QuestRestartInfo>();
}
if (m_Collections == null)
{
m_Collections = new Dictionary<Collection, int>();
}
if (m_RewardTitles == null)
{
m_RewardTitles = new List<object>();
}
#endregion
// Professions weren't verified on 1.0 RC0
if (!CharacterCreation.VerifyProfession(m_Profession))
{
m_Profession = 0;
}
if (m_PermaFlags == null)
{
m_PermaFlags = new List<Mobile>();
}
if (m_JusticeProtectors == null)
{
m_JusticeProtectors = new List<Mobile>();
}
#region FS:ATS Edits
if ( m_TamingBOBFilter == null )
{
m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter();
}
#endregion
if (m_GuildRank == null)
{
m_GuildRank = RankDefinition.Member;
//Default to member if going from older version to new version (only time it should be null)
}
if (m_LastOnline == DateTime.MinValue && Account != null)
{
m_LastOnline = ((Account)Account).LastLogin;
}
if (m_ChampionTitles == null)
{
m_ChampionTitles = new ChampionTitleInfo();
}
var list = Stabled;
for (int i = 0; i < list.Count; ++i)
{
BaseCreature bc = list[i] as BaseCreature;
if (bc != null)
{
bc.IsStabled = true;
bc.StabledBy = this;
}
}
CheckAtrophies(this);
if (Hidden) //Hiding is the only buff where it has an effect that's serialized.
{
AddBuff(new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655));
}
}
Is there something I'm missing?