mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fixed some coding mistakes (#4105)
Co-authored-by: Canvas123 <lunarfury6@gmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -110,25 +110,6 @@ namespace Robust.Build.Tasks
|
||||
var compiler =
|
||||
new RobustXamlILCompiler(transformerconfig, emitConfig, true);
|
||||
|
||||
var loaderDispatcherDef = new TypeDefinition("CompiledRobustXaml", "!XamlLoader",
|
||||
TypeAttributes.Class, asm.MainModule.TypeSystem.Object);
|
||||
|
||||
var loaderDispatcherMethod = new MethodDefinition("TryLoad",
|
||||
MethodAttributes.Static | MethodAttributes.Public,
|
||||
asm.MainModule.TypeSystem.Object)
|
||||
{
|
||||
Parameters = {new ParameterDefinition(asm.MainModule.TypeSystem.String)}
|
||||
};
|
||||
loaderDispatcherDef.Methods.Add(loaderDispatcherMethod);
|
||||
asm.MainModule.Types.Add(loaderDispatcherDef);
|
||||
|
||||
var stringEquals = asm.MainModule.ImportReference(asm.MainModule.TypeSystem.String.Resolve().Methods.First(
|
||||
m =>
|
||||
m.IsStatic && m.Name == "Equals" && m.Parameters.Count == 2 &&
|
||||
m.ReturnType.FullName == "System.Boolean"
|
||||
&& m.Parameters[0].ParameterType.FullName == "System.String"
|
||||
&& m.Parameters[1].ParameterType.FullName == "System.String"));
|
||||
|
||||
bool CompileGroup(IResourceGroup group)
|
||||
{
|
||||
var typeDef = new TypeDefinition("CompiledRobustXaml", "!" + group.Name, TypeAttributes.Class,
|
||||
@@ -252,31 +233,6 @@ namespace Robust.Build.Tasks
|
||||
$"No call to RobustXamlLoader.Load(this) call found anywhere in the type {classType.FullName} and type seems to have custom constructors.");
|
||||
}
|
||||
}
|
||||
|
||||
//add compiled build method
|
||||
var compiledBuildMethod = typeSystem.GetTypeReference(builder).Resolve().Methods
|
||||
.First(m => m.Name == buildName);
|
||||
var parameterlessCtor = classTypeDefinition.GetConstructors()
|
||||
.FirstOrDefault(c => c.IsPublic && !c.IsStatic && !c.HasParameters);
|
||||
|
||||
if (compiledBuildMethod != null && parameterlessCtor != null)
|
||||
{
|
||||
var i = loaderDispatcherMethod.Body.Instructions;
|
||||
var nop = Instruction.Create(OpCodes.Nop);
|
||||
i.Add(Instruction.Create(OpCodes.Ldarg_0));
|
||||
i.Add(Instruction.Create(OpCodes.Ldstr, res.Uri));
|
||||
i.Add(Instruction.Create(OpCodes.Call, stringEquals));
|
||||
i.Add(Instruction.Create(OpCodes.Brfalse, nop));
|
||||
if (parameterlessCtor != null)
|
||||
i.Add(Instruction.Create(OpCodes.Newobj, parameterlessCtor));
|
||||
else
|
||||
{
|
||||
i.Add(Instruction.Create(OpCodes.Call, compiledBuildMethod));
|
||||
}
|
||||
|
||||
i.Add(Instruction.Create(OpCodes.Ret));
|
||||
i.Add(nop);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -293,8 +249,6 @@ namespace Robust.Build.Tasks
|
||||
return false;
|
||||
}
|
||||
|
||||
loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ldnull));
|
||||
loaderDispatcherMethod.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Robust.Client.GameObjects
|
||||
get => scale;
|
||||
set
|
||||
{
|
||||
if (MathF.Abs(value.X) < 0.005f || MathF.Abs(value.X) < 0.005f)
|
||||
if (MathF.Abs(value.X) < 0.005f || MathF.Abs(value.Y) < 0.005f)
|
||||
{
|
||||
// Scales of ~0.0025 or lower can lead to singular matrices due to rounding errors.
|
||||
Logger.Error($"Attempted to set layer sprite scale to very small values. Entity: {entities.ToPrettyString(Owner)}. Scale: {value}");
|
||||
@@ -1574,7 +1574,7 @@ namespace Robust.Client.GameObjects
|
||||
{
|
||||
if (_scale.EqualsApprox(value)) return;
|
||||
|
||||
if (MathF.Abs(value.X) < 0.005f || MathF.Abs(value.X) < 0.005f)
|
||||
if (MathF.Abs(value.X) < 0.005f || MathF.Abs(value.Y) < 0.005f)
|
||||
{
|
||||
// Scales of ~0.0025 or lower can lead to singular matrices due to rounding errors.
|
||||
Logger.Error($"Attempted to set layer sprite scale to very small values. Entity: {_parent.entities.ToPrettyString(_parent.Owner)}. Scale: {value}");
|
||||
|
||||
@@ -1038,7 +1038,7 @@ namespace Robust.Client.GameStates
|
||||
private void HandleEntityState(EntityUid uid, IEventBus bus, EntityState? curState,
|
||||
EntityState? nextState, GameTick lastApplied, GameTick toTick, bool enteringPvs)
|
||||
{
|
||||
var size = curState?.ComponentChanges.Span.Length ?? 0 + nextState?.ComponentChanges.Span.Length ?? 0;
|
||||
var size = (curState?.ComponentChanges.Span.Length ?? 0) + (nextState?.ComponentChanges.Span.Length ?? 0);
|
||||
var compStateWork = new Dictionary<ushort, (IComponent Component, ComponentState? curState, ComponentState? nextState)>(size);
|
||||
|
||||
// First remove any deleted components
|
||||
|
||||
@@ -308,7 +308,7 @@ namespace Robust.Client.UserInterface.Controls
|
||||
|
||||
var active = _currentTab == i;
|
||||
var box = active ? boxActive : boxInactive;
|
||||
var boxAdvance = titleLength + box?.MinimumSize.X ?? 0;
|
||||
var boxAdvance = titleLength + (box?.MinimumSize.X ?? 0);
|
||||
|
||||
if (headerOffset < relX && headerOffset + boxAdvance > relX)
|
||||
{
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace Robust.Shared.Physics.Dynamics.Contacts
|
||||
|
||||
public void ResetFriction()
|
||||
{
|
||||
Friction = MathF.Sqrt(FixtureA?.Friction ?? 0.0f * FixtureB?.Friction ?? 0.0f);
|
||||
Friction = MathF.Sqrt((FixtureA?.Friction ?? 0.0f) * (FixtureB?.Friction ?? 0.0f));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -457,7 +457,7 @@ public abstract partial class SharedPhysicsSystem
|
||||
uidA = jointCompA.Relay.Value;
|
||||
}
|
||||
|
||||
if (jointQuery.TryGetComponent(uidA, out var jointCompB) &&
|
||||
if (jointQuery.TryGetComponent(uidB, out var jointCompB) &&
|
||||
jointCompB.Relay != null)
|
||||
{
|
||||
uidB = jointCompB.Relay.Value;
|
||||
|
||||
Reference in New Issue
Block a user