Mercurial > mm7
changeset 1590:5792fdafe2f5
Слияние
author | Ritor1 |
---|---|
date | Wed, 11 Sep 2013 09:39:09 +0600 |
parents | f408fbf3d9cc (current diff) e42073046f92 (diff) |
children | d687f6e7c610 |
files | Allocator.cpp Allocator.h GUIWindow.cpp NPC.cpp UI/UIHouses.cpp mm7_2.cpp mm7_data.cpp mm7_data.h |
diffstat | 55 files changed, 1226 insertions(+), 1514 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/Actor.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ /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 Wed Sep 11 09:23:41 2013 +0600 +++ /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 Wed Sep 11 09:23:41 2013 +0600 +++ b/AudioPlayer.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/BSPModel.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Chest.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/DecorationList.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Events.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/GUIWindow.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 ); @@ -1496,7 +1495,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;
--- a/IconFrameTable.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/IconFrameTable.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Indoor.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Items.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Items.h Wed Sep 11 09:39:09 2013 +0600 @@ -61,12 +61,30 @@ ITEM_WAND_FIRE = 135, ITEM_WAND_STUN = 138, ITEM_WAND_INCENERATION = 0x9F, + ITEM_REAGENT_WIDOWSWEEP_BERRIES = 200, ITEM_TROLL_BLOOD = 0xCA, ITEM_DRAGON_EYE = 0xCC, ITEM_HARPY_FEATHER = 0xCF, ITEM_DEVIL_ICHOR = 0xD6, ITEM_OOZE_ECTOPLASM_BOTTLE = 0xD9, - ITEM_POTION_BOTTLE = 0xDC, + 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 ITEM_SPELLBOOK_FIRE_STRIKE = 401,//0x191, ITEM_SPELLBOOK_AIR_FEATHER_FALL = 0x19C,
--- a/LOD.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/LOD.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Log.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Monsters.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/NPC.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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; }
--- a/ObjectList.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/ObjectList.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Outdoor.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Outdoor.h Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/OutdoorCamera.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/OutdoorCamera.h Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Overlays.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Render.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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; } @@ -6701,8 +6699,11 @@ auto ecx0 = this; v3 = 0; - if ( ecx0->pRenderD3D ) - { + + if (!this->pRenderD3D) + __debugbreak(); // sw render + + //{ v4 = a3; if ( a3 <= 1.0 ) { @@ -6713,6 +6714,7 @@ { v4 = 1.0; } + __debugbreak(); // banker's rounding again a3 = v4 * 255.0; v39 = a3 + 6.7553994e15; LODWORD(v40) = LODWORD(v39); @@ -6774,7 +6776,7 @@ ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); - } + /*} else { v40 = (1.0 - a3) * 65536.0; @@ -6800,7 +6802,7 @@ if ( pRenderer->uTargetGBits == 6 ) { - v17 = _42690D_colors_cvt(this_); + v17 = sr_42690D_colors_cvt(this_); v18 = (65536 - LODWORD(a3)) * (v17 & 0x1F); this_ = (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (unsigned __int16)(v17 & 0xF800) & 0xF800FFFF | v18 & 0x1F0000 | (65536 - LODWORD(a3)) * (v17 & 0x7E0) & 0x7E00000u) >> 16); v19 = v40; @@ -6831,7 +6833,7 @@ } else { - v24 = _4268E3_smthn_to_a1r5g5b5(this_); + v24 = sr_4268E3_smthn_to_a1r5g5b5(this_); v25 = (65536 - LODWORD(a3)) * (v24 & 0x1F); this_ = (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16 << 16) | (((65536 - LODWORD(a3)) * (v24 & 0x7C00) & 0x7C000000 | v25 & 0x1F0000 | (65536 - LODWORD(a3)) * (v24 & 0x3E0) & 0x3E00000u) >> 16); @@ -6860,7 +6862,7 @@ } while ( v32 != 1 ); } - } + }*/ return result; } @@ -8490,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 @@ -8565,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; @@ -8596,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); @@ -8610,13 +8609,6 @@ pTex->pPixels = v26; } return pTex; - //result = pTex; -// } -// else -// { -//LABEL_8: -// return nullptr; -// } } //----- (0045271F) -------------------------------------------------------- @@ -8664,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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Render.h Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/SaveLoad.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Spells.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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/SpriteObject.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/SpriteObject.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -82,11 +82,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; - pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; - pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); } else { @@ -107,11 +107,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; - pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; - pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); } else { @@ -132,11 +132,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; - pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; - pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)) >> 16; + a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); } else { @@ -157,11 +157,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; - pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; - pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); } else { @@ -182,11 +182,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; - pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; - pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); } else { @@ -331,9 +331,9 @@ if ( !(v2->uFlags & OBJECT_DESC_BOUNCE) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) ) v1->vVelocity.z = 0; - v1->vVelocity.x = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.x) >> 16); - v1->vVelocity.y = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.y) >> 16); - v1->vVelocity.z = (signed __int16)((unsigned __int64)(58500i64 * (signed __int64)(signed int)v1->vVelocity.z) >> 16); + v1->vVelocity.x = fixpoint_sub0(58500, v1->vVelocity.x); + v1->vVelocity.y = fixpoint_sub0(58500, v1->vVelocity.y); + v1->vVelocity.z = fixpoint_sub0(58500, v1->vVelocity.z); if ( (v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x) < 400 ) { @@ -620,12 +620,12 @@ int v18; // eax@52 int v19; // ecx@52 Vec3_short_ *v20; // ecx@53 - int v21; // ecx@57 + //int v21; // ecx@57 __int16 v22; // ax@57 int v23; // edi@62 - int v24; // edi@62 - int v25; // eax@62 - unsigned __int64 v26; // qax@62 + //int v24; // edi@62 + //int v25; // eax@62 + //unsigned __int64 v26; // qax@62 unsigned __int8 v27; // sf@64 unsigned __int8 v28; // of@64 __int16 v29; // di@67 @@ -641,7 +641,7 @@ int v39; // [sp+80h] [bp-10h]@33 Actor *v39b; int v40; // [sp+84h] [bp-Ch]@28 - int v41; // [sp+88h] [bp-8h]@34 + //int v41; // [sp+88h] [bp-8h]@34 int v42; // [sp+8Ch] [bp-4h]@4 //uLayingItemID_ = uLayingItemID; @@ -791,7 +791,7 @@ pSpriteObject->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16; pSpriteObject->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); - pSpriteObject->uSectorID = LOWORD(stru_721530.uSectorID); + pSpriteObject->uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) return; @@ -801,15 +801,8 @@ v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y); v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x, pSpriteObject->vPosition.y - pLevelDecorations[v15].vPosition.y); - v42 = stru_5C6E00->Cos(v23); - v41 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; - v24 = v23; - pSpriteObject->vVelocity.x = (unsigned int)(v42 * v40) >> 16; - v25 = stru_5C6E00->Sin(v23); - v42 = v25; - v26 = v25 * (signed __int64)v40; - v41 = v26 >> 16; - pSpriteObject->vVelocity.y = WORD1(v26); + pSpriteObject->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v23), v40); + pSpriteObject->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v23), v40); } else { @@ -823,25 +816,17 @@ + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16; if ( (stru_721530.speed >> 3) > v42 ) v42 = stru_721530.speed >> 3; - v40 = v16->pFacePlane_old.vNormal.x; - v40 = (unsigned __int64)(v42 * (signed __int64)v40) >> 16; - v41 = v16->pFacePlane_old.vNormal.y; - v41 = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; - v39 = v16->pFacePlane_old.vNormal.z; - v39 = (unsigned __int64)(v42 * (signed __int64)v39) >> 16; - pSpriteObject->vVelocity.x += 2 * v40; - pSpriteObject->vVelocity.y += 2 * v41; + pSpriteObject->vVelocity.x += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.x); + pSpriteObject->vVelocity.y += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.y); + v39 = fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.z); if ( v16->pFacePlane_old.vNormal.z <= 32000 ) { v22 = 2 * v39; } else { - v21 = v39; - v40 = 32000; pSpriteObject->vVelocity.z += v39; - v41 = (unsigned __int64)(v40 * (signed __int64)v21) >> 16; - v22 = (unsigned int)(v40 * v21) >> 16; + v22 = fixpoint_sub0(32000, v39); } pSpriteObject->vVelocity.z += v22; if ( BYTE3(v16->uAttributes) & 0x10 ) @@ -876,20 +861,12 @@ LABEL_63: //v2 = v37; LABEL_64: - v41 = pSpriteObject->vVelocity.x; - v40 = 58500; - v41 = (unsigned __int64)(58500i64 * v41) >> 16; - pSpriteObject->vVelocity.x = v41; - v41 = pSpriteObject->vVelocity.y; - v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; - v40 = 58500; - pSpriteObject->vVelocity.y = v41; - v41 = pSpriteObject->vVelocity.z; - v41 = (unsigned __int64)(v40 * (signed __int64)v41) >> 16; + pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z); ++uFaceID; v28 = __OFSUB__(uFaceID, 100); v27 = uFaceID - 100 < 0; - pSpriteObject->vVelocity.z = v41; if ( !(v27 ^ v28) ) return; v8 = 0; @@ -916,18 +893,10 @@ pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); v8 = 0; } - v42 = pSpriteObject->vVelocity.x; - uFaceID = 58500; - v42 = (unsigned __int64)(58500i64 * v42) >> 16; - pSpriteObject->vVelocity.x = v42; - v42 = pSpriteObject->vVelocity.y; - v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; - uFaceID = 58500; - pSpriteObject->vVelocity.y = v42; - v42 = pSpriteObject->vVelocity.z; - v42 = (unsigned __int64)(uFaceID * (signed __int64)v42) >> 16; + pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z); v9 = pSpriteObject->vVelocity.x; - pSpriteObject->vVelocity.z = v42; if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 ) { pSpriteObject->vVelocity.z = v8;
--- a/Sprites.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/Sprites.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/StorylineTextTable.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Texture.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Texture.h Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/TileTable.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/Books/UIMapBook.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/Books/UINotesBooks.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/Books/UISpellBook.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UIBooks.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UICharacter.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UIHouses.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -3797,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 @@ -3846,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 ) @@ -4112,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/UIMainMenu.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UIMainMenu.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UIPartyCreation.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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/UIPopup.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UIPopup.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -1929,7 +1929,7 @@ { case SCREEN_CASTING: { - identify_item(); + OnInventoryItemRightClick(); break; } @@ -2097,7 +2097,7 @@ { if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E ) { - identify_item(); + OnInventoryItemRightClick(); } else if ( (signed int)pY >= 345 ) break; @@ -2112,7 +2112,7 @@ else { if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )//2DEvent - CharacerScreenInventory - identify_item(); + OnInventoryItemRightClick(); } break; }
--- a/UI/UISaveLoad.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/UI/UISaveLoad.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/VideoPlayer.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/Viewport.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/_deleted.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -12319,7 +12319,6 @@ } return 0; } - //----- (0046271C) -------------------------------------------------------- void CreateDefaultBLVLevel() { @@ -12344,6 +12343,431 @@ ofn.lpTemplateName = 0; ofn.lpstrFileTitle = pTmpBuf.data(); } +//----- (004268E3) -------------------------------------------------------- +int __fastcall sr_4268E3_smthn_to_a1r5g5b5(unsigned int uColor) +{ + unsigned int v1; // eax@1 + unsigned int v2; // edx@1 + int v3; // eax@1 + int v4; // edx@1 + unsigned int v5; // ecx@1 + + v1 = uColor >> 9; + v2 = uColor >> 6; + LOWORD(v1) = (uColor >> 9) & 0x7C00; + LOWORD(v2) = (uColor >> 6) & 0x3E0; + v3 = v2 | v1; + v4 = (unsigned __int8)uColor >> 3; + v5 = uColor >> 16; + LOWORD(v5) = v5 & 0x8000; + return v5 | v4 | v3; +} +//----- (0042690D) -------------------------------------------------------- +int __fastcall sr_42690D_colors_cvt(unsigned int a1) +{ + unsigned int v1; // eax@1 + unsigned int v2; // edx@1 + + v1 = a1 >> 8; + v2 = a1 >> 5; + LOWORD(v1) = (a1 >> 8) & 0xF800; + 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 Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_1.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_2.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 ); @@ -780,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 ) @@ -2064,7 +2063,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 @@ -2357,7 +2356,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"); @@ -2694,7 +2693,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"); @@ -2731,7 +2730,7 @@ } if ( pHostileTXT_Raw) { - pAllocator->FreeChunk(pHostileTXT_Raw); + free(pHostileTXT_Raw); pHostileTXT_Raw = NULL; } } @@ -3756,7 +3755,7 @@ } //----- (00464479) -------------------------------------------------------- -void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() +void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() { int v0; // esi@9 @@ -3776,7 +3775,7 @@ if (uCurrentlyLoadedLevelType == LEVEL_Indoor) pIndoor->Release(); else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Release2(); + pOutdoor->Release(); pAudioPlayer->StopChannels(-1, -1); pSoundList->_4A9D79(0); @@ -3804,21 +3803,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(), 0x20u); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); pGame->Deinitialize(); pRenderer->Release2(); if ( !DestroyWindow(hWnd) ) GetLastError(); hWnd = 0; - exit(v1); + exit(exitCode); } //----- (004647AB) -------------------------------------------------------- @@ -3839,13 +3833,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; @@ -3888,7 +3882,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") ) @@ -3899,7 +3893,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) { @@ -4515,15 +4509,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; @@ -4980,6 +4965,7 @@ void IntegrityTest() { + assert(sizeof(MovieHeader) == 44); assert(sizeof(SoundDesc_mm6) == 112); assert(sizeof(SoundDesc) == 120); assert(sizeof(OverlayDesc) == 8);
--- a/mm7_3.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_3.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_4.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_5.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -3242,11 +3242,14 @@ } //----- (004356FF) -------------------------------------------------------- -void back_to_game() +void back_to_game() { dword_507BF0_is_there_popup_onscreen = 0; dword_4E455C = 1; - dword_50CDCC = 0; + + extern int no_rightlick_in_inventory; + no_rightlick_in_inventory = false; + if ( pGUIWindow_ScrollWindow ) free_book_subwindow(); if ( !pCurrentScreen && !pGUIWindow_Settings ) @@ -4903,23 +4906,24 @@ } +int no_rightlick_in_inventory = false; // 0050CDCC //----- (00416196) -------------------------------------------------------- -void identify_item() +void OnInventoryItemRightClick() { - Player *v0; // esi@2 - POINT *v1; // edi@2 - signed int v2; // ecx@5 - signed int v3; // eax@5 - int v4; // eax@5 - char v5; // sf@5 - int v6; // eax@5 + //Player *v0; // esi@2 + //POINT *v1; // edi@2 + //signed int v2; // ecx@5 + //signed int v3; // eax@5 + //int v4; // eax@5 + //char v5; // sf@5 + //int v6; // eax@5 int v7; // eax@7 - unsigned __int16 v8; // ax@10 + //unsigned __int16 v8; // ax@10 int v9; // edi@10 - int v10; // eax@10 - int v11; // edx@13 - LONG v12; // edx@23 - signed int v13; // edx@23 + //int v10; // eax@10 + //int v11; // edx@13 + //LONG v12; // edx@23 + //signed int v13; // edx@23 int v14; // edx@25 unsigned int v15; // edi@25 signed int v16; // edx@27 @@ -4934,213 +4938,229 @@ int v25; // eax@80 int v26; // eax@84 ItemGen *v27; // esi@98 - unsigned int v28; // eax@98 - ItemGen *v29; // edi@98 - unsigned int v30; // ecx@103 + //unsigned int v28; // eax@98 + //ItemGen *v29; // edi@98 + //unsigned int v30; // ecx@103 double v31; // st7@112 - unsigned __int64 v32; // qax@113 - unsigned int v33; // ecx@117 - int v34; // eax@126 - unsigned int v35; // ecx@127 + //unsigned __int64 v32; // qax@113 + //unsigned int v33; // ecx@117 + //int v34; // eax@126 + //unsigned int v35; // ecx@127 double v36; // st7@132 signed __int64 v37; // qax@135 - unsigned int v38; // eax@138 + //unsigned int v38; // eax@138 Vec3_int_ v39; // [sp-18h] [bp-A8h]@83 - int *v40; // [sp-Ch] [bp-9Ch]@83 - int *v41; // [sp-8h] [bp-98h]@83 - int *v42; // [sp-4h] [bp-94h]@83 + //int *v40; // [sp-Ch] [bp-9Ch]@83 + //int *v41; // [sp-8h] [bp-98h]@83 + //int *v42; // [sp-4h] [bp-94h]@83 GUIWindow v43; // [sp+Ch] [bp-84h]@137 - unsigned int pY; // [sp+60h] [bp-30h]@2 + //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 - POINT y; // [sp+70h] [bp-20h]@2 + //unsigned int pX; // [sp+68h] [bp-28h]@2 + //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 + //Vec3_int_ pOut; // [sp+80h] [bp-10h]@2 unsigned int v51; // [sp+8Ch] [bp-4h]@23 - if ( dword_50CDCC ) + if (no_rightlick_in_inventory) + return; + + if (a2.x <= 13 || a2.x >= 462) return; - v0 = pPlayers[uActiveCharacter]; - v1 = pMouse->GetCursorPos(&a2); - pOut.z = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&y)->y]] & 0xFFFF; - pMouse->GetClickPos(&pX, &pY); - if ( !pOut.z ) + + auto player = pPlayers[uActiveCharacter]; + + pMouse->GetCursorPos(&a2); + int item_pid = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; + //pMouse->GetClickPos(&pX, &pY); + if (!item_pid) { - if ( (signed int)pX <= 13 - || (signed int)pX >= 462 - || (v2 = pX - 14, - v3 = pY - 17, - pX = v2, - pY = v3, - v4 = 14 * (v3 >> 5), - v2 >>= 5, - v5 = v2 + v4 < 0, - v6 = v2 + v4, - pOut.z = v6, - v5) - || v6 > 126 - || (v7 = v0->GetItemIDAtInventoryIndex(&pOut.z)) == 0 ) + int inventory_mouse_x = a2.x - 14; + int inventory_mouse_y = a2.y - 17; + + int mouse_cell_x = inventory_mouse_x / 32; + int mouse_cell_y = inventory_mouse_y / 32; + + if (mouse_cell_x + mouse_cell_y < 0) + return; + + int inventory_idx = mouse_cell_x + 14 * mouse_cell_y; + if (inventory_idx > 126) return; - pOut.z = v7; + + v7 = player->GetItemIDAtInventoryIndex(&inventory_idx); + if (v7 == 0) + return; + + item_pid = v7; } - if ( !v0->CanAct() ) + + if (!player->CanAct()) { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], v0->pName, pGlobalTXT_LocalizationStrings[541]); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], player->pName, pGlobalTXT_LocalizationStrings[541]); v43.Hint = pTmpBuf.data(); v43.uFrameWidth = 384; v43.uFrameHeight = 180; + if (a2.x <= 320 ) + v43.uFrameX = a2.x + 30; + else + v43.uFrameX = a2.x - 414; v43.uFrameY = 40; - if ( pMouse->GetCursorPos(&a2)->x <= 320 ) - v38 = pMouse->GetCursorPos(&a2)->x + 30; - else - v38 = pMouse->GetCursorPos(&a2)->x - 414; - v43.uFrameX = v38; v43.DrawMessageBox(0); return; } - --pOut.z; - LOBYTE(v8) = v0->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY); - v9 = v8 & 0x3F; - v45 = v8 & 0x3F; - pOut.y = SkillToMastery(v8); - v10 = pOut.z; - if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) + + --item_pid; + int alchemy_level = (int8_t)player->GetActualSkillLevel(PLAYER_SKILL_ALCHEMY); + v9 = alchemy_level & 0x3F; + //v45 = alchemy_level & 0x3F; + int alchemy_skill = SkillToMastery(alchemy_level); + + auto item = &player->pInventoryItemList[item_pid]; + if (pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE) { -LABEL_116: - GameUI_DrawItemInfo(&v0->pInventoryItemList[v10]); +__show_item_desc: + GameUI_DrawItemInfo(item); return; } - if ( (signed int)pParty->pPickedItem.uItemID < 200 - || (signed int)pParty->pPickedItem.uItemID > 219 - || (v11 = (int)((char *)v0 + 36 * pOut.z), *(int *)(v11 + 532) != 220) ) + + if (pParty->pPickedItem.uItemID == ITEM_POTION_RECHARGE_ITEM) { - if ( (signed int)pParty->pPickedItem.uItemID < 221 - || (signed int)pParty->pPickedItem.uItemID > 271 - || (v12 = (LONG)((char *)v0 + 36 * pOut.z), a2.y = v12, v13 = *(int *)(v12 + 532), v51 = v13, v13 < 221) - || v13 > 271 ) + if (item->uItemID != ITEM_POTION_BOTTLE && // cant recharge bottle + item->uItemID < ITEM_POTION_CATALYST && // cant recharge + item->uItemID > ITEM_POTION_REJUVENATION) // all potions { - if ( pParty->pPickedItem.uItemID != 236 - && ((signed int)pParty->pPickedItem.uItemID < 246 || (signed int)pParty->pPickedItem.uItemID > 250) - && pParty->pPickedItem.uItemID != 263 - && pParty->pPickedItem.uItemID != 233 ) - goto LABEL_116; - v27 = &v0->pInventoryItemList[pOut.z]; - v28 = v27->uItemID; - v51 = pItemsTable->pItems[v27->uItemID].uEquipType; - v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); - if ( pParty->pPickedItem.uItemID != 233 ) - { - if ( pParty->pPickedItem.uItemID == 236 ) - { - v35 = v27->uAttributes; - if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 ) - { - pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; - return; - } - LOWORD(v35) = v35 | 0x210; - v27->uAttributes = v35; - } - else - { - if ( (signed int)pParty->pPickedItem.uItemID <= 245 ) - { - pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; - return; - } - if ( (signed int)pParty->pPickedItem.uItemID <= 250 ) - { - v27->UpdateTempBonus(pParty->uTimePlayed); - v33 = v27->uItemID; - if ( (signed int)v27->uItemID >= 64 && (signed int)v33 <= 65 - || (pOut.y = v27->uAttributes, pOut.y & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v33 >= 500 ) - { - pMouse->RemoveHoldingItem(); - dword_50CDCC = 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 - || (pOut.y = v27->uAttributes, pOut.y & 2) - || v27->uSpecEnchantmentType - || v27->uEnchantmentType - || v51 && v51 != 1 && v51 != 2 - || (signed int)v30 >= 500 ) - { - pMouse->RemoveHoldingItem(); - dword_50CDCC = 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) = pOut.y; - LOBYTE(v32) = LOBYTE(pOut.y) | 0x18; - HIDWORD(v27->uExpireTime) = HIDWORD(v32); - v27->uAttributes = v32; - } - _50C9A8_item_enchantment_timer = 256; - pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; - return; - } - v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; - if ( v36 < 0.0 ) - v36 = 0.0; - if ( v51 != 12 ) + if (pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_WAND) // can recharge only wands { 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(); - dword_50CDCC = 1; - 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; } - v14 = v13 - 222; - v15 = pParty->pPickedItem.uItemID - 222; - v47 = v14; - y.y = 0; - if ( pParty->pPickedItem.uItemID == 221 || v51 == 221 ) + 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) + { + 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) + { + 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 __show_item_desc; + } + + // src not reagent, dst not bottle + // src potion, dst potion + + v14 = item->uItemID - ITEM_POTION_CURE_WOUNDS; + v15 = pParty->pPickedItem.uItemID - ITEM_POTION_CURE_WOUNDS; + + 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 = pOut.z; + v16 = pItemsTable->potion_data[v15][v14 + 2]; } v51 = v16; - if ( v45 ) + 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 && pOut.y != 4 ) + if ( v16 >= ITEM_POTION_STONE_TO_FLESH && alchemy_level != 4 ) { LABEL_53: v51 = 4; @@ -5149,7 +5169,7 @@ } else { - if ( pOut.y <= 2 ) + if ( alchemy_level <= 2 ) { LABEL_38: v51 = 3; @@ -5159,7 +5179,7 @@ } else { - if ( pOut.y == 1 ) + if ( alchemy_level == 1 ) { LABEL_35: v51 = 2; @@ -5170,70 +5190,63 @@ } 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: - pOut.y = 0; - pOut.x = v10 + 1; - v17 = (int)v0->pInventoryMatrix; - while ( *(int *)v17 != pOut.x ) + int pOut_y = 0; + int pOut_x = item_pid + 1; + v17 = (int)player->pInventoryMatrix; + while ( *(int *)v17 != pOut_x ) { - ++pOut.y; + ++pOut_y; v17 += 4; - if ( pOut.y >= 126 ) + if ( pOut_y >= 126 ) { - v18 = y.y; + v18 = pOut_y; goto LABEL_59; } } - v18 = pOut.y; + v18 = pOut_y; LABEL_59: if ( !v51 ) - { -LABEL_115: - v10 = pOut.z; - goto LABEL_116; - } + goto __show_item_desc;; if ( v51 == 1 ) { - v0->RemoveItemAtInventoryIndex(v18); + player->RemoveItemAtInventoryIndex(v18); v26 = rand(); - v0->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE); + player->ReceiveDamage(v26 % 11 + 10, DMGT_FIRE); pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - v42 = (int *)&a2.y; - v41 = (int *)&y.y; - v40 = (int *)&pOut; v39.z = pParty->vPosition.z + pParty->sEyelevel; } else { if ( v51 == 2 ) { - v0->RemoveItemAtInventoryIndex(v18); + player->RemoveItemAtInventoryIndex(v18); v25 = rand(); - v0->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE); + player->ReceiveDamage(v25 % 71 + 30, DMGT_FIRE); v23 = 1; } else { if ( v51 == 3 ) { - v0->RemoveItemAtInventoryIndex(v18); + player->RemoveItemAtInventoryIndex(v18); v24 = rand(); - v0->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE); + player->ReceiveDamage(v24 % 201 + 50, DMGT_FIRE); v23 = 5; } else @@ -5242,76 +5255,79 @@ { if ( v51 != 5 ) { - v19 = v0->AddItem(-1, 0xDCu); + v19 = player->AddItem(-1, 0xDCu); if ( v19 ) // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; - v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED; - v20 = v47 + 50 * v15; - v0->pInventoryItemList[pOut.z].uItemID = v51; - v0->pInventoryItemList[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType - + v0->pInventoryItemList[pOut.z].uEnchantmentType) + player->pOwnItems[v19-1].uAttributes = ITEM_IDENTIFIED; + v20 = v14 + 50 * v15; + player->pInventoryItemList[item_pid].uItemID = v51; + player->pInventoryItemList[item_pid].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType + + player->pInventoryItemList[item_pid].uEnchantmentType) / 2; - v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 + player->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 LABEL_74: - v22 = (int)((char *)v0 + 36 * pOut.z); + v22 = (int)((char *)player + 36 * item_pid); if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) *(int *)(v22 + 552) |= 1u; if ( !dword_4E455C ) { pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; + no_rightlick_in_inventory = 1; return; } - v0->PlaySound(SPEECH_16, 0); + player->PlaySound(SPEECH_16, 0); dword_4E455C = 0; pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; + no_rightlick_in_inventory = 1; return; } - if ( v45 ) + if ( v9 ) { - if ( *(int *)(a2.y + 532) == 221 ) - *(int *)(a2.y + 532) = pParty->pPickedItem.uItemID; + if ( *(int *)(player + 36 * item_pid + 532) == 221 ) + *(int *)(player + 36 * item_pid + 532) = pParty->pPickedItem.uItemID; else - *(int *)(a2.y + 536) = pParty->pPickedItem.uEnchantmentType; - v21 = v0->AddItem(-1, 0xDCu); + *(int *)(player + 36 * item_pid + 536) = pParty->pPickedItem.uEnchantmentType; + v21 = player->AddItem(-1, 0xDCu); if ( v21 ) //*(int *)&v0->field_1F5[36 * v21 + 15] = 1; - v0->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; + player->pOwnItems[v21-1].uAttributes=ITEM_IDENTIFIED; goto LABEL_74; } - goto LABEL_115; + goto __show_item_desc; } - v0->RemoveItemAtInventoryIndex(v18); - v0->SetCondition(0x10u, 0); + player->RemoveItemAtInventoryIndex(v18); + player->SetCondition(0x10u, 0); v23 = 0; } } - v0->ItemsEnchant(v23); + player->ItemsEnchant(v23); pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - v42 = (int *)&a2.y; - v41 = (int *)&y.y; - v40 = (int *)&pOut; v39.z = pParty->vPosition.z + pParty->sEyelevel; } - *(_QWORD *)&v39.x = *(_QWORD *)&pParty->vPosition.x; - Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, v40, v41, v42); - sub_42F7EB_DropItemAt(0x41Bu, pOut.x, y.y, a2.y, 0, 1, 0, 0, 0); + v39.x = pParty->vPosition.x; + v39.y = pParty->vPosition.y; + + int rot_x, rot_y, rot_z; + Vec3_int_::Rotate(64, pParty->sRotationY, pParty->sRotationX, v39, &rot_x, &rot_y, &rot_z); + sub_42F7EB_DropItemAt(0x41Bu, rot_x, rot_y, rot_z, 0, 1, 0, 0, 0); if ( dword_4E455C ) { - if ( v0->CanAct() ) - v0->PlaySound(SPEECH_17, 0); + if ( player->CanAct() ) + player->PlaySound(SPEECH_17, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); dword_4E455C = 0; } pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; + no_rightlick_in_inventory = 1; return; } - *(int *)(v11 + 536) = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; + + // end alchemy + + player->pInventoryItemList[item_pid].uEnchantmentType = v9 + pItemsTable->pItems[pParty->pPickedItem.uItemID].uDamageDice; switch ( pParty->pPickedItem.uItemID ) { case 0xC8u: @@ -5319,39 +5335,46 @@ case 0xCAu: case 0xCBu: case 0xCCu: - v0->pInventoryItemList[pOut.z].uItemID = 222; + player->pInventoryItemList[item_pid].uItemID = 222; break; case 0xCDu: case 0xCEu: case 0xCFu: case 0xD0u: case 0xD1u: - v0->pInventoryItemList[pOut.z].uItemID = 223; + player->pInventoryItemList[item_pid].uItemID = 223; break; case 0xD2u: case 0xD3u: case 0xD4u: case 0xD5u: case 0xD6u: - v0->pInventoryItemList[pOut.z].uItemID = 224; + player->pInventoryItemList[item_pid].uItemID = 224; break; case 0xD7u: case 0xD8u: case 0xD9u: case 0xDAu: case 0xDBu: - v0->pInventoryItemList[pOut.z].uItemID = 221; + player->pInventoryItemList[item_pid].uItemID = 221; break; default: break; } pMouse->RemoveHoldingItem(); - dword_50CDCC = 1; + no_rightlick_in_inventory = 1; if ( dword_4E455C ) { - v0->PlaySound(SPEECH_16, 0); + player->PlaySound(SPEECH_16, 0); dword_4E455C = 0; } + return; + + +__invalid_item: + pMouse->RemoveHoldingItem(); + no_rightlick_in_inventory = true; + return; } //----- (00417AD4) -------------------------------------------------------- @@ -5395,6 +5418,5 @@ } break; } - assert(false); - return 0; + Error("Invalid player class: %u", uPlayerClass); } \ No newline at end of file
--- a/mm7_6.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_6.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -209,38 +209,6 @@ return result; } -//----- (004268E3) -------------------------------------------------------- -int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor) -{ - unsigned int v1; // eax@1 - unsigned int v2; // edx@1 - int v3; // eax@1 - int v4; // edx@1 - unsigned int v5; // ecx@1 - - v1 = uColor >> 9; - v2 = uColor >> 6; - LOWORD(v1) = (uColor >> 9) & 0x7C00; - LOWORD(v2) = (uColor >> 6) & 0x3E0; - v3 = v2 | v1; - v4 = (unsigned __int8)uColor >> 3; - v5 = uColor >> 16; - LOWORD(v5) = v5 & 0x8000; - return v5 | v4 | v3; -} - -//----- (0042690D) -------------------------------------------------------- -int __fastcall _42690D_colors_cvt(unsigned int a1) -{ - unsigned int v1; // eax@1 - unsigned int v2; // edx@1 - - v1 = a1 >> 8; - v2 = a1 >> 5; - LOWORD(v1) = (a1 >> 8) & 0xF800; - LOWORD(v2) = (a1 >> 5) & 0x7E0; - return ((unsigned __int8)a1 >> 3) | v2 | v1; -} //----- (00426A5A) -------------------------------------------------------- void stru319::LootActor(Actor *pActor) @@ -1824,7 +1792,7 @@ } //----- (0042FC4E) -------------------------------------------------------- -void ProcessInputActions() +void ProcessInputActions() { char v4; // al@9 char v8; // bl@100 @@ -2139,7 +2107,7 @@ pMessageQueue_50CBD0->uNumMessages = 1; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].field_8 = 0; ++pMessageQueue_50CBD0->uNumMessages; break; } @@ -2151,10 +2119,7 @@ case INPUT_CharCycle: if ( pCurrentScreen == SCREEN_SPELL_BOOK ) break; - /* dword_50C9EC[3 * dword_50C9E8] = 176;|| dword_50C9E8 >= 40 - dword_50C9EC[3 * dword_50C9E8 + 1] = 0; - dword_50C9EC[3 * dword_50C9E8 + 2] = 0; - ++dword_50C9E8;*/ + pMessageQueue_50C9E8->AddMessage(UIMSG_CycleCharacters, 0, 0); break; case INPUT_LookUp: @@ -2196,22 +2161,9 @@ } break; case INPUT_ZoomIn: - /*if ( dword_50C9E8 >= 40 ) - break; - dword_50C9EC[3 * dword_50C9E8] = 367; - dword_50C9EC[3 * dword_50C9E8 + 1] = 0; - dword_50C9EC[3 * dword_50C9E8 + 2] = 0; - ++dword_50C9E8;*/ pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomOutBtn, 0, 0); break; case INPUT_ZoomOut: - /*if ( dword_50C9E8 < 40 ) - { - dword_50C9EC[3 * dword_50C9E8] = 368; - dword_50C9EC[3 * dword_50C9E8 + 1] = 0; - dword_50C9EC[3 * dword_50C9E8 + 2] = 0; - ++dword_50C9E8; - }*/ pMessageQueue_50C9E8->AddMessage(UIMSG_ClickZoomInBtn, 0, 0); break; case INPUT_AlwaysRun:
--- a/mm7_data.cpp Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_data.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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 @@ -1006,7 +1006,6 @@ //int dword_50C9E8; // idb //int dword_50C9EC[120]; // weak int dword_50CDC8; -int dword_50CDCC; // weak int bProcessorIsNotIntel; // weak Vec3_int_ layingitem_vel_50FDFC; char pStartingMapName[32]; // idb @@ -1310,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 Wed Sep 11 09:23:41 2013 +0600 +++ b/mm7_data.h Wed Sep 11 09:39:09 2013 +0600 @@ -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 @@ -654,7 +654,6 @@ //extern int dword_50C9E8; // idb //extern int dword_50C9EC[]; // 50C9EC extern int dword_50CDC8; -extern int dword_50CDCC; // weak extern int bProcessorIsNotIntel; // weak extern Vec3_int_ layingitem_vel_50FDFC; extern char pStartingMapName[32]; // idb @@ -970,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; @@ -1094,7 +1086,7 @@ void SetAttributeNames(); void uGameUIFontMain_initialize(); void uGameUIFontShadow_initialize(); -void identify_item(); +void OnInventoryItemRightClick(); void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this); void UI_OnMouseLeftClick(int *pXY); // idb unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos); @@ -1122,8 +1114,6 @@ bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); int sr_424CD7(unsigned int uVertexID); // idb int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb -int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor); // idb -int __fastcall _42690D_colors_cvt(unsigned int a1); void __fastcall GivePartyExp(unsigned int pEXPNum); bool __fastcall sub_427769_spell(unsigned int uSpellID); void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6); @@ -1150,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); @@ -1233,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); @@ -1375,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 Wed Sep 11 09:23:41 2013 +0600 +++ b/texts.cpp Wed Sep 11 09:39:09 2013 +0600 @@ -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");