# HG changeset patch # User Grumpy7 # Date 1399852232 -7200 # Node ID bddcaf5d5db2e49f4c5ec22338f4637bb924b187 # Parent 91b6c0a338ad275d356a786e33ae4ffc4564d820 removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments diff -r 91b6c0a338ad -r bddcaf5d5db2 Arcomage.cpp --- a/Arcomage.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Arcomage.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 AudioPlayer.cpp --- a/AudioPlayer.cpp Mon May 12 00:13:39 2014 +0200 +++ b/AudioPlayer.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 BSPModel.cpp --- a/BSPModel.cpp Mon May 12 00:13:39 2014 +0200 +++ b/BSPModel.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Mon May 12 00:13:39 2014 +0200 +++ b/CastSpellInfo.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Game.cpp --- a/Game.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Game.cpp Mon May 12 01:50:32 2014 +0200 @@ -887,34 +887,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 +2081,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 91b6c0a338ad -r bddcaf5d5db2 Indoor.cpp --- a/Indoor.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Indoor.cpp Mon May 12 01:50:32 2014 +0200 @@ -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; diff -r 91b6c0a338ad -r bddcaf5d5db2 Indoor.h --- a/Indoor.h Mon May 12 00:13:39 2014 +0200 +++ b/Indoor.h Mon May 12 01:50:32 2014 +0200 @@ -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); diff -r 91b6c0a338ad -r bddcaf5d5db2 Items.cpp --- a/Items.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Items.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Items.h --- a/Items.h Mon May 12 00:13:39 2014 +0200 +++ b/Items.h Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 LOD.cpp --- a/LOD.cpp Mon May 12 00:13:39 2014 +0200 +++ b/LOD.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 MapInfo.cpp --- a/MapInfo.cpp Mon May 12 00:13:39 2014 +0200 +++ b/MapInfo.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Monsters.cpp --- a/Monsters.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Monsters.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Mouse.cpp --- a/Mouse.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Mouse.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Mouse.h --- a/Mouse.h Mon May 12 00:13:39 2014 +0200 +++ b/Mouse.h Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 NPC.cpp --- a/NPC.cpp Mon May 12 00:13:39 2014 +0200 +++ b/NPC.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 ObjectList.cpp --- a/ObjectList.cpp Mon May 12 00:13:39 2014 +0200 +++ b/ObjectList.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Outdoor.cpp --- a/Outdoor.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Outdoor.cpp Mon May 12 01:50:32 2014 +0200 @@ -668,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(); } @@ -1065,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) -------------------------------------------------------- @@ -1632,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); @@ -1842,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"); @@ -1864,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; diff -r 91b6c0a338ad -r bddcaf5d5db2 Outdoor.h --- a/Outdoor.h Mon May 12 00:13:39 2014 +0200 +++ b/Outdoor.h Mon May 12 01:50:32 2014 +0200 @@ -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; diff -r 91b6c0a338ad -r bddcaf5d5db2 Overlays.cpp --- a/Overlays.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Overlays.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Player.cpp --- a/Player.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Player.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Render.cpp --- a/Render.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Render.cpp Mon May 12 01:50:32 2014 +0200 @@ -800,10 +800,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 +811,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 +1217,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 +1259,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 +2019,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 +2035,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 +2046,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 +2799,6 @@ { if (!pDefaultZBuffer) { - pDefaultZBuffer = pActiveZBuffer = nullptr; pDefaultZBuffer = pActiveZBuffer = (int *)malloc(0x12C000); memset32(pActiveZBuffer, 0xFFFF0000, 0x4B000u); // // inlined Render::ClearActiveZBuffer (mm8::004A085B) } @@ -2863,21 +2834,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 +3167,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 +3224,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 +3238,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 +3251,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 +3325,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 +3385,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 +3443,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 +3457,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 +3470,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; diff -r 91b6c0a338ad -r bddcaf5d5db2 Spells.cpp --- a/Spells.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Spells.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Sprites.cpp --- a/Sprites.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Sprites.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 StorylineTextTable.cpp --- a/StorylineTextTable.cpp Mon May 12 00:13:39 2014 +0200 +++ b/StorylineTextTable.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 Texture.cpp --- a/Texture.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Texture.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 TileTable.cpp --- a/TileTable.cpp Mon May 12 00:13:39 2014 +0200 +++ b/TileTable.cpp Mon May 12 01:50:32 2014 +0200 @@ -15,11 +15,8 @@ //----- (00487E1D) -------------------------------------------------------- TileTable::~TileTable() { - if ( pTiles ) - { - free(pTiles); - pTiles = nullptr; - } + free(pTiles); + pTiles = nullptr; sNumTiles = 0; } diff -r 91b6c0a338ad -r bddcaf5d5db2 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Mon May 12 00:13:39 2014 +0200 +++ b/UI/UICharacter.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Mon May 12 00:13:39 2014 +0200 +++ b/UI/UIHouses.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 UI/UIPopup.cpp --- a/UI/UIPopup.cpp Mon May 12 00:13:39 2014 +0200 +++ b/UI/UIPopup.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 UI/UIShops.cpp --- a/UI/UIShops.cpp Mon May 12 00:13:39 2014 +0200 +++ b/UI/UIShops.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 UI/UiGame.cpp --- a/UI/UiGame.cpp Mon May 12 00:13:39 2014 +0200 +++ b/UI/UiGame.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 VideoPlayer.cpp --- a/VideoPlayer.cpp Mon May 12 00:13:39 2014 +0200 +++ b/VideoPlayer.cpp Mon May 12 01:50:32 2014 +0200 @@ -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); diff -r 91b6c0a338ad -r bddcaf5d5db2 Viewport.cpp --- a/Viewport.cpp Mon May 12 00:13:39 2014 +0200 +++ b/Viewport.cpp Mon May 12 01:50:32 2014 +0200 @@ -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 91b6c0a338ad -r bddcaf5d5db2 mm7_2.cpp --- a/mm7_2.cpp Mon May 12 00:13:39 2014 +0200 +++ b/mm7_2.cpp Mon May 12 01:50:32 2014 +0200 @@ -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; @@ -1239,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 ) @@ -1274,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 91b6c0a338ad -r bddcaf5d5db2 mm7_3.cpp --- a/mm7_3.cpp Mon May 12 00:13:39 2014 +0200 +++ b/mm7_3.cpp Mon May 12 01:50:32 2014 +0200 @@ -3618,7 +3618,7 @@ pGUIWindow2 = 0; activeLevelDecoration = _591094_decoration; EventProcessor(dword_5C3418, 0, 1, dword_5C341C); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; pEventTimer->Resume(); } diff -r 91b6c0a338ad -r bddcaf5d5db2 mm7_4.cpp --- a/mm7_4.cpp Mon May 12 00:13:39 2014 +0200 +++ b/mm7_4.cpp Mon May 12 01:50:32 2014 +0200 @@ -2262,7 +2262,7 @@ activeLevelDecoration = (LevelDecoration*)1; current_npc_text = 0; EventProcessor(npc_event_id, 0, 1); - activeLevelDecoration = NULL; + activeLevelDecoration = nullptr; break; } } diff -r 91b6c0a338ad -r bddcaf5d5db2 texts.cpp --- a/texts.cpp Mon May 12 00:13:39 2014 +0200 +++ b/texts.cpp Mon May 12 01:50:32 2014 +0200 @@ -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");