# HG changeset patch # User Ritor1 # Date 1399876086 -21600 # Node ID bcd7fadbf7d2d8be25b7006285ce5b6422c09509 # Parent 14c05b8762180921c4e0d62298ec9ca64a617672# Parent bbf8a522dcec39ac73007efb284b508971c62e71 Слияние diff -r 14c05b876218 -r bcd7fadbf7d2 Actor.cpp --- a/Actor.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Actor.cpp Mon May 12 12:28:06 2014 +0600 @@ -1,5 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS +#include "PaletteManager.h" #include "ErrorHandling.h" #include "VectorTypes.h" #include "mm7_unsorted_subs.h" @@ -4980,4 +4981,470 @@ if ( current_sector != obj2_sector ) return 0; return 1; -} \ No newline at end of file +} + + +//----- (00450B0A) -------------------------------------------------------- +bool __fastcall SpawnActor(unsigned int uMonsterID) +{ + unsigned int v1; // ebx@1 + bool result; // eax@2 + MonsterDesc *v3; // esi@5 + MonsterInfo *v4; // edi@5 + Vec3_int_ v5; // ST08_12@5 + unsigned int v6; // ecx@5 + Actor *v7; // eax@7 + Actor actor; // [sp+4h] [bp-350h]@5 + Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 + + v1 = uMonsterID; + if ( uNumActors == 499 ) + { + result = 0; + } + else + { + if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) + v1 = 0; + v3 = &pMonsterList->pMonsters[v1]; + v4 = &pMonsterStats->pInfos[v1 + 1]; + memset(&actor, 0, 0x344u); + strcpy(actor.pActorName, v4->pName); + actor.sCurrentHP = LOWORD(v4->uHP); + memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u); + actor.word_000086_some_monster_id = v1 + 1; + actor.uActorRadius = v3->uMonsterRadius; + actor.uActorHeight = v3->uMonsterHeight; + actor.uMovementSpeed = v3->uMovementSpeed; + v5 = pParty->vPosition; + Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y); + actor.vInitialPosition.x = pOut.x; + actor.vPosition.x = pOut.x; + actor.uTetherDistance = 256; + actor.vInitialPosition.y = LOWORD(pOut.z); + actor.vPosition.y = LOWORD(pOut.z); + actor.vInitialPosition.z = LOWORD(pOut.y); + actor.vPosition.z = LOWORD(pOut.y); + pSprites_LOD->DeleteSomeSprites(); + pPaletteManager->ResetNonTestLocked(); + v6 = uNumActors - 1; + if ( dword_5C6DF8 == 1 ) + { + dword_5C6DF8 = 0; + v6 = uNumActors++; + } + v7 = &pActors[v6]; + memcpy(v7, &actor, 0x344u); + v7->PrepareSprites(1); + result = 1; + } + return result; +} +// 5C6DF8: using guessed type int dword_5C6DF8; + + +//----- (0044FA4C) -------------------------------------------------------- +signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) +{ + signed int v3; // ecx@6 + Actor *v4; // edx@7 + signed int result; // eax@13 + Actor *v6; // esi@16 + char *v7; // ebx@16 + MonsterDesc *v8; // edi@16 + unsigned __int16 v9; // ax@16 + int v10; // ebx@16 + //int v11; // edi@16 + //int v12; // eax@16 + //int v13; // ecx@16 + //int v14; // ebx@16 + const char *v15; // [sp-4h] [bp-24h]@2 + //unsigned __int16 v16; // [sp+0h] [bp-20h]@1 + //int v17; // [sp+4h] [bp-1Ch]@1 + unsigned int uFaceID; // [sp+8h] [bp-18h]@16 + int v19; // [sp+Ch] [bp-14h]@16 + size_t v20; // [sp+10h] [bp-10h]@6 + int v21; // [sp+14h] [bp-Ch]@14 + //int v22; // [sp+18h] [bp-8h]@14 + unsigned int v23; // [sp+1Ch] [bp-4h]@6 + + //v16 = a2; + //v17 = a1; + if ( a2 == 4 ) + { + v15 = "Elemental Light C"; + } + else if ( a2 == 3 ) + v15 = "Elemental Light B"; + else + v15 = "Elemental Light A"; + + v23 = pMonsterList->GetMonsterIDByName(v15); + v3 = 0; + v20 = uNumActors; + if ( (signed int)uNumActors > 0 ) + { + v4 = pActors.data();//[0].uAIState; + while ( v4->uAIState != Removed ) + { + ++v3; + ++v4; + if ( v3 >= (signed int)uNumActors ) + break; + } + if( v3 < (signed int)uNumActors ) + v20 = v3; + } + if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) ) + { + v21 = 0; + //v22 = pParty->vPosition.z; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + v6 = &pActors[v20]; + v7 = (char *)&pMonsterStats->pInfos[v23 + 1]; + v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; + v6->Reset(); + v8 = &pMonsterList->pMonsters[v23]; + strcpy(v6->pActorName, *(const char **)v7); + v6->sCurrentHP = *((short *)v7 + 32); + memcpy(&v6->pMonsterInfo, v7, 0x58u); + v6->word_000086_some_monster_id = v23 + 1; + v6->uActorRadius = v8->uMonsterRadius; + v6->uActorHeight = v8->uMonsterHeight; + v9 = v8->uMovementSpeed; + v6->pMonsterInfo.uTreasureDiceRolls = 0; + v6->pMonsterInfo.uTreasureType = 0; + v6->pMonsterInfo.uExp = 0; + v6->uMovementSpeed = v9; + v10 = rand() % 2048; + //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); + uFaceID = stru_5C6E00->Sin(v10); + //v12 = pParty->vPosition.y; + //v13 = fixpoint_mul(uFaceID, v19); + //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); + //LOWORD(v12) = v22; + v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); + v6->vPosition.x = v6->vInitialPosition.x; + v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); + v6->vPosition.y = v6->vInitialPosition.y; + v6->vInitialPosition.z = pParty->vPosition.z; + v6->vPosition.z = v6->vInitialPosition.z; + //LOWORD(v12) = v21; + v6->uTetherDistance = 256; + v6->uSectorID = v21; + v6->PrepareSprites(0); + v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + v6->uAlly = 9999; + v6->uGroup = 0; + v6->uCurrentActionTime = 0; + v6->uAIState = Summoned; + v6->uCurrentActionLength = 256; + v6->UpdateAnimation(); + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor + || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z), + result == v21) + && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000) + && (result = abs(result - pParty->vPosition.z), result <= 1024) ) + { + if ( v20 == uNumActors ) + ++uNumActors; + v6->uSummonerID = PID(OBJECT_Player, a1); + result = v6->pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, + a2, + a1, + 0, + 0); + } + } + return result; +} + + +//----- (0044F57C) -------------------------------------------------------- +void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) +{ + //MapInfo *v5; // esi@1 + //SpawnPointMM7 *v6; // ebx@1 + int v7; // eax@2 + char v8; // zf@5 + // int v9; // edi@9 + // int v10; // eax@9 + // int v11; // ecx@9 + int v12; // edx@9 + // int v13; // eax@9 + // int v14; // eax@14 + // int v15; // ecx@14 + // int v16; // eax@19 + // int v17; // ecx@19 + int v18; // esi@31 + //int pPosX; // ecx@32 + //int v20; // edx@32 + //int v21; // eax@32 + Actor *pMonster; // esi@35 + int v23; // edx@36 + signed int v24; // edi@36 + int v25; // ecx@36 + // unsigned __int16 v26; // ax@47 + MonsterDesc *v27; // edi@48 + signed int v28; // eax@48 + // __int16 v29; // cx@50 + // __int16 v30; // ax@50 + // __int16 v31; // ax@50 + int v32; // eax@50 + // int v33; // edi@50 + // int v34; // eax@50 + // int v35; // eax@50 + // int v36; // eax@50 + int v37; // eax@51 + int v38; // eax@52 + int v39; // edi@52 + std::string v40; // [sp-18h] [bp-100h]@60 + // void *v41; // [sp-14h] [bp-FCh]@50 + //void *v42; // [sp-10h] [bp-F8h]@50 + //size_t v43; // [sp-Ch] [bp-F4h]@50 + const char *v44; // [sp-8h] [bp-F0h]@13 + char *pTexture; // [sp-4h] [bp-ECh]@9 + char Str[32]; // [sp+Ch] [bp-DCh]@60 + char Str2[120]; // [sp+2Ch] [bp-BCh]@29 + unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 + MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 + int v50; // [sp+ACh] [bp-3Ch]@47 + char Source[32]; // [sp+B0h] [bp-38h]@20 + int v52; // [sp+D0h] [bp-18h]@34 + int v53; // [sp+D4h] [bp-14h]@34 + int pSector; // [sp+D8h] [bp-10h]@32 + int pPosX; // [sp+DCh] [bp-Ch]@32 + int v56; // [sp+E0h] [bp-8h]@8 + int v57; // [sp+E4h] [bp-4h]@1 + + //auto a2 = spawn; + v57 = 0; + //v5 = pMapInfo; + //v6 = spawn; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + v7 = pOutdoor->ddm.field_C_alert; + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + v7 = pIndoor->dlv.field_C_alert; + else + v7 = 0; + if (v7) + v8 = (spawn->uAttributes & 1) == 0; + else + v8 = (spawn->uAttributes & 1) == 1; + if (v8) + return; + //result = (void *)(spawn->uIndex - 1); + v56 = 1; + switch (spawn->uIndex - 1) + { + case 0: + //v9 = pMapInfo->uEncounterMonster1AtLeast; + //v10 = rand(); + //v11 = pMapInfo->uEncounterMonster1AtMost; + //pTexture = pMapInfo->pEncounterMonster1Texture; + v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1); + //v13 = pMapInfo->Dif_M1; + v57 = pMapInfo->Dif_M1; + v56 = pMapInfo->uEncounterMonster1AtLeast + v12; + strcpy(Source, pMapInfo->pEncounterMonster1Texture); + break; + case 3: + //pTexture = pMapInfo->pEncounterMonster1Texture; + //v44 = "%s A"; + sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture); + break; + case 4: + //pTexture = pMapInfo->pEncounterMonster2Texture; + //v44 = "%s A"; + sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture); + break; + case 5: + //pTexture = pMapInfo->pEncounterMonster3Texture; + //v44 = "%s A"; + sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture); + break; + case 1: + //v9 = pMapInfo->uEncounterMonster2AtLeast; + //v14 = rand(); + //v15 = pMapInfo->uEncounterMonster2AtMost; + //pTexture = pMapInfo->pEncounterMonster2Texture; + v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1); + //v13 = pMapInfo->Dif_M2; + v57 = pMapInfo->Dif_M2; + v56 = pMapInfo->uEncounterMonster2AtLeast + v12; + strcpy(Source, pMapInfo->pEncounterMonster2Texture); + break; + case 6: + //pTexture = pMapInfo->pEncounterMonster1Texture; + //v44 = "%s B"; + sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture); + break; + case 7: + //pTexture = pMapInfo->pEncounterMonster2Texture; + //v44 = "%s B"; + sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture); + break; + case 8: + //pTexture = pMapInfo->pEncounterMonster3Texture; + //v44 = "%s B"; + sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture); + break; + case 2: + //v9 = pMapInfo->uEncounterMonster3AtLeast; + //v16 = rand(); + //v17 = pMapInfo->uEncounterMonster3AtMost; + //pTexture = pMapInfo->pEncounterMonster3Texture; + v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1); + //v13 = pMapInfo->Dif_M3; + v57 = pMapInfo->Dif_M3; + v56 = pMapInfo->uEncounterMonster3AtLeast + v12; + strcpy(Source, pMapInfo->pEncounterMonster3Texture); + break; + case 9: + //pTexture = pMapInfo->pEncounterMonster1Texture; + //v44 = "%s C"; + sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture); + break; + case 10: + //pTexture = pMapInfo->pEncounterMonster2Texture; + //v44 = "%s C"; + sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture); + break; + case 11: + //pTexture = pMapInfo->pEncounterMonster3Texture; + //v44 = "%s C"; + sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture); + break; + default: + return; + } + if (Source[0] == '0') + return; + v57 += a3; + if ( v57 > 4 ) + v57 = 4; + strcpy(Str2, Source); + if ( a4 ) + v56 = a4; + v18 = v56; + if ( (signed int)(v56 + uNumActors) >= 500 ) + return; + pSector = 0; + pPosX = spawn->vPosition.x; + a4 = spawn->vPosition.y; + a3 = spawn->vPosition.z; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); + v53 = 0; + v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; + if ( v18 <= 0 ) + return; + for (uint i = v53; i < v56; ++i) + { + pMonster = &pActors[uNumActors]; + pActors[uNumActors].Reset(); + if ( v57 ) + { + v23 = rand() % 100; + v24 = 3; + v25 = (unsigned __int16)word_4E8152[3 * v57]; + if ( v23 >= v25 ) + { + if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) + v24 = 2; + } + else + { + v24 = 1; + } + if ( v24 == 1 ) + { + pTexture = Source; + v44 = "%s A"; + } + else + { + if ( v24 == 2 ) + { + pTexture = Source; + v44 = "%s B"; + } + else + { + if ( v24 != 3 ) + continue; + pTexture = Source; + v44 = "%s C"; + } + } + sprintf(Str2, v44, pTexture); + } + v50 = pMonsterList->GetMonsterIDByName(Str2); + pTexture = Str2; + if ( (signed __int16)v50 == -1 ) + { + sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); + MessageBoxA(nullptr, Str, nullptr, 0); + ExitProcess(0); + } + v27 = &pMonsterList->pMonsters[(signed __int16)v50]; + v28 = pMonsterStats->FindMonsterByTextureName(pTexture); + if ( !v28 ) + v28 = 1; + Src = &pMonsterStats->pInfos[v28]; + strcpy(pMonster->pActorName, Src->pName); + pMonster->sCurrentHP = Src->uHP; + assert(sizeof(MonsterInfo) == 88); + memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo)); + pMonster->word_000086_some_monster_id = v50 + 1; + pMonster->uActorRadius = v27->uMonsterRadius; + pMonster->uActorHeight = v27->uMonsterHeight; + pMonster->uMovementSpeed = v27->uMovementSpeed; + pMonster->vInitialPosition.x = spawn->vPosition.x; + pMonster->vPosition.x = spawn->vPosition.x; + pMonster->uTetherDistance = 256; + pMonster->vInitialPosition.y = a4; + pMonster->vPosition.y = a4; + pMonster->vInitialPosition.z = a3; + pMonster->vPosition.z = a3; + pMonster->uSectorID = pSector; + pMonster->uGroup = spawn->uGroup; + pMonster->PrepareSprites(0); + pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + v32 = rand(); + a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52); + pPosX = a3 + spawn->vPosition.x; + a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52); + a4 = a3 + spawn->vPosition.y; + a3 = spawn->vPosition.z; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + if ( a5 ) + pMonster->uAttributes |= 0x080000; + ++uNumActors; + continue; + } + v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z); + if ( v37 == pSector ) + { + v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); + v39 = v38; + if ( v38 != -30000 ) + { + if ( abs(v38 - a3) <= 1024 ) + { + a3 = v39; + if ( a5 ) + pMonster->uAttributes |= 0x080000; + ++uNumActors; + continue; + } + } + } + ; + //v53 = (char *)v53 + 1; + //result = v53; + } + //while ( (signed int)v53 < v56 ); +} diff -r 14c05b876218 -r bcd7fadbf7d2 Actor.h --- a/Actor.h Mon May 12 12:27:50 2014 +0600 +++ b/Actor.h Mon May 12 12:28:06 2014 +0600 @@ -304,3 +304,6 @@ void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3); void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle); bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID); +bool __fastcall SpawnActor(unsigned int uMonsterID); +int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); +void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); diff -r 14c05b876218 -r bcd7fadbf7d2 Arcomage.cpp --- a/Arcomage.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Arcomage.cpp Mon May 12 12:28:06 2014 +0600 @@ -464,7 +464,7 @@ pArcomageGame->pBlit_Copy_pixels = pPixels; pRenderer->am_Blt_Copy(&pSrcRect, &pTargetPoint, 2); pRenderer->EndScene(); - pArcomageGame->pBlit_Copy_pixels = 0; + pArcomageGame->pBlit_Copy_pixels = nullptr; } //----- (0040DDC9) -------------------------------------------------------- @@ -762,7 +762,7 @@ void am_EndScene() { pRenderer->EndScene(); - pArcomageGame->pBlit_Copy_pixels = NULL; + pArcomageGame->pBlit_Copy_pixels = nullptr; } //----- (0040D7B7) -------------------------------------------------------- diff -r 14c05b876218 -r bcd7fadbf7d2 AudioPlayer.cpp --- a/AudioPlayer.cpp Mon May 12 12:27:50 2014 +0600 +++ b/AudioPlayer.cpp Mon May 12 12:28:06 2014 +0600 @@ -255,7 +255,7 @@ if ( this->pSL_Sounds[i].pSoundData[0] ) { ReleaseSoundData(this->pSL_Sounds[i].pSoundData[0]); - this->pSL_Sounds[i].pSoundData[0] = 0; + this->pSL_Sounds[i].pSoundData[0] = nullptr; this->pSL_Sounds[i].uFlags &= 0xFFFFFFFE; } } @@ -273,7 +273,7 @@ if ( this->pSL_Sounds[i].pSoundData[0] ) { ReleaseSoundData(this->pSL_Sounds[i].pSoundData[0]); - this->pSL_Sounds[i].pSoundData[0] = 0; + this->pSL_Sounds[i].pSoundData[0] = nullptr; } this->pSL_Sounds[i].uFlags &= ~SOUND_DESC_SYSTEM; } @@ -295,7 +295,7 @@ if ( pSL_Sounds[uSoundID].pSoundData[0] ) { ReleaseSoundData(pSL_Sounds[uSoundID].pSoundData[0]); - pSL_Sounds[uSoundID].pSoundData[0] = NULL; + pSL_Sounds[uSoundID].pSoundData[0] = nullptr; pSL_Sounds[uSoundID].uFlags &= ~SOUND_DESC_SYSTEM; } } diff -r 14c05b876218 -r bcd7fadbf7d2 BSPModel.cpp --- a/BSPModel.cpp Mon May 12 12:27:50 2014 +0600 +++ b/BSPModel.cpp Mon May 12 12:28:06 2014 +0600 @@ -11,11 +11,11 @@ free(this->pVertices.pVertices); this->pVertices.pVertices = 0; free(this->pFaces); - this->pFaces = 0; + this->pFaces = nullptr; free(this->pFacesOrdering); - this->pFacesOrdering = 0; + this->pFacesOrdering = nullptr; free(this->pNodes); - this->pNodes = 0; + this->pNodes = nullptr; this->uNumNodes = 0; this->uNumFaces = 0; this->pVertices.uNumVertices = 0; diff -r 14c05b876218 -r bcd7fadbf7d2 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Mon May 12 12:27:50 2014 +0600 +++ b/CastSpellInfo.cpp Mon May 12 12:28:06 2014 +0600 @@ -2395,7 +2395,7 @@ { activeLevelDecoration = &pLevelDecorations[obj_id]; EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[obj_id]._idx_in_stru123 - 75] + 380, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; } } if (PID_TYPE(a2) == OBJECT_BModel) diff -r 14c05b876218 -r bcd7fadbf7d2 DecorationList.cpp --- a/DecorationList.cpp Mon May 12 12:27:50 2014 +0600 +++ b/DecorationList.cpp Mon May 12 12:28:06 2014 +0600 @@ -6,6 +6,8 @@ #include "mm7_data.h" #include "Indoor.h" #include "ErrorHandling.h" +#include "stru123.h" +#include "Level\Decoration.h" //----- (0045864C) -------------------------------------------------------- void DecorationList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) @@ -260,4 +262,29 @@ } } return 0; +} + + +//----- (00450AAA) -------------------------------------------------------- +void RespawnGlobalDecorations() +{ + memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125); + + uint decorEventIdx = 0; + for (uint i = 0; i < uNumLevelDecorations; ++i) + { + LevelDecoration* decor = &pLevelDecorations[i]; + + if (!decor->uEventID) + { + if (decor->IsInteractive()) + { + if (decorEventIdx < 124) + { + decor->_idx_in_stru123 = decorEventIdx + 75; + stru_5E4C90_MapPersistVars._decor_events[decorEventIdx++] = decor->GetGlobalEvent(); + } + } + } + } } \ No newline at end of file diff -r 14c05b876218 -r bcd7fadbf7d2 DecorationList.h --- a/DecorationList.h Mon May 12 12:27:50 2014 +0600 +++ b/DecorationList.h Mon May 12 12:28:06 2014 +0600 @@ -75,4 +75,6 @@ #pragma pack(pop) -extern struct DecorationList *pDecorationList; \ No newline at end of file +extern struct DecorationList *pDecorationList; + +void RespawnGlobalDecorations(); \ No newline at end of file diff -r 14c05b876218 -r bcd7fadbf7d2 GUIWindow.cpp --- a/GUIWindow.cpp Mon May 12 12:27:50 2014 +0600 +++ b/GUIWindow.cpp Mon May 12 12:28:06 2014 +0600 @@ -27,6 +27,7 @@ #include "Outdoor.h" #include "Game.h" #include "IconFrameTable.h" +#include "Actor.h" #include "mm7_data.h" diff -r 14c05b876218 -r bcd7fadbf7d2 Game.cpp --- a/Game.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Game.cpp Mon May 12 12:28:06 2014 +0600 @@ -785,8 +785,7 @@ //----- (00465CF3) -------------------------------------------------------- void Game::Destroy() { - if (pGame) - delete pGame; + delete pGame; pGame = nullptr; } @@ -887,34 +886,20 @@ //----- (0044E7F3) -------------------------------------------------------- Game::~Game() { - if (pGammaController) - delete pGammaController; - if (pKeyboardInstance) - delete pKeyboardInstance; - /*if (pCShow) - delete pCShow; - if (pStru12Instance) - delete pStru12Instance; - if (pStru11Instance) - delete pStru11Instance;*/ - if (pStru10Instance) - delete pStru10Instance; - if (pStru9Instance) - delete pStru9Instance; - if (pIndoorCameraD3D) - delete pIndoorCameraD3D; - if (pStru6Instance) - delete pStru6Instance; - if (pVisInstance) - delete pVisInstance; - if (pLightmapBuilder) - delete pLightmapBuilder; - if (pMouseInstance) - delete pMouseInstance; - if (pParticleEngine) - delete pParticleEngine; - //if (pThreadWardInstance) - // delete pThreadWardInstance; + delete pGammaController; + delete pKeyboardInstance; +/*delete pCShow; + delete pStru12Instance; + delete pStru11Instance;*/ + delete pStru10Instance; + delete pStru9Instance; + delete pIndoorCameraD3D; + delete pStru6Instance; + delete pVisInstance; + delete pLightmapBuilder; + delete pMouseInstance; + delete pParticleEngine; +//delete pThreadWardInstance; } //----- (0044E904) -------------------------------------------------------- @@ -2095,7 +2080,7 @@ { LOBYTE(ptr_50C9A4_ItemToEnchant->uAttributes) &= 0xFu; _50C9A8_item_enchantment_timer = 0; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } if ( pGUIWindow_Settings ) { diff -r 14c05b876218 -r bcd7fadbf7d2 Indoor.cpp --- a/Indoor.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Indoor.cpp Mon May 12 12:28:06 2014 +0600 @@ -4903,7 +4903,7 @@ return 1; activeLevelDecoration = &pLevelDecorations[v17]; EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[v17]._idx_in_stru123 - 75] + 380, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; } break; @@ -6301,4 +6301,174 @@ if ( result ) result = abs(((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / result); return result; +} + +//----- (00450DA3) -------------------------------------------------------- +int GetAlertStatus() +{ + int result; // eax@2 + + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + result = pOutdoor->ddm.field_C_alert; + else + result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0; + return result; +} + + +//----- (0045063B) -------------------------------------------------------- +int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) +{ + int result; // eax@8 + int v6; // edi@11 + int v7; // ebx@11 + int v8; // edi@11 + int v9; // ebx@12 + int v10; // eax@12 + char v11; // zf@16 + int v12; // edi@20 + int v13; // eax@20 + int v14; // ebx@20 + int v15; // eax@20 + int v16; // eax@20 + int v17; // eax@20 + int v18; // eax@21 + SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 + int v22; // [sp+2Ch] [bp-18h]@3 + unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 + int v26; // [sp+3Ch] [bp-8h]@11 + int v27; // [sp+40h] [bp-4h]@11 + + if (!uNumActors) + return 0; + + for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) + { + if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C + (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C + (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C + pActors[mon_id].CanAct()) + { + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + v22 = 0; + uint face_id = 0; + for ( face_id; face_id < 100; ++face_id ) + { + v6 = rand() % 1024 + 512; + v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); + v8 = 0; + v19.uIndex = a2; + v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v26 = 0; + v27 = 0; + v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); + for( int i = 0; i < pOutdoor->uNumBModels; i++ ) + { + v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); + v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) + { + v22 = 1; + break; + } + } + if ( v22 ) + { + v11 = face_id == 100; + break; + } + } + v11 = face_id == 100; + } + else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + for ( uint i = 0; i < 100; ++i ) + { + v12 = rand() % 512 + 256; + v13 = rand(); + v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; + v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); + v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v19.uIndex = a2; + v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); + if ( v17 == v22 ) + { + v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); + v19.vPosition.z = v18; + if ( v18 != -30000 ) + { + if ( abs(v18 - pParty->vPosition.z) <= 1024 ) + break; + } + } + } + v11 = v26 == 100; + } + if ( v11 ) + result = 0; + else + { + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; + } + } + + //break; + //v22 = v3->pMonsterInfo.uID - 1; + //v4 = (signed __int64)((double)v22 * 0.3333333333333333); + //if ( (int)v4 != 40 ) + //{ + // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) + // break; + //} + //++v2; + //++v3; + //if ( v2 >= (signed int)uNumActors ) + // goto LABEL_8; + } + return result; +} + +//----- (00450521) -------------------------------------------------------- +int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6) +{ + int v6; // edi@1 + int v7; // esi@1 + signed int v8; // edi@1 + unsigned __int16 v9; // cx@1 + // char *v10; // edx@2 + unsigned __int16 v11; // ax@5 + SpriteObject a1; // [sp+8h] [bp-70h]@1 + + v6 = ecx0; + v7 = a2; + pItemsTable->GenerateItem(v6, v7, &a1.stru_24); + v8 = 0; + v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; + a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; + v11 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v9 == pObjectList->pObjects[i].uObjectID ) + { + v11 = i; + break; + } + } + a1.uObjectDescID = v11; + a1.vPosition.y = a4; + a1.vPosition.x = a3; + a1.vPosition.z = a5; + a1.uFacing = a6; + a1.uAttributes = 0; + a1.uSectorID = pIndoor->GetSector(a3, a4, a5); + a1.uSpriteFrameID = 0; + return a1.Create(0, 0, 0, 0); } \ No newline at end of file diff -r 14c05b876218 -r bcd7fadbf7d2 Indoor.h --- a/Indoor.h Mon May 12 12:27:50 2014 +0600 +++ b/Indoor.h Mon May 12 12:28:06 2014 +0600 @@ -262,10 +262,10 @@ this->uNumVertices = 0; this->uAttributes = 0; this->uFaceExtraID = 0; - this->pVertexIDs = 0; - this->pZInterceptDisplacements = 0; - this->pYInterceptDisplacements = 0; - this->pXInterceptDisplacements = 0; + this->pVertexIDs = nullptr; + this->pZInterceptDisplacements = nullptr; + this->pYInterceptDisplacements = nullptr; + this->pXInterceptDisplacements = nullptr; } void _get_normals(Vec3_int_ *a2, Vec3_int_ *a3); @@ -556,3 +556,6 @@ int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6); void __fastcall PrepareDrawLists_BLV(); void PrepareToLoadBLV(unsigned int bLoading); +int GetAlertStatus(); +int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2); +int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); diff -r 14c05b876218 -r bcd7fadbf7d2 Items.cpp --- a/Items.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Items.cpp Mon May 12 12:28:06 2014 +0600 @@ -283,33 +283,28 @@ //----- (0045814E) -------------------------------------------------------- void ItemsTable::Release() { - if ( pMonstersTXT_Raw ) - free(pMonstersTXT_Raw); - if ( pMonsterPlacementTXT_Raw ) - free(pMonsterPlacementTXT_Raw); - if ( pSkillDescTXT_Raw ) - free(pSkillDescTXT_Raw); - if (pSpcItemsTXT_Raw ) - free(pSpcItemsTXT_Raw); - if ( pStdItemsTXT_Raw ) - free(pStdItemsTXT_Raw); - if ( pRndItemsTXT_Raw ) - free(pRndItemsTXT_Raw); - if ( pItemsTXT_Raw ) - free(pItemsTXT_Raw); - if ( pHostileTXT_Raw ) - free(pHostileTXT_Raw); - if ( pHistoryTXT_Raw ) - free(pHistoryTXT_Raw); - if ( pPotionsTXT_Raw ) - free(pPotionsTXT_Raw); - if ( pPotionNotesTXT_Raw ) - free(pPotionNotesTXT_Raw); - pSpcItemsTXT_Raw = NULL; - pSkillDescTXT_Raw = NULL; - pStdItemsTXT_Raw = NULL; - pRndItemsTXT_Raw = NULL; - pItemsTXT_Raw = NULL; + free(pMonstersTXT_Raw); + free(pMonsterPlacementTXT_Raw); + free(pSkillDescTXT_Raw); + free(pSpcItemsTXT_Raw); + free(pStdItemsTXT_Raw); + free(pRndItemsTXT_Raw); + free(pItemsTXT_Raw); + free(pHostileTXT_Raw); + free(pHistoryTXT_Raw); + free(pPotionsTXT_Raw); + free(pPotionNotesTXT_Raw); + pMonstersTXT_Raw = nullptr; + pMonsterPlacementTXT_Raw = nullptr; + pSpcItemsTXT_Raw = nullptr; + pSkillDescTXT_Raw = nullptr; + pStdItemsTXT_Raw = nullptr; + pRndItemsTXT_Raw = nullptr; + pItemsTXT_Raw = nullptr; + pHostileTXT_Raw = nullptr; + pHistoryTXT_Raw = nullptr; + pPotionsTXT_Raw = nullptr; + pPotionNotesTXT_Raw = nullptr; } @@ -383,7 +378,6 @@ pStorylineText = new StorylineText; pStorylineText->Initialize(); - pStdItemsTXT_Raw = NULL; pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); strtok(pStdItemsTXT_Raw, "\r"); strtok(NULL, "\r"); @@ -425,7 +419,6 @@ } - pSpcItemsTXT_Raw = 0; pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); strtok(pSpcItemsTXT_Raw, "\r"); strtok(NULL, "\r"); @@ -465,7 +458,6 @@ InitializeBuildingResidents(); - pItemsTXT_Raw = NULL; pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0); strtok(pItemsTXT_Raw, "\r"); strtok(NULL, "\r"); @@ -547,7 +539,6 @@ item_counter++; } - pRndItemsTXT_Raw = NULL; uAllItemsCount = item_counter; pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); strtok(pRndItemsTXT_Raw, "\r"); @@ -614,14 +605,9 @@ break; } } + free(pRndItemsTXT_Raw); + pRndItemsTXT_Raw = nullptr; - if ( pRndItemsTXT_Raw ) - { - free(pRndItemsTXT_Raw); - pRndItemsTXT_Raw = NULL; - } - - pSkillDescTXT_Raw = NULL; pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); strtok(pSkillDescTXT_Raw, "\r"); for (int i=0; i<37; ++i) @@ -636,7 +622,6 @@ pGrandSkillDesc[i] = RemoveQuotes(tokens[5]); } - pStatsTXT_Raw = 0; pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); strtok(pStatsTXT_Raw, "\r"); for (int i=0; i<26; ++i) @@ -771,9 +756,7 @@ unsigned int uColumn; unsigned __int8 potion_value; - if ( pPotionNotesTXT_Raw ) - free(pPotionNotesTXT_Raw); - pPotionNotesTXT_Raw = NULL; + free(pPotionNotesTXT_Raw); auto tokens = Tokenize("", '\t'); char* pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); test_string = strtok(pPotionsTXT_Raw ,"\r") + 1; @@ -830,9 +813,7 @@ unsigned int uColumn; unsigned __int8 potion_note; - if ( pPotionNotesTXT_Raw ) - free(pPotionNotesTXT_Raw); - pPotionNotesTXT_Raw = NULL; + free(pPotionNotesTXT_Raw); auto tokens = Tokenize("", '\t'); char* pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); test_string = strtok(pPotionNotesTXT_Raw ,"\r") + 1; diff -r 14c05b876218 -r bcd7fadbf7d2 Items.h --- a/Items.h Mon May 12 12:27:50 2014 +0600 +++ b/Items.h Mon May 12 12:28:06 2014 +0600 @@ -196,7 +196,7 @@ { unsigned __int16 Player::* statPtr; int statBonus; - CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = NULL): + CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = nullptr): statBonus(bonus), statPtr(skillPtr) { @@ -216,7 +216,7 @@ int enchId, CHARACTER_ATTRIBUTE_TYPE attrId, int bonusValue = 0, - unsigned __int16 Player::* skillPtr = NULL); + unsigned __int16 Player::* skillPtr = nullptr); static std::map* > regularBonusMap; static std::map* > specialBonusMap; diff -r 14c05b876218 -r bcd7fadbf7d2 LOD.cpp --- a/LOD.cpp Mon May 12 12:27:50 2014 +0600 +++ b/LOD.cpp Mon May 12 12:28:06 2014 +0600 @@ -264,16 +264,16 @@ pHardwareSprites = (Sprite *)malloc(1500*sizeof(Sprite));//0xEA60u for (i=0; i<1500;++i) { - pHardwareSprites[i].pName=NULL; - pHardwareSprites[i].pTextureSurface=NULL; - pHardwareSprites[i].pTexture=NULL; + pHardwareSprites[i].pName=nullptr; + pHardwareSprites[i].pTextureSurface=nullptr; + pHardwareSprites[i].pTexture=nullptr; } } temp_sprite_hdr.uHeight = 0; temp_sprite_hdr.uPaletteId = 0; temp_sprite_hdr.word_1A = 0; - temp_sprite_hdr.pSpriteLines = 0; - temp_sprite_hdr.pDecompressedBytes = 0; + temp_sprite_hdr.pSpriteLines = nullptr; + temp_sprite_hdr.pDecompressedBytes = nullptr; sprite_file = FindContainer(pContainerName, 0); if ( !sprite_file ) return -1; @@ -349,11 +349,11 @@ if ( v5 ) { v5->Release(); - v1->pHardwareSprites[v3].pTexture = 0; + v1->pHardwareSprites[v3].pTexture = nullptr; } v6 = (IDirectDrawSurface *)v1->pHardwareSprites[v3].pTextureSurface; v6->Release(); - v1->pHardwareSprites[v3].pTextureSurface = 0; + v1->pHardwareSprites[v3].pTextureSurface = nullptr; pRenderer->MoveSpriteToDevice(&v1->pHardwareSprites[v3]); } ++v2; @@ -391,7 +391,7 @@ if ( v5 ) { v5->Release(); - v1->pHardwareSprites[v3].pTexture = 0; + v1->pHardwareSprites[v3].pTexture = nullptr; } v6 = v1->pHardwareSprites; if ( v6 ) @@ -400,7 +400,7 @@ if ( v7 ) { v7->Release(); - v1->pHardwareSprites[v3].pTextureSurface = 0; + v1->pHardwareSprites[v3].pTextureSurface = nullptr; } } } @@ -943,8 +943,8 @@ this->uCurrentIndexDir = 0; free(pSubIndices); free(pRoot); - pSubIndices = NULL; - pRoot = NULL; + pSubIndices = nullptr; + pRoot = nullptr; fclose(pFile); isFileOpened = false; _6A0CA8_lod_unused = 0; @@ -974,7 +974,7 @@ fwrite(pHeader,sizeof(LOD::FileHeader), 1, pFile); fwrite(pDir, sizeof(LOD::Directory), 1, pFile); fclose(pFile); - pFile = 0; + pFile = nullptr; return 0; } @@ -989,7 +989,7 @@ uNumSubDirs = 0; uLODDataSize = 0; free(pSubIndices); - pSubIndices = NULL; + pSubIndices = nullptr; } } @@ -1063,8 +1063,8 @@ free(v1->pSpriteLines); } v1->word_1A = 0; - v1->pDecompressedBytes = 0; - v1->pSpriteLines = 0; + v1->pDecompressedBytes = nullptr; + v1->pSpriteLines = nullptr; v1->pName[0] = 0; v1->word_16 = 0; v1->uPaletteId = 0; @@ -1077,8 +1077,7 @@ //----- (00450D68) -------------------------------------------------------- void Sprite::Release() { - if (pName) - free((void *)pName); + free((void *)pName); pName = nullptr; if (pTextureSurface) @@ -1267,8 +1266,8 @@ free(pDecompressedBytes); free(pSpriteLines); } - pDecompressedBytes = NULL; - pSpriteLines = NULL; + pDecompressedBytes = nullptr; + pSpriteLines = nullptr; } //----- (004623E5) -------------------------------------------------------- @@ -1333,12 +1332,9 @@ } while ( (v2 & 0x80000000u) == 0 ); } - if ( v1->pHardwareSurfaces ) - free(v1->pHardwareSurfaces); - if ( v1->pHardwareTextures ) - free(v1->pHardwareTextures); - if ( v1->ptr_011BB4 ) - free(v1->ptr_011BB4); + free(v1->pHardwareSurfaces); + free(v1->pHardwareTextures); + free(v1->ptr_011BB4); //LOD::File::vdtor((LOD::File *)v1); } @@ -1487,7 +1483,7 @@ isFileOpened = false; fflush(pFile); fclose(pFile); - pFile = 0; + pFile = nullptr; } //else //__debugbreak(); @@ -1712,7 +1708,7 @@ { MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION); free(pIOBuffer); - pIOBuffer = NULL; + pIOBuffer = nullptr; uIOBufferSize = 0; } if ( uBufferSize ) @@ -1810,9 +1806,9 @@ { memset(pLODName, 0, 256); memset(pContainerName, 0, 16); - this->pFile = 0; - this->pSubIndices = 0; - this->pIOBuffer = 0; + this->pFile = nullptr; + this->pSubIndices = nullptr; + this->pIOBuffer = nullptr; this->isFileOpened = false; this->uIOBufferSize = 0; Close(); diff -r 14c05b876218 -r bcd7fadbf7d2 MapInfo.cpp --- a/MapInfo.cpp Mon May 12 12:27:50 2014 +0600 +++ b/MapInfo.cpp Mon May 12 12:28:06 2014 +0600 @@ -24,9 +24,7 @@ int decode_step; // int item_counter; - if ( pMapStatsTXT_Raw ) - free(pMapStatsTXT_Raw); - pMapStatsTXT_Raw = NULL; + free(pMapStatsTXT_Raw); pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); strtok(pMapStatsTXT_Raw, "\r"); strtok(NULL, "\r"); diff -r 14c05b876218 -r bcd7fadbf7d2 Monsters.cpp --- a/Monsters.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Monsters.cpp Mon May 12 12:28:06 2014 +0600 @@ -578,9 +578,7 @@ char Src[120]; FrameTableTxtLine parsed_field; - if ( pMonstersTXT_Raw ) - free(pMonstersTXT_Raw); - pMonstersTXT_Raw = NULL; + free(pMonstersTXT_Raw); pMonstersTXT_Raw = (char *)pEvents_LOD->LoadRaw("monsters.txt", 0); strtok(pMonstersTXT_Raw, "\r"); strtok(NULL, "\r"); diff -r 14c05b876218 -r bcd7fadbf7d2 Mouse.cpp --- a/Mouse.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Mouse.cpp Mon May 12 12:28:06 2014 +0600 @@ -142,19 +142,12 @@ void Mouse::ClearCursor() { this->bActive = false; - if ( this->pCursorBitmap_sysmem ) - { - free(this->pCursorBitmap_sysmem); - this->pCursorBitmap_sysmem = 0; - } - if ( this->pCursorBitmap2_sysmem ) - { - free(this->pCursorBitmap2_sysmem); - this->pCursorBitmap2_sysmem = 0; - } - if ( this->ptr_90 ) - free(this->ptr_90); - this->ptr_90 = 0; + free(this->pCursorBitmap_sysmem); + this->pCursorBitmap_sysmem = nullptr; + free(this->pCursorBitmap2_sysmem); + this->pCursorBitmap2_sysmem = nullptr; + free(this->ptr_90); + this->ptr_90 = nullptr; } //----- (00469BE6) -------------------------------------------------------- @@ -198,9 +191,9 @@ this->pCursorBitmapPos.y = 0; this->uMouseClickX = 0; this->uMouseClickY = 0; - this->pCursorBitmap_sysmem = 0; + this->pCursorBitmap_sysmem = nullptr; this->field_34 = 0; - this->pCursorBitmap2_sysmem = 0; + this->pCursorBitmap2_sysmem = nullptr; SetCursorBitmap("MICON3"); SetCursorBitmap("MICON2"); @@ -293,11 +286,8 @@ //----- (00469E24) -------------------------------------------------------- void Mouse::_469E24() { - if (pCursorBitmap3_sysmembits_16bit) - { - free(pCursorBitmap3_sysmembits_16bit); - pCursorBitmap3_sysmembits_16bit = 0; - } + free(pCursorBitmap3_sysmembits_16bit); + pCursorBitmap3_sysmembits_16bit = nullptr; } //----- (00469E3B) -------------------------------------------------------- @@ -355,8 +345,7 @@ || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ ) { - if ( this->pCursorBitmap3_sysmembits_16bit ) - free(this->pCursorBitmap3_sysmembits_16bit); + free(this->pCursorBitmap3_sysmembits_16bit); this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); this->uCursorWithItemX = pMouse->uMouseClickX; this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth; @@ -409,11 +398,8 @@ } else { - if ( this->pCursorBitmap3_sysmembits_16bit ) - { - free(this->pCursorBitmap3_sysmembits_16bit); - this->pCursorBitmap3_sysmembits_16bit = 0; - } + free(this->pCursorBitmap3_sysmembits_16bit); + this->pCursorBitmap3_sysmembits_16bit = nullptr; } } diff -r 14c05b876218 -r bcd7fadbf7d2 Mouse.h --- a/Mouse.h Mon May 12 12:27:50 2014 +0600 +++ b/Mouse.h Mon May 12 12:28:06 2014 +0600 @@ -51,11 +51,11 @@ { uCursorTextureID = 0; uCursorTextureID_2 = 0; - pCursorBitmap_sysmem = 0; + pCursorBitmap_sysmem = nullptr; field_34 = 0; - pCursorBitmap2_sysmem = 0; - pCursorBitmap3_sysmembits_16bit = 0; - ptr_90 = 0; + pCursorBitmap2_sysmem = nullptr; + pCursorBitmap3_sysmembits_16bit = nullptr; + ptr_90 = nullptr; pWard = pWard; } diff -r 14c05b876218 -r bcd7fadbf7d2 NPC.cpp --- a/NPC.cpp Mon May 12 12:27:50 2014 +0600 +++ b/NPC.cpp Mon May 12 12:28:06 2014 +0600 @@ -201,7 +201,7 @@ if ( sDialogue_SpeakingActorNPC_ID >= 0 ) { *npc_indx = 0; - result = NULL; + result = nullptr; } else { @@ -249,9 +249,7 @@ char* tmp_pos; int decode_step; - if (pNPCTextTXT_Raw) - free(pNPCTextTXT_Raw); - pNPCTextTXT_Raw =NULL; + free(pNPCTextTXT_Raw); pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); strtok(pNPCTextTXT_Raw, "\r"); @@ -287,9 +285,7 @@ } while ((decode_step<2)&&!break_loop); } - if (pNPCTopicTXT_Raw) - free(pNPCTopicTXT_Raw); - pNPCTopicTXT_Raw =NULL; + free(pNPCTopicTXT_Raw); pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); strtok(pNPCTopicTXT_Raw, "\r"); @@ -325,9 +321,7 @@ } while ((decode_step<2)&&!break_loop); } - if (pNPCDistTXT_Raw) - free(pNPCDistTXT_Raw); - pNPCDistTXT_Raw = NULL; + free(pNPCDistTXT_Raw); pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); strtok(pNPCDistTXT_Raw, "\r"); strtok(NULL, "\r"); @@ -381,11 +375,8 @@ pProfessionChance[i].professionChancePerArea[59]=0; } - if (pNPCDistTXT_Raw) - { - free(pNPCDistTXT_Raw); - pNPCDistTXT_Raw = NULL; - } + free(pNPCDistTXT_Raw); + pNPCDistTXT_Raw = nullptr; } //----- (00476C60) -------------------------------------------------------- @@ -604,7 +595,6 @@ InitializeMerchants(); InitializeScrolls(); - pNPCNamesTXT_Raw = NULL; pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); strtok(pNPCNamesTXT_Raw, "\r"); @@ -655,7 +645,6 @@ } uNumNPCNames[0] = i; - pNPCProfTXT_Raw = NULL; pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); strtok(pNPCProfTXT_Raw, "\r"); strtok(NULL, "\r"); @@ -719,23 +708,23 @@ void NPCStats::Release() { free(pNPCTopicTXT_Raw); - pNPCTopicTXT_Raw = NULL; + pNPCTopicTXT_Raw = nullptr; free(pNPCTextTXT_Raw); - pNPCTextTXT_Raw = NULL; + pNPCTextTXT_Raw = nullptr; free(pNPCNewsTXT_Raw); - pNPCNewsTXT_Raw = NULL; + pNPCNewsTXT_Raw = nullptr; free(pNPCProfTXT_Raw); - pNPCProfTXT_Raw = NULL; + pNPCProfTXT_Raw = nullptr; free(pNPCNamesTXT_Raw); - pNPCNamesTXT_Raw = NULL; + pNPCNamesTXT_Raw = nullptr; free(pNPCDataTXT_Raw); - pNPCDataTXT_Raw = NULL; + pNPCDataTXT_Raw = nullptr; free(pNPCDistTXT_Raw); - pNPCDistTXT_Raw = NULL; + pNPCDistTXT_Raw = nullptr; free(pNPCGreetTXT_Raw); - pNPCGreetTXT_Raw = NULL; + pNPCGreetTXT_Raw = nullptr; free(pNCPGroupTXT_Raw); - pNCPGroupTXT_Raw = NULL; + pNCPGroupTXT_Raw = nullptr; } //----- (0047730C) -------------------------------------------------------- @@ -973,9 +962,7 @@ char* tmp_pos; int decode_step; - if ( pAwardsTXT_Raw ) - free(pAwardsTXT_Raw); - pAwardsTXT_Raw = NULL; + free(pAwardsTXT_Raw); pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); strtok(pAwardsTXT_Raw, "\r"); @@ -1027,9 +1014,7 @@ char* tmp_pos; int decode_step; - if ( pScrollsTXT_Raw ) - free(pScrollsTXT_Raw); - pScrollsTXT_Raw = NULL; + free(pScrollsTXT_Raw); pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); strtok(pScrollsTXT_Raw, "\r"); for (i=0; i<82; ++i) @@ -1076,9 +1061,7 @@ char* tmp_pos; int decode_step; - if ( pMerchantsTXT_Raw ) - free(pMerchantsTXT_Raw); - pMerchantsTXT_Raw = NULL; + free(pMerchantsTXT_Raw); pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); strtok(pMerchantsTXT_Raw, "\r"); @@ -1140,9 +1123,7 @@ char* tmp_pos; int decode_step; - if ( pTransitionsTXT_Raw ) - free(pTransitionsTXT_Raw); - pTransitionsTXT_Raw = NULL; + free(pTransitionsTXT_Raw); pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); strtok(pTransitionsTXT_Raw, "\r"); @@ -1190,9 +1171,7 @@ char* tmp_pos; int decode_step; - if ( pAutonoteTXT_Raw ) - free(pAutonoteTXT_Raw); - pAutonoteTXT_Raw = 0; + free(pAutonoteTXT_Raw); pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); strtok(pAutonoteTXT_Raw, "\r"); @@ -1275,9 +1254,7 @@ char* tmp_pos; int decode_step; - if ( pQuestsTXT_Raw ) - free(pQuestsTXT_Raw); - pQuestsTXT_Raw = NULL; + free(pQuestsTXT_Raw); pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); strtok(pQuestsTXT_Raw, "\r"); memset(pQuestTable.data(),0, sizeof(pQuestTable)); @@ -1403,7 +1380,7 @@ current_npc_text = 0; activeLevelDecoration = (LevelDecoration*)1; EventProcessor(pEventNumber, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; } } } diff -r 14c05b876218 -r bcd7fadbf7d2 ObjectList.cpp --- a/ObjectList.cpp Mon May 12 12:27:50 2014 +0600 +++ b/ObjectList.cpp Mon May 12 12:28:06 2014 +0600 @@ -144,7 +144,7 @@ v2 = this; free(this->pObjects); v3 = 0; - v2->pObjects = 0; + v2->pObjects = nullptr; v2->uNumObjects = 0; v4 = fopen(Args, "r"); File = v4; diff -r 14c05b876218 -r bcd7fadbf7d2 Outdoor.cpp --- a/Outdoor.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Outdoor.cpp Mon May 12 12:28:06 2014 +0600 @@ -371,38 +371,32 @@ //----- (0048902E) -------------------------------------------------------- bool OutdoorLocation::GetTravelDestination(signed int sPartyX, signed int sPartyZ, char *pOut, signed int a5) { - char *v6; // eax@3 - int v7; // eax@3 - //int v8; // edx@3 - signed int v9; // esi@7 - //int v10; // esi@23 - signed int v11; // eax@23 - //int v12; // ST14_4@25 - //signed int v14; // [sp-4h] [bp-84h]@6 + char *mapNumberAsStr; // eax@3 + int mapNumberAsInt; // eax@3 + signed int direction; // esi@7 + signed int destinationMap; // eax@23 char Str[140]; // [sp+8h] [bp-78h]@3 - //int a5a; // [sp+94h] [bp+14h]@3 strcpy(Str, this->pLevelFilename);// _strlwr(Str); - v6 = strtok(Str, "out"); - v6[2] = 0; - v7 = atoi(v6); - if ( a5 < 10 || strlen(this->pLevelFilename) != 9 || v7 < 1 || v7 > 15 ) // .odm + mapNumberAsStr = strtok(Str, "out"); + mapNumberAsStr[2] = 0; + mapNumberAsInt = atoi(mapNumberAsStr); + if ( a5 < 10 || strlen(this->pLevelFilename) != 9 || mapNumberAsInt < 1 || mapNumberAsInt > 15 ) // .odm return 0; - v9 = 1; if ( sPartyX < -22528 )// - v9 = 4; + direction = 4; else if ( sPartyX > 22528 ) - v9 = 3; + direction = 3; else if ( sPartyZ < -22528 ) - v9 = 2; - else if ( sPartyZ <= 22528 ) - return 0; - - if ( v7 == 14 ) + direction = 2; + else if ( sPartyZ > 22528 ) + direction = 1; + else + return false; + + if ( mapNumberAsInt == MAP_AVLEE && direction == 4) // to Shoals { - if ( v9 == 4 ) // to & from Shoals - { if ( pPlayers[1]->HasUnderwaterSuitEquipped() && pPlayers[2]->HasUnderwaterSuitEquipped() && pPlayers[3]->HasUnderwaterSuitEquipped() && @@ -412,36 +406,27 @@ strcpy(pOut, "out15.odm"); uLevel_StartingPointType = MapStartPoint_East; LOWORD(pParty->uFlags) &= 0xFD7Bu; - return 1; + return true; } - //v8 = v7; - } } - else + else if ( mapNumberAsInt == MAP_SHOALS && direction == 3 ) //from Shoals { - if ( v7 == 15 && v9 == 3 ) - { - uDefaultTravelTime_ByFoot = 1; - strcpy(pOut, "out14.odm");// - uLevel_StartingPointType = MapStartPoint_West; - LOWORD(pParty->uFlags) &= 0xFD7Bu; - return 1; - } + uDefaultTravelTime_ByFoot = 1; + strcpy(pOut, "out14.odm");// + uLevel_StartingPointType = MapStartPoint_West; + LOWORD(pParty->uFlags) &= 0xFD7Bu; + return true; } - //v10 = v9 + 4 * v7; - //v11 = (unsigned __int8)aTiletableLoadU[v10 + 39]; - v11 = foot_travel_destinations[v7 - 1][v9 - 1]; - if (v11 == MAP_INVALID) + destinationMap = foot_travel_destinations[mapNumberAsInt - 1][direction - 1]; + if (destinationMap == MAP_INVALID) return false; - assert(v11 <= MAP_SHOALS); - - uDefaultTravelTime_ByFoot = foot_travel_times[v7 - 1][v9 - 1]; - uLevel_StartingPointType = foot_travel_arrival_points[v7 - 1][v9 - 1]; - sprintf(pOut, "out%02d.odm", v11); // - return 1; - //} - //return 0; + assert(destinationMap <= MAP_SHOALS); + + uDefaultTravelTime_ByFoot = foot_travel_times[mapNumberAsInt - 1][direction - 1]; + uLevel_StartingPointType = foot_travel_arrival_points[mapNumberAsInt - 1][direction - 1]; + sprintf(pOut, "out%02d.odm", destinationMap); // + return true; } // 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; // 6BE35C: using guessed type int uLevel_StartingPointType; @@ -496,16 +481,16 @@ { v3 = pParty->uCurrentMinute + 60 * (pParty->uCurrentHour - 5); this->inv_sunlight_y = 0; - this->inv_sunlight_x = stru_5C6E00->Cos((signed int)(v3 * stru_5C6E00->uIntegerPi) / 960); - this->inv_sunlight_z = stru_5C6E00->Sin((signed int)(v3 * stru_5C6E00->uIntegerPi) / 960); + this->inv_sunlight_x = stru_5C6E00->Cos((v3 * stru_5C6E00->uIntegerPi) / 960); + this->inv_sunlight_z = stru_5C6E00->Sin((v3 * stru_5C6E00->uIntegerPi) / 960); this->vSunlight.x = -this->inv_sunlight_x; this->vSunlight.y = -this->inv_sunlight_y; this->vSunlight.z = -this->inv_sunlight_z; - if ( (signed int)v3 >= 480 ) - v8 = (double)(signed int)(960 - v3); + if ( v3 >= 480 ) + v8 = 960 - v3; else - v8 = (double)(signed int)v3; - this->max_terrain_dimming_level = (signed __int64)(20.0 - v8 / 480.0 * 20.0); + v8 = v3; + this->max_terrain_dimming_level = (int)(20.0 - v8 / 480.0 * 20.0); this->uLastSunlightUpdateMinute = pParty->uCurrentMinute; } } @@ -591,20 +576,13 @@ } //----- (00482170) -------------------------------------------------------- -bool ODMFace::IsBackfaceCulled(RenderVertexSoft *a2, struct Polygon *polygon) +bool ODMFace::IsBackfaceNotCulled(RenderVertexSoft *a2, struct Polygon *polygon) { - unsigned int v5; // edx@1 - RenderVertexSoft *v6; // ecx@2 + unsigned int numOfVertices; // edx@1 + RenderVertexSoft *currVertex; // ecx@2 double v7; // st7@5 double v8; // st6@5 double v9; // st5@5 - double v10; // st6@9 - double v11; // st5@9 - double v12; // st4@9 - double v14; // ST2C_8@17 - double v15; // ST20_8@17 - double v16; // ST0C_8@17 - double v17; // ST0C_8@17 float v18; // [sp+8h] [bp-38h]@5 float v19; // [sp+10h] [bp-30h]@5 float v20; // [sp+14h] [bp-2Ch]@5 @@ -622,69 +600,54 @@ float a3d; // [sp+48h] [bp+8h]@17 float a3e; // [sp+48h] [bp+8h]@17 - v5 = polygon->uNumVertices; - if ( (signed int)v5 < 3 ) - return false; - v6 = &a2[v5 - 1]; - if ( a2->vWorldPosition.z == a2[1].vWorldPosition.z && a2[1].vWorldPosition.z == v6->vWorldPosition.z ) - *(int *)&polygon->flags |= 0x10u; - v19 = a2[1].vWorldViewPosition.x - a2->vWorldViewPosition.x; - v18 = a2[1].vWorldViewPosition.y - a2->vWorldViewPosition.y; - v20 = a2[1].vWorldViewPosition.z - a2->vWorldViewPosition.z; - v21 = v6->vWorldViewPosition.x - a2->vWorldViewPosition.x; - v22 = v6->vWorldViewPosition.y - a2->vWorldViewPosition.y; - v23 = v6->vWorldViewPosition.z - a2->vWorldViewPosition.z; + numOfVertices = polygon->uNumVertices; + if ( numOfVertices < 3 ) + return false; + currVertex = &a2[numOfVertices - 1]; + if ( a2->vWorldPosition.z == a2[1].vWorldPosition.z && a2[1].vWorldPosition.z == currVertex->vWorldPosition.z ) + polygon->flags |= 0x10u; + v28 = a2[1].vWorldPosition.x - a2->vWorldPosition.x; v27 = a2[1].vWorldPosition.y - a2->vWorldPosition.y; a3a = a2[1].vWorldPosition.z - a2->vWorldPosition.z; - v7 = v6->vWorldPosition.x - a2->vWorldPosition.x; - v8 = v6->vWorldPosition.y - a2->vWorldPosition.y; - v9 = v6->vWorldPosition.z - a2->vWorldPosition.z; - v26 = v27 * v9 - v8 * a3a; - v24 = v7 * a3a - v9 * v28; - v25 = v8 * v28 - v7 * v27; - if ( v26 == 0.0 && v24 == 0.0 && v25 == 0.0 ) + + + for (int i = 0; i < numOfVertices; i++) { - while ( 1 ) - { - --v5; - if ( (signed int)v5 < 2 ) - break; - v10 = v6->vWorldPosition.x - a2->vWorldPosition.x; - v11 = v6->vWorldPosition.y - a2->vWorldPosition.y; - v12 = v6->vWorldPosition.z - a2->vWorldPosition.z; - v26 = v27 * v12 - v11 * a3a; - v24 = v10 * a3a - v12 * v28; - v25 = v11 * v28 - v10 * v27; - if ( v26 != 0.0 ) - break; - if ( v24 != 0.0 || v25 != 0.0 ) - break; - --v6; - } - v21 = v6->vWorldViewPosition.x - a2->vWorldViewPosition.x; - v22 = v6->vWorldViewPosition.y - a2->vWorldViewPosition.y; - v23 = v6->vWorldViewPosition.z - a2->vWorldViewPosition.z; + v7 = currVertex->vWorldPosition.x - a2->vWorldPosition.x; + v8 = currVertex->vWorldPosition.y - a2->vWorldPosition.y; + v9 = currVertex->vWorldPosition.z - a2->vWorldPosition.z; + v26 = v27 * v9 - v8 * a3a; + v24 = v7 * a3a - v9 * v28; + v25 = v8 * v28 - v7 * v27; + if ( v24 != 0.0 || v25 != 0.0 || v26 != 0.0 ) + break; + currVertex--; } + if ( ((double)pGame->pIndoorCameraD3D->vPartyPos.x - a2->vWorldPosition.x) * v26 - + ((double)pGame->pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25 - + ((double)pGame->pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 ) + + ((double)pGame->pIndoorCameraD3D->vPartyPos.z - a2->vWorldPosition.z) * v25 + + ((double)pGame->pIndoorCameraD3D->vPartyPos.y - a2->vWorldPosition.y) * v24 > 0.0 ) { + + v19 = a2[1].vWorldViewPosition.x - a2->vWorldViewPosition.x; + v18 = a2[1].vWorldViewPosition.y - a2->vWorldViewPosition.y; + v20 = a2[1].vWorldViewPosition.z - a2->vWorldViewPosition.z; + v21 = currVertex->vWorldViewPosition.x - a2->vWorldViewPosition.x; + v22 = currVertex->vWorldViewPosition.y - a2->vWorldViewPosition.y; + v23 = currVertex->vWorldViewPosition.z - a2->vWorldViewPosition.z; + a3b = v23 * v18 - v22 * v20; - v14 = a3b + 6.7553994e15; - polygon->v_18.x = LODWORD(v14); + polygon->v_18.x = bankersRounding(a3b); a3c = v21 * v20 - v23 * v19; - v15 = a3c + 6.7553994e15; - polygon->v_18.y = LODWORD(v15); + polygon->v_18.y = bankersRounding(a3c); a3d = v22 * v19 - v21 * v18; - v16 = a3d + 6.7553994e15; - polygon->v_18.z = LODWORD(v16); + polygon->v_18.z = bankersRounding(a3d); polygon->_normalize_v_18(); a3e = -((double)polygon->v_18.x * a2->vWorldViewPosition.x) - - (double)polygon->v_18.y * a2->vWorldViewPosition.y - - (double)polygon->v_18.z * a2->vWorldViewPosition.z; - v17 = a3e + 6.7553994e15; - polygon->field_24 = LODWORD(v17); + - (double)polygon->v_18.y * a2->vWorldViewPosition.y + - (double)polygon->v_18.z * a2->vWorldViewPosition.z; + polygon->field_24 = bankersRounding(a3e); return true; } else @@ -705,26 +668,14 @@ //----- (0047C7C2) -------------------------------------------------------- void OutdoorLocationTerrain::Release()// { - if (pHeightmap) - { - free(this->pHeightmap); - pHeightmap = nullptr; - } - if (pTilemap) - { - free(pTilemap); - pTilemap = nullptr; - } - if (pAttributemap) - { - free(pAttributemap); - pAttributemap = nullptr; - } - if (pDmap) - { - free(pDmap); - pDmap = nullptr; - } + free(this->pHeightmap); + pHeightmap = nullptr; + free(pTilemap); + pTilemap = nullptr; + free(pAttributemap); + pAttributemap = nullptr; + free(pDmap); + pDmap = nullptr; _47C7A9(); } @@ -1102,35 +1053,20 @@ uNumBModels = 0; } - if (pSpawnPoints) - { - free(pSpawnPoints); - pSpawnPoints = nullptr; - } + free(pSpawnPoints); + pSpawnPoints = nullptr; uNumSpawnPoints = 0; pTerrain.Release(); - if (pCmap) - { - free(pCmap); - pCmap = nullptr; - } - if (pOMAP) - { - free(pOMAP); - pOMAP = nullptr; - } - if (pFaceIDLIST) - { - free(pFaceIDLIST); - pFaceIDLIST = nullptr; - } - if (pTerrainNormals) - { - free(pTerrainNormals); - pTerrainNormals = nullptr; - } + free(pCmap); + pCmap = nullptr; + free(pOMAP); + pOMAP = nullptr; + free(pFaceIDLIST); + pFaceIDLIST = nullptr; + free(pTerrainNormals); + pTerrainNormals = nullptr; } //----- (0047D0A6) -------------------------------------------------------- @@ -1669,11 +1605,7 @@ //v43 = (char *)v43 + 16384; //v108 = (int)ptr_D4; - if (pCmap) - { - free(pCmap); - pCmap = nullptr; - } + free(pCmap); pCmap = malloc(0x8000); pTerrain.FillDMap(0, 0, 128, 128); @@ -1879,11 +1811,8 @@ //uSourceLen = (char *)uSourceLen + 4; //v108 = (int)pFaceIDLIST; - if (pFaceIDLIST) - { - free(pFaceIDLIST); - pFaceIDLIST = nullptr; - } + free(pFaceIDLIST); + pFaceIDLIST = nullptr; //v66 = field_DC; //pFaceIDLIST = 0; //v67 = malloc(0, 2 * v66, "IDLIST"); @@ -1901,11 +1830,7 @@ //v108 = (int)pOMAP; //free((void *)v108); //pOMAP = 0; - if (pOMAP) - { - free(pOMAP); - pOMAP = nullptr; - } + free(pOMAP); //v69 = malloc(0, 0x10000u, "OMAP"); pOMAP = (unsigned int *)malloc(0x10000); //v108 = 65536; @@ -2051,9 +1976,9 @@ //v108 = (int)".odm"; //v83 = strlen(pContainer); //strcpy((char *)v141 + v83, (const char *)v108); - memcpy(uUndiscoveredArea, pSrc, 0x3C8); + memcpy(uFullyRevealedCellOnMap, pSrc, 0x3C8); //v84 = (const void *)(v74 + 968); - memcpy(uDicovered_area, pSrc + 0x3C8, 0x3C8); + memcpy(uPartiallyRevealedCellOnMap, pSrc + 0x3C8, 0x3C8); pSrc += 2 * 0x3C8; //v85 = (char *)v84 + 968; @@ -2061,8 +1986,8 @@ if ( *(int *)thisa ) { - memcpy(uUndiscoveredArea, Dst, 0x3C8u); - memcpy(uDicovered_area, Src, 0x3C8u); + memcpy(uFullyRevealedCellOnMap, Dst, 0x3C8u); + memcpy(uPartiallyRevealedCellOnMap, Src, 0x3C8u); } for (uint i = 0; i < uNumBModels; ++i) @@ -2378,65 +2303,42 @@ //----- (0047EF60) -------------------------------------------------------- int OutdoorLocation::UpdateDiscoveredArea(int X_grid_pos, int Y_grid_poa, int a4) { - int v4; // ecx@1 - int v5; // edx@2 - int v6; // edi@2 - int v9; // ebx@4 - int v10; // eax@5 -// int v12; // esi@12 - char v13; // al@12 - int v15; // [sp+4h] [bp-14h]@7 - - v4 = Y_grid_poa - 10; - if ( v4 < Y_grid_poa + 10 ) + for (int i = -10; i < 10; i++) { - v5 = v4 - Y_grid_poa; - v6 = (Y_grid_poa - 30); - for ( int i = 0; i < Y_grid_poa + 10 - v4; i++) + int currYpos = Y_grid_poa + i - 20; + for (int j = -10; j < 10; j++) { - v9 = X_grid_pos - 10; - v10 = v9 - X_grid_pos; - for ( v9; v9 < X_grid_pos + 10; ++v9 ) + int currXpos = X_grid_pos + j - 20; + int distanceSquared = i * i + j * j; + if ( distanceSquared <= 100 && currYpos >= 0 && currYpos <= 87 && currXpos >= 0 && currXpos <= 87 ) { - v15 = abs(v10) * abs(v10) + abs(v5) * abs(v5); - if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 87 ) - { - v13 = 1 << (7 - (v9 - 20) % 8); - this->uDicovered_area[v6][(v9 - 20)/8] |= v13; - if ( v15 <= 49 ) - this->uUndiscoveredArea[v6][(v9 - 20)/8] |= v13; - } - ++v10; + unsigned char v13 = 1 << (7 - currXpos % 8); + this->uPartiallyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; + if ( distanceSquared <= 49 ) + this->uFullyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; } - ++v6; - ++v5; } } return 1; } + //----- (0047F04C) -------------------------------------------------------- -bool OutdoorLocation::_47F04C(signed int x_pos, signed int y_pos) +bool OutdoorLocation::IsMapCellFullyRevealed(signed int x_pos, signed int y_pos) { - bool result; // eax@5 - if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) - result = 0; + return false; else - result = (uUndiscoveredArea[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; - return result; + return (uFullyRevealedCellOnMap[y_pos][x_pos/8] & (1 << (7 - (x_pos) % 8))) != 0; } //----- (0047F097) -------------------------------------------------------- -bool OutdoorLocation::_47F097(signed int x_pos, signed int y_pos) +bool OutdoorLocation::IsMapCellPartiallyRevealed(signed int x_pos, signed int y_pos) { - bool result; // eax@5 - if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) - result = 0; + return false; else - result = (uDicovered_area[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; - return result; + return (uPartiallyRevealedCellOnMap[y_pos][x_pos/8] & (1 << (7 - (x_pos) % 8))) != 0; } //----- (0047F0E2) -------------------------------------------------------- diff -r 14c05b876218 -r bcd7fadbf7d2 Outdoor.h --- a/Outdoor.h Mon May 12 12:27:50 2014 +0600 +++ b/Outdoor.h Mon May 12 12:28:06 2014 +0600 @@ -43,10 +43,10 @@ //----- (0047C794) -------------------------------------------------------- inline OutdoorLocationTerrain() { - pHeightmap = NULL; - pTilemap = NULL; - pAttributemap = NULL; - pDmap = NULL;; + pHeightmap = nullptr; + pTilemap = nullptr; + pAttributemap = nullptr; + pDmap = nullptr;; this->field_10 = 0; this->field_12 = 0; @@ -82,7 +82,7 @@ bool HasEventHint(); - static bool IsBackfaceCulled(struct RenderVertexSoft *a2, struct Polygon *polygon); + static bool IsBackfaceNotCulled(struct RenderVertexSoft *a2, struct Polygon *polygon); inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;} inline bool Visible() const {return !Invisible();} @@ -146,8 +146,8 @@ int DoGetHeightOnTerrain(signed int sX, signed int sZ); int GetSoundIdByPosition(signed int X_pos, signed int Y_pos, int a4); int UpdateDiscoveredArea(int a2, int a3, int a4); - bool _47F04C(signed int a2, signed int a3); - bool _47F097(signed int a2, signed int a3); + bool IsMapCellFullyRevealed(signed int a2, signed int a3); + bool IsMapCellPartiallyRevealed(signed int a2, signed int a3); bool _47F0E2(); bool PrepareDecorations(); void ArrangeSpriteObjects(); @@ -200,8 +200,8 @@ //int day_fogrange_1; //int day_fogrange_2; // char field_510[24]; - unsigned char uUndiscoveredArea[88][11];//968 - unsigned char uDicovered_area[88][11];//[968] + unsigned char uFullyRevealedCellOnMap[88][11];//968 the inner array is 11 bytes long, because every bit is used for a separate cell, so in the end it's 11 * 8 bits = 88 values + unsigned char uPartiallyRevealedCellOnMap[88][11];//[968] int field_CB8; int max_terrain_dimming_level; int field_CC0; diff -r 14c05b876218 -r bcd7fadbf7d2 Overlays.cpp --- a/Overlays.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Overlays.cpp Mon May 12 12:28:06 2014 +0600 @@ -170,7 +170,7 @@ free(this->pOverlays); v3 = 0; - this->pOverlays = 0; + this->pOverlays = nullptr; this->uNumOverlays = 0; v4 = fopen(Args, "r"); File = v4; diff -r 14c05b876218 -r bcd7fadbf7d2 Player.cpp --- a/Player.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Player.cpp Mon May 12 12:28:06 2014 +0600 @@ -4767,7 +4767,7 @@ { thisa = pParty->uCurrentMonthWeek + 1; if ( pParty->uCurrentMonth >= 7 ) - v74 = NULL; + v74 = nullptr; else v74 = aAttributeNames[pParty->uCurrentMonth]; switch ( pParty->uCurrentMonth ) diff -r 14c05b876218 -r bcd7fadbf7d2 Render.cpp --- a/Render.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Render.cpp Mon May 12 12:28:06 2014 +0600 @@ -759,8 +759,7 @@ { delete [] v20.pDriverName; delete [] v20.pDeviceDesc; - if ( v20.pGUID ) - delete v20.pGUID; + delete v20.pGUID; } else { @@ -768,8 +767,7 @@ { delete [] v20.pDriverName; delete [] v20.pDeviceDesc; - if ( v20.pGUID ) - delete v20.pGUID; + delete v20.pGUID; v6 = (IUnknown *)pDirectDraw; } else @@ -800,10 +798,8 @@ { delete [] v20.pDriverName; delete [] v20.pDeviceDesc; - if ( v20.pDDraw4DevDesc ) - free(v20.pDDraw4DevDesc); - if ( v20.pGUID ) - delete v20.pGUID; + free(v20.pDDraw4DevDesc); + delete v20.pGUID; v6 = (IUnknown *)pDirectDraw4; } else @@ -813,10 +809,8 @@ pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux); delete [] v20.pDriverName; delete [] v20.pDeviceDesc; - if ( v20.pDDraw4DevDesc ) - free(v20.pDDraw4DevDesc); - if ( v20.pGUID ) - delete v20.pGUID; + free(v20.pDDraw4DevDesc); + delete v20.pGUID; pDirectDraw4->Release(); v6 = (IUnknown *)pDirect3D3; pDirectDraw4 = 0; @@ -1221,14 +1215,14 @@ //----- (0049DC58) -------------------------------------------------------- RenderD3D::RenderD3D() { - this->pHost = 0; - this->pDirect3D = 0; - this->pUnk = 0; - this->pBackBuffer = 0; - this->pFrontBuffer = 0; - this->pZBuffer = 0; - this->pDevice = 0; - this->pViewport = 0; + this->pHost = nullptr; + this->pDirect3D = nullptr; + this->pUnk = nullptr; + this->pBackBuffer = nullptr; + this->pFrontBuffer = nullptr; + this->pZBuffer = nullptr; + this->pDevice = nullptr; + this->pViewport = nullptr; this->field_40 = 1; this->field_44 = 10; GetAvailableDevices(&this->pAvailableDevices); @@ -1263,49 +1257,25 @@ v3 = 0; do { - if ( v1->pAvailableDevices[v3].pDriverName ) - { - free(v1->pAvailableDevices[v3].pDriverName); - v1->pAvailableDevices[v3].pDriverName = 0; - } - if ( v1->pAvailableDevices[v3].pDeviceDesc ) - { - free(v1->pAvailableDevices[v3].pDeviceDesc); - v1->pAvailableDevices[v3].pDeviceDesc = 0; - } - if ( v1->pAvailableDevices[v3].pDDraw4DevDesc ) - { - free(v1->pAvailableDevices[v3].pDDraw4DevDesc); - v1->pAvailableDevices[v3].pDDraw4DevDesc = 0; - } - if ( v1->pAvailableDevices[v3].pDirectDrawGUID ) - { - free(v1->pAvailableDevices[v3].pDirectDrawGUID); - v1->pAvailableDevices[v3].pDirectDrawGUID = 0; - } - if ( v1->pAvailableDevices[v3].pName ) - { - free(v1->pAvailableDevices[v3].pName); - v1->pAvailableDevices[v3].pName = 0; - } - if ( v1->pAvailableDevices[v3].pDescription ) - { - free(v1->pAvailableDevices[v3].pDescription); - v1->pAvailableDevices[v3].pDescription = 0; - } - if ( v1->pAvailableDevices[v3].pGUID ) - { - free(v1->pAvailableDevices[v3].pGUID); - v1->pAvailableDevices[v3].pGUID = 0; - } + free(v1->pAvailableDevices[v3].pDriverName); + v1->pAvailableDevices[v3].pDriverName = nullptr; + free(v1->pAvailableDevices[v3].pDeviceDesc); + v1->pAvailableDevices[v3].pDeviceDesc = nullptr; + free(v1->pAvailableDevices[v3].pDDraw4DevDesc); + v1->pAvailableDevices[v3].pDDraw4DevDesc = nullptr; + free(v1->pAvailableDevices[v3].pDirectDrawGUID); + v1->pAvailableDevices[v3].pDirectDrawGUID = nullptr; + free(v1->pAvailableDevices[v3].pName); + v1->pAvailableDevices[v3].pName = nullptr; + free(v1->pAvailableDevices[v3].pDescription); + v1->pAvailableDevices[v3].pDescription = nullptr; + free(v1->pAvailableDevices[v3].pGUID); + v1->pAvailableDevices[v3].pGUID = nullptr; ++v3; } while ( v3 < 4 ); - if ( v1->pAvailableDevices ) - { - free(v1->pAvailableDevices); - v1->pAvailableDevices = 0; - } + free(v1->pAvailableDevices); + v1->pAvailableDevices = 0; v4 = v1->pViewport; if ( v4 ) { @@ -2047,9 +2017,9 @@ // char v3; // zf@1 //v1 = this; - this->pDirectDraw4 = 0; - this->pFrontBuffer4 = 0; - this->pBackBuffer4 = 0; + this->pDirectDraw4 = nullptr; + this->pFrontBuffer4 = nullptr; + this->pBackBuffer4 = nullptr; //this->pColorKeySurface4 = 0; //this->pDirectDraw2 = 0; //this->pFrontBuffer2 = 0; @@ -2063,8 +2033,8 @@ //this->field_14 = 480; //this->field_40030 = 0; //this->field_4002C = 0; - this->pActiveZBuffer = 0; - this->pDefaultZBuffer = 0; + this->pActiveZBuffer = nullptr; + this->pDefaultZBuffer = nullptr; this->raster_clip_y = 0; this->raster_clip_x = 0; this->raster_clip_z = 639; @@ -2074,15 +2044,15 @@ this->uClipZ = 640; //this->field_40044 = 2; //this->field_40048 = 6; - this->pFrontBuffer4 = 0; - this->pBackBuffer4 = 0; + this->pFrontBuffer4 = nullptr; + this->pBackBuffer4 = nullptr; //this->pColorKeySurface4 = 0; - this->pDirectDraw4 = 0; + this->pDirectDraw4 = nullptr; this->pRenderD3D = 0; this->uNumSceneBegins = 0; this->uNumD3DSceneBegins = 0; this->using_software_screen_buffer = 0; - this->pTargetSurface = 0; + this->pTargetSurface = nullptr; this->uTargetSurfacePitch = 0; this->uClipY = 0; this->uClipX = 0; @@ -2827,7 +2797,6 @@ { if (!pDefaultZBuffer) { - pDefaultZBuffer = pActiveZBuffer = nullptr; pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) } @@ -2863,21 +2832,18 @@ pRenderD3D->ClearTarget(true, 0, false, 1.0); } //v1->pColorKeySurface4 = 0; - v1->pBackBuffer4 = 0; - v1->pFrontBuffer4 = 0; - v1->pDirectDraw4 = 0; - if (v1->pTargetSurface) - { - delete [] v1->pTargetSurface_unaligned; - v1->pTargetSurface = 0; - v1->pTargetSurface_unaligned = 0; - } + v1->pBackBuffer4 = nullptr; + v1->pFrontBuffer4 = nullptr; + v1->pDirectDraw4 = nullptr; + delete [] v1->pTargetSurface_unaligned; + v1->pTargetSurface = nullptr; + v1->pTargetSurface_unaligned = nullptr; if (pRenderD3D) { pRenderD3D->Release(); delete pRenderD3D; } - pRenderD3D = 0; + pRenderD3D = nullptr; } else ;//__debugbreak(); // no sr @@ -3199,9 +3165,9 @@ //v2 = this; this->using_software_screen_buffer = 0; //this->pColorKeySurface4 = 0; - this->pBackBuffer4 = 0; - this->pFrontBuffer4 = 0; - this->pDirectDraw4 = 0; + this->pBackBuffer4 = nullptr; + this->pFrontBuffer4 = nullptr; + this->pDirectDraw4 = nullptr; //this->bColorKeySupported = 0; Release(); //v3 = hWnd; @@ -3256,10 +3222,10 @@ pRenderD3D->Release(); delete pRenderD3D; } - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device failed to return capabilities."); } if ( v10 & 0x3E ) @@ -3270,10 +3236,10 @@ delete pRenderD3D; } //pColorKeySurface4 = 0; - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); } if ( (v10 & 0x80u) != 0 ) @@ -3283,10 +3249,10 @@ pRenderD3D->Release(); delete pRenderD3D; } - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device doesn't support non-square textures."); } //LOBYTE(field_10365C) = ~(unsigned __int8)(v10 >> 6) & 1; @@ -3357,8 +3323,7 @@ } else*/ { - pTargetSurface = 0; - pTargetSurface_unaligned = 0; + pTargetSurface = nullptr; pTargetSurface_unaligned = (unsigned int *)malloc(window->GetWidth() * window->GetHeight() * 2 + 32); if ( !pTargetSurface_unaligned || (memset(&pDesc, 0, 0x7Cu), @@ -3418,9 +3383,9 @@ using_software_screen_buffer = 0; Release(); //pColorKeySurface4 = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; //bColorKeySupported = 0; CreateZBuffer(); /*if (!bUserDirect3D) @@ -3476,10 +3441,10 @@ pRenderD3D->Release(); delete pRenderD3D; } - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device failed to return capabilities."); } if ( v9 & 0x3E ) @@ -3490,10 +3455,10 @@ delete pRenderD3D; } //pColorKeySurface4 = 0; - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device doesn't support the necessary alpha blending modes."); } if (v9 & 0x80) @@ -3503,10 +3468,10 @@ pRenderD3D->Release(); delete pRenderD3D; } - pRenderD3D = 0; - pBackBuffer4 = 0; - pFrontBuffer4 = 0; - pDirectDraw4 = 0; + pRenderD3D = nullptr; + pBackBuffer4 = nullptr; + pFrontBuffer4 = nullptr; + pDirectDraw4 = nullptr; Error("Direct3D renderer: The device doesn't support non-square textures."); } //LOBYTE(field_10365C) = ~(unsigned __int8)(v9 >> 6) & 1; @@ -8816,7 +8781,7 @@ array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) return; - if ( ODMFace::IsBackfaceCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) + if ( ODMFace::IsBackfaceNotCulled(array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) { pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; diff -r 14c05b876218 -r bcd7fadbf7d2 SaveLoad.cpp --- a/SaveLoad.cpp Mon May 12 12:27:50 2014 +0600 +++ b/SaveLoad.cpp Mon May 12 12:28:06 2014 +0600 @@ -426,9 +426,9 @@ pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 data_write_pos += sizeof(DDM_DLV_Header); - memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); + memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8); data_write_pos += 968; - memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); + memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8); data_write_pos += 968; for (int i = 0; i < pOutdoor->uNumBModels ; ++i) for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) diff -r 14c05b876218 -r bcd7fadbf7d2 Spells.cpp --- a/Spells.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Spells.cpp Mon May 12 12:28:06 2014 +0600 @@ -324,11 +324,9 @@ char* test_string; - if ( pSpellsTXT_Raw ) - free(pSpellsTXT_Raw); - pSpellsTXT_Raw = NULL; + free(pSpellsTXT_Raw); + pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); - pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); strtok(pSpellsTXT_Raw, "\r"); strtok(NULL, "\r"); for(int i=1; i<100; ++i) diff -r 14c05b876218 -r bcd7fadbf7d2 Sprites.cpp --- a/Sprites.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Sprites.cpp Mon May 12 12:28:06 2014 +0600 @@ -26,15 +26,9 @@ //----- (0044D4D8) -------------------------------------------------------- void SpriteFrameTable::ReleaseSFrames() { - SpriteFrameTable *v1; // esi@1 - - v1 = this; - if ( this->pSpriteSFrames ) - { - free(this->pSpriteSFrames); - v1->pSpriteSFrames = 0; - } - v1->uNumSpriteFrames = 0; + free(this->pSpriteSFrames); + this->pSpriteSFrames = nullptr; + this->uNumSpriteFrames = 0; } //----- (0044D4F6) -------------------------------------------------------- diff -r 14c05b876218 -r bcd7fadbf7d2 StorylineTextTable.cpp --- a/StorylineTextTable.cpp Mon May 12 12:27:50 2014 +0600 +++ b/StorylineTextTable.cpp Mon May 12 12:28:06 2014 +0600 @@ -14,9 +14,7 @@ { char* test_string; - if ( pHistoryTXT_Raw ) - free(pHistoryTXT_Raw); - pHistoryTXT_Raw = NULL; + free(pHistoryTXT_Raw); pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); strtok(pHistoryTXT_Raw, "\r"); diff -r 14c05b876218 -r bcd7fadbf7d2 Texture.cpp --- a/Texture.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Texture.cpp Mon May 12 12:28:06 2014 +0600 @@ -507,12 +507,12 @@ uWidthLn2 = 0; palette_id1 = 0; palette_id2 = 0; - pLevelOfDetail0_prolly_alpha_mask = 0; - pLevelOfDetail3 = 0; - pLevelOfDetail2 = 0; - pLevelOfDetail1 = 0; - pPalette16 = 0; - pPalette24 = 0; + pLevelOfDetail0_prolly_alpha_mask = nullptr; + pLevelOfDetail3 = nullptr; + pLevelOfDetail2 = nullptr; + pLevelOfDetail1 = nullptr; + pPalette16 = nullptr; + pPalette24 = nullptr; } //----- (0040F414) -------------------------------------------------------- @@ -559,7 +559,7 @@ if ( this->pPixels ) { if ( mode ) - { + { if ( mode != 2 ) { if ( !this->pPixels ) @@ -575,7 +575,7 @@ this->DecodePCX(Str1a, this->pPixels, this->uWidth); free(Str1a); return 0; - } + } free(this->pPixels); } if ( !mode ) @@ -1153,11 +1153,7 @@ if ( mode == 0 ) { - if ( pPixels ) - { - free(pPixels); - pPixels = 0; - } + free(pPixels); pPixels = (unsigned __int16 *)malloc(2 * uNumPixels + 4); } else @@ -1367,8 +1363,7 @@ this->uNumPixels = (signed __int16)this->uWidth * (signed __int16)this->uHeight; if ( !a3 ) { - if ( this->pPixels ) - free(this->pPixels); + free(this->pPixels); this->pPixels = (unsigned __int16 *)malloc(2 * this->uNumPixels + 4); } if ( a3 == 2 ) diff -r 14c05b876218 -r bcd7fadbf7d2 TileTable.cpp --- a/TileTable.cpp Mon May 12 12:27:50 2014 +0600 +++ b/TileTable.cpp Mon May 12 12:28:06 2014 +0600 @@ -15,11 +15,8 @@ //----- (00487E1D) -------------------------------------------------------- TileTable::~TileTable() { - if ( pTiles ) - { - free(pTiles); - pTiles = nullptr; - } + free(pTiles); + pTiles = nullptr; sNumTiles = 0; } diff -r 14c05b876218 -r bcd7fadbf7d2 UI/Books/UIMapBook.cpp --- a/UI/Books/UIMapBook.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/Books/UIMapBook.cpp Mon May 12 12:28:06 2014 +0600 @@ -571,9 +571,9 @@ for (int x = 0; x < screenCenterY; ++x) { map_tile_X = (v64 - 80) / 4; - if ( !pOutdoor->_47F04C(map_tile_X, map_tile_Y) ) + if ( !pOutdoor->IsMapCellFullyRevealed(map_tile_X, map_tile_Y) ) { - if ( pOutdoor->_47F097(map_tile_X, map_tile_Y) ) + if ( pOutdoor->IsMapCellPartiallyRevealed(map_tile_X, map_tile_Y) ) { if ( !((x + screenCenter_X) % 2) ) //*a4a = Color16(12, 12, 12); @@ -678,7 +678,7 @@ result = 0; map_tile_X = abs(global_coord_X + 22528) / 512;//In the mapbook only lady Margaret dispays for defoult zoom( ) map_tile_Y = abs(global_coord_Y - 22528) / 512; - if ( pOutdoor->_47F04C(map_tile_X, map_tile_Y) && uCurrentlyLoadedLevelType == LEVEL_Outdoor && (signed int)pOutdoor->uNumBModels > 0 ) + if ( pOutdoor->IsMapCellFullyRevealed(map_tile_X, map_tile_Y) && uCurrentlyLoadedLevelType == LEVEL_Outdoor && (signed int)pOutdoor->uNumBModels > 0 ) { for(int i = 0; i < pOutdoor->uNumBModels && !result; i++) { diff -r 14c05b876218 -r bcd7fadbf7d2 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/UICharacter.cpp Mon May 12 12:28:06 2014 +0600 @@ -818,7 +818,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -862,7 +862,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(item->GetIconName(), TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), @@ -923,7 +923,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_texture[pBodyComplection][index]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -988,7 +988,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][0]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1050,7 +1050,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v59), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1119,7 +1119,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v75), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1209,7 +1209,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v94), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1252,7 +1252,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_armor_texture[pBodyComplection][index][1]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1316,7 +1316,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(paperdoll_cloak_collar_texture[pBodyComplection][index]), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1379,7 +1379,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v127), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1437,7 +1437,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE)), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1509,7 +1509,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0Fu; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(item_X, item_Y, pIcons_LOD->GetTexture(v153), pIcons_LOD->LoadTexturePtr(container, TEXTURE_16BIT_PALETTE), GetTickCount() * 0.1, 0, 255); @@ -1588,7 +1588,7 @@ { _50C9A8_item_enchantment_timer = 0; LOBYTE(player->pInventoryItemList[player->pInventoryMatrix[i] - 1].uAttributes) &= 0xF; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(uCellX, uCellY, pTexture, loadedTextureptr, GetTickCount() * 0.1, 0, 255); @@ -1631,7 +1631,7 @@ { _50C9A8_item_enchantment_timer = 0; item->uAttributes &= 0xFFFFFF0F; - ptr_50C9A4_ItemToEnchant = 0; + ptr_50C9A4_ItemToEnchant = nullptr; } pRenderer->DrawAura(x, y, item_texture, enchantment_texture, GetTickCount() * 0.1, 0, 255); } diff -r 14c05b876218 -r bcd7fadbf7d2 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/UIHouses.cpp Mon May 12 12:28:06 2014 +0600 @@ -3087,9 +3087,7 @@ char* tmp_pos; int decode_step; - if ( p2DEventsTXT_Raw ) - free(p2DEventsTXT_Raw); - p2DEventsTXT_Raw = NULL; + free(p2DEventsTXT_Raw); p2DEventsTXT_Raw = (char *)pEvents_LOD->LoadRaw("2dEvents.txt", 0); strtok(p2DEventsTXT_Raw, "\r"); strtok(NULL, "\r"); diff -r 14c05b876218 -r bcd7fadbf7d2 UI/UIPopup.cpp --- a/UI/UIPopup.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/UIPopup.cpp Mon May 12 12:28:06 2014 +0600 @@ -132,7 +132,7 @@ if (!inspect_item->uItemID) return; - iteminfo_window.Hint = 0; + iteminfo_window.Hint = nullptr; iteminfo_window.uFrameWidth = 384; iteminfo_window.uFrameHeight = 180; iteminfo_window.uFrameY = 40; @@ -1256,7 +1256,7 @@ spell_info_window.uFrameX = 90; spell_info_window.uFrameZ = 417; spell_info_window.uFrameW = v3 + 67; - spell_info_window.Hint = 0; + spell_info_window.Hint = nullptr; v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL]); if ( pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_MASTER]) > v5 ) v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_MASTER]); @@ -1378,7 +1378,7 @@ popup_window.ptr_1C = (void *)((signed int)pX / 118); if ( (signed int)pX / 118 < 4 )//portaits zone { - popup_window.Hint = 0; + popup_window.Hint = nullptr; popup_window.uFrameWidth = 400; popup_window.uFrameHeight = 200; popup_window.uFrameX = 38; @@ -1393,7 +1393,7 @@ { if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 )//buff_tooltip zone { - popup_window.Hint = 0; + popup_window.Hint = nullptr; popup_window.uFrameWidth = 400; popup_window.uFrameHeight = 200; popup_window.uFrameX = 38; @@ -1428,7 +1428,7 @@ } else//game zone { - popup_window.Hint = 0; + popup_window.Hint = nullptr; popup_window.uFrameWidth = 320; popup_window.uFrameHeight = 320; popup_window.uFrameX = pX - 350; @@ -1509,7 +1509,7 @@ } case SCREEN_PARTY_CREATION: { - popup_window.Hint = 0; + popup_window.Hint = nullptr; pStr = 0; for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext) { @@ -1566,7 +1566,7 @@ if ( popup_window.Hint ) { pHint = popup_window.Hint; - popup_window.Hint = 0; + popup_window.Hint = nullptr; popup_window.uFrameWidth = 384; popup_window.uFrameHeight = 256; popup_window.uFrameX = 128; diff -r 14c05b876218 -r bcd7fadbf7d2 UI/UIShops.cpp --- a/UI/UIShops.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/UIShops.cpp Mon May 12 12:28:06 2014 +0600 @@ -1811,7 +1811,7 @@ v3 = pMouse->GetCursorPos(&a2)->y + 30; else v3 = 30; - a1.Hint = 0; + a1.Hint = nullptr; a1.uFrameY = v3; a1.uFrameWidth = 328; a1.uFrameHeight = 68; diff -r 14c05b876218 -r bcd7fadbf7d2 UI/UiGame.cpp --- a/UI/UiGame.cpp Mon May 12 12:27:50 2014 +0600 +++ b/UI/UiGame.cpp Mon May 12 12:28:06 2014 +0600 @@ -209,7 +209,7 @@ if ( !lpsz ) lpsz = ""; } - popup_window.Hint = 0; + popup_window.Hint = nullptr; popup_window.uFrameX = 38; popup_window.uFrameY = 60; popup_window.uFrameWidth = 276; @@ -363,7 +363,7 @@ unsigned __int16 pTextColor; // ax@104 GUIWindow window; // [sp+ACh] [bp-68h]@42 // GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39 - const char *pInString=NULL; // [sp+110h] [bp-4h]@32 + const char *pInString=nullptr; // [sp+110h] [bp-4h]@32 if ( !pDialogueWindow ) return; @@ -577,7 +577,7 @@ if (pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1) { int num_dead_actors = 0; - pInString = 0; + pInString = nullptr; for ( uint i = 0; i < uNumActors; ++i ) { if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || pActors[i].uAIState == Disabled) diff -r 14c05b876218 -r bcd7fadbf7d2 VideoPlayer.cpp --- a/VideoPlayer.cpp Mon May 12 12:27:50 2014 +0600 +++ b/VideoPlayer.cpp Mon May 12 12:28:06 2014 +0600 @@ -232,8 +232,6 @@ } ReadFile(hMightVid, &uNumMightVideoHeaders, 4, &NumberOfBytesRead, 0); ReadFile(hMagicVid, &uNumMagicVideoHeaders, 4, &NumberOfBytesRead, 0); - pMagicVideoHeaders = 0; - pMightVideoHeaders = 0; pMightVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMightVideoHeaders + 2); pMagicVideoHeaders = (MovieHeader *)malloc(sizeof(MovieHeader) * uNumMagicVideoHeaders + 2); ReadFile(hMightVid, pMightVideoHeaders, 44 * uNumMightVideoHeaders, &NumberOfBytesRead, 0); @@ -256,11 +254,8 @@ AIL_redbook_resume(pAudioPlayer->hAILRedbook); pEventTimer->Resume(); - if (pMovie) - { - delete pMovie; - pMovie = nullptr; - } + delete pMovie; + pMovie = nullptr; } void VideoPlayer::_inlined_in_463149() diff -r 14c05b876218 -r bcd7fadbf7d2 Viewport.cpp --- a/Viewport.cpp Mon May 12 12:27:50 2014 +0600 +++ b/Viewport.cpp Mon May 12 12:28:06 2014 +0600 @@ -546,7 +546,7 @@ v15 = stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380; activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; EventProcessor(v15, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; } return; } diff -r 14c05b876218 -r bcd7fadbf7d2 mm7_2.cpp --- a/mm7_2.cpp Mon May 12 12:27:50 2014 +0600 +++ b/mm7_2.cpp Mon May 12 12:28:06 2014 +0600 @@ -578,7 +578,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_CANCELLED); pKeyActionMap->ResetKeys(); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; current_npc_text = 0; if ( pDialogueNPCCount == 0) return 0; @@ -959,661 +959,6 @@ return result; } -//----- (0044F57C) -------------------------------------------------------- -void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) -{ - //MapInfo *v5; // esi@1 - //SpawnPointMM7 *v6; // ebx@1 - int v7; // eax@2 - char v8; // zf@5 -// int v9; // edi@9 -// int v10; // eax@9 -// int v11; // ecx@9 - int v12; // edx@9 -// int v13; // eax@9 -// int v14; // eax@14 -// int v15; // ecx@14 -// int v16; // eax@19 -// int v17; // ecx@19 - int v18; // esi@31 - //int pPosX; // ecx@32 - //int v20; // edx@32 - //int v21; // eax@32 - Actor *pMonster; // esi@35 - int v23; // edx@36 - signed int v24; // edi@36 - int v25; // ecx@36 -// unsigned __int16 v26; // ax@47 - MonsterDesc *v27; // edi@48 - signed int v28; // eax@48 -// __int16 v29; // cx@50 -// __int16 v30; // ax@50 -// __int16 v31; // ax@50 - int v32; // eax@50 -// int v33; // edi@50 -// int v34; // eax@50 -// int v35; // eax@50 -// int v36; // eax@50 - int v37; // eax@51 - int v38; // eax@52 - int v39; // edi@52 - std::string v40; // [sp-18h] [bp-100h]@60 -// void *v41; // [sp-14h] [bp-FCh]@50 - //void *v42; // [sp-10h] [bp-F8h]@50 - //size_t v43; // [sp-Ch] [bp-F4h]@50 - const char *v44; // [sp-8h] [bp-F0h]@13 - char *pTexture; // [sp-4h] [bp-ECh]@9 - char Str[32]; // [sp+Ch] [bp-DCh]@60 - char Str2[120]; // [sp+2Ch] [bp-BCh]@29 - unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 - MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 - int v50; // [sp+ACh] [bp-3Ch]@47 - char Source[32]; // [sp+B0h] [bp-38h]@20 - int v52; // [sp+D0h] [bp-18h]@34 - int v53; // [sp+D4h] [bp-14h]@34 - int pSector; // [sp+D8h] [bp-10h]@32 - int pPosX; // [sp+DCh] [bp-Ch]@32 - int v56; // [sp+E0h] [bp-8h]@8 - int v57; // [sp+E4h] [bp-4h]@1 - - //auto a2 = spawn; - v57 = 0; - //v5 = pMapInfo; - //v6 = spawn; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - v7 = pOutdoor->ddm.field_C_alert; - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - v7 = pIndoor->dlv.field_C_alert; - else - v7 = 0; - if (v7) - v8 = (spawn->uAttributes & 1) == 0; - else - v8 = (spawn->uAttributes & 1) == 1; - if (v8) - return; - //result = (void *)(spawn->uIndex - 1); - v56 = 1; - switch (spawn->uIndex - 1) - { - case 0: - //v9 = pMapInfo->uEncounterMonster1AtLeast; - //v10 = rand(); - //v11 = pMapInfo->uEncounterMonster1AtMost; - //pTexture = pMapInfo->pEncounterMonster1Texture; - v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1); - //v13 = pMapInfo->Dif_M1; - v57 = pMapInfo->Dif_M1; - v56 = pMapInfo->uEncounterMonster1AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster1Texture); - break; - case 3: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture); - break; - case 4: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture); - break; - case 5: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture); - break; - case 1: - //v9 = pMapInfo->uEncounterMonster2AtLeast; - //v14 = rand(); - //v15 = pMapInfo->uEncounterMonster2AtMost; - //pTexture = pMapInfo->pEncounterMonster2Texture; - v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1); - //v13 = pMapInfo->Dif_M2; - v57 = pMapInfo->Dif_M2; - v56 = pMapInfo->uEncounterMonster2AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster2Texture); - break; - case 6: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture); - break; - case 7: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture); - break; - case 8: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture); - break; - case 2: - //v9 = pMapInfo->uEncounterMonster3AtLeast; - //v16 = rand(); - //v17 = pMapInfo->uEncounterMonster3AtMost; - //pTexture = pMapInfo->pEncounterMonster3Texture; - v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1); - //v13 = pMapInfo->Dif_M3; - v57 = pMapInfo->Dif_M3; - v56 = pMapInfo->uEncounterMonster3AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster3Texture); - break; - case 9: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture); - break; - case 10: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture); - break; - case 11: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture); - break; - default: - return; - } - if (Source[0] == '0') - return; - v57 += a3; - if ( v57 > 4 ) - v57 = 4; - strcpy(Str2, Source); - if ( a4 ) - v56 = a4; - v18 = v56; - if ( (signed int)(v56 + uNumActors) >= 500 ) - return; - pSector = 0; - pPosX = spawn->vPosition.x; - a4 = spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); - v53 = 0; - v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - if ( v18 <= 0 ) - return; - for (uint i = v53; i < v56; ++i) - { - pMonster = &pActors[uNumActors]; - pActors[uNumActors].Reset(); - if ( v57 ) - { - v23 = rand() % 100; - v24 = 3; - v25 = (unsigned __int16)word_4E8152[3 * v57]; - if ( v23 >= v25 ) - { - if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) - v24 = 2; - } - else - { - v24 = 1; - } - if ( v24 == 1 ) - { - pTexture = Source; - v44 = "%s A"; - } - else - { - if ( v24 == 2 ) - { - pTexture = Source; - v44 = "%s B"; - } - else - { - if ( v24 != 3 ) - continue; - pTexture = Source; - v44 = "%s C"; - } - } - sprintf(Str2, v44, pTexture); - } - v50 = pMonsterList->GetMonsterIDByName(Str2); - pTexture = Str2; - if ( (signed __int16)v50 == -1 ) - { - sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); - MessageBoxA(nullptr, Str, nullptr, 0); - ExitProcess(0); - } - v27 = &pMonsterList->pMonsters[(signed __int16)v50]; - v28 = pMonsterStats->FindMonsterByTextureName(pTexture); - if ( !v28 ) - v28 = 1; - Src = &pMonsterStats->pInfos[v28]; - strcpy(pMonster->pActorName, Src->pName); - pMonster->sCurrentHP = Src->uHP; - assert(sizeof(MonsterInfo) == 88); - memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo)); - pMonster->word_000086_some_monster_id = v50 + 1; - pMonster->uActorRadius = v27->uMonsterRadius; - pMonster->uActorHeight = v27->uMonsterHeight; - pMonster->uMovementSpeed = v27->uMovementSpeed; - pMonster->vInitialPosition.x = spawn->vPosition.x; - pMonster->vPosition.x = spawn->vPosition.x; - pMonster->uTetherDistance = 256; - pMonster->vInitialPosition.y = a4; - pMonster->vPosition.y = a4; - pMonster->vInitialPosition.z = a3; - pMonster->vPosition.z = a3; - pMonster->uSectorID = pSector; - pMonster->uGroup = spawn->uGroup; - pMonster->PrepareSprites(0); - pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v32 = rand(); - a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52); - pPosX = a3 + spawn->vPosition.x; - a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52); - a4 = a3 + spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - if ( a5 ) - pMonster->uAttributes |= 0x080000; - ++uNumActors; - continue; - } - v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z); - if ( v37 == pSector ) - { - v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); - v39 = v38; - if ( v38 != -30000 ) - { - if ( abs(v38 - a3) <= 1024 ) - { - a3 = v39; - if ( a5 ) - pMonster->uAttributes |= 0x080000; - ++uNumActors; - continue; - } - } - } - ; - //v53 = (char *)v53 + 1; - //result = v53; - } - //while ( (signed int)v53 < v56 ); -} - -//----- (0044FA4C) -------------------------------------------------------- -signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) -{ - signed int v3; // ecx@6 - Actor *v4; // edx@7 - signed int result; // eax@13 - Actor *v6; // esi@16 - char *v7; // ebx@16 - MonsterDesc *v8; // edi@16 - unsigned __int16 v9; // ax@16 - int v10; // ebx@16 - //int v11; // edi@16 - //int v12; // eax@16 - //int v13; // ecx@16 - //int v14; // ebx@16 - const char *v15; // [sp-4h] [bp-24h]@2 - //unsigned __int16 v16; // [sp+0h] [bp-20h]@1 - //int v17; // [sp+4h] [bp-1Ch]@1 - unsigned int uFaceID; // [sp+8h] [bp-18h]@16 - int v19; // [sp+Ch] [bp-14h]@16 - size_t v20; // [sp+10h] [bp-10h]@6 - int v21; // [sp+14h] [bp-Ch]@14 - //int v22; // [sp+18h] [bp-8h]@14 - unsigned int v23; // [sp+1Ch] [bp-4h]@6 - - //v16 = a2; - //v17 = a1; - if ( a2 == 4 ) - { - v15 = "Elemental Light C"; - } - else if ( a2 == 3 ) - v15 = "Elemental Light B"; - else - v15 = "Elemental Light A"; - - v23 = pMonsterList->GetMonsterIDByName(v15); - v3 = 0; - v20 = uNumActors; - if ( (signed int)uNumActors > 0 ) - { - v4 = pActors.data();//[0].uAIState; - while ( v4->uAIState != Removed ) - { - ++v3; - ++v4; - if ( v3 >= (signed int)uNumActors ) - break; - } - if( v3 < (signed int)uNumActors ) - v20 = v3; - } - if ( v20 != uNumActors || (result = uNumActors + 1, (signed int)(uNumActors + 1) < 500) ) - { - v21 = 0; - //v22 = pParty->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - v6 = &pActors[v20]; - v7 = (char *)&pMonsterStats->pInfos[v23 + 1]; - v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - v6->Reset(); - v8 = &pMonsterList->pMonsters[v23]; - strcpy(v6->pActorName, *(const char **)v7); - v6->sCurrentHP = *((short *)v7 + 32); - memcpy(&v6->pMonsterInfo, v7, 0x58u); - v6->word_000086_some_monster_id = v23 + 1; - v6->uActorRadius = v8->uMonsterRadius; - v6->uActorHeight = v8->uMonsterHeight; - v9 = v8->uMovementSpeed; - v6->pMonsterInfo.uTreasureDiceRolls = 0; - v6->pMonsterInfo.uTreasureType = 0; - v6->pMonsterInfo.uExp = 0; - v6->uMovementSpeed = v9; - v10 = rand() % 2048; - //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); - uFaceID = stru_5C6E00->Sin(v10); - //v12 = pParty->vPosition.y; - //v13 = fixpoint_mul(uFaceID, v19); - //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); - //LOWORD(v12) = v22; - v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); - v6->vPosition.x = v6->vInitialPosition.x; - v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); - v6->vPosition.y = v6->vInitialPosition.y; - v6->vInitialPosition.z = pParty->vPosition.z; - v6->vPosition.z = v6->vInitialPosition.z; - //LOWORD(v12) = v21; - v6->uTetherDistance = 256; - v6->uSectorID = v21; - v6->PrepareSprites(0); - v6->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v6->uAlly = 9999; - v6->uGroup = 0; - v6->uCurrentActionTime = 0; - v6->uAIState = Summoned; - v6->uCurrentActionLength = 256; - v6->UpdateAnimation(); - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor - || (result = pIndoor->GetSector(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z), - result == v21) - && (result = BLV_GetFloorLevel(v6->vPosition.x, v6->vPosition.y, v6->vPosition.z, result, &uFaceID), result != -30000) - && (result = abs(result - pParty->vPosition.z), result <= 1024) ) - { - if ( v20 == uNumActors ) - ++uNumActors; - v6->uSummonerID = PID(OBJECT_Player, a1); - result = v6->pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, - a2, - a1, - 0, - 0); - } - } - return result; -} - -//----- (00450521) -------------------------------------------------------- -int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6) -{ - int v6; // edi@1 - int v7; // esi@1 - signed int v8; // edi@1 - unsigned __int16 v9; // cx@1 -// char *v10; // edx@2 - unsigned __int16 v11; // ax@5 - SpriteObject a1; // [sp+8h] [bp-70h]@1 - - v6 = ecx0; - v7 = a2; - pItemsTable->GenerateItem(v6, v7, &a1.stru_24); - v8 = 0; - v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; - a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; - v11 = 0; - for( int i = 0; i < pObjectList->uNumObjects; i++ ) - { - if( v9 == pObjectList->pObjects[i].uObjectID ) - { - v11 = i; - break; - } - } - a1.uObjectDescID = v11; - a1.vPosition.y = a4; - a1.vPosition.x = a3; - a1.vPosition.z = a5; - a1.uFacing = a6; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a3, a4, a5); - a1.uSpriteFrameID = 0; - return a1.Create(0, 0, 0, 0); -} - -//----- (0045063B) -------------------------------------------------------- -int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) -{ - int result; // eax@8 - int v6; // edi@11 - int v7; // ebx@11 - int v8; // edi@11 - int v9; // ebx@12 - int v10; // eax@12 - char v11; // zf@16 - int v12; // edi@20 - int v13; // eax@20 - int v14; // ebx@20 - int v15; // eax@20 - int v16; // eax@20 - int v17; // eax@20 - int v18; // eax@21 - SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 - int v22; // [sp+2Ch] [bp-18h]@3 - unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 - int v26; // [sp+3Ch] [bp-8h]@11 - int v27; // [sp+40h] [bp-4h]@11 - - if (!uNumActors) - return 0; - - for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) - { - if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C - (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C - (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C - pActors[mon_id].CanAct()) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - v22 = 0; - uint face_id = 0; - for ( face_id; face_id < 100; ++face_id ) - { - v6 = rand() % 1024 + 512; - v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); - v8 = 0; - v19.uIndex = a2; - v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v26 = 0; - v27 = 0; - v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); - for( int i = 0; i < pOutdoor->uNumBModels; i++ ) - { - v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); - v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); - if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) - { - v22 = 1; - break; - } - } - if ( v22 ) - { - v11 = face_id == 100; - break; - } - } - v11 = face_id == 100; - } - else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - for ( uint i = 0; i < 100; ++i ) - { - v12 = rand() % 512 + 256; - v13 = rand(); - v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; - v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); - v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = a2; - v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); - if ( v17 == v22 ) - { - v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); - v19.vPosition.z = v18; - if ( v18 != -30000 ) - { - if ( abs(v18 - pParty->vPosition.z) <= 1024 ) - break; - } - } - } - v11 = v26 == 100; - } - if ( v11 ) - result = 0; - else - { - SpawnEncounter(a1, &v19, 0, 0, 1); - result = a2; - } - } - - //break; - //v22 = v3->pMonsterInfo.uID - 1; - //v4 = (signed __int64)((double)v22 * 0.3333333333333333); - //if ( (int)v4 != 40 ) - //{ - // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) - // break; - //} - //++v2; - //++v3; - //if ( v2 >= (signed int)uNumActors ) - // goto LABEL_8; - } - return result; -} - -//----- (00450AAA) -------------------------------------------------------- -void RespawnGlobalDecorations() -{ - memset(stru_5E4C90_MapPersistVars._decor_events.data(), 0, 125); - - uint decorEventIdx = 0; - for (uint i = 0; i < uNumLevelDecorations; ++i) - { - LevelDecoration* decor = &pLevelDecorations[i]; - - if (!decor->uEventID) - { - if (decor->IsInteractive()) - { - if (decorEventIdx < 124) - { - decor->_idx_in_stru123 = decorEventIdx + 75; - stru_5E4C90_MapPersistVars._decor_events[decorEventIdx++] = decor->GetGlobalEvent(); - } - } - } - } -} - -//----- (00450B0A) -------------------------------------------------------- -bool __fastcall SpawnActor(unsigned int uMonsterID) -{ - unsigned int v1; // ebx@1 - bool result; // eax@2 - MonsterDesc *v3; // esi@5 - MonsterInfo *v4; // edi@5 - Vec3_int_ v5; // ST08_12@5 - unsigned int v6; // ecx@5 - Actor *v7; // eax@7 - Actor actor; // [sp+4h] [bp-350h]@5 - Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 - - v1 = uMonsterID; - if ( uNumActors == 499 ) - { - result = 0; - } - else - { - if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) - v1 = 0; - v3 = &pMonsterList->pMonsters[v1]; - v4 = &pMonsterStats->pInfos[v1 + 1]; - memset(&actor, 0, 0x344u); - strcpy(actor.pActorName, v4->pName); - actor.sCurrentHP = LOWORD(v4->uHP); - memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], 0x58u); - actor.word_000086_some_monster_id = v1 + 1; - actor.uActorRadius = v3->uMonsterRadius; - actor.uActorHeight = v3->uMonsterHeight; - actor.uMovementSpeed = v3->uMovementSpeed; - v5 = pParty->vPosition; - Vec3_int_::Rotate(200, pParty->sRotationY, 0, v5, &pOut.x, &pOut.z, &pOut.y); - actor.vInitialPosition.x = pOut.x; - actor.vPosition.x = pOut.x; - actor.uTetherDistance = 256; - actor.vInitialPosition.y = LOWORD(pOut.z); - actor.vPosition.y = LOWORD(pOut.z); - actor.vInitialPosition.z = LOWORD(pOut.y); - actor.vPosition.z = LOWORD(pOut.y); - pSprites_LOD->DeleteSomeSprites(); - pPaletteManager->ResetNonTestLocked(); - v6 = uNumActors - 1; - if ( dword_5C6DF8 == 1 ) - { - dword_5C6DF8 = 0; - v6 = uNumActors++; - } - v7 = &pActors[v6]; - memcpy(v7, &actor, 0x344u); - v7->PrepareSprites(1); - result = 1; - } - return result; -} -// 5C6DF8: using guessed type int dword_5C6DF8; - -//----- (00450DA3) -------------------------------------------------------- -int GetAlertStatus() -{ - int result; // eax@2 - - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - result = pOutdoor->ddm.field_C_alert; - else - result = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0; - return result; -} //----- (00450DDE) -------------------------------------------------------- stru350 *stru350::_450DDE() @@ -1894,9 +1239,7 @@ int decode_step; // int item_counter; - if ( pHostileTXT_Raw ) - free(pHostileTXT_Raw); - pHostileTXT_Raw = NULL; + free(pHostileTXT_Raw); pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); strtok(pHostileTXT_Raw, "\r"); for ( i=0; i < 89; ++i ) @@ -1929,11 +1272,8 @@ } while ((decode_step < 92) && !break_loop ); } - if ( pHostileTXT_Raw) - { - free(pHostileTXT_Raw); - pHostileTXT_Raw = NULL; - } + free(pHostileTXT_Raw); + pHostileTXT_Raw = nullptr; } diff -r 14c05b876218 -r bcd7fadbf7d2 mm7_3.cpp --- a/mm7_3.cpp Mon May 12 12:27:50 2014 +0600 +++ b/mm7_3.cpp Mon May 12 12:28:06 2014 +0600 @@ -2272,7 +2272,7 @@ if (!skybox_xp || xp_width != xn_width || xp_height != xn_height) { delete [] skybox_xn; - if (skybox_xp) delete [] skybox_xp; + delete [] skybox_xp; return false; } @@ -2281,8 +2281,8 @@ if (!skybox_yn || yn_width != xn_width || yn_height != xn_height) { delete [] skybox_xn; - if (skybox_xp) delete [] skybox_xp; - if (skybox_yn) delete [] skybox_yn; + delete [] skybox_xp; + delete [] skybox_yn; return false; } @@ -2291,9 +2291,9 @@ if (!skybox_yp || yp_width != xn_width || yp_height != xn_height) { delete [] skybox_xn; - if (skybox_xp) delete [] skybox_xp; - if (skybox_yn) delete [] skybox_yn; - if (skybox_yp) delete [] skybox_yp; + delete [] skybox_xp; + delete [] skybox_yn; + delete [] skybox_yp; return false; } @@ -2302,10 +2302,10 @@ if (!skybox_zn || zn_width != xn_width || zn_height != xn_height) { delete [] skybox_xn; - if (skybox_xp) delete [] skybox_xp; - if (skybox_yn) delete [] skybox_yn; - if (skybox_yp) delete [] skybox_yp; - if (skybox_zn) delete [] skybox_zn; + delete [] skybox_xp; + delete [] skybox_yn; + delete [] skybox_yp; + delete [] skybox_zn; return false; } @@ -2314,11 +2314,11 @@ if (!skybox_zp || zp_width != xn_width || zp_height != xn_height) { delete [] skybox_xn; - if (skybox_xp) delete [] skybox_xp; - if (skybox_yn) delete [] skybox_yn; - if (skybox_yp) delete [] skybox_yp; - if (skybox_zn) delete [] skybox_zn; - if (skybox_zp) delete [] skybox_zp; + delete [] skybox_xp; + delete [] skybox_yn; + delete [] skybox_yp; + delete [] skybox_zn; + delete [] skybox_zp; return false; } @@ -3618,7 +3618,7 @@ pGUIWindow2 = 0; activeLevelDecoration = _591094_decoration; EventProcessor(dword_5C3418, 0, 1, dword_5C341C); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; pEventTimer->Resume(); } diff -r 14c05b876218 -r bcd7fadbf7d2 mm7_4.cpp --- a/mm7_4.cpp Mon May 12 12:27:50 2014 +0600 +++ b/mm7_4.cpp Mon May 12 12:28:06 2014 +0600 @@ -2262,7 +2262,7 @@ activeLevelDecoration = (LevelDecoration*)1; current_npc_text = 0; EventProcessor(npc_event_id, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; break; } } diff -r 14c05b876218 -r bcd7fadbf7d2 mm7_unsorted_subs.h --- a/mm7_unsorted_subs.h Mon May 12 12:27:50 2014 +0600 +++ b/mm7_unsorted_subs.h Mon May 12 12:28:06 2014 +0600 @@ -116,13 +116,6 @@ void ShowNothingHereStatus(); int const_2(); bool TeleportToNWCDungeon(); -void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); -int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); -int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2); -void RespawnGlobalDecorations(); -bool __fastcall SpawnActor(unsigned int uMonsterID); -int GetAlertStatus(); inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count) { unsigned __int32* p = (unsigned __int32 *)ptr; diff -r 14c05b876218 -r bcd7fadbf7d2 stru6.cpp --- a/stru6.cpp Mon May 12 12:27:50 2014 +0600 +++ b/stru6.cpp Mon May 12 12:28:06 2014 +0600 @@ -129,12 +129,10 @@ //----- (004775C4) -------------------------------------------------------- stru6_stru1_indoor_sw_billboard::~stru6_stru1_indoor_sw_billboard() { - if (pArray1) - delete [] pArray1; + delete [] pArray1; pArray1 = nullptr; - if (pArray2) - delete [] pArray2; + delete [] pArray2; pArray2 = nullptr; } diff -r 14c05b876218 -r bcd7fadbf7d2 stru6.h --- a/stru6.h Mon May 12 12:27:50 2014 +0600 +++ b/stru6.h Mon May 12 12:28:06 2014 +0600 @@ -112,8 +112,7 @@ //----- (004A71DC) -------------------------------------------------------- ~stru6() { - if (pStru1) - delete pStru1; + delete pStru1; pStru1 = nullptr; } diff -r 14c05b876218 -r bcd7fadbf7d2 texts.cpp --- a/texts.cpp Mon May 12 12:27:50 2014 +0600 +++ b/texts.cpp Mon May 12 12:28:06 2014 +0600 @@ -24,7 +24,7 @@ -static char *pGlobalTXT_Raw=NULL; +static char *pGlobalTXT_Raw=nullptr; std::array pGlobalTXT_LocalizationStrings; @@ -91,8 +91,7 @@ int temp_str_len; // ecx@5 bool string_end; // [sp+14h] [bp-4h]@4 //v0 = 0; - if (pGlobalTXT_Raw) - free(pGlobalTXT_Raw); + free(pGlobalTXT_Raw); pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0); /* strtok(pGlobalTXT_Raw, "\r");