From ada9caef3e580992d32c1492aacc6dcfd8a9026d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 19 Jun 2020 22:22:41 +1000 Subject: [PATCH] Fix MSVC project not compiling due to missing GameStructs.h, don't expose some private functions in .h files --- src/Audio.c | 12 ++++++------ src/Audio.h | 5 +---- src/Block.c | 2 +- src/ClassiCube.vcxproj | 1 - src/ClassiCube.vcxproj.filters | 3 --- src/MapRenderer.c | 2 +- src/MapRenderer.h | 1 - src/Protocol.c | 2 +- 8 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/Audio.c b/src/Audio.c index 7636432b8..7af61b692 100644 --- a/src/Audio.c +++ b/src/Audio.c @@ -215,7 +215,7 @@ void Audio_Open(AudioHandle* handle, int buffers) { Logger_Abort("No free audio contexts"); } -cc_result Audio_Close(AudioHandle handle) { +static cc_result Audio_DoClose(AudioHandle handle) { struct AudioFormat fmt = { 0 }; struct AudioContext* ctx = &audioContexts[handle]; @@ -349,7 +349,7 @@ void Audio_Open(AudioHandle* handle, int buffers) { Logger_Abort("No free audio contexts"); } -cc_result Audio_Close(AudioHandle handle) { +static cc_result Audio_DoClose(AudioHandle handle) { struct AudioFormat fmt = { 0 }; struct AudioContext* ctx; cc_result res; @@ -447,11 +447,11 @@ struct AudioFormat* Audio_GetFormat(AudioHandle handle) { return &audioContexts[handle].format; } -cc_result Audio_StopAndClose(AudioHandle handle) { +cc_result Audio_Close(AudioHandle handle) { cc_bool finished; Audio_Stop(handle); Audio_IsFinished(handle, &finished); /* unqueue buffers */ - return Audio_Close(handle); + return Audio_DoClose(handle); } @@ -722,7 +722,7 @@ static void Sounds_FreeOutputs(struct SoundOutput* outputs) { for (i = 0; i < AUDIO_MAX_HANDLES; i++) { if (outputs[i].handle == HANDLE_INV) continue; - Audio_StopAndClose(outputs[i].handle); + Audio_Close(outputs[i].handle); outputs[i].handle = HANDLE_INV; Mem_Free(outputs[i].buffer); @@ -900,7 +900,7 @@ static void Music_RunLoop(void) { Chat_AddRaw("&cDisabling music"); Audio_MusicVolume = 0; } - Audio_StopAndClose(music_out); + Audio_Close(music_out); if (music_joining) return; Thread_Detach(music_thread); diff --git a/src/Audio.h b/src/Audio.h index 19c83117f..68f4a10ed 100644 --- a/src/Audio.h +++ b/src/Audio.h @@ -27,11 +27,8 @@ typedef int AudioHandle; /* Acquires an audio context. */ void Audio_Open(AudioHandle* handle, int buffers); -/* Frees an allocated audio context. */ -/* NOTE: Audio_StopAndClose should be used, because this method can fail if audio is playing. */ -cc_result Audio_Close(AudioHandle handle); /* Stops playing audio, unqueues buffers, then frees the audio context. */ -cc_result Audio_StopAndClose(AudioHandle handle); +cc_result Audio_Close(AudioHandle handle); /* Returns the format audio is played in. */ struct AudioFormat* Audio_GetFormat(AudioHandle handle); /* Sets the format audio to play is in. */ diff --git a/src/Block.c b/src/Block.c index 531907206..bbdf2f41c 100644 --- a/src/Block.c +++ b/src/Block.c @@ -688,7 +688,7 @@ static void Blocks_Reset(void) { static void OnAtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); } static void Blocks_Init(void) { int block; - for (block = BLOCK_AIR; block <= BLOCK_MAX_DEFINED; block++) { + for (block = BLOCK_AIR; block < BLOCK_COUNT; block++) { Blocks.CanPlace[block] = true; Blocks.CanDelete[block] = true; } diff --git a/src/ClassiCube.vcxproj b/src/ClassiCube.vcxproj index 0a464b778..87062f313 100644 --- a/src/ClassiCube.vcxproj +++ b/src/ClassiCube.vcxproj @@ -233,7 +233,6 @@ - diff --git a/src/ClassiCube.vcxproj.filters b/src/ClassiCube.vcxproj.filters index 1cc25b77d..627e60248 100644 --- a/src/ClassiCube.vcxproj.filters +++ b/src/ClassiCube.vcxproj.filters @@ -165,9 +165,6 @@ Header Files\Game - - Header Files\Game - Header Files\Utils diff --git a/src/MapRenderer.c b/src/MapRenderer.c index 7e7b0d110..bb8ab431b 100644 --- a/src/MapRenderer.c +++ b/src/MapRenderer.c @@ -50,7 +50,7 @@ struct ChunkInfo* MapRenderer_GetChunk(int cx, int cy, int cz) { return &mapChunks[MapRenderer_Pack(cx, cy, cz)]; } -void ChunkInfo_Reset(struct ChunkInfo* chunk, int x, int y, int z) { +static void ChunkInfo_Reset(struct ChunkInfo* chunk, int x, int y, int z) { chunk->CentreX = x + HALF_CHUNK_SIZE; chunk->CentreY = y + HALF_CHUNK_SIZE; chunk->CentreZ = z + HALF_CHUNK_SIZE; #ifndef CC_BUILD_GL11 diff --git a/src/MapRenderer.h b/src/MapRenderer.h index 4964a9c78..10b0f2e09 100644 --- a/src/MapRenderer.h +++ b/src/MapRenderer.h @@ -64,7 +64,6 @@ struct ChunkInfo { struct ChunkPartInfo* TranslucentParts; }; -void ChunkInfo_Reset(struct ChunkInfo* chunk, int x, int y, int z); /* Gets the chunk at the given chunk coordinates in the world. */ /* NOTE: Does NOT check coordinates are within bounds. */ struct ChunkInfo* MapRenderer_GetChunk(int cx, int cy, int cz); diff --git a/src/Protocol.c b/src/Protocol.c index bb326296a..818f69b98 100644 --- a/src/Protocol.c +++ b/src/Protocol.c @@ -1464,7 +1464,7 @@ static void CPE_DefineModel(cc_uint8* data) { /* read # CustomModelParts */ numParts = *data++; - if (numParts >= MAX_CUSTOM_MODEL_PARTS) { + if (numParts > MAX_CUSTOM_MODEL_PARTS) { String msg; char msgBuffer[256]; String_InitArray(msg, msgBuffer);