-Perform null check and add exception logging in RuleSet.

-Explicitly recognize connection termination on ServerOrder.Deserialize()
-Use explicit exception type for SDL2HardwareCursor failures.
This commit is contained in:
Peter Antal
2018-02-25 12:36:57 -08:00
committed by Paul Chote
parent f351f0346f
commit 8fa94c5301
3 changed files with 15 additions and 4 deletions

View File

@@ -227,10 +227,13 @@ namespace OpenRA
{ {
var traitName = traitNode.Key.Split('@')[0]; var traitName = traitNode.Key.Split('@')[0];
var traitType = modData.ObjectCreator.FindType(traitName + "Info"); var traitType = modData.ObjectCreator.FindType(traitName + "Info");
if (traitType.GetInterface("ILobbyCustomRulesIgnore") == null) if (traitType != null && traitType.GetInterface("ILobbyCustomRulesIgnore") == null)
return true; return true;
} }
catch { } catch (Exception ex)
{
Log.Write("debug", "Error in AnyFlaggedTraits\r\n" + ex.ToString());
}
} }
} }

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Server
byte b; byte b;
switch (b = r.ReadByte()) switch (b = r.ReadByte())
{ {
case 0xbf:
case 0xff: case 0xff:
Console.WriteLine("This isn't a server order."); Console.WriteLine("This isn't a server order.");
return null; return null;

View File

@@ -189,7 +189,7 @@ namespace OpenRA.Platforms.Default
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new InvalidDataException("Failed to create hardware cursor `{0}` - {1}".F(name, ex.Message), ex); throw new SDL2HardwareCursorException("Failed to create hardware cursor `{0}` - {1}".F(name, ex.Message), ex);
} }
} }
@@ -226,6 +226,12 @@ namespace OpenRA.Platforms.Default
} }
} }
class SDL2HardwareCursorException : Exception
{
public SDL2HardwareCursorException(string message) : base(message) { }
public SDL2HardwareCursorException(string message, Exception innerException) : base(message, innerException) { }
}
sealed class SDL2HardwareCursor : IHardwareCursor sealed class SDL2HardwareCursor : IHardwareCursor
{ {
public IntPtr Cursor { get; private set; } public IntPtr Cursor { get; private set; }
@@ -245,8 +251,9 @@ namespace OpenRA.Platforms.Default
// This call very occasionally fails on Windows, but often works when retried. // This call very occasionally fails on Windows, but often works when retried.
for (var retries = 0; retries < 3 && Cursor == IntPtr.Zero; retries++) for (var retries = 0; retries < 3 && Cursor == IntPtr.Zero; retries++)
Cursor = SDL.SDL_CreateColorCursor(surface, hotspot.X, hotspot.Y); Cursor = SDL.SDL_CreateColorCursor(surface, hotspot.X, hotspot.Y);
if (Cursor == IntPtr.Zero) if (Cursor == IntPtr.Zero)
throw new InvalidDataException("Failed to create cursor: {0}".F(SDL.SDL_GetError())); throw new SDL2HardwareCursorException("Failed to create cursor: {0}".F(SDL.SDL_GetError()));
} }
catch catch
{ {