chore: Use var everywhere (#2294)

This commit is contained in:
Kamron Batman 2025-12-27 16:47:28 -08:00 • committed by GitHub
parent 0b34cc4417
commit ebaf104935
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
267 changed files with 873 additions and 873 deletions

View file

@ -301,8 +301,8 @@ public class AdvancedSearchGump : Gump
);
// Count the number of selected objects
int count = 0;
foreach (AdvancedSearchResult e in SearchResults)
var count = 0;
foreach (var e in SearchResults)
{
if (e.Selected)
{
@ -319,7 +319,7 @@ public class AdvancedSearchGump : Gump
var allDisplayedSelected = true;
for (int i = 0; i < MaxEntries; i++)
for (var i = 0; i < MaxEntries; i++)
{
var offset = SortDescending ? MaxEntries - 1 - i : i;
var index = offset + DisplayFrom;
@ -896,7 +896,7 @@ public class AdvancedSearchGump : Gump
var commandSpan = commandString.AsSpan().Trim();
string command = null;
string[] commandArgs = new string[commandSpan.Count(" ")];
var commandArgs = new string[commandSpan.Count(" ")];
var index = 0;
foreach (var part in commandSpan.Tokenize(' '))
@ -933,9 +933,9 @@ public class AdvancedSearchGump : Gump
return;
}
CommandEventArgs cmdEventArgs = new CommandEventArgs(from, command, commandString, commandArgs);
var cmdEventArgs = new CommandEventArgs(from, command, commandString, commandArgs);
bool flushToLog = false;
var flushToLog = false;
// execute the command on the objects in the list

View file

@ -65,7 +65,7 @@ public class AdvancedSearchThreadWorker
private static void Execute(object obj)
{
AdvancedSearchThreadWorker worker = (AdvancedSearchThreadWorker)obj;
var worker = (AdvancedSearchThreadWorker)obj;
var reader = worker._entities;
@ -73,7 +73,7 @@ public class AdvancedSearchThreadWorker
{
while (true)
{
bool pauseRequested = Volatile.Read(ref worker._pause);
var pauseRequested = Volatile.Read(ref worker._pause);
if (reader.TryDequeue(out var entity))
{
var result = worker.DoEntitySearch(entity);
@ -268,7 +268,7 @@ public class AdvancedSearchThreadWorker
// Keys don't have a backreference, so we just ignore them for now
if (entity is KeyRing keyring && keyring.Keys?.Count > 0)
{
foreach (Key k in keyring.Keys)
foreach (var k in keyring.Keys)
{
_ignoreQueue.Enqueue(k);
}
@ -278,7 +278,7 @@ public class AdvancedSearchThreadWorker
if (entity is BaseHouse house)
{
foreach (RelocatedEntity relEntity in house.RelocatedEntities)
foreach (var relEntity in house.RelocatedEntities)
{
if (relEntity.Entity is Item)
{
@ -286,9 +286,9 @@ public class AdvancedSearchThreadWorker
}
}
foreach (VendorInventory inventory in house.VendorInventories)
foreach (var inventory in house.VendorInventories)
{
foreach (Item subItem in inventory.Items)
foreach (var subItem in inventory.Items)
{
_ignoreQueue.Enqueue(subItem);
}
@ -298,16 +298,16 @@ public class AdvancedSearchThreadWorker
private static bool EvaluateRecursive(IEntity entity, ReadOnlySpan<char> span)
{
int atIndex = span.IndexOf('@');
int orIndex = span.IndexOf('|');
var atIndex = span.IndexOf('@');
var orIndex = span.IndexOf('|');
if (atIndex == -1 && orIndex == -1)
{
return EvaluateSingleExpression(entity, span);
}
bool result = atIndex != -1;
int splitIndex = result ? atIndex : orIndex;
var result = atIndex != -1;
var splitIndex = result ? atIndex : orIndex;
var left = EvaluateRecursive(entity, span.Slice(0, splitIndex));
var right = EvaluateRecursive(entity, span.Slice(splitIndex + 1));
@ -356,7 +356,7 @@ public class AdvancedSearchThreadWorker
}
var propertyValue = property.GetValue(entity);
bool result = AdvancedSearchUtilities.CompareValues(property.PropertyType, propertyValue, valuePart, operatorSpan);
var result = AdvancedSearchUtilities.CompareValues(property.PropertyType, propertyValue, valuePart, operatorSpan);
return negate ? !result : result;
}

View file

@ -151,7 +151,7 @@ public static class AdvancedSearchUtilities
ReadOnlySpan<char> operatorSpan
)
{
double epsilon = CalculateEpsilon(originalValue);
var epsilon = CalculateEpsilon(originalValue);
return operatorSpan switch
{
@ -167,7 +167,7 @@ public static class AdvancedSearchUtilities
public static double CalculateEpsilon(ReadOnlySpan<char> value)
{
int decimalPlace = value.IndexOf('.');
var decimalPlace = value.IndexOf('.');
if (decimalPlace == -1)
{
@ -253,7 +253,7 @@ public static class AdvancedSearchUtilities
// Special handling for boolean and hexadecimal values
if (typeof(T) == typeof(bool))
{
string val = valuePart.ToString().ToLower();
var val = valuePart.ToString().ToLower();
if (val is "true" or "1" or "enabled" or "on")
{
return (T)(object)true;