diff --git a/ClassicalSharp/Blocks/Block.cs b/ClassicalSharp/Blocks/Block.cs
index 0b5c630b8..513d0ac2c 100644
--- a/ClassicalSharp/Blocks/Block.cs
+++ b/ClassicalSharp/Blocks/Block.cs
@@ -75,13 +75,7 @@ namespace ClassicalSharp {
public const BlockRaw Pillar = 63;
public const BlockRaw Crate = 64;
public const BlockRaw StoneBrick = 65;
-#pragma warning restore 1591
-
- public const string RawNames = "Air Stone Grass Dirt Cobblestone Wood Sapling Bedrock Water StillWater Lava" +
- " StillLava Sand Gravel GoldOre IronOre CoalOre Log Leaves Sponge Glass Red Orange Yellow Lime Green" +
- " Teal Aqua Cyan Blue Indigo Violet Magenta Pink Black Gray White Dandelion Rose BrownMushroom RedMushroom" +
- " Gold Iron DoubleSlab Slab Brick TNT Bookshelf MossyRocks Obsidian CobblestoneSlab Rope Sandstone" +
- " Snow Fire LightPink ForestGreen Brown DeepBlue Turquoise Ice CeramicTile Magma Pillar Crate StoneBrick";
+#pragma warning restore 1591
/// Max block ID used in original classic.
public const BlockRaw MaxOriginalBlock = Block.Obsidian;
diff --git a/ClassicalSharp/Blocks/BlockInfo.cs b/ClassicalSharp/Blocks/BlockInfo.cs
index af4a5002b..455461778 100644
--- a/ClassicalSharp/Blocks/BlockInfo.cs
+++ b/ClassicalSharp/Blocks/BlockInfo.cs
@@ -228,6 +228,12 @@ namespace ClassicalSharp {
}
+ const string RawNames = "Air_Stone_Grass_Dirt_Cobblestone_Wood_Sapling_Bedrock_Water_Still water_Lava" +
+ "_Still lava_Sand_Gravel_Gold ore_Iron ore_Coal ore_Log_Leaves_Sponge_Glass_Red_Orange_Yellow_Lime_Green" +
+ "_Teal_Aqua_Cyan_Blue_Indigo_Violet_Magenta_Pink_Black_Gray_White_Dandelion_Rose_Brown mushroom_Red mushroom" +
+ "_Gold_Iron_Double slab_Slab_Brick_TNT_Bookshelf_Mossy rocks_Obsidian_Cobblestone slab_Rope_Sandstone" +
+ "_Snow_Fire_Light pink_Forest green_Brown_Deep blue_Turquoise_Ice_Ceramic tile_Magma_Pillar_Crate_Stone brick";
+
static StringBuffer buffer = new StringBuffer(64);
static string DefaultName(BlockID block) {
if (block >= Block.CpeCount) return "Invalid";
@@ -235,28 +241,15 @@ namespace ClassicalSharp {
// Find start and end of this particular block name
int start = 0;
for (int i = 0; i < block; i++)
- start = Block.RawNames.IndexOf(' ', start) + 1;
- int end = Block.RawNames.IndexOf(' ', start);
- if (end == -1) end = Block.RawNames.Length;
+ start = RawNames.IndexOf('_', start) + 1;
+ int end = RawNames.IndexOf('_', start);
+ if (end == -1) end = RawNames.Length;
buffer.Clear();
- SplitUppercase(buffer, start, end);
- return buffer.ToString();
- }
-
- static void SplitUppercase(StringBuffer buffer, int start, int end) {
for (int i = start; i < end; i++) {
- char c = Block.RawNames[i];
- bool upper = Char.IsUpper(c) && i > start;
- bool nextLower = i < end - 1 && !Char.IsUpper(Block.RawNames[i + 1]);
-
- if (upper && nextLower) {
- buffer.Append(' ');
- buffer.Append(Char.ToLower(c));
- } else {
- buffer.Append(c);
- }
+ buffer.Append(RawNames[i]);
}
+ return buffer.ToString();
}
diff --git a/ClassicalSharp/Utils/ErrorHandler.cs b/ClassicalSharp/Utils/ErrorHandler.cs
index 42f790374..f64dcf109 100644
--- a/ClassicalSharp/Utils/ErrorHandler.cs
+++ b/ClassicalSharp/Utils/ErrorHandler.cs
@@ -29,13 +29,12 @@ namespace ClassicalSharp {
static string Format(Exception ex) {
try {
- return ex.GetType().FullName + ": " + ex.Message
- + Environment.NewLine + ex.StackTrace;
- } catch {
+ return ex.GetType().FullName + ": " + ex.Message + Environment.NewLine + ex.StackTrace;
+ } catch (Exception) {
return "";
}
}
-
+
static void UnhandledException(object sender, UnhandledExceptionEventArgs e) {
// So we don't get the normal unhelpful crash dialog on Windows.
Exception ex = (Exception)e.ExceptionObject;
@@ -84,17 +83,13 @@ namespace ClassicalSharp {
/// Logs a handled exception that occured at the specified location to the log file.
public static bool LogError(string location, Exception ex) {
- string error = DescribeException(ex);
+ string error = Format(ex);
if (ex.InnerException != null) {
- error += Environment.NewLine + DescribeException(ex.InnerException);
+ error += Environment.NewLine + Format(ex.InnerException);
}
return LogError(location, error);
}
- static string DescribeException(Exception ex) {
- return ex.GetType().FullName + ": " + ex.Message + Environment.NewLine + ex.StackTrace;
- }
-
/// Logs an error that occured at the specified location to the log file.
public static bool LogError(string location, string text) {
try {
diff --git a/src/Client/Block.c b/src/Client/Block.c
index db8599920..db0716c59 100644
--- a/src/Client/Block.c
+++ b/src/Client/Block.c
@@ -106,22 +106,11 @@ void Block_SetDrawType(BlockID block, UInt8 draw) {
}
-bool Char_IsUpper(UInt8 c) { return c >= 'A' && c <= 'Z'; }
-void Block_SplitUppercase(STRING_TRANSIENT String* buffer, STRING_PURE String* blockNames, Int32 start, Int32 end) {
- Int32 i;
- for (i = start; i < end; i++) {
- UInt8 c = String_CharAt(blockNames, i);
- bool upper = Char_IsUpper(c) && i > start;
- bool nextLower = i < end - 1 && !Char_IsUpper(String_CharAt(blockNames, i + 1));
-
- if (upper && nextLower) {
- String_Append(buffer, ' ');
- String_Append(buffer, Char_ToLower(c));
- } else {
- String_Append(buffer, c);
- }
- }
-}
+#define BLOCK_RAW_NAMES "Air_Stone_Grass_Dirt_Cobblestone_Wood_Sapling_Bedrock_Water_Still water_Lava"\
+"_Still lava_Sand_Gravel_Gold ore_Iron ore_Coal ore_Log_Leaves_Sponge_Glass_Red_Orange_Yellow_Lime_Green_Teal"\
+"_Aqua_Cyan_Blue_Indigo_Violet_Magenta_Pink_Black_Gray_White_Dandelion_Rose_Brown mushroom_Red mushroom_Gold"\
+"_Iron_Double slab_Slab_Brick_TNT_Bookshelf_Mossy rocks_Obsidian_Cobblestone slab_Rope_Sandstone_Snow_Fire_Light pink"\
+"_Forest green_Brown_Deep blue_Turquoise_Ice_Ceramic tile_Magma_Pillar_Crate_Stone brick"
String Block_DefaultName(BlockID block) {
#if USE16_BIT
@@ -136,13 +125,16 @@ String Block_DefaultName(BlockID block) {
/* Find start and end of this particular block name. */
Int32 start = 0, i;
for (i = 0; i < block; i++) {
- start = String_IndexOf(&blockNames, ' ', start) + 1;
+ start = String_IndexOf(&blockNames, '_', start) + 1;
}
- Int32 end = String_IndexOf(&blockNames, ' ', start);
+ Int32 end = String_IndexOf(&blockNames, '_', start);
if (end == -1) end = blockNames.length;
String buffer = String_InitAndClear(Block_NamePtr(block), STRING_SIZE);
- Block_SplitUppercase(&buffer, &blockNames, start, end);
+ Int32 i;
+ for (i = start; i < end; i++) {
+ String_Append(&buffer, blockNames.buffer[i]);
+ }
return buffer;
}
diff --git a/src/Client/BlockID.h b/src/Client/BlockID.h
index 7aac2c709..994b2cead 100644
--- a/src/Client/BlockID.h
+++ b/src/Client/BlockID.h
@@ -89,11 +89,5 @@
#define BLOCK_MAX_DEFINED 0xFF
#endif
-#define BLOCK_RAW_NAMES "Air Stone Grass Dirt Cobblestone Wood Sapling Bedrock Water StillWater Lava"\
-" StillLava Sand Gravel GoldOre IronOre CoalOre Log Leaves Sponge Glass Red Orange Yellow Lime Green Teal"\
-" Aqua Cyan Blue Indigo Violet Magenta Pink Black Gray White Dandelion Rose BrownMushroom RedMushroom Gold"\
-" Iron DoubleSlab Slab Brick TNT Bookshelf MossyRocks Obsidian CobblestoneSlab Rope Sandstone Snow Fire LightPink"\
-" ForestGreen Brown DeepBlue Turquoise Ice CeramicTile Magma Pillar Crate StoneBrick"
-
#define BLOCK_COUNT (BLOCK_MAX_DEFINED + 1)
#endif
\ No newline at end of file