From ac1de90903b803fe666c87184fc29ca0206bc1d9 Mon Sep 17 00:00:00 2001 From: Retoxified Date: Tue, 24 May 2022 15:44:40 +0200 Subject: [PATCH 1/4] Fix mistake in refactor.py --- Scripts/refactor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/refactor.py b/Scripts/refactor.py index 730d1f9c1..7b04acc3a 100644 --- a/Scripts/refactor.py +++ b/Scripts/refactor.py @@ -137,11 +137,11 @@ def process(line): line = line.replace("LOBYTE(field_6_flags) |= 4u", "field_6_flags.Set(BaseGameObject::eDead_Bit3)") line = line.replace("1835626049", "ResourceManager::Resource_Animation") - line = line.replace("0x746C6150", "ResourceManager::Resource_Animation") + line = line.replace("0x6D696E41", "ResourceManager::Resource_Animation") line = line.replace("'minA'", "ResourceManager::Resource_Animation") line = line.replace("1953259856", "ResourceManager::Resource_Palt") - line = line.replace("0x6D696E41", "ResourceManager::Resource_Animation") + line = line.replace("0x746C6150", "ResourceManager::Resource_Palt") line = line.replace("'tlaP'", "ResourceManager::Resource_Palt") From 1898191bbac0abd15e75393f0238e9d7d879740d Mon Sep 17 00:00:00 2001 From: Retoxified Date: Tue, 24 May 2022 15:45:03 +0200 Subject: [PATCH 2/4] Update get_sdl2_win32.ps1 to use the latest required sdl --- get_sdl2_win32.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get_sdl2_win32.ps1 b/get_sdl2_win32.ps1 index d3bd67266..87c45f3e8 100644 --- a/get_sdl2_win32.ps1 +++ b/get_sdl2_win32.ps1 @@ -11,7 +11,7 @@ If(!(test-path build\SDL2)) Write-Host Creating build\SDL2 New-Item -ItemType Directory -Force -Path build\SDL2 Write-Host Download ZIP - Invoke-WebRequest -Uri 'https://www.libsdl.org/release/SDL2-devel-2.0.8-VC.zip' -OutFile 'build\SDL2.zip' + Invoke-WebRequest -Uri 'https://www.libsdl.org/release/SDL2-devel-2.0.22-VC.zip' -OutFile 'build\SDL2.zip' Write-Host Extract zip Unzip "build\SDL2.zip" "build\SDL2" } From 3ea67b2930cdafd2f2b4d935c3ab70c16003f1a3 Mon Sep 17 00:00:00 2001 From: Retoxified Date: Tue, 24 May 2022 15:46:27 +0200 Subject: [PATCH 3/4] Mark already loaded objects as free when they get added through Move_Resources_To_DArray_455430 so the heap compactor can free them again. --- Source/AliveLibAO/ResourceManager.cpp | 15 +++++++++++---- Source/AliveLibAO/ResourceManager.hpp | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/AliveLibAO/ResourceManager.cpp b/Source/AliveLibAO/ResourceManager.cpp index bd4426a2b..47570f092 100644 --- a/Source/AliveLibAO/ResourceManager.cpp +++ b/Source/AliveLibAO/ResourceManager.cpp @@ -289,7 +289,7 @@ void CC ResourceManager::On_Loaded_446C10(ResourceManager_FileRecord* pLoaded) // pLoaded is done with now, remove it ObjList_5009E0->Remove_Item(pLoaded); - + if (pLoaded) { // And destruct/free it @@ -401,7 +401,7 @@ void CC ResourceManager::LoadResourcesFromList_446E80(const char_type* pFileName bool allResourcesLoaded = true; for (s32 i = 0; i < pTypeAndIdList->field_0_count; i++) { - while (!ResourceManager::GetLoadedResource_4554F0( + if (!ResourceManager::GetLoadedResource_4554F0( pTypeAndIdList->field_4_items[i].field_0_type, pTypeAndIdList->field_4_items[i].field_4_res_id, 0, @@ -791,7 +791,7 @@ EXPORT u8** CC ResourceManager::Allocate_New_Block_454FE0(u32 sizeBytes, BlockAl { ResourceHeapItem* pListItem = sFirstLinkedListItem_50EE2C; ResourceHeapItem* pHeapMem = nullptr; - const u32 size = (sizeBytes + 3) & ~3u; // Rounding ?? + const u32 size = (sizeBytes + 3) & ~3u; // Align to a multiple of 4 Header* pHeaderToUse = nullptr; while (pListItem) { @@ -934,19 +934,26 @@ s16 CC ResourceManager::Move_Resources_To_DArray_455430(u8** ppRes, DynamicArray { auto pItemToAdd = (ResourceHeapItem*) ppRes; Header* pHeader = Get_Header_455620(ppRes); + u8** pFoundResourceInList = nullptr; if (pHeader->field_8_type != Resource_End) { while (pHeader->field_8_type != Resource_Pend && pHeader->field_0_size && !(pHeader->field_0_size & 3)) { - if (pArray) + if (pFoundResourceInList) // If we already found it in the list already and incremented the ref count, so mark this as free + { + pHeader->field_8_type = Resource_Free; + } + else if (pArray) { pArray->Push_Back((u8**) pItemToAdd); pHeader->field_4_ref_count++; } pHeader = (Header*) ((s8*) pHeader + pHeader->field_0_size); + + pFoundResourceInList = GetLoadedResource_4554F0(pHeader->field_8_type, pHeader->field_C_id, 1, 0); // Out of heap space if (pHeader->field_0_size >= kResHeapSize) diff --git a/Source/AliveLibAO/ResourceManager.hpp b/Source/AliveLibAO/ResourceManager.hpp index 034261d67..dc165fa8b 100644 --- a/Source/AliveLibAO/ResourceManager.hpp +++ b/Source/AliveLibAO/ResourceManager.hpp @@ -46,6 +46,8 @@ class ResourceManager final Resource_End = 0x21646E45, Resource_Plbk = 0x6B626C50, Resource_Play = 0x79616C50, + Resource_Indx = 0x78646E49, + Resource_Seq = 0x20716553, }; enum ResourceHeaderFlags : s16 From e447812f2bbaf00256f48ab08835106e15388cd6 Mon Sep 17 00:00:00 2001 From: Retoxified Date: Tue, 24 May 2022 18:44:02 +0200 Subject: [PATCH 4/4] As requested --- Source/AliveLibAE/stdlib.hpp | 2 +- Source/AliveLibAO/stdlib.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/AliveLibAE/stdlib.hpp b/Source/AliveLibAE/stdlib.hpp index ccf2fe1c1..0bf55e257 100644 --- a/Source/AliveLibAE/stdlib.hpp +++ b/Source/AliveLibAE/stdlib.hpp @@ -24,7 +24,7 @@ inline T* ae_new(Args&&... args) void* buffer = ae_new_malloc_4954D0(sizeof(T)); if constexpr (sizeof...(args) == 0) { - return new (buffer) T; + return new (buffer) T(); } else { diff --git a/Source/AliveLibAO/stdlib.hpp b/Source/AliveLibAO/stdlib.hpp index 2cde57c29..838ef650c 100644 --- a/Source/AliveLibAO/stdlib.hpp +++ b/Source/AliveLibAO/stdlib.hpp @@ -19,7 +19,7 @@ inline T* ao_new(Args&&... args) { if constexpr (sizeof...(args) == 0) { - return new (buffer) T; + return new (buffer) T(); } else {