Merge remote-tracking branch 'origin/master' into symbian_squashed

# Conflicts:
#	src/Builder.c
This commit is contained in:
Shinovon 2025-05-20 19:26:42 +05:00
commit 47679d1788
6 changed files with 17 additions and 10 deletions

View File

@ -359,7 +359,8 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
/* idat decompressor */ /* idat decompressor */
#if CC_BUILD_MAXSTACK <= (50 * 1024) #if CC_BUILD_MAXSTACK <= (50 * 1024)
struct InflateState* inflate = (struct InflateState*)temp_mem; void* mem = TempMem_Alloc(sizeof(struct InflateState));
struct InflateState* inflate = (struct InflateState*)mem;
#else #else
struct InflateState _inflate; struct InflateState _inflate;
struct InflateState* inflate = &_inflate; struct InflateState* inflate = &_inflate;

View File

@ -361,8 +361,9 @@ static void OutputChunkPartsMeta(int x, int y, int z, struct ChunkInfo* info) {
void Builder_MakeChunk(struct ChunkInfo* info) { void Builder_MakeChunk(struct ChunkInfo* info) {
#if CC_BUILD_MAXSTACK <= (32 * 1024) #if CC_BUILD_MAXSTACK <= (32 * 1024)
BlockID* chunk = (BlockID*)temp_mem; void* mem = TempMem_Alloc((EXTCHUNK_SIZE_3 * sizeof(BlockID)) + (CHUNK_SIZE_3 * FACE_COUNT));
cc_uint8* counts = (cc_uint8*)temp_mem + EXTCHUNK_SIZE_3; BlockID* chunk = (BlockID*)mem;
cc_uint8* counts = (cc_uint8*)(chunk + EXTCHUNK_SIZE_3);
#else #else
BlockID chunk[EXTCHUNK_SIZE_3]; BlockID chunk[EXTCHUNK_SIZE_3];
cc_uint8 counts[CHUNK_SIZE_3 * FACE_COUNT]; cc_uint8 counts[CHUNK_SIZE_3 * FACE_COUNT];

View File

@ -659,9 +659,5 @@ struct Texture {
#define CC_END_HEADER #define CC_END_HEADER
#endif #endif
#if CC_BUILD_MAXSTACK < (64 * 1024)
extern char temp_mem[45000];
#endif
#endif #endif

View File

@ -316,7 +316,9 @@ static void NotchyGen_CreateHeightmap(void) {
struct CombinedNoise n1, n2; struct CombinedNoise n1, n2;
struct OctaveNoise n3; struct OctaveNoise n3;
}; };
struct NoiseBuffer* buf = (struct NoiseBuffer*)temp_mem; void* mem = TempMem_Alloc(sizeof(struct NoiseBuffer));
struct NoiseBuffer* buf = (struct NoiseBuffer*)mem;
struct CombinedNoise* n1 = &buf->n1; struct CombinedNoise* n1 = &buf->n1;
struct CombinedNoise* n2 = &buf->n2; struct CombinedNoise* n2 = &buf->n2;
struct OctaveNoise* n3 = &buf->n3; struct OctaveNoise* n3 = &buf->n3;
@ -567,7 +569,7 @@ static void NotchyGen_CreateSurfaceLayer(void) {
struct NoiseBuffer { struct NoiseBuffer {
struct OctaveNoise n1, n2; struct OctaveNoise n1, n2;
}; };
struct NoiseBuffer* buf = (struct NoiseBuffer*)temp_mem; struct NoiseBuffer* buf = TempMem_Alloc(sizeof(struct NoiseBuffer));
struct OctaveNoise* n1 = &buf->n1; struct OctaveNoise* n1 = &buf->n1;
struct OctaveNoise* n2 = &buf->n2; struct OctaveNoise* n2 = &buf->n2;
#else #else

View File

@ -18,6 +18,7 @@ Copyright 2014-2025 ClassiCube | Licensed under BSD-3
/* Suffix added to app name sent to the server */ /* Suffix added to app name sent to the server */
extern const char* Platform_AppNameSuffix; extern const char* Platform_AppNameSuffix;
void* TempMem_Alloc(int size);
#if defined CC_BUILD_WIN #if defined CC_BUILD_WIN
typedef struct cc_winstring_ { typedef struct cc_winstring_ {

View File

@ -6,7 +6,13 @@
#include "Funcs.h" #include "Funcs.h"
#if CC_BUILD_MAXSTACK < (64 * 1024) #if CC_BUILD_MAXSTACK < (64 * 1024)
CC_BIG_VAR char temp_mem[45000]; static CC_BIG_VAR int temp_mem[45000 / 4];
void* TempMem_Alloc(int size) {
if (size > sizeof(temp_mem)) Process_Abort("TempMem overflow");
return (void*)temp_mem;
}
#endif #endif
/*########################################################################################################################* /*########################################################################################################################*