Go Back   RunUO - Ultima Online Emulation > RunUO > Core Modifications > Other

Other Cant find a category above, use this one! Core mods not listed above go here!

Reply
 
Thread Tools Display Modes
Old 07-29-2006, 06:00 AM   #1 (permalink)
Forum Expert
 
Join Date: Nov 2004
Location: Southeast Missouri USA
Age: 34
Posts: 283
Default [2.0] Workbench Scripts.WB.dll for faster compile times.

I recently started a thread in Modification Suggestions about an idea i had for reducing the amount of time it takes the server to compile.
You can find this thread at:
A suggestion regarding the disparity of cache-nocache compile times

This is mostly aimed at people like me that restart the server very, very often and get annoyed that the server has to recompile every script, not just the script i changed.

Quote:
RunUO - [www.runuo.com] Version 2.0, Build 2401.3936
Core: Running on .NET Framework Version 2.0.50727
Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.NET scripts...no files found.
Scripts: Compiling Workbench C# scripts...no files found.
Scripts: Verifying...done (2086 items, 497 mobiles)
Quote:

RunUO - [www.runuo.com] Version 2.0, Build 2401.3936
Core: Running on .NET Framework Version 2.0.50727
Scripts: Compiling C# scripts...done (cached)
Scripts: Compiling VB.NET scripts...no files found.
Scripts: Compiling Workbench C# scripts...done (0 errors, 0 warnings)
Scripts: Verifying...done (2087 items, 497 mobiles)
To do this, i made two additions to ScriptCompiler.cs (SVN version 66).
You can find my additions in the attached file as:
Code:
#region Workbench Mod 1 of 2
and
Code:
#region Workbench Mod 2 of 2
The original idea was for a new folder that compiles like the \Scripts folder does and created a separate assembly, but....

After looking at the code in ScriptCompiler.cs closely, i realized that it would be much simpiler to add in a new file extention and have it generate an assembly for the new extention like it already does for vb and cs files.

Note: This mod is for c# code only.
I don't use visual basic, so i didn't include a vb compiler version...

If you don't know how to compile a new Server.exe, check out Penndragon's faq here:
Easy how to compile new server......

Once you have the Server.exe built with the ScriptCompiler.cs i include here, using the mod works like this:
1.
Any c# script file that ends in .wb (short for Workbench) will be compiled into a Scripts.WB.dll
This allows you to edit your .wb files as often as you like and not have to re-compile the .cs scripts each time.
If you only change a .wb file, the server will only compile the .wb and will load the .cs cache.
3.
After you are done, just rename your script file back to .cs!
( If you use this mod, Please, please rename files back to .cs. I can hear the questions about .wb files now... )

Test server version of RunUO 2.0 anyone?


Edit:
Currently, if a script contains a class or method that is required to exist by another file, you cannot just rename the cs to a wb.
This is because when you start the server, the cs scripts are compiled together and they have to all work together.

I am working on the problem but until i can find a solution, there does exist two partial workarounds for this situation.

1.
Make the rest of the dependant files wb.
This is a partial solution because having too many files to keep track of sucks.

2.
Copy the existing cs you want to edit and name the extention of the copy wb.
This way, the original cs script exists for the other scripts that depend on it, and you have a copy that you can make changes in.
This workaround is limited in that you can only check to see if your changes will compile.
Your changes to the wb file will not appear in-game since the dependant files compiled against the cs version of the file in question.

This is a partial solution because it does not work in all cases.
An example is that this workaround works on BaseKnife, but not on BaseWeapon.
Attached Files
File Type: cs ScriptCompiler.cs (24.2 KB, 89 views)

Last edited by Ashlar; 07-31-2006 at 05:02 PM.
Ashlar is offline   Reply With Quote
Old 07-29-2006, 09:39 AM   #2 (permalink)
Forum Expert
 
Join Date: Feb 2005
Age: 24
Posts: 985
Send a message via AIM to Nochte
Default

Looks great, I'll try it out just as soon as I can.
__________________
Quote:
Originally Posted by kkjjkk View Post
how sad you people call yourselves scripters and you can't even format an emulator game into something completely differnt....no wounder y'all are stuck here with no real scripting jobs unlike me. please go back to school.
QFDA
Nochte is offline   Reply With Quote
Old 07-31-2006, 03:34 PM   #3 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,413
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Interesting idea.

I have a problem with it however.

This is only good if you are adding a file that is not depended on by existing c# files, and does not work if your files are integrated with stock scripts.

In other words, what files can you just simply rename with .wb extension, and still be able to compile your C# scripts? I don't have many files like that.

I cannot change BaseWeapon.cs to BaseWeapon.wb and work just on that file, because the C# scripts will not compile without BaseWeapon.cs being there.

EDIT: This WILL work OK if you are adding a completely 'Drag-n-drop' script or script system, where you are not modifying existing C# scripts (most of which depend on eachother to a degree.)

Last edited by Lokai; 07-31-2006 at 03:48 PM.
Lokai is offline   Reply With Quote
Old 07-31-2006, 04:26 PM   #4 (permalink)
Forum Expert
 
Join Date: Nov 2004
Location: Southeast Missouri USA
Age: 34
Posts: 283
Default

Quote:
Originally Posted by Lokai
I cannot change BaseWeapon.cs to BaseWeapon.wb and work just on that file, because the C# scripts will not compile without BaseWeapon.cs being there.
That is true and I believe that is what Phantom was refering to.
I don't edit the distro files much myself since i am more concerned with making new scripts.
And when you are making new scripts, the problem doesn't appear at all.

There is a partial workaround that works in some cases...
Copy BaseKnife.cs to a new folder, and change the extention on the copy to a .wb ( i.e. BaseKnife.cs.wb ).

You still have the original file as a cs so the server will compile, and a wb file to make your changes in and restart the server quickly.

Doing this however will only show you if the server will compile, since any knives created in game will not use values from the wb BaseKnife.
But, just knowing that your changes will compile as a .cs script will still save time.

I said earlier that this workaround will work in "some cases".
Your BaseWeapon example will still not work due to abstract class protection levels in IDurability.
But, as i have shown (and tested) with the BaseKnife, it doesn't take much time to find out if the workaround will work on a particular script file.

This mod will not work for everything unfortunately.
I didnt understand Phantom's concern until just today, but i still see this as an invaluable tool - it has saved me hours and hours already!

Like any tool however, it doesn't work for every job.... Just most of em


I am going to be looking into seeing if i can fix this problem by getting the wb scriptcompiler to load the Scripts.cs.dll as a resource. Edit: err, reverse that...

In the meantime, I hope that the workaround i suggested helps you Lokai.

P.S. Thanks for trying this out!

Last edited by Ashlar; 07-31-2006 at 05:05 PM. Reason: Formatting/Color
Ashlar is offline   Reply With Quote
Old 08-01-2006, 06:53 PM   #5 (permalink)
Forum Expert
 
Cheetah2003's Avatar
 
Join Date: Jun 2006
Location: Laramie, Wyoming
Age: 36
Posts: 354
Send a message via ICQ to Cheetah2003 Send a message via AIM to Cheetah2003 Send a message via MSN to Cheetah2003 Send a message via Yahoo to Cheetah2003
Default

I think this tool is wonderful, its saving me tons of time working on some new stuff. I don't really see or understand the problem you guys are describing, however.

I've just made some new mobs, which are derived from BaseCreature, and I didn't need to rename my BaseCreature.cs to .wb. Seems like a great tool to me, I was really getting tired of recompiling everything everytime I made a little change.

Thanks Ashlar!
Cheetah2003 is offline   Reply With Quote
Old 08-02-2006, 09:30 PM   #6 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,413
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Glad to hear that Cheetah.

Here is where the problem comes in:

I am working on several big systems at the moment. Each one has about 20-30 files in it. Now, if they were self-contained, or were based on other files, but "NOTHING DEPENDED ON THEM" then I could just rename them all with the .WB extension, and it would work fine. But for example, one of the systems I am working on also makes a change and addition to the AI system. So, if I rename the files, BaseAI says it "misses" them, and if I rename BaseAI, there are about 1000 files that miss that. etc. etc. etc.

Don't get me wrong. I was maybe the first one to create a brand new server to test this out. I think its a very cool idea. It is just frustrating that it doesnt work for me yet.
Lokai is offline   Reply With Quote
Old 08-03-2006, 10:32 AM   #7 (permalink)
Forum Expert
 
Join Date: Nov 2004
Location: Southeast Missouri USA
Age: 34
Posts: 283
Default

Glad you like it Cheetah2003
For the first day or so i kept wanting to yell either "station" or "workbench" everytime i restarted the server.


This is only for those having problems like Lokai was desribing...
If you are having no problems with using this mod, dont bother to read on because this only occurs when editing WB files that CS scripts are dependant on.

Lokai, I have been working on this, trying to get it where you could use it with no problems.

Like you said, it works great for smaller projects, but for larger ones that change lots of code throughout the scripts... yech!

I have been making a lot of tests and suchlike and while i have figured out how to create a "trailing effect" (See next paragraph), it isn't something that i recommend for use because it gets.... err, complex to know what is going on where.

What i am calling a "trailing effect" is that;
I have been able to get the cs compiler to load the wb.dll as a resource if it exists.
Meaning that:
1. You copy the cs and name the copy a wb.
2. Compile, the cs is still there, so it loads the cs cache and compiles the wb.
3. Shut the server back down.
4. Rename or remove the cs that you copied.
5. Restart the server to re-compile. (It has to compile the cs scripts since you deleted one of them, but it loads the Scripts.WB.dll as a resource.)

From this point on, the wb file IS the cs script as far as the cs compiler is concerned since it loads it.

Problem:
If you cannot compile a script as a wb, (the baseweapon problem), you cannot get a dll of it and the whole thing breaks down.... grr!



On the plus side, from this effect i believe it is possible to get the compiler to loop through all the scripts in the \Scripts folder, compiling them one at a time and creating assemblys for each of them as it goes and then using the dll's of them as resources for suceeding compiles.

I believe that code that does this would be the ultimate word in a developers test shard.
This way, the server would only compile scripts that have changed and load everything else.

Now, the only problem is that i do not know enough about the CSharpCodeProvider to code this 'Dynamic, hierarchical, compile and load in-line loop'!

*Ashlar sends out a plea for help to those who know more than he.*

Attached is the version that loads the wb.dll as a resource for the cs compiler in case you want to see it.
I also have in it that the wb compiler loads the cs.dll as a resource in hopes that it would help on the baseweapon problem.
It gives different warnings, but the error remains.
Quote:
+ BaseWeapon.cs.wb:
CS0122: Line 23: 'Server.Items.IDurability' is inaccessible due to its protection level.
ction level
( I do not yet understand why this error appears only in the wb script... pout )
Attached Files
File Type: cs ScriptCompiler.cs (24.9 KB, 14 views)

Last edited by Ashlar; 08-03-2006 at 08:28 PM.
Ashlar is offline   Reply With Quote
Old 08-07-2006, 06:56 PM   #8 (permalink)
Forum Expert
 
Lokai's Avatar
 
Join Date: Aug 2003
Location: Bergen, NY (Rochester)
Age: 41
Posts: 1,413
Send a message via ICQ to Lokai Send a message via MSN to Lokai Send a message via Yahoo to Lokai
Default

Thank you Ashlar!

I am using the original version, and finally have a good use. Cuts compile time down from about 4 minutes ( i have lots of beefy customs ) to about 5 seconds (LITTERALLY!)

Excellent!
Lokai is offline   Reply With Quote
Old 08-21-2006, 03:55 AM   #9 (permalink)
Forum Newbie
 
nickfly's Avatar
 
Join Date: Jul 2004
Location: IL, USA
Age: 20
Posts: 41
Send a message via ICQ to nickfly
Default

Hey there,

Trying to get the new Server.exe working, but I get this feedback:
Code:
RunUO - [www.runuo.com] Version 2.0, Build 2424.3593
Core: Running on .NET Framework Version 2.0.50727
Scripts: Compiling C# scripts...done (cached)
Scripts: Compiling VB.NET scripts...no files found.
Scripts: Compiling Workbench C# scripts...no files found.
Scripts: Verifying...done (4 items, 0 mobiles)
Error:
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation. ---> System.NullReferenceException: Object reference not
set to an instance of an object.
   at Server.Admin.AdminNetwork.Configure()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] argum
ents, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle
 typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] argume
nts, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwn
er)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisib
ilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at Server.ScriptCompiler.Compile(Boolean debug)
   at Server.Core.Main(String[] args)
This exception is fatal, press return to exit
__________________
- nickfly
(aka Gorgan)
nickfly is offline   Reply With Quote
Old 08-21-2006, 03:13 PM   #10 (permalink)
Forum Expert
 
Join Date: Nov 2004
Location: Southeast Missouri USA
Age: 34
Posts: 283
Default

Hey there

I just rebuilt the server to svn ver 74 myself to make sure that it still works.

It does, so my guess is that you probably forgot to delete the contents of \Scripts\Output before you started your new server build.

What the problem seems to be is that the scripts.dll was compiled with a different server.exe, and the new one cannot use it.

If you delete the files in \Scripts\Output does it still have the error?
Ashlar is offline   Reply With Quote
Old 11-15-2006, 02:12 AM   #11 (permalink)
Forum Expert
 
Sparkin's Avatar
 
Join Date: Dec 2005
Location: Missouri , USA
Age: 38
Posts: 256
Thumbs up

Server compile time before .WB aprox 10 minutes
Server compile time After adding a new .wb aprox 2 seconds
Running this package has made my life alot smoother, running this on 2 servers at this time and going to add it to the 3rd soon i used to dread adding or changing one simple line of code now i hit [restart and just simply log back in and with a brief little burp the shard is running again!

Thanks Ashlar +++ Karma to you man
__________________
Quote:
Originally Posted by Ryan View Post
You are a moron.
Sparkin 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