From 4618df5331c55ea5917fde5597ee7c95f1af2071 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 1 Jun 2018 19:45:49 +1000 Subject: [PATCH] Fix few bugs from last commit --- ClassicalSharp/2D/Drawing/IDrawer2D.cs | 2 +- ClassicalSharp/ClassicalSharp.csproj | 1 - ClassicalSharp/TexturePack/TerrainAtlas.cs | 7 +++---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ClassicalSharp/2D/Drawing/IDrawer2D.cs b/ClassicalSharp/2D/Drawing/IDrawer2D.cs index a66d4b5ec..421c91ebd 100644 --- a/ClassicalSharp/2D/Drawing/IDrawer2D.cs +++ b/ClassicalSharp/2D/Drawing/IDrawer2D.cs @@ -96,7 +96,7 @@ namespace ClassicalSharp { public Texture MakeTextTexture(ref DrawTextArgs args, int windowX, int windowY) { Size size = MeasureSize(ref args); if (size == Size.Empty) - return new Texture(-1, windowX, windowY, 0, 0, 1, 1); + return new Texture(0, windowX, windowY, 0, 0, 1, 1); using (Bitmap bmp = CreatePow2Bitmap(size)) { SetBitmap(bmp); diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index c5aceee85..cb6d406f4 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -56,7 +56,6 @@ DEBUG;TRACE;USE_DX; Project obj\ - unk aa 127.0.0.1 25566 ..\output\release\ diff --git a/ClassicalSharp/TexturePack/TerrainAtlas.cs b/ClassicalSharp/TexturePack/TerrainAtlas.cs index 9bf385f6c..d0f343545 100644 --- a/ClassicalSharp/TexturePack/TerrainAtlas.cs +++ b/ClassicalSharp/TexturePack/TerrainAtlas.cs @@ -23,14 +23,13 @@ namespace ClassicalSharp.Textures { } public static int LoadTile(int texLoc) { - int size = TileSize; + int size = TileSize, x = texLoc % TilesPerRow, y = texLoc / TilesPerRow; + if (y >= RowsCount) return 0; + using (FastBitmap atlas = new FastBitmap(Atlas, true, true)) using (Bitmap bmp = Platform.CreateBmp(size, size)) using (FastBitmap dst = new FastBitmap(bmp, true, false)) { - int x = texLoc % TilesPerRow, y = texLoc / TilesPerRow; - y %= RowsCount; - FastBitmap.MovePortion(x * size, y * size, 0, 0, atlas, dst, size); return game.Graphics.CreateTexture(dst, false, game.Graphics.Mipmaps); }