From 843f31ecbace5b78486cb72df9404e0bfec900df Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 25 Sep 2014 18:33:01 +0200 Subject: HangingEntity: Silenced a crash. Vanilla worlds sometimes contain data that this was asserting upon. Changed into a log. --- src/Entities/HangingEntity.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Entities/HangingEntity.cpp') diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index 8c70c606e..6e9a89550 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -28,11 +28,17 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle) // The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces switch (m_BlockFace) { - case BLOCK_FACE_ZP: break; // Initialised to zero + case BLOCK_FACE_ZP: Dir = 0; break; case BLOCK_FACE_ZM: Dir = 2; break; case BLOCK_FACE_XM: Dir = 1; break; case BLOCK_FACE_XP: Dir = 3; break; - default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return; + default: + { + LOGINFO("Invalid face (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.", + m_BlockFace, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ() + ); + Dir = 3; + } } if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180 -- cgit v1.2.3 From daf5127b28f3c6884e94fc066b3e5e117a6b5d35 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 25 Sep 2014 18:37:24 +0200 Subject: Fixed hanging direction bugs. --- src/Entities/HangingEntity.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Entities/HangingEntity.cpp') diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp index 8c70c606e..e789f5f18 100644 --- a/src/Entities/HangingEntity.cpp +++ b/src/Entities/HangingEntity.cpp @@ -21,6 +21,21 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, +void cHangingEntity::SetDirection(eBlockFace a_BlockFace) +{ + if ((a_BlockFace < 2) || (a_BlockFace > 5)) + { + ASSERT(!"Tried to set a bad direction!"); + return; + } + + m_BlockFace = a_BlockFace; +} + + + + + void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle) { int Dir = 0; -- cgit v1.2.3