diff --git a/src/game/Bag.cpp b/src/game/Bag.cpp index 8d032083d..742b8d545 100644 --- a/src/game/Bag.cpp +++ b/src/game/Bag.cpp @@ -35,8 +35,7 @@ Bag::Bag(): Item() Bag::~Bag() { for (int i = 0; i < MAX_BAG_SIZE; ++i) - if (m_bagslot[i]) - delete m_bagslot[i]; + delete m_bagslot[i]; } void Bag::AddToWorld() @@ -103,11 +102,9 @@ bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) for (int i = 0; i < MAX_BAG_SIZE; ++i) { SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid()); - if (m_bagslot[i]) - { - delete m_bagslot[i]; - m_bagslot[i] = NULL; - } + + delete m_bagslot[i]; + m_bagslot[i] = NULL; } return true; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 27036ef22..4b199645d 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -976,7 +976,7 @@ void ChatHandler::SendSysMessage(const char* str) m_session->SendPacket(&data); } - delete [] buf; + delete[] buf; } void ChatHandler::SendGlobalSysMessage(const char* str) @@ -994,7 +994,7 @@ void ChatHandler::SendGlobalSysMessage(const char* str) sWorld.SendGlobalMessage(&data); } - delete [] buf; + delete[] buf; } void ChatHandler::SendSysMessage(int32 entry) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 545ec1694..5a6b52524 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -732,8 +732,7 @@ bool Creature::AIM_Initialize() CreatureAI* oldAI = i_AI; i_motionMaster.Initialize(); i_AI = FactorySelector::selectAI(this); - if (oldAI) - delete oldAI; + delete oldAI; return true; } diff --git a/src/game/GridMap.cpp b/src/game/GridMap.cpp index ac20df5bf..a10cc59e4 100644 --- a/src/game/GridMap.cpp +++ b/src/game/GridMap.cpp @@ -117,20 +117,11 @@ bool GridMap::loadData(char* filename) void GridMap::unloadData() { - if (m_area_map) - delete[] m_area_map; - - if (m_V9) - delete[] m_V9; - - if (m_V8) - delete[] m_V8; - - if (m_liquid_type) - delete[] m_liquid_type; - - if (m_liquid_map) - delete[] m_liquid_map; + delete[] m_area_map; + delete[] m_V9; + delete[] m_V8; + delete[] m_liquid_type; + delete[] m_liquid_map; m_area_map = NULL; m_V9 = NULL; @@ -588,12 +579,12 @@ bool GridMap::ExistMap(uint32 mapid, int gx, int gy) !IsAcceptableClientBuild(header.buildMagic)) { sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.", tmp); - delete [] tmp; + delete[] tmp; fclose(pf); // close file before return return false; } - delete [] tmp; + delete[] tmp; fclose(pf); return true; } @@ -1073,7 +1064,7 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) // ASSERT(false); } - delete [] tmp; + delete[] tmp; m_GridMaps[x][y] = map; // load VMAPs for current map/grid... diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 44cff04e8..047e8e0df 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -109,8 +109,7 @@ Group::~Group() itr2->second.state->RemoveGroup(this); // Sub group counters clean up - if (m_subGroupsCounts) - delete[] m_subGroupsCounts; + delete[] m_subGroupsCounts; } bool Group::Create(ObjectGuid guid, const char* name) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index b1f16b7de..41dd6c3d5 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -48,11 +48,8 @@ Map::~Map() if (m_persistentState) m_persistentState->SetUsedByMapState(NULL); // field pointer can be deleted after this - if (i_data) - { - delete i_data; - i_data = NULL; - } + delete i_data; + i_data = NULL; // unload instance specific navigation data MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(m_TerrainData->GetMapId(), GetInstanceId()); diff --git a/src/game/MoveMap.cpp b/src/game/MoveMap.cpp index 9169169b4..1c697ef6e 100644 --- a/src/game/MoveMap.cpp +++ b/src/game/MoveMap.cpp @@ -67,17 +67,11 @@ namespace MMAP void MMapFactory::clear() { - if (g_mmapDisabledIds) - { - delete g_mmapDisabledIds; - g_mmapDisabledIds = NULL; - } + delete g_mmapDisabledIds; + delete g_MMapManager; - if (g_MMapManager) - { - delete g_MMapManager; - g_MMapManager = NULL; - } + g_mmapDisabledIds = NULL; + g_MMapManager = NULL; } // ######################## MMapManager ######################## @@ -105,7 +99,7 @@ namespace MMAP if (!file) { sLog.outDebug("MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName); - delete [] fileName; + delete[] fileName; return false; } @@ -119,11 +113,11 @@ namespace MMAP { dtFreeNavMesh(mesh); sLog.outError("MMAP:loadMapData: Failed to initialize dtNavMesh for mmap %03u from file %s", mapId, fileName); - delete [] fileName; + delete[] fileName; return false; } - delete [] fileName; + delete[] fileName; sLog.outDetail("MMAP:loadMapData: Loaded %03i.mmap", mapId); @@ -167,10 +161,10 @@ namespace MMAP if (!file) { sLog.outDebug("MMAP:loadMap: Could not open mmtile file '%s'", fileName); - delete [] fileName; + delete[] fileName; return false; } - delete [] fileName; + delete[] fileName; // read header MmapTileHeader fileHeader; diff --git a/src/game/MoveMap.h b/src/game/MoveMap.h index 3322e23fb..58d33b6b4 100644 --- a/src/game/MoveMap.h +++ b/src/game/MoveMap.h @@ -33,7 +33,7 @@ inline void* dtCustomAlloc(int size, dtAllocHint /*hint*/) inline void dtCustomFree(void* ptr) { - delete [](unsigned char*)ptr; + delete[] (unsigned char*)ptr; } // move map related classes diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 929c885f6..1fd03119c 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -71,13 +71,8 @@ Object::~Object() MANGOS_ASSERT(false); } - if (m_uint32Values) - { - // DEBUG_LOG("Object desctr 1 check (%p)",(void*)this); - delete [] m_uint32Values; - delete [] m_uint32Values_mirror; - // DEBUG_LOG("Object desctr 2 check (%p)",(void*)this); - } + delete[] m_uint32Values; + delete[] m_uint32Values_mirror; } void Object::_InitValues() diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index d55306811..2c9595118 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -312,10 +312,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c if (result) { - if (m_declinedname) - delete m_declinedname; - + delete m_declinedname; m_declinedname = new DeclinedName; + Field* fields2 = result->Fetch(); for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) m_declinedname->name[i] = fields2[i].GetCppString(); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index df50cb538..899465bf0 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -570,8 +570,7 @@ Player::~Player() // Note: buy back item already deleted from DB when player was saved for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i) { - if (m_items[i]) - delete m_items[i]; + delete m_items[i]; } CleanupChannels(); @@ -590,8 +589,7 @@ Player::~Player() } for (size_t x = 0; x < ItemSetEff.size(); ++x) - if (ItemSetEff[x]) - delete ItemSetEff[x]; + delete ItemSetEff[x]; // clean up player-instance binds, may unload some instance saves for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) @@ -15338,10 +15336,9 @@ void Player::_LoadDeclinedNames(QueryResult* result) if (!result) return; - if (m_declinedname) - delete m_declinedname; - + delete m_declinedname; m_declinedname = new DeclinedName; + Field* fields = result->Fetch(); for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) m_declinedname->name[i] = fields[i].GetCppString(); @@ -15580,11 +15577,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid()); SetVisibleItemSlot(slot, NULL); - if (m_items[slot]) - { - delete m_items[slot]; - m_items[slot] = NULL; - } + delete m_items[slot]; + m_items[slot] = NULL; } DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_STATS, "Load Basic value of player %s is: ", m_name.c_str()); diff --git a/src/game/UpdateMask.h b/src/game/UpdateMask.h index b95655ca5..ae1bb73c0 100644 --- a/src/game/UpdateMask.h +++ b/src/game/UpdateMask.h @@ -30,8 +30,7 @@ class UpdateMask ~UpdateMask() { - if (mUpdateMask) - delete [] mUpdateMask; + delete[] mUpdateMask; } void SetBit(uint32 index) @@ -56,8 +55,7 @@ class UpdateMask void SetCount(uint32 valuesCount) { - if (mUpdateMask) - delete [] mUpdateMask; + delete[] mUpdateMask; mCount = valuesCount; mBlocks = (valuesCount + 31) / 32; diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index 672166d09..384ccf00c 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -438,8 +438,7 @@ void WaypointManager::Unload() void WaypointManager::_clearPath(WaypointPath& path) { for (WaypointPath::const_iterator itr = path.begin(); itr != path.end(); ++itr) - if (itr->behavior) - delete itr->behavior; + delete itr->behavior; path.clear(); } diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 921b2aca0..765bb538d 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -117,8 +117,7 @@ WorldSocket::WorldSocket(void) : WorldSocket::~WorldSocket(void) { - if (m_RecvWPct) - delete m_RecvWPct; + delete m_RecvWPct; if (m_OutBuffer) m_OutBuffer->release(); diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 17e577649..61de72c82 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -81,8 +81,7 @@ class ReactorRunnable : protected ACE_Task_Base Stop(); Wait(); - if (m_Reactor) - delete m_Reactor; + delete m_Reactor; } void Stop() @@ -216,11 +215,8 @@ WorldSocketMgr::WorldSocketMgr(): WorldSocketMgr::~WorldSocketMgr() { - if (m_NetThreads) - delete [] m_NetThreads; - - if (m_Acceptor) - delete m_Acceptor; + delete[] m_NetThreads; + delete m_Acceptor; } int WorldSocketMgr::StartReactiveIO(ACE_UINT16 port, const char* address) diff --git a/src/game/vmap/VMapFactory.cpp b/src/game/vmap/VMapFactory.cpp index 7cfa074c3..f4cf81785 100644 --- a/src/game/vmap/VMapFactory.cpp +++ b/src/game/vmap/VMapFactory.cpp @@ -122,15 +122,10 @@ namespace VMAP // delete all internal data structures void VMapFactory::clear() { - if (iIgnoreSpellIds) - { - delete iIgnoreSpellIds; - iIgnoreSpellIds = NULL; - } - if (gVMapManager) - { - delete gVMapManager; - gVMapManager = NULL; - } + delete iIgnoreSpellIds; + delete gVMapManager; + + iIgnoreSpellIds = NULL; + gVMapManager = NULL; } } diff --git a/src/shared/Auth/BigNumber.cpp b/src/shared/Auth/BigNumber.cpp index eaee36239..4249df92b 100644 --- a/src/shared/Auth/BigNumber.cpp +++ b/src/shared/Auth/BigNumber.cpp @@ -169,11 +169,7 @@ uint8* BigNumber::AsByteArray(int minSize, bool reverse) { int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes(); - if (_array) - { - delete[] _array; - _array = NULL; - } + delete[] _array; _array = new uint8[length]; // If we need more bytes than length of BigNumber set the rest to 0 diff --git a/src/shared/Database/DBCFileLoader.cpp b/src/shared/Database/DBCFileLoader.cpp index 8aabdce15..2628c15d6 100644 --- a/src/shared/Database/DBCFileLoader.cpp +++ b/src/shared/Database/DBCFileLoader.cpp @@ -30,13 +30,8 @@ DBCFileLoader::DBCFileLoader() bool DBCFileLoader::Load(const char* filename, const char* fmt) { - uint32 header; - if (data) - { - delete [] data; - data = NULL; - } + delete[] data; FILE* f = fopen(filename, "rb"); if (!f)return false; @@ -91,10 +86,8 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) DBCFileLoader::~DBCFileLoader() { - if (data) - delete [] data; - if (fieldsOffset) - delete [] fieldsOffset; + delete[] data; + delete[] fieldsOffset; } DBCFileLoader::Record DBCFileLoader::getRecord(size_t id) diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index 3c0df6664..153fd9109 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -150,24 +150,17 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) void Database::StopServer() { HaltDelayThread(); - /*Delete objects*/ - if (m_pResultQueue) - { - delete m_pResultQueue; - m_pResultQueue = NULL; - } - if (m_pAsyncConn) - { - delete m_pAsyncConn; - m_pAsyncConn = NULL; - } + delete m_pResultQueue; + delete m_pAsyncConn; + + m_pResultQueue = NULL; + m_pAsyncConn = NULL; for (size_t i = 0; i < m_pQueryConnections.size(); ++i) delete m_pQueryConnections[i]; m_pQueryConnections.clear(); - } SqlDelayThread* Database::CreateDelayThread() @@ -644,9 +637,6 @@ SqlTransaction* Database::TransHelper::detach() void Database::TransHelper::reset() { - if (m_pTrans) - { - delete m_pTrans; - m_pTrans = NULL; - } + delete m_pTrans; + m_pTrans = NULL; } diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 5dd54ba88..cc0272cc3 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -444,8 +444,8 @@ void MySqlPreparedStatement::RemoveBinds() if (!m_stmt) return; - delete [] m_pInputArgs; - delete [] m_pResult; + delete[] m_pInputArgs; + delete[] m_pResult; mysql_free_result(m_pResultMetadata); mysql_stmt_close(m_stmt); diff --git a/src/shared/Database/QueryResultMysql.cpp b/src/shared/Database/QueryResultMysql.cpp index 4ffc7a2af..e019d4efe 100644 --- a/src/shared/Database/QueryResultMysql.cpp +++ b/src/shared/Database/QueryResultMysql.cpp @@ -59,11 +59,8 @@ bool QueryResultMysql::NextRow() void QueryResultMysql::EndQuery() { - if (mCurrentRow) - { - delete [] mCurrentRow; - mCurrentRow = 0; - } + delete[] mCurrentRow; + mCurrentRow = 0; if (mResult) { diff --git a/src/shared/Database/QueryResultPostgre.cpp b/src/shared/Database/QueryResultPostgre.cpp index 1f4438aee..6e418b712 100644 --- a/src/shared/Database/QueryResultPostgre.cpp +++ b/src/shared/Database/QueryResultPostgre.cpp @@ -63,11 +63,8 @@ bool QueryResultPostgre::NextRow() void QueryResultPostgre::EndQuery() { - if (mCurrentRow) - { - delete [] mCurrentRow; - mCurrentRow = 0; - } + delete[] mCurrentRow; + mCurrentRow = 0; if (mResult) { diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 48996c550..e8c899cbf 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -36,7 +36,7 @@ void SQLStorage::EraseEntry(uint32 id) case FT_STRING: { if (pIndex[id]) - delete [] *(char**)((char*)(pIndex[id]) + offset); + delete[] *(char**)((char*)(pIndex[id]) + offset); offset += sizeof(char*); break; @@ -81,7 +81,7 @@ void SQLStorage::Free() { for (uint32 y = 0; y < MaxEntry; ++y) if (pIndex[y]) - delete [] *(char**)((char*)(pIndex[y]) + offset); + delete[] *(char**)((char*)(pIndex[y]) + offset); offset += sizeof(char*); break; @@ -104,8 +104,8 @@ void SQLStorage::Free() } } - delete [] pIndex; - delete [] data; + delete[] pIndex; + delete[] data; } void SQLStorage::Load() diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index cc18eaa6e..deb7349ee 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -169,7 +169,7 @@ QueryResult* SqlQueryHolder::GetResult(size_t index) /// the query strings are freed on the first GetResult or in the destructor if (m_queries[index].first != NULL) { - delete [](const_cast(m_queries[index].first)); + delete[] (const_cast(m_queries[index].first)); m_queries[index].first = NULL; } /// when you get a result aways remember to delete it! @@ -194,9 +194,8 @@ SqlQueryHolder::~SqlQueryHolder() /// results used already (getresult called) are expected to be deleted if (m_queries[i].first != NULL) { - delete [](const_cast(m_queries[i].first)); - if (m_queries[i].second) - delete m_queries[i].second; + delete[] (const_cast(m_queries[i].first)); + delete m_queries[i].second; } } } diff --git a/src/shared/Database/SqlOperations.h b/src/shared/Database/SqlOperations.h index d11034d6d..82f724acc 100644 --- a/src/shared/Database/SqlOperations.h +++ b/src/shared/Database/SqlOperations.h @@ -49,7 +49,7 @@ class SqlPlainRequest : public SqlOperation const char* m_sql; public: SqlPlainRequest(const char* sql) : m_sql(mangos_strdup(sql)) {} - ~SqlPlainRequest() { char* tofree = const_cast(m_sql); delete [] tofree; } + ~SqlPlainRequest() { char* tofree = const_cast(m_sql); delete[] tofree; } bool Execute(SqlConnection* conn) override; }; @@ -104,7 +104,7 @@ class SqlQuery : public SqlOperation public: SqlQuery(const char* sql, MaNGOS::IQueryCallback* callback, SqlResultQueue* queue) : m_sql(mangos_strdup(sql)), m_callback(callback), m_queue(queue) {} - ~SqlQuery() { char* tofree = const_cast(m_sql); delete [] tofree; } + ~SqlQuery() { char* tofree = const_cast(m_sql); delete[] tofree; } bool Execute(SqlConnection* conn) override; }; diff --git a/src/shared/Database/SqlPreparedStatement.cpp b/src/shared/Database/SqlPreparedStatement.cpp index 51de8c60e..e0dceb390 100644 --- a/src/shared/Database/SqlPreparedStatement.cpp +++ b/src/shared/Database/SqlPreparedStatement.cpp @@ -41,11 +41,8 @@ SqlStatement& SqlStatement::operator=(const SqlStatement& index) m_index = index.m_index; m_pDB = index.m_pDB; - if (m_pParams) - { - delete m_pParams; - m_pParams = NULL; - } + delete m_pParams; + m_pParams = NULL; if (index.m_pParams) m_pParams = new SqlStmtParameters(*(index.m_pParams)); diff --git a/src/shared/Threading.cpp b/src/shared/Threading.cpp index 45cd1e456..14a7a8018 100644 --- a/src/shared/Threading.cpp +++ b/src/shared/Threading.cpp @@ -215,8 +215,7 @@ Thread* Thread::current() _thread->m_hThreadHandle = Thread::currentHandle(); Thread* _oldValue = m_ThreadStorage.ts_object(_thread); - if (_oldValue) - delete _oldValue; + delete _oldValue; } return _thread; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ba9f55404..8c32d7793 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12078" + #define REVISION_NR "12079" #endif // __REVISION_NR_H__