Fix crashing in singleplayer, fix multiplayer maps with over 256 custom blocks still screwing up

This commit is contained in:
UnknownShadow200 2020-03-31 18:56:06 +11:00
parent 48d394f8d0
commit 035f5cedd8
4 changed files with 7 additions and 3 deletions

View File

@ -135,6 +135,7 @@ void* Mem_Realloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize, const char
#if defined CC_BUILD_WIN
void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) {
cc_uint32 numBytes = numElems * elemsSize; /* TODO: avoid overflow here */
if (numBytes >= 128 * 64 * 128) return NULL;
return HeapAlloc(heap, 0, numBytes);
}

View File

@ -107,9 +107,10 @@ static int Program_Run(int argc, char** argv) {
int argsCount = Platform_GetCommandLineArgs(argc, argv, args);
#ifdef _MSC_VER
/* NOTE: Make sure to comment this out before pushing a commit */
String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
//String rawArgs = String_FromConst("UnknownShadow200 40f6ae6f5ba44ce9765b388103a8365a 207.180.232.193 25556");
//String rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
//String rawArgs = String_FromConst("UnknownShadow200");
argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
//argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
#endif
if (argsCount == 0) {

View File

@ -516,7 +516,7 @@ static void Classic_LevelFinalise(cc_uint8* data) {
WoM_CheckSendWomID();
#ifdef EXTENDED_BLOCKS
if (map2.allocFailed) { FreeMapStates(); return; }
if (map2.allocFailed) FreeMapStates();
#endif
width = Stream_GetU16_BE(data + 0);

View File

@ -146,6 +146,8 @@ static void SPConnection_BeginConnect(void) {
Random_SeedFromCurrentTime(&rnd);
World_SetDimensions(128, 64, 128);
World_NewMap();
Gen_Vanilla = true;
Gen_Seed = Random_Next(&rnd, Int32_MaxValue);
GeneratingScreen_Show();