Fix last commit accidentally undoing out of memory handling improvements in Protocol.c

This commit is contained in:
UnknownShadow200 2020-04-04 14:59:19 +11:00
parent 209a4046fb
commit 636bada0c8

View File

@ -423,8 +423,7 @@ static void MapState_Read(struct MapState* m) {
} }
static void Classic_StartLoading(void) { static void Classic_StartLoading(void) {
World_Reset(); World_NewMap();
Event_RaiseVoid(&WorldEvents.NewMap);
Stream_ReadonlyMemory(&map_part, NULL, 0); Stream_ReadonlyMemory(&map_part, NULL, 0);
LoadingScreen_Show(&Server.Name, &Server.MOTD); LoadingScreen_Show(&Server.Name, &Server.MOTD);
@ -515,9 +514,8 @@ static void Classic_LevelFinalise(cc_uint8* data) {
map_begunLoading = false; map_begunLoading = false;
WoM_CheckSendWomID(); WoM_CheckSendWomID();
if (map.allocFailed) return;
#ifdef EXTENDED_BLOCKS #ifdef EXTENDED_BLOCKS
if (map2.allocFailed) { FreeMapStates(); return; } if (map2.allocFailed) FreeMapStates();
#endif #endif
width = Stream_GetU16_BE(data + 0); width = Stream_GetU16_BE(data + 0);
@ -528,17 +526,13 @@ static void Classic_LevelFinalise(cc_uint8* data) {
Chat_AddRaw("&cFailed to load map, try joining a different map"); Chat_AddRaw("&cFailed to load map, try joining a different map");
Chat_AddRaw(" &cBlocks array size does not match volume of map"); Chat_AddRaw(" &cBlocks array size does not match volume of map");
FreeMapStates(); FreeMapStates();
return;
} }
World_SetNewMap(map.blocks, width, height, length);
#ifdef EXTENDED_BLOCKS #ifdef EXTENDED_BLOCKS
/* defer allocation of second map array if possible */ /* defer allocation of second map array if possible */
if (cpe_extBlocks && map2.blocks) { if (cpe_extBlocks && map2.blocks) World_SetMapUpper(map2.blocks);
World_SetMapUpper(map2.blocks);
}
#endif #endif
Event_RaiseVoid(&WorldEvents.MapLoaded); World_SetNewMap(map.blocks, width, height, length);
} }
static void Classic_SetBlock(cc_uint8* data) { static void Classic_SetBlock(cc_uint8* data) {
@ -1434,7 +1428,7 @@ static void CPE_Tick(void) {
*------------------------------------------------------Custom blocks------------------------------------------------------* *------------------------------------------------------Custom blocks------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static void BlockDefs_OnBlockUpdated(BlockID block, cc_bool didBlockLight) { static void BlockDefs_OnBlockUpdated(BlockID block, cc_bool didBlockLight) {
if (!World.Blocks) return; if (!World.Loaded) return;
/* Need to refresh lighting when a block's light blocking state changes */ /* Need to refresh lighting when a block's light blocking state changes */
if (Blocks.BlocksLight[block] != didBlockLight) Lighting_Refresh(); if (Blocks.BlocksLight[block] != didBlockLight) Lighting_Refresh();
} }
@ -1609,4 +1603,4 @@ void Protocol_Tick(void) {
Classic_Tick(); Classic_Tick();
CPE_Tick(); CPE_Tick();
WoM_Tick(); WoM_Tick();
} }