From 4ac9498ec5fc5dba251134752686a2741b9a2063 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 16 May 2019 14:53:17 +1000 Subject: [PATCH] more of that --- src/Block.c | 14 +++++++------- src/Block.h | 21 +++++++++------------ src/Core.h | 3 ++- src/EnvRenderer.c | 10 +++++----- src/Graphics.c | 4 ++-- src/Gui.c | 17 +++++++++-------- src/Menus.c | 10 +++++----- src/Options.c | 8 +++----- src/Platform.c | 18 +++++++++--------- src/Platform.h | 4 ++-- src/Stream.c | 8 ++++---- src/TexturePack.c | 2 +- src/Window.c | 14 +++++++------- 13 files changed, 65 insertions(+), 68 deletions(-) diff --git a/src/Block.c b/src/Block.c index bedee5a03..144d83c98 100644 --- a/src/Block.c +++ b/src/Block.c @@ -47,7 +47,7 @@ static PackedCol DefaultSet_FogColour(BlockID b) { return colZero; } -static DrawType DefaultSet_Draw(BlockID b) { +static uint8_t DefaultSet_Draw(BlockID b) { if (b == BLOCK_AIR) return DRAW_GAS; if (b == BLOCK_LEAVES) return DRAW_TRANSPARENT_THICK; @@ -68,7 +68,7 @@ static bool DefaultSet_BlocksLight(BlockID b) { || b == BLOCK_AIR || DefaultSet_Draw(b) == DRAW_SPRITE); } -static CollideType DefaultSet_Collide(BlockID b) { +static uint8_t DefaultSet_Collide(BlockID b) { if (b == BLOCK_ICE) return COLLIDE_ICE; if (b == BLOCK_WATER || b == BLOCK_STILL_WATER) return COLLIDE_LIQUID_WATER; if (b == BLOCK_LAVA || b == BLOCK_STILL_LAVA) return COLLIDE_LIQUID_LAVA; @@ -79,7 +79,7 @@ static CollideType DefaultSet_Collide(BlockID b) { } /* Returns a backwards compatible collide type of a block. */ -static CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide) { +static uint8_t DefaultSet_MapOldCollide(BlockID b, uint8_t collide) { if (b == BLOCK_ROPE && collide == COLLIDE_GAS) return COLLIDE_CLIMB_ROPE; if (b == BLOCK_ICE && collide == COLLIDE_SOLID) return COLLIDE_ICE; @@ -90,7 +90,7 @@ static CollideType DefaultSet_MapOldCollide(BlockID b, CollideType collide) { return collide; } -static SoundType DefaultSet_DigSound(BlockID b) { +static uint8_t DefaultSet_DigSound(BlockID b) { if (b >= BLOCK_RED && b <= BLOCK_WHITE) return SOUND_CLOTH; if (b >= BLOCK_LIGHT_PINK && b <= BLOCK_TURQUOISE) return SOUND_CLOTH; if (b == BLOCK_IRON || b == BLOCK_GOLD) return SOUND_METAL; @@ -113,7 +113,7 @@ static SoundType DefaultSet_DigSound(BlockID b) { return SOUND_NONE; } -static SoundType DefaultSet_StepSound(BlockID b) { +static uint8_t DefaultSet_StepSound(BlockID b) { if (b == BLOCK_GLASS) return SOUND_STONE; if (b == BLOCK_ROPE) return SOUND_CLOTH; if (DefaultSet_Draw(b) == DRAW_SPRITE) return SOUND_NONE; @@ -177,7 +177,7 @@ static void Block_RecalcIsLiquid(BlockID b) { (collide == COLLIDE_LIQUID_LAVA && Blocks.Draw[b] == DRAW_TRANSPARENT); } -void Block_SetCollide(BlockID block, CollideType collide) { +void Block_SetCollide(BlockID block, uint8_t collide) { /* necessary if servers redefined core blocks, before extended collide types were added */ collide = DefaultSet_MapOldCollide(block, collide); Blocks.ExtendedCollide[block] = collide; @@ -192,7 +192,7 @@ void Block_SetCollide(BlockID block, CollideType collide) { Blocks.Collide[block] = collide; } -void Block_SetDrawType(BlockID block, DrawType draw) { +void Block_SetDrawType(BlockID block, uint8_t draw) { Vector3 zero = Vector3_Zero(); Vector3 one = Vector3_One(); diff --git a/src/Block.h b/src/Block.h index 749232b7e..b9b5d26d7 100644 --- a/src/Block.h +++ b/src/Block.h @@ -11,25 +11,25 @@ struct IGameComponent; extern struct IGameComponent Blocks_Component; -typedef enum SoundType_ { +enum SoundType { SOUND_NONE, SOUND_WOOD, SOUND_GRAVEL, SOUND_GRASS, SOUND_STONE, SOUND_METAL, SOUND_GLASS, SOUND_CLOTH, SOUND_SAND, SOUND_SNOW, SOUND_COUNT -} SoundType; +}; extern const char* Sound_Names[SOUND_COUNT]; /* Describes how a block is rendered in the world. */ -typedef enum DrawType_ { +enum DrawType { DRAW_OPAQUE, /* Completely covers blocks behind (e.g. dirt). */ DRAW_TRANSPARENT, /* Blocks behind show (e.g. glass). Pixels either fully visible or invisible. */ DRAW_TRANSPARENT_THICK, /* Same as Transparent, but all neighbour faces show. (e.g. leaves) */ DRAW_TRANSLUCENT, /* Blocks behind show (e.g. water). Pixels blend with other blocks behind. */ DRAW_GAS, /* Does not show (e.g. air). Can still be collided with. */ DRAW_SPRITE /* Block renders as an X (e.g. sapling). Pixels either fully visible or invisible. */ -} DrawType; +}; /* Describes the interaction a block has with a player when they collide with it. */ -typedef enum CollideType_ { +enum CollideType { COLLIDE_GAS, /* No interaction when player collides. */ COLLIDE_LIQUID, /* 'swimming'/'bobbing' interaction when player collides. */ COLLIDE_SOLID, /* Block completely stops the player when they are moving. */ @@ -38,7 +38,7 @@ typedef enum CollideType_ { COLLIDE_LIQUID_WATER, /* Water style 'swimming'/'bobbing' interaction when player collides. */ COLLIDE_LIQUID_LAVA, /* Lava style 'swimming'/'bobbing' interaction when player collides. */ COLLIDE_CLIMB_ROPE /* Rope/Ladder style climbing interaction when player collides. */ -} CollideType; +}; CC_VAR extern struct _BlockLists { /* Whether this block is a liquid. (Like water/lava) */ @@ -110,10 +110,6 @@ if (Blocks.Tinted[block]) {\ col.B = (uint8_t)(col.B * tintCol.B / 255);\ } -#ifdef EXTENDED_BLOCKS -extern void Block_SetUsedCount(int count); -#endif - /* Returns whether the given block has been changed from default. */ bool Block_IsCustomDefined(BlockID block); /* Sets whether the given block has been changed from default. */ @@ -121,8 +117,9 @@ void Block_SetCustomDefined(BlockID block, bool defined); void Block_DefineCustom(BlockID block); /* Sets the basic and extended collide types of the given block. */ -void Block_SetCollide(BlockID block, CollideType collide); -void Block_SetDrawType(BlockID block, DrawType draw); +void Block_SetCollide(BlockID block, uint8_t collide); +/* Sets draw type and updates related state (e.g. FullOpaque) for the given block. */ +void Block_SetDrawType(BlockID block, uint8_t draw); /* Resets all the properties of the given block to default. */ void Block_ResetProps(BlockID block); diff --git a/src/Core.h b/src/Core.h index 1292ee75c..af5a0b95e 100644 --- a/src/Core.h +++ b/src/Core.h @@ -56,6 +56,7 @@ typedef uint16_t Codepoint; #ifdef __APPLE__ /* TODO: REMOVE THIS AWFUL AWFUL HACK */ #include +#elif __cplusplus #else typedef uint8_t bool; #define true 1 @@ -63,7 +64,7 @@ typedef uint8_t bool; #endif #ifndef NULL -#ifdef __cplusplus +#if __cplusplus #define NULL 0 #else #define NULL ((void*)0) diff --git a/src/EnvRenderer.c b/src/EnvRenderer.c index 5e4dd99e8..4e4486877 100644 --- a/src/EnvRenderer.c +++ b/src/EnvRenderer.c @@ -194,7 +194,7 @@ static void EnvRenderer_UpdateClouds(void) { ptr = v; if (clouds_vertices > ENV_SMALL_VERTICES) { - ptr = Mem_Alloc(clouds_vertices, sizeof(VertexP3fT2fC4b), "temp clouds vertices"); + ptr = (VertexP3fT2fC4b*)Mem_Alloc(clouds_vertices, sizeof(VertexP3fT2fC4b), "clouds vertices"); } EnvRenderer_DrawCloudsY(x1, z1, x2, z2, Env.CloudsHeight, ptr); @@ -273,7 +273,7 @@ static void EnvRenderer_UpdateSky(void) { ptr = v; if (sky_vertices > ENV_SMALL_VERTICES) { - ptr = Mem_Alloc(sky_vertices, sizeof(VertexP3fC4b), "temp sky vertices"); + ptr = (VertexP3fC4b*)Mem_Alloc(sky_vertices, sizeof(VertexP3fC4b), "sky vertices"); } height = max((World.Height + 2), Env.CloudsHeight) + 6; @@ -368,7 +368,7 @@ static Vector3I weather_lastPos; static void EnvRenderer_InitWeatherHeightmap(void) { int i; - Weather_Heightmap = Mem_Alloc(World.Width * World.Length, 2, "weather heightmap"); + Weather_Heightmap = (int16_t*)Mem_Alloc(World.Width * World.Length, 2, "weather heightmap"); for (i = 0; i < World.Width * World.Length; i++) { Weather_Heightmap[i] = Int16_MaxValue; @@ -714,7 +714,7 @@ static void EnvRenderer_UpdateMapSides(void) { ptr = v; if (sides_vertices > ENV_SMALL_VERTICES) { - ptr = Mem_Alloc(sides_vertices, sizeof(VertexP3fT2fC4b), "temp sides vertices"); + ptr = (VertexP3fT2fC4b*)Mem_Alloc(sides_vertices, sizeof(VertexP3fT2fC4b), "sides vertices"); } cur = ptr; @@ -768,7 +768,7 @@ static void EnvRenderer_UpdateMapEdges(void) { ptr = v; if (edges_vertices > ENV_SMALL_VERTICES) { - ptr = Mem_Alloc(edges_vertices, sizeof(VertexP3fT2fC4b), "temp edge vertices"); + ptr = (VertexP3fT2fC4b*)Mem_Alloc(edges_vertices, sizeof(VertexP3fT2fC4b), "edge vertices"); } cur = ptr; diff --git a/src/Graphics.c b/src/Graphics.c index aaa09fe6d..07473e5ea 100644 --- a/src/Graphics.c +++ b/src/Graphics.c @@ -373,7 +373,7 @@ static void D3D9_RecreateDevice(void) { void Gfx_Init(void) { Gfx.MinZNear = 0.05f; - void* winHandle = Window_GetHandle(); + HWND winHandle = (HWND)Window_GetHandle(); d3d = Direct3DCreate9(D3D_SDK_VERSION); D3D9_FindCompatibleFormat(); @@ -465,7 +465,7 @@ static void D3D9_DoMipmaps(IDirect3DTexture9* texture, int x, int y, Bitmap* bmp if (width > 1) width /= 2; if (height > 1) height /= 2; - cur = Mem_Alloc(width * height, 4, "mipmaps"); + cur = (uint8_t*)Mem_Alloc(width * height, 4, "mipmaps"); Gfx_GenMipmaps(width, height, cur, prev); Bitmap_Init(mipmap, width, height, cur); diff --git a/src/Gui.c b/src/Gui.c index a08f8251d..bc8ab1714 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -24,12 +24,12 @@ struct Screen* Gui_Overlays[GUI_MAX_OVERLAYS]; int Gui_OverlaysCount; void Gui_DefaultRecreate(void* elem) { - struct GuiElem* e = elem; + struct GuiElem* e = (struct GuiElem*)elem; Elem_Free(e); Elem_Init(e); } void Screen_CommonInit(void* screen) { - struct Screen* s = screen; + struct Screen* s = (struct Screen*)screen; Event_RegisterVoid(&GfxEvents.ContextLost, s, s->VTABLE->ContextLost); Event_RegisterVoid(&GfxEvents.ContextRecreated, s, s->VTABLE->ContextRecreated); @@ -37,27 +37,28 @@ void Screen_CommonInit(void* screen) { s->VTABLE->ContextRecreated(s); } -void Screen_CommonFree(void* screen) { struct Screen* s = screen; +void Screen_CommonFree(void* screen) { + struct Screen* s = (struct Screen*)screen; Event_UnregisterVoid(&GfxEvents.ContextLost, s, s->VTABLE->ContextLost); Event_UnregisterVoid(&GfxEvents.ContextRecreated, s, s->VTABLE->ContextRecreated); s->VTABLE->ContextLost(s); } void Widget_SetLocation(void* widget, uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) { - struct Widget* w = widget; + struct Widget* w = (struct Widget*)widget; w->HorAnchor = horAnchor; w->VerAnchor = verAnchor; w->XOffset = xOffset; w->YOffset = yOffset; Widget_Reposition(w); } void Widget_CalcPosition(void* widget) { - struct Widget* w = widget; + struct Widget* w = (struct Widget*)widget; w->X = Gui_CalcPos(w->HorAnchor, w->XOffset, w->Width , Game.Width ); w->Y = Gui_CalcPos(w->VerAnchor, w->YOffset, w->Height, Game.Height); } void Widget_Reset(void* widget) { - struct Widget* w = widget; + struct Widget* w = (struct Widget*)widget; w->Active = false; w->Disabled = false; w->X = 0; w->Y = 0; @@ -69,7 +70,7 @@ void Widget_Reset(void* widget) { } bool Widget_Contains(void* widget, int x, int y) { - struct Widget* w = widget; + struct Widget* w = (struct Widget*)widget; return Gui_Contains(w->X, w->Y, w->Width, w->Height, x, y); } @@ -176,7 +177,7 @@ void Gui_FreeActive(void) { if (Gui_Active) { Elem_TryFree(Gui_Active); } } void Gui_Close(void* screen) { - struct Screen* s = screen; + struct Screen* s = (struct Screen*)screen; if (s) { Elem_TryFree(s); } if (s == Gui_Active) Gui_SetActive(NULL); } diff --git a/src/Menus.c b/src/Menus.c index 761f0635c..b6b8a5cea 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -473,8 +473,8 @@ static void ListScreen_QuickSort(int left, int right) { } } -static String ListScreen_UNSAFE_GetCur(struct ListScreen* s, struct Widget* w) { - int i = Menu_Index(s, w); +static String ListScreen_UNSAFE_GetCur(struct ListScreen* s, void* widget) { + int i = Menu_Index(s, widget); return ListScreen_UNSAFE_Get(s, s->CurrentIndex + i); } @@ -1046,7 +1046,7 @@ static void GenLevelScreen_InputClick(void* screen, void* input) { struct GenLevelScreen* s = (struct GenLevelScreen*)screen; if (s->Selected) s->Selected->Base.ShowCaret = false; - s->Selected = input; + s->Selected = (struct MenuInputWidget*)input; Elem_HandlesMouseDown(&s->Selected->Base, Mouse_X, Mouse_Y, MOUSE_LEFT); s->Selected->Base.ShowCaret = true; } @@ -1263,7 +1263,7 @@ static void SaveLevelScreen_Save(void* screen, void* widget, const char* ext) { String path; char pathBuffer[FILENAME_SIZE]; struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen; - struct ButtonWidget* btn = widget; + struct ButtonWidget* btn = (struct ButtonWidget*)widget; String file = s->Input.Base.Text; if (!file.length) { @@ -2917,7 +2917,7 @@ static void WarningOverlay_MakeButtons(void* menu, struct ButtonWidget* btns, bo const static String alwaysYes = String_FromConst("Always yes"); const static String alwaysNo = String_FromConst("Always no"); - struct MenuScreen* s = menu; + struct MenuScreen* s = (struct MenuScreen*)menu; Menu_Button(s, 4, &btns[0], 160, &yes, &s->TitleFont, yesClick, ANCHOR_CENTRE, ANCHOR_CENTRE, -110, 30); Menu_Button(s, 5, &btns[1], 160, &no, &s->TitleFont, noClick, diff --git a/src/Options.c b/src/Options.c index af7618270..5825a5f3e 100644 --- a/src/Options.c +++ b/src/Options.c @@ -175,7 +175,7 @@ void Options_SetSecure(const char* opt, const String* src, const String* key) { if (Platform_Encrypt(src->buffer, src->length, &enc, &encLen)) { /* fallback to NOT SECURE XOR. Prevents simple reading from options.txt */ encLen = src->length; - enc = Mem_Alloc(encLen, 1, "XOR encode"); + enc = (uint8_t*)Mem_Alloc(encLen, 1, "XOR encode"); for (i = 0; i < encLen; i++) { enc[i] = (uint8_t)(src->buffer[i] ^ key->buffer[i % key->length] ^ 0x43); @@ -205,15 +205,13 @@ void Options_GetSecure(const char* opt, String* dst, const String* key) { if (Platform_Decrypt(data, dataLen, &dec, &decLen)) { /* fallback to NOT SECURE XOR. Prevents simple reading from options.txt */ decLen = dataLen; - dec = Mem_Alloc(decLen, 1, "XOR decode"); + dec = (uint8_t*)Mem_Alloc(decLen, 1, "XOR decode"); for (i = 0; i < decLen; i++) { dec[i] = (uint8_t)(data[i] ^ key->buffer[i % key->length] ^ 0x43); } } - for (i = 0; i < decLen; i++) { - String_Append(dst, dec[i]); - } + for (i = 0; i < decLen; i++) String_Append(dst, dec[i]); Mem_Free(dec); } diff --git a/src/Platform.c b/src/Platform.c index 213973edd..410994b13 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -855,9 +855,9 @@ typedef struct FontData_ { static unsigned long FontData_Read(FT_Stream s, unsigned long offset, unsigned char* buffer, unsigned long count) { FontData* data; ReturnCode res; - if (!count && offset > s->size) return 1; - data = s->descriptor.pointer; + + data = (FontData*)s->descriptor.pointer; if (s->pos != offset) data->src.Seek(&data->src, offset); res = Stream_Read(&data->src, buffer, count); @@ -1535,7 +1535,7 @@ ReturnCode DynamicLib_Load(const String* path, void** lib) { } ReturnCode DynamicLib_Get(void* lib, const char* name, void** symbol) { - *symbol = GetProcAddress(lib, name); + *symbol = GetProcAddress((HMODULE)lib, name); return *symbol ? 0 : GetLastError(); } @@ -1818,25 +1818,25 @@ int Platform_GetCommandLineArgs(int argc, STRING_REF const char** argv, String* return i; } -ReturnCode Platform_Encrypt(const uint8_t* data, int len, uint8_t** enc, int* encLen) { +ReturnCode Platform_Encrypt(const void* data, int len, uint8_t** enc, int* encLen) { DATA_BLOB dataIn, dataOut; dataIn.cbData = len; dataIn.pbData = data; if (!CryptProtectData(&dataIn, NULL, NULL, NULL, NULL, 0, &dataOut)) return GetLastError(); /* copy to memory we can free */ - *enc = Mem_Alloc(dataOut.cbData, 1, "encrypt data"); + *enc = (uint8_t*)Mem_Alloc(dataOut.cbData, 1, "encrypt data"); *encLen = dataOut.cbData; Mem_Copy(*enc, dataOut.pbData, dataOut.cbData); LocalFree(dataOut.pbData); return 0; } -ReturnCode Platform_Decrypt(const uint8_t* data, int len, uint8_t** dec, int* decLen) { +ReturnCode Platform_Decrypt(const void* data, int len, uint8_t** dec, int* decLen) { DATA_BLOB dataIn, dataOut; dataIn.cbData = len; dataIn.pbData = data; if (!CryptUnprotectData(&dataIn, NULL, NULL, NULL, NULL, 0, &dataOut)) return GetLastError(); /* copy to memory we can free */ - *dec = Mem_Alloc(dataOut.cbData, 1, "decrypt data"); + *dec = (uint8_t*)Mem_Alloc(dataOut.cbData, 1, "decrypt data"); *decLen = dataOut.cbData; Mem_Copy(*dec, dataOut.pbData, dataOut.cbData); LocalFree(dataOut.pbData); @@ -1904,10 +1904,10 @@ int Platform_GetCommandLineArgs(int argc, STRING_REF const char** argv, String* return count; } -ReturnCode Platform_Encrypt(const uint8_t* data, int len, uint8_t** enc, int* encLen) { +ReturnCode Platform_Encrypt(const void* data, int len, uint8_t** enc, int* encLen) { return ERR_NOT_SUPPORTED; } -ReturnCode Platform_Decrypt(const uint8_t* data, int len, uint8_t** dec, int* decLen) { +ReturnCode Platform_Decrypt(const void* data, int len, uint8_t** dec, int* decLen) { return ERR_NOT_SUPPORTED; } diff --git a/src/Platform.h b/src/Platform.h index 247cc7b09..1db3bbdd6 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -48,10 +48,10 @@ CC_API ReturnCode Platform_MarkExecutable(const String* path); int Platform_GetCommandLineArgs(int argc, STRING_REF const char** argv, String* args); /* Encrypts data in a platform-specific manner. (may not be supported) */ /* NOTE: Should only be implemented when platform natively supports it. */ -ReturnCode Platform_Encrypt(const uint8_t* data, int len, uint8_t** enc, int* encLen); +ReturnCode Platform_Encrypt(const void* data, int len, uint8_t** enc, int* encLen); /* Decrypts data in a platform-specific manner. (may not be supported) */ /* NOTE: Should only be implemented when platform natively supports it. */ -ReturnCode Platform_Decrypt(const uint8_t* data, int len, uint8_t** dec, int* decLen); +ReturnCode Platform_Decrypt(const void* data, int len, uint8_t** dec, int* decLen); /* Outputs more detailed information about errors with operating system functions. */ /* NOTE: This is for general functions like file I/O. If a more specific describe exists (e.g. DynamicLib_DescribeError), that should be preferred. */ diff --git a/src/Stream.c b/src/Stream.c index 928f602cb..7804c15e0 100644 --- a/src/Stream.c +++ b/src/Stream.c @@ -270,10 +270,10 @@ static void Stream_CommonMemory(struct Stream* s, void* data, uint32_t len) { s->Position = Stream_MemoryPosition; s->Length = Stream_MemoryLength; - s->Meta.Mem.Cur = data; + s->Meta.Mem.Cur = (uint8_t*)data; s->Meta.Mem.Left = len; s->Meta.Mem.Length = len; - s->Meta.Mem.Base = data; + s->Meta.Mem.Base = (uint8_t*)data; } void Stream_ReadonlyMemory(struct Stream* s, void* data, uint32_t len) { @@ -359,8 +359,8 @@ void Stream_ReadonlyBuffered(struct Stream* s, struct Stream* source, void* data s->Meta.Buffered.Left = 0; s->Meta.Buffered.End = 0; - s->Meta.Buffered.Cur = data; - s->Meta.Buffered.Base = data; + s->Meta.Buffered.Cur = (uint8_t*)data; + s->Meta.Buffered.Base = (uint8_t*)data; s->Meta.Buffered.Length = size; s->Meta.Buffered.Source = source; } diff --git a/src/TexturePack.c b/src/TexturePack.c index 7d44c3e1b..4cfcf9c29 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -234,7 +234,7 @@ static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, int s /* cannot allocate memory on the stack for very big animation.png frames */ if (size > ANIMS_FAST_SIZE) { - ptr = Mem_Alloc(size * size, 4, "anim frame"); + ptr = (uint8_t*)Mem_Alloc(size * size, 4, "anim frame"); } Bitmap_Init(frame, size, size, ptr); diff --git a/src/Window.c b/src/Window.c index bbbe82cff..ea989444e 100644 --- a/src/Window.c +++ b/src/Window.c @@ -149,7 +149,7 @@ const static uint8_t key_map[14 * 16] = { KEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_LBRACKET, KEY_BACKSLASH, KEY_RBRACKET, KEY_QUOTE, 0, }; -static Key Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } +static int Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } static void Window_ResetWindowState(void) { suppress_resize++; @@ -534,7 +534,7 @@ void Window_SetClipboardText(const String* value) { HANDLE hGlobal = GlobalAlloc(GMEM_MOVEABLE, (value->length + 1) * 2); if (!hGlobal) { CloseClipboard(); return; } - Codepoint* text = GlobalLock(hGlobal); + Codepoint* text = (Codepoint*)GlobalLock(hGlobal); for (i = 0; i < value->length; i++, text++) { *text = Convert_CP437ToUnicode(value->buffer[i]); } @@ -665,7 +665,7 @@ void Window_ShowDialog(const char* title, const char* msg) { MessageBoxA(win_handle, msg, title, 0); } -static HGDIOBJ draw_DC; +static HDC draw_DC; static HBITMAP draw_DIB; void Window_InitRaw(Bitmap* bmp) { BITMAPINFO hdr = { 0 }; @@ -762,7 +762,7 @@ static long win_eventMask; /*########################################################################################################################* *-----------------------------------------------------Private details-----------------------------------------------------* *#########################################################################################################################*/ -static Key Window_MapKey(KeySym key) { +static int Window_MapKey(KeySym key) { if (key >= XK_0 && key <= XK_9) { return '0' + (key - XK_0); } if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); } if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); } @@ -1653,7 +1653,7 @@ const static uint8_t key_map[8 * 16] = { KEY_F5, KEY_F6, KEY_F7, KEY_F3, KEY_F8, KEY_F9, 0, KEY_F11, 0, KEY_F13, 0, KEY_F14, 0, KEY_F10, 0, KEY_F12, 'U', KEY_F15, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_F4, KEY_END, KEY_F2, KEY_PAGEDOWN, KEY_F1, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0, }; -static Key Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } +static int Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; } /* TODO: Check these.. */ /* case 0x37: return KEY_LWIN; */ /* case 0x38: return KEY_LSHIFT; */ @@ -2381,7 +2381,7 @@ void Window_Close(void) { SDL_PushEvent(&e); } -static Key Window_MapKey(SDL_Keycode k) { +static int Window_MapKey(SDL_Keycode k) { if (k >= SDLK_0 && k <= SDLK_9) { return '0' + (k - SDLK_0); } if (k >= SDLK_a && k <= SDLK_z) { return 'A' + (k - SDLK_a); } if (k >= SDLK_F1 && k <= SDLK_F12) { return KEY_F1 + (k - SDLK_F1); } @@ -2697,7 +2697,7 @@ static const char* Window_BeforeUnload(int type, const void* ev, void *data) { return NULL; } -static Key Window_MapKey(int k) { +static int Window_MapKey(int k) { if (k >= '0' && k <= '9') return k; if (k >= 'A' && k <= 'Z') return k; if (k >= DOM_VK_F1 && k <= DOM_VK_F24) { return KEY_F1 + (k - DOM_VK_F1); }