diff options
-rw-r--r-- | VC2008/MCServer.vcproj | 4 | ||||
-rw-r--r-- | source/ClientHandle.cpp | 10 | ||||
-rw-r--r-- | source/Entities/Player.cpp | 6 | ||||
-rw-r--r-- | source/Entities/ProjectileEntity.h | 69 | ||||
-rw-r--r-- | source/OSSupport/IsThread.cpp | 1 | ||||
-rw-r--r-- | source/OSSupport/ListenThread.cpp | 2 | ||||
-rw-r--r-- | source/OSSupport/Socket.cpp | 4 | ||||
-rw-r--r-- | source/PluginLua.cpp | 5 | ||||
-rw-r--r-- | source/Protocol/Protocol132.cpp | 3 |
9 files changed, 97 insertions, 7 deletions
diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index fbbd999a9..686eba48a 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1160,6 +1160,10 @@ > </File> <File + RelativePath="..\source\Entities\ProjectileEntity.h" + > + </File> + <File RelativePath="..\source\Entities\TNTEntity.cpp" > </File> diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 57830f63c..319640eea 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -1522,6 +1522,16 @@ void cClientHandle::SendChat(const AString & a_Message) void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) { + ASSERT(m_Player != NULL); + + if ((m_State == csAuthenticated) || (m_State == csDownloadingWorld)) + { + if ((a_ChunkX == m_Player->GetChunkX()) && (a_ChunkZ == m_Player->GetChunkZ())) + { + m_Protocol->SendPlayerMoveLook(); + } + } + // Check chunks being sent, erase them from m_ChunksToSend: bool Found = false; { diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp index 3ccb4ca1d..119afbafc 100644 --- a/source/Entities/Player.cpp +++ b/source/Entities/Player.cpp @@ -200,6 +200,12 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) } } + if (!a_Chunk.IsValid()) + { + // This may happen if the cPlayer is created before the chunks have the chance of being loaded / generated (#83) + return; + } + super::Tick(a_Dt, a_Chunk); // Set player swimming state diff --git a/source/Entities/ProjectileEntity.h b/source/Entities/ProjectileEntity.h new file mode 100644 index 000000000..2e050068b --- /dev/null +++ b/source/Entities/ProjectileEntity.h @@ -0,0 +1,69 @@ + +// ProjectileEntity.h + +// Declares the cProjectileEntity class representing the common base class for projectiles + + + + + +#pragma once + +#include "Entity.h" + + + + + +// tolua_begin + +class cProjectileEntity : + public cEntity +{ + typedef cEntity super; + +public: + /// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet. + enum eKind + { + pkArrow = 60, + pkSnowball = 61, + pkEgg = 62, + pkGhastFireball = 63, // TODO: Unverified TypeID, check this in ProtoProxy + pkFireCharge = 64, // TODO: Unverified TypeID, check this in ProtoProxy + pkEnderPearl = 65, + pkExpBottle = 75, + pkSplashPotion = 73, + pkWitherSkull = 66, + pkFishingFloat = 90, + } ; + + cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); + cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); + + /// Called by the physics blocktracer when the entity hits a solid block, the coords and the face hit is given + virtual void OnHitSolidBlock(double a_BlockX, double a_BlockY, double a_BlockZ, char a_BlockFace) {}; + +protected: + eKind m_Kind; + + /// The entity who has created this projectile; may be NULL (e. g. for dispensers) + cEntity * m_Creator; +} ; + + + + + +class cArrowEntity : + public cProjectileEntity +{ +public: + cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height); + cArrowEntity(cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height); +} ; + +// tolua_end + + + diff --git a/source/OSSupport/IsThread.cpp b/source/OSSupport/IsThread.cpp index 45e329a68..1fadb3769 100644 --- a/source/OSSupport/IsThread.cpp +++ b/source/OSSupport/IsThread.cpp @@ -147,6 +147,7 @@ bool cIsThread::Wait(void) int res = pthread_join(m_Handle, NULL); m_Handle = NULL; LOGD("Thread %s finished", m_ThreadName.c_str()); + m_HasStarted = false; return (res == 0); #endif // else _WIN32 } diff --git a/source/OSSupport/ListenThread.cpp b/source/OSSupport/ListenThread.cpp index c586227df..0890aabc8 100644 --- a/source/OSSupport/ListenThread.cpp +++ b/source/OSSupport/ListenThread.cpp @@ -80,7 +80,7 @@ void cListenThread::Stop(void) super::Wait(); // Close all the listening sockets: - for (cSockets::iterator itr = m_Sockets.begin(), end = m_Sockets.end(); itr != end; ++itr) + for (cSockets::iterator itr = m_Sockets.begin() + 1, end = m_Sockets.end(); itr != end; ++itr) { itr->CloseSocket(); } // for itr - m_Sockets[] diff --git a/source/OSSupport/Socket.cpp b/source/OSSupport/Socket.cpp index f79bdbf47..48b5d704d 100644 --- a/source/OSSupport/Socket.cpp +++ b/source/OSSupport/Socket.cpp @@ -74,11 +74,11 @@ void cSocket::CloseSocket() if (shutdown(m_Socket, SHUT_RDWR) != 0)//SD_BOTH); { - LOGWARN("Error on shutting down socket (%s): %s", m_IPString.c_str(), GetLastErrorString().c_str()); + LOGWARN("Error on shutting down socket %d (%s): %s", m_Socket, m_IPString.c_str(), GetLastErrorString().c_str()); } if (close(m_Socket) != 0) { - LOGWARN("Error closing socket (%s): %s", m_IPString.c_str(), GetLastErrorString().c_str()); + LOGWARN("Error closing socket %d (%s): %s", m_Socket, m_IPString.c_str(), GetLastErrorString().c_str()); } #endif // else _WIN32 diff --git a/source/PluginLua.cpp b/source/PluginLua.cpp index 5128ef0b0..44b36f8f8 100644 --- a/source/PluginLua.cpp +++ b/source/PluginLua.cpp @@ -36,7 +36,10 @@ cPluginLua::cPluginLua(const AString & a_PluginDirectory) : cPluginLua::~cPluginLua() { cCSLock Lock(m_CriticalSection); - m_LuaState.Close(); + if (m_LuaState.IsValid()) + { + m_LuaState.Close(); + } } diff --git a/source/Protocol/Protocol132.cpp b/source/Protocol/Protocol132.cpp index 2e5c305cc..26a1a9fad 100644 --- a/source/Protocol/Protocol132.cpp +++ b/source/Protocol/Protocol132.cpp @@ -340,9 +340,6 @@ void cProtocol132::SendLogin(const cPlayer & a_Player, const cWorld & a_World) Flush(); SendCompass(a_World); - - // Send the initial position (so that confirmation works, FS #245): - SendPlayerMoveLook(); } |