RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Fixes for RunUO 2.0 RC1 on Linux

groboclown

Wanderer
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.
 

Jargon

Wanderer
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 :)
 

groboclown

Wanderer
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.
 

Viky

Wanderer
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?
 

TheNorthStar

Sorceror
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.
 

TheNorthStar

Sorceror
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 );

[color="Red"]CompilerResults results = provider.CompileAssemblyFromFile( parms, files );[/color]
from ScriptCompiler.cs, but I have no idea how I would work around that one.
 

kthfive

Wanderer
it would be ahel lot earier if you'd create a proper patch instead of posting filenames and human readable diffs. ;p
 

RavonTUS

Sorceror
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'
                   [COLOR="Red"]return (TOutput)value;[/COLOR]  //<-- 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
 

Attachments

  • Listener.cs
    4.1 KB · Views: 28
  • SaveMetrics.cs
    5.2 KB · Views: 28
  • Serialization.cs
    47.2 KB · Views: 28
  • Utility.cs
    31.1 KB · Views: 34

Nott32

Wanderer
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.
 

RavonTUS

Sorceror
Greetings,

I always use this command line...

Code:
gmcs /debug /nologo /out:.\test.exe /unsafe /recurse:*.cs

-Ravon
 

RavonTUS

Sorceror
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
 

Attachments

  • MONO Fixes.zip
    9 KB · Views: 42

groboclown

Wanderer
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.
 

RavonTUS

Sorceror
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:
[COLOR="Red"]nant -buildfile:RunUO.build *.cs[/COLOR]
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">
[COLOR="Red"]        <csc debug="${debug}" unsafe="true" target="exe"[/COLOR]
                main="Server.Core" win32icon="${src.ico}"
                define="MONO"
                output="${out.server}">
            <sources>
                <include name="${src.server}/**/*.cs" />
            </sources>            
        </csc>
    </target>

Any Suggestions?

-Ravon
 

seirge

Wanderer
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?
 

RavonTUS

Sorceror
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.
 

seirge

Wanderer
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.
 
Top