diff --git a/ClassicalSharp/2D/Drawing/IDrawer2D.cs b/ClassicalSharp/2D/Drawing/IDrawer2D.cs index 421c91ebd..11c7a3261 100644 --- a/ClassicalSharp/2D/Drawing/IDrawer2D.cs +++ b/ClassicalSharp/2D/Drawing/IDrawer2D.cs @@ -189,12 +189,10 @@ namespace ClassicalSharp { } } - /// Returns whenever the given character is a valid colour code. public static bool ValidColCode(string text, int i) { return i < text.Length && ValidColCode(text[i]); } - /// Returns whenever the given character is a valid colour code. public static bool ValidColCode(char c) { if (c >= '~' && c <= '~') return Cols[c].A > 0; return Cols[Utils.UnicodeToCP437(c)].A > 0; @@ -212,8 +210,6 @@ namespace ClassicalSharp { } #if !LAUNCHER - /// Returns the last valid colour code in the given input, - /// or \0 if no valid colour code was found. public static char LastCol(string text, int start) { if (start >= text.Length) start = text.Length - 1; diff --git a/ClassicalSharp/Game/ChatLog.cs b/ClassicalSharp/Game/ChatLog.cs index 846576494..31a0da926 100644 --- a/ClassicalSharp/Game/ChatLog.cs +++ b/ClassicalSharp/Game/ChatLog.cs @@ -23,11 +23,7 @@ namespace ClassicalSharp { void IGameComponent.OnNewMap(Game game) { } void IGameComponent.OnNewMapLoaded(Game game) { } - /// List of chat messages received from the server and added by client commands. - /// index 0 is the oldest chat message, last index is newest. public List Log = new List(); - - /// List of chat messages sent by the user to the server. public List InputLog = new List(); public void Send(string text) { diff --git a/ClassicalSharp/Map/World.cs b/ClassicalSharp/Map/World.cs index 396354ffa..55b9ccc23 100644 --- a/ClassicalSharp/Map/World.cs +++ b/ClassicalSharp/Map/World.cs @@ -16,20 +16,14 @@ namespace ClassicalSharp.Map { public int Width, Height, Length, MaxX, MaxY, MaxZ, OneY; public bool HasBlocks; - /// Contains the environment metadata for this world. public WorldEnv Env; - - /// Unique uuid/guid of this particular world. public Guid Uuid; - - /// Current terrain.png or texture pack url of this map. public string TextureUrl = null; public World(Game game) { Env = new WorldEnv(game); } - /// Resets all of the properties to their defaults and raises the 'OnNewMap' event. public void Reset() { Env.Reset(); Width = 0; Height = 0; Length = 0; @@ -42,7 +36,6 @@ namespace ClassicalSharp.Map { HasBlocks = false; } - /// Updates the underlying block array, and dimensions of this map. public void SetNewMap(BlockRaw[] blocksRaw, int width, int height, int length) { Width = width; MaxX = width - 1; Height = height; MaxY = height - 1; diff --git a/ClassicalSharp/Map/WorldEnv.cs b/ClassicalSharp/Map/WorldEnv.cs index 7e4b5cb9b..f4d102c2f 100644 --- a/ClassicalSharp/Map/WorldEnv.cs +++ b/ClassicalSharp/Map/WorldEnv.cs @@ -10,76 +10,44 @@ namespace ClassicalSharp.Map { /// Contains the environment metadata for a world. public sealed class WorldEnv { - /// Colour of the sky located behind/above clouds. public FastColour SkyCol = DefaultSkyCol; public static readonly FastColour DefaultSkyCol = new FastColour(0x99, 0xCC, 0xFF); public const string DefaultSkyColHex = "99CCFF"; - - /// Colour applied to the fog/horizon looking out horizontally. - /// Note the true horizon colour is a blend of this and sky colour. + public FastColour FogCol = DefaultFogCol; public static readonly FastColour DefaultFogCol = new FastColour(0xFF, 0xFF, 0xFF); public const string DefaultFogColHex = "FFFFFF"; - /// Colour applied to the clouds. public FastColour CloudsCol = DefaultCloudsCol; public static readonly FastColour DefaultCloudsCol = new FastColour(0xFF, 0xFF, 0xFF); public const string DefaultCloudsColHex = "FFFFFF"; - /// Height of the clouds in world space. public int CloudHeight; - - /// Modifier of how fast clouds travel across the world, defaults to 1. public float CloudsSpeed = 1; - /// Modifier of how fast rain/snow falls, defaults to 1. public float WeatherSpeed = 1; - - /// Modifier of how fast rain/snow fades, defaults to 1. public float WeatherFade = 1; - /// Colour applied to blocks located in direct sunlight. public FastColour Sunlight; public int Sun, SunXSide, SunZSide, SunYBottom; public static readonly FastColour DefaultSunlight = new FastColour(0xFF, 0xFF, 0xFF); public const string DefaultSunlightHex = "FFFFFF"; - /// Colour applied to blocks located in shadow / hidden from direct sunlight. public FastColour Shadowlight; public int Shadow, ShadowXSide, ShadowZSide, ShadowYBottom; public static readonly FastColour DefaultShadowlight = new FastColour(0x9B, 0x9B, 0x9B); public const string DefaultShadowlightHex = "9B9B9B"; - /// Current weather for this particular map. public Weather Weather = Weather.Sunny; - - /// Block that surrounds map the map horizontally (default water) public BlockID EdgeBlock = Block.StillWater; - - /// Height of the map edge in world space. public int EdgeHeight; - /// Block that surrounds the map that fills the bottom of the map horizontally, - /// fills part of the vertical sides of the map, and also surrounds map the map horizontally. (default bedrock) public BlockID SidesBlock = Block.Bedrock; - - /// Maximum height of the various parts of the map sides, in world space. public int SidesHeight { get { return EdgeHeight + SidesOffset; } } - - /// Offset of height of map sides from height of map edge. public int SidesOffset = -2; - /// Whether exponential fog mode is used by default. - public bool ExpFog; - - /// Horizontal skybox rotation speed. - public float SkyboxHorSpeed; - - /// Vertical skybox rotation speed. - public float SkyboxVerSpeed; - - /// Whether clouds still render, even with skybox. - public bool SkyboxClouds; + public float SkyboxHorSpeed, SkyboxVerSpeed; + public bool ExpFog, SkyboxClouds; Game game; public WorldEnv(Game game) { diff --git a/ClassicalSharp/Utils/Utils.cs b/ClassicalSharp/Utils/Utils.cs index deb0f724e..e3870827d 100644 --- a/ClassicalSharp/Utils/Utils.cs +++ b/ClassicalSharp/Utils/Utils.cs @@ -175,7 +175,7 @@ namespace ClassicalSharp { if (c >= 'A' && c <= 'Z') { hasUpper = true; break; } } - if (!hasUpper) return src; + if (!hasUpper) return src; char[] dst = new char[src.Length]; for (int i = 0; i < src.Length; i++) { diff --git a/Launcher2/WebTasks.cs b/Launcher2/WebTasks.cs index 147a5b31a..81835dcf2 100644 --- a/Launcher2/WebTasks.cs +++ b/Launcher2/WebTasks.cs @@ -61,8 +61,7 @@ namespace Launcher.Web { public string Token; protected override void Handle(Request req) { - JsonContext ctx = new JsonContext(); ctx.Val = (string)req.Data; - JsonObject data = (JsonObject)Json.ParseStream(ctx); + JsonObject data = ParseJson(req); Token = (string)data["token"]; } } diff --git a/OpenTK/Platform/X11/X11GLNative.cs b/OpenTK/Platform/X11/X11GLNative.cs index 79423f51c..35c6ddc09 100644 --- a/OpenTK/Platform/X11/X11GLNative.cs +++ b/OpenTK/Platform/X11/X11GLNative.cs @@ -437,10 +437,10 @@ namespace OpenTK.Platform.X11 { IntPtr prop_type, num_items, bytes_after, data = IntPtr.Zero; int prop_format; - API.XGetWindowProperty (window.Display, window.WinHandle, xa_data_sel, IntPtr.Zero, new IntPtr (1024), false, IntPtr.Zero, - out prop_type, out prop_format, out num_items, out bytes_after, ref data); + API.XGetWindowProperty(window.Display, window.WinHandle, xa_data_sel, IntPtr.Zero, new IntPtr (1024), false, IntPtr.Zero, + out prop_type, out prop_format, out num_items, out bytes_after, ref data); - API.XDeleteProperty (window.Display, window.WinHandle, xa_data_sel); + API.XDeleteProperty(window.Display, window.WinHandle, xa_data_sel); if (num_items == IntPtr.Zero) break; if (prop_type == xa_utf8_string) { @@ -468,7 +468,7 @@ namespace OpenTK.Platform.X11 { if (e.SelectionRequestEvent.selection == xa_clipboard && e.SelectionRequestEvent.target == xa_utf8_string && clipboard_copy_text != null) { reply.SelectionEvent.property = GetSelectionProperty(ref e); - byte[] utf8_data = Encoding.UTF8.GetBytes (clipboard_copy_text); + byte[] utf8_data = Encoding.UTF8.GetBytes(clipboard_copy_text); fixed (byte* utf8_ptr = utf8_data) { API.XChangeProperty(window.Display, reply.SelectionEvent.requestor, reply.SelectionEvent.property, xa_utf8_string, 8, PropertyMode.Replace, (IntPtr)utf8_ptr, utf8_data.Length); diff --git a/src/Client/Deflate.c b/src/Client/Deflate.c index 612e3cf64..b3acc2ee5 100644 --- a/src/Client/Deflate.c +++ b/src/Client/Deflate.c @@ -282,18 +282,24 @@ static Int32 Huffman_Decode(InflateState* state, HuffmanTable* table) { return -1; } -static Int32 Huffman_Unsafe_Decode(InflateState* state, HuffmanTable* table) { - Inflate_UNSAFE_EnsureBits(state, INFLATE_MAX_BITS); - UInt32 codeword = Inflate_PeekBits(state, INFLATE_FAST_BITS); - Int32 packed = table->Fast[codeword]; - if (packed >= 0) { - Int32 bits = packed >> INFLATE_FAST_BITS; - Inflate_ConsumeBits(state, bits); - return packed & 0x1FF; - } +#define Huffman_Unsafe_Decode(state, table, result) \ +{\ + Inflate_UNSAFE_EnsureBits(state, INFLATE_MAX_BITS);\ + Int32 packed = table.Fast[Inflate_PeekBits(state, INFLATE_FAST_BITS)];\ + if (packed >= 0) {\ + Int32 consumedBits = packed >> INFLATE_FAST_BITS;\ + Inflate_ConsumeBits(state, consumedBits);\ + result = packed & 0x1FF;\ + } else {\ + result = Huffman_Unsafe_Decode_Slow(state, &table);\ + }\ +} +static Int32 Huffman_Unsafe_Decode_Slow(InflateState* state, HuffmanTable* table) { + UInt32 codeword = Inflate_PeekBits(state, INFLATE_FAST_BITS); /* Slow, bit by bit lookup. Need to reverse order for huffman. */ codeword = Huffman_ReverseBits(codeword, INFLATE_FAST_BITS); + UInt32 i, j; for (i = INFLATE_FAST_BITS + 1, j = INFLATE_FAST_BITS; i < INFLATE_MAX_BITS; i++, j++) { codeword = (codeword << 1) | ((state->Bits >> j) & 1); @@ -358,9 +364,8 @@ static void Inflate_InflateFast(InflateState* state) { #define INFLATE_FAST_COPY_MAX (INFLATE_WINDOW_SIZE - INFLATE_FASTINF_OUT) while (state->AvailOut >= INFLATE_FASTINF_OUT && state->AvailIn >= INFLATE_FASTINF_IN && copyLen < INFLATE_FAST_COPY_MAX) { - UInt32 lit = Huffman_Unsafe_Decode(state, &state->LitsTable); + UInt32 lit; Huffman_Unsafe_Decode(state, state->LitsTable, lit); if (lit <= 256) { - //Platform_Log1("lit %i", &lit); if (lit < 256) { window[curIdx] = (UInt8)lit; state->AvailOut--; copyLen++; @@ -375,13 +380,11 @@ static void Inflate_InflateFast(InflateState* state) { Inflate_UNSAFE_EnsureBits(state, bits); UInt32 len = len_base[lenIdx] + Inflate_ReadBits(state, bits); - UInt32 distIdx = Huffman_Unsafe_Decode(state, &state->DistsTable); + UInt32 distIdx; Huffman_Unsafe_Decode(state, state->DistsTable, distIdx); bits = dist_bits[distIdx]; Inflate_UNSAFE_EnsureBits(state, bits); UInt32 dist = dist_base[distIdx] + Inflate_ReadBits(state, bits); - //Platform_Log2("len %i, dist %i", &len, &dist); - UInt32 startIdx = (curIdx - dist) & INFLATE_WINDOW_MASK; UInt32 i; if (curIdx >= startIdx && (curIdx + len) < INFLATE_WINDOW_SIZE) { @@ -587,7 +590,6 @@ void Inflate_Process(InflateState* state) { Int32 lit = Huffman_Decode(state, &state->LitsTable); if (lit < 256) { if (lit == -1) return; - //Platform_Log1("lit %i", &lit); *state->Output = (UInt8)lit; state->Window[state->WindowIndex] = (UInt8)lit; state->Output++; state->AvailOut--; @@ -622,8 +624,6 @@ void Inflate_Process(InflateState* state) { Inflate_EnsureBits(state, bits); state->TmpDist = dist_base[distIdx] + Inflate_ReadBits(state, bits); state->State = INFLATE_STATE_COMPRESSED_DATA; - - //Platform_Log2("len %i, dist %i", &state->TmpLit, &state->TmpDist); } case INFLATE_STATE_COMPRESSED_DATA: { @@ -732,8 +732,6 @@ static void Deflate_Lit(DeflateState* state, Int32 lit) { if (lit <= 143) { Deflate_PushHuff(state, lit + 48, 8); } else { Deflate_PushHuff(state, lit + 256, 9); } Deflate_FlushBits(state); - - //Platform_Log1("lit %i", &lit); } static void Deflate_LenDist(DeflateState* state, Int32 len, Int32 dist) { @@ -755,8 +753,6 @@ static void Deflate_LenDist(DeflateState* state, Int32 len, Int32 dist) { if (dist_bits[j]) { Deflate_PushBits(state, dist - dist_base[j], dist_bits[j]); } Deflate_FlushBits(state); - //Platform_Log2("len %i, dist %i", &len, &dist); - len_base[29] = 0; dist_base[30] = 0; }