Permalink
Browse files

Fix crash if you get disconnected when context is lost (thanks lavacr…

…aft)
  • Loading branch information...
UnknownShadow200 committed Jan 6, 2019
1 parent 9cfb8fa commit 91c9df5c05293b2f7a4539e48740a40047d435e3
@@ -88,6 +88,7 @@ public class DisconnectScreen : Screen {
public override bool HandlesMouseUp(int mouseX, int mouseY, MouseButton button) { return true; }

public override bool HandlesMouseMove(int mouseX, int mouseY) {
if (reconnect == null) return true;
reconnect.Active = !reconnect.Disabled && reconnect.Contains(mouseX, mouseY);
return true;
}
@@ -47,7 +47,7 @@
<StartAction>Project</StartAction>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_D3D' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
@@ -37,6 +37,8 @@ internal static class Program {
string user = null, mppass = null;
string skinServer = "http://static.classicube.net/skins/";

args = new string[] { "UnknownShadow200", "mppass", "127.0.0.1", "25565" };

if (args.Length == 0 || args.Length == 1) {
user = args.Length > 0 ? args[0] : "Singleplayer";
} else if (args.Length < 4) {
@@ -617,15 +617,15 @@ static void NormalBuilder_RenderBlock(int index) {
baseOffset = (Blocks.Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES;
lightFlags = Blocks.LightOffset[Builder_Block];

Drawer_MinBB = Blocks.MinBB[Builder_Block]; Drawer_MinBB.Y = 1.0f - Drawer_MinBB.Y;
Drawer_MaxBB = Blocks.MaxBB[Builder_Block]; Drawer_MaxBB.Y = 1.0f - Drawer_MaxBB.Y;
Drawer.MinBB = Blocks.MinBB[Builder_Block]; Drawer.MinBB.Y = 1.0f - Drawer.MinBB.Y;
Drawer.MaxBB = Blocks.MaxBB[Builder_Block]; Drawer.MaxBB.Y = 1.0f - Drawer.MaxBB.Y;

min = Blocks.RenderMinBB[Builder_Block]; max = Blocks.RenderMaxBB[Builder_Block];
Drawer_X1 = Builder_X + min.X; Drawer_Y1 = Builder_Y + min.Y; Drawer_Z1 = Builder_Z + min.Z;
Drawer_X2 = Builder_X + max.X; Drawer_Y2 = Builder_Y + max.Y; Drawer_Z2 = Builder_Z + max.Z;
Drawer.X1 = Builder_X + min.X; Drawer.Y1 = Builder_Y + min.Y; Drawer.Z1 = Builder_Z + min.Z;
Drawer.X2 = Builder_X + max.X; Drawer.Y2 = Builder_Y + max.Y; Drawer.Z2 = Builder_Z + max.Z;

Drawer_Tinted = Blocks.Tinted[Builder_Block];
Drawer_TintCol = Blocks.FogCol[Builder_Block];
Drawer.Tinted = Blocks.Tinted[Builder_Block];
Drawer.TintCol = Blocks.FogCol[Builder_Block];

if (count_XMin) {
loc = Block_GetTex(Builder_Block, FACE_XMIN);
@@ -16,7 +16,7 @@ extern bool Builder_SmoothLighting;

void Builder_Init(void);
void Builder_OnNewMapLoaded(void);
/* Builds the vertices mesh for the given chunk. */
/* Builds the mesh of vertices for the given chunk. */
void Builder_MakeChunk(struct ChunkInfo* info);

void NormalBuilder_SetActive(void);
@@ -2,131 +2,127 @@
#include "TexturePack.h"
#include "Constants.h"

bool Drawer_Tinted;
PackedCol Drawer_TintCol;
Vector3 Drawer_MinBB, Drawer_MaxBB;
float Drawer_X1, Drawer_Y1, Drawer_Z1;
float Drawer_X2, Drawer_Y2, Drawer_Z2;
struct _DrawerData Drawer;

/* Performance critical, use macro to ensure always inlined. */
#define ApplyTint \
if (Drawer_Tinted) {\
col.R = (uint8_t)(col.R * Drawer_TintCol.R / 255);\
col.G = (uint8_t)(col.G * Drawer_TintCol.G / 255);\
col.B = (uint8_t)(col.B * Drawer_TintCol.B / 255);\
if (Drawer.Tinted) {\
col.R = (uint8_t)(col.R * Drawer.TintCol.R / 255);\
col.G = (uint8_t)(col.G * Drawer.TintCol.G / 255);\
col.B = (uint8_t)(col.B * Drawer.TintCol.B / 255);\
}


void Drawer_XMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;
float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;

float u1 = Drawer_MinBB.Z;
float u2 = (count - 1) + Drawer_MaxBB.Z * UV2_Scale;
float v1 = vOrigin + Drawer_MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;
float u1 = Drawer.MinBB.Z;
float u2 = (count - 1) + Drawer.MaxBB.Z * UV2_Scale;
float v1 = vOrigin + Drawer.MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.X = Drawer_X1; v.Col = col;
v.X = Drawer.X1; v.Col = col;

v.Y = Drawer_Y2; v.Z = Drawer_Z2 + (count - 1); v.U = u2; v.V = v1; *ptr++ = v;
v.Z = Drawer_Z1; v.U = u1; *ptr++ = v;
v.Y = Drawer_Y1; v.V = v2; *ptr++ = v;
v.Z = Drawer_Z2 + (count - 1); v.U = u2; *ptr++ = v;
v.Y = Drawer.Y2; v.Z = Drawer.Z2 + (count - 1); v.U = u2; v.V = v1; *ptr++ = v;
v.Z = Drawer.Z1; v.U = u1; *ptr++ = v;
v.Y = Drawer.Y1; v.V = v2; *ptr++ = v;
v.Z = Drawer.Z2 + (count - 1); v.U = u2; *ptr++ = v;
*vertices = ptr;
}

void Drawer_XMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;
float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;

float u1 = (count - Drawer_MinBB.Z);
float u2 = (1 - Drawer_MaxBB.Z) * UV2_Scale;
float v1 = vOrigin + Drawer_MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;
float u1 = (count - Drawer.MinBB.Z);
float u2 = (1 - Drawer.MaxBB.Z) * UV2_Scale;
float v1 = vOrigin + Drawer.MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.X = Drawer_X2; v.Col = col;
v.X = Drawer.X2; v.Col = col;

v.Y = Drawer_Y2; v.Z = Drawer_Z1; v.U = u1; v.V = v1; *ptr++ = v;
v.Z = Drawer_Z2 + (count - 1); v.U = u2; *ptr++ = v;
v.Y = Drawer_Y1; v.V = v2; *ptr++ = v;
v.Z = Drawer_Z1; v.U = u1; *ptr++ = v;
v.Y = Drawer.Y2; v.Z = Drawer.Z1; v.U = u1; v.V = v1; *ptr++ = v;
v.Z = Drawer.Z2 + (count - 1); v.U = u2; *ptr++ = v;
v.Y = Drawer.Y1; v.V = v2; *ptr++ = v;
v.Z = Drawer.Z1; v.U = u1; *ptr++ = v;
*vertices = ptr;
}

void Drawer_ZMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;
float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;

float u1 = (count - Drawer_MinBB.X);
float u2 = (1 - Drawer_MaxBB.X) * UV2_Scale;
float v1 = vOrigin + Drawer_MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;
float u1 = (count - Drawer.MinBB.X);
float u2 = (1 - Drawer.MaxBB.X) * UV2_Scale;
float v1 = vOrigin + Drawer.MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.Z = Drawer_Z1; v.Col = col;
v.Z = Drawer.Z1; v.Col = col;

v.X = Drawer_X2 + (count - 1); v.Y = Drawer_Y1; v.U = u2; v.V = v2; *ptr++ = v;
v.X = Drawer_X1; v.U = u1; *ptr++ = v;
v.Y = Drawer_Y2; v.V = v1; *ptr++ = v;
v.X = Drawer_X2 + (count - 1); v.U = u2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.Y = Drawer.Y1; v.U = u2; v.V = v2; *ptr++ = v;
v.X = Drawer.X1; v.U = u1; *ptr++ = v;
v.Y = Drawer.Y2; v.V = v1; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.U = u2; *ptr++ = v;
*vertices = ptr;
}

void Drawer_ZMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;
float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;

float u1 = Drawer_MinBB.X;
float u2 = (count - 1) + Drawer_MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer_MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;
float u1 = Drawer.MinBB.X;
float u2 = (count - 1) + Drawer.MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer.MaxBB.Y * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MinBB.Y * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.Z = Drawer_Z2; v.Col = col;
v.Z = Drawer.Z2; v.Col = col;

v.X = Drawer_X2 + (count - 1); v.Y = Drawer_Y2; v.U = u2; v.V = v1; *ptr++ = v;
v.X = Drawer_X1; v.U = u1; *ptr++ = v;
v.Y = Drawer_Y1; v.V = v2; *ptr++ = v;
v.X = Drawer_X2 + (count - 1); v.U = u2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.Y = Drawer.Y2; v.U = u2; v.V = v1; *ptr++ = v;
v.X = Drawer.X1; v.U = u1; *ptr++ = v;
v.Y = Drawer.Y1; v.V = v2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.U = u2; *ptr++ = v;
*vertices = ptr;
}

void Drawer_YMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;

float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;
float u1 = Drawer_MinBB.X;
float u2 = (count - 1) + Drawer_MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer_MinBB.Z * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MaxBB.Z * Atlas1D_InvTileSize * UV2_Scale;
float u1 = Drawer.MinBB.X;
float u2 = (count - 1) + Drawer.MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer.MinBB.Z * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MaxBB.Z * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.Y = Drawer_Y1; v.Col = col;
v.Y = Drawer.Y1; v.Col = col;

v.X = Drawer_X2 + (count - 1); v.Z = Drawer_Z2; v.U = u2; v.V = v2; *ptr++ = v;
v.X = Drawer_X1; v.U = u1; *ptr++ = v;
v.Z = Drawer_Z1; v.V = v1; *ptr++ = v;
v.X = Drawer_X2 + (count - 1); v.U = u2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.Z = Drawer.Z2; v.U = u2; v.V = v2; *ptr++ = v;
v.X = Drawer.X1; v.U = u1; *ptr++ = v;
v.Z = Drawer.Z1; v.V = v1; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.U = u2; *ptr++ = v;
*vertices = ptr;
}

void Drawer_YMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices) {
VertexP3fT2fC4b* ptr = *vertices; VertexP3fT2fC4b v;
float vOrigin = Atlas1D_RowId(texLoc) * Atlas1D_InvTileSize;

float u1 = Drawer_MinBB.X;
float u2 = (count - 1) + Drawer_MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer_MinBB.Z * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer_MaxBB.Z * Atlas1D_InvTileSize * UV2_Scale;
float u1 = Drawer.MinBB.X;
float u2 = (count - 1) + Drawer.MaxBB.X * UV2_Scale;
float v1 = vOrigin + Drawer.MinBB.Z * Atlas1D_InvTileSize;
float v2 = vOrigin + Drawer.MaxBB.Z * Atlas1D_InvTileSize * UV2_Scale;

ApplyTint;
v.Y = Drawer_Y2; v.Col = col;
v.Y = Drawer.Y2; v.Col = col;

v.X = Drawer_X2 + (count - 1); v.Z = Drawer_Z1; v.U = u2; v.V = v1; *ptr++ = v;
v.X = Drawer_X1; v.U = u1; *ptr++ = v;
v.Z = Drawer_Z2; v.V = v2; *ptr++ = v;
v.X = Drawer_X2 + (count - 1); v.U = u2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.Z = Drawer.Z1; v.U = u2; v.V = v1; *ptr++ = v;
v.X = Drawer.X1; v.U = u1; *ptr++ = v;
v.Z = Drawer.Z2; v.V = v2; *ptr++ = v;
v.X = Drawer.X2 + (count - 1); v.U = u2; *ptr++ = v;
*vertices = ptr;
}
@@ -6,23 +6,31 @@
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/

/* Whether a colour tinting effect should be applied to all faces. */
extern bool Drawer_Tinted;
/* The colour to multiply colour of faces by (tinting effect). */
extern PackedCol Drawer_TintCol;
/* Minimum corner of base block bounding box. (For texture UV) */
extern Vector3 Drawer_MinBB;
/* Maximum corner of base block bounding box. (For texture UV) */
extern Vector3 Drawer_MaxBB;
/* Coordinate of minimum block bounding box corner in the world. */
extern float Drawer_X1, Drawer_Y1, Drawer_Z1;
/* Coordinate of maximum block bounding box corner in the world. */
extern float Drawer_X2, Drawer_Y2, Drawer_Z2;
extern struct _DrawerData {
/* Whether a colour tinting effect should be applied to all faces. */
bool Tinted;
/* The colour to multiply colour of faces by (tinting effect). */
PackedCol TintCol;
/* Minimum corner of base block bounding box. (For texture UV) */
Vector3 MinBB;
/* Maximum corner of base block bounding box. (For texture UV) */
Vector3 MaxBB;
/* Coordinate of minimum block bounding box corner in the world. */
float X1, Y1, Z1;
/* Coordinate of maximum block bounding box corner in the world. */
float X2, Y2, Z2;
} Drawer;

/* Draws minimum X face of the cuboid. (i.e. at X1) */
void Drawer_XMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum X face of the cuboid. (i.e. at X2) */
void Drawer_XMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws minimum Z face of the cuboid. (i.e. at Z1) */
void Drawer_ZMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum Z face of the cuboid. (i.e. at Z2) */
void Drawer_ZMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws minimum Y face of the cuboid. (i.e. at Y1) */
void Drawer_YMin(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
/* Draws maximum Y face of the cuboid. (i.e. at Y2) */
void Drawer_YMax(int count, PackedCol col, TextureLoc texLoc, VertexP3fT2fC4b** vertices);
#endif
Oops, something went wrong.

0 comments on commit 91c9df5

Please sign in to comment.