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 09-13-2006, 02:34 PM   #1 (permalink)
Forum Newbie
 
Join Date: Jan 2006
Posts: 6
Default Fixes for RunUO 2.0 RC1 on Linux

Here's a list of the patches I made to get RunUO 2.0 RC1 running on Linux (tested with Mono 1.1.14). I can't guarantee that it's as stable as the non-patched version, but it compiles and runs, at least.

Network/Listener.cs:
Code:
@@ -93,8 +93,10 @@
                        try
                        {
+#if !MONO
                                s.LingerState.Enabled = false;
                                s.ExclusiveAddressUse = false;
+#endif

                                s.Bind( ipep );
Persistence/FileOperations.cs:
Code:
@@ -87,4 +87,8 @@

                public static FileStream OpenSequentialStream( string path, FileMode mode, FileAccess access, FileShare share ) {
+
+#if MONO
+                       return new FileStream( path, mode, access, share, bufferSize, concurrency > 0 );
+#else
                        FileOptions options = FileOptions.SequentialScan;

@@ -92,8 +96,5 @@
                                options |= FileOptions.Asynchronous;
                        }
-
-#if MONO
-                       return new FileStream( path, mode, access, share, bufferSize, options );
-#else
+
                        if ( unbuffered ) {
                                options |= NoBuffering;
Persistence/SaveMetrics.cs:
Code:
@@ -76,5 +76,9 @@
                                );

+#if MONO
+                               PerformanceCounterCategory.Create( PerformanceCategoryName, PerformanceCategoryDesc, counters );
+#else
                                PerformanceCounterCategory.Create( PerformanceCategoryName, PerformanceCategoryDesc, PerformanceCounterCategoryType.SingleInstance, counters );
+#endif
                        }
Serialization.cs: It appears that the Mono compiler is more strict or has different rules for templates.
Code:
[@@ -672,5 +672,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Deleted )
+                                       if( ((Item) list[i]).Deleted )
                                                list.RemoveAt( i );
                                        else
@@ -720,5 +720,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Deleted )
+                                       if( ((Mobile) list[i]).Deleted )
                                                list.RemoveAt( i );
                                        else
@@ -768,5 +768,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Disbanded )
+                                       if( ((BaseGuild)list[i]).Disbanded )
                                                list.RemoveAt( i );
                                        else
@@ -968,15 +968,15 @@
                public override T ReadItem<T>()
                {
-                       return ReadItem() as T;
+                       return (T) ReadItem();
                }

                public override T ReadMobile<T>()
                {
-                       return ReadMobile() as T;
+                       return (T) ReadMobile();
                }

                public override T ReadGuild<T>()
                {
-                       return ReadGuild() as T;
+                       return (T) ReadGuild();
                }

@@ -1057,5 +1057,5 @@
                        for( int i = 0; i < count; ++i )
                        {
-                               T item = ReadItem() as T;
+                               T item = ReadItem<T>();

                                if( item != null )
@@ -1091,5 +1091,5 @@
                        for( int i = 0; i < count; ++i )
                        {
-                               T m = ReadMobile() as T;
+                               T m = ReadMobile<T>();

                                if( m != null )
@@ -1125,5 +1125,5 @@
                        for( int i = 0; i < count; ++i )
                        {
-                               T g = ReadGuild() as T;
+                               T g = ReadGuild<T>();

                                if( g != null )
@@ -1589,5 +1589,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Deleted )
+                                       if( ((Item)list[i]).Deleted )
                                                list.RemoveAt( i );
                                        else
@@ -1637,5 +1637,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Deleted )
+                                       if( ((Mobile)list[i]).Deleted )
                                                list.RemoveAt( i );
                                        else
@@ -1685,5 +1685,5 @@
                                for( int i = 0; i < list.Count; )
                                {
-                                       if( list[i].Disbanded )
+                                       if( ((BaseGuild)list[i]).Disbanded )
                                                list.RemoveAt( i );
                                        else
Utility.cs:
Code:
@@ -316,4 +316,7 @@
                        int i;

+            if( value == null || value.Length <= 0 )
+                return -1;
+
                        if( value.StartsWith( "0x" ) )
                                int.TryParse( value.Substring( 2 ), NumberStyles.HexNumber, null, out i );
@@ -371,10 +374,18 @@
                        catch
                        {
-                               DateTime d;
-
-                               if( DateTime.TryParse( dateTimeString, out d ) )+#if MONO
+                               try {
+                                       DateTime d = DateTime.Parse( dateTimeString );
                                        return d;
+                               } catch (Exception e) {
+                                       return defaultValue;
+                               }
+#else
+                                DateTime d;

-                               return defaultValue;
+                                if( DateTime.TryParse( dateTimeString, out d )
)                                        return d;
+
+                                return defaultValue;
+#endif
                        }
                }
For users of Mono prior to 1.1.15, you'll need to add in Stopwatch.cs from the Mono source of 1.1.17 in the source directory, changing the namespace to Server.
groboclown is offline   Reply With Quote
Old 09-24-2006, 03:01 AM   #2 (permalink)
Forum Newbie
 
Join Date: Mar 2006
Posts: 4
Default :)

Thanks man, highly appreciated
larrylarry is offline   Reply With Quote
Old 09-24-2006, 06:33 PM   #3 (permalink)
Forum Newbie
 
Join Date: Mar 2005
Age: 23
Posts: 10
Default

Hey man, thanks for the mono patches.

I got the sourcecode to compile, but unfortunately I couldn't get the binary to run. It gives the following error:

Code:
Error:
System.EntryPointNotFoundException: SetConsoleCtrlHandler
  at (wrapper managed-to-native) Server.Core:SetConsoleCtrlHandler (Server.Core/ConsoleEventHandler,bool)
  at Server.Core.Main (System.String[] args) [0x00000]
This exception is fatal, press return to exit
I assume it's referring to the public static void main method. But I've specified main class (Server.Core). I've tried both through the command line with gmcs and with monodevelop and neither worked. I'm pretty new to mono and not sure if i'm doing anything wrong.

Any help on this would be greatly appreciated
Jargon is offline   Reply With Quote
Old 09-27-2006, 09:42 PM   #4 (permalink)
Forum Newbie
 
Join Date: Jan 2006
Posts: 6
Default

I had to manually add the "-define:MONO" argument to the mono compiler to avoid getting these bits compiled into the binary. I wrote a custom NANT script to help out with all of this.

Note that the default scripts need lots of work, as well.

I'm going to move up to the SVN version and Mono 1.1.17. I'll post my customizations as I go along.
groboclown is offline   Reply With Quote
Old 10-08-2006, 11:06 PM   #5 (permalink)
Newbie
 
Join Date: Feb 2004
Posts: 50
Default

thank you so much for the mono patches. I hope you continue the great work!
jairon is offline   Reply With Quote
Old 10-17-2006, 06:27 AM   #6 (permalink)
Newbie
 
Join Date: Nov 2003
Posts: 60
Default

Is it compatible with newest version of mono (1.1.18)? This branche was redefined from "development" to "stable". Is any chance to apply this patches to official SVN?
Viky is offline   Reply With Quote
Old 10-18-2006, 09:06 PM   #7 (permalink)
Forum Novice
 
Join Date: Aug 2004
Location: :P
Age: 21
Posts: 138
Send a message via AIM to TheNorthStar
Default

I haven't had any luck getting it to work with 1.1.18, though it may just be me. RunUO starts fine, but once it starts to compile the scripts it crashes. I'd post the error but I'm not on my linux computer right now. I haven't really had a chance to look into the problem yet, please let me know if you have any ideas on this.
I hadn't tried running RunUO 2.0 under mono until this latest version came out, so it's very possible that the error is on my end. Though I'm using a stock core with only these patches applied. I'll mess with it some more tomorrow.

EDIT: Ok here's the error:
Code:
> mono RunUO.exe

RunUO - [www.runuo.com] Version 2.0, Build 2480.29346
Core: Running on .NET Framework Version 2.0.50727
Scripts: Compiling C# scripts...Error:
System.Exception: Compiler failed to produce the assembly. Stderr='', Stdout=''
  at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compile r.CompilerParameters options, System.String[] fileNames) [0x00000]
  at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom .Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
  at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.Cod eDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
  at Server.ScriptCompiler.CompileCSScripts (Boolean debug, System.Reflection.As sembly& assembly) [0x00000]
  at Server.ScriptCompiler.Compile (Boolean debug) [0x00000]
  at Server.Core.Main (System.String[] args) [0x00000]
This exception is fatal, press return to exit

** (RunUO.exe:16940): WARNING **: exception inside UnhandledException handler: C annot cast from source type to destination type.
I'll experiment with this a bit today, I'll post anything I figure out.
__________________
Make music online with Splice!

Last edited by TheNorthStar; 10-19-2006 at 02:59 PM.
TheNorthStar is offline   Reply With Quote
Old 10-19-2006, 06:55 PM   #8 (permalink)
Forum Novice
 
Join Date: Aug 2004
Location: :P
Age: 21
Posts: 138
Send a message via AIM to TheNorthStar
Default

Well I give up for now, this is frustrating me too much. I'll try installing 1.1.17 next time I get a chance. Has anyone had any success with 1.1.18?

EDIT: I think the problem must be my own, I tried installing 1.1.17 and got the same error. So now I don't even have a clue what to do.

EDIT 2: Well here's the line that causes the problem:
Code:
CompilerParameters parms = new CompilerParameters( GetReferenceAssemblies(), path, debug );
string defines = GetDefines();

if ( defines != null )
	parms.CompilerOptions = string.Format( "/define:{0}", defines );

CompilerResults results = provider.CompileAssemblyFromFile( parms, files );
from ScriptCompiler.cs, but I have no idea how I would work around that one.
__________________
Make music online with Splice!

Last edited by TheNorthStar; 10-19-2006 at 10:36 PM.
TheNorthStar is offline   Reply With Quote
Old 11-17-2006, 05:59 PM   #9 (permalink)
Forum Newbie
 
Join Date: Nov 2006
Posts: 1
Default

it would be ahel lot earier if you'd create a proper patch instead of posting filenames and human readable diffs. ;p
kthfive is offline   Reply With Quote
Old 12-19-2006, 10:24 AM   #10 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

I used RunUO SVN 120 and MONO 1.2.2.1 and most of the fixes above. It will compile up to this point (see below). The error is a known bug in mono and there is a code fix for it. However, I am not knowledgable enought to apply it.

Would someone have a minute to look at the Mono Fix here, and apply it to the code below?

Error Message:
Code:
./Utility.cs(1096,104): error CS0030: Cannot convert type `TInput' to `TOutput'
./Utility.cs(1096,104): The type  has two conflicting definitions, one comes from .test, Version=0.0.0.0, Culture=neutral and the other from .test, Version=0.0.0.0, Culture=neutralerror)
Code:
Code:
        public static List<TOutput> CastConvertList<TInput, TOutput>(List<TInput> list) where TOutput : TInput
        {
            return list.ConvertAll<TOutput>
               (new Converter<TInput, TOutput>
               (delegate(TInput value)
               {
               	   //./Utility.cs(1096,28): error CS0030: Cannot convert type `TInput' to `TOutput'
                   return (TOutput)value;  //<-- This is 1096
               }
               )
               );
        }


        public static List<TOutput> SafeConvertList<TInput, TOutput>(List<TInput> list) where TOutput : class
        {
            List<TOutput> output = new List<TOutput>(list.Capacity);

            for (int i = 0; i < list.Count; i++)
            {
                TOutput t = list[i] as TOutput;

                if (t != null)
                    output.Add(t);
            }
            return output;
        }
Or is there a way to re-write this section to look like "SafeConvertList" code below it?

-Ravon
Attached Files
File Type: cs Listener.cs (4.1 KB, 25 views)
File Type: cs SaveMetrics.cs (5.2 KB, 23 views)
File Type: cs Serialization.cs (47.2 KB, 25 views)
File Type: cs Utility.cs (31.1 KB, 29 views)
__________________

Will RunUO work on Linux? Yes

Last edited by RavonTUS; 12-21-2006 at 03:23 PM. Reason: Update
RavonTUS is offline   Reply With Quote
Old 12-27-2006, 02:59 PM   #11 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

How do I compile RunUO with Mono? I have never compiled a application bigger than 1 file before... Im running mono 1.1.17.1 on Ubuntu Linux.

Thanks, Nott32.
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 12-28-2006, 10:59 PM   #12 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

I always use this command line...

Code:
gmcs /debug /nologo /out:.\test.exe /unsafe /recurse:*.cs
-Ravon
RavonTUS is offline   Reply With Quote
Old 12-29-2006, 01:41 PM   #13 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

Thanks :-) I also got it off of your blog kubuntUO.
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-05-2007, 02:35 PM   #14 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

It COMPILED!! However, it still doesn't work.

I managed to use MonoDevelop to compile the files and after several modification as posted above it did compile.

However, when I open the console and run the file I end up with the following message...

Code:
root@ubuntu://RunUO-v2.0-SVN# mono RunUOv2r129-Mono.exe
Error:System.EntryPointNotFoundException: SetConsoleCtrlHandler at (wrapper managed-to-native) Server.Core:SetConsoleCtrlHandler (Server.Core/ConsoleEventHandler,bool)  at Server.Core.Main (System.String[] args) [0x00000]
This exception is fatal, press return to exit

** (RunUOv2r129-Mono.exe:6708): WARNING **: exception inside UnhandledException handler: Cannot cast from source type to destination type.
Anybody have any suggestion?

-Ravon
Attached Files
File Type: zip MONO Fixes.zip (9.0 KB, 37 views)
RavonTUS is offline   Reply With Quote
Old 01-06-2007, 03:29 PM   #15 (permalink)
Forum Newbie
 
Join Date: Jan 2006
Posts: 6
Default

I used an Ant .NET build script (attached below).
Attached Files
File Type: zip RunUO.build.zip (649 Bytes, 47 views)
groboclown is offline   Reply With Quote
Old 01-06-2007, 03:32 PM   #16 (permalink)
Forum Newbie
 
Join Date: Jan 2006
Posts: 6
Default

Quote:
Error:System.EntryPointNotFoundException: SetConsoleCtrlHandler at (wrapper managed-to-native) Server.Core:SetConsoleCtrlHandler (Server.Core/ConsoleEventHandler,bool) at Server.Core.Main (System.String[] args) [0x00000]
This happens because Mono doesn't have this in its library. You need to find this bit of code, and wrap it in #if !MONO / #endif.
groboclown is offline   Reply With Quote
Old 01-09-2007, 01:56 PM   #17 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

OK, I don't quite understand the NANT, I tried that and came up with this. I would assume I am not getting the subdirectories. What command should I be using?

Code:
nant -buildfile:RunUO.build *.cs
NAnt 0.85 (Build 0.85.2478.0; release; 10/14/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///Projects/RunUOv2r129/RunUOv2r129/RunUO.build
Target framework: Mono 2.0 Profile
Target(s) specified: AggressorInfo.cs AssemblyInfo.cs Attributes.cs BaseVendor.cs Body.cs ClientVersion.cs Commands.cs Effects.cs EventLog.cs EventSink.cs ExpansionInfo.cs Geometry.cs Guild.cs HuePicker.cs IAccount.cs IEntity.cs Insensitive.cs Interfaces.cs ItemBounds.cs Item.cs KeywordList.cs Main.cs Map.cs Mobile.cs Movement.cs MultiData.cs Notoriety.cs ObjectPropertyList.cs Party.cs Point3DList.cs Poison.cs Prompt.cs QuestArrow.cs Race.cs Region.cs ScriptCompiler.cs Sector.cs SecureTrade.cs Serial.cs Serialization.cs Skills.cs TileData.cs TileList.cs TileMatrix.cs TileMatrixPatch.cs Timer.cs Utility.cs VirtueInfo.cs World.cs


BUILD FAILED

Target 'AggressorInfo.cs' does not exist in this project.

Total time: 0 seconds.
UPDATE:
The build file must be in the same directory a the folders - Server, Scripts and DATA.

However, you still get the following error...
Code:
BUILD FAILED - 0 non-fatal error(s), 62 warning(s)

/home/test/runuo/RunUO-v2.0-SVN/RunUO.build(25,10):
External Program Failed: /usr/local/lib/pkgconfig/../../lib/mono/2.0/gmcs.exe (return code was 1)
Here is the section of code from the .build file...
Code:
    <target name="compile:server">
        <csc debug="${debug}" unsafe="true" target="exe"
                main="Server.Core" win32icon="${src.ico}"
                define="MONO"
                output="${out.server}">
            <sources>
                <include name="${src.server}/**/*.cs" />
            </sources>            
        </csc>
    </target>
Any Suggestions?

-Ravon
__________________

Will RunUO work on Linux? Yes

Last edited by RavonTUS; 01-17-2007 at 08:48 AM.
RavonTUS is offline   Reply With Quote
Old 01-31-2007, 12:40 AM   #18 (permalink)
Newbie
 
Join Date: Aug 2004
Age: 24
Posts: 35
Default

Compilation can be easyly achieved by the following command
Code:
gmcs -out:../RunUO.exe -d:MONO -optimize+ -unsafe -nowarn:219,169,414 -recurse:*.cs
(tryed on Gentoo/mono 1.2.2.1)
It should be done in core folder (and it will create RunUO.exe file one directory above)
But you should change some core scripts (as mentioned in previous posts).
But compiled exe wouldn't work as expected.

I managed to edit source code so it is running:
2 patches should be done to mono (already in Mono SVN, waiting for mono 1.2.3)
and several #if MONO #endif in RunUO Core.

The main questiong is: can patches to core be reviewed by RunUO Core team and add to RunUO SVN? Then several users of Linux will be able to run RunUO. Or such changes are unsupported by RunUO team?

Last edited by seirge; 01-31-2007 at 12:47 AM.
seirge is offline   Reply With Quote
Old 01-31-2007, 11:01 AM   #19 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

Seirge can you post your "utility.cs" script from /server? I would like to see how your getting the "public static List<TOutput> CastConvertList<TInput, TOutput>(List<TInput> list) where TOutput : TInput" to work.

This is the point at which I am stuck. I have tried the latest version of Mono (SVN) and it still doesn't seem to help. I keep ending up with one of the two following errors...

Code:
System.Exception: Compiler failed to produce the assembly. Stderr='', Stdout=''
or
Code:
System.InvalidCastException: Cannot cast from source type to destination type.
__________________

Will RunUO work on Linux? Yes
RavonTUS is offline   Reply With Quote
Old 02-01-2007, 10:21 PM   #20 (permalink)
Newbie
 
Join Date: Aug 2004
Age: 24
Posts: 35
Default

here is it:
Code:
#if MONO
                public static List<TOutput> CastConvertList<TInput, TOutput>( List<TInput> list ) 
                       where TInput : class
                       where TOutput : class
                {
                        return list.ConvertAll<TOutput>( new Converter<TInput, TOutput>( delegate( TInput value ) { return value as TOutput; } ) );
                }

#else
                public static List<TOutput> CastConvertList<TInput, TOutput>( List<TInput> list ) where TOutput : TInput
                {
                        return list.ConvertAll<TOutput>( new Converter<TInput, TOutput>( delegate( TInput value ) { return (TOutput)value; } ) );
                }

#endif
Is is bad solution, but it is the only way to force it to work under mono for now. (it is bad, because if will be used to convert wrong types it will throw exception runtime, not on compilation stage)
Of course, you should define MONO symbol while compiling.
seirge is offline   Reply With Quote
Old 02-02-2007, 07:22 AM   #21 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

Thank you seirge. I took advise and install MONO from their SVN and it seems to get past this error.

Now it appears to be having problems with either finding the scripts folder or there are problems with the way MONO handles the Console.ReadKey or both.

I will play with it a little more today.

-Ravon
__________________

Will RunUO work on Linux? Yes
RavonTUS is offline   Reply With Quote
Old 02-07-2007, 08:09 AM   #22 (permalink)
Forum Expert
 
RavonTUS's Avatar
 
Join Date: Aug 2004
Location: in a house.
Age: 39
Posts: 587
Send a message via ICQ to RavonTUS Send a message via AIM to RavonTUS
Default

Greetings,

Not making any progress.

seirge - would you consider posting your changes for us?!? Please!

-Ravon
__________________

Will RunUO work on Linux? Yes
RavonTUS is offline   Reply With Quote
Old 02-08-2007, 03:06 AM   #23 (permalink)
Newbie
 
Join Date: Aug 2004
Age: 24
Posts: 35
Default

Try this ScriptCompiler.
One of the mono problem is the fact, that it cannot handle command lines with more, then 64k symbols (due to shell restriction). So, standard RunUO ScriptCompiler will not work.
Another problem in ScriptCompiler is MakeRelativeUri function (that is not implemented in Mono).
I attach modified ScriptCompiler.cs and diff to SVN 156.

If smth goes wrong, show errors, please.
Attached Files
File Type: cs ScriptCompiler.cs (19.9 KB, 28 views)
File Type: txt ScriptCompiler.cs.diff.txt (2.3 KB, 21 views)
seirge is offline   Reply With Quote
Old 02-09-2007, 10:57 PM   #24 (permalink)