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:
Persistence/FileOperations.cs:
Persistence/SaveMetrics.cs:
Serialization.cs: It appears that the Mono compiler is more strict or has different rules for templates.
Utility.cs:
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.
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.