Go Back   RunUO - Ultima Online Emulation > RunUO > Modification Suggestions

Modification Suggestions This is where you can suggest a modifcation to RunUO!

Reply
 
Thread Tools Display Modes
Old 01-25-2006, 12:09 AM   #1 (permalink)
Forum Master
 
Joeku's Avatar
 
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
Default Base classes...

Okay, this is really starting to tick me off. Any time I have a great idea that would require a modification to all classes (either item or mobile), I have to ditch it because it would require a core modification. I think it would be nice to have "empty" classes; so:

-BaseItem is in the core
-Item (containing no functions, just a blank class) which is a sub-class of BaseItem, is in the regular scripts
-Everything branches off of Item

That way, if I want to add a property to all items, it doesn't require a core modification. The same thing goes for mobiles. This would make things easier to add stuff to everything in a class.

Comments please.
Joeku is offline   Reply With Quote
Old 01-25-2006, 12:45 AM   #2 (permalink)
Forum Expert
 
Courageous's Avatar
 
Join Date: Nov 2005
Location: San Diego, CA
Posts: 1,825
Default

That's a fine idea.

C//
Courageous is offline   Reply With Quote
Old 01-25-2006, 02:26 AM   #3 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

yah i had done that at one point but eventually went away from it (mostly cause i was too lazy to go back through and change all Mobile references to BaseMobile and all Item references to BaseItem. It was usefull the first time i added the personal bless deed to my shard. also when i was adding my global level system that I wanted to affect players and creatures alike. but anywho, it's doable but i dont ever see it happening officially.
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 01-25-2006, 02:45 AM   #4 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

The only problem with this is making it backward compatible for shards with items already in existence.

How would you handle converting these items?
TheOutkastDev is offline   Reply With Quote
Old 01-25-2006, 02:58 AM   #5 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

Quote:
Originally Posted by TheOutkastDev
The only problem with this is making it backward compatible for shards with items already in existence.

How would you handle converting these items?
heh to my knowledge you couldn't I ended up wiping my Entire shard the first time I did it (Including my playermobiles, which pissed off my players to no end), but I gave em some extra pscrolls and boosted their stats and some of there base "profession" skills to a little higher and they stopped whining, but from that point i had a warning popup when they logged one. But you are entirely right and that is one of the other reasones why I tossed the base stuff out.
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 01-25-2006, 06:42 AM   #6 (permalink)
Ray
Forum Novice
 
Join Date: Jul 2004
Location: Switzerland
Age: 25
Posts: 234
Default

Quote:
Originally Posted by TheOutkastDev
The only problem with this is making it backward compatible for shards with items already in existence.

How would you handle converting these items?
They do not need to be converted in any complex manner. In a very short-mulled way: All that is needed to change is the deserialize function of this class, by adding a one time job to it. And the core, of course.


Code:
public override void Deserialize( GenericReader reader )
{
	base.Deserialize( reader );
	if(OldVersion) // only to call if the save has items with 'my' data
	{
		int version = reader.ReadInt();
	}
}
else, the reader would make no reading at this point, thus the filepointer (in a binary save) stays at the current position, allowing the subclass to continue.

That works for all inherited classes.
Now the core code; core-Item is a directly constructable class, thus, the mentioned subclass would be surpassable. This could be avoided by making the item class non-constructable and abstract. Of course with a rename to BaseItem and all references to it withing the core, otherwise most bundled scripts with a new Item() call would stop working. If the core containes a new-call to this abstract class, it would stop to work as well.
That would be all, i think. Correct me if not

Now what can 'OldVersion' be...
a simple bool for the scripter who needs the convert?
a startup-parameter?
a configure variable?
an automatic value fetched out of the save-format?


Comments...
This would make many things easier, especially own functionality. But i dont see a real need to do that.
The above mentioned way inflicts a lot more than only the things listed. Once the Item class gets abstract, the next step would logically be to make as much functions as possible virtual or abstact too. That would raise expenses in safety, maintainability, and speed.
Oh, forgot, i'm an optimist
Ray is offline   Reply With Quote
Old 01-25-2006, 02:01 PM   #7 (permalink)
 
Join Date: Oct 2002
Age: 23
Posts: 4,689
Default

If you want an empty class, you would want empty methods... such as

Code:
public override void Deserialize( GenericReader reader )
{
     base.Deserialize( reader );
}
XxSP1DERxX is offline   Reply With Quote
Old 01-25-2006, 02:07 PM   #8 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 28
Posts: 4,892
Default

Ah interesting topic, I would like to see a good answer to this
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 01-25-2006, 04:12 PM   #9 (permalink)
Forum Master
 
Joeku's Avatar
 
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
Default

Code:
using System;
using Server;

namespace Server.Items
{
	public class Item : BaseItem
	{
		public Item( Serial serial ) : base( serial )
		{
		}

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

			writer.Write( (int) 0 ); // version
		}

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

			int version = reader.ReadInt();
		}
	}
}
That's what I meant by a "blank class." If there really is a way to convert all existing items to the Item subclass of BaseItem, that would be really great. Either that or you could put a global control script in "Scripts/Misc" on whether or not to use the BaseItem/Item instead of just Item...

Again, this isn't really an issue of need, but rather an issue of want; it would be a lot easier to make global modifications to the item and mobile classes if this "method" was instituted, and I'm sure more people would be encouraged to make a wider variety of scripts.
Joeku is offline   Reply With Quote
Old 01-25-2006, 06:43 PM   #10 (permalink)
xir
Forum Newbie
 
Join Date: Jul 2004
Posts: 59
Default

Doesn't C# let you define custom attributes that allow you to seperate crosscutting concerns i.e. Serialisation?
xir is offline   Reply With Quote
Old 01-27-2006, 02:25 PM   #11 (permalink)
 
Join Date: Oct 2002
Age: 23
Posts: 4,689
Default

And Joeku, I just said that you can do that (with no problems), if you do
Code:
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
		}
Then once you have loaded it up and what not... if you wanted to add stuff to the serialization, you can version it in later just as you normally would.
XxSP1DERxX is offline   Reply With Quote
Old 01-27-2006, 06:09 PM   #12 (permalink)
RunUO Developer/Demise Person
 
ASayre's Avatar
 
Join Date: Mar 2003
Location: California
Age: 20
Posts: 1,700
Default

http://blogs.tedneward.com/2005/09/2...Explained.aspx

"Extension Methods"
__________________
Andre Sayre, Core Developer
The RunUO Software Team

The day we are born is the day Death inches ever closer...
E-mail: ASayre ( AT ) RunUO ( Dot ) c o m
I'm as graceful as a gazelle galloping over glistening green grass with it's head on fire.
ASayre is offline   Reply With Quote
Old 01-27-2006, 07:44 PM   #13 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

C# 3.0 is a ways away from release.
TheOutkastDev is offline   Reply With Quote
Old 01-27-2006, 08:33 PM   #14 (permalink)
xir
Forum Newbie
 
Join Date: Jul 2004
Posts: 59
Default

Quote:
Originally Posted by ASayre8
If seperation of concerns isn't done at the requirements/design phase it is very difficult and tedious to disentangle the functionality from the rest of the system. (Of course it can be done with refactoring techniques.) Crosscutting concerns that are not handled properly are noticed by code scattering and tangling of a feature or service across multiple units of modularity. Dependancy and tightly coupled interfaces/classes as a result of improperly handled crosscutting concerns reduce adaptability and resuability (on which the whole ideas of OO are based). Is serialisation a crosscutting concern in RunUO? If the functionality of the serialisation service is scattered across multiple classes then perhaps it is.
These "Extension Methods" provide a very very limited AOP type feature to deal with these concerns. There are a couple of Aspect Weavers that I am aware of that allow one to deal with this issue elegantly using the AOP constructs/extensions to the C# language.
My previous question on whether custom attributes can provide a limited solution to this problem still stands, and would be interested to know how it works.

Last edited by xir; 01-27-2006 at 08:38 PM.
xir is offline   Reply With Quote
Old 01-27-2006, 11:55 PM   #15 (permalink)
Forum Expert
 
TheOutkastDev's Avatar
 
Join Date: Sep 2002
Location: Houston, Texas
Age: 22
Posts: 3,933
Default

Quote:
Originally Posted by XxSP1DERxX
And Joeku, I just said that you can do that (with no problems), if you do
Code:
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
		}
Then once you have loaded it up and what not... if you wanted to add stuff to the serialization, you can version it in later just as you normally would.
You're still required to run the server once with the serialization code ONLY, then reboot the server with the deserialization code. How many people would you like to wager will screw this up?
TheOutkastDev 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 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5