Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 10-21-2008, 05:38 PM   #26 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

Quote:
Originally Posted by Soteric View Post
Do you serialize version as 26?
Yeap! 26!

Code:
...
public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			switch ( version )
			{
				case 26:				
				{
					m_Race = (RaceType) reader.ReadInt();					
					goto case 25;
				}				
				case 25:
				{
					int recipeCount = reader.ReadInt();

					if( recipeCount > 0 )
...
 The rest is default. :)
CB0T is offline   Reply With Quote
Old 10-21-2008, 05:58 PM   #27 (permalink)
Forum Expert
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 1,673
Send a message via ICQ to Soteric
Default

This is deserializing. You need Serialize method:
Code:
base.Serialize( writer );

writer.Write( (int) 26 ); // version
Soteric is offline   Reply With Quote
Old 10-22-2008, 01:03 AM   #28 (permalink)
Forum Novice
 
Join Date: Sep 2002
Posts: 114
Default

He has a serialize, stated in the original post. Could you post a few additional lines of your serialize method?

Code:
base.Serialize( writer );

writer.Write( (int) 26 ); // version

writer.Write( (int) m_Race );

...
Should look something like that.
LuxoR is offline   Reply With Quote
Old 10-22-2008, 09:06 AM   #29 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

Look:

Code:
CheckAtrophies( this );

			base.Serialize( writer );
			
			writer.Write( (int) 25 ); // version

                        writer.Write( (int) m_Race );

			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 );
The error is in RED, right?

Last edited by CB0T; 10-22-2008 at 09:29 AM.
CB0T is offline   Reply With Quote
Old 10-22-2008, 09:11 AM   #30 (permalink)
Forum Expert
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 1,673
Send a message via ICQ to Soteric
Default

Right, it should look like in Luxor's post
Soteric is offline   Reply With Quote
Old 10-22-2008, 09:31 AM   #31 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

WOOOOOOOOOOOOOOOOOORKS!

THANK YOU very much Soteric/Alf!

THANK YOU very much LuxoR!

CB0T is offline   Reply With Quote
Old 10-23-2008, 06:40 AM   #32 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

O Myyy.

Now i need some help to serialize and deserialize BaseCreature.cs


Code:
private RaceType m_Race; 
		[CommandProperty(AccessLevel.GameMaster)]
        public RaceType RaceType
        {
            get { return (m_Race); }
            set { m_Race = (RaceType)value; }
        }
Code:
public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 17 ); // version 16 to 17 here

			writer.Write( (int) m_Race );
Code:
public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			m_Race = (RaceType) reader.ReadInt();					
			
			m_CurrentAI = (AIType)reader.ReadInt();
			m_DefaultAI = (AIType)reader.ReadInt();
Thanks!
CB0T is offline   Reply With Quote
Old 10-23-2008, 06:49 AM   #33 (permalink)
Forum Expert
 
Soteric's Avatar
 
Join Date: Aug 2006
Location: Russia, Rostov-on-Don
Posts: 1,673
Send a message via ICQ to Soteric
Default

Add m_Race serialization to the end of the Serialize() method, not after version

In Deserialize() go to the last version checking, add new checking after it and place m_Race deserialization there
Soteric is offline   Reply With Quote
Old 10-23-2008, 07:07 AM   #34 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

Hard Work.

Code:
public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 17 ); // version

(...)

                        // Version 14
			writer.Write( (bool)m_RemoveIfUntamed );
			writer.Write( (int)m_RemoveStep );
			
			// Version 17???
			writer.Write( (int) m_Race );
		}
Code:
public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

(...)

                        if ( version >= 16 ) // <16
				Loyalty *= 10;

			if (version < 17 )
				m_Race = (RaceType) reader.ReadInt();									
				
			double activeSpeed = m_dActiveSpeed;
			double passiveSpeed = m_dPassiveSpeed;
Quote:
World: Loading...An error was encountered while loading a saved object
- Type: Server.Mobiles.Vagabond
- Serial: 0x00003CE7
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, type=Ser
ver.Mobiles.Vagabond, serial=0x00003CE7) ---> System.Exception: ***** Bad serial
ize on Server.Mobiles.Vagabond *****
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
CB0T is offline   Reply With Quote
Old 10-23-2008, 07:46 AM   #35 (permalink)
Newbie
 
Join Date: May 2004
Posts: 45
Default

Code:
if (version >= 17 )
				m_Race = (RaceType) reader.ReadInt();

Code:
// Version 14
			writer.Write( (bool)m_RemoveIfUntamed );
			writer.Write( (int)m_RemoveStep );
			
			// Version 17???
			writer.Write( (int) m_Race );
WORKS!

Thanks Again Alf.

You are the boss.

Last edited by CB0T; 10-23-2008 at 08:08 AM.
CB0T is offline   Reply With Quote
Old 10-23-2008, 12:32 PM   #36 (permalink)
Forum Novice
 
Join Date: Sep 2002
Posts: 114
Default

That doesn't make much sense...

Code:
public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 17 ); // version

			writer.Write( (int) m_Race );

                        // Version 14
			writer.Write( (bool)m_RemoveIfUntamed );
			writer.Write( (int)m_RemoveStep );
		}
Your serialize was fine. You want to save updates at the top, that way you can version control when you load up. The error is in your Deserialize, you are not using proper version control (ie: loading version 16 BaseCreatures as version 17.

Code:
public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			if (version > 16 )
				m_Race = (RaceType) reader.ReadInt();

(...)

                        if ( version >= 16 ) // <16
				Loyalty *= 10;

			double activeSpeed = m_dActiveSpeed;
			double passiveSpeed = m_dPassiveSpeed;

I suspect that there should be a switch statement in BaseCreature deserialize, why did you not just add to that?
LuxoR is offline   Reply With Quote
Old 10-23-2008, 02:07 PM   #37 (permalink)
Forum Novice
 
Join Date: Jan 2006
Posts: 397
Default

Quote:
Originally Posted by LuxoR View Post
I suspect that there should be a switch statement in BaseCreature deserialize, why did you not just add to that?
I suspect that you haven't looked at the deserialization portion of BaseCreature.cs. It does NOT have a switch statement in it.
razzles is offline   Reply With Quote
Old 10-23-2008, 05:01 PM   #38 (permalink)
Forum Novice
 
Join Date: Sep 2002
Posts: 114
Default

Quote:
Originally Posted by razzles View Post
I suspect that you haven't looked at the deserialization portion of BaseCreature.cs. It does NOT have a switch statement in it.
Clearly, the fact that I said *should be* would be indication. Suspect is also the primary word, meaning it's not 100% certain, it's a guess, a logical one based on the fact that just about everything else in the core follows that method of version control.

It's not like I said "There is a switch statement in BaseCreature. Just change that."
LuxoR is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5