From b6d77d9679b7b26f31d6249b66b49d52eabe5bb6 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 31 Aug 2014 20:26:08 +0100 Subject: Init RankMgr pointer to NULL --- src/Protocol/MojangAPI.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp index 4e5c41a8a..28da83c31 100644 --- a/src/Protocol/MojangAPI.cpp +++ b/src/Protocol/MojangAPI.cpp @@ -158,7 +158,8 @@ cMojangAPI::cMojangAPI(void) : m_NameToUUIDServer(DEFAULT_NAME_TO_UUID_SERVER), m_NameToUUIDAddress(DEFAULT_NAME_TO_UUID_ADDRESS), m_UUIDToProfileServer(DEFAULT_UUID_TO_PROFILE_SERVER), - m_UUIDToProfileAddress(DEFAULT_UUID_TO_PROFILE_ADDRESS) + m_UUIDToProfileAddress(DEFAULT_UUID_TO_PROFILE_ADDRESS), + m_RankMgr(NULL) { } -- cgit v1.2.3 From 3e7332c70ceb372afcd2abf431c6b4c222fe9359 Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 31 Aug 2014 20:28:41 +0100 Subject: Delete the entity before removing from the list Old code was calling dereference on invalid iterator --- src/SetChunkData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SetChunkData.cpp b/src/SetChunkData.cpp index 97903074a..bfe59fbcb 100644 --- a/src/SetChunkData.cpp +++ b/src/SetChunkData.cpp @@ -134,8 +134,8 @@ void cSetChunkData::RemoveInvalidBlockEntities(void) ); cBlockEntityList::iterator itr2 = itr; itr2++; - m_BlockEntities.erase(itr); delete *itr; + m_BlockEntities.erase(itr); itr = itr2; } else -- cgit v1.2.3 From 361b7d5379faf59140befa9d3a6c88fcad75535b Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 31 Aug 2014 21:14:42 +0100 Subject: Changed null check to assert Changed the null check to clarify that the function should not be called before the entity has been attached to a world. --- src/BlockEntities/CommandBlockEntity.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index dd0858378..43cdb92fb 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -188,12 +188,10 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) void cCommandBlockEntity::Execute() { - if (m_World != NULL) + ASSERT(m_World != NULL); //Execute should not be called before the command block is attached to a world + if (!m_World->AreCommandBlocksEnabled()) { - if (!m_World->AreCommandBlocksEnabled()) - { - return; - } + return; } class CommandBlockOutCb : -- cgit v1.2.3 From 468c2558d632bb5702c12577c74967c50327accf Mon Sep 17 00:00:00 2001 From: worktycho Date: Sun, 31 Aug 2014 21:26:02 +0100 Subject: Removed isDone check The same data is returned by executeStep so why execute a call when you have the data. --- src/RankManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RankManager.cpp b/src/RankManager.cpp index dc6eec9e4..e5896f8f3 100644 --- a/src/RankManager.cpp +++ b/src/RankManager.cpp @@ -477,8 +477,8 @@ AString cRankManager::GetPlayerRankName(const AString & a_PlayerUUID) { SQLite::Statement stmt(m_DB, "SELECT Rank.Name FROM Rank LEFT JOIN PlayerRank ON Rank.RankID = PlayerRank.RankID WHERE PlayerRank.PlayerUUID = ?"); stmt.bind(1, a_PlayerUUID); - stmt.executeStep(); - if (stmt.isDone()) + // executeStep returns false on no data + if (!stmt.executeStep()) { // No data returned from the DB return AString(); -- cgit v1.2.3 From 1e60265a909884df3c440e298d1400889c07b5fb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 1 Sep 2014 13:33:17 +0200 Subject: Fixed style. --- src/BlockEntities/CommandBlockEntity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BlockEntities/CommandBlockEntity.cpp b/src/BlockEntities/CommandBlockEntity.cpp index 43cdb92fb..20702a9ac 100644 --- a/src/BlockEntities/CommandBlockEntity.cpp +++ b/src/BlockEntities/CommandBlockEntity.cpp @@ -188,7 +188,8 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value) void cCommandBlockEntity::Execute() { - ASSERT(m_World != NULL); //Execute should not be called before the command block is attached to a world + ASSERT(m_World != NULL); // Execute should not be called before the command block is attached to a world + if (!m_World->AreCommandBlocksEnabled()) { return; -- cgit v1.2.3