Mercurial > mm7
changeset 1603:c58916c53d8e
Merge
author | Grumpy7 |
---|---|
date | Thu, 12 Sep 2013 09:58:07 +0200 |
parents | 96a1f5e0b6cd (current diff) 1efbaf1d01c3 (diff) |
children | 4b79ff62df3a 361b63797bdf |
files | Actor.cpp Allocator.cpp Allocator.h Items.cpp Items.h mm7_2.cpp mm7_4.cpp |
diffstat | 53 files changed, 1139 insertions(+), 1500 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Actor.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -32,7 +32,6 @@ #include "stru298.h" #include "Log.h" #include "Texts.h" -#include "Allocator.h" @@ -5401,8 +5400,7 @@ monster_id = a1; x_ = x; v15 = a1; - if (uNumActors < 500 - && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 ) + if (uNumActors < 500) { v16 = 0; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
--- a/Allocator.cpp Thu Sep 12 09:55:20 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,427 +0,0 @@ -#ifdef _MSC_VER -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include <string.h> -#include <stdio.h> - -#include "Allocator.h" -#include "ErrorHandling.h" - -#include "mm7_data.h" - - - -Allocator *pAllocator; // idb - -int aborting_app = false; // weak - - - - -void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize); - - - -//----- (00426755) -------------------------------------------------------- -void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName) -{ - Assert(!pPrevPtrValue, "PrevPtrValue != 0"); - - if (!uSize) - return 0; - return malloc(uSize); -/* - //Allocator *v4; // esi@1 - unsigned int v5; // eax@7 - void *result; // eax@8 - // unsigned int *pNumBuffersUsed; // ebx@12 - unsigned int v8; // edi@15 - char v9; // zf@15 - int v10; // eax@16 - void **v11; // ebx@19 - void *v12; // eax@22 - unsigned int Size; // [sp+14h] [bp+Ch]@16 - - int aligned_size; - - - if ( pPrevPtrValue && !aborting_app ) - AbortWithError(); - if ( !bBigBufferAllocated && !aborting_app ) - AbortWithError(); - - if (!uSize) - return 0; - - if (((uSize & 0x80000000u) != 0) && !aborting_app) - AbortWithError(); - - if (uNumBuffersUsed == 6000 && !aborting_app) - AbortWithError(); - - ++uNumBuffersUsed; - - if (!bUseBigBuffer) - { - pMemoryBuffers[uNumBuffersUsed] = malloc(uSize); - if (pMemoryBuffers[uNumBuffersUsed]) - uMemoryBuffersSizes[uNumBuffersUsed] = uSize; - else - { - if ( !aborting_app ) - AbortWithError(); - } - } - else - { - - aligned_size =(uSize&0xFFFFFFFC) + 4; - - if ((uNextFreeOffsetInBigBuffer +aligned_size) > uBigBufferSizeAligned) - { - printf("Id: %s Size: %i", pName, aligned_size); - CreateFileDump( "Memory"); - if ( !aborting_app ) - AbortWithError(); - } - - pMemoryBuffers[uNumBuffersUsed] = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;//(char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer; - uMemoryBuffersSizes[uNumBuffersUsed] =aligned_size; - - if (pName) - strncpy(pMemoryBuffersNames[uNumBuffersUsed], pName, 11); - uNextFreeOffsetInBigBuffer += aligned_size; - } - return pMemoryBuffers[uNumBuffersUsed]; - */ - /* - //v4 = this; - if ( pPrevPtrValue && !aborting_app ) - AbortWithError(); - if ( !bBigBufferAllocated && !aborting_app ) - AbortWithError(); - v5 = uSize; - if ( uSize ) - { - if ( (uSize & 0x80000000u) != 0 && !aborting_app ) - { - AbortWithError(); - v5 = uSize; - } - pNumBuffersUsed = &uNumBuffersUsed; - if (uNumBuffersUsed == 6000 && !aborting_app) - { - AbortWithError(); - v5 = uSize; - } - v8 = *pNumBuffersUsed; - v9 = bUseBigBuffer == 0; - ++*pNumBuffersUsed; - if ( v9 ) - { - v12 = malloc(v5); - v11 = &pMemoryBuffers[v8]; - *v11 = v12; - if ( v12 ) - { - uMemoryBuffersSizes[v8] = uSize; - } - else - { - if ( !aborting_app ) - AbortWithError(); - } - } - else - { - LOBYTE(v5) = v5 & 0xFC; - v10 = v5 + 4; - Size = v10; - if ( v10 + uNextFreeOffsetInBigBuffer > uBigBufferSizeAligned ) - { - printf("Id: %s Size: %i\n", pName, v10); - CreateFileDump("Memory"); - if ( !aborting_app ) - AbortWithError(); - } - v11 = &pMemoryBuffers[v8]; - *v11 = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer; - uMemoryBuffersSizes[v8] = Size; - if (pName) - strncpy(pMemoryBuffersNames[v8], pName, 11); - uNextFreeOffsetInBigBuffer += Size; - } - result = *v11; - } - else - { - result = 0; - } - return result;*/ -} -// 720018: using guessed type int aborting_app; - - - -//----- (004266CD) -------------------------------------------------------- -bool Allocator::Initialize(unsigned int uNumKBytes) -{ - if (bBigBufferAllocated) - return false; - - if (!uNumKBytes) - return false; - - pBigMemoryBuffer = malloc(uNumKBytes * 1024); - if (!pBigMemoryBuffer) - return false; - - pBigBufferAligned = (void *)((unsigned int)(pBigMemoryBuffer) & 0xFFFF0000 + 4096); - //(char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096; - uBigBufferSizeAligned = (uNumKBytes * 1024) - 4096; - - uNumBuffersUsed = 0; - uNextFreeOffsetInBigBuffer = 0; - - bUseBigBuffer = true; - return bBigBufferAllocated = true; -} - - -//----- (00426474) -------------------------------------------------------- -void Allocator::FreeChunk(void *ptr) -{ - free(ptr); - return; -/* Allocator *v2; // esi@1 - unsigned int v3; // eax@5 - signed int i; // edi@5 - unsigned int v5; // eax@13 - signed int v6; // ecx@16 - signed int j; // edx@16 - char v8; // zf@20 - - - - unsigned int uBuffindx; - unsigned int indx; - - if (ptr) - { - if ((!bBigBufferAllocated)&& (!aborting_app )) - AbortWithError(); - for (indx = 0; indx <=uNumBuffersUsed; ++indx) - if (pMemoryBuffers[indx] == ptr) - break; - //if ((indx>uNumBuffersUsed)&& !aborting_app ) - //AbortWithError(); //to detect memory problems - uncomment - if (!bUseBigBuffer) - free(pMemoryBuffers[indx]); - pMemoryBuffers[indx] = NULL; - uMemoryBuffersSizes[indx] = 0; - pMemoryBuffersNames[indx][0] = 0; - if (indx == (uNumBuffersUsed-1)) - { - if (indx>0) - { - uBuffindx = 0; - for (j = 0; j < uNumBuffersUsed-1; ++j) - { - if (pMemoryBuffers[j]) - uBuffindx = j; - } - uNumBuffersUsed = uBuffindx + 1; - if (bUseBigBuffer) - uNextFreeOffsetInBigBuffer = - ((long)((char*)pMemoryBuffers[uBuffindx] -(char*)pBigBufferAligned)+ uMemoryBuffersSizes[uBuffindx]); - } - else - { - uNumBuffersUsed = 0; - uNextFreeOffsetInBigBuffer = 0; - } - } - } - */ -/* - v2 = this; - if ( ptr ) - { - if ( !this->bBigBufferAllocated && !aborting_app ) - AbortWithError(); - v3 = v2->uNumBuffersUsed; - for ( i = 0; i < (signed int)v3; ++i ) - { - if ( v2->pMemoryBuffers[i] == ptr ) - break; - } - if ( i >= (signed int)v3 && !aborting_app ) - AbortWithError(); - if ( !v2->bUseBigBuffer ) - free(v2->pMemoryBuffers[i]); - v2->pMemoryBuffers[i] = 0; - v2->uMemoryBuffersSizes[i] = 0; - LOBYTE(v2->pMemoryBuffers[3 * i + 12000]) = 0; - v5 = v2->uNumBuffersUsed; - if ( i == v5 - 1 ) - { - if ( i ) - { - v6 = 0; - for ( j = 0; j < (signed int)v5; ++j ) - { - if ( v2->pMemoryBuffers[j] ) - v6 = j; - } - v8 = v2->bUseBigBuffer == 0; - v2->uNumBuffersUsed = v6 + 1; - if ( !v8 ) - v2->uNextFreeOffsetInBigBuffer = (char *)v2->pMemoryBuffers[v6] - + v2->uMemoryBuffersSizes[v6] - - v2->pBigMemoryBuffer; - } - else - { - v2->uNextFreeOffsetInBigBuffer = 0; - v2->uNumBuffersUsed = 0; - } - } - }*/ -} -// 720018: using guessed type int aborting_app; - - - -//----- (00426429) -------------------------------------------------------- -Allocator::Allocator() -{ - Allocator *v1; // eax@1 - signed int v2; // ecx@1 - int v3; // edx@1 - - v1 = this; - v2 = 0; - v1->uBigBufferSizeAligned = 0; - v1->bBigBufferAllocated = 0; - v3 = (int)v1->pMemoryBuffersNames; - do - { - v1->pMemoryBuffers[v2] = 0; - v1->uMemoryBuffersSizes[v2] = 0; - *(char *)v3 = 0; - ++v2; - v3 += 12; - } - while ( v2 < 6000 ); - v1->uDumpsCount = 0; -} - - -//----- (0042654C) -------------------------------------------------------- -bool Allocator::CreateFileDump(const char *a1) -{ - Allocator *v2; // esi@1 - unsigned int v3; // ST44_4@1 - FILE *v4; // eax@1 - FILE *v5; // edi@1 - bool result; // eax@2 - unsigned int v7; // ecx@5 - int v8; // edx@5 - int v9; // eax@6 - int v10; // eax@8 - int v11; // ecx@8 - signed int v12; // ebx@8 - signed int v13; // ebx@10 - struct _MEMORYSTATUS memstat; // [sp+8h] [bp-38h]@5 - char Filename[20]; // [sp+28h] [bp-18h]@1 - unsigned int *v16; // [sp+3Ch] [bp-4h]@11 - int a1a; // [sp+48h] [bp+8h]@11 - - v2 = this; - v3 = this->uDumpsCount; - this->uDumpsCount = v3 + 1; - sprintf(Filename, "Mem%03i.txt", v3); - v4 = fopen(Filename, "w"); - v5 = v4; - if ( v4 ) - { - if ( a1 ) - fprintf(v4, "%s\n\n", a1); - fprintf(v5, "Windows Memory Status"); - GlobalMemoryStatus(&memstat); - fprintf(v5, "dwLength: %d\n\n", memstat.dwLength); - fprintf(v5, "dwMemoryLoad: %d\n", memstat.dwMemoryLoad); - fprintf(v5, "dwTotalPhys: %d\n", memstat.dwTotalPhys); - fprintf(v5, "dwAvailPhys: %d\n", memstat.dwAvailPhys); - fprintf(v5, "dwTotalPageFile: %d\n", memstat.dwTotalPageFile); - fprintf(v5, "dwAvailPageFile: %d\n", memstat.dwAvailPageFile); - fprintf(v5, "dwTotalVirtual: %d\n", memstat.dwTotalVirtual); - fprintf(v5, "dwAvailVirtual: %d\n\n\n", memstat.dwAvailVirtual); - v7 = v2->uNumBuffersUsed; - v8 = 0; - if ( (signed int)v7 > 0 ) - { - v9 = (int)v2->uMemoryBuffersSizes; - do - { - v8 += *(int *)v9; - v9 += 4; - --v7; - } - while ( v7 ); - } - v10 = 0; - v11 = (int)v2->uMemoryBuffersSizes; - v12 = 6000; - do - { - v10 += *(int *)v11; - v11 += 4; - --v12; - } - while ( v12 ); - fprintf(v5, "Size: %i %i %i\n\n", v2->uNumBuffersUsed, v8, v10); - v13 = 0; - if ( (signed int)v2->uNumBuffersUsed > 0 ) - { - v16 = v2->uMemoryBuffersSizes; - a1a = (int)v2->pMemoryBuffersNames; - do - { - fprintf(v5, "%10i %10i %s\n", v13, *v16, a1a); - a1a += 12; - ++v16; - ++v13; - } - while ( v13 < (signed int)v2->uNumBuffersUsed ); - } - fclose(v5); - result = 0; - } - else - { - result = 1; - } - return result; -} - - - - - - - - -//----- (00426892) -------------------------------------------------------- -static void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize) -{ - DWORD v2; // edi@1 - DWORD i; // eax@1 - struct _SYSTEM_INFO SystemInfo; // [sp+8h] [bp-24h]@1 - - v2 = uSize; - GetSystemInfo(&SystemInfo); - for ( i = 16 * SystemInfo.dwPageSize; i < v2; i += SystemInfo.dwPageSize ) - ; -}
--- a/Allocator.h Thu Sep 12 09:55:20 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#pragma once - - -#pragma pack(push, 1) -struct Allocator -{ - static Allocator *Create() {static Allocator a; return &a;} - - Allocator(); - bool Initialize(unsigned int uNumKBytes); - void *AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName); - void FreeChunk(void *ptr); - bool CreateFileDump(const char *a1); - - void *pMemoryBuffers[6000]; - unsigned int uMemoryBuffersSizes[6000]; - char pMemoryBuffersNames[6000][12]; - unsigned int uDumpsCount; - unsigned int uNumBuffersUsed; - void *pBigMemoryBuffer; - unsigned int uNextFreeOffsetInBigBuffer; - unsigned int uBigBufferSizeAligned; - unsigned int bBigBufferAllocated; - unsigned int bUseBigBuffer; - void *pBigBufferAligned; -}; -#pragma pack(pop) - - - -extern Allocator *pAllocator; // idb \ No newline at end of file
--- a/AudioPlayer.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/AudioPlayer.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -7,7 +7,6 @@ #include "mm7_data.h" #include "VideoPlayer.h" #include "AudioPlayer.h" -#include "Allocator.h" #include "FrameTableInc.h" #include "Indoor.h" #include "SpriteObject.h" @@ -399,7 +398,7 @@ assert(sNumSounds); assert(!num_mm8_sounds); - pSounds = (SoundDesc *)pAllocator->AllocNamedChunk(pSounds, sNumSounds * sizeof(SoundDesc), "Snd Des."); + pSounds = (SoundDesc *)malloc(sNumSounds * sizeof(SoundDesc)); memcpy(pSounds, (char *)data_mm7 + 4, num_mm7_sounds * sizeof(SoundDesc)); for (uint i = 0; i < num_mm6_sounds; ++i) { @@ -436,7 +435,7 @@ unsigned int Argsa; // [sp+304h] [bp+8h]@3 v2 = this; - pAllocator->FreeChunk(this->pSounds); + free(this->pSounds); v3 = 0; v2->pSounds = 0; v2->sNumSounds = 0; @@ -461,7 +460,7 @@ v3 = 0; } v2->sNumSounds = v5; - v6 = pAllocator->AllocNamedChunk(v2->pSounds, 120 * v5, "Snd Des."); + v6 = malloc(120 * v5); v2->pSounds = (SoundDesc *)v6; if ( v6 == (void *)v3 ) Error("SoundListClass::load - Out of Memory!"); @@ -1873,7 +1872,7 @@ ReadFile(hAudioSnd, &uNumSoundHeaders, 4u, &NumberOfBytesRead, 0); pSoundHeaders = nullptr; - pSoundHeaders = (SoundHeader *)pAllocator->AllocNamedChunk(0, 52 * uNumSoundHeaders + 2, 0); + pSoundHeaders = (SoundHeader *)malloc(52 * uNumSoundHeaders + 2); ReadFile(hAudioSnd, pSoundHeaders, 52 * uNumSoundHeaders, &NumberOfBytesRead, 0); } @@ -2417,7 +2416,7 @@ { if ( pSounds[i].pSoundData == _this ) { - pAllocator->FreeChunk(_this); + free(_this); memset(&pSounds[i], 0, 0x80u); } } @@ -2506,7 +2505,7 @@ if ( uFindSound_BinSearch_ResultID == -1 ) return 0; if ( pOutBuff == (SoundData *)-1 ) - pOutBuff = (SoundData *)pAllocator->AllocNamedChunk(0, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4, pSoundName); + pOutBuff = (SoundData *)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4); SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uFileOffset, 0, 0); if ( (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) {
--- a/BSPModel.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/BSPModel.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -1,5 +1,6 @@ +#include <stdlib.h> + #include "BSPModel.h" -#include "Allocator.h" @@ -12,16 +13,16 @@ void *v4; // ST00_4@1 v1 = this; - pAllocator->FreeChunk(*(void **)&this->pVertices.pVertices); + free(*(void **)&this->pVertices.pVertices); v2 = v1->pFaces; v1->pVertices.pVertices = 0; - pAllocator->FreeChunk(v2); + free(v2); v3 = v1->pFacesOrdering; v1->pFaces = 0; - pAllocator->FreeChunk(v3); + free(v3); v4 = v1->pNodes; v1->pFacesOrdering = 0; - pAllocator->FreeChunk(v4); + free(v4); v1->pNodes = 0; v1->uNumNodes = 0; v1->uNumFaces = 0;
--- a/Chest.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Chest.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -8,7 +8,6 @@ #include "Items.h" #include "Chest.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "LOD.h" #include "MapInfo.h" #include "Actor.h" @@ -635,7 +634,7 @@ assert(uNumChests); assert(!num_mm8_chests); - pChests = (ChestDesc *)pAllocator->AllocNamedChunk(pChests, uNumChests * sizeof(ChestDesc), "Chest Descrip"); + pChests = (ChestDesc *)malloc(uNumChests * sizeof(ChestDesc)); memcpy(pChests, (char *)data_mm7 + 4, num_mm7_chests * sizeof(ChestDesc)); memcpy(pChests + num_mm7_chests, (char *)data_mm6 + 4, num_mm6_chests * sizeof(ChestDesc)); memcpy(pChests + num_mm6_chests + num_mm7_chests, (char *)data_mm8 + 4, num_mm8_chests * sizeof(ChestDesc)); @@ -664,7 +663,7 @@ unsigned int Argsa; // [sp+300h] [bp+8h]@3 v2 = this; - pAllocator->FreeChunk(this->pChests); + free(this->pChests); v3 = 0; v2->pChests = 0; v2->uNumChests = 0; @@ -690,7 +689,7 @@ } v6 = v2->pChests; v2->uNumChests = v5; - v7 = pAllocator->AllocNamedChunk(v6, 36 * v5, "Chest Descrip"); + v7 = malloc(36 * v5); v2->pChests = (ChestDesc *)v7; if ( v7 == (void *)v3 ) Error("ChestDescriptionList::load - Out of Memory!");
--- a/DecorationList.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/DecorationList.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -1,6 +1,5 @@ #include "Sprites.h" #include "DecorationList.h" -#include "Allocator.h" #include "MM7.h" #include "FrameTableInc.h" #include "mm7_data.h" @@ -18,7 +17,7 @@ Assert(uNumDecorations); Assert(!num_mm8_decs); - pDecorations = (DecorationDesc *)pAllocator->AllocNamedChunk(pDecorations, uNumDecorations * sizeof(DecorationDesc), "Dec Descrip"); + pDecorations = (DecorationDesc *)malloc(uNumDecorations * sizeof(DecorationDesc)); memcpy(pDecorations, (char *)data_mm7 + 4, num_mm7_decs * sizeof(DecorationDesc)); for (uint i = 0; i < num_mm6_decs; ++i) { @@ -104,7 +103,7 @@ v4 = Argsa; } v2->uNumDecorations = v4; - v5 = pAllocator->AllocNamedChunk(v2->pDecorations, 84 * v4, "Dec Descrip"); + v5 = malloc(84 * v4); v2->pDecorations = (DecorationDesc *)v5; if ( !v5 ) Error("DecorationDescriptionList::load - Out of Memory!");
--- a/Events.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Events.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -25,7 +25,6 @@ #include "Indoor.h" #include "Viewport.h" #include "texts.h" -#include "Allocator.h" #include "stru123.h" #include "stru159.h" #include "Events.h" @@ -84,7 +83,7 @@ Error("File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); memcpy(pBuffer, ptr, uTextureSize); - pAllocator->FreeChunk(ptr); + free(ptr); return uTextureSize; } @@ -812,7 +811,7 @@ do { v49 = v48->pNext; - pAllocator->FreeChunk(v48); + free(v48); v48 = v49; } while ( v49 );
--- a/GUIWindow.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/GUIWindow.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -10,7 +10,6 @@ #include "IndoorCamera.h" #include "Math.h" #include "VideoPlayer.h" -#include "Allocator.h" #include "MapInfo.h" #include "Time.h" #include "AudioPlayer.h" @@ -353,7 +352,7 @@ do { pNextBtn = this->pControlsHead->pNext; - pAllocator->FreeChunk(this->pControlsHead); + free(this->pControlsHead); this->pControlsHead = pNextBtn; } while ( pNextBtn ); @@ -1038,6 +1037,7 @@ TempleDialog(); break; case BuildingType_Stables: + case BuildingType_Boats: TravelByTransport(); break; case BuildingType_Training: @@ -1496,7 +1496,7 @@ GUIButton *v21; // eax@7 va_list texturs_ptr; - pButton = (GUIButton *)pAllocator->AllocNamedChunk(0, 0xBCu, "BUTTON"); + pButton = (GUIButton *)malloc(0xBC); pButton->pParent = this; pButton->uWidth = uWidth; pButton->uHeight = uHeight; @@ -1726,31 +1726,29 @@ if (eWindowType == WINDOW_HouseInterior) { pCurrentScreen = SCREEN_HOUSE; - pBtn_ExitCancel = pWindow->CreateButton(471, 445, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[80],//Âûéòè èç çäàíèÿ + pBtn_ExitCancel = pWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[80],//Âûéòè èç çäàíèÿ pIcons_LOD->GetTexture(uExitCancelTextureId), 0); - - for ( v26 = 0; v26 < uNumDialogueNPCPortraits; ++v26 ) + for ( v26 = 0; v26 < uNumDialogueNPCPortraits; ++v26 ) + { + if ( v26 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) { - if ( v26 + 1 == uNumDialogueNPCPortraits && uHouse_ExitPic ) - { - v30 = pMapStats->pInfos[uHouse_ExitPic].pName; - v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S]; - } + v30 = pMapStats->pInfos[uHouse_ExitPic].pName; + v29 = (char*)pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S]; + } + else + { + if ( v26 || !dword_591080 ) + v27 = HouseNPCData[v26 +1 - ((dword_591080 != 0)? 1:0)]->pName; else - { - if ( v26 || !dword_591080 ) - v27 = HouseNPCData[v26 +1 - ((dword_591080 != 0)? 1:0)]->pName; - else - v27 = (char*)p2DEvents[pButton - 1].pProprieterName; - v30 = v27; - v29 = (char*)pGlobalTXT_LocalizationStrings[435]; - } - sprintfex(byte_591180[v26].data(), v29, v30); - dword_5913F4[v26] = pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], - pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], - 0x3Fu, 0x49u, 1, 0, UIMSG_ClickHouseNPCPortrait, v26, 0, byte_591180[v26].data(), 0, 0, 0); + v27 = (char*)p2DEvents[pButton - 1].pProprieterName; + v30 = v27; + v29 = (char*)pGlobalTXT_LocalizationStrings[435]; } - + sprintfex(byte_591180[v26].data(), v29, v30); + HouseNPCPortraitsButtonsList[v26] = pWindow->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][v26], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][v26], + 63, 73, 1, 0, UIMSG_ClickHouseNPCPortrait, v26, 0, byte_591180[v26].data(), 0, 0, 0); + } if ( uNumDialogueNPCPortraits == 1 ) { window_SpeakInHouse = &pWindowList[uNextFreeWindowID];
--- a/IconFrameTable.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/IconFrameTable.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -1,7 +1,6 @@ #include "IconFrameTable.h" #include "LOD.h" #include "mm7_data.h" -#include "Allocator.h" #include "FrameTableInc.h" //----- (00494F3A) -------------------------------------------------------- @@ -122,7 +121,7 @@ Assert(uNumIcons); Assert(!num_mm8_frames); - pIcons = (IconFrame *)pAllocator->AllocNamedChunk(pIcons, uNumIcons * sizeof(IconFrame), "I Frames"); + pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame)); memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame)); memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame)); memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame)); @@ -182,7 +181,7 @@ v4 = v21; } v2->uNumIcons = v4; - v5 = pAllocator->AllocNamedChunk(v2->pIcons, 32 * v4, "I Frames"); + v5 = malloc(32 * v4);//, "I Frames"); v2->pIcons = (IconFrame *)v5; if ( v5 ) {
--- a/Indoor.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Indoor.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -17,7 +17,6 @@ #include "Time.h" #include "Party.h" #include "Math.h" -#include "Allocator.h" #include "LOD.h" #include "DecorationList.h" #include "ObjectList.h" @@ -1023,15 +1022,15 @@ v1 = this; v2 = (char *)&this->ptr_0002B4_doors_ddata; - pAllocator->FreeChunk(this->ptr_0002B4_doors_ddata); + free(this->ptr_0002B4_doors_ddata); *(int *)v2 = 0; - pAllocator->FreeChunk(v1->ptr_0002B0_sector_rdata); + free(v1->ptr_0002B0_sector_rdata); v1->ptr_0002B0_sector_rdata = 0; - pAllocator->FreeChunk(v1->ptr_0002B8_sector_lrdata); + free(v1->ptr_0002B8_sector_lrdata); v1->ptr_0002B8_sector_lrdata = 0; - pAllocator->FreeChunk(v1->pLFaces); + free(v1->pLFaces); v1->pLFaces = 0; - pAllocator->FreeChunk(v1->pSpawnPoints); + free(v1->pSpawnPoints); v3 = v1->pVertices; v1->pSpawnPoints = 0; v1->uNumSectors = 0; @@ -1040,14 +1039,14 @@ v1->uNumNodes = 0; v1->uNumDoors = 0; v1->uNumLights = 0; - pAllocator->FreeChunk(v3); - pAllocator->FreeChunk(v1->pFaces); - pAllocator->FreeChunk(v1->pFaceExtras); - pAllocator->FreeChunk(v1->pSectors); - pAllocator->FreeChunk(v1->pLights); - pAllocator->FreeChunk(v1->pDoors); - pAllocator->FreeChunk(v1->pNodes); - pAllocator->FreeChunk(v1->pMapOutlines); + free(v3); + free(v1->pFaces); + free(v1->pFaceExtras); + free(v1->pSectors); + free(v1->pLights); + free(v1->pDoors); + free(v1->pNodes); + free(v1->pMapOutlines); v1->pVertices = 0; v1->pFaces = 0; v1->pFaceExtras = 0; @@ -1062,14 +1061,14 @@ //----- (00498C45) -------------------------------------------------------- bool IndoorLocation::Alloc() { - pVertices = (Vec3_short_ *) pAllocator->AllocNamedChunk(pVertices, 15000*sizeof(Vec3_short_), "L.V");//0x15F90u - pFaces = (BLVFace *) pAllocator->AllocNamedChunk(pFaces, 10000*sizeof(BLVFace), "L.F");//0xEA600u - pFaceExtras = (BLVFaceExtra *) pAllocator->AllocNamedChunk(pFaceExtras,5000*sizeof(BLVFaceExtra), "L.FX"); //0x2BF20u - pSectors = (BLVSector *) pAllocator->AllocNamedChunk(pSectors, 512*sizeof(BLVSector), "L.R");//0xE800u - pLights = (BLVLightMM7 *) pAllocator->AllocNamedChunk(pLights, 400*sizeof(BLVLightMM7), "L.L");//0x1900u - pDoors = (BLVDoor *) pAllocator->AllocNamedChunk(pDoors, 200*sizeof(BLVDoor), "L.D");//0x3E80u - pNodes = (BSPNode *) pAllocator->AllocNamedChunk(pNodes, 5000*sizeof(BSPNode), "L.BSP");//0x9C40u - pMapOutlines =(BLVMapOutlines *)pAllocator->AllocNamedChunk(pMapOutlines, sizeof(BLVMapOutlines), "L.Map");//0x14824u + pVertices = (Vec3_short_ *) malloc(15000 * sizeof(Vec3_short_));//0x15F90u + pFaces = (BLVFace *) malloc(10000 * sizeof(BLVFace));//0xEA600u + pFaceExtras = (BLVFaceExtra *) malloc(5000 * sizeof(BLVFaceExtra)); //0x2BF20u + pSectors = (BLVSector *) malloc(512 * sizeof(BLVSector));//0xE800u + pLights = (BLVLightMM7 *) malloc(400 * sizeof(BLVLightMM7));//0x1900u + pDoors = (BLVDoor *) malloc(200 * sizeof(BLVDoor));//0x3E80u + pNodes = (BSPNode *) malloc(5000 * sizeof(BSPNode));//0x9C40u + pMapOutlines =(BLVMapOutlines *)malloc(sizeof(BLVMapOutlines));//0x14824u if (pVertices && pFaces && pFaceExtras && pSectors && pLights && pDoors && pNodes && pMapOutlines ) { memset(pVertices, 0, 15000*sizeof(Vec3_short_)); @@ -1345,7 +1344,7 @@ fread(&uNumFaces, 4u, 1u, v7); fseek(v7, v210, 0); fread(pFaces, 0x60u, uNumFaces, v7); - v10 = pAllocator->AllocNamedChunk(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); + v10 = malloc(ptr_2AC, blv.uFaces_fdata_Size, "L.FData"); v202 = (int)v7; ptr_2AC = (unsigned __int16 *)v10; fread(v10, 1u, blv.uFaces_fdata_Size, (FILE *)v202); @@ -1466,7 +1465,7 @@ fread(&uNumSectors, 4u, 1u, v7); fseek(v7, v214, 0); fread(pSectors, 0x74u, uNumSectors, v7); - v32 = pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); + v32 = malloc(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); v202 = (int)v7; ptr_0002B0_sector_rdata = (unsigned __int16 *)v32; fread(v32, 1u, blv.uSector_rdata_Size, (FILE *)v202); @@ -1523,7 +1522,7 @@ } while ( Argse < uNumSectors ); } - v47 = pAllocator->AllocNamedChunk( + v47 = malloc( ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); @@ -1554,7 +1553,7 @@ fread(&uNumDoors, 4u, 1u, v7); fseek(v7, v216, 0); fread(pDoors, 0x50u, 0xC8u, v7); - v51 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); + v51 = malloc(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); v202 = (int)v7; ptr_0002B4_doors_ddata = (unsigned __int16 *)v51; fread(v51, 1u, blv.uDoors_ddata_Size, (FILE *)v202); @@ -1718,7 +1717,7 @@ fread(pNodes, 8u, uNumNodes, v7); fseek(v7, v230, 0); fread(&uNumSpawnPoints, 4u, 1u, v7); - v79 = pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); + v79 = malloc(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); v202 = 0; pSpawnPoints = (SpawnPointMM7 *)v79; fseek(v7, v231, v202); @@ -1823,7 +1822,7 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(pFaces, pData += 4, uNumFaces * sizeof (BLVFace)); - pLFaces = (unsigned __int16 *)pAllocator->AllocNamedChunk(pLFaces, blv.uFaces_fdata_Size, "L.FData"); + pLFaces = (unsigned __int16 *)malloc(blv.uFaces_fdata_Size); memcpy(pLFaces, pData += uNumFaces * sizeof (BLVFace), blv.uFaces_fdata_Size); @@ -1951,7 +1950,7 @@ pGameLoadingUI_ProgressBar->Progress(); - ptr_0002B0_sector_rdata = (unsigned short *)pAllocator->AllocNamedChunk(ptr_0002B0_sector_rdata, blv.uSector_rdata_Size, "L.RData"); + ptr_0002B0_sector_rdata = (unsigned short *)malloc(blv.uSector_rdata_Size);//, "L.RData"); memcpy(ptr_0002B0_sector_rdata, pData, blv.uSector_rdata_Size); pData += blv.uSector_rdata_Size; @@ -2034,7 +2033,7 @@ //while ( v245 < uNumSectors ); } - ptr_0002B8_sector_lrdata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B8_sector_lrdata, blv.uSector_lrdata_Size, "L.RLData"); + ptr_0002B8_sector_lrdata = (unsigned __int16 *)malloc(blv.uSector_lrdata_Size);//, "L.RLData"); memcpy(ptr_0002B8_sector_lrdata, pData, blv.uSector_lrdata_Size); pData += blv.uSector_lrdata_Size; @@ -2082,7 +2081,7 @@ pGameLoadingUI_ProgressBar->Progress(); memcpy(&uNumSpawnPoints, pData, 4); - pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, uNumSpawnPoints * sizeof(SpawnPointMM7), "Spawn"); + pSpawnPoints = (SpawnPointMM7 *)malloc(uNumSpawnPoints * sizeof(SpawnPointMM7)); memcpy(pSpawnPoints, pData + 4, uNumSpawnPoints * sizeof(SpawnPointMM7)); pData += 4 + uNumSpawnPoints * sizeof(SpawnPointMM7); @@ -2294,9 +2293,9 @@ //v201 = (const char *)blv.uDoors_ddata_Size; //v200 = (size_t)ptr_0002B4_doors_ddata; - //v170 = pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); + //v170 = malloc(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); //v171 = blv.uDoors_ddata_Size; - ptr_0002B4_doors_ddata = (unsigned __int16 *)pAllocator->AllocNamedChunk(ptr_0002B4_doors_ddata, blv.uDoors_ddata_Size, "L.DData"); + ptr_0002B4_doors_ddata = (unsigned __int16 *)malloc(blv.uDoors_ddata_Size);//, "L.DData"); memcpy(ptr_0002B4_doors_ddata, pData, blv.uDoors_ddata_Size); pData += blv.uDoors_ddata_Size; @@ -3690,7 +3689,7 @@ v3 = v37; } dword_6BE13C_uCurrentlyLoadedLocationID = v39; - pAllocator->FreeChunk(ptr_6A0D08); + free(ptr_6A0D08); ptr_6A0D08 = 0; _6A0D0C_txt_lod_loading = 0; TryLoadLevelFromLOD();
--- a/Items.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Items.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -6,7 +6,6 @@ #include "Items.h" #include "MapInfo.h" -#include "Allocator.h" #include "GUIWindow.h" #include "Events2D.h" #include "Chest.h" @@ -281,27 +280,27 @@ void ItemsTable::Release() { if ( pMonstersTXT_Raw ) - pAllocator->FreeChunk(pMonstersTXT_Raw); + free(pMonstersTXT_Raw); if ( pMonsterPlacementTXT_Raw ) - pAllocator->FreeChunk(pMonsterPlacementTXT_Raw); + free(pMonsterPlacementTXT_Raw); if ( pSkillDescTXT_Raw ) - pAllocator->FreeChunk(pSkillDescTXT_Raw); + free(pSkillDescTXT_Raw); if (pSpcItemsTXT_Raw ) - pAllocator->FreeChunk(pSpcItemsTXT_Raw); + free(pSpcItemsTXT_Raw); if ( pStdItemsTXT_Raw ) - pAllocator->FreeChunk(pStdItemsTXT_Raw); + free(pStdItemsTXT_Raw); if ( pRndItemsTXT_Raw ) - pAllocator->FreeChunk(pRndItemsTXT_Raw); + free(pRndItemsTXT_Raw); if ( pItemsTXT_Raw ) - pAllocator->FreeChunk(pItemsTXT_Raw); + free(pItemsTXT_Raw); if ( pHostileTXT_Raw ) - pAllocator->FreeChunk(pHostileTXT_Raw); + free(pHostileTXT_Raw); if ( pHistoryTXT_Raw ) - pAllocator->FreeChunk(pHistoryTXT_Raw); + free(pHistoryTXT_Raw); if ( pPotionsTXT_Raw ) - pAllocator->FreeChunk(pPotionsTXT_Raw); + free(pPotionsTXT_Raw); if ( pPotionNotesTXT_Raw ) - pAllocator->FreeChunk(pPotionNotesTXT_Raw); + free(pPotionNotesTXT_Raw); pSpcItemsTXT_Raw = NULL; pSkillDescTXT_Raw = NULL; pStdItemsTXT_Raw = NULL; @@ -1050,7 +1049,7 @@ if ( pRndItemsTXT_Raw ) { - pAllocator->FreeChunk(pRndItemsTXT_Raw); + free(pRndItemsTXT_Raw); pRndItemsTXT_Raw = NULL; } @@ -1285,7 +1284,7 @@ unsigned __int8 potion_value; if ( pPotionsTXT_Raw ) - pAllocator->FreeChunk(pPotionsTXT_Raw); + free(pPotionsTXT_Raw); pPotionsTXT_Raw = NULL; pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); test_string = strtok(pPotionsTXT_Raw,"\t\r\n"); @@ -1352,7 +1351,7 @@ } if ( pPotionsTXT_Raw ) { - pAllocator->FreeChunk(pPotionsTXT_Raw); + free(pPotionsTXT_Raw); pPotionsTXT_Raw = 0; } } @@ -1368,7 +1367,7 @@ unsigned __int8 potion_note; if ( pPotionNotesTXT_Raw ) - pAllocator->FreeChunk(pPotionNotesTXT_Raw); + free(pPotionNotesTXT_Raw); pPotionNotesTXT_Raw = NULL; pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); test_string = strtok(pPotionNotesTXT_Raw ,"\t\r\n"); @@ -1599,7 +1598,7 @@ v5 = this; if (!out_item) - out_item = (ItemGen *)pAllocator->AllocNamedChunk(out_item, sizeof(*out_item), "newItemGen"); + out_item = (ItemGen *)malloc(sizeof(ItemGen)); memset(out_item, 0, sizeof(*out_item));
--- a/Items.h Thu Sep 12 09:55:20 2013 +0200 +++ b/Items.h Thu Sep 12 09:58:07 2013 +0200 @@ -70,11 +70,19 @@ ITEM_REAGENT_PHILOSOPHERS_STONE = 219, ITEM_POTION_BOTTLE = 220, ITEM_POTION_CATALYST = 221, + ITEM_POTION_CURE_WOUNDS = 222, + ITEM_POTION_CURE_DISEASE = 225, + ITEM_POTION_AWAKEN = 227, + ITEM_POTION_HASTE = 228, ITEM_POTION_RECHARGE_ITEM = 233, ITEM_POTION_HARDEN_ITEM = 236, + ITEM_POTION_CURE_INSANITY = 239, + ITEM_POTION_MIGHT_BOOST = 240, ITEM_POTION_ACCURACY_BOOST = 245, ITEM_POTION_FLAMING_POTION = 246, ITEM_POTION_SWIFT_POTION = 250, + ITEM_POTION_BODY_RESISTANE = 261, + ITEM_POTION_STONE_TO_FLESH = 262, ITEM_POTION_SLAYING_POTION = 263, ITEM_POTION_REJUVENATION = 271, ITEM_SPELLBOOK_TORCHLIGHT = 400,//0x190
--- a/LOD.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/LOD.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -4,7 +4,6 @@ #include "LOD.h" #include "Render.h" -#include "Allocator.h" #include "PaletteManager.h" #include "Viewport.h" @@ -182,7 +181,7 @@ fread(pSpriteHeader, 1u, 0x20u, v3); strcpy(pSpriteHeader->pName, pContainer); Sizea = pSpriteHeader->uSpriteSize; - v7 = (LODSprite_stru0 *)pAllocator->AllocNamedChunk(v6->pSpriteLines, 8 * v6->uHeight, v6->pName); + v7 = (LODSprite_stru0 *)malloc(8 * v6->uHeight); v8 = 8 * pSpriteHeader->uHeight; pSpriteHeader->pSpriteLines = v7; fread(v7, 1u, v8, v4); @@ -190,19 +189,16 @@ v10 = pSpriteHeader->uDecompressedSize; if ( v10 ) { - pSpriteHeader->pDecompressedBytes = pAllocator->AllocNamedChunk( - pSpriteHeader->pDecompressedBytes, - v10, - pSpriteHeader->pName); - DstBufa = pAllocator->AllocNamedChunk(0, Sizea, pSpriteHeader->pName); + pSpriteHeader->pDecompressedBytes = malloc(v10); + DstBufa = malloc(Sizea); fread(DstBufa, 1u, Sizea, File); zlib::MemUnzip(v6->pDecompressedBytes, (unsigned int *)&v6->uDecompressedSize, DstBufa, v6->uSpriteSize); v6->uSpriteSize = *v9; - pAllocator->FreeChunk(DstBufa); + free(DstBufa); } else { - v11 = pAllocator->AllocNamedChunk(pSpriteHeader->pDecompressedBytes, Sizea, pSpriteHeader->pName); + v11 = malloc(Sizea); pSpriteHeader->pDecompressedBytes = v11; fread(v11, 1u, Sizea, File); } @@ -265,7 +261,7 @@ { if ( !pHardwareSprites ) { - pHardwareSprites = (Sprite *)pAllocator->AllocNamedChunk(0, 1500*sizeof(Sprite) , "hardSprites");//0xEA60u + pHardwareSprites = (Sprite *)malloc(1500*sizeof(Sprite));//0xEA60u for (i=0; i<1500;++i) { pHardwareSprites[i].pName=NULL; @@ -317,7 +313,7 @@ if ( pRenderer->pRenderD3D ) { - pHardwareSprites[uNumLoadedSprites].pName = (const char *)pAllocator->AllocNamedChunk(pHardwareSprites[uNumLoadedSprites].pName, 20, pContainerName); + pHardwareSprites[uNumLoadedSprites].pName = (const char *)malloc(20); strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID; pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); @@ -944,8 +940,8 @@ { this->pContainerName[0] = 0; this->uCurrentIndexDir = 0; - pAllocator->FreeChunk(pSubIndices); - pAllocator->FreeChunk(pRoot); + free(pSubIndices); + free(pRoot); pSubIndices = NULL; pRoot = NULL; fclose(pFile); @@ -991,7 +987,7 @@ uOffsetToSubIndex = 0; uNumSubDirs = 0; uLODDataSize = 0; - pAllocator->FreeChunk(pSubIndices); + free(pSubIndices); pSubIndices = NULL; } } @@ -1062,8 +1058,8 @@ v1 = this; if ( !(HIBYTE(this->word_1A) & 4) ) { - pAllocator->FreeChunk(this->pDecompressedBytes); - pAllocator->FreeChunk(v1->pSpriteLines); + free(this->pDecompressedBytes); + free(v1->pSpriteLines); } v1->word_1A = 0; v1->pDecompressedBytes = 0; @@ -1081,7 +1077,7 @@ void Sprite::Release() { if (pName) - pAllocator->FreeChunk((void *)pName); + free((void *)pName); pName = nullptr; if (pTextureSurface) @@ -1267,8 +1263,8 @@ v1 = this; if ( !(HIBYTE(this->word_1A) & 4) ) { - pAllocator->FreeChunk(pDecompressedBytes); - pAllocator->FreeChunk(pSpriteLines); + free(pDecompressedBytes); + free(pSpriteLines); } pDecompressedBytes = NULL; pSpriteLines = NULL; @@ -1693,8 +1689,8 @@ //----- (00461A11) -------------------------------------------------------- void LOD::File::FreeSubIndexAndIO() { - pAllocator->FreeChunk(pSubIndices); - pAllocator->FreeChunk(pIOBuffer);// delete [] pIOBuffer; + free(pSubIndices); + free(pIOBuffer);// delete [] pIOBuffer; pIOBuffer = nullptr; pSubIndices = nullptr; } @@ -1706,20 +1702,20 @@ if (pSubIndices) { MessageBoxA(0, "Attempt to reset a LOD subindex!", "MM6", MB_ICONEXCLAMATION); - pAllocator->FreeChunk(pSubIndices); + free(pSubIndices); pSubIndices = nullptr; } - pSubIndices =(LOD::Directory *)pAllocator->AllocNamedChunk( pSubIndices, 32 * uNumSubIndices,"LODsub"); + pSubIndices =(LOD::Directory *)malloc(32 * uNumSubIndices); if (pIOBuffer) { MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION); - pAllocator->FreeChunk(pIOBuffer); + free(pIOBuffer); pIOBuffer = NULL; uIOBufferSize = 0; } if ( uBufferSize ) { - pIOBuffer = (unsigned __int8 *)pAllocator->AllocNamedChunk(pIOBuffer, uBufferSize, "LODio"); + pIOBuffer = (unsigned __int8 *)malloc(uBufferSize); uIOBufferSize = uBufferSize; } } @@ -1746,7 +1742,7 @@ uOffsetToSubIndex =curr_index->uOfsetFromSubindicesStart ; uNumSubDirs =curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28); fseek( pFile, uOffsetToSubIndex, SEEK_SET); - pSubIndices = (LOD::Directory *)pAllocator->AllocNamedChunk(pSubIndices, sizeof(LOD::Directory)*(uNumSubDirs + 5), "LOD Index"); + pSubIndices = (LOD::Directory *)malloc(sizeof(LOD::Directory)*(uNumSubDirs + 5)); if ( pSubIndices) fread( pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); @@ -1773,7 +1769,7 @@ { strcpy(pLODName, pFilename); fread(&header, sizeof(LOD::FileHeader), 1u, pFile); - pRoot = (LOD::Directory *)pAllocator->AllocNamedChunk(pRoot, 160, "LOD CArray"); + pRoot = (LOD::Directory *)malloc(160); if ( pRoot ) { fread(pRoot, sizeof(LOD::Directory), header.uNumIndices, pFile); @@ -1800,7 +1796,7 @@ if ( this->isFileOpened ) { fclose(this->pFile); - pAllocator->FreeChunk(v1->pSubIndices); + free(v1->pSubIndices); } } @@ -2091,20 +2087,20 @@ if ( a3 ) v6 = malloc(DstBuf.uDecompressedSize+1); else - v6 = pAllocator->AllocNamedChunk(0, DstBuf.uDecompressedSize+1, DstBuf.pName); + v6 = malloc(DstBuf.uDecompressedSize+1); v7 = v6; - v8 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName); + v8 = malloc(DstBuf.uTextureSize+1); fread(v8, 1u, Argsa, File); zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize); DstBuf.uTextureSize = DstBuf.uDecompressedSize; - pAllocator->FreeChunk(v8); + free(v8); } else { if ( a3 ) v9 = malloc(DstBuf.uTextureSize+1); else - v9 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize+1, DstBuf.pName); + v9 = malloc(DstBuf.uTextureSize+1); v7 = v9; fread(v9, 1u, Argsa, v5); } @@ -2547,7 +2543,7 @@ void *v17; // eax@27 unsigned int v18; // ST28_4@27 void *v19; // ST3C_4@27 - Allocator *v20; // ebx@29 + //Allocator *v20; // ebx@29 void *v21; // eax@29 size_t v22; // ST2C_4@29 const void *v23; // ecx@29 @@ -2632,8 +2628,7 @@ pOutTex = (Texture *)v8->uTextureSize; if ( !v8->uDecompressedSize || dword_011BA4 ) { - v20 = pAllocator; - v32 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v15, v8->pName); + v32 = malloc(v15); v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v32; fread(v32, 1u, (size_t)pOutTex, pFile); } @@ -2649,11 +2644,10 @@ free(v19); if ( bUseLoResSprites && v8->pBits & 2 ) { - v20 = pAllocator; pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2) + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4) + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6)); - v21 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, (unsigned int)pOutTex, v8->pName); + v21 = malloc((unsigned int)pOutTex); v22 = (size_t)pOutTex; v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight]; v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v21; @@ -2675,19 +2669,18 @@ else { v29 = *v16; - v20 = pAllocator; - v30 = pAllocator->AllocNamedChunk(v8->pLevelOfDetail0_prolly_alpha_mask, v29, v8->pName); + v30 = malloc(v29); v31 = v8->uDecompressedSize; v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)v30; memcpy(v30, pContainer, v31); } free((void *)pContainer); } - pAllocator->FreeChunk(v8->pPalette16); - pAllocator->FreeChunk(v8->pPalette24); + free(v8->pPalette16); + free(v8->pPalette24); if ( eTextureType == TEXTURE_24BIT_PALETTE ) { - v33 = pAllocator->AllocNamedChunk(v8->pPalette24, 0x300u, v8->pName); + v33 = malloc(0x300); v8->pPalette24 = (unsigned __int8 *)v33; fread(v33, 1u, 0x300u, pFile); } @@ -2696,7 +2689,7 @@ v8->pPalette24 = 0; if ( eTextureType == TEXTURE_16BIT_PALETTE ) { - v8->pPalette16 = (unsigned __int16 *)pAllocator->AllocNamedChunk(v8->pPalette16, 0x200u, v8->pName); + v8->pPalette16 = (unsigned __int16 *)malloc(0x200); v38 = 0; do { @@ -2933,7 +2926,7 @@ fseek(v0, 0, 2); v2 = ftell(v1); rewind(v1); - ptr_6A0D08 = pAllocator->AllocNamedChunk(ptr_6A0D08, v2, "LevelLod"); + ptr_6A0D08 = malloc(v2); fread(ptr_6A0D08, v2, 1u, v1); fseek(v1, v2 - 6, 0); DstBuf = 0; @@ -2947,7 +2940,7 @@ //----- (0046080D) -------------------------------------------------------- void sub_46080D() { - pAllocator->FreeChunk(ptr_6A0D08); + free(ptr_6A0D08); ptr_6A0D08 = 0; _6A0D0C_txt_lod_loading = 0; }
--- a/Log.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Log.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -26,8 +26,8 @@ va_end(args); DWORD w; - WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); - WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr); + WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); + WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); } //----- (004BE386) -------------------------------------------------------- void __fastcall log_error(const char *pMessage)
--- a/Monsters.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Monsters.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -8,7 +8,6 @@ #include "Monsters.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "LOD.h" #include "texts.h" #include "mm7_data.h" @@ -385,7 +384,7 @@ v4 = Argsa; } v2->uNumMonsters = v4; - v5 = pAllocator->AllocNamedChunk(v2->pMonsters, 152 * v4, "Mon Race"); + v5 = malloc(152 * v4); v2->pMonsters = (MonsterDesc *)v5; if ( !v5 ) Error("MonsterRaceListStruct::load - Out of Memory!"); @@ -468,7 +467,7 @@ Assert(uNumMonsters); Assert(!num_mm8_monsters); - pMonsters = (MonsterDesc *)pAllocator->AllocNamedChunk(pMonsters, sizeof(MonsterDesc) * uNumMonsters, "Mon Race"); + pMonsters = (MonsterDesc *)malloc(sizeof(MonsterDesc) * uNumMonsters); memcpy(pMonsters, (char *)data_mm7 + 4, num_mm7_monsters * sizeof(MonsterDesc)); for (uint i = 0; i < num_mm6_monsters; ++i) { @@ -582,7 +581,7 @@ FrameTableTxtLine parsed_field; if ( pMonstersTXT_Raw ) - pAllocator->FreeChunk(pMonstersTXT_Raw); + free(pMonstersTXT_Raw); pMonstersTXT_Raw = NULL; pMonstersTXT_Raw = (char *)pEvents_LOD->LoadRaw("monsters.txt", 0); strtok(pMonstersTXT_Raw, "\r");
--- a/NPC.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/NPC.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -2,7 +2,6 @@ #define _CRT_SECURE_NO_WARNINGS #endif -#include "Allocator.h" #include "texts.h" #include "LOD.h" #include "Autonotes.h" @@ -248,7 +247,7 @@ int decode_step; if (pNPCTextTXT_Raw) - pAllocator->FreeChunk(pNPCTextTXT_Raw); + free(pNPCTextTXT_Raw); pNPCTextTXT_Raw =NULL; pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); strtok(pNPCTextTXT_Raw, "\r"); @@ -286,7 +285,7 @@ } if (pNPCTopicTXT_Raw) - pAllocator->FreeChunk(pNPCTopicTXT_Raw); + free(pNPCTopicTXT_Raw); pNPCTopicTXT_Raw =NULL; pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); strtok(pNPCTopicTXT_Raw, "\r"); @@ -324,7 +323,7 @@ } if (pNPCDistTXT_Raw) - pAllocator->FreeChunk(pNPCDistTXT_Raw); + free(pNPCDistTXT_Raw); pNPCDistTXT_Raw = NULL; pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); strtok(pNPCDistTXT_Raw, "\r"); @@ -381,7 +380,7 @@ if (pNPCDistTXT_Raw) { - pAllocator->FreeChunk(pNPCDistTXT_Raw); + free(pNPCDistTXT_Raw); pNPCDistTXT_Raw = NULL; } } @@ -716,23 +715,23 @@ //----- (00477266) -------------------------------------------------------- void NPCStats::Release() { - pAllocator->FreeChunk(pNPCTopicTXT_Raw); + free(pNPCTopicTXT_Raw); pNPCTopicTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCTextTXT_Raw); + free(pNPCTextTXT_Raw); pNPCTextTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCNewsTXT_Raw); + free(pNPCNewsTXT_Raw); pNPCNewsTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCProfTXT_Raw); + free(pNPCProfTXT_Raw); pNPCProfTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCNamesTXT_Raw); + free(pNPCNamesTXT_Raw); pNPCNamesTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCDataTXT_Raw); + free(pNPCDataTXT_Raw); pNPCDataTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCDistTXT_Raw); + free(pNPCDistTXT_Raw); pNPCDistTXT_Raw = NULL; - pAllocator->FreeChunk(pNPCGreetTXT_Raw); + free(pNPCGreetTXT_Raw); pNPCGreetTXT_Raw = NULL; - pAllocator->FreeChunk(pNCPGroupTXT_Raw); + free(pNCPGroupTXT_Raw); pNCPGroupTXT_Raw = NULL; } @@ -936,7 +935,7 @@ int decode_step; if ( pAwardsTXT_Raw ) - pAllocator->FreeChunk(pAwardsTXT_Raw); + free(pAwardsTXT_Raw); pAwardsTXT_Raw = NULL; pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); strtok(pAwardsTXT_Raw, "\r"); @@ -990,7 +989,7 @@ int decode_step; if ( pScrollsTXT_Raw ) - pAllocator->FreeChunk(pScrollsTXT_Raw); + free(pScrollsTXT_Raw); pScrollsTXT_Raw = NULL; pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); strtok(pScrollsTXT_Raw, "\r"); @@ -1039,7 +1038,7 @@ int decode_step; if ( pMerchantsTXT_Raw ) - pAllocator->FreeChunk(pMerchantsTXT_Raw); + free(pMerchantsTXT_Raw); pMerchantsTXT_Raw = NULL; pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); strtok(pMerchantsTXT_Raw, "\r"); @@ -1103,7 +1102,7 @@ int decode_step; if ( pTransitionsTXT_Raw ) - pAllocator->FreeChunk(pTransitionsTXT_Raw); + free(pTransitionsTXT_Raw); pTransitionsTXT_Raw = NULL; pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); strtok(pTransitionsTXT_Raw, "\r"); @@ -1153,7 +1152,7 @@ int decode_step; if ( pAutonoteTXT_Raw ) - pAllocator->FreeChunk(pAutonoteTXT_Raw); + free(pAutonoteTXT_Raw); pAutonoteTXT_Raw = 0; pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); strtok(pAutonoteTXT_Raw, "\r"); @@ -1238,7 +1237,7 @@ int decode_step; if ( pQuestsTXT_Raw ) - pAllocator->FreeChunk(pQuestsTXT_Raw); + free(pQuestsTXT_Raw); pQuestsTXT_Raw = NULL; pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); strtok(pQuestsTXT_Raw, "\r"); @@ -1377,7 +1376,7 @@ } else { - sub_4B3FE5(pEventNumber); + _4B3FE5_training_dialogue(pEventNumber); } goto _return; } @@ -1648,7 +1647,7 @@ else { for ( i = 0; i < uNumDialogueNPCPortraits; ++i ) - dword_5913F4[i]->Release(); + HouseNPCPortraitsButtonsList[i]->Release(); } pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); pBtn_ExitCancel = pDialogueWindow->CreateButton( 471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0,
--- a/ObjectList.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/ObjectList.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -2,7 +2,6 @@ #include "mm7_data.h" #include "Sprites.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "ErrorHandling.h" //----- (0042EB42) -------------------------------------------------------- @@ -67,7 +66,7 @@ Assert(uNumObjects); Assert(!num_mm8_objs); - pObjects = (ObjectDesc *)pAllocator->AllocNamedChunk(pObjects, uNumObjects * sizeof(ObjectDesc), "Obj Descrip"); + pObjects = (ObjectDesc *)malloc(uNumObjects * sizeof(ObjectDesc)); memcpy(pObjects, (char *)data_mm7 + 4, num_mm7_objs * sizeof(ObjectDesc)); for (uint i = 0; i < num_mm6_objs; ++i) { @@ -142,7 +141,7 @@ int Argsb; // [sp+470h] [bp+8h]@15 v2 = this; - pAllocator->FreeChunk(this->pObjects); + free(this->pObjects); v3 = 0; v2->pObjects = 0; v2->uNumObjects = 0; @@ -167,7 +166,7 @@ v3 = 0; } v2->uNumObjects = v5; - v6 = pAllocator->AllocNamedChunk(v2->pObjects, 56 * v5, "Obj Descrip"); + v6 = malloc(56 * v5); v2->pObjects = (ObjectDesc *)v6; if ( v6 == (void *)v3 ) Error("ObjectDescriptionList::load - Out of Memory!");
--- a/Outdoor.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Outdoor.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -11,7 +11,6 @@ #include "Party.h" #include "SpriteObject.h" #include "LOD.h" -#include "Allocator.h" #include "PaletteManager.h" #include "GUIProgressBar.h" #include "AudioPlayer.h" @@ -116,10 +115,7 @@ if (bRedraw) { - Software_ResetNewEdges(); sub_487DA9(); - ptr_80C97C_Surfs = pSurfs; - ptr_80C978_Edges = pEdges; } if ( pParty->uCurrentMinute != pOutdoor->uLastSunlightUpdateMinute ) pOutdoor->UpdateSunlightVectors(); @@ -333,14 +329,6 @@ return result; } -//----- (0048901B) -------------------------------------------------------- -bool OutdoorLocation::Release2() -{ - Release(); - pOutdoorCamera->ReleaseSoftwareDrawBuffers(); - return true; -} - char foot_travel_destinations[15][4] = @@ -813,22 +801,22 @@ { if (pHeightmap) { - pAllocator->FreeChunk(this->pHeightmap); + free(this->pHeightmap); pHeightmap = nullptr; } if (pTilemap) { - pAllocator->FreeChunk(pTilemap); + free(pTilemap); pTilemap = nullptr; } if (pAttributemap) { - pAllocator->FreeChunk(pAttributemap); + free(pAttributemap); pAttributemap = nullptr; } if (pDmap) { - pAllocator->FreeChunk(pDmap); + free(pDmap); pDmap = nullptr; } @@ -1134,12 +1122,11 @@ //----- (0047CD44) -------------------------------------------------------- bool OutdoorLocationTerrain::Initialize() { - - pHeightmap= (unsigned __int8 *)pAllocator->AllocNamedChunk(pHeightmap, 0x4000u, "HMAP");//height map - pTilemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pTilemap, 0x4000u, "TMAP");//tile map - pAttributemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pAttributemap, 0x4000u, "AMAP");//êàðòà àòðèáóòîâ - pDmap=(struct DMap *)pAllocator->AllocNamedChunk(pDmap, 0x8000u, "DMAP"); - if ( pHeightmap && pTilemap && pAttributemap && pDmap ) + pHeightmap = (unsigned __int8 *)malloc(0x4000u);//height map + pTilemap = (unsigned __int8 *)malloc(0x4000u);//tile map + pAttributemap = (unsigned __int8 *)malloc(0x4000u);//êàðòà àòðèáóòîâ + pDmap = (struct DMap *)malloc(0x8000u); + if (pHeightmap && pTilemap && pAttributemap && pDmap ) return true; else return false; @@ -1168,28 +1155,28 @@ v1->pTileTypes[3].tileset = Tileset_RoadGrassCobble; v1->LoadTileGroupIds(); v1->LoadRoadTileset(); - pAllocator->FreeChunk(v1->pBModels); - pAllocator->FreeChunk(v1->pSpawnPoints); + free(v1->pBModels); + free(v1->pSpawnPoints); v1->pBModels = 0; v1->pSpawnPoints = 0; v1->pTerrain.Initialize(); v1->pTerrain.ZeroLandscape(); v1->pTerrain.FillDMap(0, 0, 128, 128); - pAllocator->FreeChunk(v1->pCmap); + free(v1->pCmap); v1->pCmap = 0; - v2 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); + v2 = malloc(0x8000u); v3 = v1->pOMAP; v1->pCmap = v2; - pAllocator->FreeChunk(v3); + free(v3); v1->pOMAP = 0; - v4 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); + v4 = malloc(0x10000u); v1->pOMAP = (unsigned int *)v4; memset(v4, 0, 0x10000u); v5 = v1->pFaceIDLIST; v1->numFaceIDListElems = 0; - pAllocator->FreeChunk(v5); + free(v5); v1->pFaceIDLIST = 0; - v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST"); + v6 = malloc(2); v1->pFaceIDLIST = (unsigned __int16 *)v6; *(short *)v6 = 0; strcpy(v1->pSkyTextureName, pDefaultSkyTexture.data()); @@ -1229,14 +1216,14 @@ for (uint i = 0; i < uNumBModels; ++i) pBModels[i].Release(); - pAllocator->FreeChunk(pBModels); + free(pBModels); pBModels = nullptr; uNumBModels = 0; } if (pSpawnPoints) { - pAllocator->FreeChunk(pSpawnPoints); + free(pSpawnPoints); pSpawnPoints = nullptr; } uNumSpawnPoints = 0; @@ -1245,22 +1232,22 @@ if (pCmap) { - pAllocator->FreeChunk(pCmap); + free(pCmap); pCmap = nullptr; } if (pOMAP) { - pAllocator->FreeChunk(pOMAP); + free(pOMAP); pOMAP = nullptr; } if (pFaceIDLIST) { - pAllocator->FreeChunk(pFaceIDLIST); + free(pFaceIDLIST); pFaceIDLIST = nullptr; } if (pTerrainNormals) { - pAllocator->FreeChunk(pTerrainNormals); + free(pTerrainNormals); pTerrainNormals = nullptr; } } @@ -1479,23 +1466,23 @@ fseek((FILE *)v7, v121, 0); fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7); pTerrain._47C80A(0, 0, 128, 128); - pAllocator->FreeChunk(ptr_D4); + free(ptr_D4); ptr_D4 = 0; - v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); + v9 = malloc(0, 0x8000u, "CMAP"); v108 = (int)pOMAP; ptr_D4 = v9; - pAllocator->FreeChunk((void *)v108); + free((void *)v108); pOMAP = 0; - v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); + v10 = malloc(0, 0x10000u, "OMAP"); v108 = 0; pOMAP = (unsigned int *)v10; fseek((FILE *)v7, v136, v108); fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7); fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7); fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7); - pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); + pTerrainNormals = (Vec3_float_ *)malloc(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7); - v11 = pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); + v11 = malloc(pBModels, 188 * uNumBModels, "BDdata"); v108 = 0; pBModels = (BSPModel *)v11; fseek((FILE *)v7, v122, v108); @@ -1516,13 +1503,13 @@ sprintfex(FileName, "%s", v108); v13 = pBModels; v138 = 0; - pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, + pBModels[v12].pVertices.pVertices = (Vec3_int_ *)malloc(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices, FileName); - pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, + pBModels[v12].pFaces = (ODMFace *)malloc(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces, FileName); - pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pBModels[v12].pFacesOrdering, + pBModels[v12].pFacesOrdering = (unsigned __int16 *)malloc(pBModels[v12].pFacesOrdering, 2 * pBModels[v12].uNumFaces, FileName); - v14 = pAllocator->AllocNamedChunk(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); + v14 = malloc(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName); v15 = pBModels; v108 = (int)File; v15[v12].pNodes = (BSPNode *)v14; @@ -1652,10 +1639,10 @@ fread(pChests, 0x14CCu, uNumChests, (FILE *)v22); fseek((FILE *)v22, v128, 0); fread(&field_DC, 4u, 1u, (FILE *)v22); - pAllocator->FreeChunk(pFaceIDLIST); + free(pFaceIDLIST); v32 = field_DC; pFaceIDLIST = 0; - v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST"); + v33 = malloc(0, 2 * v32, "IDLIST"); v108 = (int)v22; pFaceIDLIST = (unsigned __int16 *)v33; fread(v33, 2u, field_DC, (FILE *)v108); @@ -1663,7 +1650,7 @@ fread(pOMAP, 4u, 0x4000u, (FILE *)v22); fseek((FILE *)v22, v130, 0); fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22); - pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); + pSpawnPoints = (SpawnPointMM7 *)malloc(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn"); fseek((FILE *)v22, v131, 0); fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22); fseek((FILE *)v22, v132, 0); @@ -1803,10 +1790,10 @@ //v108 = (int)ptr_D4; if (pCmap) { - pAllocator->FreeChunk(pCmap); + free(pCmap); pCmap = nullptr; } - pCmap = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP"); + pCmap = malloc(0x8000); pTerrain.FillDMap(0, 0, 128, 128); pGameLoadingUI_ProgressBar->Progress(); @@ -1820,7 +1807,7 @@ //v43 = (char *)v43 + 65536; //pFilename = (char *)(12 * uNumTerrainNormals); - pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm"); + pTerrainNormals = (Vec3_float_ *)malloc(sizeof(Vec3_float_) * uNumTerrainNormals); memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals); pSrc += 12 * uNumTerrainNormals; //v44 = (char *)v43 + (int)pFilename; @@ -1832,10 +1819,10 @@ //v107 = 188 * v45; //v106 = (char *)pBModels; - //v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata"); + //v46 = (BSPModel *)malloc(v106, 188 * v45, "BDdata"); //v47 = uNumBModels; memcpy(&uNumBModels, pSrc, 4); - pBModels = (BSPModel *)pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata"); + pBModels = (BSPModel *)malloc(188 * uNumBModels); //pFilename = (char *)(188 * v47); memcpy(pBModels, pSrc + 4, 188 * uNumBModels); pSrc += 4 + 188 * uNumBModels; @@ -1864,7 +1851,7 @@ //v106 = (char *)v50->pVertices.pVertices; assert(sizeof(Vec3_int_) == 12); uint verticesSize = model->pVertices.uNumVertices * sizeof(Vec3_int_); - model->pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(model->pVertices.pVertices, verticesSize, ""); + model->pVertices.pVertices = (Vec3_int_ *)malloc(verticesSize); memcpy(model->pVertices.pVertices, pSrc, verticesSize); pSrc += verticesSize; //v51 = &pBModels[v48]; @@ -1873,7 +1860,7 @@ //v106 = (char *)v51->pFaces; assert(sizeof(ODMFace) == 308); uint facesSize = model->uNumFaces * sizeof(ODMFace); - model->pFaces = (ODMFace *)pAllocator->AllocNamedChunk(model->pFaces, facesSize, ""); + model->pFaces = (ODMFace *)malloc(facesSize); memcpy(model->pFaces, pSrc, facesSize); pSrc += facesSize; //v52 = &pBModels[v48]; @@ -1881,7 +1868,7 @@ //v107 = 2 * v52->uNumFaces; //v106 = (char *)v52->pFacesOrdering; uint facesOrderingSize = model->uNumFaces * sizeof(short); - model->pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(model->pFacesOrdering, facesOrderingSize, ""); + model->pFacesOrdering = (unsigned __int16 *)malloc(facesOrderingSize); memcpy(model->pFacesOrdering, pSrc, facesOrderingSize); pSrc += facesOrderingSize; //v53 = &pBModels[v48]; @@ -1890,7 +1877,7 @@ //v106 = (char *)v53->pNodes; assert(sizeof(BSPNode) == 8); uint nodesSize = model->uNumNodes * sizeof(BSPNode); - model->pNodes = (BSPNode *)pAllocator->AllocNamedChunk(model->pNodes, nodesSize, ""); + model->pNodes = (BSPNode *)malloc(nodesSize); memcpy(model->pNodes, pSrc, nodesSize); pSrc += nodesSize; //v54 = &pBModels[v48]; @@ -2013,14 +2000,14 @@ //v108 = (int)pFaceIDLIST; if (pFaceIDLIST) { - pAllocator->FreeChunk(pFaceIDLIST); + free(pFaceIDLIST); pFaceIDLIST = nullptr; } //v66 = field_DC; //pFaceIDLIST = 0; - //v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST"); + //v67 = malloc(0, 2 * v66, "IDLIST"); uint faceIDListSize = 2 * numFaceIDListElems; - pFaceIDLIST = (unsigned short *)pAllocator->AllocNamedChunk(0, faceIDListSize, "IDLIST"); + pFaceIDLIST = (unsigned short *)malloc(faceIDListSize); //v68 = field_DC; //pFaceIDLIST = (unsigned __int16 *)v67; //pFilename = (char *)(2 * v68); @@ -2031,15 +2018,15 @@ pGameLoadingUI_ProgressBar->Progress(); //v108 = (int)pOMAP; - //pAllocator->FreeChunk((void *)v108); + //free((void *)v108); //pOMAP = 0; if (pOMAP) { - pAllocator->FreeChunk(pOMAP); + free(pOMAP); pOMAP = nullptr; } - //v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP"); - pOMAP = (unsigned int *)pAllocator->AllocNamedChunk(0, 0x10000, "OMAP"); + //v69 = malloc(0, 0x10000u, "OMAP"); + pOMAP = (unsigned int *)malloc(0x10000); //v108 = 65536; //pOMAP = (unsigned int *)v69; memcpy(pOMAP, pSrc, 65536); @@ -2057,7 +2044,7 @@ //v106 = (char *)pSpawnPoints; assert(sizeof(SpawnPointMM7) == 24); uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7); - pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, spawnPointsSize, "Spawn"); + pSpawnPoints = (SpawnPointMM7 *)malloc(spawnPointsSize); //v72 = uNumSpawnPoints; //pSpawnPoints = v71; memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize);
--- a/Outdoor.h Thu Sep 12 09:55:20 2013 +0200 +++ b/Outdoor.h Thu Sep 12 09:58:07 2013 +0200 @@ -156,7 +156,7 @@ unsigned int GetTileTexture(int sX, int sZ); int GetHeightOnTerrain(int sX, int sZ); bool Initialize(const char *pFilename, int File, size_t uRespawnInterval, int thisa); - bool Release2(); + //bool Release2(); bool GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5); void MessWithLUN(); void UpdateSunlightVectors();
--- a/OutdoorCamera.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/OutdoorCamera.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -6,7 +6,6 @@ #include "Viewport.h" #include "Math.h" #include "mm7_data.h" -#include "Allocator.h" //----- (00481E55) -------------------------------------------------------- void OutdoorCamera::Project(unsigned int uNumVertices) @@ -71,33 +70,4 @@ camera_rotation_y_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationY); camera_rotation_x_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationX); camera_rotation_x_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationX); -} -//----- (00486A28) -------------------------------------------------------- -void OutdoorCamera::AllocSoftwareDrawBuffers() -{ - if ( !this || !pSpans ) - { - ReleaseSoftwareDrawBuffers(); - pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS"); - pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES"); - pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS"); - pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES"); - memset(pSpans, 0, 0x493E0u); - memset(pEdges, 0, 0x4C2C0u); - memset(pSurfs, 0, 0x11940u); - memset(pNewEdges, 0, 0x6180u); - } -} - -//----- (00486AFC) -------------------------------------------------------- -void OutdoorCamera::ReleaseSoftwareDrawBuffers() -{ - pAllocator->FreeChunk(pSpans); - pAllocator->FreeChunk(pEdges); - pAllocator->FreeChunk(pSurfs); - pAllocator->FreeChunk(pNewEdges); - pSpans = 0; - pEdges = 0; - pSurfs = 0; - pNewEdges = 0; } \ No newline at end of file
--- a/OutdoorCamera.h Thu Sep 12 09:55:20 2013 +0200 +++ b/OutdoorCamera.h Thu Sep 12 09:58:07 2013 +0200 @@ -23,8 +23,8 @@ void _485F64(); void RotationToInts(); - void AllocSoftwareDrawBuffers(); - void ReleaseSoftwareDrawBuffers(); + //void AllocSoftwareDrawBuffers(); + //void ReleaseSoftwareDrawBuffers(); static void Project(unsigned int uNumVertices); //static bool _487355();
--- a/Overlays.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Overlays.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -7,7 +7,6 @@ #include "Overlays.h" #include "Sprites.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "IconFrameTable.h" #include "Time.h" #include "Party.h" @@ -193,7 +192,7 @@ Assert(uNumOverlays); Assert(!num_mm8_overlays); - pOverlays = (OverlayDesc *)pAllocator->AllocNamedChunk(pOverlays, uNumOverlays * sizeof(OverlayDesc), "Ovl Des."); + pOverlays = (OverlayDesc *)malloc(uNumOverlays * sizeof(OverlayDesc)); memcpy(pOverlays, (char *)data_mm7 + 4, num_mm7_overlays * sizeof(OverlayDesc)); memcpy(pOverlays + num_mm7_overlays, (char *)data_mm6 + 4, num_mm6_overlays * sizeof(OverlayDesc)); memcpy(pOverlays + num_mm6_overlays + num_mm7_overlays, (char *)data_mm8 + 4, num_mm8_overlays * sizeof(OverlayDesc)); @@ -223,7 +222,7 @@ unsigned int Argsa; // [sp+308h] [bp+8h]@3 v2 = this; - pAllocator->FreeChunk(this->pOverlays); + free(this->pOverlays); v3 = 0; v2->pOverlays = 0; v2->uNumOverlays = 0; @@ -249,7 +248,7 @@ } v6 = v2->pOverlays; v2->uNumOverlays = v5; - v7 = pAllocator->AllocNamedChunk(v6, 8 * v5, "Ovl Des."); + v7 = malloc(8 * v5); v2->pOverlays = (OverlayDesc *)v7; if ( v7 == (void *)v3 ) Error("OverlayDescriptionList::load - Out of Memory!");
--- a/Render.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Render.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -26,7 +26,6 @@ #include "ObjectList.h" #include "SpriteObject.h" #include "DecorationList.h" -#include "Allocator.h" #include "OSInfo.h" #include "Actor.h" #include "Log.h" @@ -2018,7 +2017,7 @@ Render *v1; // esi@1 v1 = this; - pAllocator->FreeChunk(this->pDefaultZBuffer); + free(this->pDefaultZBuffer); v1->pD3DBitmaps.Release(); v1->pD3DSprites.Release(); Release(); @@ -2318,7 +2317,7 @@ fwrite(&header2.pitch, 2u, 1u, v6); fwrite(&header2.palette_info, 2u, 1u, v6); fwrite(v15, 0x3Au, 1u, v6); - ptr = pAllocator->AllocNamedChunk(0, 3 * var38 + 6, 0); + ptr = malloc(3 * var38 + 6); if ( v29 > 0 ) { v7 = v30; @@ -2391,7 +2390,7 @@ pRenderer->EndScene(); } - pAllocator->FreeChunk(ptr); + free(ptr); fclose(v6); } } @@ -2515,7 +2514,7 @@ fwrite(&v39, 2u, 1u, v7); fwrite(&v40, 2u, 1u, v7); fwrite(&v16, 0x3Au, 1u, v7); - ptr = pAllocator->AllocNamedChunk(0, 3 * v25 + 6, 0); + ptr = malloc(3 * v25 + 6); if ( (signed int)a1 > 0 ) { v8 = v43; @@ -2587,7 +2586,7 @@ { pRenderer->EndScene(); } - pAllocator->FreeChunk(ptr); + free(ptr); fclose(v7); } } @@ -2682,7 +2681,7 @@ memcpy(v8, &v18, 0x3Au); v9 = (char *)v8 + 58; - lineRGB = (char*)pAllocator->AllocNamedChunk(0, 3 * (wight + 2), 0); + lineRGB = (char*)malloc(3 * (wight + 2)); if ( heidth > 0 ) { v10 = pitch; @@ -2743,7 +2742,7 @@ v10 = pitch; } } - pAllocator->FreeChunk(lineRGB); + free(lineRGB); *(int *)packed_size = (char *)v9 - data_buff; } @@ -2814,7 +2813,7 @@ fwrite(&header2.pitch, 2u, 1u, v7); fwrite(&header2.palette_info, 2u, 1u, v7); fwrite(v14, 0x3Au, 1u, v7); - ptr = pAllocator->AllocNamedChunk(0, 3 * a4 + 6, 0); + ptr = malloc(3 * a4 + 6); if ( a5 > 0 ) { v8 = v24; @@ -2877,7 +2876,7 @@ v8 = v24; } } - pAllocator->FreeChunk(ptr); + free(ptr); result = (FILE *)fclose(v7); } return result; @@ -2982,7 +2981,7 @@ if (!pDefaultZBuffer) { pDefaultZBuffer = pActiveZBuffer = nullptr; - pDefaultZBuffer = pActiveZBuffer = (int *)pAllocator->AllocNamedChunk(0, 0x12C000, "Z Buf."); + pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) } } @@ -3335,11 +3334,10 @@ } bWindowMode = 0; pParty->uFlags |= 2u; - LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; + LODWORD(flt_6BE3A0) = 0x3F0CCCCDu; __debugbreak(); // replace with actual float pViewport->_4C02F8(36044); return v15 != 0; } -// 6BE3A0: using guessed type float flt_6BE3A0; //----- (004A05F3) -------------------------------------------------------- bool Render::SwitchToWindow(HWND hWnd) @@ -6453,7 +6451,7 @@ Error("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); //v10 = *pOutSurface; //v11 = 0; - if ( bMipMaps ) + if (bMipMaps) { Dst._450DDE(); //v20 = 0; @@ -6472,7 +6470,7 @@ if ( LockSurface_DDraw4(pNextSurf, &desc, DDLOCK_WAIT | DDLOCK_WRITEONLY) ) { - Dst.sub_451007_scale_image_bicubic( + /*Dst.sub_451007_scale_image_bicubic( pHWLTexture->pPixels, pHWLTexture->uWidth, pHWLTexture->uHeight, @@ -6482,7 +6480,7 @@ desc.dwHeight, desc.lPitch >> 1, 0, - 0); + 0);*/ ErrD3D(pNextSurf->Unlock(0)); //bMipMaps = 0x4D86ACu; } @@ -8472,7 +8470,7 @@ { InvalidateRect(0, 0, 0); MoveWindow(hWnd, uWindowX, uWindowY, uWindowWidth, uWindowHeight, 0); - ShowWindow(hWnd, 1); + ShowWindow(hWnd, SW_SHOWNORMAL); } pMouse->bActive = 1; if ( pVideoPlayer->AnyMovieLoaded() ) @@ -8494,11 +8492,11 @@ //----- (004524D8) -------------------------------------------------------- HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) { - int v11; // eax@13 - int v12; // ecx@13 + //int v11; // eax@13 + //int v12; // ecx@13 void *v13; // eax@13 - unsigned __int8 v14; // zf@13 - unsigned __int8 v15; // sf@13 + //unsigned __int8 v14; // zf@13 + //unsigned __int8 v15; // sf@13 int v16; // esi@14 int v17; // ecx@16 int v18; // esi@16 @@ -8569,18 +8567,14 @@ else fread(pTex->pPixels, 2, pTex->uWidth * pTex->uHeight, pFile); - if ( field_61A94_scale_hwls_to_half ) //is it even possible to ever get here? field_61A94_scale_hwls_to_half is only set to zero - { - v11 = pTex->uHeight / 2; - v12 = pTex->uWidth / 2; - pTex->uHeight = v11; - pTex->uWidth = v12; - v13 = new unsigned __int16[v12 * v11]; + if ( scale_hwls_to_half ) + { + pTex->uHeight /= 2; + pTex->uWidth /= 2; + v13 = new unsigned __int16[pTex->uWidth * pTex->uHeight]; v28 = 0; - v14 = pTex->uHeight == 0; - v15 = (pTex->uHeight & 0x80000000u) != 0; v26 = (unsigned __int16 *)v13; - if ( !(v15 | v14) ) + if ( pTex->uHeight > 0 ) { v16 = pTex->uWidth; v27 = 1; @@ -8600,7 +8594,8 @@ LOWORD(v20) = *(unsigned short *)(v21 + 2); LOWORD(v21) = *(unsigned short *)v21; v23 = pDestb++ + v18; - v26[v23] = sub_452442(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); + extern unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); + v26[v23] = _452442_color_cvt(*(unsigned short *)v22, *(unsigned short *)(v22 + 2), v21, v20); v16 = pTex->uWidth; } while (pDestb < pTex->uWidth); @@ -8614,13 +8609,6 @@ pTex->pPixels = v26; } return pTex; - //result = pTex; -// } -// else -// { -//LABEL_8: -// return nullptr; -// } } //----- (0045271F) -------------------------------------------------------- @@ -8668,7 +8656,7 @@ this->uDataOffset = 0; memset(&this->uNumItems, 0, 0x61A84u); this->uNumItems = 0; - this->field_61A94_scale_hwls_to_half = 0; + this->scale_hwls_to_half = false; } //----- (0045237F) --------------------------------------------------------
--- a/Render.h Thu Sep 12 09:55:20 2013 +0200 +++ b/Render.h Thu Sep 12 09:58:07 2013 +0200 @@ -177,7 +177,7 @@ char *pSpriteNames[50000]; int pSpriteOffsets[50000]; int bDumpDebug; - int field_61A94_scale_hwls_to_half; + int scale_hwls_to_half; }; #pragma pack(pop)
--- a/SaveLoad.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/SaveLoad.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -22,7 +22,6 @@ #include "stru123.h" #include "texts.h" #include "Log.h" -#include "Allocator.h" #include "VideoPlayer.h" #include "mm7_data.h" @@ -617,7 +616,7 @@ if ( pVideoPlayer->AnyMovieLoaded() ) pVideoPlayer->Unload(); - pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); + pSave = malloc(1000000); pNew_LOD->CloseWriteFile(); remove("data\\new.lod"); @@ -666,7 +665,7 @@ pParty->sRotationY = 512; SaveGame(1, 1); } - pAllocator->FreeChunk(pSave); + free(pSave); } //----- (0045E03A) -------------------------------------------------------- unsigned short * MakeScreenshot( signed int width, signed int height )
--- a/Spells.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Spells.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -6,7 +6,6 @@ #include "Spells.h" #include "Overlays.h" -#include "Allocator.h" #include "LOD.h" #include "texts.h" @@ -301,7 +300,7 @@ char* tmp_pos; if ( pSpellsTXT_Raw ) - pAllocator->FreeChunk(pSpellsTXT_Raw); + free(pSpellsTXT_Raw); pSpellsTXT_Raw = NULL; pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0);
--- a/Sprites.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Sprites.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -5,7 +5,6 @@ #include <string.h> #include <algorithm> -#include "Allocator.h" #include "Sprites.h" #include "PaletteManager.h" #include "LOD.h" @@ -33,7 +32,7 @@ v1 = this; if ( this->pSpriteSFrames ) { - pAllocator->FreeChunk(this->pSpriteSFrames); + free(this->pSpriteSFrames); v1->pSpriteSFrames = 0; } v1->uNumSpriteFrames = 0; @@ -389,10 +388,10 @@ uNumSpriteFrames = num_mm6_frames + num_mm7_frames + num_mm8_frames; uNumEFrames = num_mm6_eframes + num_mm7_eframes + num_mm8_eframes; - pSpriteSFrames = (SpriteFrame *)pAllocator->AllocNamedChunk(pSpriteSFrames, uNumSpriteFrames * sizeof(SpriteFrame), "S Frames"); - pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk(pSpriteEFrames, uNumSpriteFrames * sizeof(short), "E Frames"); + pSpriteSFrames = (SpriteFrame *)malloc(uNumSpriteFrames * sizeof(SpriteFrame)); + pSpriteEFrames = (__int16 *)malloc(uNumSpriteFrames * sizeof(short)); - pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk(pSpritePFrames, 4 * uNumSpriteFrames, "P Frames"); + pSpritePFrames = (SpriteFrame **)malloc(4 * uNumSpriteFrames); auto mm7_frames_size = num_mm7_frames * sizeof(SpriteFrame); memcpy(pSpriteSFrames, (char *)data_mm7 + 8, mm7_frames_size); @@ -495,9 +494,9 @@ v4 = Argsa; } v2->uNumSpriteFrames = v4; - v2->pSpriteSFrames = (SpriteFrame *)pAllocator->AllocNamedChunk(v2->pSpriteSFrames, 60 * v4, "S Frames"); - v2->pSpriteEFrames = (__int16 *)pAllocator->AllocNamedChunk( v2->pSpriteEFrames, 2 * v2->uNumSpriteFrames, "E Frames"); - v2->pSpritePFrames = (SpriteFrame **)pAllocator->AllocNamedChunk( v2->pSpritePFrames, 4 * v2->uNumSpriteFrames, "P Frames"); + v2->pSpriteSFrames = (SpriteFrame *)malloc(60 * v4); + v2->pSpriteEFrames = (__int16 *)malloc(2 * v2->uNumSpriteFrames); + v2->pSpritePFrames = (SpriteFrame **)malloc(4 * v2->uNumSpriteFrames); if ( v2->pSpriteSFrames ) { v6 = File;
--- a/StorylineTextTable.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/StorylineTextTable.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -6,7 +6,6 @@ #include <string.h> #include "LOD.h" -#include "allocator.h" #include "texts.h" #include "StorylineTextTable.h" @@ -26,7 +25,7 @@ int decode_step; if ( pHistoryTXT_Raw ) - pAllocator->FreeChunk(pHistoryTXT_Raw); + free(pHistoryTXT_Raw); pHistoryTXT_Raw = NULL; pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); strtok(pHistoryTXT_Raw, "\r");
--- a/Texture.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Texture.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -6,7 +6,6 @@ #include "Texture.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "LOD.h" #include "PaletteManager.h" #include "Render.h" @@ -274,7 +273,7 @@ Assert(sNumTextures); Assert(!num_mm8_frames); - pTextures = (TextureFrame *)pAllocator->AllocNamedChunk(pTextures, sNumTextures * sizeof(TextureFrame), "Txt Frames"); + pTextures = (TextureFrame *)malloc(sNumTextures * sizeof(TextureFrame)); memcpy(pTextures, (char *)data_mm7 + 4, num_mm7_frames * sizeof(TextureFrame)); memcpy(pTextures + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(TextureFrame)); @@ -402,9 +401,9 @@ __debugbreak(); } - pAllocator->FreeChunk(pLevelOfDetail0_prolly_alpha_mask); - pAllocator->FreeChunk(pPalette16); - pAllocator->FreeChunk(pPalette24); + free(pLevelOfDetail0_prolly_alpha_mask); + free(pPalette16); + free(pPalette24); pLevelOfDetail0_prolly_alpha_mask = nullptr; @@ -460,11 +459,11 @@ if ( DstBuf.uDecompressedSize ) { v5 = malloc(DstBuf.uDecompressedSize); - uSourceLena = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName); + uSourceLena = malloc(DstBuf.uTextureSize); fread(uSourceLena, 1u, Count, File); zlib::MemUnzip(v5, &DstBuf.uDecompressedSize, uSourceLena, DstBuf.uTextureSize); DstBuf.uTextureSize = DstBuf.uDecompressedSize; - pAllocator->FreeChunk(uSourceLena); + free(uSourceLena); } else { @@ -548,11 +547,11 @@ if ( DstBuf.uDecompressedSize ) { Str1a = (char *)malloc(DstBuf.uDecompressedSize); - v6 = pAllocator->AllocNamedChunk(0, DstBuf.uTextureSize, DstBuf.pName); + v6 = malloc(DstBuf.uTextureSize); fread(v6, 1u, Count, File); zlib::MemUnzip(Str1a, &DstBuf.uDecompressedSize, v6, DstBuf.uTextureSize); DstBuf.uTextureSize = DstBuf.uDecompressedSize; - pAllocator->FreeChunk(v6); + free(v6); } else { @@ -575,18 +574,18 @@ { if ( mode ) goto LABEL_14; - pAllocator->FreeChunk(v10); + free(v10); } if ( !mode ) { - v11 = pAllocator->AllocNamedChunk(v3->pPixels, 2 * v3->uNumPixels + 4, "16bit PCX"); + v11 = malloc(2 * v3->uNumPixels + 4); goto LABEL_16; } LABEL_14: if ( mode != 2 ) goto LABEL_17; v11 = malloc(2 * v3->uNumPixels + 4); - *(unsigned int *)&v3->field_20 |= 1u; + v3->_allocation_flags |= 1u; LABEL_16: v3->pPixels = (unsigned __int16 *)v11; LABEL_17: @@ -1147,20 +1146,17 @@ { if ( pPixels ) { - pAllocator->FreeChunk(pPixels); + free(pPixels); pPixels = 0; } - pPixels = (unsigned __int16 *)pAllocator->AllocNamedChunk( - pPixels, - 2 * uNumPixels + 4, - pName); + pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4); } else { if ( mode != 1 && mode == 2 ) { pPixels = (unsigned __int16 *)malloc((uNumPixels + 2) * sizeof(unsigned __int16)); - field_20 |= 1; + _allocation_flags |= 1; } } @@ -1310,14 +1306,14 @@ void *v3; // [sp-4h] [bp-Ch]@1 v1 = this; - v2 = (this->field_20 & 1) == 0; + v2 = (this->_allocation_flags & 1) == 0; v3 = this->pPixels; this->pName[0] = 0; if ( v2 ) - pAllocator->FreeChunk(v3); + free(v3); else free(v3); - *(unsigned int *)&v1->field_20 = 0; + v1->_allocation_flags = 0; v1->pPixels = 0; v1->uNumPixels = 0; v1->uHeight = 0; @@ -1394,14 +1390,14 @@ if ( v12 ) { if ( v3->pPixels ) - pAllocator->FreeChunk(v3->pPixels); - v13 = pAllocator->AllocNamedChunk(v3->pPixels, 2 * v3->uNumPixels + 4, v3->pName); + free(v3->pPixels); + v13 = malloc(2 * v3->uNumPixels + 4); goto LABEL_16; } if ( a3 != 1 && a3 == 2 ) { - v13 = operator new(4 * v11 + 8); - *(unsigned int *)&v3->field_20 |= 1u; + v13 = malloc(4 * v11 + 8); + v3->_allocation_flags |= 1u; LABEL_16: v3->pPixels = (unsigned __int16 *)v13; } @@ -1641,8 +1637,7 @@ uWidth = 0; field_1A = 0; field_18 = 0; - field_20 = 0; - field_22 = 0; + _allocation_flags = 0; } //----- (0044E1EC) -------------------------------------------------------- int TextureFrameTable::FromFileTxt(const char *Args) @@ -1702,7 +1697,7 @@ } v5 = v2->pTextures; v2->sNumTextures = v4; - v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames"); + v6 = malloc(20 * v4); v2->pTextures = (TextureFrame *)v6; if ( !v6 ) Error("CTextureFrameTable::load - Out of Memory!");
--- a/Texture.h Thu Sep 12 09:55:20 2013 +0200 +++ b/Texture.h Thu Sep 12 09:58:07 2013 +0200 @@ -24,8 +24,7 @@ __int16 field_1A; __int16 field_1C; __int16 field_1E; - __int16 field_20; - __int16 field_22; + int _allocation_flags; // & 1 - malloc, else custom allocator unsigned __int16 *pPixels; }; #pragma pack(pop)
--- a/TileTable.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/TileTable.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -8,7 +8,6 @@ #include "TileFrameTable.h" #include "FrameTableInc.h" -#include "Allocator.h" #include "PaletteManager.h" #include "LOD.h" @@ -20,7 +19,7 @@ { if ( pTiles ) { - pAllocator->FreeChunk(pTiles); + free(pTiles); pTiles = nullptr; } sNumTiles = 0; @@ -119,7 +118,7 @@ Assert(sNumTiles); Assert(!num_mm8_tiles); - pTiles = (TileDesc *)pAllocator->AllocNamedChunk(pTiles, sNumTiles * sizeof(TileDesc), "Tile Descrip"); + pTiles = (TileDesc *)malloc(sNumTiles * sizeof(TileDesc)); memcpy(pTiles, (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc)); memcpy(pTiles + num_mm7_tiles, (char *)data_mm6 + 4, num_mm6_tiles * sizeof(TileDesc)); memcpy(pTiles + num_mm6_tiles + num_mm7_tiles, (char *)data_mm8 + 4, num_mm8_tiles * sizeof(TileDesc)); @@ -227,7 +226,7 @@ ++v4; } v2->sNumTiles = v4; - v5 = pAllocator->AllocNamedChunk(v2->pTiles, 26 * v4, "Tile Descrip"); + v5 = malloc(26 * v4); v2->pTiles = (TileDesc *)v5; if ( !v5 ) Error("TileTable::Load - Out of Memory!");
--- a/UI/Books/UIMapBook.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/Books/UIMapBook.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -13,7 +13,6 @@ #include "..\..\AudioPlayer.h" #include "..\..\Outdoor.h" #include "..\..\LOD.h" -#include "..\..\Allocator.h" #include "..\..\Viewport.h" #include "..\..\Math.h" #include "..\..\texts.h"
--- a/UI/Books/UINotesBooks.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/Books/UINotesBooks.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -12,7 +12,6 @@ #include "..\..\Party.h" #include "..\..\AudioPlayer.h" #include "..\..\LOD.h" -#include "..\..\Allocator.h" #include "..\..\Viewport.h" #include "..\..\Awards.h" #include "..\..\Autonotes.h"
--- a/UI/Books/UISpellBook.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/Books/UISpellBook.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -11,7 +11,6 @@ #include "..\..\Party.h" #include "..\..\AudioPlayer.h" #include "..\..\LOD.h" -#include "..\..\Allocator.h" #include "..\..\Viewport.h" #include "..\..\texts.h" #include "..\..\mm7_data.h" @@ -45,13 +44,13 @@ //----- (00411597) -------------------------------------------------------- void OnCloseBook() { - pAllocator->FreeChunk(pSpellFont); + free(pSpellFont); pSpellFont = nullptr; - pAllocator->FreeChunk(pBookFont); + free(pBookFont); pBookFont = nullptr; - pAllocator->FreeChunk(pBook2Font); + free(pBook2Font); pBook2Font = nullptr; - pAllocator->FreeChunk(pAutonoteFont); + free(pAutonoteFont); pAutonoteFont = nullptr; pTexture_mapbordr->Release(); pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
--- a/UI/UIBooks.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UIBooks.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -9,7 +9,7 @@ #include "..\GUIFont.h" #include "..\AudioPlayer.h" #include "..\LOD.h" -#include "..\Allocator.h" + #include "..\mm7_data.h" //----- (00413CC6) -------------------------------------------------------- @@ -90,7 +90,7 @@ do { pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext; - pAllocator->FreeChunk(pGUIWindow_CurrentMenu->pControlsHead); + free(pGUIWindow_CurrentMenu->pControlsHead); pGUIWindow_CurrentMenu->pControlsHead = pNextButton; } while ( pNextButton );
--- a/UI/UICharacter.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UICharacter.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -19,10 +19,9 @@ #include "..\Awards.h" #include "..\CastSpellInfo.h" #include "..\texts.h" +#include "..\Mouse.h" + #include "..\mm7_data.h" -#include "..\Mouse.h" -#include "..\Allocator.h" - int bRingsShownInCharScreen; // 5118E0 @@ -2736,7 +2735,7 @@ if ( BYTE1(i->field_1C) & 0x80 ) { i->Release(); - pAllocator->FreeChunk(i); + free(i); } } for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext )
--- a/UI/UIHouses.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UIHouses.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -89,8 +89,8 @@ { { 0, 1, 1, 34}, // HOUSE_STABLES_HARMONDALE { 2, 3, 4, 5}, // HOUSE_STABLES_STEADWICK - { 6, 7, 8, 8}, // HOUSE_STABLES_56 - { 9, 10, 10, 10}, // HOUSE_STABLES_57 + { 6, 7, 8, 8}, // HOUSE_STABLES_TULAREAN_FOREST + { 9, 10, 10, 10}, // HOUSE_STABLES_DEYJA { 11, 11, 12, 12}, // HOUSE_STABLES_58 { 13, 13, 13, 13}, // HOUSE_STABLES_59 { 14, 14, 15, 15}, // HOUSE_STABLES_60 @@ -989,7 +989,6 @@ { int experience_for_next_level; // eax@5 GUIWindow *v8; // esi@10 - //int v11; // edi@31 int v16; // eax@32 int v17; // eax@33 int v18; // eax@34 @@ -1910,283 +1909,196 @@ //----- (004B6943) -------------------------------------------------------- void TravelByTransport() { - GUIWindow *v0; // ebx@1 - Player *v1; // esi@1 - signed int v2; // edi@1 - unsigned int v3; // eax@1 signed int v4; // ebx@1 - stru365_travel_info *v5; // esi@7 - int v11; // ecx@12 + stru365_travel_info *pTravel; // esi@7 signed int v12; // esi@13 signed int v13; // edi@14 DWORD v14; // eax@26 DWORD v15; // edi@26 - GUIWindow *v16; // ebx@36 - int v17; // esi@36 - int v18; // eax@36 - int v19; // ecx@36 - int v20; // esi@36 - int v21; // eax@36 - void *v22; // eax@39 - int v23; // esi@39 - GUIButton *v24; // ebx@39 + int pTextHeight; // eax@36 + int pRealTextHeight; // esi@36 + int schedule_id; // esi@39 + GUIButton *pButton; // ebx@39 signed int v25; // eax@41 - //int v26; // esi@44 - //const char *v27; // eax@46 - char *v28; // eax@62 - int v29; // eax@62 unsigned int v30; // ecx@62 - char *v31; // eax@63 - MapInfo v32; // [sp-3Ch] [bp-2CCh]@62 - /*int v33; // [sp-38h] [bp-2C8h]@62 - int v34; // [sp-34h] [bp-2C4h]@62 - int v35; // [sp-30h] [bp-2C0h]@62 - int v36; // [sp-2Ch] [bp-2BCh]@62 - int v37; // [sp-28h] [bp-2B8h]@62 - int v38; // [sp-24h] [bp-2B4h]@62 - int v39; // [sp-20h] [bp-2B0h]@62 - int v40; // [sp-1Ch] [bp-2ACh]@62 - int v41; // [sp-18h] [bp-2A8h]@62 - int v42; // [sp-14h] [bp-2A4h]@62 - char *v43; // [sp-10h] [bp-2A0h]@62 - char *v44; // [sp-Ch] [bp-29Ch]@62 - unsigned int v45; // [sp-8h] [bp-298h]@62 - char *v46; // [sp-4h] [bp-294h]@62 - const char *v47[5]; // [sp+0h] [bp-290h]@7*/ - char v48[5][100]; // [sp+14h] [bp-27Ch]@37 - //char v49[100]; // [sp+78h] [bp-218h]@68 - //char v50[100]; // [sp+DCh] [bp-1B4h]@68 - //char v51[100]; // [sp+140h] [bp-150h]@68 - //char Dest[100]; // [sp+1A4h] [bp-ECh]@36 - GUIWindow v53; // [sp+208h] [bp-88h]@1 - int v54; // [sp+25Ch] [bp-34h]@36 - int v55; // [sp+260h] [bp-30h]@36 - //unsigned int v56; // [sp+264h] [bp-2Ch]@1 - //int v57; // [sp+268h] [bp-28h]@1 - int v58; // [sp+26Ch] [bp-24h]@36 - //GUIWindow *v59; // [sp+270h] [bp-20h]@1 - unsigned int v60; // [sp+274h] [bp-1Ch]@36 - //Player *v61; // [sp+278h] [bp-18h]@1 - int v62; // [sp+27Ch] [bp-14h]@36 - int v63; // [sp+280h] [bp-10h]@14 - char *a1; // [sp+284h] [bp-Ch]@37 - unsigned int s1; // [sp+288h] [bp-8h]@1 - int v66; // [sp+28Ch] [bp-4h]@48 + MapInfo pMap; // [sp-3Ch] [bp-2CCh]@62 + char pTopicArray[5][100]; // [sp+14h] [bp-27Ch]@37 + GUIWindow travel_window; // [sp+208h] [bp-88h]@1 + int pPrimaryTextHeight; // [sp+260h] [bp-30h]@36 + //unsigned int v60; // [sp+274h] [bp-1Ch]@36 + int index; // [sp+27Ch] [bp-14h]@36 + //char *a1; // [sp+284h] [bp-Ch]@37 + unsigned int pPrice; // [sp+288h] [bp-8h]@1 + int travel_time; // [sp+28Ch] [bp-4h]@48 + enum PlayerSpeech pSpeech; + unsigned int pCurrentButton; - v0 = window_SpeakInHouse; - memcpy(&v53, window_SpeakInHouse, sizeof(v53)); - v2 = 255; - //v61 = pPlayers[uActiveCharacter]; - v1 = pPlayers[uActiveCharacter]; - v53.uFrameX = 483; - v53.uFrameWidth = 148; - v53.uFrameZ = 334; - auto color_default = TargetColor(255, 255, 255); - auto color_selected = TargetColor(255, 255, 155); - v3 = 52 * (unsigned int)v0->ptr_1C; - //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); - //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50); - //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); + memcpy(&travel_window, window_SpeakInHouse, sizeof(travel_window)); + travel_window.uFrameX = 483; + travel_window.uFrameWidth = 148; + travel_window.uFrameZ = 334; - v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50; - v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; + v4 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50; + v4 *= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - s1 = v4 * (100 - v1->GetMerchant()) / 100; - if ( (signed int)s1 < v4 / 3 ) - s1 = v4 / 3; + pPrice = v4 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( (signed int)pPrice < v4 / 3 ) + pPrice = v4 / 3; if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) { if ( HouseUI_CheckIfPlayerCanInteract() ) { - v16 = pDialogueWindow; - v58 = 255; - v62 = 0; - v17 = LOBYTE(pFontArrus->uFontHeight) - 3; - //v59 = pDialogueWindow; - v54 = v17; - strcpy(v48[4], ""); - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[405], s1); // Price: %lu gold - v18 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &v53, 0, 0); - v19 = v16->pNumPresenceButton; - v20 = v18 + v17 + 146; - v21 = v16->pStartingPosActiveItem; - v63 = v20; - v55 = v20; - v60 = v21; - if ( v21 >= v21 + v19 ) - goto LABEL_71; - s1 = 2; - a1 = (char *)v48; - while ( 1 ) + index = 0; + strcpy(pTopicArray[4], ""); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[405], pPrice); // Price: %lu gold + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &travel_window, 0, 0); + pRealTextHeight = pTextHeight + (LOBYTE(pFontArrus->uFontHeight) - 3) + 146; + pPrimaryTextHeight = pRealTextHeight; + pCurrentButton = 2; + for ( uint i = pDialogueWindow->pStartingPosActiveItem; i < (unsigned int)(pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem); ++i ) { - int v47 = v60; - v22 = window_SpeakInHouse->ptr_1C; - v23 = transport_routes[(unsigned int)v22 - HOUSE_STABLES_HARMONDALE][v62]; - //v23 = (unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // negindex. actual address is around + 0x36 - //v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // + 0x3F for sea travels, less for land - v24 = v16->GetControl(v60); + schedule_id = transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][index]; + pButton = pDialogueWindow->GetControl(i); - if (v23 != v58) + if (schedule_id != 255) { - if (v23 >= 25) + if (schedule_id >= 25) Log::Warning(L"Transport UI: scedule overflow"); - if (s1 >= 6) + if ( pCurrentButton >= 6 ) v25 = true; else - v25 = transport_schedule[v23].pSchedule[pParty->uDaysPlayed % 7]; + v25 = transport_schedule[schedule_id].pSchedule[pParty->uDaysPlayed % 7]; } - if (v23 != v58 && v25 && (!transport_schedule[v23].uQuestBit || _449B57_test_bit(pParty->_quest_bits, transport_schedule[v23].uQuestBit)) ) + if (schedule_id != 255 && v25 && (!transport_schedule[schedule_id].uQuestBit + || _449B57_test_bit(pParty->_quest_bits, transport_schedule[schedule_id].uQuestBit)) ) { - v58 = v23; - if ( pDialogueWindow->pCurrentPosActiveItem == s1 ) - sprintf(a1, "\f%05d", color_selected); - else - sprintf(a1, "\f%05d", color_default); - - //v32.uRedbookTrackID = v27; - v66 = transport_schedule[v23].uTravelTime; - if ( (unsigned int)window_SpeakInHouse->ptr_1C >= HOUSE_BOATS_63 ) +//get color for current string(îïðåäåëåíèå öâåòà òåêóùåé ñòðîêè)------------ + if ( pDialogueWindow->pCurrentPosActiveItem == pCurrentButton ) + sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 155)); + else + sprintf(pTopicArray[index], "\f%05d", TargetColor(255, 255, 255)); + //hired NPC premium(ïðåìèÿ íà¸ìíîãî ÍÏÑ)---------------------------------- + travel_time = transport_schedule[schedule_id].uTravelTime; + if ( (unsigned int)window_SpeakInHouse->ptr_1C >= HOUSE_BOATS_EMERALD_ISLE ) { if ( CheckHiredNPCSpeciality(Sailor) ) - v66 -= 2; + travel_time -= 2; if ( CheckHiredNPCSpeciality(Navigator) ) - v66 -= 3; + travel_time -= 3; if ( CheckHiredNPCSpeciality(Pirate) ) - v66 -= 2; + travel_time -= 2; } else { if ( CheckHiredNPCSpeciality(Horseman) ) - v66 -= 2; + travel_time -= 2; } if ( CheckHiredNPCSpeciality(Explorer) ) - --v66; - if ( v66 < 1 ) - v66 = 1; - if ( v23 != v2 ) + --travel_time; + + if ( travel_time < 1 ) + travel_time = 1; + if ( schedule_id != 255 ) { - memcpy(&v32, &pMapStats->pInfos[transport_schedule[v23].uMapInfoID], 0x44u); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[404], // Time - %d days, destination %s - v66, v32.pName); - strcat(a1, pTmpBuf.data()); - v28 = a1; - a1 += 100; - ++v62; - ++s1; - strcat(v28, "\n \n"); - v24->uY = v63; - v29 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v53, 0, 0); - v30 = v24->uY; - v24->uHeight = v29; - v2 = 255; - v24->uW = v30 + v29 - 1; - v63 += v54 + v29; + memcpy(&pMap, &pMapStats->pInfos[transport_schedule[schedule_id].uMapInfoID], 0x44u); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[404], travel_time, pMap.pName); // Time - %d days, destination %s + strcat(pTopicArray[index], pTmpBuf.data()); + strcat(pTopicArray[index], "\n \n"); + pButton->uY = pRealTextHeight; + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0); + v30 = pButton->uY; + pButton->uHeight = pTextHeight; + pButton->uW = v30 + pTextHeight - 1; + pRealTextHeight += (LOBYTE(pFontArrus->uFontHeight) - 3) + pTextHeight; } } else { - v31 = a1; - ++v62; - ++s1; - a1 += 100; - strcpy(v31, ""); - if ( v24 ) + strcpy(pTopicArray[index], ""); + if ( pButton ) { - v24->uW = 0; - v24->uHeight = 0; - v24->uY = 0; + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; } } - ++v60; - if ( (signed int)v60 >= v16->pNumPresenceButton + v16->pStartingPosActiveItem ) - break; - //v16 = v59; + ++index; + ++pCurrentButton; } - if ( v63 != v55 ) + if ( pRealTextHeight != pPrimaryTextHeight ) { - /*v47[1] = &Dest; - v47[0] = &v51; - v46 = &v50; - v45 = (unsigned int)&v49; - v44 = &v48; - v43 = pTmpBuf2.data();*/ - sprintf(pTmpBuf.data(), "%s\n \n%s%s%s%s%s", pTmpBuf2.data(), v48[0], v48[1], v48[2], v48[3], v48[4]); - v53.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + sprintf(pTmpBuf.data(), "%s\n \n%s%s%s%s%s", pTmpBuf2.data(), pTopicArray[0], pTopicArray[1], pTopicArray[2], pTopicArray[3], pTopicArray[4]); + travel_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf.data(), 3); } else { -LABEL_71: - v53.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &v53, 0, 0)) / 2 + 138, - color_default, pGlobalTXT_LocalizationStrings[561], 3); + travel_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &travel_window, 0, 0)) / 2 + 138,//"Èçâèíèòå, ïðèõîäèòå â äðóãîé äåíü" + TargetColor(255, 255, 255), pGlobalTXT_LocalizationStrings[561], 3); pAudioPlayer->StopChannels(-1, -1); } } } - else + else//ïîñëå íàæàòèÿ òîïèêà { if ( dialog_menu_id >= HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1 && dialog_menu_id <= HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_4 ) { - if ( pParty->uNumGold < s1 ) + if ( pParty->uNumGold < pPrice ) { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);//"Ó âàñ íå õâàòàåò çîëîòà" PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); return; } - Party::TakeGold(s1); + Party::TakeGold(pPrice); - v5 = &transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][dialog_menu_id - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]]; - if ( v5->pSchedule[pParty->uDaysPlayed % 7] ) + pTravel = &transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][dialog_menu_id - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]]; + if ( pTravel->pSchedule[pParty->uDaysPlayed % 7] ) { - if ( _stricmp(pCurrentMapName, pMapStats->pInfos[v5->uMapInfoID].pFilename) ) + if ( _stricmp(pCurrentMapName, pMapStats->pInfos[pTravel->uMapInfoID].pFilename) ) { SaveGame(1, 0); - strcpy(pCurrentMapName, pMapStats->pInfos[v5->uMapInfoID].pFilename); + strcpy(pCurrentMapName, pMapStats->pInfos[pTravel->uMapInfoID].pFilename); dword_6BE364_game_settings_1 |= 1u; _5B65B8_npcdata_hiword_house_or_other = 0; dword_5B65BC = 0; - _5B65B4_npcdata_loword_house_or_other = v5->arrival_rot_y; - v11 = *((int *)v5 + 3); + _5B65B4_npcdata_loword_house_or_other = pTravel->arrival_rot_y; uGameState = GAME_STATE_2; - _5B65A8_npcdata_uflags_or_other = v11; - _5B65AC_npcdata_fame_or_other = v5->arrival_y; - _5B65B0_npcdata_rep_or_other = v5->arrival_z; - dword_5B65C0 = v11 | v5->arrival_y | v5->arrival_z | v5->arrival_rot_y; + _5B65A8_npcdata_uflags_or_other = pTravel->arrival_x; + _5B65AC_npcdata_fame_or_other = pTravel->arrival_y; + _5B65B0_npcdata_rep_or_other = pTravel->arrival_z; + dword_5B65C0 = pTravel->arrival_x | pTravel->arrival_y | pTravel->arrival_z | pTravel->arrival_rot_y; } else { pIndoorCamera->sRotationY = 0; pParty->uFlags |= 2u; - pParty->vPosition.x = v5->arrival_x; - pParty->vPosition.y = v5->arrival_y; - pParty->vPosition.z = v5->arrival_z; + pParty->vPosition.x = pTravel->arrival_x; + pParty->vPosition.y = pTravel->arrival_y; + pParty->vPosition.z = pTravel->arrival_z; pParty->uFallStartY = pParty->vPosition.z; pParty->sRotationX = 0; - pParty->sRotationY = v5->arrival_rot_y; + pParty->sRotationY = pTravel->arrival_rot_y; } PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); - v12 = v5->uTravelTime; - int _v47; + v12 = pTravel->uTravelTime; if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 ) { - v63 = SPEECH_SetSail; + pSpeech = SPEECH_SetSail; v13 = 2500; if ( CheckHiredNPCSpeciality(Sailor) ) v12 -= 2; if ( CheckHiredNPCSpeciality(Navigator) ) v12 -= 3; - //_v47 = 45; if ( CheckHiredNPCSpeciality(Pirate) ) v12 -= 2; } else { - v63 = SPEECH_CarriageReady; + pSpeech = SPEECH_CarriageReady; v13 = 1500; - //_v47 = 35; if ( CheckHiredNPCSpeciality(Horseman) ) v12 -= 2; } @@ -2195,7 +2107,7 @@ if ( v12 < 1 ) v12 = 1; RestAndHeal(1440 * v12); - v1->PlaySound((PlayerSpeech)v63, 0); + pPlayers[uActiveCharacter]->PlaySound(pSpeech, 0); v14 = GetTickCount(); v15 = v14 + v13; if ( v15 < v14 ) @@ -2218,20 +2130,17 @@ //----- (004B68EA) -------------------------------------------------------- bool __fastcall IsTravelAvailable(int a1) { - for (uint i = 0; i < 4; ++i) + for ( uint i = 0; i < 4; ++i ) { - uint route = transport_routes[a1][i]; - if (transport_schedule[route].pSchedule[pParty->uDaysPlayed % 7]) + if ( transport_schedule[transport_routes[a1][i]].pSchedule[pParty->uDaysPlayed % 7] ) { - if (!transport_schedule[route].uQuestBit || _449B57_test_bit(pParty->_quest_bits, transport_schedule[route].uQuestBit)) + if (!transport_schedule[transport_routes[a1][i]].uQuestBit || _449B57_test_bit(pParty->_quest_bits, transport_schedule[transport_routes[a1][i]].uQuestBit)) return true; } } return false; } - - //----- (004B7911) -------------------------------------------------------- void TownHallDialog() { @@ -3888,42 +3797,15 @@ //----- (004B2A74) -------------------------------------------------------- void SimpleHouseAndBoatsDialog() { - char *v0; // esi@3 - char *v1; // ST1C_4@3 char *v2; // eax@3 - const char *v3; // ST1C_4@5 - int v4; // eax@5 unsigned int i; // eax@5 - NPCData *v6; // esi@6 - unsigned __int16 v7; // bx@6 - unsigned int v8; // eax@6 - int v9; // eax@11 - unsigned int v10; // ecx@12 - int v11; // eax@12 - int v12; // esi@12 - char *v13; // eax@12 - GUIWindow *v14; // ebx@13 + NPCData *pNPC; // esi@6 char *v15; // esi@14 - GUIButton *v16; // eax@15 - unsigned int v17; // ecx@15 + GUIButton *pButton; // eax@15 int v18; // ecx@17 - int v19; // ecx@18 - int v20; // ecx@19 - int v21; // ecx@20 - int v22; // ecx@21 - unsigned int v23; // ecx@23 - int v24; // ecx@35 - int v25; // ecx@36 - int v26; // ecx@37 - int v27; // ecx@38 - int v28; // ecx@39 char *v29; // esi@42 - unsigned int v30; // ST20_4@42 int v31; // ST1C_4@42 - unsigned int v32; // eax@42 - char *v33; // eax@43 int v34; // esi@51 - int v35; // eax@51 unsigned int v36; // edi@51 GUIButton *v37; // eax@52 int v38; // eax@52 @@ -3937,258 +3819,226 @@ unsigned __int16 v46; // ax@60 GUIFont *v47; // ebx@64 int v48; // esi@64 - char *v49; // eax@66 GUIWindow w; // [sp+Ch] [bp-110h]@64 GUIWindow v52; // [sp+60h] [bp-BCh]@13 - GUIWindow a1; // [sp+B4h] [bp-68h]@1 - unsigned int v54; // [sp+108h] [bp-14h]@14 - int v55; // [sp+10Ch] [bp-10h]@6 - int v56; // [sp+110h] [bp-Ch]@13 + GUIWindow house_window; // [sp+B4h] [bp-68h]@1 char *pInString; // [sp+114h] [bp-8h]@12 - NPCData *v58; // [sp+118h] [bp-4h]@6 - memcpy(&a1, pDialogueWindow, sizeof(a1)); + memcpy(&house_window, pDialogueWindow, sizeof(house_window)); if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) { - v0 = pMapStats->pInfos[uHouse_ExitPic].pName; - v1 = pMapStats->pInfos[uHouse_ExitPic].pName; - a1.uFrameX = 493; - a1.uFrameWidth = 126; - a1.uFrameZ = 366; - a1.DrawTitleText(pFontCreate, 0, 2u, 0, v1, 3u); - a1.uFrameX = 483; - a1.uFrameWidth = 148; - a1.uFrameZ = 334; + house_window.uFrameX = 493; + house_window.uFrameWidth = 126; + house_window.uFrameZ = 366; + house_window.DrawTitleText(pFontCreate, 0, 2, 0, pMapStats->pInfos[uHouse_ExitPic].pName, 3); + house_window.uFrameX = 483; + house_window.uFrameWidth = 148; + house_window.uFrameZ = 334; v2 = pTransitionStrings[uHouse_ExitPic]; if ( !v2 ) { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], v0); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);//Âîéòè â ^Pv[%s] v2 = pTmpBuf.data(); } - v3 = v2; - v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0); - a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u); + house_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(v2, &house_window, 0, 0)) / 2 + 101, 0, v2, 3); return; } - a1.uFrameWidth -= 10; - a1.uFrameZ -= 10; - v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 - v6 = v58; - v55 = TargetColor(0xE1u, 0xCDu, 0x23u); - v7 = TargetColor(0x15u, 0x99u, 0xE9u); - v8 = v6->uProfession; - if ( v8 ) - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]); + house_window.uFrameWidth -= 10; + house_window.uFrameZ -= 10; + pNPC = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 + if ( pNPC->uProfession ) + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s else - strcpy(pTmpBuf.data(), v6->pName); - a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf.data(), 3u); + strcpy(pTmpBuf.data(), pNPC->pName); + house_window.DrawTitleText(pFontCreate, 483, 113, TargetColor(0x15u, 0x99u, 0xE9u), pTmpBuf.data(), 3); if ( !dword_591080 ) { if ( !uDialogueType ) { - v9 = v6->greet; - if ( v9 ) + if ( pNPC->greet ) { - v10 = v6->uFlags; - a1.uFrameWidth = game_viewport_width; - a1.uFrameZ = 452; - pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9); - v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0); - v12 = v11 + 7; - pRenderer->GetLeather(8, 352 - (v11 + 7), - pIcons_LOD->GetTexture(uTextureID_Leather), - pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (v11 + 7)); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, pFontArrus, &a1, 0xDu, 0); - pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0); + house_window.uFrameWidth = game_viewport_width; + house_window.uFrameZ = 452; + pInString = (char *)*(&pNPCStats->field_17884 + ((pNPC->uFlags & 3) == 2) + 2 * pNPC->greet); + pRenderer->GetLeather(8, 352 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), + pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight + - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7)); + pRenderer->DrawTextureIndexed(8, 347 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), pTexture_591428); + pDialogueWindow->DrawText(pFontArrus, 13, 354 - (pFontArrus->CalcTextHeight(pInString, &house_window, 13, 0) + 7), + 0, FitTextInAWindow(pInString, pFontArrus, &house_window, 0xDu, 0), 0, 0, 0); } } } - v14 = pDialogueWindow; memcpy(&v52, pDialogueWindow, sizeof(v52)); v52.uFrameX = 483; v52.uFrameWidth = 148; v52.uFrameZ = 334; - v56 = v52.pStartingPosActiveItem; + if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton ) { - v15 = "";//(char *)v54; - while ( 1 ) + v15 = ""; + for ( int i = v52.pStartingPosActiveItem; i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i ) { - v16 = v52.GetControl(v56); - v17 = v16->msg_param; - pInString = (char *)v16; - if ( (signed int)v17 > 24 ) + pButton = v52.GetControl(i); + if ( (signed int)pButton->msg_param > 24 ) { - v24 = v17 - 76; - if ( !v24 ) + if ( pButton->msg_param == 76 ) { - v15 = pGlobalTXT_LocalizationStrings[406]; - goto LABEL_49; + v15 = pGlobalTXT_LocalizationStrings[406];//Íàíÿòü + strcpy(pButton->pButtonName, v15); + continue; } - v25 = v24 - 1; - if ( !v25 ) + if ( pButton->msg_param == 77 ) { - v15 = pGlobalTXT_LocalizationStrings[407]; - goto LABEL_49; + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[407]);//Ïîäðîáíåå + continue; } - v26 = v25 - 2; - if ( !v26 ) + if ( pButton->msg_param == 79 ) { - v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C); -LABEL_44: - v15 = v33; - v16 = (GUIButton *)pInString; - goto LABEL_49; + strcpy(pButton->pButtonName, _4B254D_SkillMasteryTeacher((int)v52.ptr_1C)); + continue; } - v27 = v26 - 3; - if ( !v27 ) + if ( pButton->msg_param == 82 ) { - v33 = (char *)ContractSelectText((int)v52.ptr_1C); - goto LABEL_44; + strcpy(pButton->pButtonName, ContractSelectText((int)v52.ptr_1C)); + continue; } - v28 = v27 - 1; - if ( !v28 ) + if ( pButton->msg_param == 83 ) { v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName; - v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); v31 = *(int *)v29; - v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30); + sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), v31, TargetColor(0xFFu, 0xFFu, 0xFFu)); sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); current_npc_text = pTmpBuf2.data(); - v15 = ""; - v16 = (GUIButton *)pInString; - goto LABEL_49; + strcpy(pButton->pButtonName, ""); + continue; } - if ( v28 != 10 ) + if ( pButton->msg_param != 93 ) { - v15 = ""; - goto LABEL_49; + strcpy(pButton->pButtonName, ""); + continue; } } else { - if ( v17 == 24 ) + if ( pButton->msg_param == 24 )//evt_F { - v23 = v58->evt_F; -LABEL_33: - v15 = (char *)pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; + v15 = (char *)pNPCTopics[pNPC->evt_F-1].pTopic; if ( !v15 ) { - v16->msg_param = 0; + pButton->msg_param = 0; v15 = ""; } - goto LABEL_49; + strcpy(pButton->pButtonName, v15); + continue; } - v18 = v17 - 13; + v18 = pButton->msg_param - 13; if ( v18 ) { - v19 = v18 - 6; - if ( !v19 ) + if ( pButton->msg_param == 19 )//evt_A { - v23 = v58->evt_A; - goto LABEL_33; - } - v20 = v19 - 1; - if ( !v20 ) - { - v15 = (char *)pNPCTopics[v58->evt_B-1].pTopic;//(&dword_721660)[8 * v58->evtb]; + v15 = (char *)pNPCTopics[pNPC->evt_A-1].pTopic; if ( !v15 ) { - v16->msg_param = 0; + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; + } + if ( pButton->msg_param == 20 )//evt_B + { + v15 = (char *)pNPCTopics[pNPC->evt_B-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; v15 = ""; } if ( uDialogueType != 84 ) - goto LABEL_49; - sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName); + { + strcpy(pButton->pButtonName, v15); + continue; + } + sprintf(pTmpBuf.data(), format_4E2D80, TargetColor(0xE1u, 0xCDu, 0x23u), pItemsTable->pItems[contract_approved].pUnidentifiedName); sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); current_npc_text = pTmpBuf2.data(); - v16 = (GUIButton *)pInString; - goto LABEL_49; + strcpy(pButton->pButtonName, v15); + continue; } - v21 = v20 - 1; - if ( !v21 ) + if ( pButton->msg_param == 21 )//evt_C { - v23 = v58->evt_C; - goto LABEL_33; + v15 = (char *)pNPCTopics[pNPC->evt_C-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; } - v22 = v21 - 1; - if ( !v22 ) - { - v23 = v58->evt_D; - goto LABEL_33; - } - if ( v22 == 1 ) + if ( pButton->msg_param == 22 )//evt_D { - v23 = v58->evt_E; - goto LABEL_33; + v15 = (char *)pNPCTopics[pNPC->evt_D-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; } -LABEL_41: - v15 = ""; - goto LABEL_49; + if ( pButton->msg_param == 23 )//evt_E + { + v15 = (char *)pNPCTopics[pNPC->evt_E-1].pTopic; + if ( !v15 ) + { + pButton->msg_param = 0; + v15 = ""; + } + strcpy(pButton->pButtonName, v15); + continue; + } + strcpy(pButton->pButtonName, ""); + continue; } - v15 = pGlobalTXT_LocalizationStrings[122]; - } -LABEL_49: - strcpy(v16->pButtonName, v15); - ++v56; - if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton ) - { - v14 = pDialogueWindow; - break; + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]);//Âñòóïèòü } } } v34 = 0; - v54 = TargetColor(0xFFu, 0xFFu, 0xFFu); - v35 = TargetColor(0xE1u, 0xCDu, 0x23u); - v36 = v14->pStartingPosActiveItem; - v55 = v35; - for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton + v36 = pDialogueWindow->pStartingPosActiveItem; + for ( i = v36 + pDialogueWindow->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) { - v37 = v14->GetControl(v36); + v37 = pDialogueWindow->GetControl(v36); v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0); - v14 = pDialogueWindow; v34 += v38; ++v36; } - v39 = v14->pNumPresenceButton; + v39 = pDialogueWindow->pNumPresenceButton; if ( v39 ) { - v58 = (NPCData *)((174 - v34) / v39); - if ( (signed int)v58 > 32 ) - v58 = (NPCData *)32; + pNPC = (NPCData *)((174 - v34) / v39); + if ( (signed int)pNPC > 32 ) + pNPC = (NPCData *)32; pInString = (char *)2; - v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138; - v56 = v14->pStartingPosActiveItem; - i = v56; - if ( (signed int)i < (signed int)(i + v39) ) + v40 = (174 - (signed int)pNPC * v39 - v34) / 2 - (signed int)pNPC / 2 + 138; + for ( i = pDialogueWindow->pStartingPosActiveItem; i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) { - while ( 1 ) - { - v41 = v14->GetControl(i); - v42 = v41; - v43 = v41->pButtonName; - v41->uY = (unsigned int)((char *)v58 + v40); - v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0); - v45 = v42->uY; - v42->uHeight = v44; - v40 = v45 + v44 - 1; - v42->uW = v40; - v46 = v55; - if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) - v46 = v54; - v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3u); - v14 = pDialogueWindow; - ++pInString; - ++v56; - i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; - if ( v56 >= (signed int)i ) - break; - i = v56; - } + v41 = pDialogueWindow->GetControl(i); + v42 = v41; + v43 = v41->pButtonName; + v41->uY = (unsigned int)((char *)pNPC + v40); + v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0); + v45 = v42->uY; + v42->uHeight = v44; + v40 = v45 + v44 - 1; + v42->uW = v40; + v46 = TargetColor(0xE1u, 0xCDu, 0x23u); + if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) + v46 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3); + ++pInString; } } if ( current_npc_text ) @@ -4203,9 +4053,8 @@ v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; } pRenderer->GetLeather(8, 352 - v48, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); - pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428); - v49 = FitTextInAWindow(current_npc_text, v47, &w, 13, 0); - a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); + pRenderer->DrawTextureIndexed(8, 347 - v48, pTexture_591428); + house_window.DrawText(v47, 13, 354 - v48, 0, FitTextInAWindow(current_npc_text, v47, &w, 13, 0), 0, 0, 0); } }
--- a/UI/UIHouses.h Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UIHouses.h Thu Sep 12 09:58:07 2013 +0200 @@ -56,21 +56,21 @@ HOUSE_ALCHEMIST_HARMONDALE = 43, HOUSE_STABLES_HARMONDALE = 54, HOUSE_STABLES_STEADWICK = 55, - HOUSE_STABLES_56 = 56, - HOUSE_STABLES_57 = 57, - HOUSE_STABLES_58 = 58, - HOUSE_STABLES_59 = 59, - HOUSE_STABLES_60 = 60, + HOUSE_STABLES_TULAREAN_FOREST = 56, + HOUSE_STABLES_DEYJA = 57, + HOUSE_STABLES_BRACADA_DESERT = 58, + HOUSE_STABLES_TATALIA = 59, + HOUSE_STABLES_AVLEE = 60, HOUSE_STABLES_61 = 61, HOUSE_STABLES_62 = 62, - HOUSE_BOATS_63 = 63, - HOUSE_BOATS_64 = 64, - HOUSE_BOATS_65 = 65, - HOUSE_BOATS_66 = 66, - HOUSE_BOATS_67 = 67, + HOUSE_BOATS_EMERALD_ISLE = 63, + HOUSE_BOATS_ERATHIA = 64, + HOUSE_BOATS_TULAREAN_FOREST = 65, + HOUSE_BOATS_BRACADA_DESERT = 66, + HOUSE_BOATS_EVENMORN_ISLAND = 67, HOUSE_BOATS_68 = 68, - HOUSE_BOATS_69 = 69, - HOUSE_BOATS_70 = 70, + HOUSE_BOATS_TATALIA = 69, + HOUSE_BOATS_AVLEE = 70, HOUSE_BOATS_71 = 71, HOUSE_BOATS_72 = 72, HOUSE_BOATS_73 = 73,
--- a/UI/UIMainMenu.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UIMainMenu.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -10,7 +10,6 @@ #include "..\AudioPlayer.h" #include "..\Render.h" #include "..\LOD.h" -#include "..\Allocator.h" #include "..\PaletteManager.h" #include "..\IconFrameTable.h" #include "..\texts.h" @@ -290,13 +289,12 @@ pHeight = pFont2->GetStringHeight2(pFont, v1, &a2, 0, 1); pTexture2.uHeight = pHeight + 2 * a2.uFrameHeight; pTexture2.uNumPixels = (signed __int16)pTexture2.uWidth * (signed __int16)pTexture2.uHeight; - v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap"); + v7 = malloc(2 * pTexture2.uNumPixels);//, "scrollermap"); pNumPixels = pTexture2.uNumPixels; pTexture2.pPixels = (unsigned __int16 *)v7; teal = TargetColor(0, 0xFFu, 0xFFu); fill_pixels_fast(teal, pTexture2.pPixels, pNumPixels); - pTexture2.field_20 = 0; - pTexture2.field_22 = 0; + pTexture2._allocation_flags = 0; pColor1 = TargetColor(0x70u, 0x8Fu, 0xFEu); pColor2 = TargetColor(0xECu, 0xE6u, 0x9Cu); pString = (char *)operator new(2 * pSize); @@ -340,9 +338,9 @@ } while ( GetCurrentMenuID() == MENU_CREDITSPROC ); pAudioPlayer->_4AA258(1); - pAllocator->FreeChunk(ptr); - pAllocator->FreeChunk(pFontQuick); - pAllocator->FreeChunk(pFontCChar); + free(ptr); + free(pFontQuick); + free(pFontCChar); pWindow_MainMenu->Release(); pIcons_LOD->RemoveTexturesPackFromTextureList(); pTexture.Release();
--- a/UI/UIPartyCreation.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UIPartyCreation.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -12,7 +12,6 @@ #include "..\AudioPlayer.h" #include "..\Render.h" #include "..\LOD.h" -#include "..\Allocator.h" #include "..\Time.h" #include "..\IconFrameTable.h" #include "..\texts.h" @@ -631,7 +630,7 @@ //----- (0049750E) -------------------------------------------------------- void DeleteCCharFont() { - pAllocator->FreeChunk(pFontCChar); + free(pFontCChar); pFontCChar = 0; } //----- (00497526) --------------------------------------------------------
--- a/UI/UISaveLoad.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/UI/UISaveLoad.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -13,7 +13,6 @@ #include "..\Render.h" #include "..\IndoorCamera.h" #include "..\LOD.h" -#include "..\Allocator.h" #include "..\SaveLoad.h" #include "..\texts.h"
--- a/VideoPlayer.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/VideoPlayer.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -16,7 +16,6 @@ #include "Render.h" #include "Party.h" #include "GUIWindow.h" -#include "Allocator.h" #include "Time.h" #include "Log.h" #include "texts.h" @@ -516,8 +515,8 @@ ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); pMagicVideoHeaders = 0; pMightVideoHeaders = 0; - pMightVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(0, 44 * uNumMightVideoHeaders + 2, 0); - pMagicVideoHeaders = (MovieHeader *)pAllocator->AllocNamedChunk(pMagicVideoHeaders, 44 * uNumMagicVideoHeaders + 2, 0); + pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); + pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); ReadFile(hMagicVid, pMagicVideoHeaders, 44 * uNumMagicVideoHeaders, &NumberOfBytesRead, 0); }
--- a/Viewport.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/Viewport.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -62,10 +62,10 @@ //----- (004C02F8) -------------------------------------------------------- void Viewport::_4C02F8(int a2) - { +{ this->field_30 = a2; SetScreen(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y); - } +} //----- (004C0312) -------------------------------------------------------- void Viewport::SetViewport( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
--- a/_deleted.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/_deleted.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -12374,6 +12374,400 @@ LOWORD(v2) = (a1 >> 5) & 0x7E0; return ((unsigned __int8)a1 >> 3) | v2 | v1; } +//----- (00487DBE) -------------------------------------------------------- +void Software_ResetNewEdges() +{ + int v0; // ecx@1 + Edge **v1; // eax@1 + signed int v2; // eax@3 + + v0 = 0; + v1 = ptr_80CA10.data(); + do + { + ++v0; + *((int *)&pNewEdges[v0] - 9) = (int)&defaultEdge; + *v1 = 0; + ++v1; + } + while ( (signed int)v1 < (signed int)&unk_80D190 ); + v2 = 2000; + do + { + pSurfs->field_22 = 0; + --v2; + } + while ( v2 ); +} +//----- (00486A28) -------------------------------------------------------- +void OutdoorCamera::AllocSoftwareDrawBuffers() +{ + if ( !this || !pSpans ) + { + ReleaseSoftwareDrawBuffers(); + pSpans = (Span *)malloc(pSpans, 0x493E0u, "SPANS"); + pEdges = (Edge *)malloc(pEdges, 0x4C2C0u, "EDGES"); + pSurfs = (Surf *)malloc(pSurfs, 0x11940u, "SURFS"); + pNewEdges = (Edge *)malloc(pNewEdges, 0x6180u, "NEWEDGES"); + memset(pSpans, 0, 0x493E0u); + memset(pEdges, 0, 0x4C2C0u); + memset(pSurfs, 0, 0x11940u); + memset(pNewEdges, 0, 0x6180u); + } +} +//----- (00486AFC) -------------------------------------------------------- +void OutdoorCamera::ReleaseSoftwareDrawBuffers() +{ + free(pSpans); + free(pEdges); + free(pSurfs); + free(pNewEdges); + pSpans = 0; + pEdges = 0; + pSurfs = 0; + pNewEdges = 0; +} +//----- (0048901B) -------------------------------------------------------- +bool OutdoorLocation::Release2() +{ + Release(); + pOutdoorCamera->ReleaseSoftwareDrawBuffers(); + return true; +} + +struct Allocator +{ + static Allocator *Create() {static Allocator a; return &a;} + + Allocator(); + bool Initialize(unsigned int uNumKBytes); + void *AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName); + void FreeChunk(void *ptr); + bool CreateFileDump(const char *a1); + + void *pMemoryBuffers[6000]; + unsigned int uMemoryBuffersSizes[6000]; + char pMemoryBuffersNames[6000][12]; + unsigned int uDumpsCount; + unsigned int uNumBuffersUsed; + void *pBigMemoryBuffer; + unsigned int uNextFreeOffsetInBigBuffer; + unsigned int uBigBufferSizeAligned; + unsigned int bBigBufferAllocated; + unsigned int bUseBigBuffer; + void *pBigBufferAligned; +}; +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <string.h> +#include <stdio.h> + +#include "Allocator.h" +#include "ErrorHandling.h" + +#include "mm7_data.h" + + + +Allocator *pAllocator; // idb + +int aborting_app = false; // weak + + + + +void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize); + + + +//----- (00426755) -------------------------------------------------------- +void *Allocator::AllocNamedChunk(const void *pPrevPtrValue, unsigned int uSize, const char *pName) +{ + //Allocator *v4; // esi@1 + unsigned int v5; // eax@7 + void *result; // eax@8 + // unsigned int *pNumBuffersUsed; // ebx@12 + unsigned int v8; // edi@15 + char v9; // zf@15 + int v10; // eax@16 + void **v11; // ebx@19 + void *v12; // eax@22 + unsigned int Size; // [sp+14h] [bp+Ch]@16 + + int aligned_size; + + + if ( pPrevPtrValue && !aborting_app ) + AbortWithError(); + if ( !bBigBufferAllocated && !aborting_app ) + AbortWithError(); + + if (!uSize) + return 0; + + if (((uSize & 0x80000000u) != 0) && !aborting_app) + AbortWithError(); + + if (uNumBuffersUsed == 6000 && !aborting_app) + AbortWithError(); + + ++uNumBuffersUsed; + + if (!bUseBigBuffer) + { + pMemoryBuffers[uNumBuffersUsed] = malloc(uSize); + if (pMemoryBuffers[uNumBuffersUsed]) + uMemoryBuffersSizes[uNumBuffersUsed] = uSize; + else + { + if ( !aborting_app ) + AbortWithError(); + } + } + else + { + + aligned_size =(uSize&0xFFFFFFFC) + 4; + + if ((uNextFreeOffsetInBigBuffer +aligned_size) > uBigBufferSizeAligned) + { + printf("Id: %s Size: %i", pName, aligned_size); + CreateFileDump( "Memory"); + if ( !aborting_app ) + AbortWithError(); + } + + pMemoryBuffers[uNumBuffersUsed] = (char *)pBigMemoryBuffer + uNextFreeOffsetInBigBuffer;//(char *)(pBigBufferAligned) + uNextFreeOffsetInBigBuffer; + uMemoryBuffersSizes[uNumBuffersUsed] =aligned_size; + + if (pName) + strncpy(pMemoryBuffersNames[uNumBuffersUsed], pName, 11); + uNextFreeOffsetInBigBuffer += aligned_size; + } + return pMemoryBuffers[uNumBuffersUsed]; +} +// 720018: using guessed type int aborting_app; + + + +//----- (004266CD) -------------------------------------------------------- +bool Allocator::Initialize(unsigned int uNumKBytes) +{ + if (bBigBufferAllocated) + return false; + + if (!uNumKBytes) + return false; + + pBigMemoryBuffer = malloc(uNumKBytes * 1024); + if (!pBigMemoryBuffer) + return false; + + pBigBufferAligned = (void *)((unsigned int)(pBigMemoryBuffer) & 0xFFFF0000 + 4096); + //(char *)pBigMemoryBuffer + -((unsigned __int16)pBigMemoryBuffer & 0xFFF) + 4096; + uBigBufferSizeAligned = (uNumKBytes * 1024) - 4096; + + uNumBuffersUsed = 0; + uNextFreeOffsetInBigBuffer = 0; + + bUseBigBuffer = true; + return bBigBufferAllocated = true; +} + + +//----- (00426474) -------------------------------------------------------- +void Allocator::FreeChunk(void *ptr) +{ + Allocator *v2; // esi@1 + unsigned int v3; // eax@5 + signed int i; // edi@5 + unsigned int v5; // eax@13 + signed int v6; // ecx@16 + signed int j; // edx@16 + char v8; // zf@20 + + + + unsigned int uBuffindx; + unsigned int indx; + + if (ptr) + { + if ((!bBigBufferAllocated)&& (!aborting_app )) + AbortWithError(); + for (indx = 0; indx <=uNumBuffersUsed; ++indx) + if (pMemoryBuffers[indx] == ptr) + break; + //if ((indx>uNumBuffersUsed)&& !aborting_app ) + //AbortWithError(); //to detect memory problems - uncomment + if (!bUseBigBuffer) + free(pMemoryBuffers[indx]); + pMemoryBuffers[indx] = NULL; + uMemoryBuffersSizes[indx] = 0; + pMemoryBuffersNames[indx][0] = 0; + if (indx == (uNumBuffersUsed-1)) + { + if (indx>0) + { + uBuffindx = 0; + for (j = 0; j < uNumBuffersUsed-1; ++j) + { + if (pMemoryBuffers[j]) + uBuffindx = j; + } + uNumBuffersUsed = uBuffindx + 1; + if (bUseBigBuffer) + uNextFreeOffsetInBigBuffer = + ((long)((char*)pMemoryBuffers[uBuffindx] -(char*)pBigBufferAligned)+ uMemoryBuffersSizes[uBuffindx]); + } + else + { + uNumBuffersUsed = 0; + uNextFreeOffsetInBigBuffer = 0; + } + } + } +} +// 720018: using guessed type int aborting_app; + + + +//----- (00426429) -------------------------------------------------------- +Allocator::Allocator() +{ + Allocator *v1; // eax@1 + signed int v2; // ecx@1 + int v3; // edx@1 + + v1 = this; + v2 = 0; + v1->uBigBufferSizeAligned = 0; + v1->bBigBufferAllocated = 0; + v3 = (int)v1->pMemoryBuffersNames; + do + { + v1->pMemoryBuffers[v2] = 0; + v1->uMemoryBuffersSizes[v2] = 0; + *(char *)v3 = 0; + ++v2; + v3 += 12; + } + while ( v2 < 6000 ); + v1->uDumpsCount = 0; +} + + +//----- (0042654C) -------------------------------------------------------- +bool Allocator::CreateFileDump(const char *a1) +{ + Allocator *v2; // esi@1 + unsigned int v3; // ST44_4@1 + FILE *v4; // eax@1 + FILE *v5; // edi@1 + bool result; // eax@2 + unsigned int v7; // ecx@5 + int v8; // edx@5 + int v9; // eax@6 + int v10; // eax@8 + int v11; // ecx@8 + signed int v12; // ebx@8 + signed int v13; // ebx@10 + struct _MEMORYSTATUS memstat; // [sp+8h] [bp-38h]@5 + char Filename[20]; // [sp+28h] [bp-18h]@1 + unsigned int *v16; // [sp+3Ch] [bp-4h]@11 + int a1a; // [sp+48h] [bp+8h]@11 + + v2 = this; + v3 = this->uDumpsCount; + this->uDumpsCount = v3 + 1; + sprintf(Filename, "Mem%03i.txt", v3); + v4 = fopen(Filename, "w"); + v5 = v4; + if ( v4 ) + { + if ( a1 ) + fprintf(v4, "%s\n\n", a1); + fprintf(v5, "Windows Memory Status"); + GlobalMemoryStatus(&memstat); + fprintf(v5, "dwLength: %d\n\n", memstat.dwLength); + fprintf(v5, "dwMemoryLoad: %d\n", memstat.dwMemoryLoad); + fprintf(v5, "dwTotalPhys: %d\n", memstat.dwTotalPhys); + fprintf(v5, "dwAvailPhys: %d\n", memstat.dwAvailPhys); + fprintf(v5, "dwTotalPageFile: %d\n", memstat.dwTotalPageFile); + fprintf(v5, "dwAvailPageFile: %d\n", memstat.dwAvailPageFile); + fprintf(v5, "dwTotalVirtual: %d\n", memstat.dwTotalVirtual); + fprintf(v5, "dwAvailVirtual: %d\n\n\n", memstat.dwAvailVirtual); + v7 = v2->uNumBuffersUsed; + v8 = 0; + if ( (signed int)v7 > 0 ) + { + v9 = (int)v2->uMemoryBuffersSizes; + do + { + v8 += *(int *)v9; + v9 += 4; + --v7; + } + while ( v7 ); + } + v10 = 0; + v11 = (int)v2->uMemoryBuffersSizes; + v12 = 6000; + do + { + v10 += *(int *)v11; + v11 += 4; + --v12; + } + while ( v12 ); + fprintf(v5, "Size: %i %i %i\n\n", v2->uNumBuffersUsed, v8, v10); + v13 = 0; + if ( (signed int)v2->uNumBuffersUsed > 0 ) + { + v16 = v2->uMemoryBuffersSizes; + a1a = (int)v2->pMemoryBuffersNames; + do + { + fprintf(v5, "%10i %10i %s\n", v13, *v16, a1a); + a1a += 12; + ++v16; + ++v13; + } + while ( v13 < (signed int)v2->uNumBuffersUsed ); + } + fclose(v5); + result = 0; + } + else + { + result = 1; + } + return result; +} + + + + + + + + +//----- (00426892) -------------------------------------------------------- +static void __fastcall CheckMemoryAccessibility(void *pBase, DWORD uSize) +{ + DWORD v2; // edi@1 + DWORD i; // eax@1 + struct _SYSTEM_INFO SystemInfo; // [sp+8h] [bp-24h]@1 + + v2 = uSize; + GetSystemInfo(&SystemInfo); + for ( i = 16 * SystemInfo.dwPageSize; i < v2; i += SystemInfo.dwPageSize ) + ; +} + + const wchar_t *UIMessage2String(UIMessageType msg) {
--- a/mm7_1.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_1.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -26,7 +26,6 @@ #include "Overlays.h" #include "LOD.h" #include "Actor.h" -#include "Allocator.h" #include "Events.h" #include "Viewport.h" #include "SpriteObject.h"
--- a/mm7_2.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_2.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -36,7 +36,6 @@ #include "Arcomage.h" #include "LOD.h" #include "Actor.h" -#include "Allocator.h" #include "Events.h" #include "Viewport.h" #include "FrameTableInc.h" @@ -345,7 +344,7 @@ do { v6 = v5->pNext; - pAllocator->FreeChunk(v5); + free(v5); v5 = v6; } while ( v6 ); @@ -578,9 +577,6 @@ int sub_4BD8B5() { int v0; // eax@4 - int v1; // eax@29 - unsigned int v2; // esi@30 - //const char *v3; // ebx@31 if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; @@ -591,12 +587,9 @@ if ( pDialogueNPCCount ) { v0 = dialog_menu_id; - if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD - && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL - && dialog_menu_id != HOUSE_DIALOGUE_97 - && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR - && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY - && ShopTexture ) + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD && dialog_menu_id != HOUSE_DIALOGUE_SHOP_SELL + && dialog_menu_id != HOUSE_DIALOGUE_97 && dialog_menu_id != HOUSE_DIALOGUE_SHOP_REPAIR + && dialog_menu_id != HOUSE_DIALOGUE_SHOP_IDENTIFY && ShopTexture ) { ShopTexture->Release(); v0 = dialog_menu_id; @@ -645,23 +638,17 @@ dialog_menu_id = HOUSE_DIALOGUE_NULL; pDialogueWindow = 0; pIcons_LOD->SyncLoadedFilesCount(); - v1 = uNumDialogueNPCPortraits; if ( uNumDialogueNPCPortraits != 1 ) { - v2 = 0; pBtn_ExitCancel = window_SpeakInHouse->pControlsHead; if ( uNumDialogueNPCPortraits > 0 ) { - //v3 = byte_591180; - do + for ( uint i = 0; i < (unsigned int)uNumDialogueNPCPortraits; ++i ) { - dword_5913F4[v2] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[v1 - 1][v2], pNPCPortraits_y[v1 - 1][v2], - 0x3Fu, 0x49u, 1, 0, UIMSG_ClickHouseNPCPortrait, v2, 0, byte_591180[v2].data(), 0, 0, 0); - v1 = uNumDialogueNPCPortraits; - ++v2; - //v3 += 100; + HouseNPCPortraitsButtonsList[i] = window_SpeakInHouse->CreateButton(pNPCPortraits_x[uNumDialogueNPCPortraits - 1][i], + pNPCPortraits_y[uNumDialogueNPCPortraits - 1][i], + 63, 73, 1, 0, UIMSG_ClickHouseNPCPortrait, i, 0, byte_591180[i].data(), 0, 0, 0); } - while ( (signed int)v2 < uNumDialogueNPCPortraits ); } pVideoPlayer->_4BF5B2(); return 1; @@ -792,7 +779,7 @@ if ( pRenderer->pRenderD3D ) pRenderer->pBeforePresentFunction(); pRenderer->_49F1BC("MM7_Win.Pcx"); - pAllocator->FreeChunk(pFont); + free(pFont); window_SpeakInHouse->Release(); window_SpeakInHouse = 0; if ( v15 == (void *)2 ) @@ -2077,7 +2064,7 @@ } //----- (00452442) -------------------------------------------------------- -unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4) +unsigned int __fastcall _452442_color_cvt(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4) { int v4; // ebx@0 __int16 v5; // ST14_2@1 @@ -2370,7 +2357,7 @@ int item_counter; if ( pMapStatsTXT_Raw ) - pAllocator->FreeChunk(pMapStatsTXT_Raw); + free(pMapStatsTXT_Raw); pMapStatsTXT_Raw = NULL; pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); strtok(pMapStatsTXT_Raw, "\r"); @@ -2707,7 +2694,7 @@ int item_counter; if ( pHostileTXT_Raw ) - pAllocator->FreeChunk(pHostileTXT_Raw); + free(pHostileTXT_Raw); pHostileTXT_Raw = NULL; pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); strtok(pHostileTXT_Raw, "\r"); @@ -2744,7 +2731,7 @@ } if ( pHostileTXT_Raw) { - pAllocator->FreeChunk(pHostileTXT_Raw); + free(pHostileTXT_Raw); pHostileTXT_Raw = NULL; } } @@ -3769,7 +3756,7 @@ } //----- (00464479) -------------------------------------------------------- -void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() +void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() { int v0; // esi@9 @@ -3789,7 +3776,7 @@ if (uCurrentlyLoadedLevelType == LEVEL_Indoor) pIndoor->Release(); else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Release2(); + pOutdoor->Release(); pAudioPlayer->StopChannels(-1, -1); pSoundList->_4A9D79(0); @@ -3817,21 +3804,16 @@ } //----- (00464761) -------------------------------------------------------- -void Game_DeinitializeAndTerminate(int exitCode) +void Game_DeinitializeAndTerminate(int exitCode) { - int v1; // esi@1 - HANDLE v2; // eax@1 - - v1 = exitCode; - v2 = GetCurrentProcess(); - SetPriorityClass(v2, 0x20u); + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); pGame->Deinitialize(); pRenderer->Release2(); if ( !DestroyWindow(hWnd) ) GetLastError(); hWnd = 0; - exit(v1); + exit(exitCode); } //----- (004647AB) -------------------------------------------------------- @@ -3852,13 +3834,13 @@ // 6BE3A0: using guessed type float flt_6BE3A0; //----- (00464839) -------------------------------------------------------- -char Is_out15odm_underwater() +char Is_out15odm_underwater() { return _stricmp(pCurrentMapName, "out15.odm") == 0; } //----- (00464851) -------------------------------------------------------- -void SetUnderwaterFog() +void SetUnderwaterFog() { day_fogrange_1 = 50; day_fogrange_2 = 5000; @@ -3901,7 +3883,7 @@ if ( !_stricmp(pCurrentMapName, "out15.odm") ) { bUnderwater = true; - pGame->uFlags2 |= 8u; + pGame->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY; } pParty->floor_face_pid = 0; if ( _stricmp(Str1, "blv") ) @@ -3912,7 +3894,7 @@ _461103_load_level_sub(); if ( !_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv") ) { - //spawning grounds & good analogue - no loot & exp from monsters + //spawning grounds & walls of mist - no loot & exp from monsters for (uint i = 0; i < uNumActors; ++i) { @@ -4528,15 +4510,6 @@ return false; } } - - pAllocator = Allocator::Create(); - if (!pAllocator->Initialize(48 * 1024)) - { - MessageBoxW(nullptr, - L"Unable to Allocate 48Mb of RAM", - L"More RAM Memory Required", MB_ICONEXCLAMATION); - return false; - } game_starting_year = 1168; @@ -4993,6 +4966,7 @@ void IntegrityTest() { + assert(sizeof(MovieHeader) == 44); assert(sizeof(SoundDesc_mm6) == 112); assert(sizeof(SoundDesc) == 120); assert(sizeof(OverlayDesc) == 8);
--- a/mm7_3.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_3.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -28,7 +28,6 @@ #include "Overlays.h" #include "LOD.h" #include "Actor.h" -#include "Allocator.h" #include "Events.h" #include "Viewport.h" #include "Math.h" @@ -5505,14 +5504,14 @@ //int v13; // [sp+8Ch] [bp-4h]@11 pFilename = pLevelFilename; - thisa->AllocSoftwareDrawBuffers(); + //thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); if ( qword_A750D8 ) - qword_A750D8 = 0i64; + qword_A750D8 = 0; v2 = pMapStats->GetMapInfo(pCurrentMapName); v3 = 0; if ( v2 ) @@ -6322,7 +6321,7 @@ int decode_step; if ( p2DEventsTXT_Raw ) - pAllocator->FreeChunk(p2DEventsTXT_Raw); + free(p2DEventsTXT_Raw); p2DEventsTXT_Raw = NULL; p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); strtok(p2DEventsTXT_Raw, "\r");
--- a/mm7_4.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_4.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -24,7 +24,6 @@ #include "IndoorCamera.h" #include "LOD.h" #include "Actor.h" -#include "Allocator.h" #include "Events.h" #include "Viewport.h" #include "FrameTableInc.h" @@ -397,38 +396,12 @@ } //----- (00487DA9) -------------------------------------------------------- -void sub_487DA9() +void sub_487DA9() { for (int i = 0; i < 20000; ++i) array_77EC08[i].field_108 = 0; } -//----- (00487DBE) -------------------------------------------------------- -void Software_ResetNewEdges() -{ - int v0; // ecx@1 - Edge **v1; // eax@1 - signed int v2; // eax@3 - - v0 = 0; - v1 = ptr_80CA10.data(); - do - { - ++v0; - *((int *)&pNewEdges[v0] - 9) = (int)&defaultEdge; - *v1 = 0; - ++v1; - } - while ( (signed int)v1 < (signed int)&unk_80D190 ); - v2 = 2000; - do - { - pSurfs->field_22 = 0; - --v2; - } - while ( v2 ); -} - //----- (0048A959) -------------------------------------------------------- unsigned int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace) { @@ -1571,7 +1544,7 @@ assert(uNumFrames); assert(!num_mm8_frames); - pFrames = (PlayerFrame *)pAllocator->AllocNamedChunk(pFrames, uNumFrames * sizeof(PlayerFrame), "P Frames"); + pFrames = (PlayerFrame *)malloc(uNumFrames * sizeof(PlayerFrame)); memcpy(pFrames, (char *)data_mm7 + 4, num_mm7_frames * sizeof(PlayerFrame)); memcpy(pFrames + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(PlayerFrame)); memcpy(pFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(PlayerFrame)); @@ -1634,7 +1607,7 @@ v4 = v25; } v2->uNumFrames = v4; - v5 = pAllocator->AllocNamedChunk(v2->pFrames, 10 * v4, "P Frames"); + v5 = malloc(10 * v4); v2->pFrames = (PlayerFrame *)v5; if ( !v5 ) Error("PlayerFrameTable::load - Out of Memory!"); @@ -3376,7 +3349,7 @@ //----- (004B3FE5) -------------------------------------------------------- -void __fastcall sub_4B3FE5(int a4) +void __fastcall _4B3FE5_training_dialogue(int a4) { int v1; // edi@1 char *v2; // edi@1 @@ -3612,7 +3585,7 @@ case DIALOGUE_24: npc_event_id = speakingNPC->evt_F; break; } if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) - sub_4B3FE5(npc_event_id); //200-310 + _4B3FE5_training_dialogue(npc_event_id); //200-310 else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) { //400-410 dword_F8B1D8 = newDialogueType;
--- a/mm7_5.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_5.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -4920,7 +4920,7 @@ int v7; // eax@7 //unsigned __int16 v8; // ax@10 int v9; // edi@10 - int v10; // eax@10 + //int v10; // eax@10 //int v11; // edx@13 //LONG v12; // edx@23 //signed int v13; // edx@23 @@ -4939,12 +4939,12 @@ int v26; // eax@84 ItemGen *v27; // esi@98 //unsigned int v28; // eax@98 - ItemGen *v29; // edi@98 - unsigned int v30; // ecx@103 + //ItemGen *v29; // edi@98 + //unsigned int v30; // ecx@103 double v31; // st7@112 - unsigned __int64 v32; // qax@113 + //unsigned __int64 v32; // qax@113 //unsigned int v33; // ecx@117 - int v34; // eax@126 + //int v34; // eax@126 //unsigned int v35; // ecx@127 double v36; // st7@132 signed __int64 v37; // qax@135 @@ -4957,7 +4957,7 @@ //unsigned int pY; // [sp+60h] [bp-30h]@2 int v45; // [sp+64h] [bp-2Ch]@10 //unsigned int pX; // [sp+68h] [bp-28h]@2 - int v47; // [sp+6Ch] [bp-24h]@25 + //int v47; // [sp+6Ch] [bp-24h]@25 //POINT y; // [sp+70h] [bp-20h]@2 POINT a2; // [sp+78h] [bp-18h]@2 //Vec3_int_ pOut; // [sp+80h] [bp-10h]@2 @@ -5016,14 +5016,110 @@ v9 = alchemy_level & 0x3F; //v45 = alchemy_level & 0x3F; int alchemy_skill = SkillToMastery(alchemy_level); - v10 = item_pid; - if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) + + auto item = &player->pInventoryItemList[item_pid]; + if (pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE) { -LABEL_116: - GameUI_DrawItemInfo(&player->pInventoryItemList[v10]); +__show_item_desc: + GameUI_DrawItemInfo(item); return; } + if (pParty->pPickedItem.uItemID == ITEM_POTION_RECHARGE_ITEM) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant recharge bottle + item->uItemID < ITEM_POTION_CATALYST && // cant recharge + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_WAND) // can recharge only wands + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + + v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; + if ( v36 < 0.0 ) + v36 = 0.0; + v37 = (signed __int64)((double)item->uMaxCharges - v36 * (double)item->uMaxCharges); + item->uMaxCharges = v37; + item->uNumCharges = v37; + + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = 1; + return; + } + goto __show_item_desc; + } + + else if (pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant harden bottle + item->uItemID < ITEM_POTION_CATALYST && // cant harden + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (item->IsBroken() || // cant harden broken items + item->uItemID >= ITEM_ARTIFACT_PUCK || // cant harden artifacts + pItemsTable->pItems[item->uItemID].uEquipType < EQUIP_OFF_HAND || + pItemsTable->pItems[item->uItemID].uEquipType > EQUIP_WAND) + goto __invalid_item; + + item->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED; + + _50C9A8_item_enchantment_timer = 256; + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; + } + goto __show_item_desc; + } + + else if (pParty->pPickedItem.uItemID >= ITEM_POTION_FLAMING_POTION && + pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION || + pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) + { + if (item->uItemID != ITEM_POTION_BOTTLE && // cant enchant bottle + item->uItemID < ITEM_POTION_CATALYST && // cant enchant + item->uItemID > ITEM_POTION_REJUVENATION) // all potions + { + if (item->uItemID >= ITEM_BLASTER && item->uItemID <= ITEM_LASER_RIFLE || + item->uItemID >= ITEM_ARTIFACT_PUCK || + item->IsBroken() || + item->uSpecEnchantmentType || + item->uEnchantmentType || + pItemsTable->pItems[item->uItemID].uEquipType >= EQUIP_ARMOUR) // only melee weapons and bows + goto __invalid_item; + + item->UpdateTempBonus(pParty->uTimePlayed); + if (pParty->pPickedItem.uItemID == ITEM_POTION_SLAYING_POTION) + { + item->uSpecEnchantmentType = 40; // of Slaying + v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); + } + else + { + static int _4E2904_enchantment_by_potion_lut[] = + { + 164, 93, 22, + 164, 93, 22, + 11, 5, 13, 7, 59 + }; + item->uSpecEnchantmentType = _4E2904_enchantment_by_potion_lut[pParty->pPickedItem.uItemID - 240]; + v31 = (double)(1800 * pParty->pPickedItem.uEnchantmentType * 128); + } + + v27->uExpireTime = pParty->uTimePlayed + v31 * 0.033333335; + v27->uAttributes = alchemy_skill | 0x18; + + _50C9A8_item_enchantment_timer = 256; + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; + } + goto __show_item_desc; + } + + + if (pParty->pPickedItem.uItemID < ITEM_REAGENT_WIDOWSWEEP_BERRIES || pParty->pPickedItem.uItemID > ITEM_REAGENT_PHILOSOPHERS_STONE || player->pInventoryItemList[item_pid].uItemID != ITEM_POTION_BOTTLE) @@ -5031,127 +5127,40 @@ if (pParty->pPickedItem.uItemID < ITEM_POTION_CATALYST || pParty->pPickedItem.uItemID > ITEM_POTION_REJUVENATION || player->pInventoryItemList[item_pid].uItemID < ITEM_POTION_CATALYST || - player->pInventoryItemList[item_pid].uItemID >= ITEM_POTION_REJUVENATION) + player->pInventoryItemList[item_pid].uItemID > ITEM_POTION_REJUVENATION) { if (pParty->pPickedItem.uItemID != ITEM_POTION_HARDEN_ITEM && (pParty->pPickedItem.uItemID < ITEM_POTION_FLAMING_POTION || pParty->pPickedItem.uItemID > ITEM_POTION_SWIFT_POTION) && pParty->pPickedItem.uItemID != ITEM_POTION_SLAYING_POTION && pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM) - goto LABEL_116; + goto __show_item_desc; + } + + // src not reagent, dst not bottle + // src potion, dst potion - int a2_y; - v27 = &player->pInventoryItemList[item_pid]; - v51 = pItemsTable->pItems[v27->uItemID].uEquipType; - v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); - if ( pParty->pPickedItem.uItemID != ITEM_POTION_RECHARGE_ITEM ) - { - if ( pParty->pPickedItem.uItemID == ITEM_POTION_HARDEN_ITEM ) - { - if (v27->IsBroken() || v51 < EQUIP_OFF_HAND || v51 > EQUIP_WAND || v27->uItemID >= ITEM_ARTIFACT_PUCK ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = true; - return; - } - v27->uAttributes |= ITEM_AURA_EFFECT_RED | ITEM_ENCHANTED; - } - else - { - if (pParty->pPickedItem.uItemID <= ITEM_POTION_ACCURACY_BOOST ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = true; - return; - } - if (pParty->pPickedItem.uItemID <= ITEM_POTION_SWIFT_POTION) - { - v27->UpdateTempBonus(pParty->uTimePlayed); - if ( (signed int)v27->uItemID >= 64 && (signed int)v27->uItemID <= 65 - || (alchemy_skill = v27->uAttributes, alchemy_skill & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v27->uItemID >= 500 ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; - a2_y = (int)v29 << 7; - v31 = (double)(signed int)((int)v29 << 7); - v27->uSpecEnchantmentType = v34; - } - else - { - if ( pParty->pPickedItem.uItemID != 263 - || (v27->UpdateTempBonus(pParty->uTimePlayed), v30 = v27->uItemID, (signed int)v27->uItemID >= 64) - && (signed int)v30 <= 65 - || (alchemy_skill = v27->uAttributes, alchemy_skill & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v30 >= 500 ) - { - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - a2_y = (int)v29 << 7; - v27->uSpecEnchantmentType = 40; - v31 = (double)a2_y; - } - v32 = pParty->uTimePlayed + (signed int)(signed __int64)(v31 * 0.033333335); - LODWORD(v27->uExpireTime) = v32; - LODWORD(v32) = alchemy_skill; - LOBYTE(v32) = LOBYTE(alchemy_skill) | 0x18; - HIDWORD(v27->uExpireTime) = HIDWORD(v32); - v27->uAttributes = v32; - } - _50C9A8_item_enchantment_timer = 256; - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; - if ( v36 < 0.0 ) - v36 = 0.0; - if ( v51 != 12 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - a2_y = v27->uMaxCharges; - v37 = (signed __int64)((double)a2_y - v36 * (double)a2_y); - v27->uMaxCharges = v37; - v27->uNumCharges = (unsigned __int8)v37; - pMouse->RemoveHoldingItem(); - no_rightlick_in_inventory = 1; - return; - } - v14 = player->pInventoryItemList[item_pid].uItemID - 222; - v15 = pParty->pPickedItem.uItemID - 222; - v47 = v14; + v14 = item->uItemID - ITEM_POTION_CURE_WOUNDS; + v15 = pParty->pPickedItem.uItemID - ITEM_POTION_CURE_WOUNDS; - if ( pParty->pPickedItem.uItemID == 221 || player->pInventoryItemList[item_pid].uItemID == 221 ) + if ( pParty->pPickedItem.uItemID == ITEM_POTION_CATALYST || + item->uItemID == ITEM_POTION_CATALYST ) { v16 = 5; } else { - v16 = *(short *)&pItemsTable->field_EDE0[2 * (v14 + 50 * v15) + 388]; - v10 = item_pid; + v16 = pItemsTable->potion_data[v15][v14 + 2]; } v51 = v16; if ( v9 ) { - if ( v16 < 225 || v16 > 227 ) + if ( v16 < ITEM_POTION_CURE_DISEASE || v16 > ITEM_POTION_AWAKEN ) { - if ( v16 < 228 || v16 > 239 ) + if ( v16 < ITEM_POTION_HASTE || v16 > ITEM_POTION_CURE_INSANITY ) { - if ( v16 < 240 || v16 > 261 ) + if ( v16 < ITEM_POTION_MIGHT_BOOST || v16 > ITEM_POTION_BODY_RESISTANE ) { - if ( v16 >= 262 && alchemy_level != 4 ) + if ( v16 >= ITEM_POTION_STONE_TO_FLESH && alchemy_level != 4 ) { LABEL_53: v51 = 4; @@ -5181,21 +5190,21 @@ } else { - if ( v16 >= 225 && v16 <= 227 ) + if ( v16 >= ITEM_POTION_CURE_DISEASE && v16 <= ITEM_POTION_AWAKEN ) { v51 = 1; goto LABEL_54; } - if ( v16 >= 228 && v16 <= 239 ) + if ( v16 >= ITEM_POTION_HASTE && v16 <= ITEM_POTION_CURE_INSANITY ) goto LABEL_35; - if ( v16 >= 240 && v16 <= 261 ) + if ( v16 >= ITEM_POTION_MIGHT_BOOST && v16 <= ITEM_POTION_BODY_RESISTANE ) goto LABEL_38; - if ( v16 >= 262 ) + if ( v16 >= ITEM_POTION_STONE_TO_FLESH ) goto LABEL_53; } LABEL_54: int pOut_y = 0; - int pOut_x = v10 + 1; + int pOut_x = item_pid + 1; v17 = (int)player->pInventoryMatrix; while ( *(int *)v17 != pOut_x ) { @@ -5210,11 +5219,7 @@ v18 = pOut_y; LABEL_59: if ( !v51 ) - { -LABEL_115: - v10 = item_pid; - goto LABEL_116; - } + goto __show_item_desc;; if ( v51 == 1 ) { player->RemoveItemAtInventoryIndex(v18); @@ -5254,7 +5259,7 @@ if ( v19 ) // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; player->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED; - v20 = v47 + 50 * v15; + v20 = v14 + 50 * v15; player->pInventoryItemList[item_pid].uItemID = v51; player->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType + player->pInventoryItemList[item_pid].uEnchantmentType) @@ -5288,7 +5293,7 @@ player->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; goto LABEL_74; } - goto LABEL_115; + goto __show_item_desc; } player->RemoveItemAtInventoryIndex(v18); player->SetCondition(0x10u, 0); @@ -5320,6 +5325,8 @@ return; } + // end alchemy + player->pInventoryItemList[item_pid].uEnchantmentType = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; switch ( pParty->pPickedItem.uItemID ) { @@ -5361,6 +5368,13 @@ player->PlaySound(SPEECH_16, 0); dword_4E455C = 0; } + return; + + +__invalid_item: + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; } //----- (00417AD4) --------------------------------------------------------
--- a/mm7_data.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_data.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -374,7 +374,7 @@ char aPending[777]; // idb char aCanTFindS[777]; // idb -std::array<char, 7> aSbwb00; // weak +//std::array<char, 7> aSbwb00; // weak char aW[2]; // idb char aA[2]; // idb char aSD[777]; // idb @@ -1043,7 +1043,7 @@ int dword_59117C_teleportx; // weak std::array<std::array<char, 100>, 6> byte_591180; // idb std::array<struct NPCData *, 7> HouseNPCData;//0 zero element holds standart house npc -GUIButton* dword_5913F4[6]; +GUIButton* HouseNPCPortraitsButtonsList[6];//dword_5913F4 struct Texture *pTexture_591428; struct Texture *pTexture_outside; // idb struct Texture *pTexture_Dialogue_Background; @@ -1309,13 +1309,6 @@ int dword_80AA20; // weak unsigned int uNumElementsIn80AA28; std::array<struct Polygon *, 2000> ptr_80AA28; -struct Edge *pNewEdges; -struct Surf *pSurfs; -struct Edge *pEdges; -struct Span *pSpans; -struct Edge *ptr_80C978_Edges; -struct Surf *ptr_80C97C_Surfs; -std::array<struct Edge *, 480> ptr_80CA10; _UNKNOWN unk_80D190; // weak int dword_A74C88; // weak unsigned int uPlayerCreationUI_SkySliderPos;
--- a/mm7_data.h Thu Sep 12 09:55:20 2013 +0200 +++ b/mm7_data.h Thu Sep 12 09:58:07 2013 +0200 @@ -334,7 +334,7 @@ extern __int16 word_4E1D3A[]; // weak -extern std::array<char, 7> aSbwb00; // weak +//extern std::array<char, 7> aSbwb00; // weak extern char aW[2]; // idb extern char aA[2]; // idb extern char aSD[]; // idb @@ -693,7 +693,7 @@ extern int dword_59117C_teleportx; // weak extern std::array<std::array<char, 100>, 6> byte_591180; // idb extern std::array<struct NPCData *, 7> HouseNPCData; //0this array size temporarily increased to 60 from 6 to work aroud house overflow -extern GUIButton* dword_5913F4[6]; +extern GUIButton* HouseNPCPortraitsButtonsList[6]; extern struct Texture *pTexture_591428; extern struct Texture *pTexture_outside; // idb extern struct Texture *pTexture_Dialogue_Background; @@ -969,13 +969,6 @@ extern int dword_80AA20; // weak extern unsigned int uNumElementsIn80AA28; extern std::array<struct Polygon *, 2000> ptr_80AA28; -extern struct Edge *pNewEdges; -extern struct Surf *pSurfs; -extern struct Edge *pEdges; -extern struct Span *pSpans; -extern struct Edge *ptr_80C978_Edges; -extern struct Surf *ptr_80C97C_Surfs; -extern std::array<struct Edge *, 480> ptr_80CA10; extern _UNKNOWN unk_80D190; // weak extern int dword_A74C88; // weak extern unsigned int uPlayerCreationUI_SkySliderPos; @@ -1147,7 +1140,6 @@ int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4); void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); void sub_43B1B0(signed int a1, unsigned int a2, struct Vec3_int_ *pVelocity, signed int a4); -void Software_ResetNewEdges(); void CharacterUI_LoadPaperdollTextures(); int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder); bool _43ED6F_check_party_races(bool b); @@ -1230,7 +1222,7 @@ void FillAviableSkillsToTeach(int _this); void sub_4B3E1E(); void DrawJoinGuildWindow(int pEventCode); -void __fastcall sub_4B3FE5(int a4); +void __fastcall _4B3FE5_training_dialogue(int a4); void NPCHireableDialogPrepare(); void _4B4224_UpdateNPCTopics(int _this); void __fastcall DrawTextAtStatusBar(const char *Str, int a5); @@ -1372,7 +1364,6 @@ void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int GetAlertStatus(); -unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); int integer_sqrt(int val); int __fastcall MakeColorMaskFromBitDepth(int a1); void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels);
--- a/texts.cpp Thu Sep 12 09:55:20 2013 +0200 +++ b/texts.cpp Thu Sep 12 09:58:07 2013 +0200 @@ -3,7 +3,6 @@ #endif #include <string.h> -#include "Allocator.h" #include "LOD.h" #include "mm7_data.h" #include "texts.h" @@ -80,7 +79,7 @@ bool string_end; // [sp+14h] [bp-4h]@4 //v0 = 0; if (pGlobalTXT_Raw) - pAllocator->FreeChunk(pGlobalTXT_Raw); + free(pGlobalTXT_Raw); pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0); /* strtok(pGlobalTXT_Raw, "\r");