mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Fix last commit whoops
This commit is contained in:
parent
e90e63e92c
commit
a7da47e552
5 changed files with 28 additions and 29 deletions
|
@ -19,7 +19,7 @@ static cc_bool shadows_boundTex;
|
|||
static GfxResourceID shadows_VB;
|
||||
static GfxResourceID shadows_tex;
|
||||
static float shadow_radius, shadow_uvScale;
|
||||
struct ShadowData { float y; BlockID Block; cc_uint8 A; };
|
||||
struct ShadowData { float y; BlockID block; cc_uint8 alpha; };
|
||||
|
||||
/* Circle shadows extend at most 4 blocks vertically */
|
||||
#define SHADOW_MAX_RANGE 4
|
||||
|
@ -54,7 +54,7 @@ static void EntityShadow_DrawCoords(struct VertexTextured** vertices, struct Ent
|
|||
z2 = min(z2, cen.z + shadow_radius); v2 = v2 <= 1.0f ? v2 : 1.0f;
|
||||
|
||||
v = *vertices;
|
||||
col = PackedCol_Make(255, 255, 255, data->A);
|
||||
col = PackedCol_Make(255, 255, 255, data->alpha);
|
||||
|
||||
v->x = x1; v->y = data->y; v->z = z1; v->Col = col; v->U = u1; v->V = v1; v++;
|
||||
v->x = x2; v->y = data->y; v->z = z1; v->Col = col; v->U = u2; v->V = v1; v++;
|
||||
|
@ -83,13 +83,13 @@ static void EntityShadow_DrawCircle(struct VertexTextured** vertices, struct Ent
|
|||
Vec3 min, max, nMin, nMax;
|
||||
int i;
|
||||
x = (float)Math_Floor(x); z = (float)Math_Floor(z);
|
||||
min = Blocks.MinBB[data[0].Block]; max = Blocks.MaxBB[data[0].Block];
|
||||
min = Blocks.MinBB[data[0].block]; max = Blocks.MaxBB[data[0].block];
|
||||
|
||||
EntityShadow_DrawCoords(vertices, e, &data[0], x + min.x, z + min.z, x + max.x, z + max.z);
|
||||
for (i = 1; i < 4; i++)
|
||||
{
|
||||
if (data[i].Block == BLOCK_AIR) return;
|
||||
nMin = Blocks.MinBB[data[i].Block]; nMax = Blocks.MaxBB[data[i].Block];
|
||||
if (data[i].block == BLOCK_AIR) return;
|
||||
nMin = Blocks.MinBB[data[i].block]; nMax = Blocks.MaxBB[data[i].block];
|
||||
|
||||
EntityShadow_DrawCoords(vertices, e, &data[i], x + min.x, z + nMin.z, x + max.x, z + min.z);
|
||||
EntityShadow_DrawCoords(vertices, e, &data[i], x + min.x, z + max.z, x + max.x, z + nMax.z);
|
||||
|
@ -103,11 +103,12 @@ static void EntityShadow_DrawCircle(struct VertexTextured** vertices, struct Ent
|
|||
static void EntityShadow_CalcAlpha(float playerY, struct ShadowData* data) {
|
||||
float height = playerY - data->y;
|
||||
if (height <= 6.0f) {
|
||||
data->A = (cc_uint8)(160 - 160 * height / 6.0f);
|
||||
data->y += 1.0f / 64.0f; return;
|
||||
data->alpha = (cc_uint8)(160 - 160 * height / 6.0f);
|
||||
data->y += 1.0f / 64.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
data->A = 0;
|
||||
data->alpha = 0;
|
||||
if (height <= 16.0f) data->y += 1.0f / 64.0f;
|
||||
else if (height <= 32.0f) data->y += 1.0f / 16.0f;
|
||||
else if (height <= 96.0f) data->y += 1.0f / 8.0f;
|
||||
|
@ -144,7 +145,7 @@ static cc_bool EntityShadow_GetBlocks(struct Entity* e, int x, int y, int z, str
|
|||
topY = y + Blocks.MaxBB[block].y;
|
||||
if (topY >= posY + 0.01f) continue;
|
||||
|
||||
cur->Block = block; cur->y = topY;
|
||||
cur->block = block; cur->y = topY;
|
||||
EntityShadow_CalcAlpha(posY, cur);
|
||||
i++; cur++;
|
||||
|
||||
|
@ -154,7 +155,7 @@ static cc_bool EntityShadow_GetBlocks(struct Entity* e, int x, int y, int z, str
|
|||
}
|
||||
|
||||
if (i < 4) {
|
||||
cur->Block = Env.EdgeBlock; cur->y = 0.0f;
|
||||
cur->block = Env.EdgeBlock; cur->y = 0.0f;
|
||||
EntityShadow_CalcAlpha(posY, cur);
|
||||
i++; cur++;
|
||||
}
|
||||
|
@ -188,16 +189,16 @@ static void EntityShadow_Draw(struct Entity* e) {
|
|||
x1 = Math_Floor(pos.x - shadow_radius); z1 = Math_Floor(pos.z - shadow_radius);
|
||||
x2 = Math_Floor(pos.x + shadow_radius); z2 = Math_Floor(pos.z + shadow_radius);
|
||||
|
||||
if (EntityShadow_GetBlocks(e, x1, y, z1, data) && data[0].A > 0) {
|
||||
if (EntityShadow_GetBlocks(e, x1, y, z1, data) && data[0].alpha > 0) {
|
||||
EntityShadow_DrawCircle(&ptr, e, data, (float)x1, (float)z1);
|
||||
}
|
||||
if (x1 != x2 && EntityShadow_GetBlocks(e, x2, y, z1, data) && data[0].A > 0) {
|
||||
if (x1 != x2 && EntityShadow_GetBlocks(e, x2, y, z1, data) && data[0].alpha > 0) {
|
||||
EntityShadow_DrawCircle(&ptr, e, data, (float)x2, (float)z1);
|
||||
}
|
||||
if (z1 != z2 && EntityShadow_GetBlocks(e, x1, y, z2, data) && data[0].A > 0) {
|
||||
if (z1 != z2 && EntityShadow_GetBlocks(e, x1, y, z2, data) && data[0].alpha > 0) {
|
||||
EntityShadow_DrawCircle(&ptr, e, data, (float)x1, (float)z2);
|
||||
}
|
||||
if (x1 != x2 && z1 != z2 && EntityShadow_GetBlocks(e, x2, y, z2, data) && data[0].A > 0) {
|
||||
if (x1 != x2 && z1 != z2 && EntityShadow_GetBlocks(e, x2, y, z2, data) && data[0].alpha > 0) {
|
||||
EntityShadow_DrawCircle(&ptr, e, data, (float)x2, (float)z2);
|
||||
}
|
||||
}
|
||||
|
@ -262,6 +263,7 @@ void EntityShadows_Render(void) {
|
|||
if (Entities.ShadowsMode == SHADOW_MODE_CIRCLE_ALL) {
|
||||
for (i = 0; i < ENTITIES_MAX_COUNT; i++)
|
||||
{
|
||||
e = Entities.List[i];
|
||||
if (!e || !e->ShouldRender || e == &Entities.CurPlayer->Base) continue;
|
||||
EntityShadow_Draw(e);
|
||||
}
|
||||
|
|
|
@ -500,11 +500,11 @@ static cc_result HttpConnection_Read(struct HttpConnection* conn, cc_uint8* data
|
|||
return Socket_Read(conn->socket, data, count, read);
|
||||
}
|
||||
|
||||
static cc_result HttpConnection_Write(struct HttpConnection* conn, const cc_uint8* data, cc_uint32 count, cc_uint32* wrote) {
|
||||
static cc_result HttpConnection_Write(struct HttpConnection* conn, const cc_uint8* data, cc_uint32 count) {
|
||||
if (conn->sslCtx)
|
||||
return SSL_Write(conn->sslCtx, data, count, wrote);
|
||||
return SSL_WriteAll(conn->sslCtx, data, count);
|
||||
|
||||
return Socket_WriteAll(conn->socket, data, count, wrote);
|
||||
return Socket_WriteAll(conn->socket, data, count);
|
||||
}
|
||||
|
||||
|
||||
|
@ -623,15 +623,13 @@ static void HttpClient_Serialise(struct HttpClientState* state) {
|
|||
static cc_result HttpClient_SendRequest(struct HttpClientState* state) {
|
||||
char inputBuffer[16384];
|
||||
cc_string inputMsg;
|
||||
cc_uint32 wrote;
|
||||
|
||||
String_InitArray(inputMsg, inputBuffer);
|
||||
state->req->meta = &inputMsg;
|
||||
state->req->progress = HTTP_PROGRESS_FETCHING_DATA;
|
||||
HttpClient_Serialise(state);
|
||||
|
||||
/* TODO check that wrote is >= inputMsg.length */
|
||||
return HttpConnection_Write(state->conn, (cc_uint8*)inputBuffer, inputMsg.length, &wrote);
|
||||
return HttpConnection_Write(state->conn, (cc_uint8*)inputBuffer, inputMsg.length);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -380,10 +380,9 @@ static cc_result SSL_WriteChunk(struct SSLContext* s, const cc_uint8* data, cc_u
|
|||
return Socket_WriteAll(s->socket, buffer, total);
|
||||
}
|
||||
|
||||
cc_result SSL_Write(void* ctx, const cc_uint8* data, cc_uint32 count, cc_uint32* wrote) {
|
||||
cc_result SSL_WriteAll(void* ctx, const cc_uint8* data, cc_uint32 count) {
|
||||
struct SSLContext* s = ctx;
|
||||
cc_result res;
|
||||
*wrote = 0;
|
||||
|
||||
/* TODO: Don't loop here? move to HTTPConnection instead?? */
|
||||
while (count)
|
||||
|
@ -391,7 +390,6 @@ cc_result SSL_Write(void* ctx, const cc_uint8* data, cc_uint32 count, cc_uint32*
|
|||
int len = min(count, s->sizes.cbMaximumMessage);
|
||||
if ((res = SSL_WriteChunk(s, data, len))) return res;
|
||||
|
||||
*wrote += len;
|
||||
data += len;
|
||||
count -= len;
|
||||
}
|
||||
|
@ -543,7 +541,7 @@ cc_result SSL_Read(void* ctx_, cc_uint8* data, cc_uint32 count, cc_uint32* read)
|
|||
return 0;
|
||||
}
|
||||
|
||||
cc_result SSL_Write(void* ctx_, const cc_uint8* data, cc_uint32 count, cc_uint32* wrote) {
|
||||
cc_result SSL_WriteAll(void* ctx_, const cc_uint8* data, cc_uint32 count) {
|
||||
SSLContext* ctx = (SSLContext*)ctx_;
|
||||
// TODO: just br_sslio_write ??
|
||||
int res = br_sslio_write_all(&ctx->ioc, data, count);
|
||||
|
@ -554,7 +552,6 @@ cc_result SSL_Write(void* ctx_, const cc_uint8* data, cc_uint32 count, cc_uint32
|
|||
}
|
||||
|
||||
br_sslio_flush(&ctx->ioc);
|
||||
*wrote = res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -577,7 +574,7 @@ cc_result SSL_Read(void* ctx, cc_uint8* data, cc_uint32 count, cc_uint32* read)
|
|||
return ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
cc_result SSL_Write(void* ctx, const cc_uint8* data, cc_uint32 count, cc_uint32* wrote) {
|
||||
cc_result SSL_WriteAll(void* ctx, const cc_uint8* data, cc_uint32 count) {
|
||||
return ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,6 @@ cc_bool SSLBackend_DescribeError(cc_result res, cc_string* dst);
|
|||
|
||||
cc_result SSL_Init(cc_socket socket, const cc_string* host, void** ctx);
|
||||
cc_result SSL_Read(void* ctx, cc_uint8* data, cc_uint32 count, cc_uint32* read);
|
||||
cc_result SSL_Write(void* ctx, const cc_uint8* data, cc_uint32 count, cc_uint32* wrote);
|
||||
cc_result SSL_WriteAll(void* ctx, const cc_uint8* data, cc_uint32 count);
|
||||
cc_result SSL_Free(void* ctx);
|
||||
#endif
|
||||
|
|
|
@ -80,11 +80,13 @@ static void SysFont_Done(struct SysFont* font) {
|
|||
if (!source->meta.file) return;
|
||||
source->Close(source);
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (!font->glyphs[i]) continue;
|
||||
FT_Done_Glyph((FT_Glyph)font->glyphs[i]);
|
||||
}
|
||||
for (i = 0; i < 256; i++) {
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (!font->shadow_glyphs[i]) continue;
|
||||
FT_Done_Glyph((FT_Glyph)font->shadow_glyphs[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue