Full Version : my last De/Serialize Problem is with PlayerMobiles
xmlspawner >>Scripting Support >>my last De/Serialize Problem is with PlayerMobiles
<< Prev | Next >>
TWiG- 10-28-2006
Ok.. I've been working on getting my server upgraded to v2 svn96..
I have got all the scripts merged and a working server.. and have the item saves loading fine.. but I'm down to a playermobile Serial/Deserialization prob loading the mobile saves.
Im not the best coder (I know it, so I dont need to told it ), so I'm sure I overlooked a few things... (its gotta be something stupid)
If anyone was wanting to help with this I would greatly love it... a couple friends are bugging for some of the updates.. my daughter is bugging for others.. and my wife is bugging for even more.. so I have been locked in here for days till I get this figured out. hahahha I banged on the other probs and got em all working before posting here, and just cant get this one to go. hehe
Here is the error I get (if its needed)

CODE
World: Loading...An error was encountered while loading a saved object - Type: Server.Mobiles.PlayerMobile - Serial: 0x0000516A Error: System.Exception: Load failed (items=False, mobiles=True, guilds=False, type=Ser
ver.Mobiles.PlayerMobile, serial=0x0000516A) ---> System.Exception: ***** Bad se
rialize on Server.Mobiles.PlayerMobile *****
at Server.World.Load()
--- End of inner exception stack trace ---
at Server.World.Load()
at Server.ScriptCompiler.Compile(Boolean debug, Boolean cache)
at Server.Core.Main(String[] args)
This exception is fatal, press return to exit

Here is the Deserialize section of my PlayerMobile.cs (all my changes are clearly marked)

CODE
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch ( version )
{
/*Edit*/ case 31:
{
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 );
}
}
/*Edit*/ goto case 30;
}
/*Edit*/ case 30:
{
m_LastHonorLoss = reader.ReadDeltaTime();
/*Edit*/ goto case 29;
}
/*Edit*/ case 29:
{
m_ChampionTitles = new ChampionTitleInfo( reader );
/*Edit*/ goto case 28;
}
/*Edit*/ case 28:
{
m_LastValorLoss = reader.ReadDateTime();
/*Edit*/ goto case 27;
}
/*Edit*/ case 27:
{
m_ToTItemsTurnedIn = reader.ReadEncodedInt();
m_ToTTotalMonsterFame = reader.ReadInt();
/*Edit*/ goto case 26;
}
/*Edit*/ case 26:
{
m_AllianceMessageHue = reader.ReadEncodedInt();
m_GuildMessageHue = reader.ReadEncodedInt();
/*Edit*/ goto case 25;
}
/*Edit*/ case 25:
{
int rank = reader.ReadEncodedInt();
int maxRank = Guilds.RankDefinition.Ranks.Length -1;
if( rank > maxRank )
rank = maxRank;
m_GuildRank = Guilds.RankDefinition.Ranks[rank];
m_LastOnline = reader.ReadDateTime();
/*Edit*/ goto case 24;
}
case 24: /// FOR Tresures of Tokuno -- NOT USED
////////////////////// ADDED FOR Taming Bulk Orders ///////
//
case 23:
{
m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter( reader );
goto case 22;
}
case 22:
{
NextTamingBulkOrder = reader.ReadTimeSpan();
goto case 21;
}
//
///////////////////////// END ADDITION //////////////////////////////
//
////////////////////// ADDED FOR MARRAGE //////////////////////
//
case 21:
{
m_marriedto = reader.ReadString();
m_oldname = reader.ReadString();
m_ismarried = reader.ReadBool();
goto case 20;
}
//
///////////////////////// END ADDITION //////////////////////////////
case 20: /// FOR PLAYER TOWNS --- Not Used Anymore
/*Edit*/ case 19:
{
m_SolenFriendship = (SolenFriendship) reader.ReadEncodedInt();
/*Edit*/ goto case 18;
}
//Start Sickness Edit/////////////////////////////////////////////
//
case 18:
{
m_VampType = (VampType)reader.ReadInt();
m_Vampirism = (bool)reader.ReadBool();
m_VampHunger = (bool)reader.ReadBool();
m_VampBurn = (bool)reader.ReadBool();
m_Blood = reader.ReadInt();
goto case 17;
}
//
//End Sickness Edit//////////////////////////////////////
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:
{
m_BOBFilter = new Engines.BulkOrders.BOBFilter( reader );
goto case 11;
}
case 11:
{
if ( version < 13 )
{
List<Item> 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();
// We cannot call SetHairMods( -1, -1 ) here because the items have not yet loaded
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RevertHair ) );
}
goto case 9;
}
case 9:
{
/**/ if ( version >= 25 )
/**/ {
SavagePaintExpiration = reader.ReadTimeSpan();
/**/ }
/**/ else
/**/ {
/**/ SavagePaintExpiration = TimeSpan.Zero;
/**/ }
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:
{
/**/ if ( version >= 25 )
/**/ {
m_PermaFlags = reader.ReadStrongMobileList();
/**/ }
/**/ else
/**/ {
/**/ m_PermaFlags = null;
/**/ }
goto case 6;
}
case 6:
{
NextTailorBulkOrder = reader.ReadTimeSpan();
goto case 5;
}
case 5:
{
NextSmithBulkOrder = reader.ReadTimeSpan();
goto case 4;
}
case 4:
{
m_LastJusticeLoss = reader.ReadDeltaTime();
/**/ if ( version >= 25 )
/**/ {
m_JusticeProtectors = reader.ReadStrongMobileList();
/**/ }
/**/ else
/**/ {
/**/ m_JusticeProtectors = null;
/**/ }
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:
{
break;
}
}
// 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>();
if ( m_BOBFilter == null )
m_BOBFilter = new Engines.BulkOrders.BOBFilter();
/////////////////////////////////*ADDED*/
if ( m_TamingBOBFilter == null )
m_TamingBOBFilter = new Engines.BulkOrders.TamingBOBFilter();
///////////////////////////////////////////
if( m_GuildRank == null )
m_GuildRank = Guilds.RankDefinition.Member; //Default to member if going from older verstion 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();
List<Mobile> list = this.Stabled;
for ( int i = 0; i < list.Count; ++i )
{
BaseCreature bc = list[i] as BaseCreature;
if ( bc != null )
bc.IsStabled = true;
}
CheckAtrophies( this );
if( Hidden ) //Hiding is the only buff where it has an effect that's serialized.
AddBuff( new BuffInfo( BuffIcon.HidingAndOrStealth, 1075655 ) );
}

Here is the Serialize Section... (my changes are clearly marked)

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.Now )
remove.Add( time );
}
for (int i=0;i<remove.Count;++i)
t.Remove( remove[i] );
}
//decay our kills
if ( m_ShortTermElapse < this.GameTime )
{
m_ShortTermElapse += TimeSpan.FromHours( 8 );
if ( ShortTermMurders > 0 )
--ShortTermMurders;
}
if ( m_LongTermElapse < this.GameTime )
{
m_LongTermElapse += TimeSpan.FromHours( 40 );
if ( Kills > 0 )
--Kills;
}
CheckAtrophies( this );
base.Serialize( writer );
/*EDIT*/ writer.Write( (int) 31 ); // Alt 2 version
if( m_AcquiredRecipes == null )
{
writer.Write( (int)0 );
}
else
{
writer.Write( m_AcquiredRecipes.Count );
foreach( KeyValuePair<int, bool> 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 );
////////////// ADDED BIG LIST //////////////////////////
m_TamingBOBFilter.Serialize( writer );
writer.Write( NextTamingBulkOrder );
////////////////////// ADDED FOR MARRAGE //////////////////////
//
writer.Write( (string) m_marriedto);
writer.Write( (string) m_oldname );
writer.Write( (bool) m_ismarried );
//
//////////////// END ADDITION /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Start Sickness Edit////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
writer.Write( (int)m_VampType );
writer.Write( (bool)m_Vampirism );
writer.Write( (bool)m_VampHunger );
writer.Write( (bool)m_VampBurn );
writer.Write( (int)m_Blood );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End Sickness Edit//////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// ADDED BIG LIST END //////////////////////////
writer.WriteEncodedInt( (int) m_SolenFriendship );
QuestSerializer.Serialize( m_Quest, writer );
if ( m_DoneQuests == null )
{
writer.WriteEncodedInt( (int) 0 );
}
else
{
writer.WriteEncodedInt( (int) m_DoneQuests.Count );
for ( int i = 0; i < m_DoneQuests.Count; ++i )
{
QuestRestartInfo restartInfo = m_DoneQuests[i];
QuestSerializer.Write( (Type) restartInfo.QuestType, QuestSystem.QuestTypes, writer );
writer.Write( (DateTime) restartInfo.RestartTime );
}
}
writer.WriteEncodedInt( (int) m_Profession );
writer.WriteDeltaTime( m_LastCompassionLoss );
writer.WriteEncodedInt( m_CompassionGains );
if ( m_CompassionGains > 0 )
writer.WriteDeltaTime( m_NextCompassionDay );
m_BOBFilter.Serialize( writer );
bool useMods = ( m_HairModID != -1 || m_BeardModID != -1 );
writer.Write( useMods );
if ( useMods )
{
writer.Write( (int) m_HairModID );
writer.Write( (int) m_HairModHue );
writer.Write( (int) m_BeardModID );
writer.Write( (int) m_BeardModHue );
}
writer.Write( SavagePaintExpiration );
writer.Write( (int) m_NpcGuild );
writer.Write( (DateTime) m_NpcGuildJoinTime );
writer.Write( (TimeSpan) m_NpcGuildGameTime );
writer.Write( m_PermaFlags, true );
writer.Write( NextTailorBulkOrder );
writer.Write( NextSmithBulkOrder );
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( this.GameTime );
}

If you need any other info from me to figure it out... let me know..
Thanks in advance..
TWiG- 10-30-2006
maybe just some tips??
*sits back in defeat*
ArteGordon- 10-30-2006
well, I can see one thing. The SolenFriendship ser/deser is in the wrong order.

CODE
case 20: /// FOR PLAYER TOWNS --- Not Used Anymore /*Edit*/ case 19: { m_SolenFriendship = (SolenFriendship) reader.ReadEncodedInt(); /*Edit*/ goto case 18;
}
//Start Sickness Edit/////////////////////////////////////////////
//
case 18:
{
m_VampType = (VampType)reader.ReadInt();
m_Vampirism = (bool)reader.ReadBool();
m_VampHunger = (bool)reader.ReadBool();
m_VampBurn = (bool)reader.ReadBool();
m_Blood = reader.ReadInt();
goto case 17;
}
//
//End Sickness Edit//////////////////////////////////////
case 17: // changed how DoneQuests is serialized
case 16:
{

CODE
// writer.Write( (string) m_marriedto); writer.Write( (string) m_oldname ); writer.Write( (bool) m_ismarried ); //
//////////////// END ADDITION /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Start Sickness Edit////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
writer.Write( (int)m_VampType );
writer.Write( (bool)m_Vampirism );
writer.Write( (bool)m_VampHunger );
writer.Write( (bool)m_VampBurn );
writer.Write( (int)m_Blood );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End Sickness Edit//////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// ADDED BIG LIST END //////////////////////////
writer.WriteEncodedInt( (int) m_SolenFriendship );
QuestSerializer.Serialize( m_Quest, writer );

you write it after the vamp stuff, but read it before.
TWiG- 11-02-2006
I knew I would miss something that seems simple to everyone else.. hehehe
Kick Arse!! Thanks to that help and something I read elsewhere.. and thanks to your posting compiled svn executables.. I have my server fully updated and running great!! Thanks again!!