less compile errors as C++

This commit is contained in:
UnknownShadow200 2019-05-16 11:23:12 +10:00
parent 63ab591b69
commit a154f617b3
15 changed files with 131 additions and 131 deletions

View File

@ -431,7 +431,7 @@ ReturnCode Audio_StopAndClose(AudioHandle handle) {
*#########################################################################################################################*/ *#########################################################################################################################*/
struct Sound { struct Sound {
struct AudioFormat Format; struct AudioFormat Format;
uint8_t* Data; uint32_t DataSize; uint8_t* Data; uint32_t Size;
}; };
#define AUDIO_MAX_SOUNDS 10 #define AUDIO_MAX_SOUNDS 10
@ -475,8 +475,8 @@ static ReturnCode Sound_ReadWaveData(struct Stream* stream, struct Sound* snd) {
snd->Format.BitsPerSample = Stream_GetU16_LE(&tmp[14]); snd->Format.BitsPerSample = Stream_GetU16_LE(&tmp[14]);
size -= WAV_FMT_SIZE; size -= WAV_FMT_SIZE;
} else if (fourCC == WAV_FourCC('d','a','t','a')) { } else if (fourCC == WAV_FourCC('d','a','t','a')) {
snd->Data = Mem_Alloc(size, 1, "WAV sound data"); snd->Data = (uint8_t*)Mem_Alloc(size, 1, "WAV sound data");
snd->DataSize = size; snd->Size = size;
return Stream_Read(stream, snd->Data, size); return Stream_Read(stream, snd->Data, size);
} }
@ -553,8 +553,8 @@ static void Soundboard_Init(struct Soundboard* board, const String* boardName, S
if (res) { if (res) {
Logger_Warn2(res, "decoding", &file); Logger_Warn2(res, "decoding", &file);
Mem_Free(snd->Data); Mem_Free(snd->Data);
snd->Data = NULL; snd->Data = NULL;
snd->DataSize = 0; snd->Size = 0;
} else { group->Count++; } } else { group->Count++; }
} }
} }
@ -604,23 +604,23 @@ static void Sounds_PlayRaw(struct SoundOutput* output, struct Sound* snd, struct
/* copy to temp buffer to apply volume */ /* copy to temp buffer to apply volume */
if (volume < 100) { if (volume < 100) {
if (output->BufferSize < snd->DataSize) { if (output->BufferSize < snd->Size) {
expandBy = snd->DataSize - output->BufferSize; expandBy = snd->Size - output->BufferSize;
output->Buffer = Utils_Resize(output->Buffer, &output->BufferSize, output->Buffer = Utils_Resize(output->Buffer, &output->BufferSize,
1, AUDIO_DEF_ELEMS, expandBy); 1, AUDIO_DEF_ELEMS, expandBy);
} }
data = output->Buffer; data = output->Buffer;
Mem_Copy(data, snd->Data, snd->DataSize); Mem_Copy(data, snd->Data, snd->Size);
if (fmt->BitsPerSample == 8) { if (fmt->BitsPerSample == 8) {
Volume_Mix8(data, snd->DataSize, volume); Volume_Mix8((uint8_t*)data, snd->Size, volume);
} else { } else {
Volume_Mix16(data, snd->DataSize / 2, volume); Volume_Mix16((int16_t*)data, snd->Size / 2, volume);
} }
} }
if ((res = Audio_BufferData(output->Handle, 0, data, snd->DataSize))) { Sounds_Fail(res); return; } if ((res = Audio_BufferData(output->Handle, 0, data, snd->Size))) { Sounds_Fail(res); return; }
if ((res = Audio_Play(output->Handle))) { Sounds_Fail(res); return; } if ((res = Audio_Play(output->Handle))) { Sounds_Fail(res); return; }
} }
static void Sounds_Play(uint8_t type, struct Soundboard* board) { static void Sounds_Play(uint8_t type, struct Soundboard* board) {

View File

@ -26,7 +26,7 @@ void Bitmap_CopyBlock(int srcX, int srcY, int dstX, int dstY, Bitmap* src, Bitma
void Bitmap_Allocate(Bitmap* bmp, int width, int height) { void Bitmap_Allocate(Bitmap* bmp, int width, int height) {
bmp->Width = width; bmp->Height = height; bmp->Width = width; bmp->Height = height;
bmp->Scan0 = Mem_Alloc(width * height, 4, "bitmap data"); bmp->Scan0 = (uint8_t*)Mem_Alloc(width * height, 4, "bitmap data");
} }
void Bitmap_AllocateClearedPow2(Bitmap* bmp, int width, int height) { void Bitmap_AllocateClearedPow2(Bitmap* bmp, int width, int height) {
@ -34,7 +34,7 @@ void Bitmap_AllocateClearedPow2(Bitmap* bmp, int width, int height) {
height = Math_NextPowOf2(height); height = Math_NextPowOf2(height);
bmp->Width = width; bmp->Height = height; bmp->Width = width; bmp->Height = height;
bmp->Scan0 = Mem_AllocCleared(width * height, 4, "bitmap data"); bmp->Scan0 = (uint8_t*)Mem_AllocCleared(width * height, 4, "bitmap data");
} }
@ -376,7 +376,7 @@ ReturnCode Png_Decode(Bitmap* bmp, struct Stream* stream) {
if (bmp->Width < 0 || bmp->Width > PNG_MAX_DIMS) return PNG_ERR_TOO_WIDE; if (bmp->Width < 0 || bmp->Width > PNG_MAX_DIMS) return PNG_ERR_TOO_WIDE;
if (bmp->Height < 0 || bmp->Height > PNG_MAX_DIMS) return PNG_ERR_TOO_TALL; if (bmp->Height < 0 || bmp->Height > PNG_MAX_DIMS) return PNG_ERR_TOO_TALL;
bmp->Scan0 = Mem_Alloc(bmp->Width * bmp->Height, 4, "PNG bitmap data"); bmp->Scan0 = (uint8_t*)Mem_Alloc(bmp->Width * bmp->Height, 4, "PNG bitmap data");
bitsPerSample = tmp[8]; col = tmp[9]; bitsPerSample = tmp[8]; col = tmp[9];
rowExpander = Png_GetExpander(col, bitsPerSample); rowExpander = Png_GetExpander(col, bitsPerSample);
if (rowExpander == NULL) return PNG_ERR_INVALID_COL_BPP; if (rowExpander == NULL) return PNG_ERR_INVALID_COL_BPP;

View File

@ -400,7 +400,7 @@ static float Block_GetSpriteBB_MaxY(int size, int tileX, int tileY, const Bitmap
} }
void Block_RecalculateBB(BlockID block) { void Block_RecalculateBB(BlockID block) {
Bitmap* bmp = &Atlas2D.Bitmap; Bitmap* bmp = &Atlas2D.Bmp;
int tileSize = Atlas2D.TileSize; int tileSize = Atlas2D.TileSize;
TextureLoc texLoc = Block_Tex(block, FACE_XMAX); TextureLoc texLoc = Block_Tex(block, FACE_XMAX);
int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc); int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc);

View File

@ -443,7 +443,7 @@ static void Builder_DefaultPostStretchTiles(int x1, int y1, int z1) {
if (vertsCount > Builder_VerticesElems) { if (vertsCount > Builder_VerticesElems) {
Mem_Free(Builder_Vertices); Mem_Free(Builder_Vertices);
/* ensure buffer can be accessed with 64 bytes alignment by putting 2 extra vertices at end. */ /* ensure buffer can be accessed with 64 bytes alignment by putting 2 extra vertices at end. */
Builder_Vertices = Mem_Alloc(vertsCount + 2, sizeof(VertexP3fT2fC4b), "chunk vertices"); Builder_Vertices = (VertexP3fT2fC4b*)Mem_Alloc(vertsCount + 2, sizeof(VertexP3fT2fC4b), "chunk vertices");
Builder_VerticesElems = vertsCount; Builder_VerticesElems = vertsCount;
} }

View File

@ -928,7 +928,7 @@ static ReturnCode Deflate_StreamWrite(struct Stream* stream, const uint8_t* data
struct DeflateState* state; struct DeflateState* state;
ReturnCode res; ReturnCode res;
state = stream->Meta.Inflate; state = (struct DeflateState*)stream->Meta.Inflate;
*modified = 0; *modified = 0;
while (total > 0) { while (total > 0) {
@ -957,7 +957,7 @@ static ReturnCode Deflate_StreamClose(struct Stream* stream) {
struct DeflateState* state; struct DeflateState* state;
ReturnCode res; ReturnCode res;
state = stream->Meta.Inflate; state = (struct DeflateState*)stream->Meta.Inflate;
res = Deflate_FlushBlock(state, state->InputPosition - DEFLATE_BLOCK_SIZE); res = Deflate_FlushBlock(state, state->InputPosition - DEFLATE_BLOCK_SIZE);
if (res) return res; if (res) return res;
@ -1019,8 +1019,8 @@ void Deflate_MakeStream(struct Stream* stream, struct DeflateState* state, struc
*-----------------------------------------------------GZip (compress)-----------------------------------------------------* *-----------------------------------------------------GZip (compress)-----------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static ReturnCode GZip_StreamClose(struct Stream* stream) { static ReturnCode GZip_StreamClose(struct Stream* stream) {
struct GZipState* state = (struct GZipState*)stream->Meta.Inflate;
uint8_t data[8]; uint8_t data[8];
struct GZipState* state = stream->Meta.Inflate;
ReturnCode res; ReturnCode res;
if ((res = Deflate_StreamClose(stream))) return res; if ((res = Deflate_StreamClose(stream))) return res;
@ -1030,7 +1030,7 @@ static ReturnCode GZip_StreamClose(struct Stream* stream) {
} }
static ReturnCode GZip_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) { static ReturnCode GZip_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
struct GZipState* state = stream->Meta.Inflate; struct GZipState* state = (struct GZipState*)stream->Meta.Inflate;
uint32_t i, crc32 = state->Crc32; uint32_t i, crc32 = state->Crc32;
state->Size += count; state->Size += count;
@ -1045,7 +1045,7 @@ static ReturnCode GZip_StreamWrite(struct Stream* stream, const uint8_t* data, u
static ReturnCode GZip_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) { static ReturnCode GZip_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
static uint8_t header[10] = { 0x1F, 0x8B, 0x08 }; /* GZip header */ static uint8_t header[10] = { 0x1F, 0x8B, 0x08 }; /* GZip header */
struct GZipState* state = stream->Meta.Inflate; struct GZipState* state = (struct GZipState*)stream->Meta.Inflate;
ReturnCode res; ReturnCode res;
if ((res = Stream_Write(state->Base.Dest, header, sizeof(header)))) return res; if ((res = Stream_Write(state->Base.Dest, header, sizeof(header)))) return res;
@ -1066,8 +1066,8 @@ void GZip_MakeStream(struct Stream* stream, struct GZipState* state, struct Stre
*-----------------------------------------------------ZLib (compress)-----------------------------------------------------* *-----------------------------------------------------ZLib (compress)-----------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static ReturnCode ZLib_StreamClose(struct Stream* stream) { static ReturnCode ZLib_StreamClose(struct Stream* stream) {
struct ZLibState* state = (struct ZLibState*)stream->Meta.Inflate;
uint8_t data[4]; uint8_t data[4];
struct ZLibState* state = stream->Meta.Inflate;
ReturnCode res; ReturnCode res;
if ((res = Deflate_StreamClose(stream))) return res; if ((res = Deflate_StreamClose(stream))) return res;
@ -1076,7 +1076,7 @@ static ReturnCode ZLib_StreamClose(struct Stream* stream) {
} }
static ReturnCode ZLib_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) { static ReturnCode ZLib_StreamWrite(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
struct ZLibState* state = stream->Meta.Inflate; struct ZLibState* state = (struct ZLibState*)stream->Meta.Inflate;
uint32_t i, adler32 = state->Adler32; uint32_t i, adler32 = state->Adler32;
uint32_t s1 = adler32 & 0xFFFF, s2 = (adler32 >> 16) & 0xFFFF; uint32_t s1 = adler32 & 0xFFFF, s2 = (adler32 >> 16) & 0xFFFF;
@ -1093,7 +1093,7 @@ static ReturnCode ZLib_StreamWrite(struct Stream* stream, const uint8_t* data, u
static ReturnCode ZLib_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) { static ReturnCode ZLib_StreamWriteFirst(struct Stream* stream, const uint8_t* data, uint32_t count, uint32_t* modified) {
static uint8_t header[2] = { 0x78, 0x9C }; /* ZLib header */ static uint8_t header[2] = { 0x78, 0x9C }; /* ZLib header */
struct ZLibState* state = stream->Meta.Inflate; struct ZLibState* state = (struct ZLibState*)stream->Meta.Inflate;
ReturnCode res; ReturnCode res;
if ((res = Stream_Write(state->Base.Dest, header, sizeof(header)))) return res; if ((res = Stream_Write(state->Base.Dest, header, sizeof(header)))) return res;

View File

@ -17,7 +17,7 @@ static void Gen_Init(void) {
Gen_CurrentProgress = 0.0f; Gen_CurrentProgress = 0.0f;
Gen_CurrentState = ""; Gen_CurrentState = "";
Gen_Blocks = Mem_Alloc(World.Volume, 1, "map blocks for gen"); Gen_Blocks = (BlockRaw*)Mem_Alloc(World.Volume, 1, "map blocks for gen");
Gen_Done = false; Gen_Done = false;
} }
@ -609,7 +609,7 @@ static void NotchyGen_PlantTrees(void) {
void NotchyGen_Generate(void) { void NotchyGen_Generate(void) {
Gen_Init(); Gen_Init();
Heightmap = Mem_Alloc(World.Width * World.Length, 2, "gen heightmap"); Heightmap = (int16_t*)Mem_Alloc(World.Width * World.Length, 2, "gen heightmap");
Random_Seed(&rnd, Gen_Seed); Random_Seed(&rnd, Gen_Seed);
waterLevel = World.Height / 2; waterLevel = World.Height / 2;

View File

@ -233,10 +233,10 @@ static void Hotkeys_QuickSort(int left, int right) {
} }
} }
static void Hotkeys_AddNewHotkey(Key trigger, uint8_t flags, const String* text, bool more) { static void Hotkeys_AddNewHotkey(Key trigger, uint8_t modifiers, const String* text, bool more) {
struct HotkeyData hKey; struct HotkeyData hKey;
hKey.Trigger = trigger; hKey.Trigger = trigger;
hKey.Flags = flags; hKey.Flags = modifiers;
hKey.TextIndex = HotkeysText.Count; hKey.TextIndex = HotkeysText.Count;
hKey.StaysOpen = more; hKey.StaysOpen = more;
@ -262,29 +262,29 @@ static void Hotkeys_RemoveText(int index) {
} }
void Hotkeys_Add(Key trigger, HotkeyFlags flags, const String* text, bool more) { void Hotkeys_Add(Key trigger, uint8_t modifiers, const String* text, bool more) {
struct HotkeyData* hKey = HotkeysList; struct HotkeyData* hk = HotkeysList;
int i; int i;
for (i = 0; i < HotkeysText.Count; i++, hKey++) { for (i = 0; i < HotkeysText.Count; i++, hk++) {
if (hKey->Trigger != trigger || hKey->Flags != flags) continue; if (hk->Trigger != trigger || hk->Flags != modifiers) continue;
Hotkeys_RemoveText(hKey->TextIndex); Hotkeys_RemoveText(hk->TextIndex);
hKey->StaysOpen = more; hk->StaysOpen = more;
hKey->TextIndex = HotkeysText.Count; hk->TextIndex = HotkeysText.Count;
StringsBuffer_Add(&HotkeysText, text); StringsBuffer_Add(&HotkeysText, text);
return; return;
} }
Hotkeys_AddNewHotkey(trigger, flags, text, more); Hotkeys_AddNewHotkey(trigger, modifiers, text, more);
} }
bool Hotkeys_Remove(Key trigger, HotkeyFlags flags) { bool Hotkeys_Remove(Key trigger, uint8_t modifiers) {
struct HotkeyData* hKey = HotkeysList; struct HotkeyData* hk = HotkeysList;
int i, j; int i, j;
for (i = 0; i < HotkeysText.Count; i++, hKey++) { for (i = 0; i < HotkeysText.Count; i++, hk++) {
if (hKey->Trigger != trigger || hKey->Flags != flags) continue; if (hk->Trigger != trigger || hk->Flags != modifiers) continue;
Hotkeys_RemoveText(hKey->TextIndex); Hotkeys_RemoveText(hk->TextIndex);
for (j = i; j < HotkeysText.Count; j++) { for (j = i; j < HotkeysText.Count; j++) {
HotkeysList[j] = HotkeysList[j + 1]; HotkeysList[j] = HotkeysList[j + 1];
@ -295,17 +295,17 @@ bool Hotkeys_Remove(Key trigger, HotkeyFlags flags) {
} }
int Hotkeys_FindPartial(Key key) { int Hotkeys_FindPartial(Key key) {
struct HotkeyData hKey; struct HotkeyData hk;
int i, flags = 0; int i, modifiers = 0;
if (Key_IsControlPressed()) flags |= HOTKEY_FLAG_CTRL; if (Key_IsControlPressed()) modifiers |= HOTKEY_MOD_CTRL;
if (Key_IsShiftPressed()) flags |= HOTKEY_FLAG_SHIFT; if (Key_IsShiftPressed()) modifiers |= HOTKEY_MOD_SHIFT;
if (Key_IsAltPressed()) flags |= HOTKEY_FLAG_ALT; if (Key_IsAltPressed()) modifiers |= HOTKEY_MOD_ALT;
for (i = 0; i < HotkeysText.Count; i++) { for (i = 0; i < HotkeysText.Count; i++) {
hKey = HotkeysList[i]; hk = HotkeysList[i];
/* e.g. if holding Ctrl and Shift, a hotkey with only Ctrl flags matches */ /* e.g. if holding Ctrl and Shift, a hotkey with only Ctrl modifiers matches */
if ((hKey.Flags & flags) == hKey.Flags && hKey.Trigger == key) return i; if ((hk.Flags & modifiers) == hk.Flags && hk.Trigger == key) return i;
} }
return -1; return -1;
} }
@ -340,21 +340,21 @@ void Hotkeys_Init(void) {
} }
} }
void Hotkeys_UserRemovedHotkey(Key trigger, HotkeyFlags flags) { void Hotkeys_UserRemovedHotkey(Key trigger, uint8_t modifiers) {
String key; char keyBuffer[STRING_SIZE]; String key; char keyBuffer[STRING_SIZE];
String_InitArray(key, keyBuffer); String_InitArray(key, keyBuffer);
String_Format2(&key, "hotkey-%c&%i", Key_Names[trigger], &flags); String_Format2(&key, "hotkey-%c&%b", Key_Names[trigger], &modifiers);
Options_SetString(&key, NULL); Options_SetString(&key, NULL);
} }
void Hotkeys_UserAddedHotkey(Key trigger, HotkeyFlags flags, bool moreInput, const String* text) { void Hotkeys_UserAddedHotkey(Key trigger, uint8_t modifiers, bool moreInput, const String* text) {
String key; char keyBuffer[STRING_SIZE]; String key; char keyBuffer[STRING_SIZE];
String value; char valueBuffer[STRING_SIZE * 2]; String value; char valueBuffer[STRING_SIZE * 2];
String_InitArray(key, keyBuffer); String_InitArray(key, keyBuffer);
String_InitArray(value, valueBuffer); String_InitArray(value, valueBuffer);
String_Format2(&key, "hotkey-%c&%i", Key_Names[trigger], &flags); String_Format2(&key, "hotkey-%c&%b", Key_Names[trigger], &modifiers);
String_Format2(&value, "%t&%s", &moreInput, text); String_Format2(&value, "%t&%s", &moreInput, text);
Options_SetString(&key, &value); Options_SetString(&key, &value);
} }

View File

@ -119,30 +119,30 @@ void KeyBind_Init(void);
extern const uint8_t Hotkeys_LWJGL[256]; extern const uint8_t Hotkeys_LWJGL[256];
struct HotkeyData { struct HotkeyData {
int TextIndex; /* contents to copy directly into the input bar */ int TextIndex; /* contents to copy directly into the input bar */
uint8_t Trigger; /* Member of Key enumeration */ uint8_t Trigger; /* Member of Key enumeration */
uint8_t Flags; /* ctrl 1, shift 2, alt 4 */ uint8_t Flags; /* HotkeyModifiers bitflags */
bool StaysOpen; /* whether the user is able to enter further input */ bool StaysOpen; /* whether the user is able to enter further input */
}; };
#define HOTKEYS_MAX_COUNT 256 #define HOTKEYS_MAX_COUNT 256
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT]; extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
extern StringsBuffer HotkeysText; extern StringsBuffer HotkeysText;
typedef enum HotkeyFlags_ { enum HotkeyModifiers {
HOTKEY_FLAG_CTRL = 1, HOTKEY_FLAG_SHIFT = 2, HOTKEY_FLAG_ALT = 4 HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4
} HotkeyFlags; };
/* Adds or updates a new hotkey. */ /* Adds or updates a new hotkey. */
void Hotkeys_Add(Key trigger, HotkeyFlags flags, const String* text, bool more); void Hotkeys_Add(Key trigger, uint8_t modifiers, const String* text, bool more);
/* Removes the given hotkey. */ /* Removes the given hotkey. */
bool Hotkeys_Remove(Key trigger, HotkeyFlags flags); bool Hotkeys_Remove(Key trigger, uint8_t modifiers);
/* Returns the first hotkey which is bound to the given key and has its modifiers pressed. */ /* Returns the first hotkey which is bound to the given key and has its modifiers pressed. */
/* NOTE: The hotkeys list is sorted, so hotkeys with most modifiers are checked first. */ /* NOTE: The hotkeys list is sorted, so hotkeys with most modifiers are checked first. */
int Hotkeys_FindPartial(Key key); int Hotkeys_FindPartial(Key key);
/* Initalises and loads hotkeys from options. */ /* Initalises and loads hotkeys from options. */
void Hotkeys_Init(void); void Hotkeys_Init(void);
/* Called when user has removed a hotkey. (removes it from options) */ /* Called when user has removed a hotkey. (removes it from options) */
void Hotkeys_UserRemovedHotkey(Key trigger, HotkeyFlags flags); void Hotkeys_UserRemovedHotkey(Key trigger, uint8_t modifiers);
/* Called when user has added a hotkey. (Adds it to options) */ /* Called when user has added a hotkey. (Adds it to options) */
void Hotkeys_UserAddedHotkey(Key trigger, HotkeyFlags flags, bool moreInput, const String* text); void Hotkeys_UserAddedHotkey(Key trigger, uint8_t modifiers, bool moreInput, const String* text);
#endif #endif

View File

@ -110,8 +110,8 @@ static void LButton_DrawHighlight(struct LButton* w) {
} }
static void LButton_Draw(void* widget) { static void LButton_Draw(void* widget) {
struct LButton* w = (struct LButton*)widget;
struct DrawTextArgs args; struct DrawTextArgs args;
struct LButton* w = widget;
int xOffset, yOffset; int xOffset, yOffset;
if (w->Hidden) return; if (w->Hidden) return;
@ -306,7 +306,7 @@ static Rect2D lastCaretRec;
#define Rect2D_Equals(a, b) a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height #define Rect2D_Equals(a, b) a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height
static void LInput_TickCaret(void* widget) { static void LInput_TickCaret(void* widget) {
struct LInput* w = widget; struct LInput* w = (struct LInput*)widget;
BitmapCol col = BITMAPCOL_CONST(0, 0, 0, 255); BitmapCol col = BITMAPCOL_CONST(0, 0, 0, 255);
int elapsed; int elapsed;
bool caretShow; bool caretShow;
@ -393,7 +393,7 @@ static void LInput_Unselect(void* widget) {
} }
static void LInput_KeyDown(void* widget, Key key, bool was) { static void LInput_KeyDown(void* widget, Key key, bool was) {
struct LInput* w = widget; struct LInput* w = (struct LInput*)widget;
if (key == KEY_BACKSPACE && LInput_Backspace(w)) { if (key == KEY_BACKSPACE && LInput_Backspace(w)) {
LWidget_Redraw(w); LWidget_Redraw(w);
} else if (key == KEY_DELETE && LInput_Delete(w)) { } else if (key == KEY_DELETE && LInput_Delete(w)) {
@ -414,7 +414,7 @@ static void LInput_KeyDown(void* widget, Key key, bool was) {
} }
static void LInput_KeyChar(void* widget, char c) { static void LInput_KeyChar(void* widget, char c) {
struct LInput* w = widget; struct LInput* w = (struct LInput*)widget;
if (LInput_Append(w, c)) LWidget_Redraw(w); if (LInput_Append(w, c)) LWidget_Redraw(w);
} }
@ -529,8 +529,8 @@ bool LInput_CopyFromClipboard(struct LInput* w) {
*------------------------------------------------------LabelWidget--------------------------------------------------------* *------------------------------------------------------LabelWidget--------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static void LLabel_Draw(void* widget) { static void LLabel_Draw(void* widget) {
struct LLabel* w = (struct LLabel*)widget;
struct DrawTextArgs args; struct DrawTextArgs args;
struct LLabel* w = widget;
if (w->Hidden) return; if (w->Hidden) return;
DrawTextArgs_Make(&args, &w->Text, &w->Font, true); DrawTextArgs_Make(&args, &w->Text, &w->Font, true);
@ -599,7 +599,7 @@ static void LSlider_DrawBox(struct LSlider* w) {
} }
static void LSlider_Draw(void* widget) { static void LSlider_Draw(void* widget) {
struct LSlider* w = widget; struct LSlider* w = (struct LSlider*)widget;
int curWidth; int curWidth;
if (w->Hidden) return; if (w->Hidden) return;
@ -892,7 +892,7 @@ bool LTable_HandlesKey(Key key) {
} }
static void LTable_KeyDown(void* widget, Key key, bool was) { static void LTable_KeyDown(void* widget, Key key, bool was) {
struct LTable* w = widget; struct LTable* w = (struct LTable*)widget;
int index = LTable_GetSelectedIndex(w); int index = LTable_GetSelectedIndex(w);
if (key == KEY_UP) { if (key == KEY_UP) {
@ -910,7 +910,7 @@ static void LTable_KeyDown(void* widget, Key key, bool was) {
} }
static void LTable_MouseMove(void* widget, int deltaX, int deltaY, bool wasOver) { static void LTable_MouseMove(void* widget, int deltaX, int deltaY, bool wasOver) {
struct LTable* w = widget; struct LTable* w = (struct LTable*)widget;
int x = Mouse_X - w->X, y = Mouse_Y - w->Y, col; int x = Mouse_X - w->X, y = Mouse_Y - w->Y, col;
if (w->DraggingScrollbar) { if (w->DraggingScrollbar) {
@ -995,7 +995,7 @@ static void LTable_ScrollbarClick(struct LTable* w) {
} }
static void LTable_MouseDown(void* widget, bool wasSelected) { static void LTable_MouseDown(void* widget, bool wasSelected) {
struct LTable* w = widget; struct LTable* w = (struct LTable*)widget;
if (Mouse_X >= Game.Width - SCROLLBAR_WIDTH) { if (Mouse_X >= Game.Width - SCROLLBAR_WIDTH) {
LTable_ScrollbarClick(w); LTable_ScrollbarClick(w);
@ -1010,7 +1010,7 @@ static void LTable_MouseDown(void* widget, bool wasSelected) {
} }
static void LTable_MouseWheel(void* widget, float delta) { static void LTable_MouseWheel(void* widget, float delta) {
struct LTable* w = widget; struct LTable* w = (struct LTable*)widget;
w->TopRow -= Utils_AccumulateWheelDelta(&w->_wheelAcc, delta); w->TopRow -= Utils_AccumulateWheelDelta(&w->_wheelAcc, delta);
LTable_ClampTopRow(w); LTable_ClampTopRow(w);
LWidget_Draw(w); LWidget_Draw(w);
@ -1038,7 +1038,7 @@ void LTable_Reposition(struct LTable* w) {
} }
static void LTable_Draw(void* widget) { static void LTable_Draw(void* widget) {
struct LTable* w = widget; struct LTable* w = (struct LTable*)widget;
LTable_DrawBackground(w); LTable_DrawBackground(w);
LTable_DrawHeaders(w); LTable_DrawHeaders(w);
LTable_DrawRows(w); LTable_DrawRows(w);

View File

@ -358,7 +358,7 @@ static void Lighting_Reset(void) {
} }
static void Lighting_OnNewMapLoaded(void) { static void Lighting_OnNewMapLoaded(void) {
Lighting_Heightmap = Mem_Alloc(World.Width * World.Length, 2, "lighting heightmap"); Lighting_Heightmap = (int16_t*)Mem_Alloc(World.Width * World.Length, 2, "lighting heightmap");
Lighting_Refresh(); Lighting_Refresh();
} }

View File

@ -853,18 +853,18 @@ static void EditHotkeyScreen_LeaveOpen(void* screen, void* b) {
static void EditHotkeyScreen_SaveChanges(void* screen, void* b) { static void EditHotkeyScreen_SaveChanges(void* screen, void* b) {
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen; struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
struct HotkeyData hotkey = s->OrigHotkey; struct HotkeyData hk = s->OrigHotkey;
if (hotkey.Trigger) { if (hk.Trigger) {
Hotkeys_Remove(hotkey.Trigger, hotkey.Flags); Hotkeys_Remove(hk.Trigger, hk.Flags);
Hotkeys_UserRemovedHotkey(hotkey.Trigger, hotkey.Flags); Hotkeys_UserRemovedHotkey(hk.Trigger, hk.Flags);
} }
hotkey = s->CurHotkey; hk = s->CurHotkey;
if (hotkey.Trigger) { if (hk.Trigger) {
String text = s->Input.Base.Text; String text = s->Input.Base.Text;
Hotkeys_Add(hotkey.Trigger, hotkey.Flags, &text, hotkey.StaysOpen); Hotkeys_Add(hk.Trigger, hk.Flags, &text, hk.StaysOpen);
Hotkeys_UserAddedHotkey(hotkey.Trigger, hotkey.Flags, hotkey.StaysOpen, &text); Hotkeys_UserAddedHotkey(hk.Trigger, hk.Flags, hk.StaysOpen, &text);
} }
Gui_FreeActive(); Gui_FreeActive();
@ -873,11 +873,11 @@ static void EditHotkeyScreen_SaveChanges(void* screen, void* b) {
static void EditHotkeyScreen_RemoveHotkey(void* screen, void* b) { static void EditHotkeyScreen_RemoveHotkey(void* screen, void* b) {
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen; struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
struct HotkeyData hotkey = s->OrigHotkey; struct HotkeyData hk = s->OrigHotkey;
if (hotkey.Trigger) { if (hk.Trigger) {
Hotkeys_Remove(hotkey.Trigger, hotkey.Flags); Hotkeys_Remove(hk.Trigger, hk.Flags);
Hotkeys_UserRemovedHotkey(hotkey.Trigger, hotkey.Flags); Hotkeys_UserRemovedHotkey(hk.Trigger, hk.Flags);
} }
Gui_FreeActive(); Gui_FreeActive();
@ -916,9 +916,9 @@ static bool EditHotkeyScreen_KeyDown(void* screen, Key key, bool was) {
s->CurHotkey.Trigger = key; s->CurHotkey.Trigger = key;
EditHotkeyScreen_MakeBaseKey(s, EditHotkeyScreen_BaseKey); EditHotkeyScreen_MakeBaseKey(s, EditHotkeyScreen_BaseKey);
} else if (s->SelectedI == 1) { } else if (s->SelectedI == 1) {
if (key == KEY_LCTRL || key == KEY_RCTRL) s->CurHotkey.Flags |= HOTKEY_FLAG_CTRL; if (key == KEY_LCTRL || key == KEY_RCTRL) s->CurHotkey.Flags |= HOTKEY_MOD_CTRL;
else if (key == KEY_LSHIFT || key == KEY_RSHIFT) s->CurHotkey.Flags |= HOTKEY_FLAG_SHIFT; else if (key == KEY_LSHIFT || key == KEY_RSHIFT) s->CurHotkey.Flags |= HOTKEY_MOD_SHIFT;
else if (key == KEY_LALT || key == KEY_RALT) s->CurHotkey.Flags |= HOTKEY_FLAG_ALT; else if (key == KEY_LALT || key == KEY_RALT) s->CurHotkey.Flags |= HOTKEY_MOD_ALT;
else s->CurHotkey.Flags = 0; else s->CurHotkey.Flags = 0;
EditHotkeyScreen_MakeModifiers(s, EditHotkeyScreen_Modifiers); EditHotkeyScreen_MakeModifiers(s, EditHotkeyScreen_Modifiers);
@ -1477,9 +1477,9 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
} }
String_UNSAFE_Separate(&text, '+', &key, &value); String_UNSAFE_Separate(&text, '+', &key, &value);
if (String_ContainsString(&value, &ctrl)) flags |= HOTKEY_FLAG_CTRL; if (String_ContainsString(&value, &ctrl)) flags |= HOTKEY_MOD_CTRL;
if (String_ContainsString(&value, &shift)) flags |= HOTKEY_FLAG_SHIFT; if (String_ContainsString(&value, &shift)) flags |= HOTKEY_MOD_SHIFT;
if (String_ContainsString(&value, &alt)) flags |= HOTKEY_FLAG_ALT; if (String_ContainsString(&value, &alt)) flags |= HOTKEY_MOD_ALT;
trigger = Utils_ParseEnum(&key, KEY_NONE, Key_Names, KEY_COUNT); trigger = Utils_ParseEnum(&key, KEY_NONE, Key_Names, KEY_COUNT);
for (i = 0; i < HotkeysText.Count; i++) { for (i = 0; i < HotkeysText.Count; i++) {
@ -1492,9 +1492,9 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
} }
static void HotkeyListScreen_MakeFlags(int flags, String* str) { static void HotkeyListScreen_MakeFlags(int flags, String* str) {
if (flags & HOTKEY_FLAG_CTRL) String_AppendConst(str, " Ctrl"); if (flags & HOTKEY_MOD_CTRL) String_AppendConst(str, " Ctrl");
if (flags & HOTKEY_FLAG_SHIFT) String_AppendConst(str, " Shift"); if (flags & HOTKEY_MOD_SHIFT) String_AppendConst(str, " Shift");
if (flags & HOTKEY_FLAG_ALT) String_AppendConst(str, " Alt"); if (flags & HOTKEY_MOD_ALT) String_AppendConst(str, " Alt");
} }
struct Screen* HotkeyListScreen_MakeInstance(void) { struct Screen* HotkeyListScreen_MakeInstance(void) {
@ -1582,7 +1582,7 @@ static void KeyBindingsScreen_GetText(struct KeyBindingsScreen* s, int i, String
static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) { static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
String text; char textBuffer[STRING_SIZE]; String text; char textBuffer[STRING_SIZE];
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen; struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
struct ButtonWidget* btn = widget; struct ButtonWidget* btn = (struct ButtonWidget*)widget;
struct ButtonWidget* cur; struct ButtonWidget* cur;
String_InitArray(text, textBuffer); String_InitArray(text, textBuffer);
@ -2050,7 +2050,7 @@ static void MenuOptionsScreen_Default(void* screen, void* widget) {
static void MenuOptionsScreen_Bool(void* screen, void* widget) { static void MenuOptionsScreen_Bool(void* screen, void* widget) {
String value; char valueBuffer[STRING_SIZE]; String value; char valueBuffer[STRING_SIZE];
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
struct ButtonWidget* btn = widget; struct ButtonWidget* btn = (struct ButtonWidget*)widget;
int index; int index;
bool isOn; bool isOn;
@ -2067,7 +2067,7 @@ static void MenuOptionsScreen_Bool(void* screen, void* widget) {
static void MenuOptionsScreen_Enum(void* screen, void* widget) { static void MenuOptionsScreen_Enum(void* screen, void* widget) {
String value; char valueBuffer[STRING_SIZE]; String value; char valueBuffer[STRING_SIZE];
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
struct ButtonWidget* btn = widget; struct ButtonWidget* btn = (struct ButtonWidget*)widget;
int index; int index;
struct MenuInputValidator* v; struct MenuInputValidator* v;
const char** names; const char** names;
@ -2093,7 +2093,7 @@ static void MenuOptionsScreen_Input(void* screen, void* widget) {
String value; char valueBuffer[STRING_SIZE]; String value; char valueBuffer[STRING_SIZE];
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen; struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
struct ButtonWidget* btn = widget; struct ButtonWidget* btn = (struct ButtonWidget*)widget;
int i; int i;
s->ActiveI = Menu_Index(s, btn); s->ActiveI = Menu_Index(s, btn);
@ -2896,7 +2896,7 @@ static void Overlay_Free(void* screen) {
static bool Overlay_KeyDown(void* screen, Key key, bool was) { return true; } static bool Overlay_KeyDown(void* screen, Key key, bool was) { return true; }
static void Overlay_MakeLabels(void* menu, struct TextWidget* labels, const String* lines) { static void Overlay_MakeLabels(void* menu, struct TextWidget* labels, const String* lines) {
struct MenuScreen* s = menu; struct MenuScreen* s = (struct MenuScreen*)menu;
PackedCol col = PACKEDCOL_CONST(224, 224, 224, 255); PackedCol col = PACKEDCOL_CONST(224, 224, 224, 255);
int i; int i;
Menu_Label(s, 0, &labels[0], &lines[0], &s->TitleFont, Menu_Label(s, 0, &labels[0], &lines[0], &s->TitleFont,

View File

@ -712,7 +712,7 @@ void* Thread_StartCallback(void* lpParam) {
} }
void* Thread_Start(Thread_StartFunc* func, bool detach) { void* Thread_Start(Thread_StartFunc* func, bool detach) {
pthread_t* ptr = Mem_Alloc(1, sizeof(pthread_t), "allocating thread"); pthread_t* ptr = (pthread_t*)Mem_Alloc(1, sizeof(pthread_t), "thread");
int res = pthread_create(ptr, NULL, Thread_StartCallback, func); int res = pthread_create(ptr, NULL, Thread_StartCallback, func);
if (res) Logger_Abort2(res, "Creating thread"); if (res) Logger_Abort2(res, "Creating thread");
@ -721,7 +721,7 @@ void* Thread_Start(Thread_StartFunc* func, bool detach) {
} }
void Thread_Detach(void* handle) { void Thread_Detach(void* handle) {
pthread_t* ptr = handle; pthread_t* ptr = (pthread_t*)handle;
int res = pthread_detach(*ptr); int res = pthread_detach(*ptr);
if (res) Logger_Abort2(res, "Detaching thread"); if (res) Logger_Abort2(res, "Detaching thread");
Mem_Free(ptr); Mem_Free(ptr);
@ -735,7 +735,7 @@ void Thread_Join(void* handle) {
} }
void* Mutex_Create(void) { void* Mutex_Create(void) {
pthread_mutex_t* ptr = Mem_Alloc(1, sizeof(pthread_mutex_t), "allocating mutex"); pthread_mutex_t* ptr = (pthread_mutex_t*)Mem_Alloc(1, sizeof(pthread_mutex_t), "mutex");
int res = pthread_mutex_init(ptr, NULL); int res = pthread_mutex_init(ptr, NULL);
if (res) Logger_Abort2(res, "Creating mutex"); if (res) Logger_Abort2(res, "Creating mutex");
return ptr; return ptr;
@ -763,7 +763,7 @@ struct WaitData {
}; };
void* Waitable_Create(void) { void* Waitable_Create(void) {
struct WaitData* ptr = Mem_Alloc(1, sizeof(struct WaitData), "allocating waitable"); struct WaitData* ptr = Mem_Alloc(1, sizeof(struct WaitData), "waitable");
int res; int res;
res = pthread_cond_init(&ptr->cond, NULL); res = pthread_cond_init(&ptr->cond, NULL);
@ -839,7 +839,7 @@ static void Font_Init(void);
#define DPI_PIXEL 72 #define DPI_PIXEL 72
#define DPI_DEVICE 96 /* TODO: GetDeviceCaps(hdc, LOGPIXELSY) in Window_Init ? */ #define DPI_DEVICE 96 /* TODO: GetDeviceCaps(hdc, LOGPIXELSY) in Window_Init ? */
struct FontData { typedef struct FontData_ {
FT_Face face; FT_Face face;
struct Stream src, file; struct Stream src, file;
FT_StreamRec stream; FT_StreamRec stream;
@ -850,10 +850,10 @@ struct FontData {
#ifdef CC_BUILD_OSX #ifdef CC_BUILD_OSX
char filename[FILENAME_SIZE + 1]; char filename[FILENAME_SIZE + 1];
#endif #endif
}; } FontData;
static unsigned long FontData_Read(FT_Stream s, unsigned long offset, unsigned char* buffer, unsigned long count) { static unsigned long FontData_Read(FT_Stream s, unsigned long offset, unsigned char* buffer, unsigned long count) {
struct FontData* data; FontData* data;
ReturnCode res; ReturnCode res;
if (!count && offset > s->size) return 1; if (!count && offset > s->size) return 1;
@ -864,7 +864,7 @@ static unsigned long FontData_Read(FT_Stream s, unsigned long offset, unsigned c
return res ? 0 : count; return res ? 0 : count;
} }
static void FontData_Free(struct FontData* font) { static void FontData_Free(FontData* font) {
int i; int i;
/* Close the actual underlying file */ /* Close the actual underlying file */
@ -883,11 +883,11 @@ static void FontData_Free(struct FontData* font) {
} }
static void FontData_Close(FT_Stream stream) { static void FontData_Close(FT_Stream stream) {
struct FontData* data = stream->descriptor.pointer; FontData* data = (FontData*)stream->descriptor.pointer;
FontData_Free(data); FontData_Free(data);
} }
static bool FontData_Init(const String* path, struct FontData* data, FT_Open_Args* args) { static bool FontData_Init(const String* path, FontData* data, FT_Open_Args* args) {
FileHandle file; FileHandle file;
uint32_t size; uint32_t size;
@ -962,7 +962,7 @@ String Font_Lookup(const String* fontName, int style) {
} }
void Font_Make(FontDesc* desc, const String* fontName, int size, int style) { void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
struct FontData* data; FontData* data;
String value, path, index; String value, path, index;
int faceIndex; int faceIndex;
FT_Open_Args args; FT_Open_Args args;
@ -976,7 +976,7 @@ void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
String_UNSAFE_Separate(&value, ',', &path, &index); String_UNSAFE_Separate(&value, ',', &path, &index);
Convert_ParseInt(&index, &faceIndex); Convert_ParseInt(&index, &faceIndex);
data = Mem_Alloc(1, sizeof(struct FontData), "FontData"); data = (FontData*)Mem_Alloc(1, sizeof(FontData), "FontData");
if (!FontData_Init(&path, data, &args)) return; if (!FontData_Init(&path, data, &args)) return;
desc->Handle = data; desc->Handle = data;
@ -987,7 +987,7 @@ void Font_Make(FontDesc* desc, const String* fontName, int size, int style) {
} }
void Font_Free(FontDesc* desc) { void Font_Free(FontDesc* desc) {
struct FontData* data; FontData* data;
FT_Error err; FT_Error err;
desc->Size = 0; desc->Size = 0;
@ -995,7 +995,7 @@ void Font_Free(FontDesc* desc) {
/* NULL for fonts created by Drawer2D_MakeFont and bitmapped text mode is on */ /* NULL for fonts created by Drawer2D_MakeFont and bitmapped text mode is on */
if (!desc->Handle) return; if (!desc->Handle) return;
data = desc->Handle; data = (FontData*)desc->Handle;
err = FT_Done_Face(data->face); err = FT_Done_Face(data->face);
if (err) Logger_Abort2(err, "Deleting font failed"); if (err) Logger_Abort2(err, "Deleting font failed");
@ -1031,7 +1031,7 @@ static void Font_Add(const String* path, FT_Face face, int index, char type, con
} }
static int Font_Register(const String* path, int faceIndex) { static int Font_Register(const String* path, int faceIndex) {
struct FontData data; FontData data;
FT_Open_Args args; FT_Open_Args args;
FT_Error err; FT_Error err;
int flags, count; int flags, count;
@ -1084,7 +1084,7 @@ static void Font_DirCallback(const String* path, void* obj) {
#define TEXT_CEIL(x) (((x) + 63) >> 6) #define TEXT_CEIL(x) (((x) + 63) >> 6)
int Platform_TextWidth(struct DrawTextArgs* args) { int Platform_TextWidth(struct DrawTextArgs* args) {
struct FontData* data = args->Font.Handle; FontData* data = (FontData*)args->Font.Handle;
FT_Face face = data->face; FT_Face face = data->face;
String text = args->Text; String text = args->Text;
int i, width = 0, charWidth; int i, width = 0, charWidth;
@ -1113,8 +1113,8 @@ int Platform_TextWidth(struct DrawTextArgs* args) {
} }
int Platform_FontHeight(const FontDesc* font) { int Platform_FontHeight(const FontDesc* font) {
struct FontData* data = font->Handle; FontData* data = (FontData*)font->Handle;
FT_Face face = data->face; FT_Face face = data->face;
return TEXT_CEIL(face->size->metrics.height); return TEXT_CEIL(face->size->metrics.height);
} }
@ -1167,7 +1167,7 @@ static void Platform_BlackWhiteGlyph(FT_Bitmap* img, Bitmap* bmp, int x, int y,
} }
int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow) { int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow) {
struct FontData* data = args->Font.Handle; FontData* data = (FontData*)args->Font.Handle;
FT_Face face = data->face; FT_Face face = data->face;
String text = args->Text; String text = args->Text;
FT_Glyph* glyphs = data->glyphs; FT_Glyph* glyphs = data->glyphs;

View File

@ -429,7 +429,7 @@ static void Atlas_Convert2DTo1D(void) {
atlasY = Atlas2D_TileY(tile) * tileSize; atlasY = Atlas2D_TileY(tile) * tileSize;
Bitmap_CopyBlock(atlasX, atlasY, 0, y * tileSize, Bitmap_CopyBlock(atlasX, atlasY, 0, y * tileSize,
&Atlas2D.Bitmap, &atlas1D, tileSize); &Atlas2D.Bmp, &atlas1D, tileSize);
} }
Atlas1D.TexIds[i] = Gfx_CreateTexture(&atlas1D, true, Gfx.Mipmaps); Atlas1D.TexIds[i] = Gfx_CreateTexture(&atlas1D, true, Gfx.Mipmaps);
} }
@ -452,7 +452,7 @@ static void Atlas_Update1D(void) {
} }
void Atlas_Update(Bitmap* bmp) { void Atlas_Update(Bitmap* bmp) {
Atlas2D.Bitmap = *bmp; Atlas2D.Bmp = *bmp;
Atlas2D.TileSize = bmp->Width / ATLAS2D_TILES_PER_ROW; Atlas2D.TileSize = bmp->Width / ATLAS2D_TILES_PER_ROW;
Atlas2D.RowsCount = bmp->Height / Atlas2D.TileSize; Atlas2D.RowsCount = bmp->Height / Atlas2D.TileSize;
Atlas2D.RowsCount = min(Atlas2D.RowsCount, ATLAS2D_MAX_ROWS_COUNT); Atlas2D.RowsCount = min(Atlas2D.RowsCount, ATLAS2D_MAX_ROWS_COUNT);
@ -466,7 +466,7 @@ static GfxResourceID Atlas_LoadTile_Raw(TextureLoc texLoc, Bitmap* element) {
int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc); int x = Atlas2D_TileX(texLoc), y = Atlas2D_TileY(texLoc);
if (y >= Atlas2D.RowsCount) return GFX_NULL; if (y >= Atlas2D.RowsCount) return GFX_NULL;
Bitmap_CopyBlock(x * size, y * size, 0, 0, &Atlas2D.Bitmap, element, size); Bitmap_CopyBlock(x * size, y * size, 0, 0, &Atlas2D.Bmp, element, size);
return Gfx_CreateTexture(element, false, Gfx.Mipmaps); return Gfx_CreateTexture(element, false, Gfx.Mipmaps);
} }
@ -490,8 +490,8 @@ GfxResourceID Atlas2D_LoadTile(TextureLoc texLoc) {
void Atlas_Free(void) { void Atlas_Free(void) {
int i; int i;
Mem_Free(Atlas2D.Bitmap.Scan0); Mem_Free(Atlas2D.Bmp.Scan0);
Atlas2D.Bitmap.Scan0 = NULL; Atlas2D.Bmp.Scan0 = NULL;
for (i = 0; i < Atlas1D.Count; i++) { for (i = 0; i < Atlas1D.Count; i++) {
Gfx_DeleteTexture(&Atlas1D.TexIds[i]); Gfx_DeleteTexture(&Atlas1D.TexIds[i]);

View File

@ -30,7 +30,7 @@ extern struct IGameComponent Animations_Component;
CC_VAR extern struct _Atlas2DData { CC_VAR extern struct _Atlas2DData {
/* Bitmap that contains the textures of all tiles. */ /* Bitmap that contains the textures of all tiles. */
/* Tiles are indexed left to right, top to bottom. */ /* Tiles are indexed left to right, top to bottom. */
Bitmap Bitmap; Bitmap Bmp;
/* Size of each tile in pixels. (default 16x16) */ /* Size of each tile in pixels. (default 16x16) */
int TileSize; int TileSize;
/* Number of rows in the atlas. (default 16, can be 32) */ /* Number of rows in the atlas. (default 16, can be 32) */

View File

@ -224,8 +224,8 @@ static bool Codebook_CalcCodewords(struct Codebook* c, uint8_t* len) {
int offset; int offset;
int len_offsets[33]; int len_offsets[33];
c->Codewords = Mem_Alloc(c->TotalCodewords, 4, "codewords"); c->Codewords = (uint32_t*)Mem_Alloc(c->TotalCodewords, 4, "codewords");
c->Values = Mem_Alloc(c->TotalCodewords, 4, "values"); c->Values = (uint32_t*)Mem_Alloc(c->TotalCodewords, 4, "values");
/* Codeword entries are ordered by length */ /* Codeword entries are ordered by length */
offset = 0; offset = 0;
@ -290,7 +290,7 @@ static ReturnCode Codebook_DecodeSetup(struct VorbisState* ctx, struct Codebook*
c->Dimensions = Vorbis_ReadBits(ctx, 16); c->Dimensions = Vorbis_ReadBits(ctx, 16);
c->Entries = Vorbis_ReadBits(ctx, 24); c->Entries = Vorbis_ReadBits(ctx, 24);
codewordLens = Mem_Alloc(c->Entries, 1, "raw codeword lens"); codewordLens = (uint8_t*)Mem_Alloc(c->Entries, 1, "raw codeword lens");
for (i = 0; i < Array_Elems(c->NumCodewords); i++) { for (i = 0; i < Array_Elems(c->NumCodewords); i++) {
c->NumCodewords[i] = 0; c->NumCodewords[i] = 0;
} }