Fix RCS1118

This commit is contained in:
RoosterDragon
2023-03-18 12:58:22 +00:00
committed by Gustas
parent eb287d9b8d
commit fbe147ce61
11 changed files with 115 additions and 107 deletions

View File

@@ -70,40 +70,40 @@ namespace OpenRA.Mods.Common.Lint
return;
// TODO: Check all available languages.
var language = "en";
var modTranslation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { });
var mapTranslation = new Translation(language, FieldLoader.GetValue<string[]>("value", map.TranslationDefinitions.Value), map, error => emitError(error.ToString()));
const string Language = "en";
var modTranslation = new Translation(Language, modData.Manifest.Translations, modData.DefaultFileSystem, _ => { });
var mapTranslation = new Translation(Language, FieldLoader.GetValue<string[]>("value", map.TranslationDefinitions.Value), map, error => emitError(error.ToString()));
TestTraits(map.Rules, emitError, key =>
{
if (modTranslation.HasMessage(key))
{
if (mapTranslation.HasMessage(key))
emitWarning($"Map translation key `{key}` already exists in `{language}` mod translations and will not be used.");
emitWarning($"Map translation key `{key}` already exists in `{Language}` mod translations and will not be used.");
}
else if (!mapTranslation.HasMessage(key))
emitWarning($"`{key}` is not present in `{language}` translation.");
emitWarning($"`{key}` is not present in `{Language}` translation.");
});
}
void ILintPass.Run(Action<string> emitError, Action<string> emitWarning, ModData modData)
{
// TODO: Check all available languages.
var language = "en";
Console.WriteLine($"Testing translation: {language}");
var translation = new Translation(language, modData.Manifest.Translations, modData.DefaultFileSystem, error => emitError(error.ToString()));
const string Language = "en";
Console.WriteLine($"Testing translation: {Language}");
var translation = new Translation(Language, modData.Manifest.Translations, modData.DefaultFileSystem, error => emitError(error.ToString()));
TestTraits(modData.DefaultRules, emitError, key =>
{
if (!translation.HasMessage(key))
emitWarning($"`{key}` is not present in `{language}` translation.");
emitWarning($"`{key}` is not present in `{Language}` translation.");
});
var gameSpeeds = modData.Manifest.Get<GameSpeeds>();
foreach (var speed in gameSpeeds.Speeds.Values)
{
if (!translation.HasMessage(speed.Name))
emitWarning($"`{speed.Name}` is not present in `{language}` translation.");
emitWarning($"`{speed.Name}` is not present in `{Language}` translation.");
referencedKeys.Add(speed.Name);
}
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Lint
continue;
if (!translation.HasMessage(key))
emitWarning($"`{key}` is not present in `{language}` translation.");
emitWarning($"`{key}` is not present in `{Language}` translation.");
var translationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(fieldInfo, true)[0];
if (translationReference.RequiredVariableNames != null && translationReference.RequiredVariableNames.Length > 0)
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.Common.Lint
{
var nodes = MiniYaml.FromStream(modData.DefaultFileSystem.Open(filename));
foreach (var node in nodes)
CheckChrome(node, translation, language, emitError, emitWarning, translatableFields);
CheckChrome(node, translation, Language, emitError, emitWarning, translatableFields);
}
foreach (var file in modData.Manifest.Translations)

View File

@@ -496,8 +496,8 @@ namespace OpenRA.Mods.Common.Projectiles
lastHt = 0; // Height just before the last height change
// NOTE: Might be desired to unhardcode the lookahead step size
var stepSize = 32;
var step = new WVec(0, -stepSize, 0)
const int StepSize = 32;
var step = new WVec(0, -StepSize, 0)
.Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(hFacing))); // Step vector of length 128
// Probe terrain ahead of the missile
@@ -505,7 +505,7 @@ namespace OpenRA.Mods.Common.Projectiles
var maxLookaheadDistance = loopRadius * 4;
var posProbe = pos;
var curDist = 0;
var tickLimit = System.Math.Min(maxLookaheadDistance, distCheck) / stepSize;
var tickLimit = System.Math.Min(maxLookaheadDistance, distCheck) / StepSize;
var prevHt = 0;
// TODO: Make sure cell on map!!!
@@ -517,7 +517,7 @@ namespace OpenRA.Mods.Common.Projectiles
var ht = world.Map.Height[world.Map.CellContaining(posProbe)] * 512;
curDist += stepSize;
curDist += StepSize;
if (ht > predClfHgt)
{
predClfHgt = ht;