Files
OpenRA/RALint/RALint.cs
2011-07-19 21:14:12 +12:00

72 lines
1.8 KiB
C#

#region Copyright & License Information
/*
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using OpenRA;
using OpenRA.FileFormats;
using OpenRA.Traits;
namespace RALint
{
static class RALint
{
static int errors = 0;
static void EmitError(string e)
{
Console.WriteLine("RALint(1,1): Error: {0}", e);
++errors;
}
static void EmitWarning(string e)
{
Console.WriteLine("RALint(1,1): Warning: {0}", e);
}
static int Main(string[] args)
{
try
{
// bind some nonfatal error handling into FieldLoader, so we don't just *explode*.
ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s));
FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));
AppDomain.CurrentDomain.AssemblyResolve += FileSystem.ResolveAssembly;
Game.modData = new ModData(args);
Rules.LoadRules(Game.modData.Manifest, new Map());
foreach (var customPassType in Game.modData.ObjectCreator
.GetTypesImplementing<ILintPass>())
{
var customPass = (ILintPass)Game.modData.ObjectCreator
.CreateBasic(customPassType);
Console.WriteLine("CustomPass: {0}".F(customPassType.ToString()));
customPass.Run(EmitError, EmitWarning);
}
if (errors > 0)
{
Console.WriteLine("Errors: {0}", errors);
return 1;
}
return 0;
}
catch (Exception e)
{
EmitError("Failed with exception: {0}".F(e));
return 1;
}
}
}
}