mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-24 18:13:15 -05:00
Fix C client crashing on close
This commit is contained in:
parent
be479f6a7d
commit
f3e8fb5678
25 changed files with 90 additions and 114 deletions
|
@ -284,7 +284,7 @@ static void AsyncDownloader_WorkerFunc(void) {
|
|||
|
||||
Mutex_Lock(async_curRequestMutex);
|
||||
{
|
||||
async_curRequest.ID[0] = NULL;
|
||||
async_curRequest.ID[0] = '\0';
|
||||
async_curProgress = ASYNC_PROGRESS_NOTHING;
|
||||
}
|
||||
Mutex_Unlock(async_curRequestMutex);
|
||||
|
|
|
@ -359,7 +359,7 @@ static void AudioManager_Init(void) {
|
|||
static void AudioManager_Free(void) {
|
||||
Music_Free();
|
||||
Sounds_Free();
|
||||
Waitable_Free(&music_waitable);
|
||||
Waitable_Free(music_waitable);
|
||||
Event_UnregisterBlock(&UserEvents_BlockChanged, NULL, Audio_PlayBlockSound);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "Funcs.h"
|
||||
#include "Block.h"
|
||||
#include "EnvRenderer.h"
|
||||
#include "GameStructs.h"
|
||||
|
||||
#define CHAT_LOGTIMES_DEF_ELEMS 256
|
||||
#define CHAT_LOGTIMES_EXPAND_ELEMS 512
|
||||
|
|
|
@ -238,7 +238,6 @@
|
|||
<ClInclude Include="GraphicsCommon.h" />
|
||||
<ClInclude Include="Platform.h" />
|
||||
<ClInclude Include="String.h" />
|
||||
<ClInclude Include="Texture.h" />
|
||||
<ClInclude Include="Typedefs.h" />
|
||||
<ClInclude Include="Vectors.h" />
|
||||
<ClInclude Include="VertexStructs.h" />
|
||||
|
@ -303,7 +302,6 @@
|
|||
<ClCompile Include="Stream.c" />
|
||||
<ClCompile Include="String.c" />
|
||||
<ClCompile Include="TerrainAtlas.c" />
|
||||
<ClCompile Include="Texture.c" />
|
||||
<ClCompile Include="TexturePack.c" />
|
||||
<ClCompile Include="Utils.c" />
|
||||
<ClCompile Include="Vectors.c" />
|
||||
|
|
|
@ -177,9 +177,6 @@
|
|||
<ClInclude Include="GraphicsCommon.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Texture.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VertexStructs.h">
|
||||
<Filter>Header Files\Graphics</Filter>
|
||||
</ClInclude>
|
||||
|
@ -494,9 +491,6 @@
|
|||
<ClCompile Include="EntityComponents.c">
|
||||
<Filter>Source Files\Entities</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Texture.c">
|
||||
<Filter>Source Files\Graphics</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HeldBlockRenderer.c">
|
||||
<Filter>Source Files\Rendering</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -815,7 +815,7 @@ static ReturnCode Deflate_FlushBlock(struct DeflateState* state, Int32 len) {
|
|||
ReturnCode result = Stream_TryWrite(state->Dest, state->Output, DEFLATE_OUT_SIZE - state->AvailOut);
|
||||
state->NextOut = state->Output;
|
||||
state->AvailOut = DEFLATE_OUT_SIZE;
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
}
|
||||
|
||||
/* literals for last few bytes */
|
||||
|
@ -898,7 +898,7 @@ void Deflate_MakeStream(struct Stream* stream, struct DeflateState* state, struc
|
|||
*#########################################################################################################################*/
|
||||
static ReturnCode GZip_StreamClose(struct Stream* stream) {
|
||||
ReturnCode result = Deflate_StreamClose(stream);
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
|
||||
struct GZipState* state = stream->Meta.Inflate;
|
||||
UInt32 crc32 = state->Crc32 ^ 0xFFFFFFFFUL;
|
||||
|
@ -926,7 +926,7 @@ static ReturnCode GZip_StreamWriteFirst(struct Stream* stream, UInt8* data, UInt
|
|||
struct GZipState* state = stream->Meta.Inflate;
|
||||
|
||||
ReturnCode result = Stream_TryWrite(state->Base.Dest, gz_header, sizeof(gz_header));
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
|
||||
stream->Write = GZip_StreamWrite;
|
||||
return GZip_StreamWrite(stream, data, count, modified);
|
||||
|
@ -946,7 +946,7 @@ void GZip_MakeStream(struct Stream* stream, struct GZipState* state, struct Stre
|
|||
*#########################################################################################################################*/
|
||||
static ReturnCode ZLib_StreamClose(struct Stream* stream) {
|
||||
ReturnCode result = Deflate_StreamClose(stream);
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
|
||||
struct ZLibState* state = stream->Meta.Inflate;
|
||||
Stream_WriteU32_BE(state->Base.Dest, state->Adler32);
|
||||
|
@ -974,7 +974,7 @@ static ReturnCode ZLib_StreamWriteFirst(struct Stream* stream, UInt8* data, UInt
|
|||
struct ZLibState* state = stream->Meta.Inflate;
|
||||
|
||||
ReturnCode result = Stream_TryWrite(state->Base.Dest, zl_header, sizeof(zl_header));
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
|
||||
stream->Write = ZLib_StreamWrite;
|
||||
return ZLib_StreamWrite(stream, data, count, modified);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "Platform.h"
|
||||
#include "ExtMath.h"
|
||||
#include "ErrorHandler.h"
|
||||
#include "Texture.h"
|
||||
#include "GraphicsCommon.h"
|
||||
|
||||
void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF String* text, struct FontDesc* font, bool useShadow) {
|
||||
args->Text = *text;
|
||||
|
@ -178,7 +178,7 @@ UChar Drawer2D_LastCol(STRING_PURE String* text, Int32 start) {
|
|||
return text->buffer[i + 1];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return '\0';
|
||||
}
|
||||
bool Drawer2D_IsWhiteCol(UChar c) { return c == '\0' || c == 'f' || c == 'F'; }
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
#ifndef CC_ENTITY_H
|
||||
#define CC_ENTITY_H
|
||||
#include "Texture.h"
|
||||
#include "EntityComponents.h"
|
||||
#include "Physics.h"
|
||||
#include "GameStructs.h"
|
||||
#include "Constants.h"
|
||||
#include "GraphicsCommon.h"
|
||||
/* Represents an in-game entity.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
|
|
|
@ -630,7 +630,7 @@ static void Dat_ReadFieldDesc(struct Stream* stream, struct JFieldDesc* desc) {
|
|||
|
||||
static void Dat_ReadClassDesc(struct Stream* stream, struct JClassDesc* desc) {
|
||||
UInt8 typeCode = Stream_ReadU8(stream);
|
||||
if (typeCode == TC_NULL) { desc->ClassName[0] = NULL; desc->FieldsCount = 0; return; }
|
||||
if (typeCode == TC_NULL) { desc->ClassName[0] = '\0'; desc->FieldsCount = 0; return; }
|
||||
if (typeCode != TC_CLASSDESC) ErrorHandler_Fail("Unsupported type code in ClassDesc header");
|
||||
|
||||
Dat_ReadString(stream, desc->ClassName);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "Event.h"
|
||||
#include "Funcs.h"
|
||||
#include "ExtMath.h"
|
||||
#include "Texture.h"
|
||||
|
||||
UChar Gfx_ApiBuffer[7][String_BufferSize(STRING_SIZE)];
|
||||
String Gfx_ApiInfo[7] = {
|
||||
|
@ -227,3 +226,38 @@ Int32 GfxCommon_MipmapsLevels(Int32 width, Int32 height) {
|
|||
return max(lvlsWidth, lvlsHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Texture_FromOrigin(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height,
|
||||
Real32 u2, Real32 v2) {
|
||||
Texture_From(tex, id, x, y, width, height, 0, u2, 0, v2);
|
||||
}
|
||||
|
||||
void Texture_FromRec(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, struct TextureRec rec) {
|
||||
Texture_From(tex, id, x, y, width, height, rec.U1, rec.U2, rec.V1, rec.V2);
|
||||
}
|
||||
|
||||
void Texture_From(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height,
|
||||
Real32 u1, Real32 u2, Real32 v1, Real32 v2) {
|
||||
tex->ID = id;
|
||||
tex->X = x; tex->Y = y;
|
||||
tex->Width = width; tex->Height = height;
|
||||
|
||||
tex->U1 = u1; tex->V1 = v1;
|
||||
tex->U2 = u2; tex->V2 = v2;
|
||||
}
|
||||
|
||||
void Texture_MakeInvalid(struct Texture* tex) {
|
||||
struct Texture empty = { 0 }; *tex = empty;
|
||||
}
|
||||
|
||||
void Texture_Render(struct Texture* tex) {
|
||||
Gfx_BindTexture(tex->ID);
|
||||
PackedCol white = PACKEDCOL_WHITE;
|
||||
GfxCommon_Draw2DTexture(tex, white);
|
||||
}
|
||||
|
||||
void Texture_RenderShaded(struct Texture* tex, PackedCol shadeCol) {
|
||||
Gfx_BindTexture(tex->ID);
|
||||
GfxCommon_Draw2DTexture(tex, shadeCol);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
#ifndef CC_GFXCOMMON_H
|
||||
#define CC_GFXCOMMON_H
|
||||
#include "String.h"
|
||||
#include "VertexStructs.h"
|
||||
|
||||
/* Provides common/shared methods for a 3D graphics rendering API.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
struct Texture;
|
||||
|
||||
extern String Gfx_ApiInfo[7];
|
||||
GfxResourceID GfxCommon_defaultIb;
|
||||
|
||||
/* Contains the information necessary to describe a 2D textured quad. */
|
||||
struct Texture {
|
||||
GfxResourceID ID;
|
||||
Int16 X, Y; UInt16 Width, Height;
|
||||
Real32 U1, V1, U2, V2;
|
||||
};
|
||||
|
||||
void GfxCommon_Init(void);
|
||||
void GfxCommon_Free(void);
|
||||
void GfxCommon_LoseContext(const UChar* reason);
|
||||
|
@ -38,4 +42,11 @@ void GfxCommon_RestoreAlphaState(UInt8 draw);
|
|||
|
||||
void GfxCommon_GenMipmaps(Int32 width, Int32 height, UInt8* lvlScan0, UInt8* scan0);
|
||||
Int32 GfxCommon_MipmapsLevels(Int32 width, Int32 height);
|
||||
|
||||
void Texture_FromOrigin(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, Real32 u2, Real32 v2);
|
||||
void Texture_FromRec(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, struct TextureRec rec);
|
||||
void Texture_From(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, Real32 u1, Real32 u2, Real32 v1, Real32 v2);
|
||||
void Texture_MakeInvalid(struct Texture* tex);
|
||||
void Texture_Render(struct Texture* tex);
|
||||
void Texture_RenderShaded(struct Texture* tex, PackedCol shadeCol);
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef CC_GUI_H
|
||||
#define CC_GUI_H
|
||||
#include "Input.h"
|
||||
#include "Texture.h"
|
||||
#include "VertexStructs.h"
|
||||
#include "GraphicsCommon.h"
|
||||
/* Describes and manages 2D GUI elements on screen.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,7 @@ void Platform_UnicodeExpand(void* dstPtr, STRING_PURE String* src) {
|
|||
UInt16 codepoint = Convert_CP437ToUnicode(src->buffer[i]);
|
||||
Int32 len = Stream_WriteUtf8(dst, codepoint); dst += len;
|
||||
}
|
||||
*dst = NULL;
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
static void Platform_InitDisplay(void) {
|
||||
|
|
|
@ -63,7 +63,7 @@ void PackedCol_ToHex(STRING_TRANSIENT String* str, PackedCol value) {
|
|||
hex[i * 2 + 1] = lo < 10 ? (lo + 48) : (lo + 55);
|
||||
}
|
||||
|
||||
hex[6] = NULL; /* Null terminate hex characters */
|
||||
hex[6] = '\0';
|
||||
String_AppendConst(str, hex);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ static void SPConnection_BeginConnect(void) {
|
|||
Gui_ReplaceActive(GeneratingScreen_MakeInstance());
|
||||
}
|
||||
|
||||
UInt8 SPConnection_LastCol = NULL;
|
||||
UChar SPConnection_LastCol = '\0';
|
||||
static void SPConnection_AddPortion(STRING_PURE String* text) {
|
||||
UChar tmpBuffer[String_BufferSize(STRING_SIZE * 2)];
|
||||
String tmp = String_InitAndClearArray(tmpBuffer);
|
||||
|
@ -191,14 +191,14 @@ static void SPConnection_AddPortion(STRING_PURE String* text) {
|
|||
}
|
||||
String_UNSAFE_TrimEnd(&tmp);
|
||||
|
||||
UInt8 col = Drawer2D_LastCol(&tmp, tmp.length);
|
||||
UChar col = Drawer2D_LastCol(&tmp, tmp.length);
|
||||
if (col) SPConnection_LastCol = col;
|
||||
Chat_Add(&tmp);
|
||||
}
|
||||
|
||||
static void SPConnection_SendChat(STRING_PURE String* text) {
|
||||
if (!text->length) return;
|
||||
SPConnection_LastCol = NULL;
|
||||
SPConnection_LastCol = '\0';
|
||||
|
||||
String part = *text;
|
||||
while (part.length > STRING_SIZE) {
|
||||
|
|
|
@ -47,7 +47,7 @@ ReturnCode Stream_TryWrite(struct Stream* stream, UInt8* buffer, UInt32 count) {
|
|||
UInt32 write;
|
||||
while (count > 0) {
|
||||
ReturnCode result = stream->Write(stream, buffer, count, &write);
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
if (!write) return 1;
|
||||
|
||||
buffer += write;
|
||||
|
@ -73,7 +73,7 @@ void Stream_Skip(struct Stream* stream, UInt32 count) {
|
|||
UInt32 toRead = min(count, sizeof(tmp)), read;
|
||||
result = stream->Read(stream, tmp, toRead, &read);
|
||||
|
||||
if (result != 0) Stream_Fail(stream, result, "Skipping data from");
|
||||
if (result) Stream_Fail(stream, result, "Skipping data from");
|
||||
if (!read) break; /* end of stream */
|
||||
count -= read;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ String String_InitAndClear(STRING_REF UChar* buffer, UInt16 capacity) {
|
|||
Int32 i;
|
||||
|
||||
/* Need to set region occupied by string to NULL for interop with native APIs */
|
||||
for (i = 0; i < capacity + 1; i++) { buffer[i] = NULL; }
|
||||
for (i = 0; i < capacity + 1; i++) { buffer[i] = '\0'; }
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ void String_StripCols(STRING_TRANSIENT String* str) {
|
|||
void String_Clear(STRING_TRANSIENT String* str) {
|
||||
Int32 i;
|
||||
for (i = 0; i < str->length; i++) {
|
||||
str->buffer[i] = NULL;
|
||||
str->buffer[i] = '\0';
|
||||
}
|
||||
str->length = 0;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ bool String_AppendReal32(STRING_TRANSIENT String* str, Real32 num, Int32 fracDig
|
|||
}
|
||||
|
||||
bool String_Hex32(STRING_TRANSIENT String* str, UInt32 value) {
|
||||
UChar hex[9]; hex[8] = NULL;
|
||||
UChar hex[9]; hex[8] = '\0';
|
||||
Int32 i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
|
@ -243,7 +243,7 @@ bool String_Hex32(STRING_TRANSIENT String* str, UInt32 value) {
|
|||
}
|
||||
|
||||
bool String_Hex64(STRING_TRANSIENT String* str, UInt64 value) {
|
||||
UChar hex[17]; hex[16] = NULL;
|
||||
UChar hex[17]; hex[16] = '\0';
|
||||
Int32 i;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
@ -327,7 +327,7 @@ void String_DeleteAt(STRING_TRANSIENT String* str, Int32 offset) {
|
|||
str->buffer[i] = str->buffer[i + 1];
|
||||
}
|
||||
|
||||
str->buffer[str->length - 1] = NULL;
|
||||
str->buffer[str->length - 1] = '\0';
|
||||
str->length--;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
#include "Texture.h"
|
||||
#include "GraphicsCommon.h"
|
||||
#include "GraphicsAPI.h"
|
||||
|
||||
void Texture_FromOrigin(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height,
|
||||
Real32 u2, Real32 v2) {
|
||||
Texture_From(tex, id, x, y, width, height, 0, u2, 0, v2);
|
||||
}
|
||||
|
||||
void Texture_FromRec(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, struct TextureRec rec) {
|
||||
Texture_From(tex, id, x, y, width, height, rec.U1, rec.U2, rec.V1, rec.V2);
|
||||
}
|
||||
|
||||
void Texture_From(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height,
|
||||
Real32 u1, Real32 u2, Real32 v1, Real32 v2) {
|
||||
tex->ID = id;
|
||||
tex->X = x; tex->Y = y;
|
||||
tex->Width = width; tex->Height = height;
|
||||
|
||||
tex->U1 = u1; tex->V1 = v1;
|
||||
tex->U2 = u2; tex->V2 = v2;
|
||||
}
|
||||
|
||||
void Texture_MakeInvalid(struct Texture* tex) {
|
||||
struct Texture empty = { 0 }; *tex = empty;
|
||||
}
|
||||
|
||||
void Texture_Render(struct Texture* tex) {
|
||||
Gfx_BindTexture(tex->ID);
|
||||
PackedCol white = PACKEDCOL_WHITE;
|
||||
GfxCommon_Draw2DTexture(tex, white);
|
||||
}
|
||||
|
||||
void Texture_RenderShaded(struct Texture* tex, PackedCol shadeCol) {
|
||||
Gfx_BindTexture(tex->ID);
|
||||
GfxCommon_Draw2DTexture(tex, shadeCol);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef CC_TEXTURE_H
|
||||
#define CC_TEXTURE_H
|
||||
#include "PackedCol.h"
|
||||
#include "2DStructs.h"
|
||||
|
||||
/* Represents a simple 2D textured quad.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
|
||||
/* Contains the information necessary to describe a 2D textured quad. */
|
||||
struct Texture {
|
||||
GfxResourceID ID; /* Native texture ID.*/
|
||||
Int16 X, Y; /* Origin of quad. */
|
||||
UInt16 Width, Height; /* Dimensions of quad. */
|
||||
Real32 U1, V1; /* Texture coordinates of top left corner. */
|
||||
Real32 U2, V2; /* Texture coordinates of bottom right corner. */
|
||||
};
|
||||
|
||||
void Texture_FromOrigin(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, Real32 u2, Real32 v2);
|
||||
void Texture_FromRec(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, struct TextureRec rec);
|
||||
void Texture_From(struct Texture* tex, GfxResourceID id, Int32 x, Int32 y, Int32 width, Int32 height, Real32 u1, Real32 u2, Real32 v1, Real32 v2);
|
||||
void Texture_MakeInvalid(struct Texture* tex) ;
|
||||
|
||||
void Texture_Render(struct Texture* tex);
|
||||
void Texture_RenderShaded(struct Texture* tex, PackedCol shadeCol);
|
||||
#endif
|
|
@ -23,7 +23,7 @@ static String Zip_ReadFixedString(struct Stream* stream, UChar* buffer, UInt16 l
|
|||
if (length > ZIP_MAXNAMELEN) ErrorHandler_Fail("Zip string too long");
|
||||
String fileName = String_Init(buffer, length, length);
|
||||
Stream_Read(stream, buffer, length);
|
||||
buffer[length] = NULL; /* Ensure null terminated */
|
||||
buffer[length] = '\0';
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef double Real64;
|
|||
typedef UInt8 bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define NULL 0
|
||||
#define NULL ((void*)0)
|
||||
|
||||
#if USE16_BIT
|
||||
typedef UInt16 BlockID;
|
||||
|
|
|
@ -953,7 +953,7 @@ static UChar InputWidget_GetLastCol(struct InputWidget* widget, Int32 indexX, In
|
|||
if (code) return code;
|
||||
if (y > 0) { x = widget->Lines[y - 1].length; }
|
||||
}
|
||||
return NULL;
|
||||
return '\0';
|
||||
}
|
||||
|
||||
static void InputWidget_UpdateCaret(struct InputWidget* widget) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "BlockID.h"
|
||||
#include "Constants.h"
|
||||
#include "Entity.h"
|
||||
#include "2DStructs.h"
|
||||
/* Contains all 2D widget implementations.
|
||||
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
#include <mmsystem.h>
|
||||
|
||||
/* Missing from some old MingW32 headers */
|
||||
#ifndef HTTP_QUERY_ETAG
|
||||
#define HTTP_QUERY_ETAG 54
|
||||
#endif
|
||||
|
||||
HDC hdc;
|
||||
HANDLE heap;
|
||||
|
@ -41,16 +43,16 @@ void Platform_UnicodeExpand(void* dstPtr, STRING_PURE String* src) {
|
|||
for (i = 0; i < src->length; i++) {
|
||||
*dst = Convert_CP437ToUnicode(src->buffer[i]); dst++;
|
||||
}
|
||||
*dst = NULL;
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
static void Platform_InitDisplay(void) {
|
||||
HDC hdc = GetDC(NULL);
|
||||
struct DisplayDevice device = { 0 };
|
||||
|
||||
device.Bounds.Width = GetSystemMetrics(SM_CXSCREEN);
|
||||
device.Bounds.Height = GetSystemMetrics(SM_CYSCREEN);
|
||||
device.BitsPerPixel = GetDeviceCaps(hdc, BITSPIXEL);
|
||||
device.Bounds.Width = GetSystemMetrics(SM_CXSCREEN);
|
||||
device.Bounds.Height = GetSystemMetrics(SM_CYSCREEN);
|
||||
device.BitsPerPixel = GetDeviceCaps(hdc, BITSPIXEL);
|
||||
DisplayDevice_Default = device;
|
||||
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
@ -230,15 +232,15 @@ ReturnCode Directory_Enum(STRING_PURE String* path, void* obj, Directory_EnumCal
|
|||
callback(&file, obj);
|
||||
} while (FindNextFileW(find, &entry));
|
||||
|
||||
ReturnCode code = GetLastError(); /* return code from FindNextFile */
|
||||
ReturnCode result = GetLastError(); /* return code from FindNextFile */
|
||||
FindClose(find);
|
||||
return code == ERROR_NO_MORE_FILES ? 0 : code;
|
||||
return result == ERROR_NO_MORE_FILES ? 0 : result;
|
||||
}
|
||||
|
||||
ReturnCode File_GetModifiedTime(STRING_PURE String* path, DateTime* time) {
|
||||
void* file;
|
||||
ReturnCode result = File_Open(&file, path);
|
||||
if (result != 0) return result;
|
||||
if (result) return result;
|
||||
|
||||
FILETIME writeTime;
|
||||
if (GetFileTime(file, NULL, NULL, &writeTime)) {
|
||||
|
@ -361,14 +363,14 @@ void Mutex_Unlock(void* handle) {
|
|||
void* Waitable_Create(void) {
|
||||
void* handle = CreateEventW(NULL, false, false, NULL);
|
||||
if (!handle) {
|
||||
ErrorHandler_FailWithCode(GetLastError(), "Creating event");
|
||||
ErrorHandler_FailWithCode(GetLastError(), "Creating waitable");
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Waitable_Free(void* handle) {
|
||||
if (!CloseHandle((HANDLE)handle)) {
|
||||
ErrorHandler_FailWithCode(GetLastError(), "Freeing event");
|
||||
ErrorHandler_FailWithCode(GetLastError(), "Freeing waitable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -483,7 +483,7 @@ void Window_SetClipboardText(STRING_PURE String* value) {
|
|||
for (i = 0; i < value->length; i++) {
|
||||
*text = Convert_CP437ToUnicode(value->buffer[i]); text++;
|
||||
}
|
||||
*text = NULL;
|
||||
*text = '\0';
|
||||
|
||||
GlobalUnlock(hGlobal);
|
||||
EmptyClipboard();
|
||||
|
|
Loading…
Add table
Reference in a new issue