Style: Indent catch and switch properly.

This commit is contained in:
UnknownShadow200 2016-12-02 15:31:34 +11:00
parent 619ebafca1
commit 75f0a73841
28 changed files with 41 additions and 41 deletions

View File

@ -424,7 +424,7 @@ namespace ClassicalSharp.Gui.Screens {
void OpenUrl(WarningScreen screen) {
try {
Process.Start((string)screen.Metadata);
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("ChatScreen.OpenUrl", ex);
}
}

View File

@ -76,7 +76,7 @@ namespace ClassicalSharp.Gui.Screens {
LocationUpdate update = LocationUpdate.MakePosAndOri(p.Spawn, p.SpawnYaw, p.SpawnPitch, false);
p.SetLocation(update, false);
}
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("loading map", ex);
string file = Path.GetFileName(path);
game.Chat.Add("&e/client loadmap: Failed to load map \"" + file + "\"");

View File

@ -140,7 +140,7 @@ namespace ClassicalSharp.Gui.Screens {
else exporter = new MapSchematicExporter();
exporter.Save(fs, game);
}
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("saving map", ex);
MakeDescWidget("&cError while trying to save map");
return;

View File

@ -190,7 +190,7 @@ namespace ClassicalSharp {
int b = Utils.ParseHex(input[i + 4]) * 16 + Utils.ParseHex(input[i + 5]);
value = new FastColour(r, g, b);
return true;
} catch(FormatException) {
} catch (FormatException) {
return false;
}
}

View File

@ -414,7 +414,7 @@ namespace ClassicalSharp.Gui.Widgets {
string text = null;
try {
text = game.window.ClipboardText.Trim(trimChars);
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("Paste from clipboard", ex);
const string warning = "&cError while trying to paste from clipboard.";
game.Chat.Add(warning, MessageType.ClientStatus4);
@ -428,7 +428,7 @@ namespace ClassicalSharp.Gui.Widgets {
if (Text.Empty) return true;
try {
game.window.ClipboardText = Text.ToString();
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("Copy to clipboard", ex);
const string warning = "&cError while trying to copy to clipboard.";
game.Chat.Add(warning, MessageType.ClientStatus4);

View File

@ -79,7 +79,7 @@ namespace ClassicalSharp.Audio {
try {
output.PlayRawAsync(chunk);
} catch(InvalidOperationException ex) {
} catch (InvalidOperationException ex) {
HandleSoundError(ex);
}
return;

View File

@ -73,10 +73,10 @@ namespace ClassicalSharp.Audio {
OggContainer container = new OggContainer(fs);
try {
musicOut.PlayStreaming(container);
} catch(InvalidOperationException ex) {
} catch (InvalidOperationException ex) {
HandleMusicError(ex);
return;
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("AudioPlayer.DoMusicThread()", ex);
game.Chat.Add("&cError while trying to play music file " + Path.GetFileName(file));
}

View File

@ -28,7 +28,7 @@ namespace ClassicalSharp {
void GetTextureRegion(byte block, int side, out Vector2 min, out Vector2 max) {
min = Vector2.Zero; max = Vector2.One;
Vector3 bbMin = MinBB[block], bbMax = MaxBB[block];
switch(side) {
switch (side) {
case Side.Left:
case Side.Right:
min = new Vector2(bbMin.Z, bbMin.Y);

View File

@ -141,7 +141,7 @@ namespace ClassicalSharp {
FileStream stream = null;
try {
stream = File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read);
} catch(IOException ex) {
} catch (IOException ex) {
int hresult = Marshal.GetHRForException(ex);
uint errorCode = (uint)hresult & 0xFFFF;
if (errorCode != 32) // ERROR_SHARING_VIOLATION

View File

@ -192,7 +192,7 @@ namespace ClassicalSharp {
try {
using (Font f = new Font(FontName, 16)) { }
} catch(Exception) {
} catch (Exception) {
FontName = "Arial";
Options.Set(OptionsKey.FontName, "Arial");
}

View File

@ -26,7 +26,7 @@ namespace ClassicalSharp.Generator {
SinglePlayerServer server = (SinglePlayerServer)game.Server;
try {
server.generatedMap = Generate(width, height, length, seed);
} catch(Exception ex) {
} catch (Exception ex) {
ErrorHandler.LogError("IMapGenerator.RunAsync", ex);
}
Done = true;

View File

@ -41,7 +41,7 @@ namespace ClassicalSharp.GraphicsAPI {
PresentParameters args = GetPresentArgs(640, 480);
try {
device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args);
} catch(SharpDXException) {
} catch (SharpDXException) {
createFlags = CreateFlags.MixedVertexProcessing;
try {
device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args);

View File

@ -95,7 +95,7 @@ namespace Ionic.Zlib
}
last = bits & 0x1;
switch((bits & 0x7) >> 1) {
switch ((bits & 0x7) >> 1) {
case 0: // stored
bits >>= 3; bitsNum -= 3;
t = bitsNum & 7; // go to byte boundary

View File

@ -72,7 +72,7 @@ namespace ClassicalSharp.Map {
void ReadClassData(FieldDescription[] fields) {
for (int i = 0; i < fields.Length; i++) {
switch(fields[i].Type) {
switch (fields[i].Type) {
case FieldType.Byte:
fields[i].Value = reader.ReadByte(); break;
case FieldType.Float:

View File

@ -92,7 +92,7 @@ namespace ClassicalSharp.Map {
tag.Name = readTagName ? ReadString() : null;
tag.TagId = (NbtTagType)typeId;
switch((NbtTagType)typeId) {
switch ((NbtTagType)typeId) {
case NbtTagType.Int8:
tag.Value = reader.ReadByte(); break;
case NbtTagType.Int16:

View File

@ -282,7 +282,7 @@ namespace ClassicalSharp {
protected bool IsLit(int x, int y, int z, int face, byte type) {
int offset = (info.LightOffset[type] >> face) & 1;
switch(face) {
switch (face) {
case Side.Left:
return x < offset || y > lighting.heightmap[(z * width) + (x - offset)];
case Side.Right:

View File

@ -42,7 +42,7 @@ namespace ClassicalSharp.Network {
socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try {
socket.Connect(address, port);
} catch(SocketException ex) {
} catch (SocketException ex) {
ErrorHandler.LogError("connecting to server", ex);
game.Disconnect("&eUnable to reach " + address + ":" + port,
"Unable to establish an underlying connection");
@ -91,7 +91,7 @@ namespace ClassicalSharp.Network {
try {
reader.ReadPendingData();
} catch(SocketException ex) {
} catch (SocketException ex) {
ErrorHandler.LogError("reading packets", ex);
game.Disconnect("&eLost connection to the server", "I/O error when reading packets");
Dispose();
@ -142,7 +142,7 @@ namespace ClassicalSharp.Network {
}
try {
writer.Send();
} catch(SocketException) {
} catch (SocketException) {
// NOTE: Not immediately disconnecting, as otherwise we sometimes miss out on kick messages
writer.index = 0;
}

View File

@ -117,7 +117,7 @@ namespace ClassicalSharp.Network.Protocols {
byte id = reader.ReadUInt8();
CustomModel model = null;
switch(reader.ReadUInt8()) {
switch (reader.ReadUInt8()) {
case 0:
model = new CustomModel(game);
model.ReadSetupPacket(reader);

View File

@ -325,7 +325,7 @@ namespace ClassicalSharp.Network.Protocols {
WorldEnv env = game.World.Env;
Utils.Clamp(ref value, short.MinValue, short.MaxValue);
switch(type) {
switch (type) {
case 0:
Utils.Clamp(ref value, byte.MinValue, byte.MaxValue);
env.SetSidesBlock((byte)value); break;

View File

@ -207,7 +207,7 @@ namespace ClassicalSharp.Network {
lastModified = response.LastModified;
value = DownloadContent(request, response);
}
} catch(Exception ex) {
} catch (Exception ex) {
if (!(ex is WebException || ex is ArgumentException || ex is UriFormatException || ex is IOException)) throw;
if (ex is WebException) {
@ -271,7 +271,7 @@ namespace ClassicalSharp.Network {
int height = bmp.Height;
}
return value;
} catch(ArgumentException) {
} catch (ArgumentException) {
Utils.LogDebug("Failed to download from: " + url);
return null;
}

View File

@ -18,7 +18,7 @@ namespace ClassicalSharp.Network {
int partsRead;
public bool ReadHeader(Stream s) {
switch(state) {
switch (state) {
case State.Header1:
if (!ReadAndCheckHeaderByte(s, 0x1F))

View File

@ -104,7 +104,7 @@ namespace ClassicalSharp {
try {
File.Copy(files[i], dst);
File.Delete(files[i]);
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("Program.CopyFiles()", ex);
}
}

View File

@ -42,7 +42,7 @@ namespace ClassicalSharp.Textures {
}
}
return true;
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("loading " + file, ex);
return false;
}
@ -61,7 +61,7 @@ namespace ClassicalSharp.Textures {
writer.WriteLine(Entries[i]);
}
return true;
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("saving " + file, ex);
return false;
}

View File

@ -26,7 +26,7 @@ namespace ClassicalSharp.Textures {
try {
return File.OpenRead(path);
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("Cache.GetData", ex);
return null;
}
@ -74,7 +74,7 @@ namespace ClassicalSharp.Textures {
using (FileStream fs = File.Create(path))
Platform.WriteBmp(bmp, fs);
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("Cache.AddToCache", ex);
}
}
@ -88,7 +88,7 @@ namespace ClassicalSharp.Textures {
Directory.CreateDirectory(basePath);
File.WriteAllBytes(path, data);
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("Cache.AddToCache", ex);
}
}

View File

@ -114,10 +114,10 @@ namespace ClassicalSharp.Textures {
static Bitmap GetBitmap(FileStream fs) {
try {
return Platform.ReadBmp(fs);
} catch(ArgumentException ex) {
} catch (ArgumentException ex) {
ErrorHandler.LogError("Cache.GetBitmap", ex);
return null;
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("Cache.GetBitmap", ex);
return null;
}

View File

@ -62,7 +62,7 @@ namespace ClassicalSharp {
w.WriteLine();
}
}
} catch(Exception) {
} catch (Exception) {
wroteToCrashLog = false;
}
@ -95,7 +95,7 @@ namespace ClassicalSharp {
writer.WriteLine(text);
writer.WriteLine();
}
} catch(Exception) {
} catch (Exception) {
return false;
}
return true;

View File

@ -157,9 +157,9 @@ namespace ClassicalSharp {
using (StreamReader reader = new StreamReader(fs, false))
LoadFrom(reader);
return true;
} catch(FileNotFoundException) {
} catch (FileNotFoundException) {
return true;
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("loading options", ex);
return false;
}
@ -202,7 +202,7 @@ namespace ClassicalSharp {
OptionsChanged.Clear();
return true;
} catch(IOException ex) {
} catch (IOException ex) {
ErrorHandler.LogError("saving options", ex);
return false;
}

View File

@ -110,7 +110,7 @@ namespace ClassicalSharp {
T mapping;
try {
mapping = (T)Enum.Parse(typeof(T), value, true);
} catch(ArgumentException) {
} catch (ArgumentException) {
result = defValue;
return false;
}
@ -137,7 +137,7 @@ namespace ClassicalSharp {
internal static byte FastByte(string s) {
int sum = 0;
switch(s.Length) {
switch (s.Length) {
case 1: sum = (s[0] - '0'); break;
case 2: sum = (s[0] - '0') * 10 + (s[1] - '0'); break;
case 3: sum = (s[0] - '0') * 100 + (s[1] - '0') * 10 + (s[2] - '0'); break;