Using ToLowerInvariant instead of ToLower (the game works for Turkish players now!)

http://www.moserware.com/2008/02/does-your-code-pass-turkey-test.html
This commit is contained in:
Regalis
2016-04-27 17:14:09 +03:00
parent 81ca1a409b
commit d3ab7946a8
52 changed files with 96 additions and 94 deletions
@@ -39,7 +39,7 @@ namespace Barotrauma
if (GameMain.GameSession!=null && GameMain.GameSession.CrewManager!=null) if (GameMain.GameSession!=null && GameMain.GameSession.CrewManager!=null)
{ {
CurrentOrder = Order.PrefabList.Find(o => o.Name.ToLower() == "dismissed"); CurrentOrder = Order.PrefabList.Find(o => o.Name.ToLowerInvariant() == "dismissed");
objectiveManager.SetOrder(CurrentOrder, ""); objectiveManager.SetOrder(CurrentOrder, "");
GameMain.GameSession.CrewManager.SetCharacterOrder(Character, CurrentOrder); GameMain.GameSession.CrewManager.SetCharacterOrder(Character, CurrentOrder);
} }
@@ -71,7 +71,7 @@ namespace Barotrauma
currentObjective = null; currentObjective = null;
switch (order.Name.ToLower()) switch (order.Name.ToLowerInvariant())
{ {
case "follow": case "follow":
currentObjective = new AIObjectiveGoTo(Character.Controlled, character, true); currentObjective = new AIObjectiveGoTo(Character.Controlled, character, true);
+2 -2
View File
@@ -39,7 +39,7 @@ namespace Barotrauma
foreach (XElement orderElement in doc.Root.Elements()) foreach (XElement orderElement in doc.Root.Elements())
{ {
if (orderElement.Name.ToString().ToLower() != "order") continue; if (orderElement.Name.ToString().ToLowerInvariant() != "order") continue;
PrefabList.Add(new Order(orderElement)); PrefabList.Add(new Order(orderElement));
} }
@@ -100,7 +100,7 @@ namespace Barotrauma
foreach (XElement subElement in orderElement.Elements()) foreach (XElement subElement in orderElement.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
SymbolSprite = new Sprite(subElement); SymbolSprite = new Sprite(subElement);
break; break;
} }
+2 -1
View File
@@ -121,7 +121,8 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() == "particleemitter") particleEmitterPrefab = new ParticleEmitterPrefab(subElement); if (subElement.Name.ToString().ToLowerInvariant() != "particleemitter") continue;
particleEmitterPrefab = new ParticleEmitterPrefab(subElement);
} }
} }
@@ -36,7 +36,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
Sprite = new Sprite(subElement); Sprite = new Sprite(subElement);
break; break;
@@ -37,7 +37,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
Sprite = new Sprite(subElement); Sprite = new Sprite(subElement);
break; break;
@@ -163,7 +163,7 @@ namespace Barotrauma
XElement ragdollElement = doc.Root.Element("ragdoll"); XElement ragdollElement = doc.Root.Element("ragdoll");
foreach (XElement limbElement in ragdollElement.Elements()) foreach (XElement limbElement in ragdollElement.Elements())
{ {
if (ToolBox.GetAttributeString(limbElement, "type", "").ToLower() != "head") continue; if (ToolBox.GetAttributeString(limbElement, "type", "").ToLowerInvariant() != "head") continue;
XElement spriteElement = limbElement.Element("sprite"); XElement spriteElement = limbElement.Element("sprite");
@@ -255,7 +255,7 @@ namespace Barotrauma
{ {
Name = ToolBox.GetAttributeString(element, "name", "unnamed"); Name = ToolBox.GetAttributeString(element, "name", "unnamed");
string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLower(); string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLowerInvariant();
gender = (genderStr == "m") ? Gender.Male : Gender.Female; gender = (genderStr == "m") ? Gender.Male : Gender.Female;
File = ToolBox.GetAttributeString(element, "file", ""); File = ToolBox.GetAttributeString(element, "file", "");
@@ -277,7 +277,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "job") continue; if (subElement.Name.ToString().ToLowerInvariant() != "job") continue;
Job = new Job(subElement); Job = new Job(subElement);
break; break;
+5 -3
View File
@@ -54,13 +54,13 @@ namespace Barotrauma
public Job(XElement element) public Job(XElement element)
{ {
string name = ToolBox.GetAttributeString(element, "name", "").ToLower(); string name = ToolBox.GetAttributeString(element, "name", "").ToLowerInvariant();
prefab = JobPrefab.List.Find(jp => jp.Name.ToLower() == name); prefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == name);
skills = new Dictionary<string, Skill>(); skills = new Dictionary<string, Skill>();
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "skill") continue; if (subElement.Name.ToString().ToLowerInvariant() != "skill") continue;
string skillName = ToolBox.GetAttributeString(subElement, "name", ""); string skillName = ToolBox.GetAttributeString(subElement, "name", "");
if (string.IsNullOrEmpty(name)) continue; if (string.IsNullOrEmpty(name)) continue;
skills.Add( skills.Add(
@@ -86,6 +86,8 @@ namespace Barotrauma
public void GiveJobItems(Character character, WayPoint spawnPoint) public void GiveJobItems(Character character, WayPoint spawnPoint)
{ {
if (SpawnItems == null) return;
foreach (XElement itemElement in SpawnItems.Elements()) foreach (XElement itemElement in SpawnItems.Elements())
{ {
InitializeJobItem(character, spawnPoint, itemElement); InitializeJobItem(character, spawnPoint, itemElement);
@@ -77,7 +77,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "items": case "items":
Items = subElement; Items = subElement;
+1 -1
View File
@@ -265,7 +265,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "sprite": case "sprite":
string spritePath = subElement.Attribute("texture").Value; string spritePath = subElement.Attribute("texture").Value;
+2 -2
View File
@@ -137,14 +137,14 @@ namespace Barotrauma
int n = 0; int n = 0;
foreach (XAttribute attribute in propertyAttributes) foreach (XAttribute attribute in propertyAttributes)
{ {
propertyNames[n] = attribute.Name.ToString().ToLower(); propertyNames[n] = attribute.Name.ToString().ToLowerInvariant();
propertyEffects[n] = ToolBox.GetAttributeObject(attribute); propertyEffects[n] = ToolBox.GetAttributeObject(attribute);
n++; n++;
} }
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "explosion": case "explosion":
explosion = new Explosion(subElement); explosion = new Explosion(subElement);
+7 -7
View File
@@ -146,7 +146,7 @@ namespace Barotrauma
if (command == "") return; if (command == "") return;
string[] commands = command.Split(' '); string[] commands = command.Split(' ');
switch (commands[0].ToLower()) switch (commands[0].ToLowerInvariant())
{ {
case "help": case "help":
NewMessage("menu: go to main menu", Color.Cyan); NewMessage("menu: go to main menu", Color.Cyan);
@@ -203,7 +203,7 @@ namespace Barotrauma
if (commands.Length > 2) if (commands.Length > 2)
{ {
switch (commands[2].ToLower()) switch (commands[2].ToLowerInvariant())
{ {
case "inside": case "inside":
spawnPoint = WayPoint.GetRandom(SpawnType.Human); spawnPoint = WayPoint.GetRandom(SpawnType.Human);
@@ -233,19 +233,19 @@ namespace Barotrauma
} }
break; break;
default: default:
spawnPoint = WayPoint.GetRandom(commands[1].ToLower()=="human" ? SpawnType.Human : SpawnType.Enemy); spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy);
break; break;
} }
} }
else else
{ {
spawnPoint = WayPoint.GetRandom(commands[1].ToLower() == "human" ? SpawnType.Human : SpawnType.Enemy); spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
} }
spawnPosition = spawnPoint == null ? Vector2.Zero : spawnPoint.WorldPosition; spawnPosition = spawnPoint == null ? Vector2.Zero : spawnPoint.WorldPosition;
if (commands[1].ToLower()=="human") if (commands[1].ToLowerInvariant()=="human")
{ {
spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition); spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition);
Character.Controlled = spawnedCharacter; Character.Controlled = spawnedCharacter;
@@ -315,8 +315,8 @@ namespace Barotrauma
case "controlcharacter": case "controlcharacter":
case "control": case "control":
if (commands.Length < 2) break; if (commands.Length < 2) break;
commands[1] = commands[1].ToLower(); commands[1] = commands[1].ToLowerInvariant();
Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLower() == commands[1]); Character.Controlled = Character.CharacterList.Find(c => !c.IsNetworkPlayer && c.Name.ToLowerInvariant() == commands[1]);
break; break;
case "godmode": case "godmode":
Submarine.Loaded.GodMode = !Submarine.Loaded.GodMode; Submarine.Loaded.GodMode = !Submarine.Loaded.GodMode;
+2 -2
View File
@@ -9,7 +9,7 @@ namespace Barotrauma
{ {
class Mission class Mission
{ {
private static List<Mission> list = new List<Mission>(); //private static List<Mission> list = new List<Mission>();
private string name; private string name;
@@ -86,7 +86,7 @@ namespace Barotrauma
headers = new List<string>(); headers = new List<string>();
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "message") continue; if (subElement.Name.ToString().ToLowerInvariant() != "message") continue;
headers.Add(ToolBox.GetAttributeString(subElement, "header", "")); headers.Add(ToolBox.GetAttributeString(subElement, "header", ""));
messages.Add(ToolBox.GetAttributeString(subElement, "text", "")); messages.Add(ToolBox.GetAttributeString(subElement, "text", ""));
} }
+1 -1
View File
@@ -73,7 +73,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "sprite": case "sprite":
Sprite sprite = new Sprite(subElement); Sprite sprite = new Sprite(subElement);
+2 -2
View File
@@ -24,14 +24,14 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
GUIComponentStyle componentStyle = new GUIComponentStyle(subElement); GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
componentStyles.Add(subElement.Name.ToString().ToLower(), componentStyle); componentStyles.Add(subElement.Name.ToString().ToLowerInvariant(), componentStyle);
} }
} }
public void Apply(GUIComponent targetComponent, GUIComponent parent = null) public void Apply(GUIComponent targetComponent, GUIComponent parent = null)
{ {
GUIComponentStyle componentStyle = null; GUIComponentStyle componentStyle = null;
string name = (parent==null) ? targetComponent.GetType().Name.ToLower() : parent.GetType().Name.ToLower(); string name = (parent == null) ? targetComponent.GetType().Name.ToLowerInvariant() : parent.GetType().Name.ToLowerInvariant();
componentStyles.TryGetValue(name, out componentStyle); componentStyles.TryGetValue(name, out componentStyle);
if (componentStyle==null) if (componentStyle==null)
+1 -1
View File
@@ -57,7 +57,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower()!="character") continue; if (subElement.Name.ToString().ToLowerInvariant() != "character") continue;
characterInfos.Add(new CharacterInfo(subElement)); characterInfos.Add(new CharacterInfo(subElement));
} }
@@ -89,7 +89,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "crew") continue; if (subElement.Name.ToString().ToLowerInvariant() != "crew") continue;
GameMain.GameSession.CrewManager = new CrewManager(subElement); GameMain.GameSession.CrewManager = new CrewManager(subElement);
} }
@@ -36,7 +36,7 @@ namespace Barotrauma.Tutorials
public virtual void Initialize() public virtual void Initialize()
{ {
GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameModePreset.list.Find(gm => gm.Name.ToLower() == "tutorial")); GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameModePreset.list.Find(gm => gm.Name.ToLowerInvariant() == "tutorial"));
(GameMain.GameSession.gameMode as TutorialMode).tutorialType = this; (GameMain.GameSession.gameMode as TutorialMode).tutorialType = this;
GameMain.GameSession.StartShift("tuto1"); GameMain.GameSession.StartShift("tuto1");
@@ -58,7 +58,7 @@ namespace Barotrauma.Tutorials
CharacterInfo charInfo = new CharacterInfo(Character.HumanConfigFile, "", Gender.None, JobPrefab.List.Find(jp => jp.Name == "Engineer")); CharacterInfo charInfo = new CharacterInfo(Character.HumanConfigFile, "", Gender.None, JobPrefab.List.Find(jp => jp.Name == "Engineer"));
character = Character.Create(charInfo, wayPoint.WorldPosition); character = Character.Create(charInfo, wayPoint.WorldPosition, false, false);
Character.Controlled = character; Character.Controlled = character;
character.GiveJobItems(null); character.GiveJobItems(null);
+1 -1
View File
@@ -96,7 +96,7 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "gamemode") continue; if (subElement.Name.ToString().ToLowerInvariant() != "gamemode") continue;
gameMode = new SinglePlayerMode(subElement); gameMode = new SinglePlayerMode(subElement);
} }
@@ -25,7 +25,7 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
string infoName = subElement.Name.ToString().ToLower(); string infoName = subElement.Name.ToString().ToLowerInvariant();
List<string> infoList = null; List<string> infoList = null;
if (!infoTexts.TryGetValue(infoName, out infoList)) if (!infoTexts.TryGetValue(infoName, out infoList))
{ {
@@ -40,7 +40,7 @@ namespace Barotrauma
public static string GetInfoText(string infoName) public static string GetInfoText(string infoName)
{ {
List<string> infoList = null; List<string> infoList = null;
if (!infoTexts.TryGetValue(infoName.ToLower(), out infoList) || !infoList.Any()) if (!infoTexts.TryGetValue(infoName.ToLowerInvariant(), out infoList) || !infoList.Any())
{ {
#if DEBUG #if DEBUG
return "Info text ''" + infoName + "'' not found"; return "Info text ''" + infoName + "'' not found";
+1 -1
View File
@@ -171,7 +171,7 @@ namespace Barotrauma
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "contentpackage": case "contentpackage":
string path = ToolBox.GetAttributeString(subElement, "path", ""); string path = ToolBox.GetAttributeString(subElement, "path", "");
+1 -1
View File
@@ -127,7 +127,7 @@ namespace Barotrauma.Items.Components
// isOpen = false; // isOpen = false;
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "sprite": case "sprite":
doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile)); doorSprite = new Sprite(subElement, Path.GetDirectoryName(item.Prefab.ConfigFile));
@@ -44,7 +44,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "attack") continue; if (subElement.Name.ToString().ToLowerInvariant() != "attack") continue;
attack = new Attack(subElement); attack = new Attack(subElement);
} }
} }
@@ -39,7 +39,7 @@ namespace Barotrauma.Items.Components
InvSlotType allowedSlot = InvSlotType.None; InvSlotType allowedSlot = InvSlotType.None;
foreach (string slot in slots) foreach (string slot in slots)
{ {
if (slot.ToLower()=="bothhands") if (slot.ToLowerInvariant() == "bothhands")
{ {
allowedSlot = InvSlotType.LeftHand | InvSlotType.RightHand; allowedSlot = InvSlotType.LeftHand | InvSlotType.RightHand;
} }
@@ -30,7 +30,7 @@ namespace Barotrauma.Items.Components
public Propulsion(Item item, XElement element) public Propulsion(Item item, XElement element)
: base(item,element) : base(item,element)
{ {
switch (ToolBox.GetAttributeString(element, "usablein", "air").ToLower()) switch (ToolBox.GetAttributeString(element, "usablein", "air").ToLowerInvariant())
{ {
case "air": case "air":
usableIn = ParticlePrefab.DrawTargetType.Air; usableIn = ParticlePrefab.DrawTargetType.Air;
@@ -83,7 +83,7 @@ namespace Barotrauma.Items.Components
fixableEntities = new List<string>(); fixableEntities = new List<string>();
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "fixable": case "fixable":
fixableEntities.Add(subElement.Attribute("name").Value); fixableEntities.Add(subElement.Attribute("name").Value);
@@ -221,7 +221,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "requireditem": case "requireditem":
case "requireditems": case "requireditems":
@@ -395,7 +395,7 @@ namespace Barotrauma.Items.Components
if (sound.VolumeProperty == "") return 1.0f; if (sound.VolumeProperty == "") return 1.0f;
ObjectProperty op = null; ObjectProperty op = null;
if (properties.TryGetValue(sound.VolumeProperty.ToLower(), out op)) if (properties.TryGetValue(sound.VolumeProperty.ToLowerInvariant(), out op))
{ {
float newVolume = 0.0f; float newVolume = 0.0f;
try try
@@ -682,7 +682,7 @@ namespace Barotrauma.Items.Components
foreach (XAttribute attribute in componentElement.Attributes()) foreach (XAttribute attribute in componentElement.Attributes())
{ {
ObjectProperty property = null; ObjectProperty property = null;
if (!properties.TryGetValue(attribute.Name.ToString().ToLower(), out property)) continue; if (!properties.TryGetValue(attribute.Name.ToString().ToLowerInvariant(), out property)) continue;
property.TrySetValue(attribute.Value); property.TrySetValue(attribute.Value);
} }
@@ -692,7 +692,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in componentElement.Elements()) foreach (XElement subElement in componentElement.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "requireditem": case "requireditem":
RelatedItem newRequiredItem = RelatedItem.Load(subElement); RelatedItem newRequiredItem = RelatedItem.Load(subElement);
@@ -717,7 +717,7 @@ namespace Barotrauma.Items.Components
public static ItemComponent Load(XElement element, Item item, string file, bool errorMessages = true) public static ItemComponent Load(XElement element, Item item, string file, bool errorMessages = true)
{ {
Type t; Type t;
string type = element.Name.ToString().ToLower(); string type = element.Name.ToString().ToLowerInvariant();
try try
{ {
// Get the type of a specified class. // Get the type of a specified class.
@@ -101,7 +101,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "containable": case "containable":
RelatedItem containable = RelatedItem.Load(subElement); RelatedItem containable = RelatedItem.Load(subElement);
@@ -62,7 +62,7 @@ namespace Barotrauma.Items.Components
{ {
if (deconstructProduct.RequireFullCondition && targetItem.Condition < 100.0f) continue; if (deconstructProduct.RequireFullCondition && targetItem.Condition < 100.0f) continue;
var itemPrefab = ItemPrefab.list.FirstOrDefault(ip => ip.Name.ToLower() == deconstructProduct.ItemPrefabName.ToLower()) as ItemPrefab; var itemPrefab = ItemPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab;
if (itemPrefab==null) if (itemPrefab==null)
{ {
DebugConsole.ThrowError("Tried to deconstruct item ''"+targetItem.Name+"'' but couldn't find item prefab ''"+deconstructProduct+"''!"); DebugConsole.ThrowError("Tried to deconstruct item ''"+targetItem.Name+"'' but couldn't find item prefab ''"+deconstructProduct+"''!");
@@ -22,7 +22,7 @@ namespace Barotrauma.Items.Components
{ {
string name = ToolBox.GetAttributeString(element, "name", ""); string name = ToolBox.GetAttributeString(element, "name", "");
TargetItem = ItemPrefab.list.Find(ip => ip.Name.ToLower() == name.ToLower()) as ItemPrefab; TargetItem = ItemPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == name.ToLowerInvariant()) as ItemPrefab;
if (TargetItem == null) if (TargetItem == null)
{ {
DebugConsole.ThrowError("Error in fabricable item "+name+"! Item ''" + element.Name + "'' not found."); DebugConsole.ThrowError("Error in fabricable item "+name+"! Item ''" + element.Name + "'' not found.");
@@ -40,7 +40,7 @@ namespace Barotrauma.Items.Components
{ {
if (string.IsNullOrWhiteSpace(requiredItemName)) continue; if (string.IsNullOrWhiteSpace(requiredItemName)) continue;
ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLower() == requiredItemName.Trim().ToLower()) as ItemPrefab; ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == requiredItemName.Trim().ToLowerInvariant()) as ItemPrefab;
if (requiredItem == null) if (requiredItem == null)
{ {
DebugConsole.ThrowError("Error in fabricable item " + name + "! Required item ''" + requiredItemName + "'' not found."); DebugConsole.ThrowError("Error in fabricable item " + name + "! Required item ''" + requiredItemName + "'' not found.");
@@ -64,7 +64,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "requiredskill": case "requiredskill":
RequiredSkills.Add(new Skill( RequiredSkills.Add(new Skill(
@@ -42,7 +42,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "pingcircle": case "pingcircle":
pingCircle = new Sprite(subElement); pingCircle = new Sprite(subElement);
@@ -401,7 +401,7 @@ namespace Barotrauma.Items.Components
public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective) public override bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
{ {
switch (objective.Option.ToLower()) switch (objective.Option.ToLowerInvariant())
{ {
case "power up": case "power up":
float tempDiff = load - temperature; float tempDiff = load - temperature;
@@ -188,7 +188,7 @@ namespace Barotrauma.Items.Components
{ {
base.ReceiveSignal(stepsTaken, signal, connection, sender, power); base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
if (connection.Name.Length > 5 && connection.Name.Substring(0, 6).ToLower() == "signal") if (connection.Name.Length > 5 && connection.Name.Substring(0, 6).ToLowerInvariant() == "signal")
{ {
connection.SendSignal(stepsTaken, signal, sender, 0.0f); connection.SendSignal(stepsTaken, signal, sender, 0.0f);
} }
@@ -54,7 +54,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "attack") continue; if (subElement.Name.ToString().ToLowerInvariant() != "attack") continue;
attack = new Attack(subElement); attack = new Attack(subElement);
} }
@@ -87,7 +87,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "link": case "link":
int index = -1; int index = -1;
@@ -93,7 +93,7 @@ namespace Barotrauma.Items.Components
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
light.LightSprite = new Sprite(subElement); light.LightSprite = new Sprite(subElement);
light.LightSprite.Origin = light.LightSprite.size / 2.0f; light.LightSprite.Origin = light.LightSprite.size / 2.0f;
break; break;
+2 -2
View File
@@ -187,7 +187,7 @@ namespace Barotrauma.Items.Components
{ {
var projectiles = GetLoadedProjectiles(); var projectiles = GetLoadedProjectiles();
if (projectiles.Count==0 || (projectiles.Count==1 && objective.Option.ToLower()!="fire at will")) if (projectiles.Count == 0 || (projectiles.Count == 1 && objective.Option.ToLowerInvariant() != "fire at will"))
{ {
ItemContainer container = null; ItemContainer container = null;
foreach (MapEntity e in item.linkedTo) foreach (MapEntity e in item.linkedTo)
@@ -272,7 +272,7 @@ namespace Barotrauma.Items.Components
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null); var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null);
if (pickedBody != null && !(pickedBody.UserData is Limb)) return false; if (pickedBody != null && !(pickedBody.UserData is Limb)) return false;
if (objective.Option.ToLower()=="fire at will") Use(deltaTime, character); if (objective.Option.ToLowerInvariant() == "fire at will") Use(deltaTime, character);
return false; return false;
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "skill": case "skill":
string skillName = ToolBox.GetAttributeString(subElement, "name", ""); string skillName = ToolBox.GetAttributeString(subElement, "name", "");
+2 -2
View File
@@ -343,7 +343,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "body": case "body":
body = new PhysicsBody(subElement, ConvertUnits.ToSimUnits(Position)); body = new PhysicsBody(subElement, ConvertUnits.ToSimUnits(Position));
@@ -535,7 +535,7 @@ namespace Barotrauma
{ {
if (tag == null) return true; if (tag == null) return true;
return (tags.Contains(tag) || tags.Contains(tag.ToLower())); return (tags.Contains(tag) || tags.Contains(tag.ToLowerInvariant()));
} }
+3 -3
View File
@@ -184,7 +184,7 @@ namespace Barotrauma
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return; if (doc == null) return;
if (doc.Root.Name.ToString().ToLower() == "item") if (doc.Root.Name.ToString().ToLowerInvariant() == "item")
{ {
new ItemPrefab(doc.Root, filePath); new ItemPrefab(doc.Root, filePath);
} }
@@ -192,7 +192,7 @@ namespace Barotrauma
{ {
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
if (element.Name.ToString().ToLower() != "item") continue; if (element.Name.ToString().ToLowerInvariant() != "item") continue;
new ItemPrefab(element, filePath); new ItemPrefab(element, filePath);
} }
@@ -253,7 +253,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLower()) switch (subElement.Name.ToString().ToLowerInvariant())
{ {
case "sprite": case "sprite":
string spriteFolder = ""; string spriteFolder = "";
+1 -1
View File
@@ -148,7 +148,7 @@ namespace Barotrauma
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "statuseffect") continue; if (subElement.Name.ToString().ToLowerInvariant() != "statuseffect") continue;
ri.statusEffects.Add(StatusEffect.Load(subElement)); ri.statusEffects.Add(StatusEffect.Load(subElement));
} }
+2 -2
View File
@@ -69,11 +69,11 @@ namespace Barotrauma
hireableJobs = new List<Tuple<JobPrefab, float>>(); hireableJobs = new List<Tuple<JobPrefab, float>>();
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "hireable") continue; if (subElement.Name.ToString().ToLowerInvariant() != "hireable") continue;
string jobName = ToolBox.GetAttributeString(subElement, "name", ""); string jobName = ToolBox.GetAttributeString(subElement, "name", "");
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName.ToLower()); JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == jobName.ToLowerInvariant());
if (jobPrefab==null) if (jobPrefab==null)
{ {
DebugConsole.ThrowError("Invalid job name ("+jobName+") in location type "+name); DebugConsole.ThrowError("Invalid job name ("+jobName+") in location type "+name);
+4 -4
View File
@@ -223,8 +223,8 @@ namespace Barotrauma
private bool EnterAssignedJob(GUITextBox textBox, string text) private bool EnterAssignedJob(GUITextBox textBox, string text)
{ {
string trimmedName = text.ToLower().Trim(); string trimmedName = text.ToLowerInvariant().Trim();
assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == trimmedName); assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == trimmedName);
if (assignedJob !=null && trimmedName!="none") if (assignedJob !=null && trimmedName!="none")
{ {
@@ -757,10 +757,10 @@ namespace Barotrauma
w.IdCardTags = idCardTagString.Split(','); w.IdCardTags = idCardTagString.Split(',');
} }
string jobName = ToolBox.GetAttributeString(element, "job", "").ToLower(); string jobName = ToolBox.GetAttributeString(element, "job", "").ToLowerInvariant();
if (!string.IsNullOrWhiteSpace(jobName)) if (!string.IsNullOrWhiteSpace(jobName))
{ {
w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName); w.assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == jobName);
} }
w.ladderId = (ushort)ToolBox.GetAttributeInt(element, "ladders", 0); w.ladderId = (ushort)ToolBox.GetAttributeInt(element, "ladders", 0);
+1 -1
View File
@@ -975,7 +975,7 @@ namespace Barotrauma.Networking
} }
else else
{ {
string command = ChatMessage.GetChatMessageCommand(message, out message).ToLower(); string command = ChatMessage.GetChatMessageCommand(message, out message).ToLowerInvariant();
if (command=="r" || command=="radio" && CanUseRadio(Character.Controlled)) type = ChatMessageType.Radio; if (command=="r" || command=="radio" && CanUseRadio(Character.Controlled)) type = ChatMessageType.Radio;
} }
+6 -6
View File
@@ -1144,10 +1144,10 @@ namespace Barotrauma.Networking
public void KickPlayer(string playerName, bool ban = false) public void KickPlayer(string playerName, bool ban = false)
{ {
playerName = playerName.ToLower(); playerName = playerName.ToLowerInvariant();
Client client = ConnectedClients.Find( c => c.name.ToLower() == playerName || Client client = ConnectedClients.Find(c => c.name.ToLowerInvariant() == playerName ||
(c.Character != null && c.Character.Name.ToLower() == playerName)); (c.Character != null && c.Character.Name.ToLowerInvariant() == playerName));
if (client == null) return; if (client == null) return;
@@ -1434,7 +1434,7 @@ namespace Barotrauma.Networking
ChatMessageType type = gameStarted && myCharacter != null ? ChatMessageType.Default : ChatMessageType.Server; ChatMessageType type = gameStarted && myCharacter != null ? ChatMessageType.Default : ChatMessageType.Server;
string command = ChatMessage.GetChatMessageCommand(message, out message).ToLower(); string command = ChatMessage.GetChatMessageCommand(message, out message).ToLowerInvariant();
if (command=="dead" || command=="d") if (command=="dead" || command=="d")
{ {
@@ -1447,8 +1447,8 @@ namespace Barotrauma.Networking
else if (command != "") else if (command != "")
{ {
targetClient = ConnectedClients.Find(c => targetClient = ConnectedClients.Find(c =>
command == c.name.ToLower() || command == c.name.ToLowerInvariant() ||
c.Character != null && command == c.Character.Name.ToLower()); (c.Character != null && command == c.Character.Name.ToLowerInvariant()));
if (targetClient == null) if (targetClient == null)
{ {
@@ -51,7 +51,7 @@ namespace Barotrauma.Particles
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
if (subElement.Name.ToString().ToLower() != "sprite") continue; if (subElement.Name.ToString().ToLowerInvariant() != "sprite") continue;
Sprites.Add(new Sprite(subElement)); Sprites.Add(new Sprite(subElement));
} }
@@ -140,7 +140,7 @@ namespace Barotrauma.Particles
RotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false); RotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false);
switch (ToolBox.GetAttributeString(element, "drawtarget", "air").ToLower()) switch (ToolBox.GetAttributeString(element, "drawtarget", "air").ToLowerInvariant())
{ {
case "air": case "air":
default: default:
+5 -5
View File
@@ -82,7 +82,7 @@ namespace Barotrauma
} }
else if (property.PropertyType == typeof(bool)) else if (property.PropertyType == typeof(bool))
{ {
propertyInfo.SetValue(obj, (value.ToLower() == "true"), null); propertyInfo.SetValue(obj, (value.ToLowerInvariant() == "true"), null);
} }
else if (property.PropertyType == typeof(int)) else if (property.PropertyType == typeof(int))
{ {
@@ -201,7 +201,7 @@ namespace Barotrauma
foreach (var property in properties) foreach (var property in properties)
{ {
dictionary.Add(property.Name.ToLower(), new ObjectProperty(property, obj)); dictionary.Add(property.Name.ToLowerInvariant(), new ObjectProperty(property, obj));
} }
return dictionary; return dictionary;
@@ -221,7 +221,7 @@ namespace Barotrauma
foreach (var property in properties) foreach (var property in properties)
{ {
ObjectProperty objProperty = new ObjectProperty(property, obj); ObjectProperty objProperty = new ObjectProperty(property, obj);
dictionary.Add(property.Name.ToLower(), objProperty); dictionary.Add(property.Name.ToLowerInvariant(), objProperty);
//set the value of the property to the default value if there is one //set the value of the property to the default value if there is one
foreach (var ini in property.Attributes.OfType<HasDefaultValue>()) foreach (var ini in property.Attributes.OfType<HasDefaultValue>())
@@ -238,7 +238,7 @@ namespace Barotrauma
foreach (XAttribute attribute in element.Attributes()) foreach (XAttribute attribute in element.Attributes())
{ {
ObjectProperty property = null; ObjectProperty property = null;
if (!dictionary.TryGetValue(attribute.Name.ToString().ToLower(), out property)) continue; if (!dictionary.TryGetValue(attribute.Name.ToString().ToLowerInvariant(), out property)) continue;
if (!property.Attributes.OfType<HasDefaultValue>().Any()) continue; if (!property.Attributes.OfType<HasDefaultValue>().Any()) continue;
property.TrySetValue(attribute.Value); property.TrySetValue(attribute.Value);
} }
@@ -279,7 +279,7 @@ namespace Barotrauma
stringValue = value.ToString(); stringValue = value.ToString();
} }
element.Add(new XAttribute(property.Name.ToLower(), stringValue)); element.Add(new XAttribute(property.Name.ToLowerInvariant(), stringValue));
} }
} }
} }
+1 -2
View File
@@ -179,7 +179,7 @@ namespace Barotrauma
GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision; GameMain.LightManager.ObstructVision = Character.Controlled != null && Character.Controlled.ObstructVision;
GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam); GameMain.LightManager.UpdateLightMap(graphics, spriteBatch, cam);
if (Character.Controlled!=null) if (Character.Controlled != null)
{ {
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition); GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
} }
@@ -194,7 +194,6 @@ namespace Barotrauma
if (Level.Loaded == null) if (Level.Loaded == null)
{ {
graphics.Clear(new Color(11, 18, 26, 255)); graphics.Clear(new Color(11, 18, 26, 255));
} }
else else
{ {
+1 -1
View File
@@ -385,7 +385,7 @@ namespace Barotrauma
XElement modeElement = null; XElement modeElement = null;
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
if (element.Name.ToString().ToLower() != "gamemode") continue; if (element.Name.ToString().ToLowerInvariant() != "gamemode") continue;
modeElement = element; modeElement = element;
break; break;
@@ -142,7 +142,7 @@ namespace Barotrauma
return; return;
} }
if (masterServerData.Substring(0,5).ToLower()=="error") if (masterServerData.Substring(0, 5).ToLowerInvariant() == "error")
{ {
DebugConsole.ThrowError("Error while connecting to master server ("+masterServerData+")!"); DebugConsole.ThrowError("Error while connecting to master server ("+masterServerData+")!");
+1 -1
View File
@@ -122,7 +122,7 @@ namespace Barotrauma
foreach (XElement element in xMusic) foreach (XElement element in xMusic)
{ {
string file = ToolBox.GetAttributeString(element, "file", ""); string file = ToolBox.GetAttributeString(element, "file", "");
string type = ToolBox.GetAttributeString(element, "type", "").ToLower(); string type = ToolBox.GetAttributeString(element, "type", "").ToLowerInvariant();
Vector2 priority = ToolBox.GetAttributeVector2(element, "priorityrange", new Vector2(0.0f, 100.0f)); Vector2 priority = ToolBox.GetAttributeVector2(element, "priorityrange", new Vector2(0.0f, 100.0f));
musicClips[i] = new BackgroundMusic(file, type, priority); musicClips[i] = new BackgroundMusic(file, type, priority);
+2 -2
View File
@@ -87,7 +87,7 @@ namespace Barotrauma
} }
else else
{ {
string lowerTrimmedVal = value.ToLower().Trim(); string lowerTrimmedVal = value.ToLowerInvariant().Trim();
if (lowerTrimmedVal == "true") if (lowerTrimmedVal == "true")
{ {
return true; return true;
@@ -186,7 +186,7 @@ namespace Barotrauma
{ {
if (attribute == null) return defaultValue; if (attribute == null) return defaultValue;
string val = attribute.Value.ToLower().Trim(); string val = attribute.Value.ToLowerInvariant().Trim();
if (val == "true") if (val == "true")
{ {
return true; return true;