From 14d2085e35bbc3e5c73c018e5c70e8093003820f Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 14:43:32 +0000 Subject: [PATCH 001/144] basic threadsafe queue interface --- src/OSSupport/Queue.h | 30 ++++++++++++++++++++++++++++++ src/OSSupport/Queue.inc | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 src/OSSupport/Queue.h create mode 100644 src/OSSupport/Queue.inc diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h new file mode 100644 index 00000000..838a101e --- /dev/null +++ b/src/OSSupport/Queue.h @@ -0,0 +1,30 @@ +#pragma once + +template +class cDeleter +{ + public: + static void Delete(T) {}; +} + +template +class cQueue +{ +public: + cQueue(int warnsize); + cQueue(cQueue& queue); + ~cQueue(); + + void EnqueueItem(T item); + bool TryDequeueItem(T& item); + T DequeueItem(); + void BlockTillEmpty(cEvent CancelationEvent); + void Clear(); + int Size(); + +private: + int warnsize; +} + +//template classes must be implemented in the header +#include "Queue.inc" diff --git a/src/OSSupport/Queue.inc b/src/OSSupport/Queue.inc new file mode 100644 index 00000000..f172e979 --- /dev/null +++ b/src/OSSupport/Queue.inc @@ -0,0 +1,4 @@ + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + + From 38f808ac3d09cbb5bf437243f4b050e196fa582c Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 15:00:31 +0000 Subject: [PATCH 002/144] ChunkSender is now warnings clean --- src/BlockEntities/BlockEntity.h | 2 +- src/ChunkDef.h | 2 +- src/ChunkSender.cpp | 2 +- src/Entities/Entity.h | 8 ++++---- src/Entities/ProjectileEntity.h | 2 +- src/Simulator/Simulator.h | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 0d358b55..4a2939b3 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -87,7 +87,7 @@ public: virtual void SendTo(cClientHandle & a_Client) = 0; /// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. - virtual bool Tick(float a_Dt, cChunk & a_Chunk) { return false; } + virtual bool Tick(float /*a_Dt*/, cChunk & /*a_Chunk*/) { return false; } protected: /// Position in absolute block coordinates diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 8c37e790..c6f6c50b 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -180,7 +180,7 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: - inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) + inline static void AbsoluteToRelative(/* in-out */ int & a_X, int& /* a_Y */, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) { BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp index fe3ee9b4..2425adf1 100644 --- a/src/ChunkSender.cpp +++ b/src/ChunkSender.cpp @@ -264,7 +264,7 @@ void cChunkSender::BlockEntity(cBlockEntity * a_Entity) -void cChunkSender::Entity(cEntity * a_Entity) +void cChunkSender::Entity(cEntity *) { // Nothing needed yet, perhaps in the future when we save entities into chunks we'd like to send them upon load, too ;) } diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9cb36eb1..0d7634f7 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -351,10 +351,10 @@ public: // tolua_end /// Called when the specified player right-clicks this entity - virtual void OnRightClicked(cPlayer & a_Player) {}; + virtual void OnRightClicked(cPlayer &) {}; /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) {} + virtual void GetDrops(cItems & /*a_Drops*/, cEntity * /*a_Killer*/ = NULL) {} protected: static cCriticalSection m_CSCount; @@ -420,11 +420,11 @@ protected: void Dereference( cEntity*& a_EntityPtr ); private: - // Measured in degrees (MAX 360°) + // Measured in degrees (MAX 360°) double m_HeadYaw; // Measured in meter/second (m/s) Vector3d m_Speed; - // Measured in degrees (MAX 360°) + // Measured in degrees (MAX 360°) Vector3d m_Rot; /// Position of the entity's XZ center and Y bottom diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 959e81ae..e9e377fe 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -52,7 +52,7 @@ public: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace); /// Called by the physics blocktracer when the entity hits another entity - virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) {} + virtual void OnHitEntity(cEntity & /*a_EntityHit*/, const Vector3d & /*a_HitPos*/) {} /// Called by Chunk when the projectile is eligible for player collection virtual void CollectedBy(cPlayer * a_Dest); diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index 5cd0e865..3a625202 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -25,7 +25,8 @@ public: virtual void Simulate(float a_Dt) = 0; /// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available - virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) {}; + virtual void SimulateChunk(float /*a_Dt*/, int /*a_ChunkX*/, + int /*a_ChunkZ*/, cChunk * /*a_Chunk*/) {}; /// Called when a block changes virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk); From 5034ae29b889b37c10524678e4b92d8ca700bde7 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 15:08:01 +0000 Subject: [PATCH 003/144] Piston is now warnings clean --- src/Blocks/BlockHandler.h | 2 +- src/Piston.cpp | 2 +- src/Simulator/FireSimulator.h | 2 +- src/Simulator/RedstoneSimulator.h | 4 ++-- src/Simulator/SandSimulator.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 107d3647..1dc0e2a2 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -99,7 +99,7 @@ public: virtual bool DoesIgnoreBuildCollision(void); /// Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow) - virtual bool DoesIgnoreBuildCollision(cPlayer * a_Player, NIBBLETYPE a_Meta) { return DoesIgnoreBuildCollision(); } + virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE /*a_Meta*/) { return DoesIgnoreBuildCollision(); } /// Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true virtual bool DoesDropOnUnsuitable(void); diff --git a/src/Piston.cpp b/src/Piston.cpp index b15e7d95..17729a35 100644 --- a/src/Piston.cpp +++ b/src/Piston.cpp @@ -236,7 +236,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) +bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE /*a_BlockMeta*/) { return g_BlockPistonBreakable[a_BlockType]; } diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h index 66c31b44..f509c66e 100644 --- a/src/Simulator/FireSimulator.h +++ b/src/Simulator/FireSimulator.h @@ -22,7 +22,7 @@ public: cFireSimulator(cWorld & a_World, cIniFile & a_IniFile); ~cFireSimulator(); - virtual void Simulate(float a_Dt) override {} // not used + virtual void Simulate(float /*a_Dt*/) override {} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h index 30913549..903ac877 100644 --- a/src/Simulator/RedstoneSimulator.h +++ b/src/Simulator/RedstoneSimulator.h @@ -19,7 +19,7 @@ public: cRedstoneSimulator(cWorld & a_World); ~cRedstoneSimulator(); - virtual void Simulate(float a_Dt) override {}; // Not used in this simulator + virtual void Simulate(float /*a_Dt*/) override {}; // Not used in this simulator virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return IsRedstone(a_BlockType); } @@ -269,4 +269,4 @@ private: default: return false; } } -}; \ No newline at end of file +}; diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index 6e9ea15a..90447c91 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -15,7 +15,7 @@ public: cSandSimulator(cWorld & a_World, cIniFile & a_IniFile); // cSimulator overrides: - virtual void Simulate(float a_Dt) override {} // Unused in this simulator + virtual void Simulate(float /*a_Dt*/) override {} // Unused in this simulator virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; From 9f41761e8ea1eff8980af4dceb7137471538298b Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 15:38:37 +0000 Subject: [PATCH 004/144] Root is now warnings clean --- src/Bindings/LuaState.h | 40 ++++++++++++++++++------------------ src/Bindings/PluginManager.h | 2 +- src/CommandOutput.h | 2 +- src/Entities/Player.h | 4 ++-- src/Items/ItemHandler.h | 2 +- src/Root.cpp | 2 +- src/Server.h | 2 ++ src/WebAdmin.h | 8 ++++---- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 15b0cdef..cca0df04 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -244,7 +244,7 @@ public: template< typename FnT, typename ArgT1, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -264,7 +264,7 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -285,7 +285,7 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -307,7 +307,7 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -330,7 +330,7 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -355,7 +355,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -381,7 +381,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -408,7 +408,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -436,7 +436,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -465,7 +465,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & /*a_Mark*/, RetT1 & a_Ret1) { if (!PushFunction(a_FnName)) { @@ -494,7 +494,7 @@ public: template< typename FnT, typename ArgT1, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -515,7 +515,7 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -538,7 +538,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -562,7 +562,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -587,7 +587,7 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -614,7 +614,7 @@ public: typename ArgT6, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -642,7 +642,7 @@ public: typename ArgT6, typename ArgT7, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) { if (!PushFunction(a_FnName)) { @@ -671,7 +671,7 @@ public: typename ArgT6, typename ArgT7, typename RetT1, typename RetT2, typename RetT3 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { if (!PushFunction(a_FnName)) { @@ -701,7 +701,7 @@ public: typename ArgT6, typename ArgT7, typename ArgT8, typename RetT1, typename RetT2, typename RetT3 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { if (!PushFunction(a_FnName)) { @@ -732,7 +732,7 @@ public: typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) { if (!PushFunction(a_FnName)) { diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 04d6470c..e5edd70e 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -271,7 +271,7 @@ private: bool m_bReloadPlugins; cPluginManager(); - ~cPluginManager(); + virtual ~cPluginManager(); /// Reloads all plugins, defaulting to settings.ini for settings location void ReloadPluginsNow(void); diff --git a/src/CommandOutput.h b/src/CommandOutput.h index bdf67523..80339b40 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -35,7 +35,7 @@ class cNullCommandOutputCallback : public cCommandOutputCallback { // cCommandOutputCallback overrides: - virtual void Out(const AString & a_Text) override + virtual void Out(const AString & /*a_Text*/) override { // Do nothing } diff --git a/src/Entities/Player.h b/src/Entities/Player.h index c0ad9eea..241eb305 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -45,7 +45,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override { }; + virtual void HandlePhysics(float /*a_Dt*/, cChunk &) override { }; /// Returns the curently equipped weapon; empty item if none virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } @@ -114,7 +114,7 @@ public: double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export - inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. + inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index e39bb054..cee3fb73 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -25,7 +25,7 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); /// Called when the client sends the SHOOT status in the lclk packet - virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) {} + virtual void OnItemShoot(cPlayer *, int /*a_BlockX*/, int /*a_BlockY*/, int /*a_BlockZ*/, char /*a_BlockFace*/) {} /// Called while the player diggs a block using this item virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace); diff --git a/src/Root.cpp b/src/Root.cpp index fffd8fb4..6b1785ab 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -580,10 +580,10 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac public: cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback) : - m_Callback(a_Callback), m_BestRating(0), m_NameLength(a_PlayerName.length()), m_PlayerName(a_PlayerName), + m_Callback(a_Callback), m_BestMatch(NULL), m_NumMatches(0) {} diff --git a/src/Server.h b/src/Server.h index 0d93469a..1f94bb3d 100644 --- a/src/Server.h +++ b/src/Server.h @@ -35,6 +35,8 @@ class cServer // tolua_export : public cListenThread::cCallback { // tolua_export public: // tolua_export + + virtual ~cServer() {} bool InitServer(cIniFile & a_SettingsIni); // tolua_begin diff --git a/src/WebAdmin.h b/src/WebAdmin.h index c629d44f..0f61d7e3 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -105,7 +105,7 @@ public: cWebAdmin(void); - ~cWebAdmin(); + virtual ~cWebAdmin(); /// Initializes the object. Returns true if successfully initialized and ready to start bool Init(void); @@ -166,9 +166,9 @@ protected: virtual void OnBody(const char * a_Data, int a_Size) override; // cHTTPFormParser::cCallbacks overrides. Files are ignored: - virtual void OnFileStart(cHTTPFormParser & a_Parser, const AString & a_FileName) override {} - virtual void OnFileData(cHTTPFormParser & a_Parser, const char * a_Data, int a_Size) override {} - virtual void OnFileEnd(cHTTPFormParser & a_Parser) override {} + virtual void OnFileStart(cHTTPFormParser &, const AString & /*a_FileName*/) override {} + virtual void OnFileData(cHTTPFormParser &, const char * /*a_Data*/, int /*a_Size*/) override {} + virtual void OnFileEnd(cHTTPFormParser &) override {} } ; From 3289abde739cdca666763ee762424257e8db2ef5 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 15:49:59 +0000 Subject: [PATCH 005/144] fixed hidden bug with furnaces ignoring time burnt this patch fixes an issue with furnaces where they would ignore the time burnt in setBurnTimes this did not cause a problem as this function was only called with the same value as the one it was using for time burnt --- src/BlockEntities/FurnaceEntity.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index 8b695d61..b0818730 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -95,7 +95,7 @@ public: // tolua_end - void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) {m_FuelBurnTime = a_FuelBurnTime; m_TimeBurned = 0; } + void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) {m_FuelBurnTime = a_FuelBurnTime; m_TimeBurned = a_TimeBurned; } void SetCookTimes(int a_NeedCookTime, int a_TimeCooked) {m_NeedCookTime = a_NeedCookTime; m_TimeCooked = a_TimeCooked; } protected: From b3046a09e5dfaa8e675c6309dc77ea517616f101 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sat, 21 Dec 2013 15:58:21 +0000 Subject: [PATCH 006/144] Chunk is now warnings clean --- src/BlockEntities/BlockEntityWithItems.h | 2 +- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/Chunk.cpp | 5 ++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index f35412e0..f2c51fd9 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -71,7 +71,7 @@ protected: cItemGrid m_Contents; // cItemGrid::cListener overrides: - virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) + virtual void OnSlotChanged(cItemGrid * a_Grid, int /*a_SlotNum*/) { ASSERT(a_Grid == &m_Contents); if (m_World != NULL) diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index fcafdc47..996de965 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -45,7 +45,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle & a_Client) override { }; + virtual void SendTo(cClientHandle &) override { }; private: int m_Record; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index e2d088f4..cf78aeac 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -52,7 +52,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle & a_Client) override { }; + virtual void SendTo(cClientHandle &) override { }; private: char m_Pitch; diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3c44b91d..adeec37f 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -527,9 +527,9 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO : check that "Level" really means Y - NIBBLETYPE SkyLight = 0; + /*NIBBLETYPE SkyLight = 0; - NIBBLETYPE BlockLight = 0; + NIBBLETYPE BlockLight = 0;*/ if (IsLightValid()) { @@ -2323,7 +2323,6 @@ BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { - int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); a_BlockType = cChunkDef::GetBlock (m_BlockTypes, a_RelX, a_RelY, a_RelZ); a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); } From d7242414070aa823f879f225b0cf734f4a880759 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 13:46:55 +0000 Subject: [PATCH 007/144] converted commneted paramater names to the unused macro --- lib/lua/Makefile | 54 --------------------- src/Bindings/LuaState.h | 61 ++++++++++++++++-------- src/BlockEntities/BlockEntity.h | 7 ++- src/BlockEntities/BlockEntityWithItems.h | 3 +- src/Blocks/BlockHandler.h | 6 ++- src/ChunkDef.h | 3 +- src/CommandOutput.h | 3 +- src/Entities/Entity.h | 10 ++-- src/Entities/Player.h | 2 +- src/Entities/ProjectileEntity.h | 6 ++- src/Items/ItemHandler.h | 8 +++- src/Piston.cpp | 3 +- src/Simulator/FireSimulator.h | 2 +- src/Simulator/RedstoneSimulator.h | 2 +- src/Simulator/SandSimulator.h | 2 +- src/Simulator/Simulator.h | 10 +++- src/WebAdmin.h | 11 ++++- 17 files changed, 100 insertions(+), 93 deletions(-) diff --git a/lib/lua/Makefile b/lib/lua/Makefile index d23c39cc..8c8cf168 100644 --- a/lib/lua/Makefile +++ b/lib/lua/Makefile @@ -733,54 +733,6 @@ src/ltm.c.s: cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltm.c.s .PHONY : src/ltm.c.s -src/lua.o: src/lua.c.o -.PHONY : src/lua.o - -# target to build an object file -src/lua.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.o -.PHONY : src/lua.c.o - -src/lua.i: src/lua.c.i -.PHONY : src/lua.i - -# target to preprocess a source file -src/lua.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.i -.PHONY : src/lua.c.i - -src/lua.s: src/lua.c.s -.PHONY : src/lua.s - -# target to generate assembly for a file -src/lua.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.s -.PHONY : src/lua.c.s - -src/luac.o: src/luac.c.o -.PHONY : src/luac.o - -# target to build an object file -src/luac.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.o -.PHONY : src/luac.c.o - -src/luac.i: src/luac.c.i -.PHONY : src/luac.i - -# target to preprocess a source file -src/luac.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.i -.PHONY : src/luac.c.i - -src/luac.s: src/luac.c.s -.PHONY : src/luac.s - -# target to generate assembly for a file -src/luac.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.s -.PHONY : src/luac.c.s - src/lundump.o: src/lundump.c.o .PHONY : src/lundump.o @@ -964,12 +916,6 @@ help: @echo "... src/ltm.o" @echo "... src/ltm.i" @echo "... src/ltm.s" - @echo "... src/lua.o" - @echo "... src/lua.i" - @echo "... src/lua.s" - @echo "... src/luac.o" - @echo "... src/luac.i" - @echo "... src/luac.s" @echo "... src/lundump.o" @echo "... src/lundump.i" @echo "... src/lundump.s" diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 475dec42..a6c31b6d 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -246,6 +246,7 @@ public: > bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -263,8 +264,9 @@ public: template< typename FnT, typename ArgT1, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -283,8 +285,9 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -304,8 +307,9 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -326,8 +330,9 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -349,8 +354,9 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -374,8 +380,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -400,8 +407,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -427,8 +435,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -455,8 +464,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -484,8 +494,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename ArgT10, typename RetT1 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & /*a_Mark*/, RetT1 & a_Ret1) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -513,8 +524,9 @@ public: template< typename FnT, typename ArgT1, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -534,8 +546,9 @@ public: template< typename FnT, typename ArgT1, typename ArgT2, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -557,8 +570,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -581,8 +595,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -606,8 +621,9 @@ public: typename FnT, typename ArgT1, typename ArgT2, typename ArgT3, typename ArgT4, typename ArgT5, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -633,8 +649,9 @@ public: typename ArgT6, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -661,8 +678,9 @@ public: typename ArgT6, typename ArgT7, typename RetT1, typename RetT2 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -690,8 +708,9 @@ public: typename ArgT6, typename ArgT7, typename RetT1, typename RetT2, typename RetT3 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -720,8 +739,9 @@ public: typename ArgT6, typename ArgT7, typename ArgT8, typename RetT1, typename RetT2, typename RetT3 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -751,8 +771,9 @@ public: typename ArgT6, typename ArgT7, typename ArgT8, typename ArgT9, typename RetT1, typename RetT2, typename RetT3, typename RetT4, typename RetT5 > - bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & /*a_Mark*/, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) + bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 4a2939b3..c3b8d41c 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -87,7 +87,12 @@ public: virtual void SendTo(cClientHandle & a_Client) = 0; /// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. - virtual bool Tick(float /*a_Dt*/, cChunk & /*a_Chunk*/) { return false; } + virtual bool Tick(float a_Dt, cChunk & a_Chunk) + { + UNUSED(a_Dt); + UNUSED(a_Chunk); + return false; + } protected: /// Position in absolute block coordinates diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index f2c51fd9..bf6289a2 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -71,8 +71,9 @@ protected: cItemGrid m_Contents; // cItemGrid::cListener overrides: - virtual void OnSlotChanged(cItemGrid * a_Grid, int /*a_SlotNum*/) + virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) { + UNUSED(a_SlotNum); ASSERT(a_Grid == &m_Contents); if (m_World != NULL) { diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 1dc0e2a2..a732aa79 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -99,7 +99,11 @@ public: virtual bool DoesIgnoreBuildCollision(void); /// Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow) - virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE /*a_Meta*/) { return DoesIgnoreBuildCollision(); } + virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) + { + UNUSED(a_Meta); + return DoesIgnoreBuildCollision(); + } /// Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true virtual bool DoesDropOnUnsuitable(void); diff --git a/src/ChunkDef.h b/src/ChunkDef.h index c6f6c50b..bf41aa62 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -180,8 +180,9 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: - inline static void AbsoluteToRelative(/* in-out */ int & a_X, int& /* a_Y */, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) + inline static void AbsoluteToRelative(/* in-out */ int & a_X, int& a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) { + UNUSED(a_Y); BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); a_X = a_X - a_ChunkX * Width; diff --git a/src/CommandOutput.h b/src/CommandOutput.h index 80339b40..3763d625 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -35,9 +35,10 @@ class cNullCommandOutputCallback : public cCommandOutputCallback { // cCommandOutputCallback overrides: - virtual void Out(const AString & /*a_Text*/) override + virtual void Out(const AString & a_Text) override { // Do nothing + UNUSED(a_Text); } } ; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 0d7634f7..3634f087 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -354,7 +354,11 @@ public: virtual void OnRightClicked(cPlayer &) {}; /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). - virtual void GetDrops(cItems & /*a_Drops*/, cEntity * /*a_Killer*/ = NULL) {} + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) + { + UNUSED(a_Drops); + UNUSED(a_Killer); + } protected: static cCriticalSection m_CSCount; @@ -420,11 +424,11 @@ protected: void Dereference( cEntity*& a_EntityPtr ); private: - // Measured in degrees (MAX 360°) + // Measured in degrees (MAX 360 degrees) double m_HeadYaw; // Measured in meter/second (m/s) Vector3d m_Speed; - // Measured in degrees (MAX 360°) + // Measured in degrees (MAX 360 degrees) Vector3d m_Rot; /// Position of the entity's XZ center and Y bottom diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 0a3f50d1..f9ce950b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -45,7 +45,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void HandlePhysics(float /*a_Dt*/, cChunk &) override { }; + virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }; /// Returns the curently equipped weapon; empty item if none virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index e9e377fe..4721409e 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -52,7 +52,11 @@ public: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace); /// Called by the physics blocktracer when the entity hits another entity - virtual void OnHitEntity(cEntity & /*a_EntityHit*/, const Vector3d & /*a_HitPos*/) {} + virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) + { + UNUSED(a_EntityHit); + UNUSED(a_HitPos); + } /// Called by Chunk when the projectile is eligible for player collection virtual void CollectedBy(cPlayer * a_Dest); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index cee3fb73..db0ffc9d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -25,7 +25,13 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); /// Called when the client sends the SHOOT status in the lclk packet - virtual void OnItemShoot(cPlayer *, int /*a_BlockX*/, int /*a_BlockY*/, int /*a_BlockZ*/, char /*a_BlockFace*/) {} + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + } /// Called while the player diggs a block using this item virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace); diff --git a/src/Piston.cpp b/src/Piston.cpp index 17729a35..75eeb5e9 100644 --- a/src/Piston.cpp +++ b/src/Piston.cpp @@ -236,8 +236,9 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) -bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE /*a_BlockMeta*/) +bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { + UNUSED(a_BlockMeta); return g_BlockPistonBreakable[a_BlockType]; } diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h index f509c66e..9ccc3ef4 100644 --- a/src/Simulator/FireSimulator.h +++ b/src/Simulator/FireSimulator.h @@ -22,7 +22,7 @@ public: cFireSimulator(cWorld & a_World, cIniFile & a_IniFile); ~cFireSimulator(); - virtual void Simulate(float /*a_Dt*/) override {} // not used + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h index cfeb2b1f..1080c3f8 100644 --- a/src/Simulator/RedstoneSimulator.h +++ b/src/Simulator/RedstoneSimulator.h @@ -19,7 +19,7 @@ public: cRedstoneSimulator(cWorld & a_World); ~cRedstoneSimulator(); - virtual void Simulate(float /*a_Dt*/) override {}; // Not used in this simulator + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return IsRedstone(a_BlockType); } diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index 90447c91..6e64aa42 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -15,7 +15,7 @@ public: cSandSimulator(cWorld & a_World, cIniFile & a_IniFile); // cSimulator overrides: - virtual void Simulate(float /*a_Dt*/) override {} // Unused in this simulator + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index 3a625202..a25b7f1b 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -25,8 +25,14 @@ public: virtual void Simulate(float a_Dt) = 0; /// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available - virtual void SimulateChunk(float /*a_Dt*/, int /*a_ChunkX*/, - int /*a_ChunkZ*/, cChunk * /*a_Chunk*/) {}; + virtual void SimulateChunk(float a_Dt, int a_ChunkX, + int a_ChunkZ, cChunk * a_Chunk) + { + UNUSED(a_Dt); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); + UNUSED(a_Chunk); + }; /// Called when a block changes virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk); diff --git a/src/WebAdmin.h b/src/WebAdmin.h index 1a27eabf..3eb80764 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -169,8 +169,15 @@ protected: virtual void OnBody(const char * a_Data, int a_Size) override; // cHTTPFormParser::cCallbacks overrides. Files are ignored: - virtual void OnFileStart(cHTTPFormParser &, const AString & /*a_FileName*/) override {} - virtual void OnFileData(cHTTPFormParser &, const char * /*a_Data*/, int /*a_Size*/) override {} + virtual void OnFileStart(cHTTPFormParser &, const AString & a_FileName) override + { + UNUSED(a_FileName); + } + virtual void OnFileData(cHTTPFormParser &, const char * a_Data, int a_Size) override + { + UNUSED(a_Data); + UNUSED(a_Size); + } virtual void OnFileEnd(cHTTPFormParser &) override {} } ; From 6d7b6ae9cafff4cbea19b9588c6cb216ee3a42fd Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:17:36 +0000 Subject: [PATCH 008/144] fixes for mac os x --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0df702b2..859575a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,10 @@ endif() if(WIN32) add_flags("/MP") +elseif(APPLE) + if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_flags("-pthread") + endif() else() add_flags("-pthread") endif() @@ -114,10 +118,10 @@ endif() set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_BAK}") if (NOT WIN32) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") - set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -rdynamic") - set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_PROFILE} -rdynamic") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic") + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -rdynamic") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -rdynamic") + set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_PROFILE} -rdynamic") endif() add_subdirectory (src) From 725b997a2817bd999079e5e6678f5497373cbbac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 28 Dec 2013 21:59:50 +0100 Subject: [PATCH 009/144] Fixed a (valid) warning in RCONServer. --- src/OSSupport/SocketThreads.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/OSSupport/SocketThreads.h b/src/OSSupport/SocketThreads.h index ecbac3ae..858729c4 100644 --- a/src/OSSupport/SocketThreads.h +++ b/src/OSSupport/SocketThreads.h @@ -61,6 +61,9 @@ public: class cCallback { public: + // Force a virtual destructor in all subclasses: + virtual ~cCallback() {} + /// Called when data is received from the remote party virtual void DataReceived(const char * a_Data, int a_Size) = 0; From b93b4c4825503e3c03c44091b415cc7186b24455 Mon Sep 17 00:00:00 2001 From: Mike Hunsinger Date: Sat, 28 Dec 2013 23:49:51 -0700 Subject: [PATCH 010/144] Added function to create Tall Birch tree in BirchTreeForest biomes --- src/Generating/Trees.cpp | 49 +++++++++++++++++++++++++++++++++++++--- src/Generating/Trees.h | 3 +++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/Generating/Trees.cpp b/src/Generating/Trees.cpp index fbed57cb..7e8a3c75 100644 --- a/src/Generating/Trees.cpp +++ b/src/Generating/Trees.cpp @@ -216,7 +216,14 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No GetBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); break; } - + + case biBirchForestM: + case biBirchForestHillsM: + { + GetTallBirchTreeImage(a_BlockX, a_BlockY, a_BlockZ, a_Noise, a_Seq, a_LogBlocks, a_OtherBlocks); + break; + } + case biRoofedForest: case biColdTaiga: case biColdTaigaHills: @@ -237,8 +244,6 @@ void GetTreeImageByBiome(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_No case biIcePlainsSpikes: case biJungleM: case biJungleEdgeM: - case biBirchForestM: - case biBirchForestHillsM: case biRoofedForestM: case biColdTaigaM: case biMegaSpruceTaiga: @@ -377,6 +382,44 @@ void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Nois +void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks) +{ + int Height = 9 + (a_Noise.IntNoise3DInt(a_BlockX + 64 * a_Seq, a_BlockY, a_BlockZ) % 3); + + // Prealloc, so that we don't realloc too often later: + a_LogBlocks.reserve(Height); + a_OtherBlocks.reserve(80); + + // The entire trunk, out of logs: + for (int i = Height - 1; i >= 0; --i) + { + a_LogBlocks.push_back(sSetBlock(a_BlockX, a_BlockY + i, a_BlockZ, E_BLOCK_LOG, E_META_LOG_BIRCH)); + } + int h = a_BlockY + Height; + + // Top layer - just the Plus: + PushCoordBlocks(a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH); + a_OtherBlocks.push_back(sSetBlock(a_BlockX, h, a_BlockZ, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH)); // There's no log at this layer + h--; + + // Second layer - log, Plus and maybe Corners: + PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO1, ARRAYCOUNT(BigO1), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH); + PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x5fffffff, a_OtherBlocks, 1, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH); + h--; + + // Third and fourth layers - BigO2 and maybe 2*Corners: + for (int Row = 0; Row < 2; Row++) + { + PushCoordBlocks (a_BlockX, h, a_BlockZ, a_OtherBlocks, BigO2, ARRAYCOUNT(BigO2), E_BLOCK_LEAVES, E_META_LEAVES_BIRCH); + PushCornerBlocks(a_BlockX, h, a_BlockZ, a_Seq, a_Noise, 0x3fffffff + Row * 0x10000000, a_OtherBlocks, 2, E_BLOCK_LEAVES, E_META_LEAVES_BIRCH); + h--; + } // for Row - 2* +} + + + + + void GetConiferTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks) { // Half chance for a spruce, half for a pine: diff --git a/src/Generating/Trees.h b/src/Generating/Trees.h index f5148ad6..514158eb 100644 --- a/src/Generating/Trees.h +++ b/src/Generating/Trees.h @@ -63,6 +63,9 @@ void GetLargeAppleTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a /// Generates an image of a random birch tree void GetBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); +/// Generates an image of a random large birch tree +void GetTallBirchTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks,sSetBlockVector & a_OtherBlocks); + /// Generates an image of a random conifer tree void GetConiferTreeImage(int a_BlockX, int a_BlockY, int a_BlockZ, cNoise & a_Noise, int a_Seq, sSetBlockVector & a_LogBlocks, sSetBlockVector & a_OtherBlocks); From 248ba1ea9f6826234535c2a777b3834fbe264e0d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 12:51:58 +0100 Subject: [PATCH 011/144] Added HOOK_PLUGINS_LOADED. This fixes #482. --- MCServer/Plugins/Debuggers/Debuggers.lua | 9 ++++++++ src/Bindings/LuaState.h | 19 +++++++++++++++++ src/Bindings/Plugin.h | 1 + src/Bindings/PluginLua.cpp | 18 ++++++++++++++++ src/Bindings/PluginLua.h | 1 + src/Bindings/PluginManager.cpp | 26 +++++++++++++++++++++--- src/Bindings/PluginManager.h | 2 ++ 7 files changed, 73 insertions(+), 3 deletions(-) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c9a610f7..8f2fa368 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -27,6 +27,7 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); + cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); PM = cRoot:Get():GetPluginManager(); PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -524,6 +525,14 @@ end +function OnPluginsLoaded() + LOG("All plugins loaded"); +end + + + + + function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) -- Get the topmost block coord: local Height = a_ChunkDesc:GetHeight(0, 0); diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 15b0cdef..40bb67e6 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -240,6 +240,25 @@ public: return CallFunction(0); } + /// Call any 0-param 1-return Lua function in a single line: + template< + typename FnT, typename RetT1 + > + bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1) + { + if (!PushFunction(a_FnName)) + { + return false; + } + if (!CallFunction(1)) + { + return false; + } + GetReturn(-1, a_Ret1); + lua_pop(m_LuaState, 1); + return true; + } + /// Call any 1-param 1-return Lua function in a single line: template< typename FnT, typename ArgT1, typename RetT1 diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 9a3c2383..ee0f8a06 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -82,6 +82,7 @@ public: virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0; virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0; + virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 0e5a66cd..69e83fb0 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -910,6 +910,24 @@ bool cPluginLua::OnPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_Block +bool cPluginLua::OnPluginsLoaded(void) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLUGINS_LOADED]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + bool ret = false; + m_LuaState.Call((int)(**itr), cLuaState::Return, ret); + res = res || ret; + } + return res; +} + + + + + bool cPluginLua::OnPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { cCSLock Lock(m_CriticalSection); diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index e1e274c7..1b257285 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -79,6 +79,7 @@ public: virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; + virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 832dc424..ffffe1a2 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -118,7 +118,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) int KeyNum = a_SettingsIni.FindKey("Plugins"); // If it does, how many plugins are there? - unsigned int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); + int NumPlugins = ((KeyNum != -1) ? (a_SettingsIni.GetNumValues(KeyNum)) : 0); if (KeyNum == -1) { @@ -126,7 +126,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) } else if (NumPlugins > 0) { - for(unsigned int i = 0; i < NumPlugins; i++) + for (int i = 0; i < NumPlugins; i++) { AString ValueName = a_SettingsIni.GetValueName(KeyNum, i); if (ValueName.compare("Plugin") == 0) @@ -136,7 +136,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) { if (m_Plugins.find(PluginFile) != m_Plugins.end()) { - LoadPlugin( PluginFile ); + LoadPlugin(PluginFile); } } } @@ -155,6 +155,7 @@ void cPluginManager::ReloadPluginsNow(cIniFile & a_SettingsIni) { LOG("-- Loaded 1 Plugin --"); } + CallHookPluginsLoaded(); } @@ -987,6 +988,25 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i +bool cPluginManager::CallHookPluginsLoaded(void) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED); + if (Plugins == m_Hooks.end()) + { + return false; + } + bool res = false; + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + res = !(*itr)->OnPluginsLoaded() || res; + } + return res; +} + + + + + bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 04d6470c..5abb8be8 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -94,6 +94,7 @@ public: // tolua_export HOOK_PLAYER_USED_ITEM, HOOK_PLAYER_USING_BLOCK, HOOK_PLAYER_USING_ITEM, + HOOK_PLUGINS_LOADED, HOOK_POST_CRAFTING, HOOK_PRE_CRAFTING, HOOK_SPAWNED_ENTITY, @@ -181,6 +182,7 @@ public: // tolua_export bool CallHookPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); bool CallHookPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); + bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity); From b84cd0b3c573d584d2dd73b9e3866cd990b9fd49 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 13:15:46 +0100 Subject: [PATCH 012/144] APIDump: Documented OnPluginsLoaded. --- .../Plugins/APIDump/Hooks/OnPluginsLoaded.lua | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua diff --git a/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua b/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua new file mode 100644 index 00000000..d36cdf5c --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua @@ -0,0 +1,79 @@ +return +{ + HOOK_PLUGINS_LOADED = + { + CalledWhen = "All the enabled plugins have been loaded", + DefaultFnName = "OnPluginsLoaded", -- also used as pagename + Desc = [[ + This callback gets called when the server finishes loading and initializing plugins. This is the + perfect occasion for a plugin to query other plugins and possibly start communicating with them using + the {{cPluginManager}}:Call() function. + ]], + Params = {}, + Returns = [[ + The return value is ignored, all registered callbacks are called. + ]], + CodeExamples = + { + { + Title = "CoreMessaging", + Desc = [[ + This example shows how to implement the CoreMessaging functionality - messages to players will be + sent through the Core plugin, formatted by that plugin. As a fallback for when the Core plugin is + not present, the messages are sent directly by this code, unformatted. + ]], + Code = [[ +-- These are the fallback functions used when the Core is not present: +local function SendMessageFallback(a_Player, a_Message) + a_Player:SendMessage(a_Message); +end + +local function SendMessageSuccessFallback(a_Player, a_Message) + a_Player:SendMessage(a_Message); +end + +local function SendMessageFailureFallback(a_Player, a_Message) + a_Player:SendMessage(a_Message); +end + +-- These three "variables" will hold the actual functions to call. +-- By default they are initialized to the Fallback variants, but will be redirected to Core when all plugins load +SendMessage = SendMessageFallback; +SendMessageSuccess = SendMessageSuccessFallback; +SendMessageFailure = SendMessageFailureFallback; + +-- The callback tries to connect to the Core, if successful, overwrites the three functions with Core ones +local function OnPluginsLoaded() + local CorePlugin = cPluginManager:Get():GetPlugin("Core"); + if (CorePlugin == nil) then + -- The Core is not loaded, keep the Fallback functions + return; + end + + -- Overwrite the three functions with Core functionality: + SendMessage = function(a_Player, a_Message) + CorePlugin:Call("SendMessage", a_Player, a_Message); + end + SendMessageSuccess = function(a_Player, a_Message) + CorePlugin:Call("SendMessageSuccess", a_Player, a_Message); + end + SendMessageFailure = function(a_Player, a_Message) + CorePlugin:Call("SendMessageFailure", a_Player, a_Message); + end +end + +-- Global scope, register the callback: +cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, CoreMessagingPluginsLoaded); + + +-- Usage, anywhere else in the plugin: +SendMessageFailure(a_Player, "Cannot teleport to player, the destination player " .. PlayerName .. " was not found"); + ]], + }, + } , -- CodeExamples + }, -- HOOK_PLUGINS_LOADED +} + + + + From 8406a37ac262bdf135b35f8a8f6f9170553c645e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 13:23:30 +0100 Subject: [PATCH 013/144] APIDump: The PRE html tag has tab width set to 2 spaces. --- MCServer/Plugins/APIDump/main.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css index 79707987..aa26bd18 100644 --- a/MCServer/Plugins/APIDump/main.css +++ b/MCServer/Plugins/APIDump/main.css @@ -30,6 +30,11 @@ pre { border: 1px solid #ccc; background-color: #eee; + -moz-tab-size: 2; + -o-tab-size: 2; + -webkit-tab-size: 2; + -ms-tab-size: 2; + tab-size: 2; } body From 61af77a5c5c99ec82decc24ff8fca899f959e48a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 13:24:38 +0100 Subject: [PATCH 014/144] APIDump: Static files overwrite their destination. --- MCServer/Plugins/APIDump/main_APIDump.lua | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index ff837ec4..b3a95eb2 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -321,6 +321,7 @@ function DumpAPIHtml() cFile:CreateFolder("API/Static"); local localFolder = g_Plugin:GetLocalFolder(); for idx, fnam in ipairs(cFile:GetFolderContents(localFolder .. "/Static")) do + cFile:Delete("API/Static/" .. fnam); cFile:Copy(localFolder .. "/Static/" .. fnam, "API/Static/" .. fnam); end @@ -428,11 +429,18 @@ function DumpAPIHtml() WriteClasses(f, API, ClassMenu); WriteHooks(f, Hooks, UndocumentedHooks, HookNav); - -- Copy the static files to the output folder (overwrite any existing): - cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.js", "API/prettify.js"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.css", "API/prettify.css"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); + -- Copy the static files to the output folder: + local StaticFiles = + { + "main.css", + "prettify.js", + "prettify.css", + "lang-lua.js", + }; + for idx, fnam in ipairs(StaticFiles) do + cFile:Delete("API/" .. fnam); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/" .. fnam, "API/" .. fnam); + end -- List the documentation problems: LOG("Listing leftovers..."); From 61254d035643de23013b8995a7385ac79a673cbd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Dec 2013 14:48:58 +0100 Subject: [PATCH 015/144] APIDump: Fixed a factual error in OnPluginsLoaded description. --- MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua b/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua index d36cdf5c..0d5b7271 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPluginsLoaded.lua @@ -6,8 +6,8 @@ return DefaultFnName = "OnPluginsLoaded", -- also used as pagename Desc = [[ This callback gets called when the server finishes loading and initializing plugins. This is the - perfect occasion for a plugin to query other plugins and possibly start communicating with them using - the {{cPluginManager}}:Call() function. + perfect occasion for a plugin to query other plugins through {{cPluginManager}}:GetPlugin() and + possibly start communicating with them using the {{cPlugin}}:Call() function. ]], Params = {}, Returns = [[ From e5f9c97e3d27fcae2825e795a82a95270c4a1460 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 30 Dec 2013 11:22:52 +0000 Subject: [PATCH 016/144] Create GETTING-STARTED.md --- GETTING-STARTED.md | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 GETTING-STARTED.md diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md new file mode 100644 index 00000000..8b6f932a --- /dev/null +++ b/GETTING-STARTED.md @@ -0,0 +1,119 @@ +Hello! Thanks for wanting to work on this project :smile:, and I hope that this file will help you somewhat in getting all set up and running. I'll go through the basics of getting the projet environment set up, the code organization and style, and general development practices. I'll also show you some good issues to start off working on to get yourself familiarised with the code. + +Minecraft Basics +---------------- + +If you don't play Minecraft or don't have a great knowledge of the basic systems, you should get to know them. The [Minecraft Wiki](http://minecraft.gamepedia.com/Minecraft_Wiki) is quite useful for this task, although some youtubers are also fairly good at teaching the basics and just playing is quite good too. + +I'd say that the important topics are: + +* Differnt types of blocks and how they act. +* Mobs, what they do and how. +* Redstone, pistons, and automation. +* Farming +* Fighting, health and the hunger system. + +Useful Resources +---------------- + + * [Minecraft Wiki](http://minecraft.gamepedia.com/Minecraft_Wiki) + * [Minecraft Protocol Wiki](http://wiki.vg) + +Setting up a Dev Environment +============================ + +Requirements +------------ + +**Linux/BSD/Solaris/OSX:** + +You'll need the basic C++ build tools: + + * gcc (or clang or another C compiler) + * g++ (or clang++ or another C++ compiler) + * make + +You'll also need CMake to generate the makefile to build from. + +**Windows:** + +If you use Windows, your best bet is the MSVC2008 (available as a free download in the Express edition from MS) or MSVS2013 (ditto), solution files for both are currently in the repo. + +Setting up the Repo +------------------- + +Next, you'll need to set up the repo. You can make a fork and work on that then PR in, or I can set you up with membership for the repo so you can work on branches here (still use PRs though, they're great tools and for the first few you'll definitely need some changes). If you want membership to the repo, just create an issue and I can set you up. + +Once you've cloned, you need to pull down the submodules: + + git submodule init + git submodule update + +After that they should come down automatically when you pull but it's not bad to refresh every once in a while. + +Repo Arrangement +--------------------------- + +The MCServer repo has recently been rearranged for better code separation and other things, but basically it's split into a few areas: + + * `src` + This holds all of the MCServer source code, and is where most development takes place. + It's split into logical areas for blocks, the protocol handling and other things. + * `lib` + This holds all the 3rd party libraries for MCServer. You basically don't need to touch these, and we're thinking of switching them into submodules soon. + * `MCServer` + This folder isn't greatly named, but it contains the default plugins and environment to actually run the server. You'll find the executable (named `MCServer`) here and in the `plugins` subdir the default plugins. The config files are also stored here. Config files with `.example.ini` on the end are generated by the server or source control and should be left alone, instead you should copy them to a file without the `example` in the name which will be prioritised over the generated ones. + +Code Styles +------------------ + +Mainly follow the code styles in [CONTRIBUTING.md](https://github.com/mc-server/MCServer/blob/master/CONTRIBUTING.md), which is definitely an important read. + + +How to Build +------------------ + +**Linux/BSD/Solaris/OSX:** + +Follow the instructions in [COMPILING.md](https://github.com/mc-server/MCServer/blob/master/COMPILING.md). You probably want to build in debug mode (when you're developing) for console alerts and debugging capability, even though it's much slower for everyday use. + +Basically, the process is: + + cmake . -DCMAKE_BUILD_TYPE=DEBUG && make + +**Windows:** + +You need to first execute the `src/Bindings/AllToLua.bat` script file, then just open the solution file in your MSVC of choice and build. + +How to Run +---------- + +The server can be run (on *nix) by a simple `./MCServer` in the `MCServer` directory. On first run it will generate the world and start a server on the default port (configurable in `settings.ini`) so you can connect in minecraft via `localhost`. + +Where to Get Started +------------------------------- + +There are a few fairly easy issues for you to get started with, as well as some more difficult but interesting ones. + +**Easy**: + + * #288 + * #385 + * #402 + * #388 + * #380 + * Clean up some of the compiler warnings. (Check [Travis CI](http://travis-ci.org/mc-server/MCServer) for a list of them.) With clang, there are over 10000 lines of warnings to clean up. + +**More Difficult**: + + * #17 + * #418 + * #398 + +You may also want to write some plugins. They are written in lua, with excellent API documentation available via [APIDump](http://mc-server.xoft.cz/LuaAPI). The [Core](https://github.com/mc-server/Core) plugin should also help quite a bit here. + +Special Things +--------------------- + + * MCServer uses ToLUA for the Lua API, and you'll really have to ask @madmaxoft for how to export stuff and @worktycho for how to add stuff to the auto generated bindings (he just re-worked it with CMake). + * Ask questions as much as you like, we're here to help :smiley: From 17b56579ebb1b5d6a79ce095df44a9ef37de223c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 30 Dec 2013 11:41:37 +0000 Subject: [PATCH 017/144] Update GETTING-STARTED.md --- GETTING-STARTED.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GETTING-STARTED.md b/GETTING-STARTED.md index 8b6f932a..66318a62 100644 --- a/GETTING-STARTED.md +++ b/GETTING-STARTED.md @@ -18,6 +18,8 @@ Useful Resources * [Minecraft Wiki](http://minecraft.gamepedia.com/Minecraft_Wiki) * [Minecraft Protocol Wiki](http://wiki.vg) + * [Lua API Documentation](http://mc-server.xoft.cz/LuaAPI) + * [VS2008 Download](http://stackoverflow.com/questions/15318560/visual-c-2008-express-download-link-dead) Setting up a Dev Environment ============================ From a71299c46b7b53a5f9f11ea2851f8e5b66d2d912 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:41:01 +0000 Subject: [PATCH 018/144] fixed rdynamic as its not acctually needed a cmake handles it, looks like the problem was caused by the linux linker accepting the option twice and the os x linker not --- CMakeLists.txt | 7 ----- lib/lua/Makefile | 54 --------------------------------- src/OSSupport/Queue.h | 31 +++++++++++++++++++ src/WorldStorage/WorldStorage.h | 3 +- 4 files changed, 33 insertions(+), 62 deletions(-) create mode 100644 src/OSSupport/Queue.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 859575a6..f8c740ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,12 +117,5 @@ else() endif() set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_BAK}") -if (NOT WIN32) - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic") - set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -rdynamic") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -rdynamic") - set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_PROFILE} -rdynamic") -endif() - add_subdirectory (src) diff --git a/lib/lua/Makefile b/lib/lua/Makefile index d23c39cc..8c8cf168 100644 --- a/lib/lua/Makefile +++ b/lib/lua/Makefile @@ -733,54 +733,6 @@ src/ltm.c.s: cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltm.c.s .PHONY : src/ltm.c.s -src/lua.o: src/lua.c.o -.PHONY : src/lua.o - -# target to build an object file -src/lua.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.o -.PHONY : src/lua.c.o - -src/lua.i: src/lua.c.i -.PHONY : src/lua.i - -# target to preprocess a source file -src/lua.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.i -.PHONY : src/lua.c.i - -src/lua.s: src/lua.c.s -.PHONY : src/lua.s - -# target to generate assembly for a file -src/lua.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lua.c.s -.PHONY : src/lua.c.s - -src/luac.o: src/luac.c.o -.PHONY : src/luac.o - -# target to build an object file -src/luac.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.o -.PHONY : src/luac.c.o - -src/luac.i: src/luac.c.i -.PHONY : src/luac.i - -# target to preprocess a source file -src/luac.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.i -.PHONY : src/luac.c.i - -src/luac.s: src/luac.c.s -.PHONY : src/luac.s - -# target to generate assembly for a file -src/luac.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/luac.c.s -.PHONY : src/luac.c.s - src/lundump.o: src/lundump.c.o .PHONY : src/lundump.o @@ -964,12 +916,6 @@ help: @echo "... src/ltm.o" @echo "... src/ltm.i" @echo "... src/ltm.s" - @echo "... src/lua.o" - @echo "... src/lua.i" - @echo "... src/lua.s" - @echo "... src/luac.o" - @echo "... src/luac.i" - @echo "... src/luac.s" @echo "... src/lundump.o" @echo "... src/lundump.i" @echo "... src/lundump.s" diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h new file mode 100644 index 00000000..4571272b --- /dev/null +++ b/src/OSSupport/Queue.h @@ -0,0 +1,31 @@ +#pragma once + +template +class cDeleter +{ + public: + static void Delete(T) {}; +}; + +template> +class cQueue +{ +public: + cQueue(int warnsize); + cQueue(cQueue& queue); + ~cQueue(); + + void EnqueueItem(T item); + bool TryDequeueItem(T& item); + T DequeueItem(); + void BlockTillEmpty(cEvent CancelationEvent); + void Clear(); + int Size(); + +private: + int warnsize; + std::list contents; +}; + +//template classes must be implemented in the header +#include "Queue.inc" diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 007d3757..106842a2 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -16,6 +16,7 @@ #include "../ChunkDef.h" #include "../OSSupport/IsThread.h" +#include "../OSSupport/Queue.h" @@ -93,7 +94,7 @@ protected: sChunkLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) : m_ChunkX(a_ChunkX), m_ChunkY(a_ChunkY), m_ChunkZ(a_ChunkZ), m_Generate(a_Generate) {} } ; - typedef std::list sChunkLoadQueue; + typedef cQueue sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; From a7a4b2886d98eb0c015421fb82c60531a8e66aaa Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:55:57 +0000 Subject: [PATCH 019/144] fixed accedental commit --- src/WorldStorage/WorldStorage.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 106842a2..007d3757 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -16,7 +16,6 @@ #include "../ChunkDef.h" #include "../OSSupport/IsThread.h" -#include "../OSSupport/Queue.h" @@ -94,7 +93,7 @@ protected: sChunkLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) : m_ChunkX(a_ChunkX), m_ChunkY(a_ChunkY), m_ChunkZ(a_ChunkZ), m_Generate(a_Generate) {} } ; - typedef cQueue sChunkLoadQueue; + typedef std::list sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; From d2ed9d9fc4471f6818302f4ca25b9c02d0162e12 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:57:56 +0000 Subject: [PATCH 020/144] removed lua makefile --- lib/lua/Makefile | 944 ----------------------------------------------- 1 file changed, 944 deletions(-) delete mode 100644 lib/lua/Makefile diff --git a/lib/lua/Makefile b/lib/lua/Makefile deleted file mode 100644 index 8c8cf168..00000000 --- a/lib/lua/Makefile +++ /dev/null @@ -1,944 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 2.8 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/tycho/MCServer - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/tycho/MCServer - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." - /usr/bin/cmake -i . -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# The main all target -all: cmake_check_build_system - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -E cmake_progress_start /home/tycho/MCServer/CMakeFiles /home/tycho/MCServer/lib/lua/CMakeFiles/progress.marks - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/lua/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/tycho/MCServer/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/lua/clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/lua/preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/lua/preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -# Convenience name for target. -lib/lua/CMakeFiles/lua.dir/rule: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/lua/CMakeFiles/lua.dir/rule -.PHONY : lib/lua/CMakeFiles/lua.dir/rule - -# Convenience name for target. -lua: lib/lua/CMakeFiles/lua.dir/rule -.PHONY : lua - -# fast build rule for target. -lua/fast: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/build -.PHONY : lua/fast - -src/lapi.o: src/lapi.c.o -.PHONY : src/lapi.o - -# target to build an object file -src/lapi.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lapi.c.o -.PHONY : src/lapi.c.o - -src/lapi.i: src/lapi.c.i -.PHONY : src/lapi.i - -# target to preprocess a source file -src/lapi.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lapi.c.i -.PHONY : src/lapi.c.i - -src/lapi.s: src/lapi.c.s -.PHONY : src/lapi.s - -# target to generate assembly for a file -src/lapi.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lapi.c.s -.PHONY : src/lapi.c.s - -src/lauxlib.o: src/lauxlib.c.o -.PHONY : src/lauxlib.o - -# target to build an object file -src/lauxlib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lauxlib.c.o -.PHONY : src/lauxlib.c.o - -src/lauxlib.i: src/lauxlib.c.i -.PHONY : src/lauxlib.i - -# target to preprocess a source file -src/lauxlib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lauxlib.c.i -.PHONY : src/lauxlib.c.i - -src/lauxlib.s: src/lauxlib.c.s -.PHONY : src/lauxlib.s - -# target to generate assembly for a file -src/lauxlib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lauxlib.c.s -.PHONY : src/lauxlib.c.s - -src/lbaselib.o: src/lbaselib.c.o -.PHONY : src/lbaselib.o - -# target to build an object file -src/lbaselib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lbaselib.c.o -.PHONY : src/lbaselib.c.o - -src/lbaselib.i: src/lbaselib.c.i -.PHONY : src/lbaselib.i - -# target to preprocess a source file -src/lbaselib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lbaselib.c.i -.PHONY : src/lbaselib.c.i - -src/lbaselib.s: src/lbaselib.c.s -.PHONY : src/lbaselib.s - -# target to generate assembly for a file -src/lbaselib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lbaselib.c.s -.PHONY : src/lbaselib.c.s - -src/lcode.o: src/lcode.c.o -.PHONY : src/lcode.o - -# target to build an object file -src/lcode.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lcode.c.o -.PHONY : src/lcode.c.o - -src/lcode.i: src/lcode.c.i -.PHONY : src/lcode.i - -# target to preprocess a source file -src/lcode.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lcode.c.i -.PHONY : src/lcode.c.i - -src/lcode.s: src/lcode.c.s -.PHONY : src/lcode.s - -# target to generate assembly for a file -src/lcode.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lcode.c.s -.PHONY : src/lcode.c.s - -src/ldblib.o: src/ldblib.c.o -.PHONY : src/ldblib.o - -# target to build an object file -src/ldblib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldblib.c.o -.PHONY : src/ldblib.c.o - -src/ldblib.i: src/ldblib.c.i -.PHONY : src/ldblib.i - -# target to preprocess a source file -src/ldblib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldblib.c.i -.PHONY : src/ldblib.c.i - -src/ldblib.s: src/ldblib.c.s -.PHONY : src/ldblib.s - -# target to generate assembly for a file -src/ldblib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldblib.c.s -.PHONY : src/ldblib.c.s - -src/ldebug.o: src/ldebug.c.o -.PHONY : src/ldebug.o - -# target to build an object file -src/ldebug.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldebug.c.o -.PHONY : src/ldebug.c.o - -src/ldebug.i: src/ldebug.c.i -.PHONY : src/ldebug.i - -# target to preprocess a source file -src/ldebug.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldebug.c.i -.PHONY : src/ldebug.c.i - -src/ldebug.s: src/ldebug.c.s -.PHONY : src/ldebug.s - -# target to generate assembly for a file -src/ldebug.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldebug.c.s -.PHONY : src/ldebug.c.s - -src/ldo.o: src/ldo.c.o -.PHONY : src/ldo.o - -# target to build an object file -src/ldo.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldo.c.o -.PHONY : src/ldo.c.o - -src/ldo.i: src/ldo.c.i -.PHONY : src/ldo.i - -# target to preprocess a source file -src/ldo.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldo.c.i -.PHONY : src/ldo.c.i - -src/ldo.s: src/ldo.c.s -.PHONY : src/ldo.s - -# target to generate assembly for a file -src/ldo.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldo.c.s -.PHONY : src/ldo.c.s - -src/ldump.o: src/ldump.c.o -.PHONY : src/ldump.o - -# target to build an object file -src/ldump.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldump.c.o -.PHONY : src/ldump.c.o - -src/ldump.i: src/ldump.c.i -.PHONY : src/ldump.i - -# target to preprocess a source file -src/ldump.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldump.c.i -.PHONY : src/ldump.c.i - -src/ldump.s: src/ldump.c.s -.PHONY : src/ldump.s - -# target to generate assembly for a file -src/ldump.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ldump.c.s -.PHONY : src/ldump.c.s - -src/lfunc.o: src/lfunc.c.o -.PHONY : src/lfunc.o - -# target to build an object file -src/lfunc.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lfunc.c.o -.PHONY : src/lfunc.c.o - -src/lfunc.i: src/lfunc.c.i -.PHONY : src/lfunc.i - -# target to preprocess a source file -src/lfunc.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lfunc.c.i -.PHONY : src/lfunc.c.i - -src/lfunc.s: src/lfunc.c.s -.PHONY : src/lfunc.s - -# target to generate assembly for a file -src/lfunc.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lfunc.c.s -.PHONY : src/lfunc.c.s - -src/lgc.o: src/lgc.c.o -.PHONY : src/lgc.o - -# target to build an object file -src/lgc.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lgc.c.o -.PHONY : src/lgc.c.o - -src/lgc.i: src/lgc.c.i -.PHONY : src/lgc.i - -# target to preprocess a source file -src/lgc.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lgc.c.i -.PHONY : src/lgc.c.i - -src/lgc.s: src/lgc.c.s -.PHONY : src/lgc.s - -# target to generate assembly for a file -src/lgc.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lgc.c.s -.PHONY : src/lgc.c.s - -src/linit.o: src/linit.c.o -.PHONY : src/linit.o - -# target to build an object file -src/linit.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/linit.c.o -.PHONY : src/linit.c.o - -src/linit.i: src/linit.c.i -.PHONY : src/linit.i - -# target to preprocess a source file -src/linit.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/linit.c.i -.PHONY : src/linit.c.i - -src/linit.s: src/linit.c.s -.PHONY : src/linit.s - -# target to generate assembly for a file -src/linit.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/linit.c.s -.PHONY : src/linit.c.s - -src/liolib.o: src/liolib.c.o -.PHONY : src/liolib.o - -# target to build an object file -src/liolib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/liolib.c.o -.PHONY : src/liolib.c.o - -src/liolib.i: src/liolib.c.i -.PHONY : src/liolib.i - -# target to preprocess a source file -src/liolib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/liolib.c.i -.PHONY : src/liolib.c.i - -src/liolib.s: src/liolib.c.s -.PHONY : src/liolib.s - -# target to generate assembly for a file -src/liolib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/liolib.c.s -.PHONY : src/liolib.c.s - -src/llex.o: src/llex.c.o -.PHONY : src/llex.o - -# target to build an object file -src/llex.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/llex.c.o -.PHONY : src/llex.c.o - -src/llex.i: src/llex.c.i -.PHONY : src/llex.i - -# target to preprocess a source file -src/llex.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/llex.c.i -.PHONY : src/llex.c.i - -src/llex.s: src/llex.c.s -.PHONY : src/llex.s - -# target to generate assembly for a file -src/llex.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/llex.c.s -.PHONY : src/llex.c.s - -src/lmathlib.o: src/lmathlib.c.o -.PHONY : src/lmathlib.o - -# target to build an object file -src/lmathlib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmathlib.c.o -.PHONY : src/lmathlib.c.o - -src/lmathlib.i: src/lmathlib.c.i -.PHONY : src/lmathlib.i - -# target to preprocess a source file -src/lmathlib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmathlib.c.i -.PHONY : src/lmathlib.c.i - -src/lmathlib.s: src/lmathlib.c.s -.PHONY : src/lmathlib.s - -# target to generate assembly for a file -src/lmathlib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmathlib.c.s -.PHONY : src/lmathlib.c.s - -src/lmem.o: src/lmem.c.o -.PHONY : src/lmem.o - -# target to build an object file -src/lmem.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmem.c.o -.PHONY : src/lmem.c.o - -src/lmem.i: src/lmem.c.i -.PHONY : src/lmem.i - -# target to preprocess a source file -src/lmem.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmem.c.i -.PHONY : src/lmem.c.i - -src/lmem.s: src/lmem.c.s -.PHONY : src/lmem.s - -# target to generate assembly for a file -src/lmem.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lmem.c.s -.PHONY : src/lmem.c.s - -src/loadlib.o: src/loadlib.c.o -.PHONY : src/loadlib.o - -# target to build an object file -src/loadlib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loadlib.c.o -.PHONY : src/loadlib.c.o - -src/loadlib.i: src/loadlib.c.i -.PHONY : src/loadlib.i - -# target to preprocess a source file -src/loadlib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loadlib.c.i -.PHONY : src/loadlib.c.i - -src/loadlib.s: src/loadlib.c.s -.PHONY : src/loadlib.s - -# target to generate assembly for a file -src/loadlib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loadlib.c.s -.PHONY : src/loadlib.c.s - -src/lobject.o: src/lobject.c.o -.PHONY : src/lobject.o - -# target to build an object file -src/lobject.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lobject.c.o -.PHONY : src/lobject.c.o - -src/lobject.i: src/lobject.c.i -.PHONY : src/lobject.i - -# target to preprocess a source file -src/lobject.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lobject.c.i -.PHONY : src/lobject.c.i - -src/lobject.s: src/lobject.c.s -.PHONY : src/lobject.s - -# target to generate assembly for a file -src/lobject.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lobject.c.s -.PHONY : src/lobject.c.s - -src/lopcodes.o: src/lopcodes.c.o -.PHONY : src/lopcodes.o - -# target to build an object file -src/lopcodes.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lopcodes.c.o -.PHONY : src/lopcodes.c.o - -src/lopcodes.i: src/lopcodes.c.i -.PHONY : src/lopcodes.i - -# target to preprocess a source file -src/lopcodes.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lopcodes.c.i -.PHONY : src/lopcodes.c.i - -src/lopcodes.s: src/lopcodes.c.s -.PHONY : src/lopcodes.s - -# target to generate assembly for a file -src/lopcodes.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lopcodes.c.s -.PHONY : src/lopcodes.c.s - -src/loslib.o: src/loslib.c.o -.PHONY : src/loslib.o - -# target to build an object file -src/loslib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loslib.c.o -.PHONY : src/loslib.c.o - -src/loslib.i: src/loslib.c.i -.PHONY : src/loslib.i - -# target to preprocess a source file -src/loslib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loslib.c.i -.PHONY : src/loslib.c.i - -src/loslib.s: src/loslib.c.s -.PHONY : src/loslib.s - -# target to generate assembly for a file -src/loslib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/loslib.c.s -.PHONY : src/loslib.c.s - -src/lparser.o: src/lparser.c.o -.PHONY : src/lparser.o - -# target to build an object file -src/lparser.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lparser.c.o -.PHONY : src/lparser.c.o - -src/lparser.i: src/lparser.c.i -.PHONY : src/lparser.i - -# target to preprocess a source file -src/lparser.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lparser.c.i -.PHONY : src/lparser.c.i - -src/lparser.s: src/lparser.c.s -.PHONY : src/lparser.s - -# target to generate assembly for a file -src/lparser.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lparser.c.s -.PHONY : src/lparser.c.s - -src/lstate.o: src/lstate.c.o -.PHONY : src/lstate.o - -# target to build an object file -src/lstate.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstate.c.o -.PHONY : src/lstate.c.o - -src/lstate.i: src/lstate.c.i -.PHONY : src/lstate.i - -# target to preprocess a source file -src/lstate.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstate.c.i -.PHONY : src/lstate.c.i - -src/lstate.s: src/lstate.c.s -.PHONY : src/lstate.s - -# target to generate assembly for a file -src/lstate.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstate.c.s -.PHONY : src/lstate.c.s - -src/lstring.o: src/lstring.c.o -.PHONY : src/lstring.o - -# target to build an object file -src/lstring.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstring.c.o -.PHONY : src/lstring.c.o - -src/lstring.i: src/lstring.c.i -.PHONY : src/lstring.i - -# target to preprocess a source file -src/lstring.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstring.c.i -.PHONY : src/lstring.c.i - -src/lstring.s: src/lstring.c.s -.PHONY : src/lstring.s - -# target to generate assembly for a file -src/lstring.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstring.c.s -.PHONY : src/lstring.c.s - -src/lstrlib.o: src/lstrlib.c.o -.PHONY : src/lstrlib.o - -# target to build an object file -src/lstrlib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstrlib.c.o -.PHONY : src/lstrlib.c.o - -src/lstrlib.i: src/lstrlib.c.i -.PHONY : src/lstrlib.i - -# target to preprocess a source file -src/lstrlib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstrlib.c.i -.PHONY : src/lstrlib.c.i - -src/lstrlib.s: src/lstrlib.c.s -.PHONY : src/lstrlib.s - -# target to generate assembly for a file -src/lstrlib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lstrlib.c.s -.PHONY : src/lstrlib.c.s - -src/ltable.o: src/ltable.c.o -.PHONY : src/ltable.o - -# target to build an object file -src/ltable.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltable.c.o -.PHONY : src/ltable.c.o - -src/ltable.i: src/ltable.c.i -.PHONY : src/ltable.i - -# target to preprocess a source file -src/ltable.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltable.c.i -.PHONY : src/ltable.c.i - -src/ltable.s: src/ltable.c.s -.PHONY : src/ltable.s - -# target to generate assembly for a file -src/ltable.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltable.c.s -.PHONY : src/ltable.c.s - -src/ltablib.o: src/ltablib.c.o -.PHONY : src/ltablib.o - -# target to build an object file -src/ltablib.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltablib.c.o -.PHONY : src/ltablib.c.o - -src/ltablib.i: src/ltablib.c.i -.PHONY : src/ltablib.i - -# target to preprocess a source file -src/ltablib.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltablib.c.i -.PHONY : src/ltablib.c.i - -src/ltablib.s: src/ltablib.c.s -.PHONY : src/ltablib.s - -# target to generate assembly for a file -src/ltablib.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltablib.c.s -.PHONY : src/ltablib.c.s - -src/ltm.o: src/ltm.c.o -.PHONY : src/ltm.o - -# target to build an object file -src/ltm.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltm.c.o -.PHONY : src/ltm.c.o - -src/ltm.i: src/ltm.c.i -.PHONY : src/ltm.i - -# target to preprocess a source file -src/ltm.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltm.c.i -.PHONY : src/ltm.c.i - -src/ltm.s: src/ltm.c.s -.PHONY : src/ltm.s - -# target to generate assembly for a file -src/ltm.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/ltm.c.s -.PHONY : src/ltm.c.s - -src/lundump.o: src/lundump.c.o -.PHONY : src/lundump.o - -# target to build an object file -src/lundump.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lundump.c.o -.PHONY : src/lundump.c.o - -src/lundump.i: src/lundump.c.i -.PHONY : src/lundump.i - -# target to preprocess a source file -src/lundump.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lundump.c.i -.PHONY : src/lundump.c.i - -src/lundump.s: src/lundump.c.s -.PHONY : src/lundump.s - -# target to generate assembly for a file -src/lundump.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lundump.c.s -.PHONY : src/lundump.c.s - -src/lvm.o: src/lvm.c.o -.PHONY : src/lvm.o - -# target to build an object file -src/lvm.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lvm.c.o -.PHONY : src/lvm.c.o - -src/lvm.i: src/lvm.c.i -.PHONY : src/lvm.i - -# target to preprocess a source file -src/lvm.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lvm.c.i -.PHONY : src/lvm.c.i - -src/lvm.s: src/lvm.c.s -.PHONY : src/lvm.s - -# target to generate assembly for a file -src/lvm.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lvm.c.s -.PHONY : src/lvm.c.s - -src/lzio.o: src/lzio.c.o -.PHONY : src/lzio.o - -# target to build an object file -src/lzio.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lzio.c.o -.PHONY : src/lzio.c.o - -src/lzio.i: src/lzio.c.i -.PHONY : src/lzio.i - -# target to preprocess a source file -src/lzio.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lzio.c.i -.PHONY : src/lzio.c.i - -src/lzio.s: src/lzio.c.s -.PHONY : src/lzio.s - -# target to generate assembly for a file -src/lzio.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/lzio.c.s -.PHONY : src/lzio.c.s - -src/print.o: src/print.c.o -.PHONY : src/print.o - -# target to build an object file -src/print.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/print.c.o -.PHONY : src/print.c.o - -src/print.i: src/print.c.i -.PHONY : src/print.i - -# target to preprocess a source file -src/print.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/print.c.i -.PHONY : src/print.c.i - -src/print.s: src/print.c.s -.PHONY : src/print.s - -# target to generate assembly for a file -src/print.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/lua/CMakeFiles/lua.dir/build.make lib/lua/CMakeFiles/lua.dir/src/print.c.s -.PHONY : src/print.c.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... edit_cache" - @echo "... lua" - @echo "... rebuild_cache" - @echo "... src/lapi.o" - @echo "... src/lapi.i" - @echo "... src/lapi.s" - @echo "... src/lauxlib.o" - @echo "... src/lauxlib.i" - @echo "... src/lauxlib.s" - @echo "... src/lbaselib.o" - @echo "... src/lbaselib.i" - @echo "... src/lbaselib.s" - @echo "... src/lcode.o" - @echo "... src/lcode.i" - @echo "... src/lcode.s" - @echo "... src/ldblib.o" - @echo "... src/ldblib.i" - @echo "... src/ldblib.s" - @echo "... src/ldebug.o" - @echo "... src/ldebug.i" - @echo "... src/ldebug.s" - @echo "... src/ldo.o" - @echo "... src/ldo.i" - @echo "... src/ldo.s" - @echo "... src/ldump.o" - @echo "... src/ldump.i" - @echo "... src/ldump.s" - @echo "... src/lfunc.o" - @echo "... src/lfunc.i" - @echo "... src/lfunc.s" - @echo "... src/lgc.o" - @echo "... src/lgc.i" - @echo "... src/lgc.s" - @echo "... src/linit.o" - @echo "... src/linit.i" - @echo "... src/linit.s" - @echo "... src/liolib.o" - @echo "... src/liolib.i" - @echo "... src/liolib.s" - @echo "... src/llex.o" - @echo "... src/llex.i" - @echo "... src/llex.s" - @echo "... src/lmathlib.o" - @echo "... src/lmathlib.i" - @echo "... src/lmathlib.s" - @echo "... src/lmem.o" - @echo "... src/lmem.i" - @echo "... src/lmem.s" - @echo "... src/loadlib.o" - @echo "... src/loadlib.i" - @echo "... src/loadlib.s" - @echo "... src/lobject.o" - @echo "... src/lobject.i" - @echo "... src/lobject.s" - @echo "... src/lopcodes.o" - @echo "... src/lopcodes.i" - @echo "... src/lopcodes.s" - @echo "... src/loslib.o" - @echo "... src/loslib.i" - @echo "... src/loslib.s" - @echo "... src/lparser.o" - @echo "... src/lparser.i" - @echo "... src/lparser.s" - @echo "... src/lstate.o" - @echo "... src/lstate.i" - @echo "... src/lstate.s" - @echo "... src/lstring.o" - @echo "... src/lstring.i" - @echo "... src/lstring.s" - @echo "... src/lstrlib.o" - @echo "... src/lstrlib.i" - @echo "... src/lstrlib.s" - @echo "... src/ltable.o" - @echo "... src/ltable.i" - @echo "... src/ltable.s" - @echo "... src/ltablib.o" - @echo "... src/ltablib.i" - @echo "... src/ltablib.s" - @echo "... src/ltm.o" - @echo "... src/ltm.i" - @echo "... src/ltm.s" - @echo "... src/lundump.o" - @echo "... src/lundump.i" - @echo "... src/lundump.s" - @echo "... src/lvm.o" - @echo "... src/lvm.i" - @echo "... src/lvm.s" - @echo "... src/lzio.o" - @echo "... src/lzio.i" - @echo "... src/lzio.s" - @echo "... src/print.o" - @echo "... src/print.i" - @echo "... src/print.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - From 15a980a6169ff975628bf1d4ecd16168fe609bf4 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 16:11:34 +0000 Subject: [PATCH 021/144] merged in warnings changes --- VC2008/MCServer.vcproj | 4 --- src/Bindings/LuaState.h | 21 +++++++++++++++ src/Bindings/PluginManager.h | 2 +- src/BlockEntities/BlockEntity.h | 6 ++++- src/BlockEntities/BlockEntityWithItems.h | 1 + src/BlockEntities/FurnaceEntity.h | 2 +- src/BlockEntities/JukeboxEntity.h | 2 +- src/BlockEntities/NoteEntity.h | 2 +- src/Blocks/BlockHandler.h | 6 ++++- src/Chunk.cpp | 15 +++-------- src/Chunk.h | 23 ---------------- src/Chunk.inl.h | 34 ------------------------ src/ChunkDef.h | 1 + src/ChunkSender.cpp | 2 +- src/CommandOutput.h | 1 + src/Entities/Entity.h | 14 +++++++--- src/Entities/Player.h | 4 +-- src/Entities/ProjectileEntity.h | 6 ++++- src/Items/ItemHandler.h | 8 +++++- src/Piston.cpp | 1 + src/Root.cpp | 2 +- src/Server.h | 2 ++ src/Simulator/FireSimulator.h | 2 +- src/Simulator/RedstoneSimulator.h | 4 +-- src/Simulator/SandSimulator.h | 2 +- src/Simulator/Simulator.h | 9 ++++++- src/WebAdmin.h | 15 ++++++++--- 27 files changed, 94 insertions(+), 97 deletions(-) delete mode 100644 src/Chunk.inl.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index cb986745..491e7740 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -494,10 +494,6 @@ RelativePath="..\src\Chunk.h" > - - diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 40bb67e6..a6c31b6d 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -246,6 +246,7 @@ public: > bool Call(FnT a_FnName, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -265,6 +266,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -285,6 +287,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -306,6 +309,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -328,6 +332,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -351,6 +356,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -376,6 +382,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -402,6 +409,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -429,6 +437,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -457,6 +466,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -486,6 +496,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, ArgT10 a_Arg10, const cRet & a_Mark, RetT1 & a_Ret1) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -515,6 +526,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -536,6 +548,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -559,6 +572,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -583,6 +597,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -608,6 +623,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -635,6 +651,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -663,6 +680,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -692,6 +710,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -722,6 +741,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; @@ -753,6 +773,7 @@ public: > bool Call(FnT a_FnName, ArgT1 a_Arg1, ArgT2 a_Arg2, ArgT3 a_Arg3, ArgT4 a_Arg4, ArgT5 a_Arg5, ArgT6 a_Arg6, ArgT7 a_Arg7, ArgT8 a_Arg8, ArgT9 a_Arg9, const cRet & a_Mark, RetT1 & a_Ret1, RetT2 & a_Ret2, RetT3 & a_Ret3, RetT4 & a_Ret4, RetT5 & a_Ret5) { + UNUSED(a_Mark); if (!PushFunction(a_FnName)) { return false; diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 5abb8be8..e9442105 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -273,7 +273,7 @@ private: bool m_bReloadPlugins; cPluginManager(); - ~cPluginManager(); + virtual ~cPluginManager(); /// Reloads all plugins, defaulting to settings.ini for settings location void ReloadPluginsNow(void); diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index 0d358b55..7c6688f8 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -87,7 +87,11 @@ public: virtual void SendTo(cClientHandle & a_Client) = 0; /// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. - virtual bool Tick(float a_Dt, cChunk & a_Chunk) { return false; } + virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) + { + UNUSED(a_Dt); + return false; + } protected: /// Position in absolute block coordinates diff --git a/src/BlockEntities/BlockEntityWithItems.h b/src/BlockEntities/BlockEntityWithItems.h index f35412e0..bf6289a2 100644 --- a/src/BlockEntities/BlockEntityWithItems.h +++ b/src/BlockEntities/BlockEntityWithItems.h @@ -73,6 +73,7 @@ protected: // cItemGrid::cListener overrides: virtual void OnSlotChanged(cItemGrid * a_Grid, int a_SlotNum) { + UNUSED(a_SlotNum); ASSERT(a_Grid == &m_Contents); if (m_World != NULL) { diff --git a/src/BlockEntities/FurnaceEntity.h b/src/BlockEntities/FurnaceEntity.h index 8b695d61..b0818730 100644 --- a/src/BlockEntities/FurnaceEntity.h +++ b/src/BlockEntities/FurnaceEntity.h @@ -95,7 +95,7 @@ public: // tolua_end - void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) {m_FuelBurnTime = a_FuelBurnTime; m_TimeBurned = 0; } + void SetBurnTimes(int a_FuelBurnTime, int a_TimeBurned) {m_FuelBurnTime = a_FuelBurnTime; m_TimeBurned = a_TimeBurned; } void SetCookTimes(int a_NeedCookTime, int a_TimeCooked) {m_NeedCookTime = a_NeedCookTime; m_TimeCooked = a_TimeCooked; } protected: diff --git a/src/BlockEntities/JukeboxEntity.h b/src/BlockEntities/JukeboxEntity.h index fcafdc47..996de965 100644 --- a/src/BlockEntities/JukeboxEntity.h +++ b/src/BlockEntities/JukeboxEntity.h @@ -45,7 +45,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle & a_Client) override { }; + virtual void SendTo(cClientHandle &) override { }; private: int m_Record; diff --git a/src/BlockEntities/NoteEntity.h b/src/BlockEntities/NoteEntity.h index e2d088f4..cf78aeac 100644 --- a/src/BlockEntities/NoteEntity.h +++ b/src/BlockEntities/NoteEntity.h @@ -52,7 +52,7 @@ public: // tolua_end virtual void UsedBy(cPlayer * a_Player) override; - virtual void SendTo(cClientHandle & a_Client) override { }; + virtual void SendTo(cClientHandle &) override { }; private: char m_Pitch; diff --git a/src/Blocks/BlockHandler.h b/src/Blocks/BlockHandler.h index 107d3647..a732aa79 100644 --- a/src/Blocks/BlockHandler.h +++ b/src/Blocks/BlockHandler.h @@ -99,7 +99,11 @@ public: virtual bool DoesIgnoreBuildCollision(void); /// Similar to DoesIgnoreBuildCollision(void), but is used for cases where block meta/player item-in-hand is needed to determine collision (thin snow) - virtual bool DoesIgnoreBuildCollision(cPlayer * a_Player, NIBBLETYPE a_Meta) { return DoesIgnoreBuildCollision(); } + virtual bool DoesIgnoreBuildCollision(cPlayer *, NIBBLETYPE a_Meta) + { + UNUSED(a_Meta); + return DoesIgnoreBuildCollision(); + } /// Returns if this block drops if it gets destroyed by an unsuitable situation. Default: true virtual bool DoesDropOnUnsuitable(void); diff --git a/src/Chunk.cpp b/src/Chunk.cpp index c446db9a..b229a4af 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -527,9 +527,10 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO : check that "Level" really means Y + /* NIBBLETYPE SkyLight = 0; - NIBBLETYPE BlockLight = 0; + */ if (IsLightValid()) { @@ -2324,8 +2325,8 @@ BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); - a_BlockType = cChunkDef::GetBlock (m_BlockTypes, a_RelX, a_RelY, a_RelZ); - a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); + a_BlockType = cChunkDef::GetBlock (m_BlockTypes, Idx); + a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, Idx); } @@ -2897,11 +2898,3 @@ NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const - -#if !C_CHUNK_USE_INLINE -# include "cChunk.inl.h" -#endif - - - - diff --git a/src/Chunk.h b/src/Chunk.h index 05a96d41..f0a50c3c 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -12,19 +12,6 @@ -#define C_CHUNK_USE_INLINE 1 - -// Do not touch -#if C_CHUNK_USE_INLINE - #define __C_CHUNK_INLINE__ inline -#else - #define __C_CHUNK_INLINE__ -#endif - - - - - namespace Json { class Value; @@ -436,8 +423,6 @@ private: void RemoveBlockEntity(cBlockEntity * a_BlockEntity); void AddBlockEntity (cBlockEntity * a_BlockEntity); - void SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff); - /// Creates a block entity for each block that needs a block entity and doesn't have one in the list void CreateBlockEntities(void); @@ -482,11 +467,3 @@ typedef std::list cChunkPtrList; - -#if C_CHUNK_USE_INLINE - #include "Chunk.inl.h" -#endif - - - - diff --git a/src/Chunk.inl.h b/src/Chunk.inl.h deleted file mode 100644 index fb9c4dad..00000000 --- a/src/Chunk.inl.h +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef __C_CHUNK_INL_H__ -#define __C_CHUNK_INL_H__ - -#ifndef MAX -# define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - - - - - -__C_CHUNK_INLINE__ -void cChunk::SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff) -{ - unsigned char CurrentLight = cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z ); - cChunkDef::SetNibble( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X-1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X+1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y-1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y+1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z-1 ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z+1 ), MAX(0,CurrentLight-a_Falloff) ) ); - MarkDirty(); -} - - - - - -#endif - - - - diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 8c37e790..7d727a4d 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -182,6 +182,7 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) { + UNUSED(a_Y); BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); a_X = a_X - a_ChunkX * Width; diff --git a/src/ChunkSender.cpp b/src/ChunkSender.cpp index fe3ee9b4..2425adf1 100644 --- a/src/ChunkSender.cpp +++ b/src/ChunkSender.cpp @@ -264,7 +264,7 @@ void cChunkSender::BlockEntity(cBlockEntity * a_Entity) -void cChunkSender::Entity(cEntity * a_Entity) +void cChunkSender::Entity(cEntity *) { // Nothing needed yet, perhaps in the future when we save entities into chunks we'd like to send them upon load, too ;) } diff --git a/src/CommandOutput.h b/src/CommandOutput.h index bdf67523..3763d625 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -38,6 +38,7 @@ class cNullCommandOutputCallback : virtual void Out(const AString & a_Text) override { // Do nothing + UNUSED(a_Text); } } ; diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9cb36eb1..2ba1b303 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -351,10 +351,14 @@ public: // tolua_end /// Called when the specified player right-clicks this entity - virtual void OnRightClicked(cPlayer & a_Player) {}; + virtual void OnRightClicked(cPlayer &) {}; /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). - virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) {} + virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) + { + UNUSED(a_Drops); + UNUSED(a_Killer); + } protected: static cCriticalSection m_CSCount; @@ -420,11 +424,13 @@ protected: void Dereference( cEntity*& a_EntityPtr ); private: - // Measured in degrees (MAX 360°) + // Measured in degrees, [-180, +180) double m_HeadYaw; + // Measured in meter/second (m/s) Vector3d m_Speed; - // Measured in degrees (MAX 360°) + + // Measured in degrees, [-180, +180) Vector3d m_Rot; /// Position of the entity's XZ center and Y bottom diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 66f1c07a..f9ce950b 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -45,7 +45,7 @@ public: virtual void Tick(float a_Dt, cChunk & a_Chunk) override; - virtual void HandlePhysics(float a_Dt, cChunk & a_Chunk) override { }; + virtual void HandlePhysics(float a_Dt, cChunk &) override { UNUSED(a_Dt); }; /// Returns the curently equipped weapon; empty item if none virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); } @@ -114,7 +114,7 @@ public: double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export - inline const double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. + inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h index 959e81ae..4721409e 100644 --- a/src/Entities/ProjectileEntity.h +++ b/src/Entities/ProjectileEntity.h @@ -52,7 +52,11 @@ public: virtual void OnHitSolidBlock(const Vector3d & a_HitPos, char a_HitFace); /// Called by the physics blocktracer when the entity hits another entity - virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) {} + virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) + { + UNUSED(a_EntityHit); + UNUSED(a_HitPos); + } /// Called by Chunk when the projectile is eligible for player collection virtual void CollectedBy(cPlayer * a_Dest); diff --git a/src/Items/ItemHandler.h b/src/Items/ItemHandler.h index e39bb054..db0ffc9d 100644 --- a/src/Items/ItemHandler.h +++ b/src/Items/ItemHandler.h @@ -25,7 +25,13 @@ public: virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); /// Called when the client sends the SHOOT status in the lclk packet - virtual void OnItemShoot(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) {} + virtual void OnItemShoot(cPlayer *, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_BlockFace); + } /// Called while the player diggs a block using this item virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace); diff --git a/src/Piston.cpp b/src/Piston.cpp index b15e7d95..75eeb5e9 100644 --- a/src/Piston.cpp +++ b/src/Piston.cpp @@ -238,6 +238,7 @@ bool cPiston::CanPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) bool cPiston::CanBreakPush(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) { + UNUSED(a_BlockMeta); return g_BlockPistonBreakable[a_BlockType]; } diff --git a/src/Root.cpp b/src/Root.cpp index 798f965b..16a52169 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -596,10 +596,10 @@ bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallbac public: cCallback (const AString & a_PlayerName, cPlayerListCallback & a_Callback) : - m_Callback(a_Callback), m_BestRating(0), m_NameLength(a_PlayerName.length()), m_PlayerName(a_PlayerName), + m_Callback(a_Callback), m_BestMatch(NULL), m_NumMatches(0) {} diff --git a/src/Server.h b/src/Server.h index 0d93469a..1f94bb3d 100644 --- a/src/Server.h +++ b/src/Server.h @@ -35,6 +35,8 @@ class cServer // tolua_export : public cListenThread::cCallback { // tolua_export public: // tolua_export + + virtual ~cServer() {} bool InitServer(cIniFile & a_SettingsIni); // tolua_begin diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h index 66c31b44..9ccc3ef4 100644 --- a/src/Simulator/FireSimulator.h +++ b/src/Simulator/FireSimulator.h @@ -22,7 +22,7 @@ public: cFireSimulator(cWorld & a_World, cIniFile & a_IniFile); ~cFireSimulator(); - virtual void Simulate(float a_Dt) override {} // not used + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h index 60c86a3c..1080c3f8 100644 --- a/src/Simulator/RedstoneSimulator.h +++ b/src/Simulator/RedstoneSimulator.h @@ -19,7 +19,7 @@ public: cRedstoneSimulator(cWorld & a_World); ~cRedstoneSimulator(); - virtual void Simulate(float a_Dt) override {}; // Not used in this simulator + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return IsRedstone(a_BlockType); } @@ -271,4 +271,4 @@ private: default: return false; } } -}; \ No newline at end of file +}; diff --git a/src/Simulator/SandSimulator.h b/src/Simulator/SandSimulator.h index 6e9ea15a..6e64aa42 100644 --- a/src/Simulator/SandSimulator.h +++ b/src/Simulator/SandSimulator.h @@ -15,7 +15,7 @@ public: cSandSimulator(cWorld & a_World, cIniFile & a_IniFile); // cSimulator overrides: - virtual void Simulate(float a_Dt) override {} // Unused in this simulator + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} // not used virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) override; virtual bool IsAllowedBlock(BLOCKTYPE a_BlockType) override; diff --git a/src/Simulator/Simulator.h b/src/Simulator/Simulator.h index 5cd0e865..a25b7f1b 100644 --- a/src/Simulator/Simulator.h +++ b/src/Simulator/Simulator.h @@ -25,7 +25,14 @@ public: virtual void Simulate(float a_Dt) = 0; /// Called in each tick for each chunk, a_Dt is the time passed since the last tick, in msec; direct access to chunk data available - virtual void SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChunk * a_Chunk) {}; + virtual void SimulateChunk(float a_Dt, int a_ChunkX, + int a_ChunkZ, cChunk * a_Chunk) + { + UNUSED(a_Dt); + UNUSED(a_ChunkX); + UNUSED(a_ChunkZ); + UNUSED(a_Chunk); + }; /// Called when a block changes virtual void WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk); diff --git a/src/WebAdmin.h b/src/WebAdmin.h index 0907e7bc..3eb80764 100644 --- a/src/WebAdmin.h +++ b/src/WebAdmin.h @@ -105,7 +105,7 @@ public: cWebAdmin(void); - ~cWebAdmin(); + virtual ~cWebAdmin(); /// Initializes the object. Returns true if successfully initialized and ready to start bool Init(void); @@ -169,9 +169,16 @@ protected: virtual void OnBody(const char * a_Data, int a_Size) override; // cHTTPFormParser::cCallbacks overrides. Files are ignored: - virtual void OnFileStart(cHTTPFormParser & a_Parser, const AString & a_FileName) override {} - virtual void OnFileData(cHTTPFormParser & a_Parser, const char * a_Data, int a_Size) override {} - virtual void OnFileEnd(cHTTPFormParser & a_Parser) override {} + virtual void OnFileStart(cHTTPFormParser &, const AString & a_FileName) override + { + UNUSED(a_FileName); + } + virtual void OnFileData(cHTTPFormParser &, const char * a_Data, int a_Size) override + { + UNUSED(a_Data); + UNUSED(a_Size); + } + virtual void OnFileEnd(cHTTPFormParser &) override {} } ; From 1f938b721b762a608efb8faee1913904c2cb1a77 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 16:26:45 +0000 Subject: [PATCH 022/144] added mergetool files to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 97712204..b15b6d50 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ cloc.xsl ## emacs *.*~ *~ +*.orig # world inside source ChunkWorx.ini From 75abce905d28192ec1ad049945b160f2b64fee4a Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 16:33:40 +0000 Subject: [PATCH 023/144] fixed bad merge --- src/Chunk.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 34cb6a53..fb26e983 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -2900,10 +2900,6 @@ NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const -#if !C_CHUNK_USE_INLINE -# include "cChunk.inl.h" -#endif - From d0cd9a2b36749b17f6c06998f5a766e498996b8a Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 22:52:21 +0000 Subject: [PATCH 024/144] added link dependency between WorldStorage and OSSupport --- src/WorldStorage/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt index d431bdf6..2c83c466 100644 --- a/src/WorldStorage/CMakeLists.txt +++ b/src/WorldStorage/CMakeLists.txt @@ -9,3 +9,5 @@ file(GLOB SOURCE ) add_library(WorldStorage ${SOURCE}) + +target_link_libraries(WorldStorage OSSupport) From a1211bcdff8e48a04b40ee60953918bbd97cc739 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 28 Dec 2013 14:42:11 +0100 Subject: [PATCH 025/144] Added support for out-of-source builds. --- src/Bindings/CMakeLists.txt | 23 ++++++++++++++--------- src/CMakeLists.txt | 25 ++++++++++++++++--------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt index 41c641d9..50b81e42 100644 --- a/src/Bindings/CMakeLists.txt +++ b/src/Bindings/CMakeLists.txt @@ -2,17 +2,22 @@ cmake_minimum_required (VERSION 2.6) project (MCServer) +# NOTE: This CMake file is processed only for Unix builds; Windows(MSVC) builds handle all the subfolders in /src in a single file, /src/CMakeLists.txt + include_directories ("${PROJECT_SOURCE_DIR}/../") - ADD_CUSTOM_COMMAND( -#add any new generated bindings here - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Bindings.cpp ${CMAKE_CURRENT_BINARY_DIR}/Bindings.h -#command execuded to regerate bindings - COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg -#add any new generation dependencies here - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/virtual_method_hooks.lua ${CMAKE_CURRENT_SOURCE_DIR}/AllToLua.pkg tolua - ) - +ADD_CUSTOM_COMMAND( + # add any new generated bindings here + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h + + # command execuded to regerate bindings + COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + + # add any new generation dependencies here + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/virtual_method_hooks.lua ${CMAKE_CURRENT_SOURCE_DIR}/AllToLua.pkg tolua +) + #add cpp files here add_library(Bindings PluginManager LuaState WebPlugin Bindings ManualBindings LuaWindow Plugin PluginLua WebPlugin) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88e469b7..bd06798f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,7 @@ set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities) -if (NOT WIN32) +if (NOT MSVC) foreach(folder ${FOLDERS}) add_subdirectory(${folder}) endforeach(folder) @@ -62,18 +62,25 @@ else () endif() -if (UNIX) - set(EXECUTABLE ../MCServer/MCServer) -else () - set(EXECUTABLE MCServer) -endif () - +set(EXECUTABLE MCServer) add_executable(${EXECUTABLE} ${SOURCE}) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/MCServer) + +if (MSVC) + # MSVC generator adds a "Debug" or "Release" postfixes to the EXECUTABLE_OUTPUT_PATH, we need to cancel them: + SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES PREFIX "../") + SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES IMPORT_PREFIX "../") +endif() + + +# Make the debug executable have a "_debug" suffix +SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES DEBUG_POSTFIX "_debug") + # Precompiled headers (2nd part) -if (WIN32) +if (MSVC) SET_TARGET_PROPERTIES( ${EXECUTABLE} PROPERTIES COMPILE_FLAGS "/Yu\"Globals.h\"" OBJECT_DEPENDS "$(IntDir)/$(TargetName.pch)" @@ -81,7 +88,7 @@ if (WIN32) endif () -if (NOT WIN32) +if (NOT MSVC) target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks) target_link_libraries(${EXECUTABLE} Protocol Generating WorldStorage) target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities) From ee15d4e08e90536afbb381a6d65a418e0027658d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Dec 2013 17:41:59 +0100 Subject: [PATCH 026/144] Fixed compilation in VC2008. Also removed an unused inline header file (yuck). --- VC2008/MCServer.vcproj | 4 ---- src/BlockEntities/BlockEntity.h | 3 +-- src/Chunk.cpp | 20 +++++++------------ src/Chunk.h | 23 ---------------------- src/Chunk.inl.h | 34 --------------------------------- src/ChunkDef.h | 2 +- src/Entities/Entity.h | 6 ++++-- 7 files changed, 13 insertions(+), 79 deletions(-) delete mode 100644 src/Chunk.inl.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index cb986745..491e7740 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -494,10 +494,6 @@ RelativePath="..\src\Chunk.h" > - - diff --git a/src/BlockEntities/BlockEntity.h b/src/BlockEntities/BlockEntity.h index c3b8d41c..7c6688f8 100644 --- a/src/BlockEntities/BlockEntity.h +++ b/src/BlockEntities/BlockEntity.h @@ -87,10 +87,9 @@ public: virtual void SendTo(cClientHandle & a_Client) = 0; /// Ticks the entity; returns true if the chunk should be marked as dirty as a result of this ticking. By default does nothing. - virtual bool Tick(float a_Dt, cChunk & a_Chunk) + virtual bool Tick(float a_Dt, cChunk & /* a_Chunk */) { UNUSED(a_Dt); - UNUSED(a_Chunk); return false; } diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a16d34f3..b229a4af 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -527,9 +527,10 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) // MG TODO : check that "Level" really means Y - /*NIBBLETYPE SkyLight = 0; - - NIBBLETYPE BlockLight = 0;*/ + /* + NIBBLETYPE SkyLight = 0; + NIBBLETYPE BlockLight = 0; + */ if (IsLightValid()) { @@ -2323,8 +2324,9 @@ BLOCKTYPE cChunk::GetBlock(int a_BlockIdx) const void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) { - a_BlockType = cChunkDef::GetBlock (m_BlockTypes, a_RelX, a_RelY, a_RelZ); - a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, a_RelX, a_RelY, a_RelZ); + int Idx = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY, a_RelZ); + a_BlockType = cChunkDef::GetBlock (m_BlockTypes, Idx); + a_BlockMeta = cChunkDef::GetNibble(m_BlockMeta, Idx); } @@ -2896,11 +2898,3 @@ NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const - -#if !C_CHUNK_USE_INLINE -# include "cChunk.inl.h" -#endif - - - - diff --git a/src/Chunk.h b/src/Chunk.h index 05a96d41..f0a50c3c 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -12,19 +12,6 @@ -#define C_CHUNK_USE_INLINE 1 - -// Do not touch -#if C_CHUNK_USE_INLINE - #define __C_CHUNK_INLINE__ inline -#else - #define __C_CHUNK_INLINE__ -#endif - - - - - namespace Json { class Value; @@ -436,8 +423,6 @@ private: void RemoveBlockEntity(cBlockEntity * a_BlockEntity); void AddBlockEntity (cBlockEntity * a_BlockEntity); - void SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff); - /// Creates a block entity for each block that needs a block entity and doesn't have one in the list void CreateBlockEntities(void); @@ -482,11 +467,3 @@ typedef std::list cChunkPtrList; - -#if C_CHUNK_USE_INLINE - #include "Chunk.inl.h" -#endif - - - - diff --git a/src/Chunk.inl.h b/src/Chunk.inl.h deleted file mode 100644 index fb9c4dad..00000000 --- a/src/Chunk.inl.h +++ /dev/null @@ -1,34 +0,0 @@ - -#ifndef __C_CHUNK_INL_H__ -#define __C_CHUNK_INL_H__ - -#ifndef MAX -# define MAX(a,b) (((a)>(b))?(a):(b)) -#endif - - - - - -__C_CHUNK_INLINE__ -void cChunk::SpreadLightOfBlock(NIBBLETYPE * a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff) -{ - unsigned char CurrentLight = cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z ); - cChunkDef::SetNibble( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X-1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X+1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y-1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y+1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z-1 ), MAX(0,CurrentLight-a_Falloff) ) ); - cChunkDef::SetNibble( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(cChunkDef::GetNibble( a_LightBuffer, a_X, a_Y, a_Z+1 ), MAX(0,CurrentLight-a_Falloff) ) ); - MarkDirty(); -} - - - - - -#endif - - - - diff --git a/src/ChunkDef.h b/src/ChunkDef.h index bf41aa62..7d727a4d 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -180,7 +180,7 @@ public: /// Converts absolute block coords into relative (chunk + block) coords: - inline static void AbsoluteToRelative(/* in-out */ int & a_X, int& a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) + inline static void AbsoluteToRelative(/* in-out */ int & a_X, int & a_Y, int & a_Z, /* out */ int & a_ChunkX, int & a_ChunkZ ) { UNUSED(a_Y); BlockToChunk(a_X, a_Z, a_ChunkX, a_ChunkZ); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 3634f087..2ba1b303 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -424,11 +424,13 @@ protected: void Dereference( cEntity*& a_EntityPtr ); private: - // Measured in degrees (MAX 360 degrees) + // Measured in degrees, [-180, +180) double m_HeadYaw; + // Measured in meter/second (m/s) Vector3d m_Speed; - // Measured in degrees (MAX 360 degrees) + + // Measured in degrees, [-180, +180) Vector3d m_Rot; /// Position of the entity's XZ center and Y bottom From cd435ffca970f954d2ade1e81c7c4ae7df75907e Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 30 Dec 2013 22:56:08 +0100 Subject: [PATCH 027/144] Implented OnPlayerFishing and OnPlayerFished. --- src/Bindings/Plugin.h | 2 ++ src/Bindings/PluginLua.cpp | 40 ++++++++++++++++++++++++++++++++ src/Bindings/PluginLua.h | 2 ++ src/Bindings/PluginManager.cpp | 42 ++++++++++++++++++++++++++++++++++ src/Bindings/PluginManager.h | 4 ++++ src/Items/ItemFishingRod.h | 8 ++++++- 6 files changed, 97 insertions(+), 1 deletion(-) diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index ee0f8a06..80356304 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -68,6 +68,8 @@ public: virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerEating (cPlayer & a_Player) = 0; + virtual bool OnPlayerFished (cPlayer & a_Player, cItems & a_Reward) = 0; + virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; virtual bool OnPlayerJoined (cPlayer & a_Player) = 0; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0; virtual bool OnPlayerMoved (cPlayer & a_Player) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 69e83fb0..66a60efe 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -630,6 +630,46 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) +bool cPluginLua::OnPlayerFished(cPlayer & a_Player, cItems & a_Reward) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHED]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + +bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHING]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnPlayerJoined(cPlayer & a_Player) { cCSLock Lock(m_CriticalSection); diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index 1b257285..d0cb209f 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -64,6 +64,8 @@ public: virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; + virtual bool OnPlayerFished (cPlayer & a_Player, cItems & a_Reward) override; + virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; virtual bool OnPlayerEating (cPlayer & a_Player) override; virtual bool OnPlayerJoined (cPlayer & a_Player) override; virtual bool OnPlayerMoved (cPlayer & a_Player) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index ffffe1a2..b863a95b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -694,6 +694,48 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) +bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, cItems a_Reward) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnPlayerFished(a_Player, a_Reward)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnPlayerFishing(a_Player, a_Reward)) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_JOINED); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index e9442105..da867c7b 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -80,6 +80,8 @@ public: // tolua_export HOOK_PLAYER_BREAKING_BLOCK, HOOK_PLAYER_BROKEN_BLOCK, HOOK_PLAYER_EATING, + HOOK_PLAYER_FISHED, + HOOK_PLAYER_FISHING, HOOK_PLAYER_JOINED, HOOK_PLAYER_LEFT_CLICK, HOOK_PLAYER_MOVING, @@ -168,6 +170,8 @@ public: // tolua_export bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerEating (cPlayer & a_Player); + bool CallHookPlayerFished (cPlayer & a_Player, cItems a_Reward); + bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerMoving (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); diff --git a/src/Items/ItemFishingRod.h b/src/Items/ItemFishingRod.h index 941ce3b7..b2eaee63 100644 --- a/src/Items/ItemFishingRod.h +++ b/src/Items/ItemFishingRod.h @@ -9,9 +9,11 @@ #pragma once +#include "../Bindings/PluginManager.h" #include "../Entities/Floater.h" #include "../Entities/Entity.h" #include "../Item.h" +#include "../Root.h" @@ -210,10 +212,14 @@ public: } } - + if (cRoot::Get()->GetPluginManager()->CallHookPlayerFishing(*a_Player, Drops)) + { + return true; + } Vector3d FloaterPos = FloaterInfo.GetPos(); Vector3d FlyDirection = a_Player->GetEyePosition() - FloaterPos; a_World->SpawnItemPickups(Drops, FloaterPos.x, FloaterPos.y, FloaterPos.z, FlyDirection.x, FlyDirection.y + 1, FlyDirection.z); + cRoot::Get()->GetPluginManager()->CallHookPlayerFished(*a_Player, Drops); } } else From 782818ffb520553e772bc5a4638009664a821f90 Mon Sep 17 00:00:00 2001 From: Morgan Redshaw Date: Mon, 30 Dec 2013 21:30:20 -0700 Subject: [PATCH 028/144] Fixed a cPlayer::IsGameModeAdventure. It was determined based off of gmCreate rather than gmAdventure. --- CONTRIBUTORS | 1 + src/Entities/Player.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index bd6b204a..150bcf09 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -19,5 +19,6 @@ SamJBarney worktycho Sxw1212 tonibm19 +Diusrex Please add yourself to this list if you contribute to MCServer. diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 67d5a47e..bc92790a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -908,8 +908,8 @@ bool cPlayer::IsGameModeSurvival(void) const bool cPlayer::IsGameModeAdventure(void) const { - return (m_GameMode == gmCreative) || // Either the player is explicitly in Adventure - ((m_GameMode == gmNotSet) && m_World->IsGameModeCreative()); // or they inherit from the world and the world is Adventure + return (m_GameMode == gmAdventure) || // Either the player is explicitly in Adventure + ((m_GameMode == gmNotSet) && m_World->IsGameModeAdventure()); // or they inherit from the world and the world is Adventure } From 25d42c44d5d9cbd3eb1178fde50cf9b271e4a96e Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 13:55:06 +0000 Subject: [PATCH 029/144] fixed warnings in BlockArea.cpp --- src/BlockArea.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index 1148908c..dd8e0da3 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -28,6 +28,8 @@ template void InternalMergeBlocks( Combinator a_Combinator ) { + UNUSED(a_SrcSizeY); + UNUSED(a_DstSizeY); for (int y = 0; y < a_SizeY; y++) { int SrcBaseY = (y + a_SrcOffY) * a_SrcSizeX * a_SrcSizeZ; From 9ebc623a0a453c71add19eb67e05782248a7b7ab Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:00:32 +0000 Subject: [PATCH 030/144] fixed warnings in webadmin.cpp --- src/WebAdmin.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index a1f0842a..e6a5a01b 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -305,6 +305,7 @@ void cWebAdmin::HandleWebadminRequest(cHTTPConnection & a_Connection, cHTTPReque void cWebAdmin::HandleRootRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) { + UNUSED(a_Request); static const char LoginForm[] = \ "

MCServer WebAdmin

" \ "
" \ @@ -450,6 +451,7 @@ AString cWebAdmin::GetBaseURL(const AStringVector & a_URLSplit) void cWebAdmin::OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) { + UNUSED(a_Connection); const AString & URL = a_Request.GetURL(); if ( (strncmp(URL.c_str(), "/webadmin", 9) == 0) || @@ -473,6 +475,7 @@ void cWebAdmin::OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_ void cWebAdmin::OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, int a_Size) { + UNUSED(a_Connection); cRequestData * Data = (cRequestData *)(a_Request.GetUserData()); if (Data == NULL) { From e41dec458c690c5c99ef75fe4baf6dc7371e5b64 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:05:53 +0000 Subject: [PATCH 031/144] fixed ClientHandle warnings --- src/ClientHandle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 99df47bf..17412c26 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1409,6 +1409,7 @@ void cClientHandle::SendData(const char * a_Data, int a_Size) void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket) { + UNUSED(a_World); ASSERT(m_Player != NULL); if (a_SendRespawnPacket) From c83dfdb66e096f16805d0a842e0492645dc086c2 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:19:29 +0000 Subject: [PATCH 032/144] fixed warnings in bytebuffer.cpp --- src/ByteBuffer.cpp | 6 +++--- src/ByteBuffer.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 64c03d0d..51001800 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -773,7 +773,7 @@ void cByteBuffer::ReadAll(AString & a_Data) -bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes) +bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes) { if (!a_Dst.CanWriteBytes(a_NumBytes) || !CanReadBytes(a_NumBytes)) { @@ -781,9 +781,9 @@ bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes) return false; } char buf[1024]; - while (a_NumBytes > 0) + while (a_NumBytes > static_cast(0)) { - int num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; + size_t num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; VERIFY(ReadBuf(buf, num)); VERIFY(a_Dst.Write(buf, num)); a_NumBytes -= num; diff --git a/src/ByteBuffer.h b/src/ByteBuffer.h index 06c846fa..cbce119b 100644 --- a/src/ByteBuffer.h +++ b/src/ByteBuffer.h @@ -110,7 +110,7 @@ public: void ReadAll(AString & a_Data); /// Reads the specified number of bytes and writes it into the destinatio bytebuffer. Returns true on success. - bool ReadToByteBuffer(cByteBuffer & a_Dst, int a_NumBytes); + bool ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes); /// Removes the bytes that have been read from the ringbuffer void CommitRead(void); From 3152c7295983418a905f3f6404a54cc7b038ead9 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:28:47 +0000 Subject: [PATCH 033/144] fixed warnings in Inventory.cpp --- src/Inventory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Inventory.cpp b/src/Inventory.cpp index a9b4ab9c..a7f77cf6 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -57,6 +57,8 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, bool a_ConsiderEmptySlo int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int a_EndSlotNum, bool a_ConsiderEmptySlots) { + + UNUSED(a_ConsiderEmptySlots); if ((a_BeginSlotNum < 0) || (a_BeginSlotNum >= invNumSlots)) { LOGWARNING("%s: Bad BeginSlotNum, got %d, there are %d slots; correcting to 0.", __FUNCTION__, a_BeginSlotNum, invNumSlots - 1); @@ -96,8 +98,6 @@ int cInventory::HowManyCanFit(const cItem & a_ItemStack, int a_BeginSlotNum, int - - int cInventory::AddItem(const cItem & a_Item, bool a_AllowNewStacks, bool a_tryToFillEquippedFirst) { cItem ToAdd(a_Item); From 2e113c63f9dce41beea8597b173f072487e07d34 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:42:17 +0000 Subject: [PATCH 034/144] fixxed warnings in Server.cpp --- src/Server.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Server.cpp b/src/Server.cpp index a93be9a5..7dedc390 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -173,6 +173,7 @@ void cServer::ClientMovedToWorld(const cClientHandle * a_Client) void cServer::PlayerCreated(const cPlayer * a_Player) { + UNUSED(a_Player); // To avoid deadlocks, the player count is not handled directly, but rather posted onto the tick thread cCSLock Lock(m_CSPlayerCountDiff); m_PlayerCountDiff += 1; @@ -184,6 +185,7 @@ void cServer::PlayerCreated(const cPlayer * a_Player) void cServer::PlayerDestroying(const cPlayer * a_Player) { + UNUSED(a_Player); // To avoid deadlocks, the player count is not handled directly, but rather posted onto the tick thread cCSLock Lock(m_CSPlayerCountDiff); m_PlayerCountDiff -= 1; @@ -514,6 +516,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & a_Output) { + UNUSED(a_Split); typedef std::pair AStringPair; typedef std::vector AStringPairs; @@ -525,6 +528,8 @@ void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & virtual bool Command(const AString & a_Command, const cPlugin * a_Plugin, const AString & a_Permission, const AString & a_HelpString) override { + UNUSED(a_Plugin); + UNUSED(a_Permission); if (!a_HelpString.empty()) { m_Commands.push_back(AStringPair(a_Command, a_HelpString)); From 2e1588820d3c27a82d4bd6401dc9af728130908c Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 14:55:24 +0000 Subject: [PATCH 035/144] fixed warnings in World.cpp --- src/BlockTracer.h | 25 ++++++++++++++++++++++--- src/Simulator/NoopFluidSimulator.h | 10 ++++++++-- src/World.cpp | 4 +++- src/World.h | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/BlockTracer.h b/src/BlockTracer.h index d0a34811..40d80da1 100644 --- a/src/BlockTracer.h +++ b/src/BlockTracer.h @@ -36,7 +36,14 @@ public: /** Called on each block encountered along the path, including the first block (path start), if chunk data is not loaded When this callback returns true, the tracing is aborted. */ - virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) { return false; } + virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_EntryFace); + return false; + } /** Called when the path goes out of world, either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path exited the world. @@ -44,7 +51,13 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by OnIntoWorld() and further OnNextBlock() calls */ - virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } + virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + return false; + } /** Called when the path goes into the world, from either below (a_BlockY < 0) or above (a_BlockY >= cChunkDef::Height) The coords specify the exact point at which the path entered the world. @@ -52,7 +65,13 @@ public: Note that some paths can go out of the world and come back again (parabola), in such a case this callback is followed by further OnNextBlock() calls */ - virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) { return false; } + virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + return false; + } /** Called when the path is sure not to hit any more blocks. Note that for some shapes this might never happen (line with constant Y) diff --git a/src/Simulator/NoopFluidSimulator.h b/src/Simulator/NoopFluidSimulator.h index 8f894433..9113aec3 100644 --- a/src/Simulator/NoopFluidSimulator.h +++ b/src/Simulator/NoopFluidSimulator.h @@ -27,8 +27,14 @@ public: } // cSimulator overrides: - virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override {} - virtual void Simulate(float a_Dt) override {} + virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override + { + UNUSED(a_BlockX); + UNUSED(a_BlockY); + UNUSED(a_BlockZ); + UNUSED(a_Chunk); + } + virtual void Simulate(float a_Dt) override { UNUSED(a_Dt);} } ; diff --git a/src/World.cpp b/src/World.cpp index 28c46c27..cc543d46 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -723,6 +723,7 @@ void cWorld::Tick(float a_Dt, int a_LastTickDurationMSec) void cWorld::TickWeather(float a_Dt) { + UNUSED(a_Dt); // There are no weather changes anywhere but in the Overworld: if (GetDimension() != dimOverworld) { @@ -794,7 +795,7 @@ void cWorld::TickMobs(float a_Dt) cMonster::mfAmbient, cMonster::mfWater, } ; - for (int i = 0; i < ARRAYCOUNT(AllFamilies); i++) + for (size_t i = 0; i < ARRAYCOUNT(AllFamilies); i++) { cMonster::eFamily Family = AllFamilies[i]; int SpawnDelay = cMonster::GetSpawnDelay(Family); @@ -1643,6 +1644,7 @@ int cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff) { + UNUSED(a_InitialVelocityCoeff); cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTimeInSec); TNT->Initialize(this); // TODO: Add a bit of speed in horiz and vert axes, based on the a_InitialVelocityCoeff diff --git a/src/World.h b/src/World.h index c067252d..67f1275c 100644 --- a/src/World.h +++ b/src/World.h @@ -78,6 +78,7 @@ public: class cTask { public: + virtual ~cTask(){}; virtual void Run(cWorld & a_World) = 0; } ; From 3da41de5539337438e6091dd1830505b755124eb Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:01:04 +0000 Subject: [PATCH 036/144] take Z axis into account when calculating neighboors in LightingThread::ChunkReady --- src/LightingThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index d7e60e45..d9c41481 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -189,7 +189,7 @@ void cLightingThread::ChunkReady(int a_ChunkX, int a_ChunkZ) { if ( (itr->x - a_ChunkX >= -1) && (itr->x - a_ChunkX <= 1) && - (itr->x - a_ChunkX >= -1) && (itr->x - a_ChunkX <= 1) + (itr->z - a_ChunkZ >= -1) && (itr->z - a_ChunkZ <= 1) ) { // It is a neighbor From 8e7e990cfe5be08030ff2b7e0323c9bf64b15201 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:04:29 +0000 Subject: [PATCH 037/144] fixed warnings in LightingThread.cpp --- src/LightingThread.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index d9c41481..7c3cc9c7 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -495,6 +495,7 @@ void cLightingThread::CalcLightStep( int & a_NumSeedsOut, unsigned char * a_IsSeedOut, unsigned int * a_SeedIdxOut ) { + UNUSED(a_IsSeedIn); int NumSeedsOut = 0; for (int i = 0; i < a_NumSeedsIn; i++) { From 1957f982bc7be250f52bac2ccc0450e60c965fba Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 15:06:41 +0000 Subject: [PATCH 038/144] fixed warnings in LineBlockTracer.cpp --- src/LineBlockTracer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index 9fcbca91..110c6b5d 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -196,7 +196,6 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) ASSERT((m_CurrentY >= 0) && (m_CurrentY < cChunkDef::Height)); // This should be provided by FixStartAboveWorld() / FixStartBelowWorld() // This is the actual line tracing loop. - bool Finished = false; while (true) { // Report the current block through the callbacks: From c3e34ee81af71c70514d53f4e54e3a6c2ac5a976 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Sun, 22 Dec 2013 17:02:36 +0000 Subject: [PATCH 039/144] removed unneccisary cast --- src/ByteBuffer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ByteBuffer.cpp b/src/ByteBuffer.cpp index 51001800..e06f63a0 100644 --- a/src/ByteBuffer.cpp +++ b/src/ByteBuffer.cpp @@ -781,7 +781,8 @@ bool cByteBuffer::ReadToByteBuffer(cByteBuffer & a_Dst, size_t a_NumBytes) return false; } char buf[1024]; - while (a_NumBytes > static_cast(0)) + // > 0 without generating warnings about unsigned comparisons where size_t is unsigned + while (a_NumBytes != 0) { size_t num = (a_NumBytes > sizeof(buf)) ? sizeof(buf) : a_NumBytes; VERIFY(ReadBuf(buf, num)); From db935c4194b01e754a188473118055fd08e7d450 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 31 Dec 2013 14:50:46 +0100 Subject: [PATCH 040/144] Documented OnPlayerFished and OnPlayerFishing. --- .../Plugins/APIDump/Hooks/OnPlayerFished.lua | 20 ++++++++++++++++++ .../Plugins/APIDump/Hooks/OnPlayerFishing.lua | 21 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua new file mode 100644 index 00000000..03ab5bfb --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua @@ -0,0 +1,20 @@ +return +{ + HOOK_PLAYER_FISHED = + { + CalledWhen = "A player gets a reward from fishing.", + DefaultFnName = "OnPlayerFished", -- also used as pagename + Desc = [[ + This hook gets called when a player already has his reward from fishing. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." }, + { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, tressure and junk." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function returns true, no other + callback is called for this event. + ]], + }, -- HOOK_PLAYER_FISHED +} \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua new file mode 100644 index 00000000..1989b02c --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua @@ -0,0 +1,21 @@ +return +{ + HOOK_PLAYER_FISHING = + { + CalledWhen = "A player is about to get a reward from fishing.", + DefaultFnName = "OnPlayerFishing", -- also used as pagename + Desc = [[ + This hook gets called when a player right clicks with a fishing rod while the floater is under water. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." }, + { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, tressure and junk." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server gives the player his reward. If the function returns true, no other + callback is called for this event and the player doesn't get his reward. + ]], + }, -- HOOK_PLAYER_FISHING +} \ No newline at end of file From 020a8b457d67a70f407482322188823af9ac7f72 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 31 Dec 2013 14:53:10 +0100 Subject: [PATCH 041/144] implemented the recommendations Xoft gave. --- src/Bindings/LuaState.cpp | 12 ++++++++++++ src/Bindings/LuaState.h | 1 + src/Bindings/Plugin.h | 4 ++-- src/Bindings/PluginLua.cpp | 8 ++++---- src/Bindings/PluginLua.h | 4 ++-- src/Bindings/PluginManager.cpp | 4 ++-- src/Bindings/PluginManager.h | 4 ++-- 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 64a818a6..a684620f 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -468,6 +468,18 @@ void cLuaState::Push(cItems * a_Items) +void cLuaState::Push(const cItems & a_Items) +{ + ASSERT(IsValid()); + + tolua_pushusertype(m_LuaState, (void *)&a_Items, "cItems"); + m_NumCurrentFunctionArgs += 1; +} + + + + + void cLuaState::Push(cClientHandle * a_Client) { ASSERT(IsValid()); diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index a6c31b6d..796559b6 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -165,6 +165,7 @@ public: void Push(cMonster * a_Monster); void Push(cItem * a_Item); void Push(cItems * a_Items); + void Push(const cItems & a_Items); void Push(cClientHandle * a_ClientHandle); void Push(cPickup * a_Pickup); void Push(cChunkDesc * a_ChunkDesc); diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 80356304..80d9316e 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -68,8 +68,8 @@ public: virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerEating (cPlayer & a_Player) = 0; - virtual bool OnPlayerFished (cPlayer & a_Player, cItems & a_Reward) = 0; - virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; + virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0; + virtual bool OnPlayerFishing (cPlayer & a_Player, const cItems & a_Reward) = 0; virtual bool OnPlayerJoined (cPlayer & a_Player) = 0; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0; virtual bool OnPlayerMoved (cPlayer & a_Player) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 66a60efe..d8108da5 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -630,14 +630,14 @@ bool cPluginLua::OnPlayerEating(cPlayer & a_Player) -bool cPluginLua::OnPlayerFished(cPlayer & a_Player, cItems & a_Reward) +bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHED]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Player, a_Reward, cLuaState::Return, res); if (res) { return true; @@ -650,14 +650,14 @@ bool cPluginLua::OnPlayerFished(cPlayer & a_Player, cItems & a_Reward) -bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward) +bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, const cItems & a_Reward) { cCSLock Lock(m_CriticalSection); bool res = false; cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLAYER_FISHING]; for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) { - m_LuaState.Call((int)(**itr), &a_Player, &a_Reward, cLuaState::Return, res); + m_LuaState.Call((int)(**itr), &a_Player, a_Reward, cLuaState::Return, res); if (res) { return true; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index d0cb209f..ab15279d 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -64,9 +64,9 @@ public: virtual bool OnPlayerAnimation (cPlayer & a_Player, int a_Animation) override; virtual bool OnPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; - virtual bool OnPlayerFished (cPlayer & a_Player, cItems & a_Reward) override; - virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; virtual bool OnPlayerEating (cPlayer & a_Player) override; + virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override; + virtual bool OnPlayerFishing (cPlayer & a_Player, const cItems & a_Reward) override; virtual bool OnPlayerJoined (cPlayer & a_Player) override; virtual bool OnPlayerMoved (cPlayer & a_Player) override; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index b863a95b..027b8754 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -694,7 +694,7 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player) -bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, cItems a_Reward) +bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED); if (Plugins == m_Hooks.end()) @@ -715,7 +715,7 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, cItems a_Reward) -bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward) +bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, const cItems a_Reward) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING); if (Plugins == m_Hooks.end()) diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index da867c7b..c6a8b8b9 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -170,8 +170,8 @@ public: // tolua_export bool CallHookPlayerBreakingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerEating (cPlayer & a_Player); - bool CallHookPlayerFished (cPlayer & a_Player, cItems a_Reward); - bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); + bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward); + bool CallHookPlayerFishing (cPlayer & a_Player, const cItems a_Reward); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerMoving (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); From f3736b1eb7bf698518cdb853ee29ee96b9c24a52 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Tue, 31 Dec 2013 15:48:57 +0000 Subject: [PATCH 042/144] refactored chunk Queue to seperate class --- src/ChunkDef.h | 1 - src/OSSupport/Event.h | 6 +- src/OSSupport/IsThread.h | 1 - src/OSSupport/Queue.h | 108 ++++++++++++++++++++---- src/OSSupport/Queue.inc | 4 - src/WorldStorage/WorldStorage.cpp | 136 ++++++++++-------------------- src/WorldStorage/WorldStorage.h | 28 ++++-- 7 files changed, 161 insertions(+), 123 deletions(-) delete mode 100644 src/OSSupport/Queue.inc diff --git a/src/ChunkDef.h b/src/ChunkDef.h index bf41aa62..c68ae510 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -14,7 +14,6 @@ - /** This is really only a placeholder to be used in places where we need to "make up" a chunk's Y coord. It will help us when the new chunk format comes out and we need to patch everything up for compatibility. */ diff --git a/src/OSSupport/Event.h b/src/OSSupport/Event.h index 71f418c0..31f32f8c 100644 --- a/src/OSSupport/Event.h +++ b/src/OSSupport/Event.h @@ -20,10 +20,10 @@ class cEvent { public: cEvent(void); - ~cEvent(); + virtual ~cEvent(); - void Wait(void); - void Set (void); + virtual void Wait(void); + virtual void Set (void); private: diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index b8784ea3..af436763 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -22,7 +22,6 @@ In the descending class' constructor call the Start() method to start the thread - class cIsThread { protected: diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 838a101e..eb323b06 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -1,30 +1,104 @@ + #pragma once +#include + +#include "../OSSupport/Promise.h" + +//this empty struct allows function inlining template -class cDeleter +struct cQueueFuncs { public: static void Delete(T) {}; -} + static void Combine(T&, const T) {}; +}; -template +template > class cQueue { + +typedef typename std::list ListType; +//magic typedef to persuade clang that the iterator is a type +typedef typename ListType::iterator iterator; public: - cQueue(int warnsize); - cQueue(cQueue& queue); - ~cQueue(); + cQueue() {} + ~cQueue() {} + + void EnqueueItem(ItemType a_item) + { + cCSLock Lock(m_CS); + m_contents.push_back(a_item); + m_evtAdded.Set(); + } + void EnqueueItemIfNotPresent(ItemType a_item) + { + cCSLock Lock(m_CS); + + for (iterator itr = m_contents.begin(); itr != m_contents.end(); ++itr) + { + if((*itr) == a_item) { + Funcs funcTable; + funcTable.Combine(*itr,a_item); + return; + } + } + m_contents.push_back(a_item); + m_evtAdded.Set(); + } + bool TryDequeueItem(ItemType& item) + { + cCSLock Lock(m_CS); + if (m_contents.size() == 0) return false; + item = m_contents.front(); + m_contents.pop_front(); + return true; + } + ItemType DequeueItem() + { + cCSLock Lock(m_CS); + while (m_contents.size() == 0) + { + cCSUnlock Unlock(m_CS); + m_evtAdded.Wait(); + } + return m_contents.pop_front(); + } + cPromise* BlockTillEmpty() { + return new cEmptyQueuePromise(this); + } + //can all be inlined when delete is a noop + void Clear() + { + cCSLock Lock(m_CS); + Funcs funcTable; + while (!m_contents.empty()) + { + funcTable.Delete(m_contents.front()); + m_contents.pop_front(); + } + } + size_t Size() + { + cCSLock Lock(m_CS); + return m_contents.size(); + } + bool Remove(ItemType item) + { + cCSLock Lock(m_CS); + m_contents.remove(item); + } - void EnqueueItem(T item); - bool TryDequeueItem(T& item); - T DequeueItem(); - void BlockTillEmpty(cEvent CancelationEvent); - void Clear(); - int Size(); - private: - int warnsize; -} + ListType m_contents; + cCriticalSection m_CS; + cEvent m_evtAdded; -//template classes must be implemented in the header -#include "Queue.inc" + class cEmptyQueuePromise : public cPromise { + public: + cEmptyQueuePromise(cQueue* a_Queue) : cPromise(), m_Queue(a_Queue) {} + virtual bool IsCompleted() {return m_Queue->Size() != 0;} + private: + cQueue* m_Queue; + }; +}; diff --git a/src/OSSupport/Queue.inc b/src/OSSupport/Queue.inc deleted file mode 100644 index f172e979..00000000 --- a/src/OSSupport/Queue.inc +++ /dev/null @@ -1,4 +0,0 @@ - -#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules - - diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index f290ec12..c3bfbd4f 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -13,7 +13,7 @@ #include "../Generating/ChunkGenerator.h" #include "../Entities/Entity.h" #include "../BlockEntities/BlockEntity.h" - +#include "../OSSupport/Promise.h" @@ -63,8 +63,6 @@ cWorldStorage::~cWorldStorage() { delete *itr; } // for itr - m_Schemas[] - m_LoadQueue.clear(); - m_SaveQueue.clear(); } @@ -98,9 +96,7 @@ void cWorldStorage::WaitForFinish(void) LOG("Waiting for the world storage to finish saving"); { - // Cancel all loading requests: - cCSLock Lock(m_CSQueues); - m_LoadQueue.clear(); + m_LoadQueue.Clear(); } // Wait for the saving to finish: @@ -120,32 +116,36 @@ void cWorldStorage::WaitForFinish(void) void cWorldStorage::WaitForQueuesEmpty(void) { - cCSLock Lock(m_CSQueues); - while (!m_ShouldTerminate && (!m_LoadQueue.empty() || !m_SaveQueue.empty())) - { - cCSUnlock Unlock(Lock); - m_evtRemoved.Wait(); - } + + cPromise * LoadPromise = m_LoadQueue.BlockTillEmpty(); + cPromise * SavePromise = m_SaveQueue.BlockTillEmpty(); + cPromise * QueuePromise = LoadPromise->WaitFor(SavePromise); + cPromise * CancelPromise = QueuePromise->CancelOn(m_ShouldTerminate); + CancelPromise->Wait(); + delete CancelPromise; + delete QueuePromise; + delete SavePromise; + delete LoadPromise; } -int cWorldStorage::GetLoadQueueLength(void) +size_t cWorldStorage::GetLoadQueueLength(void) { cCSLock Lock(m_CSQueues); - return (int)m_LoadQueue.size(); + return m_LoadQueue.Size(); } -int cWorldStorage::GetSaveQueueLength(void) +size_t cWorldStorage::GetSaveQueueLength(void) { cCSLock Lock(m_CSQueues); - return (int)m_SaveQueue.size(); + return m_SaveQueue.Size(); } @@ -154,22 +154,7 @@ int cWorldStorage::GetSaveQueueLength(void) void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) { - // Queues the chunk for loading; if not loaded, the chunk will be generated - { - cCSLock Lock(m_CSQueues); - - // Check if already in the queue: - for (sChunkLoadQueue::iterator itr = m_LoadQueue.begin(); itr != m_LoadQueue.end(); ++itr) - { - if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkY == a_ChunkY) && (itr->m_ChunkZ == a_ChunkZ) && (itr->m_Generate == a_Generate)) - { - return; - } - } - m_LoadQueue.push_back(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, a_Generate)); - } - - m_Event.Set(); + m_LoadQueue.EnqueueItemIfNotPresent(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, a_Generate)); } @@ -178,12 +163,7 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, boo void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - { - cCSLock Lock(m_CSQueues); - m_SaveQueue.remove (cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); // Don't add twice - m_SaveQueue.push_back(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); - } - m_Event.Set(); + m_SaveQueue.EnqueueItemIfNotPresent(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); } @@ -192,12 +172,8 @@ void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) void cWorldStorage::QueueSavedMessage(void) { - // Pushes a special coord pair into the queue, signalizing a message instead: - { - cCSLock Lock(m_CSQueues); - m_SaveQueue.push_back(cChunkCoords(0, CHUNK_Y_MESSAGE, 0)); - } - m_Event.Set(); + // Pushes a special coord pair into the queue, signalizing a message instead + m_SaveQueue.EnqueueItem(cChunkCoords(0, CHUNK_Y_MESSAGE, 0)); } @@ -206,7 +182,7 @@ void cWorldStorage::QueueSavedMessage(void) void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - cCSLock Lock(m_CSQueues); + /*cCSLock Lock(m_CSQueues); for (sChunkLoadQueue::iterator itr = m_LoadQueue.begin(); itr != m_LoadQueue.end(); ++itr) { if ((itr->m_ChunkX != a_ChunkX) || (itr->m_ChunkY != a_ChunkY) || (itr->m_ChunkZ != a_ChunkZ)) @@ -217,7 +193,8 @@ void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) Lock.Unlock(); m_evtRemoved.Set(); return; - } // for itr - m_LoadQueue[] + } // for itr - m_LoadQueue[]*/ + m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); } @@ -226,11 +203,7 @@ void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) void cWorldStorage::UnqueueSave(const cChunkCoords & a_Chunk) { - { - cCSLock Lock(m_CSQueues); - m_SaveQueue.remove(a_Chunk); - } - m_evtRemoved.Set(); + m_SaveQueue.Remove(a_Chunk); } @@ -281,19 +254,19 @@ void cWorldStorage::Execute(void) m_Event.Wait(); // Process both queues until they are empty again: - bool HasMore; + bool Success; do { - HasMore = false; + Success = false; if (m_ShouldTerminate) { return; } - HasMore = LoadOneChunk(); - HasMore = HasMore | SaveOneChunk(); + Success = LoadOneChunk(); + Success |= SaveOneChunk(); m_evtRemoved.Set(); - } while (HasMore); + } while (Success); } } @@ -304,19 +277,7 @@ void cWorldStorage::Execute(void) bool cWorldStorage::LoadOneChunk(void) { sChunkLoad ToLoad(0, 0, 0, false); - bool HasMore; - bool ShouldLoad = false; - { - cCSLock Lock(m_CSQueues); - if (!m_LoadQueue.empty()) - { - ToLoad = m_LoadQueue.front(); - m_LoadQueue.pop_front(); - ShouldLoad = true; - } - HasMore = !m_LoadQueue.empty(); - } - + bool ShouldLoad = m_LoadQueue.TryDequeueItem(ToLoad); if (ShouldLoad && !LoadChunk(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ)) { if (ToLoad.m_Generate) @@ -330,7 +291,7 @@ bool cWorldStorage::LoadOneChunk(void) // m_World->ChunkLoadFailed(ToLoad.m_ChunkX, ToLoad.m_ChunkY, ToLoad.m_ChunkZ); } } - return HasMore; + return ShouldLoad; } @@ -339,33 +300,24 @@ bool cWorldStorage::LoadOneChunk(void) bool cWorldStorage::SaveOneChunk(void) { - cChunkCoords Save(0, 0, 0); - bool HasMore; - bool ShouldSave = false; - { - cCSLock Lock(m_CSQueues); - if (!m_SaveQueue.empty()) + cChunkCoords ToSave(0, 0, 0); + bool ShouldSave = m_SaveQueue.TryDequeueItem(ToSave); + if(ShouldSave) { + if (ToSave.m_ChunkY == CHUNK_Y_MESSAGE) { - Save = m_SaveQueue.front(); - m_SaveQueue.pop_front(); - ShouldSave = true; + LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str()); + return ShouldSave; } - HasMore = !m_SaveQueue.empty(); - } - if (Save.m_ChunkY == CHUNK_Y_MESSAGE) - { - LOGINFO("Saved all chunks in world %s", m_World->GetName().c_str()); - return HasMore; - } - if (ShouldSave && m_World->IsChunkValid(Save.m_ChunkX, Save.m_ChunkZ)) - { - m_World->MarkChunkSaving(Save.m_ChunkX, Save.m_ChunkZ); - if (m_SaveSchema->SaveChunk(Save)) + if (ShouldSave && m_World->IsChunkValid(ToSave.m_ChunkX, ToSave.m_ChunkZ)) { - m_World->MarkChunkSaved(Save.m_ChunkX, Save.m_ChunkZ); + m_World->MarkChunkSaving(ToSave.m_ChunkX, ToSave.m_ChunkZ); + if (m_SaveSchema->SaveChunk(ToSave)) + { + m_World->MarkChunkSaved(ToSave.m_ChunkX, ToSave.m_ChunkZ); + } } } - return HasMore; + return ShouldSave; } diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 007d3757..c3eb96ce 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -16,6 +16,7 @@ #include "../ChunkDef.h" #include "../OSSupport/IsThread.h" +#include "../OSSupport/Queue.h" @@ -24,6 +25,8 @@ // fwd: class cWorld; +typedef cQueue cChunkCoordsQueue; + @@ -78,8 +81,8 @@ public: void WaitForFinish(void); void WaitForQueuesEmpty(void); - int GetLoadQueueLength(void); - int GetSaveQueueLength(void); + size_t GetLoadQueueLength(void); + size_t GetSaveQueueLength(void); protected: @@ -91,9 +94,24 @@ protected: bool m_Generate; // If true, the chunk will be generated if it cannot be loaded sChunkLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) : m_ChunkX(a_ChunkX), m_ChunkY(a_ChunkY), m_ChunkZ(a_ChunkZ), m_Generate(a_Generate) {} + + bool operator==(const sChunkLoad other) const + { + return this->m_ChunkX == other.m_ChunkX && + this->m_ChunkY == other.m_ChunkY && + this->m_ChunkZ == other.m_ChunkZ; + } } ; - - typedef std::list sChunkLoadQueue; + + struct FuncTable { + static void Delete(sChunkLoad) {}; + static void Combine(sChunkLoad& a_orig, const sChunkLoad a_new) + { + a_orig.m_Generate |= a_new.m_Generate; + }; + }; + + typedef cQueue sChunkLoadQueue; cWorld * m_World; AString m_StorageSchemaName; @@ -101,7 +119,7 @@ protected: // Both queues are locked by the same CS cCriticalSection m_CSQueues; sChunkLoadQueue m_LoadQueue; - cChunkCoordsList m_SaveQueue; + cChunkCoordsQueue m_SaveQueue; cEvent m_Event; // Set when there's any addition to the queues cEvent m_evtRemoved; // Set when an item has been removed from the queue, either by the worker thread or the Unqueue methods From 512d1b9ebebaf205756dde352c4e714dd632ca2d Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Tue, 31 Dec 2013 15:58:21 +0000 Subject: [PATCH 043/144] clean up code for patching --- src/ChunkDef.h | 1 + src/OSSupport/Event.h | 6 +++--- src/OSSupport/IsThread.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 8919bcbb..7d727a4d 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -14,6 +14,7 @@ + /** This is really only a placeholder to be used in places where we need to "make up" a chunk's Y coord. It will help us when the new chunk format comes out and we need to patch everything up for compatibility. */ diff --git a/src/OSSupport/Event.h b/src/OSSupport/Event.h index 31f32f8c..71f418c0 100644 --- a/src/OSSupport/Event.h +++ b/src/OSSupport/Event.h @@ -20,10 +20,10 @@ class cEvent { public: cEvent(void); - virtual ~cEvent(); + ~cEvent(); - virtual void Wait(void); - virtual void Set (void); + void Wait(void); + void Set (void); private: diff --git a/src/OSSupport/IsThread.h b/src/OSSupport/IsThread.h index af436763..b8784ea3 100644 --- a/src/OSSupport/IsThread.h +++ b/src/OSSupport/IsThread.h @@ -22,6 +22,7 @@ In the descending class' constructor call the Start() method to start the thread + class cIsThread { protected: From 098ed91a48df9fef58590b22fe34225ed1f44cfa Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Tue, 31 Dec 2013 16:13:13 +0000 Subject: [PATCH 044/144] fogot to add promise classes --- src/OSSupport/Promise.cpp | 54 +++++++++++++++++++++++++++++++++++++++ src/OSSupport/Promise.h | 38 +++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/OSSupport/Promise.cpp create mode 100644 src/OSSupport/Promise.h diff --git a/src/OSSupport/Promise.cpp b/src/OSSupport/Promise.cpp new file mode 100644 index 00000000..b3186933 --- /dev/null +++ b/src/OSSupport/Promise.cpp @@ -0,0 +1,54 @@ + +#include "Globals.h" + +#include "Promise.h" + +cPromise * cPromise::WaitFor(cPromise * a_Promise) +{ + return new cCombinedPromise(this, a_Promise); +} + +cPromise * cPromise::CancelOn(volatile bool& cancelation) +{ + return new cCancelablePromise(this, cancelation); +} + +void cPromise::Wait() +{ + while(!IsCompleted()){}; //busywait best we can do until waitany +} + + +cCombinedPromise::cCombinedPromise(cPromise* a_left, cPromise* a_right) : + cPromise(), + m_left(a_left), + m_right(a_right) +{ +} + +cCombinedPromise::~cCombinedPromise() +{ +} + +bool cCombinedPromise::IsCompleted() +{ + return m_left->IsCompleted() || m_right->IsCompleted(); +} + +cCancelablePromise::cCancelablePromise(cPromise* a_wrapped, volatile bool& a_cancel) : + cPromise(), + m_cancel(a_cancel), + m_wrapped(a_wrapped) +{ +} + +cCancelablePromise::~cCancelablePromise () +{ +} + +bool cCancelablePromise::IsCompleted() +{ + return m_cancel || m_wrapped->IsCompleted(); +} + + diff --git a/src/OSSupport/Promise.h b/src/OSSupport/Promise.h new file mode 100644 index 00000000..83d04860 --- /dev/null +++ b/src/OSSupport/Promise.h @@ -0,0 +1,38 @@ +#pragma once + +class cCombinedPromise; + + +class cPromise { + public: + cPromise() {} + virtual ~cPromise () {} + cPromise * WaitFor(cPromise * a_Promise); + cPromise * CancelOn(volatile bool& cancelationtoken); + void Wait(); + virtual bool IsCompleted() = 0; + //TODO:Expose Events for waiting on +}; + +class cCombinedPromise : public cPromise { +public: + cCombinedPromise(cPromise*, cPromise*); + ~cCombinedPromise(); + virtual bool IsCompleted(); +private: + cPromise* m_left; + cPromise* m_right; +}; + +class cCancelablePromise : public cPromise { +public: + cCancelablePromise(cPromise*, volatile bool&); + ~cCancelablePromise(); + virtual bool IsCompleted(); +private: + volatile bool& m_cancel; + cPromise* m_wrapped; +}; + + + From 852c52bee9ffcc7857ea5d112fef8a4254c57253 Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 1 Jan 2014 11:18:56 +0200 Subject: [PATCH 045/144] Fixed GetPhysicalRAMUsage on Linux --- src/Root.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Root.cpp b/src/Root.cpp index 16a52169..fa1fdb37 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -701,9 +701,9 @@ int cRoot::GetPhysicalRAMUsage(void) { AString Line; std::getline(StatFile, Line); - if (strncmp(Line.c_str(), "VmRSS:", 7) == 0) + if (strncmp(Line.c_str(), "VmRSS:", 6) == 0) { - int res = atoi(Line.c_str() + 8); + int res = atoi(Line.c_str() + 7); return (res == 0) ? -1 : res; // If parsing failed, return -1 } } From c5b89ea0f5561ff1569d7b9638252cf3a0d9626c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 1 Jan 2014 15:02:43 +0100 Subject: [PATCH 046/144] Fixed typo's in the documentation. --- MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua | 4 ++-- MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua index 03ab5bfb..0ad2a3af 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua @@ -10,11 +10,11 @@ return Params = { { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." }, - { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, tressure and junk." }, + { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, treasure and junk." }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. If the function returns true, no other callback is called for this event. ]], }, -- HOOK_PLAYER_FISHED -} \ No newline at end of file +}; \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua index 1989b02c..14851c08 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua @@ -10,7 +10,7 @@ return Params = { { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who pulled the fish in." }, - { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, tressure and junk." }, + { Name = "Reward", Type = "{{cItems}}", Notes = "The reward the player gets. It can be a fish, treasure and junk." }, }, Returns = [[ If the function returns false or no value, the next plugin's callback is called. Afterwards, the @@ -18,4 +18,4 @@ return callback is called for this event and the player doesn't get his reward. ]], }, -- HOOK_PLAYER_FISHING -} \ No newline at end of file +}; \ No newline at end of file From db00a36ff8d8f96c9554f29656196ecd4e08c6a9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 1 Jan 2014 15:09:53 +0100 Subject: [PATCH 047/144] OnPlayerFishing doesn't have a const cItems anymore --- src/Bindings/Plugin.h | 2 +- src/Bindings/PluginLua.cpp | 2 +- src/Bindings/PluginLua.h | 2 +- src/Bindings/PluginManager.cpp | 2 +- src/Bindings/PluginManager.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 80d9316e..2c893a65 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -69,7 +69,7 @@ public: virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerEating (cPlayer & a_Player) = 0; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) = 0; - virtual bool OnPlayerFishing (cPlayer & a_Player, const cItems & a_Reward) = 0; + virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) = 0; virtual bool OnPlayerJoined (cPlayer & a_Player) = 0; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) = 0; virtual bool OnPlayerMoved (cPlayer & a_Player) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index d8108da5..87212ed8 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -650,7 +650,7 @@ bool cPluginLua::OnPlayerFished(cPlayer & a_Player, const cItems & a_Reward) -bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, const cItems & a_Reward) +bool cPluginLua::OnPlayerFishing(cPlayer & a_Player, cItems & a_Reward) { cCSLock Lock(m_CriticalSection); bool res = false; diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index ab15279d..a47ab32e 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -66,7 +66,7 @@ public: virtual bool OnPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerEating (cPlayer & a_Player) override; virtual bool OnPlayerFished (cPlayer & a_Player, const cItems & a_Reward) override; - virtual bool OnPlayerFishing (cPlayer & a_Player, const cItems & a_Reward) override; + virtual bool OnPlayerFishing (cPlayer & a_Player, cItems & a_Reward) override; virtual bool OnPlayerJoined (cPlayer & a_Player) override; virtual bool OnPlayerMoved (cPlayer & a_Player) override; virtual bool OnPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 027b8754..3a6c542b 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -715,7 +715,7 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Rew -bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, const cItems a_Reward) +bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING); if (Plugins == m_Hooks.end()) diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index c6a8b8b9..16c64d86 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -171,7 +171,7 @@ public: // tolua_export bool CallHookPlayerBrokenBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerEating (cPlayer & a_Player); bool CallHookPlayerFished (cPlayer & a_Player, const cItems a_Reward); - bool CallHookPlayerFishing (cPlayer & a_Player, const cItems a_Reward); + bool CallHookPlayerFishing (cPlayer & a_Player, cItems a_Reward); bool CallHookPlayerJoined (cPlayer & a_Player); bool CallHookPlayerMoving (cPlayer & a_Player); bool CallHookPlayerLeftClick (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status); From 78a876ace321648db85a9373cca2a4f03ef09873 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 1 Jan 2014 15:15:56 +0100 Subject: [PATCH 048/144] Using documentation Xoft recommended. --- MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua index 0ad2a3af..40dd6b3c 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFished.lua @@ -5,7 +5,7 @@ return CalledWhen = "A player gets a reward from fishing.", DefaultFnName = "OnPlayerFished", -- also used as pagename Desc = [[ - This hook gets called when a player already has his reward from fishing. + This hook gets called after a player reels in the fishing rod. This is a notification-only hook, the reward has already been decided. If a plugin needs to modify the reward, use the {{OnPlayerFishing|HOOK_PLAYER_FISHING}} hook. ]], Params = { From d656c253c0ead77218a8236e72b678b07316bd2c Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 1 Jan 2014 15:18:12 +0100 Subject: [PATCH 049/144] Little more documentation for OnPlayerFishing. --- MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua index 14851c08..3b473109 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerFishing.lua @@ -5,7 +5,7 @@ return CalledWhen = "A player is about to get a reward from fishing.", DefaultFnName = "OnPlayerFishing", -- also used as pagename Desc = [[ - This hook gets called when a player right clicks with a fishing rod while the floater is under water. + This hook gets called when a player right clicks with a fishing rod while the floater is under water. The reward is already descided, but the plugin may change it. ]], Params = { From 042b72bc172e7eb4e9ef7668ae28be6e7a3b4036 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Thu, 2 Jan 2014 12:32:55 +0000 Subject: [PATCH 050/144] rewrote queue not to use promises for waits --- src/OSSupport/Promise.cpp | 54 ------------------------------- src/OSSupport/Promise.h | 38 ---------------------- src/OSSupport/Queue.h | 24 +++++++------- src/World.cpp | 5 ++- src/WorldStorage/WorldStorage.cpp | 21 ++++-------- src/WorldStorage/WorldStorage.h | 3 +- 6 files changed, 24 insertions(+), 121 deletions(-) delete mode 100644 src/OSSupport/Promise.cpp delete mode 100644 src/OSSupport/Promise.h diff --git a/src/OSSupport/Promise.cpp b/src/OSSupport/Promise.cpp deleted file mode 100644 index b3186933..00000000 --- a/src/OSSupport/Promise.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -#include "Globals.h" - -#include "Promise.h" - -cPromise * cPromise::WaitFor(cPromise * a_Promise) -{ - return new cCombinedPromise(this, a_Promise); -} - -cPromise * cPromise::CancelOn(volatile bool& cancelation) -{ - return new cCancelablePromise(this, cancelation); -} - -void cPromise::Wait() -{ - while(!IsCompleted()){}; //busywait best we can do until waitany -} - - -cCombinedPromise::cCombinedPromise(cPromise* a_left, cPromise* a_right) : - cPromise(), - m_left(a_left), - m_right(a_right) -{ -} - -cCombinedPromise::~cCombinedPromise() -{ -} - -bool cCombinedPromise::IsCompleted() -{ - return m_left->IsCompleted() || m_right->IsCompleted(); -} - -cCancelablePromise::cCancelablePromise(cPromise* a_wrapped, volatile bool& a_cancel) : - cPromise(), - m_cancel(a_cancel), - m_wrapped(a_wrapped) -{ -} - -cCancelablePromise::~cCancelablePromise () -{ -} - -bool cCancelablePromise::IsCompleted() -{ - return m_cancel || m_wrapped->IsCompleted(); -} - - diff --git a/src/OSSupport/Promise.h b/src/OSSupport/Promise.h deleted file mode 100644 index 83d04860..00000000 --- a/src/OSSupport/Promise.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once - -class cCombinedPromise; - - -class cPromise { - public: - cPromise() {} - virtual ~cPromise () {} - cPromise * WaitFor(cPromise * a_Promise); - cPromise * CancelOn(volatile bool& cancelationtoken); - void Wait(); - virtual bool IsCompleted() = 0; - //TODO:Expose Events for waiting on -}; - -class cCombinedPromise : public cPromise { -public: - cCombinedPromise(cPromise*, cPromise*); - ~cCombinedPromise(); - virtual bool IsCompleted(); -private: - cPromise* m_left; - cPromise* m_right; -}; - -class cCancelablePromise : public cPromise { -public: - cCancelablePromise(cPromise*, volatile bool&); - ~cCancelablePromise(); - virtual bool IsCompleted(); -private: - volatile bool& m_cancel; - cPromise* m_wrapped; -}; - - - diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index eb323b06..153e201c 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -3,8 +3,6 @@ #include -#include "../OSSupport/Promise.h" - //this empty struct allows function inlining template struct cQueueFuncs @@ -52,6 +50,7 @@ public: if (m_contents.size() == 0) return false; item = m_contents.front(); m_contents.pop_front(); + m_evtRemoved.Set(); return true; } ItemType DequeueItem() @@ -62,10 +61,15 @@ public: cCSUnlock Unlock(m_CS); m_evtAdded.Wait(); } - return m_contents.pop_front(); + ItemType item = m_contents.front(); + m_contents.pop_front(); + m_evtRemoved.Set(); + return item; } - cPromise* BlockTillEmpty() { - return new cEmptyQueuePromise(this); + void BlockTillEmpty() { + //There is a very slight race condition here if the load completes between the check + //and the wait. + while(!(Size() == 0)){m_evtRemoved.Wait();} } //can all be inlined when delete is a noop void Clear() @@ -87,18 +91,12 @@ public: { cCSLock Lock(m_CS); m_contents.remove(item); + m_evtRemoved.Set(); } private: ListType m_contents; cCriticalSection m_CS; cEvent m_evtAdded; - - class cEmptyQueuePromise : public cPromise { - public: - cEmptyQueuePromise(cQueue* a_Queue) : cPromise(), m_Queue(a_Queue) {} - virtual bool IsCompleted() {return m_Queue->Size() != 0;} - private: - cQueue* m_Queue; - }; + cEvent m_evtRemoved; }; diff --git a/src/World.cpp b/src/World.cpp index cc543d46..39300d41 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -367,10 +367,13 @@ void cWorld::InitializeSpawn(void) cWorldLoadProgress Progress(this); // Wait for the loader to finish loading - m_Storage.WaitForQueuesEmpty(); + m_Storage.WaitForLoadQueueEmpty(); // Wait for the generator to finish generating m_Generator.WaitForQueueEmpty(); + + // Wait for the loader to finish saving + m_Storage.WaitForSaveQueueEmpty(); Progress.Stop(); } diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index c3bfbd4f..9ad995c8 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -13,7 +13,6 @@ #include "../Generating/ChunkGenerator.h" #include "../Entities/Entity.h" #include "../BlockEntities/BlockEntity.h" -#include "../OSSupport/Promise.h" @@ -100,7 +99,7 @@ void cWorldStorage::WaitForFinish(void) } // Wait for the saving to finish: - WaitForQueuesEmpty(); + WaitForSaveQueueEmpty(); // Wait for the thread to finish: m_ShouldTerminate = true; @@ -114,21 +113,15 @@ void cWorldStorage::WaitForFinish(void) -void cWorldStorage::WaitForQueuesEmpty(void) +void cWorldStorage::WaitForLoadQueueEmpty(void) { - - cPromise * LoadPromise = m_LoadQueue.BlockTillEmpty(); - cPromise * SavePromise = m_SaveQueue.BlockTillEmpty(); - cPromise * QueuePromise = LoadPromise->WaitFor(SavePromise); - cPromise * CancelPromise = QueuePromise->CancelOn(m_ShouldTerminate); - CancelPromise->Wait(); - delete CancelPromise; - delete QueuePromise; - delete SavePromise; - delete LoadPromise; + m_LoadQueue.BlockTillEmpty(); } - +void cWorldStorage::WaitForSaveQueueEmpty(void) +{ + m_SaveQueue.BlockTillEmpty(); +} diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index c3eb96ce..98eb5fce 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -79,7 +79,8 @@ public: bool Start(cWorld * a_World, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args void Stop(void); // Hide the cIsThread's Stop() method, we need to signal the event void WaitForFinish(void); - void WaitForQueuesEmpty(void); + void WaitForLoadQueueEmpty(void); + void WaitForSaveQueueEmpty(void); size_t GetLoadQueueLength(void); size_t GetSaveQueueLength(void); From c510683d2a64e75a667134ef0b63e9638c474c28 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 2 Jan 2014 17:33:18 +0100 Subject: [PATCH 051/144] Fixed unaligned memory access in FastNBT. This should fix #420. --- src/StringUtils.cpp | 30 ++++++++++++++++++++++++++++++ src/StringUtils.h | 9 +++++++++ src/WorldStorage/FastNBT.cpp | 10 +++++----- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index f7aeeed2..5c6b99d8 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -764,3 +764,33 @@ AString Base64Decode(const AString & a_Base64String) + +short GetBEShort(const char * a_Mem) +{ + return (((short)a_Mem[0]) << 8) | a_Mem[1]; +} + + + + + +int GetBEInt(const char * a_Mem) +{ + return (((int)a_Mem[0]) << 24) | (((int)a_Mem[1]) << 16) | (((int)a_Mem[2]) << 8) | a_Mem[3]; +} + + + + + +void SetBEInt(char * a_Mem, Int32 a_Value) +{ + a_Mem[0] = a_Value >> 24; + a_Mem[1] = (a_Value >> 16) & 0xff; + a_Mem[2] = (a_Value >> 8) & 0xff; + a_Mem[3] = a_Value & 0xff; +} + + + + diff --git a/src/StringUtils.h b/src/StringUtils.h index 3917cc4e..471e843e 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -81,6 +81,15 @@ extern AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, /// Decodes a Base64-encoded string into the raw data extern AString Base64Decode(const AString & a_Base64String); +/// Reads two bytes from the specified memory location and interprets them as BigEndian short +extern short GetBEShort(const char * a_Mem); + +/// Reads four bytes from the specified memory location and interprets them as BigEndian int +extern int GetBEInt(const char * a_Mem); + +/// Writes four bytes to the specified memory location so that they interpret as BigEndian int +extern void SetBEInt(char * a_Mem, Int32 a_Value); + // If you have any other string helper functions, declare them here diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index e5501106..64220f09 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -80,7 +80,7 @@ bool cParsedNBT::ReadString(int & a_StringStart, int & a_StringLen) { NEEDBYTES(2); a_StringStart = m_Pos + 2; - a_StringLen = ntohs(*((short *)(m_Data + m_Pos))); + a_StringLen = GetBEShort(m_Data + m_Pos); if (a_StringLen < 0) { // Invalid string length @@ -135,7 +135,7 @@ bool cParsedNBT::ReadList(eTagType a_ChildrenType) // Read the count: NEEDBYTES(4); - int Count = ntohl(*((int *)(m_Data + m_Pos))); + int Count = GetBEInt(m_Data + m_Pos); m_Pos += 4; if (Count < 0) { @@ -197,7 +197,7 @@ bool cParsedNBT::ReadTag(void) case TAG_ByteArray: { NEEDBYTES(4); - int len = ntohl(*((int *)(m_Data + m_Pos))); + int len = GetBEInt(m_Data + m_Pos); m_Pos += 4; if (len < 0) { @@ -229,7 +229,7 @@ bool cParsedNBT::ReadTag(void) case TAG_IntArray: { NEEDBYTES(4); - int len = ntohl(*((int *)(m_Data + m_Pos))); + int len = GetBEInt(m_Data + m_Pos); m_Pos += 4; if (len < 0) { @@ -401,7 +401,7 @@ void cFastNBTWriter::EndList(void) ASSERT(m_Stack[m_CurrentStack].m_Type == TAG_List); // Update the list count: - *((int *)(m_Result.c_str() + m_Stack[m_CurrentStack].m_Pos)) = htonl(m_Stack[m_CurrentStack].m_Count); + SetBEInt((char *)(m_Result.c_str() + m_Stack[m_CurrentStack].m_Pos), m_Stack[m_CurrentStack].m_Count); --m_CurrentStack; } From 15dddc77013f5366b77a73ca02f58680eaef9736 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 2 Jan 2014 18:08:38 +0100 Subject: [PATCH 052/144] More memory alignment fixes. Ref.: #420. --- src/Protocol/Protocol132.cpp | 6 +++--- src/WorldStorage/FastNBT.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 346607b7..46ac4ef8 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -886,15 +886,15 @@ void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const A time_t CurTime = time(NULL); CryptoPP::RandomPool rng; rng.Put((const byte *)&CurTime, sizeof(CurTime)); - byte DecryptedNonce[MAX_ENC_LEN]; - DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), DecryptedNonce); + Int32 DecryptedNonce[MAX_ENC_LEN / sizeof(Int32)]; + DecodingResult res = rsaDecryptor.Decrypt(rng, (const byte *)a_EncNonce.data(), a_EncNonce.size(), (byte *)DecryptedNonce); if (!res.isValidCoding || (res.messageLength != 4)) { LOGD("Bad nonce length"); m_Client->Kick("Hacked client"); return; } - if (ntohl(*((int *)DecryptedNonce)) != (unsigned)(uintptr_t)this) + if (ntohl(DecryptedNonce[0]) != (unsigned)(uintptr_t)this) { LOGD("Bad nonce value"); m_Client->Kick("Hacked client"); diff --git a/src/WorldStorage/FastNBT.h b/src/WorldStorage/FastNBT.h index 7323c29c..b84eda1a 100644 --- a/src/WorldStorage/FastNBT.h +++ b/src/WorldStorage/FastNBT.h @@ -154,13 +154,13 @@ public: inline Int16 GetShort(int a_Tag) const { ASSERT(m_Tags[a_Tag].m_Type == TAG_Short); - return ntohs(*((Int16 *)(m_Data + m_Tags[a_Tag].m_DataStart))); + return GetBEShort(m_Data + m_Tags[a_Tag].m_DataStart); } inline Int32 GetInt(int a_Tag) const { ASSERT(m_Tags[a_Tag].m_Type == TAG_Int); - return ntohl(*((Int32 *)(m_Data + m_Tags[a_Tag].m_DataStart))); + return GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart); } inline Int64 GetLong(int a_Tag) const @@ -172,7 +172,7 @@ public: inline float GetFloat(int a_Tag) const { ASSERT(m_Tags[a_Tag].m_Type == TAG_Float); - Int32 tmp = ntohl(*((Int32 *)(m_Data + m_Tags[a_Tag].m_DataStart))); + Int32 tmp = GetBEInt(m_Data + m_Tags[a_Tag].m_DataStart); return *((float *)&tmp); } From 7076f8e73a1e4fed8388d0604756c4c91cafb416 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Thu, 2 Jan 2014 17:11:40 +0000 Subject: [PATCH 053/144] fixed compiler warnings not being enabled in clang --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67f70142..45185407 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,11 +112,15 @@ add_subdirectory(lib/expat/) add_subdirectory(lib/luaexpat/) add_subdirectory(lib/md5/) -# Re-add the maximum warning level: +# Remove disabling the maximum warning level: +# clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings # We do not do that for MSVC since MSVC produces an awful lot of warnings for its own STL headers; # the important warnings will be turned on using #pragma in Globals.h if (NOT MSVC) - add_flags("-Wall -Wextra") + string(REPLACE "-w" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") + string(REPLACE "-w" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") + string(REPLACE "-w" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") endif() add_subdirectory (src) From 0c095faac855806f96d307cd7fa46120034523e9 Mon Sep 17 00:00:00 2001 From: Tau Date: Thu, 2 Jan 2014 19:25:26 +0200 Subject: [PATCH 054/144] [Handy] updated for new API, fixed bugs, added warnings. Now v2. --- MCServer/Plugins/Handy/handy.lua | 2 +- MCServer/Plugins/Handy/handy_functions.lua | 427 +++++++-------------- 2 files changed, 145 insertions(+), 284 deletions(-) diff --git a/MCServer/Plugins/Handy/handy.lua b/MCServer/Plugins/Handy/handy.lua index 6d226cca..e4e9d3f5 100644 --- a/MCServer/Plugins/Handy/handy.lua +++ b/MCServer/Plugins/Handy/handy.lua @@ -1,7 +1,7 @@ -- Global variables PLUGIN = {} -- Reference to own plugin object CHEST_WIDTH = 9 -HANDY_VERSION = 1 +HANDY_VERSION = 2 --[[ Handy is a plugin for other plugins. It contain no commands, no hooks, but functions to ease plugins developers' life. diff --git a/MCServer/Plugins/Handy/handy_functions.lua b/MCServer/Plugins/Handy/handy_functions.lua index a76980c6..c142ffd0 100644 --- a/MCServer/Plugins/Handy/handy_functions.lua +++ b/MCServer/Plugins/Handy/handy_functions.lua @@ -6,350 +6,211 @@ function GetHandyVersion() return HANDY_VERSION end -- Checks if handy is in proper version -function CheckForRequiedVersion(IN_version) - if (IN_version > HANDY_VERSION) then return false end +function CheckForRequiedVersion( inVersion ) + if( inVersion > HANDY_VERSION ) then return false end return true end --[[ MCS-specific _functions and nasty hacks :D ]] --- There's a "GetChestHeight" function inside source code, but it's not lua-exported -function GetChestHeightCheat(IN_chest) - if (IN_chest:GetSlot(28) == nil) then -- this means we're trying to get double chest slot and FAIL - LOGWARN("HANDY: single chest checked") - return 3 - end - LOGWARN("HANDY: double chest checked") - return 6 +function GetChestHeightCheat( inChest ) + local chestGrid = inChest:GetContents() + LOGINFO( "This function serves no purpose now! You should consider chest:GetContents():GetHeight() now!" ) + LOGINFO( "Also, you might find Handy's new 'IsChestDouble()' useful for your case" ) + return chestGrid:GetHeight() end --- Those two checks how many items of given IN_itemID chest and player have, and how much they could fit inside them -function ReadChestForItem(IN_chest, IN_itemID) - local _items_found = 0 - local _free_space = 0 - -- stalk through chest slots... - local _slot_counter = 0 - local _slot_item - local _item_max_stack = GetItemMaxStack(IN_itemID) - while true do - _slot_item = IN_chest:GetSlot(_slot_counter) - if (_slot_item ~= nil) then - if (_slot_item.m_ItemID == IN_itemID) then - _items_found = _items_found + _slot_item.m_ItemCount - _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount) - end - if (_slot_item:IsEmpty() == true) then - _free_space = _free_space + _item_max_stack - end - end - _slot_counter = _slot_counter + 1 - if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then - break - end +function IsChestDouble( inChest ) + local chestHeight = inChest:GetContents():GetHeight() + if( chestHeight == 3 ) then + return false end - return _items_found, _free_space + return true end -function ReadPlayerForItem(IN_player, IN_itemID) - local _items_found = 0 - local _free_space = 0 - -- stalk through IN_player inventory slots... - local _slot_counter = 9 - if (ItemIsArmor(IN_itemID) == true) then _slot_counter = 5 end - local _slot_item - local _item_max_stack = GetItemMaxStack(IN_itemID) - while true do - _slot_item = IN_player:GetInventory():GetSlot(_slot_counter) - if (_slot_item ~= nil) then - if (_slot_item.m_ItemID == IN_itemID) then - _items_found = _items_found + _slot_item.m_ItemCount - _free_space = _free_space + (_item_max_stack - _slot_item.m_ItemCount) - end - if (_slot_item:IsEmpty() == true) then - _free_space = _free_space + _item_max_stack - end - end - _slot_counter = _slot_counter + 1 - if (_slot_counter == 45) then - break - end - end - return _items_found, _free_space +-- Those two checks how many items of given inItemID chest and player have, and how much they could fit inside them +function ReadChestForItem( inChest, inItemID ) + return ReadGridForItems( inChest:GetContents(), inItemID ) end --- Following functions are for chest-related operations (since noone was bothered writing them in MCS code) +function ReadPlayerForItem( inPlayer, inItemID ) + local inventoryFound, inventoryFree = ReadGridForItems( inPlayer:GetInventory():GetInventoryGrid(), inItemID ) + local hotbarFound, hotbarFree = ReadGridForItems( inPlayer:GetInventory():GetHotbarGrid(), inItemID ) + local itemsFound = inventoryFound + hotbarFound + local freeSpace = inventoryFree + hotbarFree + return itemsFound, freeSpace +end +-- Following functions are for chest-related operations -- BEWARE! Those assume you did checked if chest has items/space in it! -function TakeItemsFromChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR ITEMS FIRST!! - -- stalk through chest slots... - local _slot_counter = 0 - local _slot_item - local _take_count = IN_ammount - while true do - _slot_item = IN_chest:GetSlot(_slot_counter) - if (_slot_item ~= nil) then - if (_slot_item.m_ItemID == IN_itemID) then - -- assuming player have enought money - if (_take_count > 0) then - if (_take_count > _slot_item.m_ItemCount) then - _take_count = _take_count - _slot_item.m_ItemCount - IN_chest:SetSlot(_slot_counter, cItem()) -- a bit hacky, can't make cItem:Clear() work( - else - local _left_count = _slot_item.m_ItemCount - _take_count - IN_chest:SetSlot(_slot_counter, cItem(_slot_item.m_ItemID, _left_count)) -- a bit hacky - _take_count = 0 - end - end - if (_take_count == 0) then - break - end +function ReadGridForItems( inGrid, inItemID ) + local itemsFound = 0 + local freeSpace = 0 + local slotsCount = inGrid:GetNumSlots() + local testerItem = cItem( inItemID ) + local maxStackSize = testerItem:GetMaxStackSize() + for index = 0, (slotsCount - 1) do + slotItem = inGrid:GetSlot( index ) + if( slotItem:IsEmpty() ) then + freeSpace = freeSpace + maxStackSize + else + if( slotItem:IsStackableWith( testerItem ) ) then + itemsFound = itemsFound + slotItem.m_ItemCount + freeSpace = maxStackSize - slotItem.m_ItemCount end end - _slot_counter = _slot_counter + 1 - if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then - break - end end + return itemsFound, freeSpace end -function PutItemsToChest(IN_chest, IN_itemID, IN_ammount) -- UNSAFE! CHECK FOR SPACE FIRST!! - -- stalk through chest slots... - local _slot_counter = 0 - local _slot_item - local _put_count = IN_ammount - local _max_stack = GetItemMaxStack(IN_itemID) - while true do - _slot_item = IN_chest:GetSlot(_slot_counter) - local _portion = 0 - local _ammount_to_set = 0 - if (_slot_item ~= nil) then - if (_slot_item:IsEmpty() == true) then - _portion = math.min(_max_stack, _put_count) - _ammount_to_set = _portion + +function TakeItemsFromGrid( inGrid, inItem ) + local slotsCount = inGrid:GetNumSlots() + local removedItem = cItem( inItem ) + for index = 0, (slotsCount - 1) do + slotItem = inGrid:GetSlot( index ) + if( slotItem:IsSameType( removedItem ) ) then + if( slotItem.m_ItemCount <= removedItem.m_ItemCount ) then + removedItem.m_ItemCount = removedItem.m_ItemCount - slotItem.m_ItemCount + inGrid:EmptySlot( index ) else - if (_slot_item.m_ItemID == IN_itemID) then - -- choose between how much we need to put and how much free space left - _portion = math.min(_put_count, _max_stack - _slot_item.m_ItemCount) - _ammount_to_set = _slot_item.m_ItemCount + _portion - end + removedItem.m_ItemCount = slotItem.m_ItemCount - removedItem.m_ItemCount + inGrid:SetSlot( index, removedItem ) + removedItem.m_ItemCount = 0 end - end - IN_chest:SetSlot(_slot_counter, cItem(IN_itemID, _ammount_to_set)) -- we add max stack to chest - _put_count = _put_count - _portion - if (_put_count == 0) then break end - _slot_counter = _slot_counter + 1 - if (_slot_counter == CHEST_WIDTH*GetChestHeightCheat(IN_chest)) then - break + if( removedItem.m_ItemCount <= 0 ) then break end end end + return removedItem.m_ItemCount +end +-------------- +function TakeItemsFromChest( inChest, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FOR ITEMS FIRST!! + local chestGrid = inChest:GetContents() + local removedItem = cItem( inItemID, inAmount ) + TakeItemsFromGrid( chestGrid, removedItem ) +end +function PutItemsToChest( inChest, inItemID, inAmount ) + local chestGrid = inChest:GetContents() + local addedItem = cItem( inItemID, inAmount ) + chestGrid:AddItem( addedItem ) end -- Similar to chest-related. -function TakeItemsFromPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST! - local _put_count = IN_ammount - local _max_stack = GetItemMaxStack(IN_itemID) - while true do - local _portion = math.min(_max_stack, _put_count) - IN_player:GetInventory():RemoveItem(cItem(IN_itemID, _portion)) - _put_count = _put_count - _portion - if (_put_count == 0) then break end +function TakeItemsFromPlayer( inPlayer, inItemID, inAmount ) -- MIGHT BE UNSAFE! CHECK FIRST! + local removedItem = cItem( inItemID, inAmount ) + local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid() + local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid() + local itemsLeft = TakeItemsFromGrid( inventoryGrid, removedItem ) + if( itemsLeft > 0 ) then + removedItem = cItem( inItemID, itemsLeft ) + TakeItemsFromGrid( hotbarGrid, removedItem ) end end -function GiveItemsToPlayer(IN_player, IN_itemID, IN_ammount) -- UNSAFE! CHECK FIRST! - local _put_count = IN_ammount - local _max_stack = GetItemMaxStack(IN_itemID) - while true do - local _portion = math.min(_max_stack, _put_count) - IN_player:GetInventory():AddItem(cItem(IN_itemID, _portion)) - _put_count = _put_count - _portion - if (_put_count == 0) then break end +function GiveItemsToPlayer( inPlayer, inItemID, inAmount ) + local addedItem = cItem( inItemID, inAmount ) + local inventoryGrid = inPlayer:GetInventory():GetInventoryGrid() + local hotbarGrid = inPlayer:GetInventory():GetHotbarGrid() + local itemsAdded = inventoryGrid:AddItem( addedItem ) + if( itemsAdded < inAmount ) then + addedItem.m_ItemCount = addedItem.m_ItemCount - itemsAdded + hotbarGrid:AddItem( addedItem ) end end -- This function returns item max stack for a given itemID. It uses vanilla max stack size, and uses several non-common items notations; -- Those are: --- oneonerecord (because aparently 11record wasn't the best idea in lua scripting application) --- carrotonastick (because it wasn't added to items.txt yet) --- waitrecord (for same reason) +-- oneonerecord( because aparently 11record wasn't the best idea in lua scripting application ) +-- carrotonastick( because it wasn't added to items.txt yet ) +-- waitrecord( for same reason ) -- Feel free to ignore the difference, or to add those to items.txt -function GetItemMaxStack(IN_itemID) - local _result = 64 - -- Tools and swords - if (IN_itemID == woodensword) then _result = 1 end - if (IN_itemID == woodenshovel) then _result = 1 end - if (IN_itemID == woodenpickaxe) then _result = 1 end - if (IN_itemID == woodenaxe) then _result = 1 end - if (IN_itemID == woodenhoe) then _result = 1 end - if (IN_itemID == stonesword) then _result = 1 end - if (IN_itemID == stoneshovel) then _result = 1 end - if (IN_itemID == stonepickaxe) then _result = 1 end - if (IN_itemID == stoneaxe) then _result = 1 end - if (IN_itemID == stonehoe) then _result = 1 end - if (IN_itemID == ironsword) then _result = 1 end - if (IN_itemID == ironshovel) then _result = 1 end - if (IN_itemID == ironpickaxe) then _result = 1 end - if (IN_itemID == ironaxe) then _result = 1 end - if (IN_itemID == ironhoe) then _result = 1 end - if (IN_itemID == diamondsword) then _result = 1 end - if (IN_itemID == diamondshovel) then _result = 1 end - if (IN_itemID == diamondpickaxe) then _result = 1 end - if (IN_itemID == diamondaxe) then _result = 1 end - if (IN_itemID == diamondhoe) then _result = 1 end - if (IN_itemID == goldensword) then _result = 1 end - if (IN_itemID == goldenshovel) then _result = 1 end - if (IN_itemID == goldenpickaxe) then _result = 1 end - if (IN_itemID == goldenaxe) then _result = 1 end - if (IN_itemID == goldenhoe) then _result = 1 end - - if (IN_itemID == flintandsteel) then _result = 1 end - if (IN_itemID == bow) then _result = 1 end - if (IN_itemID == sign) then _result = 16 end - if (IN_itemID == woodendoor) then _result = 1 end - if (IN_itemID == irondoor) then _result = 1 end - if (IN_itemID == cake) then _result = 1 end - if (IN_itemID == cauldron) then _result = 1 end - if (IN_itemID == mushroomstew) then _result = 1 end - if (IN_itemID == painting) then _result = 1 end - if (IN_itemID == bucket) then _result = 16 end - if (IN_itemID == waterbucket) then _result = 1 end - if (IN_itemID == lavabucket) then _result = 1 end - if (IN_itemID == minecart) then _result = 1 end - if (IN_itemID == saddle) then _result = 1 end - if (IN_itemID == snowball) then _result = 16 end - if (IN_itemID == boat) then _result = 1 end - if (IN_itemID == milkbucket) then _result = 1 end - if (IN_itemID == storageminecart) then _result = 1 end - if (IN_itemID == poweredminecart) then _result = 1 end - if (IN_itemID == egg) then _result = 16 end - if (IN_itemID == fishingrod) then _result = 1 end - if (IN_itemID == bed) then _result = 1 end - if (IN_itemID == map) then _result = 1 end - if (IN_itemID == shears) then _result = 1 end - if (IN_itemID == enderpearl) then _result = 16 end - if (IN_itemID == potion) then _result = 1 end - if (IN_itemID == spawnegg) then _result = 1 end - if (IN_itemID == bookandquill) then _result = 1 end - if (IN_itemID == writtenbook) then _result = 1 end - if (IN_itemID == carrotonastick) then _result = 1 end - - if (IN_itemID == goldrecord) then _result = 1 end - if (IN_itemID == greenrecord) then _result = 1 end - if (IN_itemID == blocksrecord) then _result = 1 end - if (IN_itemID == chirprecord) then _result = 1 end - if (IN_itemID == farrecord) then _result = 1 end - if (IN_itemID == mallrecord) then _result = 1 end - if (IN_itemID == mellohirecord) then _result = 1 end - if (IN_itemID == stalrecord) then _result = 1 end - if (IN_itemID == stradrecord) then _result = 1 end - if (IN_itemID == wardrecord) then _result = 1 end - if (IN_itemID == oneonerecord) then _result = 1 end - if (IN_itemID == waitrecord) then _result = 1 end - - --if (IN_itemID == xxxxxxxxx) then _result = 1 end - - if (IN_itemID == leatherhelmet) then _result = 1 end - if (IN_itemID == leatherchestplate) then _result = 1 end - if (IN_itemID == leatherpants) then _result = 1 end - if (IN_itemID == leatherboots) then _result = 1 end - - if (IN_itemID == chainmailhelmet) then _result = 1 end - if (IN_itemID == chainmailchestplate) then _result = 1 end - if (IN_itemID == chainmailpants) then _result = 1 end - if (IN_itemID == chainmailboots) then _result = 1 end - - if (IN_itemID == ironhelmet) then _result = 1 end - if (IN_itemID == ironchestplate) then _result = 1 end - if (IN_itemID == ironpants) then _result = 1 end - if (IN_itemID == ironboots) then _result = 1 end - - if (IN_itemID == diamondhelmet) then _result = 1 end - if (IN_itemID == diamondchestplate) then _result = 1 end - if (IN_itemID == diamondpants) then _result = 1 end - if (IN_itemID == diamondboots) then _result = 1 end - - if (IN_itemID == goldenhelmet) then _result = 1 end - if (IN_itemID == goldenchestplate) then _result = 1 end - if (IN_itemID == goldenpants) then _result = 1 end - if (IN_itemID == goldenboots) then _result = 1 end - return _result +function GetItemMaxStack( inItemID ) + local testerItem = cItem( inItemID ) + LOGINFO( "This function serves no real purpose now, maybe consider using cItem:GetMaxStackSize()?" ) + return testerItem:GetMaxStackSize() end -function ItemIsArmor(IN_itemID) - local _result = false - if (IN_itemID == leatherhelmet) then _result = true end - if (IN_itemID == leatherchestplate) then _result = true end - if (IN_itemID == leatherpants) then _result = true end - if (IN_itemID == leatherboots) then _result = true end +function ItemIsArmor( inItemID, inCheckForHorseArmor ) + inCheckForHorseArmor = inCheckForHorseArmor or false + if( inItemID == E_ITEM_LEATHER_CAP ) then return true end + if( inItemID == E_ITEM_LEATHER_TUNIC ) then return true end + if( inItemID == E_ITEM_LEATHER_PANTS ) then return true end + if( inItemID == E_ITEM_LEATHER_BOOTS ) then return true end - if (IN_itemID == chainmailhelmet) then _result = true end - if (IN_itemID == chainmailchestplate) then _result = true end - if (IN_itemID == chainmailpants) then _result = true end - if (IN_itemID == chainmailboots) then _result = true end + if( inItemID == E_ITEM_CHAIN_HELMET ) then return true end + if( inItemID == E_ITEM_CHAIN_CHESTPLATE ) then return true end + if( inItemID == E_ITEM_CHAIN_LEGGINGS ) then return true end + if( inItemID == E_ITEM_CHAIN_BOOTS ) then return true end - if (IN_itemID == ironhelmet) then _result = true end - if (IN_itemID == ironchestplate) then _result = true end - if (IN_itemID == ironpants) then _result = true end - if (IN_itemID == ironboots) then _result = true end + if( inItemID == E_ITEM_IRON_HELMET ) then return true end + if( inItemID == E_ITEM_IRON_CHESTPLATE ) then return true end + if( inItemID == E_ITEM_IRON_LEGGINGS ) then return true end + if( inItemID == E_ITEM_IRON_BOOTS ) then return true end - if (IN_itemID == diamondhelmet) then _result = true end - if (IN_itemID == diamondchestplate) then _result = true end - if (IN_itemID == diamondpants) then _result = true end - if (IN_itemID == diamondboots) then _result = true end + if( inItemID == E_ITEM_DIAMOND_HELMET ) then return true end + if( inItemID == E_ITEM_DIAMOND_CHESTPLATE ) then return true end + if( inItemID == E_ITEM_DIAMOND_LEGGINGS ) then return true end + if( inItemID == E_ITEM_DIAMOND_BOOTS ) then return true end - if (IN_itemID == goldenhelmet) then _result = true end - if (IN_itemID == goldenchestplate) then _result = true end - if (IN_itemID == goldenpants) then _result = true end - if (IN_itemID == goldenboots) then _result = true end - return _result -end --- Returns full-length playername for a short name (usefull for parsing commands) -function GetExactPlayername(IN_playername) - local _result = IN_playername - local function SetProcessingPlayername(IN_player) - _result = IN_player:GetName() + if( inItemID == E_ITEM_GOLD_HELMET ) then return true end + if( inItemID == E_ITEM_GOLD_CHESTPLATE ) then return true end + if( inItemID == E_ITEM_GOLD_LEGGINGS ) then return true end + if( inItemID == E_ITEM_GOLD_BOOTS ) then return true end + + if( inCheckForHorseArmor ) then + if( inItemID == E_ITEM_IRON_HORSE_ARMOR ) then return true end + if( inItemID == E_ITEM_GOLD_HORSE_ARMOR ) then return true end + if( inItemID == E_ITEM_DIAMOND_HORSE_ARMOR ) then return true end end - cRoot:Get():FindAndDoWithPlayer(IN_playername, SetProcessingPlayername) + return false +end +-- Returns full-length playername for a short name( usefull for parsing commands ) +function GetExactPlayername( inPlayerName ) + local _result = inPlayerName + local function SetProcessingPlayername( inPlayer ) + _result = inPlayer:GetName() + end + cRoot:Get():FindAndDoWithPlayer( inPlayerName, SetProcessingPlayername ) return _result end -function GetPlayerByName(IN_playername) +function GetPlayerByName( inPlayerName ) local _player - local PlayerSetter = function (Player) + local PlayerSetter = function( Player ) _player = Player end - cRoot:Get():FindAndDoWithPlayer(IN_playername, PlayerSetter) + cRoot:Get():FindAndDoWithPlayer( inPlayerName, PlayerSetter ) return _player end --[[ Not-so-usual math _functions ]] -- Rounds floating point number. Because lua guys think this function doesn't deserve to be presented in lua's math -function round(IN_x) - if (IN_x%2 ~= 0.5) then - return math.floor(IN_x+0.5) +function round( inX ) + if( inX%2 ~= 0.5 ) then + return math.floor( inX + 0.5 ) end - return IN_x-0.5 + return inX - 0.5 end --[[ Functions I use for filework and stringswork ]] -function PluralString(IN_value, IN_singular_string, IN_plural_string) - local _value_string = tostring(IN_value) - if (_value_string[#_value_string] == "1") then - return IN_singular_string +function PluralString( inValue, inSingularString, inPluralString ) + local _value_string = tostring( inValue ) + if( _value_string[#_value_string] == "1" ) then + return inSingularString end - return IN_plural_string + return inPluralString end -function PluralItemName(IN_itemID, IN_ammount) -- BEWARE! TEMPORAL SOLUTION THERE! :D - local _value_string = tostring(IN_value) +function PluralItemName( inItemID, inAmount ) -- BEWARE! TEMPORAL SOLUTION THERE! :D + local _value_string = tostring( inValue ) local _name = "" - if (_value_string[#_value_string] == "1") then + if( _value_string[#_value_string] == "1" ) then -- singular names - _name = ItemTypeToString(IN_itemID) + _name = ItemTypeToString( inItemID ) else -- plural names - _name = ItemTypeToString(IN_itemID).."s" + _name = ItemTypeToString( inItemID ).."s" end return _name end -- for filewriting purposes. 0 = false, 1 = true -function StringToBool(value) - if value=="1" then return true end +function StringToBool( inValue ) + if( inValue == "1" ) then return true end return false end -- same, but reversal -function BoolToString(value) - if value==true then return 1 end +function BoolToString( inValue ) + if( inValue == true ) then return 1 end return 0 end \ No newline at end of file From bbdb34252e9c1023405b58585fd5999cc8f39b45 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Thu, 2 Jan 2014 17:37:34 +0000 Subject: [PATCH 055/144] fixed a few remaining issues with worldstorage --- src/WorldStorage/WorldStorage.cpp | 21 +++------------------ src/WorldStorage/WorldStorage.h | 9 +++------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 9ad995c8..5f4c112d 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -103,8 +103,7 @@ void cWorldStorage::WaitForFinish(void) // Wait for the thread to finish: m_ShouldTerminate = true; - m_Event.Set(); - m_evtRemoved.Set(); // Wake up anybody waiting in the WaitForQueuesEmpty() method + m_Event.Set(); // Wake up the thread if waiting super::Wait(); LOG("World storage thread finished"); } @@ -127,7 +126,6 @@ void cWorldStorage::WaitForSaveQueueEmpty(void) size_t cWorldStorage::GetLoadQueueLength(void) { - cCSLock Lock(m_CSQueues); return m_LoadQueue.Size(); } @@ -137,7 +135,6 @@ size_t cWorldStorage::GetLoadQueueLength(void) size_t cWorldStorage::GetSaveQueueLength(void) { - cCSLock Lock(m_CSQueues); return m_SaveQueue.Size(); } @@ -147,6 +144,7 @@ size_t cWorldStorage::GetSaveQueueLength(void) void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) { + m_Event.Set(); m_LoadQueue.EnqueueItemIfNotPresent(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, a_Generate)); } @@ -156,6 +154,7 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, boo void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { + m_Event.Set(); m_SaveQueue.EnqueueItemIfNotPresent(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); } @@ -175,18 +174,6 @@ void cWorldStorage::QueueSavedMessage(void) void cWorldStorage::UnqueueLoad(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - /*cCSLock Lock(m_CSQueues); - for (sChunkLoadQueue::iterator itr = m_LoadQueue.begin(); itr != m_LoadQueue.end(); ++itr) - { - if ((itr->m_ChunkX != a_ChunkX) || (itr->m_ChunkY != a_ChunkY) || (itr->m_ChunkZ != a_ChunkZ)) - { - continue; - } - m_LoadQueue.erase(itr); - Lock.Unlock(); - m_evtRemoved.Set(); - return; - } // for itr - m_LoadQueue[]*/ m_LoadQueue.Remove(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ,true)); } @@ -245,7 +232,6 @@ void cWorldStorage::Execute(void) while (!m_ShouldTerminate) { m_Event.Wait(); - // Process both queues until they are empty again: bool Success; do @@ -258,7 +244,6 @@ void cWorldStorage::Execute(void) Success = LoadOneChunk(); Success |= SaveOneChunk(); - m_evtRemoved.Set(); } while (Success); } } diff --git a/src/WorldStorage/WorldStorage.h b/src/WorldStorage/WorldStorage.h index 98eb5fce..06cae171 100644 --- a/src/WorldStorage/WorldStorage.h +++ b/src/WorldStorage/WorldStorage.h @@ -116,15 +116,10 @@ protected: cWorld * m_World; AString m_StorageSchemaName; - - // Both queues are locked by the same CS - cCriticalSection m_CSQueues; + sChunkLoadQueue m_LoadQueue; cChunkCoordsQueue m_SaveQueue; - cEvent m_Event; // Set when there's any addition to the queues - cEvent m_evtRemoved; // Set when an item has been removed from the queue, either by the worker thread or the Unqueue methods - /// All the storage schemas (all used for loading) cWSSchemaList m_Schemas; @@ -135,6 +130,8 @@ protected: virtual void Execute(void) override; + cEvent m_Event; // Set when there's any addition to the queues + /// Loads one chunk from the queue (if any queued); returns true if there are more chunks in the load queue bool LoadOneChunk(void); From d522619ce2ac05831febedea675d121445dcbdbe Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Thu, 2 Jan 2014 17:43:57 +0000 Subject: [PATCH 056/144] added documentation --- src/OSSupport/Queue.h | 52 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 153e201c..1f0c19f4 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -1,34 +1,55 @@ +// Queue.h + +// Implements the cQueue class representing a thread safe queue + #pragma once #include -//this empty struct allows function inlining +/* +Usage: +To use the callback functions Delete and Combine create a class with the two +methods and pass it as a second template parameter to cQueue. The class does +not need to inherit cQueueFuncs but you do so to document the classes purpose. +The second template parmeter is optional if not overriding the callback +functions +*/ + +// this empty struct allows for the callback functions to be inlined template struct cQueueFuncs { public: + // Called when an Item is deleted form the queue without being returned static void Delete(T) {}; - static void Combine(T&, const T) {}; + // Called when an Item is inserted with EnqueueItemIfNotPresent and + // there is another equal value already inserted + static void Combine(T& a_existing, const T a_new) {}; }; template > class cQueue { - +// internal typedef for a List of Items typedef typename std::list ListType; -//magic typedef to persuade clang that the iterator is a type +// magic typedef to persuade clang that the iterator is a type typedef typename ListType::iterator iterator; public: cQueue() {} ~cQueue() {} + // Enqueues an item to the queue, may block if other threads are accessing + // the queue. void EnqueueItem(ItemType a_item) { cCSLock Lock(m_CS); m_contents.push_back(a_item); m_evtAdded.Set(); } + + // Enqueues an item to the queue if not already present as determined with + // operator ==. Will block other threads from accessing the queue. void EnqueueItemIfNotPresent(ItemType a_item) { cCSLock Lock(m_CS); @@ -44,6 +65,11 @@ public: m_contents.push_back(a_item); m_evtAdded.Set(); } + + // Dequeues an Item from the queue if any are present, provides no + // guarantees about success if the list is empty but an item is enqueued at + // the same time. Returns true if successful. Value of item is undefined if + // Dequeuing was unsuccessful. bool TryDequeueItem(ItemType& item) { cCSLock Lock(m_CS); @@ -53,6 +79,8 @@ public: m_evtRemoved.Set(); return true; } + + // Dequeues an Item from the Queue, blocking until an Item is Available. ItemType DequeueItem() { cCSLock Lock(m_CS); @@ -66,12 +94,17 @@ public: m_evtRemoved.Set(); return item; } + + // Blocks Until the queue is Empty, Has a slight race condition which may + // cause it to miss the queue being empty. void BlockTillEmpty() { - //There is a very slight race condition here if the load completes between the check - //and the wait. + // There is a very slight race condition here if the load completes between the check + // and the wait. while(!(Size() == 0)){m_evtRemoved.Wait();} } - //can all be inlined when delete is a noop + + // Removes all Items from the Queue, calling Delete on each of them. + // can all be inlined when delete is a noop void Clear() { cCSLock Lock(m_CS); @@ -82,11 +115,16 @@ public: m_contents.pop_front(); } } + + // Returns the Size at time of being called + // Do not use to detirmine weather to call DequeueItem, use TryDequeue instead size_t Size() { cCSLock Lock(m_CS); return m_contents.size(); } + + // Removes an Item from the queue bool Remove(ItemType item) { cCSLock Lock(m_CS); From 6f3c5b806eb59e2610f8bac9ad3fff24994609c9 Mon Sep 17 00:00:00 2001 From: Tycho Bickerstaff Date: Fri, 3 Jan 2014 11:22:01 +0000 Subject: [PATCH 057/144] implement xsofts recommendations --- src/OSSupport/Queue.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 1f0c19f4..65f9bd25 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -5,15 +5,18 @@ #pragma once -#include - /* +Items can be added multiple times to a queue, there are two functions for +adding, EnqueueItem() and EnqueueItemIfNotPresent(). The first one always +enqueues the specified item, the second one checks if the item is already +present and only queues it if it isn't. + Usage: -To use the callback functions Delete and Combine create a class with the two -methods and pass it as a second template parameter to cQueue. The class does -not need to inherit cQueueFuncs but you do so to document the classes purpose. -The second template parmeter is optional if not overriding the callback -functions +To create a queue of type T, instantiate a cQueue object. You can also +modify the behavior of the queue when deleting items and when adding items +that are already in the queue by providing a second parameter, a class that +implements the functions Delete() and Combine(). An example is given in +cQueueFuncs and is used as the default behavior. */ // this empty struct allows for the callback functions to be inlined @@ -25,7 +28,7 @@ struct cQueueFuncs static void Delete(T) {}; // Called when an Item is inserted with EnqueueItemIfNotPresent and // there is another equal value already inserted - static void Combine(T& a_existing, const T a_new) {}; + static void Combine(T& a_existing, const T& a_new) {}; }; template > @@ -73,7 +76,10 @@ public: bool TryDequeueItem(ItemType& item) { cCSLock Lock(m_CS); - if (m_contents.size() == 0) return false; + if (m_contents.size() == 0) + { + return false; + } item = m_contents.front(); m_contents.pop_front(); m_evtRemoved.Set(); From 83c7ba2bae8e167c7fac41962f06d6aa47be04cb Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 3 Jan 2014 08:10:57 -0800 Subject: [PATCH 058/144] removed tolua++ makefile which is overwritten by cmake --- lib/tolua++/Makefile | 338 ------------------------------------------- 1 file changed, 338 deletions(-) delete mode 100644 lib/tolua++/Makefile diff --git a/lib/tolua++/Makefile b/lib/tolua++/Makefile deleted file mode 100644 index c15b4fc8..00000000 --- a/lib/tolua++/Makefile +++ /dev/null @@ -1,338 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 2.8 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake - -# The command to remove a file. -RM = /usr/bin/cmake -E remove -f - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /home/tycho/MCServer - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /home/tycho/MCServer - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." - /usr/bin/cmake -i . -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# The main all target -all: cmake_check_build_system - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -E cmake_progress_start /home/tycho/MCServer/CMakeFiles /home/tycho/MCServer/lib/tolua++/CMakeFiles/progress.marks - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/all - $(CMAKE_COMMAND) -E cmake_progress_start /home/tycho/MCServer/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -# Convenience name for target. -lib/tolua++/CMakeFiles/tolua.dir/rule: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/CMakeFiles/tolua.dir/rule -.PHONY : lib/tolua++/CMakeFiles/tolua.dir/rule - -# Convenience name for target. -tolua: lib/tolua++/CMakeFiles/tolua.dir/rule -.PHONY : tolua - -# fast build rule for target. -tolua/fast: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/build -.PHONY : tolua/fast - -# Convenience name for target. -lib/tolua++/CMakeFiles/tolualib.dir/rule: - cd /home/tycho/MCServer && $(MAKE) -f CMakeFiles/Makefile2 lib/tolua++/CMakeFiles/tolualib.dir/rule -.PHONY : lib/tolua++/CMakeFiles/tolualib.dir/rule - -# Convenience name for target. -tolualib: lib/tolua++/CMakeFiles/tolualib.dir/rule -.PHONY : tolualib - -# fast build rule for target. -tolualib/fast: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/build -.PHONY : tolualib/fast - -src/bin/tolua.o: src/bin/tolua.c.o -.PHONY : src/bin/tolua.o - -# target to build an object file -src/bin/tolua.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/tolua.c.o -.PHONY : src/bin/tolua.c.o - -src/bin/tolua.i: src/bin/tolua.c.i -.PHONY : src/bin/tolua.i - -# target to preprocess a source file -src/bin/tolua.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/tolua.c.i -.PHONY : src/bin/tolua.c.i - -src/bin/tolua.s: src/bin/tolua.c.s -.PHONY : src/bin/tolua.s - -# target to generate assembly for a file -src/bin/tolua.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/tolua.c.s -.PHONY : src/bin/tolua.c.s - -src/bin/toluabind.o: src/bin/toluabind.c.o -.PHONY : src/bin/toluabind.o - -# target to build an object file -src/bin/toluabind.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/toluabind.c.o -.PHONY : src/bin/toluabind.c.o - -src/bin/toluabind.i: src/bin/toluabind.c.i -.PHONY : src/bin/toluabind.i - -# target to preprocess a source file -src/bin/toluabind.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/toluabind.c.i -.PHONY : src/bin/toluabind.c.i - -src/bin/toluabind.s: src/bin/toluabind.c.s -.PHONY : src/bin/toluabind.s - -# target to generate assembly for a file -src/bin/toluabind.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolua.dir/build.make lib/tolua++/CMakeFiles/tolua.dir/src/bin/toluabind.c.s -.PHONY : src/bin/toluabind.c.s - -src/lib/tolua_event.o: src/lib/tolua_event.c.o -.PHONY : src/lib/tolua_event.o - -# target to build an object file -src/lib/tolua_event.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_event.c.o -.PHONY : src/lib/tolua_event.c.o - -src/lib/tolua_event.i: src/lib/tolua_event.c.i -.PHONY : src/lib/tolua_event.i - -# target to preprocess a source file -src/lib/tolua_event.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_event.c.i -.PHONY : src/lib/tolua_event.c.i - -src/lib/tolua_event.s: src/lib/tolua_event.c.s -.PHONY : src/lib/tolua_event.s - -# target to generate assembly for a file -src/lib/tolua_event.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_event.c.s -.PHONY : src/lib/tolua_event.c.s - -src/lib/tolua_is.o: src/lib/tolua_is.c.o -.PHONY : src/lib/tolua_is.o - -# target to build an object file -src/lib/tolua_is.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_is.c.o -.PHONY : src/lib/tolua_is.c.o - -src/lib/tolua_is.i: src/lib/tolua_is.c.i -.PHONY : src/lib/tolua_is.i - -# target to preprocess a source file -src/lib/tolua_is.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_is.c.i -.PHONY : src/lib/tolua_is.c.i - -src/lib/tolua_is.s: src/lib/tolua_is.c.s -.PHONY : src/lib/tolua_is.s - -# target to generate assembly for a file -src/lib/tolua_is.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_is.c.s -.PHONY : src/lib/tolua_is.c.s - -src/lib/tolua_map.o: src/lib/tolua_map.c.o -.PHONY : src/lib/tolua_map.o - -# target to build an object file -src/lib/tolua_map.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_map.c.o -.PHONY : src/lib/tolua_map.c.o - -src/lib/tolua_map.i: src/lib/tolua_map.c.i -.PHONY : src/lib/tolua_map.i - -# target to preprocess a source file -src/lib/tolua_map.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_map.c.i -.PHONY : src/lib/tolua_map.c.i - -src/lib/tolua_map.s: src/lib/tolua_map.c.s -.PHONY : src/lib/tolua_map.s - -# target to generate assembly for a file -src/lib/tolua_map.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_map.c.s -.PHONY : src/lib/tolua_map.c.s - -src/lib/tolua_push.o: src/lib/tolua_push.c.o -.PHONY : src/lib/tolua_push.o - -# target to build an object file -src/lib/tolua_push.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_push.c.o -.PHONY : src/lib/tolua_push.c.o - -src/lib/tolua_push.i: src/lib/tolua_push.c.i -.PHONY : src/lib/tolua_push.i - -# target to preprocess a source file -src/lib/tolua_push.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_push.c.i -.PHONY : src/lib/tolua_push.c.i - -src/lib/tolua_push.s: src/lib/tolua_push.c.s -.PHONY : src/lib/tolua_push.s - -# target to generate assembly for a file -src/lib/tolua_push.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_push.c.s -.PHONY : src/lib/tolua_push.c.s - -src/lib/tolua_to.o: src/lib/tolua_to.c.o -.PHONY : src/lib/tolua_to.o - -# target to build an object file -src/lib/tolua_to.c.o: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_to.c.o -.PHONY : src/lib/tolua_to.c.o - -src/lib/tolua_to.i: src/lib/tolua_to.c.i -.PHONY : src/lib/tolua_to.i - -# target to preprocess a source file -src/lib/tolua_to.c.i: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_to.c.i -.PHONY : src/lib/tolua_to.c.i - -src/lib/tolua_to.s: src/lib/tolua_to.c.s -.PHONY : src/lib/tolua_to.s - -# target to generate assembly for a file -src/lib/tolua_to.c.s: - cd /home/tycho/MCServer && $(MAKE) -f lib/tolua++/CMakeFiles/tolualib.dir/build.make lib/tolua++/CMakeFiles/tolualib.dir/src/lib/tolua_to.c.s -.PHONY : src/lib/tolua_to.c.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... edit_cache" - @echo "... rebuild_cache" - @echo "... tolua" - @echo "... tolualib" - @echo "... src/bin/tolua.o" - @echo "... src/bin/tolua.i" - @echo "... src/bin/tolua.s" - @echo "... src/bin/toluabind.o" - @echo "... src/bin/toluabind.i" - @echo "... src/bin/toluabind.s" - @echo "... src/lib/tolua_event.o" - @echo "... src/lib/tolua_event.i" - @echo "... src/lib/tolua_event.s" - @echo "... src/lib/tolua_is.o" - @echo "... src/lib/tolua_is.i" - @echo "... src/lib/tolua_is.s" - @echo "... src/lib/tolua_map.o" - @echo "... src/lib/tolua_map.i" - @echo "... src/lib/tolua_map.s" - @echo "... src/lib/tolua_push.o" - @echo "... src/lib/tolua_push.i" - @echo "... src/lib/tolua_push.s" - @echo "... src/lib/tolua_to.o" - @echo "... src/lib/tolua_to.i" - @echo "... src/lib/tolua_to.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - cd /home/tycho/MCServer && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - From 0e8bb3bf415e4c0fe6c8bd0aa06dc2d9af2823c4 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 3 Jan 2014 08:34:41 -0800 Subject: [PATCH 059/144] fixed failure to return a value from Remove --- src/OSSupport/Queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index 65f9bd25..bf6d7e45 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -134,8 +134,8 @@ public: bool Remove(ItemType item) { cCSLock Lock(m_CS); - m_contents.remove(item); m_evtRemoved.Set(); + return m_contents.remove(item); } private: From 14ec68d8d309d3fdf8e0af47196b1cf8609d017d Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 3 Jan 2014 08:49:14 -0800 Subject: [PATCH 060/144] actual fix --- src/OSSupport/Queue.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index bf6d7e45..fc942b3e 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -134,8 +134,15 @@ public: bool Remove(ItemType item) { cCSLock Lock(m_CS); - m_evtRemoved.Set(); - return m_contents.remove(item); + for (iterator itr = m_contents.begin(); itr != m_contents.end(); ++itr) + { + if((*itr) == a_item) { + m_contents.erase(itr); + m_evtRemoved.Set(); + return true; + } + } + return false; } private: From 13bbb3d99dee8041d47279cae3484c3083491f18 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 3 Jan 2014 08:56:20 -0800 Subject: [PATCH 061/144] derp --- lib/tolua++/Makefile | 3 +++ src/OSSupport/Queue.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tolua++/Makefile b/lib/tolua++/Makefile index c15b4fc8..3bbda9b1 100644 --- a/lib/tolua++/Makefile +++ b/lib/tolua++/Makefile @@ -35,6 +35,9 @@ CMAKE_COMMAND = /usr/bin/cmake # The command to remove a file. RM = /usr/bin/cmake -E remove -f +# Escaping for special characters. +EQUALS = = + # The top-level source directory on which CMake was run. CMAKE_SOURCE_DIR = /home/tycho/MCServer diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index fc942b3e..ab42c871 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -131,7 +131,7 @@ public: } // Removes an Item from the queue - bool Remove(ItemType item) + bool Remove(ItemType a_item) { cCSLock Lock(m_CS); for (iterator itr = m_contents.begin(); itr != m_contents.end(); ++itr) From d26c0e3815a8e3c38447eeb65b052a5d7c43da73 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 3 Jan 2014 09:42:35 -0800 Subject: [PATCH 062/144] Fixed Documentation --- src/OSSupport/Queue.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index ab42c871..cde26e41 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -69,10 +69,8 @@ public: m_evtAdded.Set(); } - // Dequeues an Item from the queue if any are present, provides no - // guarantees about success if the list is empty but an item is enqueued at - // the same time. Returns true if successful. Value of item is undefined if - // Dequeuing was unsuccessful. + // Dequeues an Item from the queue if any are present. Returns true if + // successful. Value of item is undefined if Dequeuing was unsuccessful. bool TryDequeueItem(ItemType& item) { cCSLock Lock(m_CS); From 7359533b1243841d4f2073f6d8bd8e1dff324c60 Mon Sep 17 00:00:00 2001 From: Bitdeli Chef Date: Sat, 4 Jan 2014 11:27:16 +0000 Subject: [PATCH 063/144] Add a Bitdeli badge to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e6726787..ff30d63b 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,7 @@ For other stuff, including plugins and discussion, check the [forums](http://for Earn bitcoins for commits or donate to reward the MCServer developers: [![tip for next commit](http://tip4commit.com/projects/74.svg)](http://tip4commit.com/projects/74) Travis CI: [![Build Status](https://travis-ci.org/mc-server/MCServer.png?branch=master)](https://travis-ci.org/mc-server/MCServer) + + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mc-server/mcserver/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + From 4c3d2a86a5c56d2f20c7aaaf685d7484db176507 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 4 Jan 2014 00:37:57 +0100 Subject: [PATCH 064/144] Added an InfoDump script for dumping all plugins' Info.lua into forum description. GitHub description will follow later on. --- MCServer/Plugins/InfoDump.deproj | 6 + MCServer/Plugins/InfoDump.lua | 293 +++++++++++++++++++++++++++++++ 2 files changed, 299 insertions(+) create mode 100644 MCServer/Plugins/InfoDump.deproj create mode 100644 MCServer/Plugins/InfoDump.lua diff --git a/MCServer/Plugins/InfoDump.deproj b/MCServer/Plugins/InfoDump.deproj new file mode 100644 index 00000000..30003c36 --- /dev/null +++ b/MCServer/Plugins/InfoDump.deproj @@ -0,0 +1,6 @@ + + + + InfoDump.lua + + diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua new file mode 100644 index 00000000..5b2e2077 --- /dev/null +++ b/MCServer/Plugins/InfoDump.lua @@ -0,0 +1,293 @@ +#!/usr/bin/lua + +-- InfoDump.lua + +-- Goes through all subfolders, loads Info.lua and dumps its g_PluginInfo into various text formats +-- This is used for generating plugin documentation for the forum and for GitHub's INFO.md files + +-- This script requires LuaRocks with LFS installed, instructions are printed when this is not present. + + + + + +-- Check Lua version. We use 5.1-specific construct when loading the plugin info, 5.2 is not compatible! +if (_VERSION ~= "Lua 5.1") then + print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "")); + return; +end + +-- Try to load lfs, do not abort if not found +local lfs, err = pcall( + function() + return require("lfs") + end +); + +-- Rather, print a nice message with instructions: +if not(lfs) then + print([[ +Cannot load LuaFileSystem +Install it through luarocks by executing the following command: + sudo luarocks install luafilesystem + +If you don't have luarocks installed, you need to install them using your OS's package manager, usually: + sudo apt-get install luarocks +On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download +]]); + + print("Original error text: ", err); + return; +end + +-- We now know that LFS is present, get it normally: +lfs = require("lfs"); + + + + + + +--- Returns an array-table of all commands that are in the specified category +-- Each item is a table {Command = "/command string", Info = {}} +local function GetCategoryCommands(a_PluginInfo, a_CategoryName) + local res = {}; + local function AppendCategoryCommand(a_Prefix, a_Commands) + for cmd, info in pairs(a_Commands) do + info.Category = info.Category or {}; + if (type(info.Category) == "string") then + info.Category = {info.Category}; + end + for idx, cat in ipairs(info.Category) do + if (cat == a_CategoryName) then + table.insert(res, {Command = a_Prefix .. cmd, Info = info}); + end + end + if (info.Subcommands ~= nil) then + AppendCategoryCommand(a_Prefix .. cmd .. " ", info.Subcommands); + end + end + end + AppendCategoryCommand("", a_PluginInfo.Commands); + return res; +end + + + + + +--- Builds an array of categories, each containing all the commands belonging to the category, +-- and the category description, if available. +-- Returns the array table, each item has the following format: +-- { Name = "CategoryName", Description = "CategoryDescription", Commands = {{CommandString = "/cmd verb", Info = {...}}, ...}} +local function BuildCategories(a_PluginInfo) + -- The returned result + -- This will contain both an array and a dict of the categories, to allow fast search + local res = {}; + + -- For each command add a reference to it into all of its categories: + local function AddCommands(a_CmdPrefix, a_Commands) + for cmd, info in pairs(a_Commands) do + local NewCmd = + { + CommandString = a_CmdPrefix .. cmd, + Info = info, + } + + if ((info.HelpString ~= nil) and (info.HelpString ~= "")) then + -- Add to each specified category: + local Category = info.Category; + if (type(Category) == "string") then + Category = {Category}; + end + for idx, cat in ipairs(Category or {""}) do + local CatEntry = res[cat]; + if (CatEntry == nil) then + -- First time we came across this category, create it: + local NewCat = {Name = cat, Description = "", Commands = {NewCmd}}; + table.insert(res, NewCat); + res[cat] = NewCat; + else + -- We already have this category, just add the command to its list of commands: + table.insert(CatEntry.Commands, NewCmd); + end + end -- for idx, cat - Category[] + end -- if (HelpString valid) + + -- Recurse all subcommands: + if (info.Subcommands ~= nil) then + AddCommands(a_CmdPrefix .. cmd .. " ", info.Subcommands); + end + end -- for cmd, info - a_Commands[] + end -- AddCommands() + + AddCommands("", a_PluginInfo.Commands); + + -- Assign descriptions to categories: + for name, desc in pairs(a_PluginInfo.Categories or {}) do + local CatEntry = res[name]; + if (CatEntry ~= nil) then + -- The result has this category, add the description: + CatEntry.Description = desc.Description; + end + end + + -- Alpha-sort each category's command list: + for idx, cat in ipairs(res) do + table.sort(cat.Commands, + function (cmd1, cmd2) + return (string.lower(cmd1.CommandString) < string.lower(cmd2.CommandString)); + end + ); + end + + return res; +end + + + + + +local function WriteCommandsCategoryForum(a_Category, f) + -- Write category name: + local CategoryName = a_Category.Name; + if (CategoryName == "") then + CategoryName = "General"; + end + f:write("\n[size=Large]", CategoryName, "[/size]\n"); + + -- Write description: + if (a_Category.Description ~= "") then + f:write(a_Category.Description, "\n"); + end + + -- Write commands: + f:write("\n[list]"); + for idx2, cmd in ipairs(a_Category.Commands) do + f:write("\nCommand: [b]", cmd.CommandString, "[/b] - ", (cmd.Info.HelpString or "UNDOCUMENTED"), "\n"); + if (cmd.Info.Permission ~= nil) then + f:write("Permission required: ", cmd.Info.Permission, "\n"); + end + if (cmd.Info.DetailedDescription ~= nil) then + f:write(cmd.Info.DetailedDescription); + end + end + f:write("[/list]\n\n") +end + + + + + +local function DumpCommandsForum(a_PluginInfo, f) + -- Copy all Categories from a dictionary into an array: + local Categories = BuildCategories(a_PluginInfo); + + -- Sort the categories by name: + table.sort(Categories, + function(cat1, cat2) + return (string.lower(cat1.Name) < string.lower(cat2.Name)); + end + ); + + -- Dump per-category commands: + for idx, cat in ipairs(Categories) do + WriteCommandsCategoryForum(cat, f); + end +end + + + + + +local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) + -- Open the output file: + local f, msg = io.open(a_PluginInfo.Name .. "_forum.txt", "w"); + if (f == nil) then + print("\tCannot dump forum info for plugin " .. a_PluginFolder .. ": " .. msg); + return; + end + + -- Write the description: + f:write(a_PluginInfo.Description); + + DumpCommandsForum(a_PluginInfo, f); + + -- TODO: Write the AdditionalInfo + + f:close(); +end + + + + + +local function DumpPluginInfoGitHub() + -- TODO +end + + + + + +--- Tries to load the g_PluginInfo from the plugin's Info.lua file +-- Returns the g_PluginInfo table on success, or nil and error message on failure +local function LoadPluginInfo(a_FolderName) + -- Check if the Info file is present at all: + local Attribs = lfs.attributes(a_FolderName .. "/Info.lua"); + if ((Attribs == nil) or (Attribs.mode ~= "file")) then + return nil; + end + + -- Load and compile the Info file: + local cfg, err = loadfile(a_FolderName .. "/Info.lua"); + if (cfg == nil) then + return nil, "Cannot open 'Info.lua': " .. err; + end + + -- Execute the loaded file in a sandbox: + -- This is Lua-5.1-specific and won't work in Lua 5.2! + local Sandbox = {}; + setfenv(cfg, Sandbox); + cfg(); + if (Sandbox.g_PluginInfo == nil) then + return nil, "Info.lua doesn't contain the g_PluginInfo declaration"; + end + return Sandbox.g_PluginInfo; +end + + + + + +local function ProcessPluginFolder(a_FolderName) + local PluginInfo, Msg = LoadPluginInfo(a_FolderName); + if (PluginInfo == nil) then + if (Msg ~= nil) then + print("\tCannot load Info.lua: " .. Msg); + end + return; + end + DumpPluginInfoForum(a_FolderName, PluginInfo); +end + + + + + +print("Processing plugin subfolders:"); +for fnam in lfs.dir(".") do + if ((fnam ~= ".") and (fnam ~= "..")) then + local Attributes = lfs.attributes(fnam); + if (Attributes ~= nil) then + if (Attributes.mode == "directory") then + print(fnam); + ProcessPluginFolder(fnam); + end + end + end +end + + + + From da2e7c25b0718fec6cfa6d90875b9985c9f78c72 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 4 Jan 2014 15:36:27 +0100 Subject: [PATCH 065/144] InfoDump: added AdditionalInfo to forum dumps. --- MCServer/Plugins/InfoDump.lua | 51 ++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 5b2e2077..d505eb42 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -48,6 +48,26 @@ lfs = require("lfs"); +--- Replaces generic formatting with forum-specific formatting +-- Also removes the single line-ends +local function ForumizeString(a_Str) + assert(type(a_Str) == "string"); + + -- Replace line ends with {%p} when multiple and space when single, so that manual word-wrap in the Info.lua file is fixed + a_Str = a_Str:gsub("\n\n", "{%%p}"); + a_Str = a_Str:gsub("\n", " "); + + -- Replace the generic formatting: + a_Str = a_Str:gsub("{%%p}", "\n\n"); + -- TODO: Other formatting + + return a_Str; +end + + + + + --- Returns an array-table of all commands that are in the specified category -- Each item is a table {Command = "/command string", Info = {}} local function GetCategoryCommands(a_PluginInfo, a_CategoryName) @@ -154,7 +174,7 @@ local function WriteCommandsCategoryForum(a_Category, f) if (CategoryName == "") then CategoryName = "General"; end - f:write("\n[size=Large]", CategoryName, "[/size]\n"); + f:write("\n[size=Large]", a_Category.DisplayName or CategoryName, "[/size]\n"); -- Write description: if (a_Category.Description ~= "") then @@ -190,6 +210,12 @@ local function DumpCommandsForum(a_PluginInfo, f) end ); + if (#Categories == 0) then + return; + end + + f:write("\n[size=X-Large]Commands[/size]\n"); + -- Dump per-category commands: for idx, cat in ipairs(Categories) do WriteCommandsCategoryForum(cat, f); @@ -200,6 +226,25 @@ end +local function DumpAdditionalInfoForum(a_PluginInfo, f) + local AInfo = a_PluginInfo.AdditionalInfo; + if ((AInfo == nil) or (type(AInfo) ~= "table")) then + -- There is no AdditionalInfo in a_PluginInfo + return; + end + + for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do + if ((info.Title ~= nil) and (info.Contents ~= nil)) then + f:write("\n[size=X-Large]", ForumizeString(info.Title), "[/size]\n"); + f:write(ForumizeString(info.Contents), "\n"); + end + end +end + + + + + local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) -- Open the output file: local f, msg = io.open(a_PluginInfo.Name .. "_forum.txt", "w"); @@ -210,10 +255,8 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) -- Write the description: f:write(a_PluginInfo.Description); - + DumpAdditionalInfoForum(a_PluginInfo, f); DumpCommandsForum(a_PluginInfo, f); - - -- TODO: Write the AdditionalInfo f:close(); end From 714cdc1e4a47ea00af5deb8d15185ce070287ffb Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 4 Jan 2014 17:34:45 +0000 Subject: [PATCH 066/144] added supported protocol --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ff30d63b..46a33e1f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ MCServer ======== +**Current Protocol Supported:** Minecraft v1.2 -> v1.7 + MCServer is a performant C++ Minecraft server designed for use in memory and cpu-limited places, or just to make regular server perform better. MCServer can run on PCs, Macs, and *nix. This includes android phones and tablets as well as Raspberry Pis. From 58e18b41f7340c6cf2f7e8df5a35758a9e8f5534 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 4 Jan 2014 19:23:21 +0100 Subject: [PATCH 067/144] InfoDump: Implemented list and formatting Forumizing. The exported strings are now parsed for basic formatting and list-related tags. --- MCServer/Plugins/InfoDump.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index d505eb42..1b27abef 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -53,12 +53,17 @@ lfs = require("lfs"); local function ForumizeString(a_Str) assert(type(a_Str) == "string"); - -- Replace line ends with {%p} when multiple and space when single, so that manual word-wrap in the Info.lua file is fixed + -- Replace multiple line ends with {%p} and single line ends with a space, + -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum a_Str = a_Str:gsub("\n\n", "{%%p}"); a_Str = a_Str:gsub("\n", " "); -- Replace the generic formatting: a_Str = a_Str:gsub("{%%p}", "\n\n"); + a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]"); + a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]"); + a_Str = a_Str:gsub("{%%list}", "[list]"):gsub("{%%/list}", "[/list]"); + a_Str = a_Str:gsub("{%%li}", "[*]"):gsub("{%%/li}", ""); -- TODO: Other formatting return a_Str; From b2ac22706414c296edf726ebd7f2865696964fb9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 4 Jan 2014 20:42:31 +0100 Subject: [PATCH 068/144] Added forum output for commands' DetailedHelp array. Also added some coloring to simulate syntax highlighting. --- MCServer/Plugins/InfoDump.lua | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 1b27abef..8adf4fea 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -173,6 +173,32 @@ end +--- Writes the specified command detailed help array to the output file, in the forum dump format +local function WriteCommandDetailedHelpForum(a_CmdString, a_DetailedHelp, f) + assert(type(a_CmdString) == "string"); + assert(type(a_DetailedHelp) == "table"); + assert(f ~= nil); + + if (#a_DetailedHelp == 0) then + -- No explicit parameter combinations to write + return; + end + + f:write("The following parameter combinations are recognized:\n"); + for idx, combination in ipairs(a_DetailedHelp) do + f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color] - ", combination.Help); + if (combination.Permission ~= nil) then + f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')"); + end + f:write("\n"); + end +end + + + + + +--- Writes all commands in the specified category to the output file, in the forum dump format local function WriteCommandsCategoryForum(a_Category, f) -- Write category name: local CategoryName = a_Category.Name; @@ -189,13 +215,16 @@ local function WriteCommandsCategoryForum(a_Category, f) -- Write commands: f:write("\n[list]"); for idx2, cmd in ipairs(a_Category.Commands) do - f:write("\nCommand: [b]", cmd.CommandString, "[/b] - ", (cmd.Info.HelpString or "UNDOCUMENTED"), "\n"); + f:write("\n[b]", cmd.CommandString, "[/b] - ", (cmd.Info.HelpString or "UNDOCUMENTED"), "\n"); if (cmd.Info.Permission ~= nil) then - f:write("Permission required: ", cmd.Info.Permission, "\n"); + f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n"); end if (cmd.Info.DetailedDescription ~= nil) then f:write(cmd.Info.DetailedDescription); end + if (cmd.Info.DetailedHelp ~= nil) then + WriteCommandDetailedHelpForum(cmd.CommandString, cmd.Info.DetailedHelp, f); + end end f:write("[/list]\n\n") end From 20da685002f9a1dcb1448ed4778ea43863193916 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 4 Jan 2014 22:11:19 +0100 Subject: [PATCH 069/144] InfoDump: All reasonable strings are forumized. --- MCServer/Plugins/InfoDump.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 8adf4fea..f140b0d8 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -186,7 +186,7 @@ local function WriteCommandDetailedHelpForum(a_CmdString, a_DetailedHelp, f) f:write("The following parameter combinations are recognized:\n"); for idx, combination in ipairs(a_DetailedHelp) do - f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color] - ", combination.Help); + f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color] - ", ForumizeString(combination.Help)); if (combination.Permission ~= nil) then f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')"); end @@ -205,17 +205,17 @@ local function WriteCommandsCategoryForum(a_Category, f) if (CategoryName == "") then CategoryName = "General"; end - f:write("\n[size=Large]", a_Category.DisplayName or CategoryName, "[/size]\n"); + f:write("\n[size=Large]", ForumizeString(a_Category.DisplayName or CategoryName), "[/size]\n"); -- Write description: if (a_Category.Description ~= "") then - f:write(a_Category.Description, "\n"); + f:write(ForumizeString(a_Category.Description), "\n"); end -- Write commands: f:write("\n[list]"); for idx2, cmd in ipairs(a_Category.Commands) do - f:write("\n[b]", cmd.CommandString, "[/b] - ", (cmd.Info.HelpString or "UNDOCUMENTED"), "\n"); + f:write("\n[b]", cmd.CommandString, "[/b] - ", ForumizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n"); if (cmd.Info.Permission ~= nil) then f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n"); end @@ -288,7 +288,7 @@ local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo) end -- Write the description: - f:write(a_PluginInfo.Description); + f:write(ForumizeString(a_PluginInfo.Description), "\n"); DumpAdditionalInfoForum(a_PluginInfo, f); DumpCommandsForum(a_PluginInfo, f); From f576b71809e824ac914de57ffeb8c66c47216207 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sun, 5 Jan 2014 08:27:59 +0000 Subject: [PATCH 070/144] Fix #506 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46a33e1f..9004c531 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ MCServer is licensed under the Apache license V2, and we welcome anybody to fork Other Stuff ----------- -For other stuff, including plugins and discussion, check the [forums](http://forum.mc-server.org) and [wiki](http://mc-server.org/wiki/). +For other stuff, including plugins and discussion, check the [forums](http://forum.mc-server.org) and [wiki](http://wiki.mc-server.org/). Earn bitcoins for commits or donate to reward the MCServer developers: [![tip for next commit](http://tip4commit.com/projects/74.svg)](http://tip4commit.com/projects/74) From 44cf86dcf98fa7c53eb59473e6eb9d8eb365de09 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 5 Jan 2014 15:04:57 +0100 Subject: [PATCH 071/144] InfoDump: Removed an unneeded function. --- MCServer/Plugins/InfoDump.lua | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index f140b0d8..54d7a604 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -73,34 +73,6 @@ end ---- Returns an array-table of all commands that are in the specified category --- Each item is a table {Command = "/command string", Info = {}} -local function GetCategoryCommands(a_PluginInfo, a_CategoryName) - local res = {}; - local function AppendCategoryCommand(a_Prefix, a_Commands) - for cmd, info in pairs(a_Commands) do - info.Category = info.Category or {}; - if (type(info.Category) == "string") then - info.Category = {info.Category}; - end - for idx, cat in ipairs(info.Category) do - if (cat == a_CategoryName) then - table.insert(res, {Command = a_Prefix .. cmd, Info = info}); - end - end - if (info.Subcommands ~= nil) then - AppendCategoryCommand(a_Prefix .. cmd .. " ", info.Subcommands); - end - end - end - AppendCategoryCommand("", a_PluginInfo.Commands); - return res; -end - - - - - --- Builds an array of categories, each containing all the commands belonging to the category, -- and the category description, if available. -- Returns the array table, each item has the following format: From 0a712931b1b547c7e7702ced73251e23dbc7737a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 5 Jan 2014 15:15:44 +0100 Subject: [PATCH 072/144] Fixed a race condition in the cQueue class. Fixes #505. --- VC2008/MCServer.vcproj | 4 ++ src/OSSupport/Queue.h | 147 ++++++++++++++++++++++++----------------- 2 files changed, 91 insertions(+), 60 deletions(-) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 491e7740..a017b5a2 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1578,6 +1578,10 @@ RelativePath="..\src\OSSupport\ListenThread.h" > + + diff --git a/src/OSSupport/Queue.h b/src/OSSupport/Queue.h index cde26e41..6c3d5829 100644 --- a/src/OSSupport/Queue.h +++ b/src/OSSupport/Queue.h @@ -19,123 +19,139 @@ implements the functions Delete() and Combine(). An example is given in cQueueFuncs and is used as the default behavior. */ -// this empty struct allows for the callback functions to be inlined +/// This empty struct allows for the callback functions to be inlined template struct cQueueFuncs { - public: - // Called when an Item is deleted form the queue without being returned - static void Delete(T) {}; - // Called when an Item is inserted with EnqueueItemIfNotPresent and - // there is another equal value already inserted - static void Combine(T& a_existing, const T& a_new) {}; +public: + + /// Called when an Item is deleted from the queue without being returned + static void Delete(T) {}; + + /// Called when an Item is inserted with EnqueueItemIfNotPresent and there is another equal value already inserted + static void Combine(T & a_existing, const T & a_new) {}; }; -template > + + + + +template > class cQueue { -// internal typedef for a List of Items -typedef typename std::list ListType; -// magic typedef to persuade clang that the iterator is a type -typedef typename ListType::iterator iterator; + // The actual storage type for the queue + typedef typename std::list QueueType; + + // Make iterator an alias for the QueueType's iterator + typedef typename QueueType::iterator iterator; + public: cQueue() {} ~cQueue() {} - // Enqueues an item to the queue, may block if other threads are accessing - // the queue. - void EnqueueItem(ItemType a_item) + + /// Enqueues an item to the queue, may block if other threads are accessing the queue. + void EnqueueItem(ItemType a_Item) { cCSLock Lock(m_CS); - m_contents.push_back(a_item); + m_Contents.push_back(a_Item); m_evtAdded.Set(); } - // Enqueues an item to the queue if not already present as determined with - // operator ==. Will block other threads from accessing the queue. - void EnqueueItemIfNotPresent(ItemType a_item) + + /// Enqueues an item in the queue if not already present (as determined by operator ==). Blocks other threads from accessing the queue. + void EnqueueItemIfNotPresent(ItemType a_Item) { cCSLock Lock(m_CS); - for (iterator itr = m_contents.begin(); itr != m_contents.end(); ++itr) + for (iterator itr = m_Contents.begin(); itr != m_Contents.end(); ++itr) { - if((*itr) == a_item) { - Funcs funcTable; - funcTable.Combine(*itr,a_item); + if ((*itr) == a_Item) + { + Funcs::Combine(*itr, a_Item); return; } } - m_contents.push_back(a_item); + m_Contents.push_back(a_Item); m_evtAdded.Set(); } - // Dequeues an Item from the queue if any are present. Returns true if - // successful. Value of item is undefined if Dequeuing was unsuccessful. - bool TryDequeueItem(ItemType& item) + + /// Dequeues an item from the queue if any are present. + /// Returns true if successful. Value of item is undefined if dequeuing was unsuccessful. + bool TryDequeueItem(ItemType & item) { cCSLock Lock(m_CS); - if (m_contents.size() == 0) + if (m_Contents.size() == 0) { return false; } - item = m_contents.front(); - m_contents.pop_front(); + item = m_Contents.front(); + m_Contents.pop_front(); m_evtRemoved.Set(); return true; } - // Dequeues an Item from the Queue, blocking until an Item is Available. - ItemType DequeueItem() + + /// Dequeues an item from the queue, blocking until an item is available. + ItemType DequeueItem(void) { cCSLock Lock(m_CS); - while (m_contents.size() == 0) + while (m_Contents.size() == 0) { - cCSUnlock Unlock(m_CS); + cCSUnlock Unlock(Lock); m_evtAdded.Wait(); } - ItemType item = m_contents.front(); - m_contents.pop_front(); + ItemType item = m_Contents.front(); + m_Contents.pop_front(); m_evtRemoved.Set(); return item; } - // Blocks Until the queue is Empty, Has a slight race condition which may - // cause it to miss the queue being empty. - void BlockTillEmpty() { - // There is a very slight race condition here if the load completes between the check - // and the wait. - while(!(Size() == 0)){m_evtRemoved.Wait();} - } - // Removes all Items from the Queue, calling Delete on each of them. - // can all be inlined when delete is a noop - void Clear() + /// Blocks until the queue is empty. + void BlockTillEmpty(void) { cCSLock Lock(m_CS); - Funcs funcTable; - while (!m_contents.empty()) + while (!m_Contents.empty()) { - funcTable.Delete(m_contents.front()); - m_contents.pop_front(); + cCSUnlock Unlock(Lock); + m_evtRemoved.Wait(); } } - // Returns the Size at time of being called - // Do not use to detirmine weather to call DequeueItem, use TryDequeue instead - size_t Size() + + /// Removes all Items from the Queue, calling Delete on each of them. + void Clear(void) { cCSLock Lock(m_CS); - return m_contents.size(); + while (!m_Contents.empty()) + { + Funcs::Delete(m_Contents.front()); + m_Contents.pop_front(); + } } - // Removes an Item from the queue - bool Remove(ItemType a_item) + + /// Returns the size at time of being called. + /// Do not use to determine whether to call DequeueItem(), use TryDequeueItem() instead + size_t Size(void) { cCSLock Lock(m_CS); - for (iterator itr = m_contents.begin(); itr != m_contents.end(); ++itr) + return m_Contents.size(); + } + + + /// Removes the item from the queue. If there are multiple such items, only the first one is removed. + /// Returns true if the item has been removed, false if no such item found. + bool Remove(ItemType a_Item) + { + cCSLock Lock(m_CS); + for (iterator itr = m_Contents.begin(); itr != m_Contents.end(); ++itr) { - if((*itr) == a_item) { - m_contents.erase(itr); + if ((*itr) == a_Item) + { + m_Contents.erase(itr); m_evtRemoved.Set(); return true; } @@ -144,8 +160,19 @@ public: } private: - ListType m_contents; + /// The contents of the queue + QueueType m_Contents; + + /// Mutex that protects access to the queue contents cCriticalSection m_CS; + + /// Event that is signalled when an item is added cEvent m_evtAdded; + + /// Event that is signalled when an item is removed (both dequeued or erased) cEvent m_evtRemoved; }; + + + + From 84bf32f857f890ce50c82a2612fe1bfe072886c9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 5 Jan 2014 15:46:45 +0100 Subject: [PATCH 073/144] Fixed cPluginManager:AddHook() binding. Fixes #401. Old formats are still accepted, for compatibility reasons. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- .../APIDump/Writing-a-MCServer-plugin.html | 6 +++--- MCServer/Plugins/APIDump/main_APIDump.lua | 2 +- MCServer/Plugins/Debuggers/Debuggers.lua | 19 +++++++++++++++++++ src/Bindings/ManualBindings.cpp | 19 +++++++++++++------ 5 files changed, 37 insertions(+), 11 deletions(-) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index d388d15d..26537918 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1713,7 +1713,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
function(Command, Permission, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature:
function (Command, HelpString)
. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, - Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" }, + Get = { Params = "", Return = "cPluginManager", Notes = "(STATIC) Returns the single instance of the plugin manager" }, GetAllPlugins = { Params = "", Return = "table", Notes = "Returns a table (dictionary) of all plugins, [name => {{cPlugin}}] pairing." }, GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" }, GetCurrentPlugin = { Params = "", Return = "{{cPlugin}}", Notes = "Returns the {{cPlugin}} object for the calling plugin. This is the same object that the Initialize function receives as the argument." }, diff --git a/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html b/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html index 50e39d53..0e07cebd 100644 --- a/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html +++ b/MCServer/Plugins/APIDump/Writing-a-MCServer-plugin.html @@ -84,7 +84,7 @@ end To register a hook, insert the following code template into the "-- Hooks" area in the previous code example.

-cPluginManager.AddHook(cPluginManager.HOOK_NAME_HERE, FunctionNameToBeCalled)
+cPluginManager:AddHook(cPluginManager.HOOK_NAME_HERE, FunctionNameToBeCalled)
 			

What does this code do? @@ -102,7 +102,7 @@ function Initialize(Plugin) Plugin:SetName("DerpyPlugin") Plugin:SetVersion(1) - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving) + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving) local PluginManager = cPluginManager:Get() -- Command bindings @@ -200,7 +200,7 @@ function Initialize(Plugin) local PluginManager = cPluginManager:Get() PluginManager:BindCommand("/explode", "derpyplugin.explode", Explode, " ~ Explode a player"); - cPluginManager.AddHook(cPluginManager.HOOK_COLLECTING_PICKUP, OnCollectingPickup) + cPluginManager:AddHook(cPluginManager.HOOK_COLLECTING_PICKUP, OnCollectingPickup) LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) return true diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index b3a95eb2..bd509dcb 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -1177,7 +1177,7 @@ function WriteHtmlHook(a_Hook, a_HookNav) f:write("\n

" .. (a_Hook.Returns or "") .. "

\n\n"); f:write([[

Code examples

Registering the callback

]]); f:write("
\n");
-	f:write([[cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
+	f:write([[cPluginManager:AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
 	f:write("
\n\n"); local Examples = a_Hook.CodeExamples or {}; for i, example in ipairs(Examples) do diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 8f2fa368..c769edc3 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -963,3 +963,22 @@ end + +-- Test the hook adding formats in #121 and #401 +local function DoNothing() +end + +LOG("Trying cPluginManager:AddHook()"); +cPluginManager:AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager.AddHook()"); +cPluginManager.AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager:Get():AddHook()"); +cPluginManager:Get():AddHook(cPluginManager.HOOK_CHAT, DoNothing); + +LOG("Trying cPluginManager:Get():AddHook(Plugin, Hook)"); +cPluginManager:Get():AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); + +LOG("Trying cPluginManager.AddHook(Plugin, Hook)"); +cPluginManager.AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 2e19c258..64f54288 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1137,16 +1137,17 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) { /* Function signatures: - cPluginManager.AddHook(HOOK_TYPE, CallbackFunction) -- (1) recommended - cPluginManager:Get():AddHook(HOOK_TYPE, CallbackFunction) -- (2) accepted silently - cPluginManager:Get():AddHook(Plugin, HOOK_TYPE) -- (3) old style (#121), accepted but complained about - cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (4) old style (#121) mangled, accepted but complained about + cPluginManager:AddHook(HOOK_TYPE, CallbackFunction) -- (1) recommended + cPluginManager.AddHook(HOOK_TYPE, CallbackFunction) -- (2) accepted silently (#401 deprecates this) + cPluginManager:Get():AddHook(HOOK_TYPE, CallbackFunction) -- (3) accepted silently + cPluginManager:Get():AddHook(Plugin, HOOK_TYPE) -- (4) old style (#121), accepted but complained about in the console + cPluginManager.AddHook(Plugin, HOOK_TYPE) -- (5) old style (#121) mangled, accepted but complained about in the console */ cLuaState S(tolua_S); cPluginManager * PlgMgr = cPluginManager::Get(); - // If the first param is a cPluginManager, use it instead of the global one: + // If the first param is a cPluginManager instance, use it instead of the global one: int ParamIdx = 1; tolua_Error err; if (tolua_isusertype(S, 1, "cPluginManager", 0, &err)) @@ -1161,6 +1162,12 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) } ParamIdx += 1; } + else if (tolua_isusertable(S, 1, "cPluginManager", 0, &err)) + { + LOGD("AddHook recommended style"); + // Style 1, use the global PlgMgr, but increment ParamIdx + ParamIdx++; + } if (lua_isnumber(S, ParamIdx) && lua_isfunction(S, ParamIdx + 1)) { @@ -1177,7 +1184,7 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) AString ParamDesc; Printf(ParamDesc, "%s, %s, %s", S.GetTypeText(1).c_str(), S.GetTypeText(2).c_str(), S.GetTypeText(3).c_str()); - LOGWARNING("cPluginManager.AddHook(): bad parameters. Expected HOOK_TYPE and CallbackFunction, got %s. Hook not added.", ParamDesc.c_str()); + LOGWARNING("cPluginManager:AddHook(): bad parameters. Expected HOOK_TYPE and CallbackFunction, got %s. Hook not added.", ParamDesc.c_str()); S.LogStackTrace(); return 0; } From 0d5b581fcd07c0bb61373abd6b0404215c0b2301 Mon Sep 17 00:00:00 2001 From: Diusrex Date: Sun, 5 Jan 2014 14:42:22 -0700 Subject: [PATCH 074/144] Making all of the useful level 4 warnings be active. --- src/Globals.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Globals.h b/src/Globals.h index 58badf4d..6a9b2050 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -14,7 +14,19 @@ #pragma warning(disable:4481) // Disable some warnings that we don't care about: - #pragma warning(disable:4100) + #pragma warning(disable:4100) // Unreferenced formal parameter + + // Useful warnings from warning level 4: + #pragma warning(3 : 4189) // Local variable is initialized but not referenced + #pragma warning(3 : 4702) // Unreachable code + #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch + #pragma warning(3 : 4389) // Signed/unsigned mismatch + #pragma warning(3 : 4701) // Potentially unitialized local variable used + #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data + #pragma warning(3 : 4310) // Cast truncates constant value + #pragma warning(3 : 4505) // Unreferenced local function has been removed + #pragma warning(3 : 4127) // Conditional expression is constant + #pragma warning(3 : 4706) // Assignment within conditional expression #define OBSOLETE __declspec(deprecated) From 2dbe5033ca30ce791e3cb28cc59f47d52225b7ae Mon Sep 17 00:00:00 2001 From: Diusrex Date: Sun, 5 Jan 2014 15:06:17 -0700 Subject: [PATCH 075/144] Added warning(push) and warning(pop) around all of the inclusions of cryptopp/*.h I also added a warning(push)/(pop) around crpytlib.cpp because it would go crazy with warnings. So now, the only warning from cryptopp that is not blocked is 'unreferenced local function has been removed', which also occurs at a single function. --- lib/cryptopp/cryptlib.cpp | 10 ++++++++++ src/Protocol/Protocol132.cpp | 13 ++++++++++++- src/Protocol/Protocol132.h | 14 ++++++++++++++ src/Protocol/Protocol14x.cpp | 13 ++++++++++++- src/Protocol/Protocol17x.h | 14 ++++++++++++++ src/Server.h | 17 ++++++++++++++++- 6 files changed, 78 insertions(+), 3 deletions(-) diff --git a/lib/cryptopp/cryptlib.cpp b/lib/cryptopp/cryptlib.cpp index df138ddb..661340b8 100644 --- a/lib/cryptopp/cryptlib.cpp +++ b/lib/cryptopp/cryptlib.cpp @@ -4,6 +4,12 @@ #ifndef CRYPTOPP_IMPORTS + +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4702) +#endif + #include "cryptlib.h" #include "misc.h" #include "filters.h" @@ -825,4 +831,8 @@ void AuthenticatedKeyAgreementDomain::GenerateEphemeralKeyPair(RandomNumberGener NAMESPACE_END +#ifdef _MSC_VER + #pragma warning(pop) +#endif + #endif diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index 46ac4ef8..ab15509b 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -5,7 +5,6 @@ #include "Globals.h" #include "ChunkDataSerializer.h" -#include "cryptopp/randpool.h" #include "Protocol132.h" #include "../Root.h" #include "../Server.h" @@ -19,8 +18,20 @@ #include "../WorldStorage/FastNBT.h" #include "../StringCompression.h" +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif +#include "cryptopp/randpool.h" +#ifdef _MSC_VER + #pragma warning(pop) +#endif #define HANDLE_PACKET_READ(Proc, Type, Var) \ diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h index f76272b8..d36384a8 100644 --- a/src/Protocol/Protocol132.h +++ b/src/Protocol/Protocol132.h @@ -10,9 +10,23 @@ #pragma once #include "Protocol125.h" + +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif + #include "cryptopp/modes.h" #include "cryptopp/aes.h" +#ifdef _MSC_VER + #pragma warning(pop) +#endif + diff --git a/src/Protocol/Protocol14x.cpp b/src/Protocol/Protocol14x.cpp index 28122034..926fe6ee 100644 --- a/src/Protocol/Protocol14x.cpp +++ b/src/Protocol/Protocol14x.cpp @@ -16,7 +16,6 @@ Implements the 1.4.x protocol classes representing these protocols: #include "../Root.h" #include "../Server.h" #include "../ClientHandle.h" -#include "cryptopp/randpool.h" #include "../Item.h" #include "ChunkDataSerializer.h" #include "../Entities/Player.h" @@ -25,8 +24,20 @@ Implements the 1.4.x protocol classes representing these protocols: #include "../Entities/Pickup.h" #include "../Entities/FallingBlock.h" +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif +#include "cryptopp/randpool.h" +#ifdef _MSC_VER + #pragma warning(pop) +#endif #define HANDLE_PACKET_READ(Proc, Type, Var) \ diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index cc0eda1e..23ff2365 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -16,9 +16,23 @@ Declares the 1.7.x protocol classes: #include "Protocol.h" #include "../ByteBuffer.h" + +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif + #include "cryptopp/modes.h" #include "cryptopp/aes.h" +#ifdef _MSC_VER + #pragma warning(pop) +#endif + diff --git a/src/Server.h b/src/Server.h index 1f94bb3d..e62c4c7b 100644 --- a/src/Server.h +++ b/src/Server.h @@ -11,9 +11,24 @@ #include "OSSupport/SocketThreads.h" #include "OSSupport/ListenThread.h" + +#include "RCONServer.h" + +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) + #pragma warning(disable:4244) + #pragma warning(disable:4231) + #pragma warning(disable:4189) + #pragma warning(disable:4702) +#endif + #include "cryptopp/rsa.h" #include "cryptopp/randpool.h" -#include "RCONServer.h" + +#ifdef _MSC_VER + #pragma warning(pop) +#endif From 1acbf07445d4dbd2d8badd3a4be709ebc4cb2a3e Mon Sep 17 00:00:00 2001 From: Diusrex Date: Sun, 5 Jan 2014 15:07:46 -0700 Subject: [PATCH 076/144] Changed the release version of ASSERT. This was so a variable only used in ASSERT statements will not give a warning about not being used. --- src/Globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Globals.h b/src/Globals.h index 6a9b2050..a761da40 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -204,7 +204,7 @@ typedef unsigned short UInt16; #ifdef _DEBUG #define ASSERT( x ) ( !!(x) || ( LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), assert(0), 0 ) ) #else - #define ASSERT(x) ((void)0) + #define ASSERT(x) ((void)(x)) #endif // Pretty much the same as ASSERT() but stays in Release builds From 487c1a24de3c375365c77232a47b99ddef0de68b Mon Sep 17 00:00:00 2001 From: Diusrex Date: Sun, 5 Jan 2014 15:08:30 -0700 Subject: [PATCH 077/144] Added fake functions into cCriticalSection because of the change to ASSERT --- src/OSSupport/CriticalSection.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OSSupport/CriticalSection.h b/src/OSSupport/CriticalSection.h index 1bfe8143..73a71f5e 100644 --- a/src/OSSupport/CriticalSection.h +++ b/src/OSSupport/CriticalSection.h @@ -14,9 +14,14 @@ public: void Lock(void); void Unlock(void); + // IsLocked/IsLockedByCurrentThread are only used in ASSERT statements, but because of the changes with ASSERT they must always be defined + // The fake versions (in Release) will not effect the program in any way #ifdef _DEBUG bool IsLocked(void); bool IsLockedByCurrentThread(void); + #else + bool IsLocked(void) { return false; } + bool IsLockedByCurrentThread(void) { return false; } #endif // _DEBUG private: From c9c71fe5a75992672013d021a918054b4795385b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 10:09:00 +0100 Subject: [PATCH 078/144] Fixed wrong enqueueing. Fixes #505. --- src/WorldStorage/WorldStorage.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/WorldStorage/WorldStorage.cpp b/src/WorldStorage/WorldStorage.cpp index 5f4c112d..6aec525a 100644 --- a/src/WorldStorage/WorldStorage.cpp +++ b/src/WorldStorage/WorldStorage.cpp @@ -117,6 +117,10 @@ void cWorldStorage::WaitForLoadQueueEmpty(void) m_LoadQueue.BlockTillEmpty(); } + + + + void cWorldStorage::WaitForSaveQueueEmpty(void) { m_SaveQueue.BlockTillEmpty(); @@ -124,6 +128,8 @@ void cWorldStorage::WaitForSaveQueueEmpty(void) + + size_t cWorldStorage::GetLoadQueueLength(void) { return m_LoadQueue.Size(); @@ -144,8 +150,8 @@ size_t cWorldStorage::GetSaveQueueLength(void) void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, bool a_Generate) { - m_Event.Set(); m_LoadQueue.EnqueueItemIfNotPresent(sChunkLoad(a_ChunkX, a_ChunkY, a_ChunkZ, a_Generate)); + m_Event.Set(); } @@ -154,8 +160,8 @@ void cWorldStorage::QueueLoadChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, boo void cWorldStorage::QueueSaveChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { - m_Event.Set(); m_SaveQueue.EnqueueItemIfNotPresent(cChunkCoords(a_ChunkX, a_ChunkY, a_ChunkZ)); + m_Event.Set(); } @@ -166,6 +172,7 @@ void cWorldStorage::QueueSavedMessage(void) { // Pushes a special coord pair into the queue, signalizing a message instead m_SaveQueue.EnqueueItem(cChunkCoords(0, CHUNK_Y_MESSAGE, 0)); + m_Event.Set(); } From 4b54f3e3ea9aa9cc80bd5eab9066b186e6dec25e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 10:13:19 +0100 Subject: [PATCH 079/144] Output dir set to $/MCServer. Ref.: #510. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bd06798f..85313876 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,7 +66,7 @@ set(EXECUTABLE MCServer) add_executable(${EXECUTABLE} ${SOURCE}) -set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/MCServer) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer) if (MSVC) # MSVC generator adds a "Debug" or "Release" postfixes to the EXECUTABLE_OUTPUT_PATH, we need to cancel them: From 8b6be58ad9c5f0769b3982501e806fd9a21b1756 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 10:25:52 +0100 Subject: [PATCH 080/144] InfoDump: Removes indent and parses ParameterCombinations. The DetailedHelp was a bad name for what it really contained, so it has been renamed to ParameterCombinations. --- MCServer/Plugins/InfoDump.lua | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 54d7a604..df47d566 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -53,8 +53,24 @@ lfs = require("lfs"); local function ForumizeString(a_Str) assert(type(a_Str) == "string"); + -- Remove the indentation, unless in the code tag: + -- Only one code or /code tag per line is supported! + local IsInCode = false; + local function RemoveIndentIfNotInCode(s) + if (IsInCode) then + -- we're in code section, check if this line terminates it + IsInCode = (s:find("{%%/code}") ~= nil); + return s .. "\n"; + else + -- we're not in code section, check if this line starts it + IsInCode = (s:find("{%%code}") ~= nil); + return s:gsub("^%s*", "") .. "\n"; + end + end + a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode); + -- Replace multiple line ends with {%p} and single line ends with a space, - -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum + -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum. a_Str = a_Str:gsub("\n\n", "{%%p}"); a_Str = a_Str:gsub("\n", " "); @@ -146,19 +162,22 @@ end --- Writes the specified command detailed help array to the output file, in the forum dump format -local function WriteCommandDetailedHelpForum(a_CmdString, a_DetailedHelp, f) +local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string"); - assert(type(a_DetailedHelp) == "table"); + assert(type(a_ParameterCombinations) == "table"); assert(f ~= nil); - if (#a_DetailedHelp == 0) then + if (#a_ParameterCombinations == 0) then -- No explicit parameter combinations to write return; end f:write("The following parameter combinations are recognized:\n"); - for idx, combination in ipairs(a_DetailedHelp) do - f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color] - ", ForumizeString(combination.Help)); + for idx, combination in ipairs(a_ParameterCombinations) do + f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color]"); + if (combination.Help ~= nil) then + f:write(" - ", ForumizeString(combination.Help)); + end if (combination.Permission ~= nil) then f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')"); end @@ -194,8 +213,8 @@ local function WriteCommandsCategoryForum(a_Category, f) if (cmd.Info.DetailedDescription ~= nil) then f:write(cmd.Info.DetailedDescription); end - if (cmd.Info.DetailedHelp ~= nil) then - WriteCommandDetailedHelpForum(cmd.CommandString, cmd.Info.DetailedHelp, f); + if (cmd.Info.ParameterCombinations ~= nil) then + WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f); end end f:write("[/list]\n\n") From 0d5a5cc990a9674bdf53000285076491fce1356f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 16:01:20 +0100 Subject: [PATCH 081/144] Exported cWorld::BroadcastBlockAction(). As requested in #508; no guarantees about it. --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.h b/src/World.h index 67f1275c..f90ddd90 100644 --- a/src/World.h +++ b/src/World.h @@ -146,7 +146,7 @@ public: // Broadcast respective packets to all clients of the chunk where the event is taking place // (Please keep these alpha-sorted) void BroadcastAttachEntity (const cEntity & a_Entity, const cEntity * a_Vehicle); - void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL); + void BroadcastBlockAction (int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude = NULL); // tolua_export void BroadcastBlockBreakAnimation(int a_EntityID, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Stage, const cClientHandle * a_Exclude = NULL); void BroadcastBlockEntity (int a_BlockX, int a_BlockY, int a_BlockZ, const cClientHandle * a_Exclude = NULL); ///< If there is a block entity at the specified coods, sends it to all clients except a_Exclude void BroadcastChat (const AString & a_Message, const cClientHandle * a_Exclude = NULL); // tolua_export From ed9a500d6bd87cef3bb1039c2bdc2ad6d9c9b952 Mon Sep 17 00:00:00 2001 From: Diusrex Date: Mon, 6 Jan 2014 10:12:40 -0700 Subject: [PATCH 082/144] Undid the changes to cryptlib.cpp. Instead, altered the VC2008 cryptopp project settings. Someone else will probably need to do the same thing for the 2013 version, since I don't have access to VC2013. --- VC2008/CryptoPP.vcproj | 3 ++- lib/cryptopp/cryptlib.cpp | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/VC2008/CryptoPP.vcproj b/VC2008/CryptoPP.vcproj index a818e9aa..f44729d8 100644 --- a/VC2008/CryptoPP.vcproj +++ b/VC2008/CryptoPP.vcproj @@ -1,7 +1,7 @@ Date: Mon, 6 Jan 2014 22:22:33 +0100 Subject: [PATCH 083/144] Fixed a few MSVC warnings. --- src/BlockEntities/FurnaceEntity.cpp | 8 ++++---- src/BlockEntities/HopperEntity.cpp | 1 - src/HTTPServer/HTTPConnection.cpp | 2 +- src/HTTPServer/HTTPFormParser.cpp | 1 - src/HTTPServer/NameValueParser.cpp | 1 - src/Item.cpp | 2 +- src/Item.h | 4 ++-- src/Protocol/Protocol132.cpp | 4 ++-- src/Protocol/Protocol15x.cpp | 2 +- src/Protocol/Protocol17x.cpp | 1 - src/Protocol/ProtocolRecognizer.cpp | 2 +- 11 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/BlockEntities/FurnaceEntity.cpp b/src/BlockEntities/FurnaceEntity.cpp index b1409f5c..f1555396 100644 --- a/src/BlockEntities/FurnaceEntity.cpp +++ b/src/BlockEntities/FurnaceEntity.cpp @@ -70,8 +70,8 @@ void cFurnaceEntity::UsedBy(cPlayer * a_Player) if (a_Player->GetWindow() != Window) { a_Player->OpenWindow(Window); - BroadcastProgress(PROGRESSBAR_FUEL, m_LastProgressFuel); - BroadcastProgress(PROGRESSBAR_SMELTING, m_LastProgressCook); + BroadcastProgress(PROGRESSBAR_FUEL, (short)m_LastProgressFuel); + BroadcastProgress(PROGRESSBAR_SMELTING, (short)m_LastProgressCook); } } } @@ -445,14 +445,14 @@ void cFurnaceEntity::UpdateProgressBars(void) int CurFuel = (m_FuelBurnTime > 0) ? (200 - 200 * m_TimeBurned / m_FuelBurnTime) : 0; if ((CurFuel / 8) != (m_LastProgressFuel / 8)) { - BroadcastProgress(PROGRESSBAR_FUEL, CurFuel); + BroadcastProgress(PROGRESSBAR_FUEL, (short)CurFuel); m_LastProgressFuel = CurFuel; } int CurCook = (m_NeedCookTime > 0) ? (200 * m_TimeCooked / m_NeedCookTime) : 0; if ((CurCook / 8) != (m_LastProgressCook / 8)) { - BroadcastProgress(PROGRESSBAR_SMELTING, CurCook); + BroadcastProgress(PROGRESSBAR_SMELTING, (short)CurCook); m_LastProgressCook = CurCook; } } diff --git a/src/BlockEntities/HopperEntity.cpp b/src/BlockEntities/HopperEntity.cpp index 0aca3209..eac59e74 100644 --- a/src/BlockEntities/HopperEntity.cpp +++ b/src/BlockEntities/HopperEntity.cpp @@ -488,7 +488,6 @@ bool cHopperEntity::MoveItemsToFurnace(cChunk & a_Chunk, int a_BlockX, int a_Blo // Feed the fuel slot of the furnace return MoveItemsToSlot(*Furnace, cFurnaceEntity::fsFuel); } - return false; } diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 68afdfc1..3d30ab17 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -57,7 +57,7 @@ void cHTTPConnection::SendNeedAuth(const AString & a_Realm) void cHTTPConnection::Send(const cHTTPResponse & a_Response) { - ASSERT(m_State = wcsRecvIdle); + ASSERT(m_State == wcsRecvIdle); a_Response.AppendToData(m_OutgoingData); m_State = wcsSendingResp; m_HTTPServer.NotifyConnectionWrite(*this); diff --git a/src/HTTPServer/HTTPFormParser.cpp b/src/HTTPServer/HTTPFormParser.cpp index 01c68881..e661ea6f 100644 --- a/src/HTTPServer/HTTPFormParser.cpp +++ b/src/HTTPServer/HTTPFormParser.cpp @@ -133,7 +133,6 @@ bool cHTTPFormParser::HasFormData(const cHTTPRequest & a_Request) (a_Request.GetURL().find('?') != AString::npos) ) ); - return false; } diff --git a/src/HTTPServer/NameValueParser.cpp b/src/HTTPServer/NameValueParser.cpp index fd56f6b2..9ea8594a 100644 --- a/src/HTTPServer/NameValueParser.cpp +++ b/src/HTTPServer/NameValueParser.cpp @@ -253,7 +253,6 @@ void cNameValueParser::Parse(const char * a_Data, int a_Size) m_State = psValueRaw; break; } - i++; } // while (i < a_Size) break; } // case psEqual diff --git a/src/Item.cpp b/src/Item.cpp index 196a260e..a4451501 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -246,7 +246,7 @@ void cItems::Delete(int a_Idx) -void cItems::Set(int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage) +void cItems::Set(int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage) { if ((a_Idx < 0) || (a_Idx >= (int)size())) { diff --git a/src/Item.h b/src/Item.h index c60d0542..64a30ade 100644 --- a/src/Item.h +++ b/src/Item.h @@ -181,9 +181,9 @@ public: void Delete(int a_Idx); void Clear (void) {clear(); } int Size (void) {return size(); } - void Set (int a_Idx, ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage); + void Set (int a_Idx, short a_ItemType, char a_ItemCount, short a_ItemDamage); - void Add (ENUM_ITEM_ID a_ItemType, char a_ItemCount, short a_ItemDamage) + void Add (short a_ItemType, char a_ItemCount, short a_ItemDamage) { push_back(cItem(a_ItemType, a_ItemCount, a_ItemDamage)); } diff --git a/src/Protocol/Protocol132.cpp b/src/Protocol/Protocol132.cpp index ab15509b..302d1298 100644 --- a/src/Protocol/Protocol132.cpp +++ b/src/Protocol/Protocol132.cpp @@ -877,7 +877,7 @@ void cProtocol132::SendCompass(const cWorld & a_World) void cProtocol132::SendEncryptionKeyRequest(void) { cCSLock Lock(m_CSPacket); - WriteByte((char)0xfd); + WriteByte(0xfd); WriteString(cRoot::Get()->GetServer()->GetServerID()); WriteShort((short)m_ServerPublicKey.size()); SendData(m_ServerPublicKey.data(), m_ServerPublicKey.size()); @@ -925,7 +925,7 @@ void cProtocol132::HandleEncryptionKeyResponse(const AString & a_EncKey, const A { // Send encryption key response: cCSLock Lock(m_CSPacket); - WriteByte((char)0xfc); + WriteByte(0xfc); WriteShort(0); WriteShort(0); Flush(); diff --git a/src/Protocol/Protocol15x.cpp b/src/Protocol/Protocol15x.cpp index 7e2aa949..0f1e59f1 100644 --- a/src/Protocol/Protocol15x.cpp +++ b/src/Protocol/Protocol15x.cpp @@ -112,7 +112,7 @@ int cProtocol150::ParseWindowClick(void) } // Convert Button, Mode, SlotNum and HeldItem into eClickAction: - eClickAction Action; + eClickAction Action = caUnknown; switch ((Mode << 8) | Button) { case 0x0000: Action = (SlotNum != -999) ? caLeftClick : caLeftClickOutside; break; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index bbbd5e97..8536689c 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -986,7 +986,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size) while (true) { UInt32 PacketLen; - int PacketStart = m_ReceivedData.GetDataStart(); if (!m_ReceivedData.ReadVarInt(PacketLen)) { // Not enough data diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index 1cae4a75..e2ea0e6e 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -198,7 +198,7 @@ void cProtocolRecognizer::SendDisconnect(const AString & a_Reason) else { // This is used when the client sends a server-ping, respond with the default packet: - WriteByte ((char)0xff); // PACKET_DISCONNECT + WriteByte (0xff); // PACKET_DISCONNECT WriteString(a_Reason); } } From 778c329ad2ff9af5595b695fc264b9fc2ad3d538 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 6 Jan 2014 22:23:03 +0100 Subject: [PATCH 084/144] Disabled the type conversion MSVC warning. It was hitting way too many false positives. --- src/Globals.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Globals.h b/src/Globals.h index a761da40..1765c53d 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -22,11 +22,13 @@ #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch #pragma warning(3 : 4389) // Signed/unsigned mismatch #pragma warning(3 : 4701) // Potentially unitialized local variable used - #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data #pragma warning(3 : 4310) // Cast truncates constant value #pragma warning(3 : 4505) // Unreferenced local function has been removed #pragma warning(3 : 4127) // Conditional expression is constant #pragma warning(3 : 4706) // Assignment within conditional expression + + // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places + // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data #define OBSOLETE __declspec(deprecated) From e3bb82d95a0bf270f9d43d0504bf155b52dc516b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 12:36:36 +0100 Subject: [PATCH 085/144] Added Base64Encode(). --- src/StringUtils.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++ src/StringUtils.h | 3 +++ 2 files changed, 51 insertions(+) diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 5c6b99d8..8d235233 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -765,6 +765,54 @@ AString Base64Decode(const AString & a_Base64String) +AString Base64Encode(const AString & a_Input) +{ + static const char BASE64[64] = { + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', + 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', + 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', + 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' + }; + + std::string output; + output.resize(((a_Input.size() + 2) / 3) * 4); + + size_t output_index = 0; + size_t size_full24 = (a_Input.size() / 3) * 3; + + for (size_t i = 0; i < size_full24; i += 3) + { + output[output_index++] = BASE64[(unsigned char)a_Input[i] >> 2]; + output[output_index++] = BASE64[((unsigned char)a_Input[i] << 4 | (unsigned char)a_Input[i + 1] >> 4) & 63]; + output[output_index++] = BASE64[((unsigned char)a_Input[i + 1] << 2 | (unsigned char)a_Input[i + 2] >> 6) & 63]; + output[output_index++] = BASE64[(unsigned char)a_Input[i + 2] & 63]; + } + + if (size_full24 < a_Input.size()) + { + output[output_index++] = BASE64[(unsigned char)a_Input[size_full24] >> 2]; + if (size_full24 + 1 == a_Input.size()) + { + output[output_index++] = BASE64[((unsigned char)a_Input[size_full24] << 4) & 63]; + output[output_index++] = '='; + } + else + { + output[output_index++] = BASE64[((unsigned char)a_Input[size_full24] << 4 | (unsigned char)a_Input[size_full24 + 1] >> 4) & 63]; + output[output_index++] = BASE64[((unsigned char)a_Input[size_full24 + 1] << 2) & 63]; + } + + output[output_index++] = '='; + } + assert(output_index == output.size()); + + return output; +} + + + + + short GetBEShort(const char * a_Mem) { return (((short)a_Mem[0]) << 8) | a_Mem[1]; diff --git a/src/StringUtils.h b/src/StringUtils.h index 471e843e..2373f384 100644 --- a/src/StringUtils.h +++ b/src/StringUtils.h @@ -81,6 +81,9 @@ extern AString ReplaceAllCharOccurrences(const AString & a_String, char a_From, /// Decodes a Base64-encoded string into the raw data extern AString Base64Decode(const AString & a_Base64String); +/// Encodes a string into Base64 +extern AString Base64Encode(const AString & a_Input); + /// Reads two bytes from the specified memory location and interprets them as BigEndian short extern short GetBEShort(const char * a_Mem); From 623146996a6a75cd7218bc6a0756511aabfd5098 Mon Sep 17 00:00:00 2001 From: Tycho Date: Tue, 7 Jan 2014 05:08:58 -0800 Subject: [PATCH 086/144] Fixed FreeBSD compilition --- CMakeLists.txt | 11 +++++++++++ lib/lua/CMakeLists.txt | 2 +- lib/sqlite/CMakeLists.txt | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45185407..135826ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,17 @@ if (WIN32) add_definitions(-DLUA_BUILD_AS_DLL) endif() +#On Unix we use two dynamic loading libraries dl and ltdl. +#Preference is for dl on unknown systems as it is specified in POSIX +#the dynamic loader is used by lua and sqllite. +if (UNIX) + if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(DYNAMIC_LOADER ltdl) + else() + set(DYNAMIC_LOADER dl) + endif() +endif() + # The Expat library is linked in statically, make the source files aware of that: add_definitions(-DXML_STATIC) diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt index 63ac18e9..b4b5b5f1 100644 --- a/lib/lua/CMakeLists.txt +++ b/lib/lua/CMakeLists.txt @@ -26,5 +26,5 @@ else() endif() if (UNIX) - target_link_libraries(lua m dl) + target_link_libraries(lua m ${DYNAMIC_LOADER}) endif() diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index 07e5a22c..0815127e 100644 --- a/lib/sqlite/CMakeLists.txt +++ b/lib/sqlite/CMakeLists.txt @@ -21,5 +21,5 @@ endif() add_library(sqlite ${SOURCE}) if (UNIX) - target_link_libraries(sqlite dl) + target_link_libraries(sqlite ${DYNAMIC_LOADER}) endif() From 934b90c121def4f6f9a7c919727cadeeca49981f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 14:24:25 +0100 Subject: [PATCH 087/144] Fixed a few MSVC warnings. --- src/BlockArea.cpp | 6 +++--- src/Generating/Caves.cpp | 8 ++++---- src/Generating/DistortedHeightmap.cpp | 3 ++- src/Generating/FinishGen.cpp | 2 +- src/Items/ItemSeeds.h | 1 - src/Protocol/Protocol132.h | 4 ++-- src/Protocol/Protocol17x.cpp | 2 +- src/WorldStorage/FastNBT.cpp | 13 ++++++++----- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/BlockArea.cpp b/src/BlockArea.cpp index dd8e0da3..910661f6 100644 --- a/src/BlockArea.cpp +++ b/src/BlockArea.cpp @@ -828,7 +828,7 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int int yd = dy - dx / 2; int zd = dz - dx / 2; - while (true) + for (;;) { RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight); @@ -860,7 +860,7 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int int xd = dx - dy / 2; int zd = dz - dy / 2; - while (true) + for (;;) { RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight); @@ -894,7 +894,7 @@ void cBlockArea::RelLine(int a_RelX1, int a_RelY1, int a_RelZ1, int a_RelX2, int int xd = dx - dz / 2; int yd = dy - dz / 2; - while (true) + for (;;) { RelSetData(a_RelX1, a_RelY1, a_RelZ1, a_DataTypes, a_BlockType, a_BlockMeta, a_BlockLight, a_BlockSkyLight); diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index df45bb4c..c94113f5 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -285,7 +285,7 @@ bool cCaveTunnel::RefineDefPoints(const cCaveDefPoints & a_Src, cCaveDefPoints & void cCaveTunnel::Smooth(void) { cCaveDefPoints Pts; - while (true) + for (;;) { if (!RefineDefPoints(m_Points, Pts)) { @@ -331,7 +331,7 @@ void cCaveTunnel::FinishLinear(void) int yd = dy - dx / 2; int zd = dz - dx / 2; - while (true) + for (;;) { m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); @@ -363,7 +363,7 @@ void cCaveTunnel::FinishLinear(void) int xd = dx - dy / 2; int zd = dz - dy / 2; - while (true) + for (;;) { m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); @@ -397,7 +397,7 @@ void cCaveTunnel::FinishLinear(void) int xd = dx - dz / 2; int yd = dy - dz / 2; - while (true) + for (;;) { m_Points.push_back(cCaveDefPoint(PrevX, PrevY, PrevZ, R)); diff --git a/src/Generating/DistortedHeightmap.cpp b/src/Generating/DistortedHeightmap.cpp index 15e352e3..eb9fe92b 100644 --- a/src/Generating/DistortedHeightmap.cpp +++ b/src/Generating/DistortedHeightmap.cpp @@ -774,10 +774,11 @@ void cDistortedHeightmap::ComposeColumn(cChunkDesc & a_ChunkDesc, int a_RelX, in return; } default: + { ASSERT(!"Unhandled biome"); return; + } } // switch (Biome) - ASSERT(!"Unexpected fallthrough"); } diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 866551e8..145fe22e 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -528,7 +528,7 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI bool IsWater = (a_Fluid == E_BLOCK_WATER); AString SectionName = IsWater ? "WaterSprings" : "LavaSprings"; AString DefaultHeightDistribution; - int DefaultChance; + int DefaultChance = 0; switch (a_World.GetDimension()) { case dimNether: diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h index 8ca86663..67f0d38b 100644 --- a/src/Items/ItemSeeds.h +++ b/src/Items/ItemSeeds.h @@ -56,7 +56,6 @@ public: case E_ITEM_SEEDS: a_BlockType = E_BLOCK_CROPS; return true; default: a_BlockType = E_BLOCK_AIR; return true; } - return false; } } ; diff --git a/src/Protocol/Protocol132.h b/src/Protocol/Protocol132.h index d36384a8..80fc8740 100644 --- a/src/Protocol/Protocol132.h +++ b/src/Protocol/Protocol132.h @@ -14,9 +14,9 @@ #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4127) - #pragma warning(disable:4244) - #pragma warning(disable:4231) #pragma warning(disable:4189) + #pragma warning(disable:4231) + #pragma warning(disable:4244) #pragma warning(disable:4702) #endif diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 8536689c..7d1f723a 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -983,7 +983,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size) } // Handle all complete packets: - while (true) + for (;;) { UInt32 PacketLen; if (!m_ReceivedData.ReadVarInt(PacketLen)) diff --git a/src/WorldStorage/FastNBT.cpp b/src/WorldStorage/FastNBT.cpp index 64220f09..8f80c3f7 100644 --- a/src/WorldStorage/FastNBT.cpp +++ b/src/WorldStorage/FastNBT.cpp @@ -16,9 +16,12 @@ #define NBT_RESERVE_SIZE 200 #endif // NBT_RESERVE_SIZE -#define RETURN_FALSE_IF_FALSE(X) do { if (!X) return false; } while (0) - - +#ifdef _MSC_VER + // Dodge a C4127 (conditional expression is constant) for this specific macro usage + #define RETURN_FALSE_IF_FALSE(X) do { if (!X) return false; } while ((false, false)) +#else + #define RETURN_FALSE_IF_FALSE(X) do { if (!X) return false; } while (false) +#endif @@ -99,7 +102,7 @@ bool cParsedNBT::ReadCompound(void) // Reads the latest tag as a compound int ParentIdx = m_Tags.size() - 1; int PrevSibling = -1; - while (true) + for (;;) { NEEDBYTES(1); eTagType TagType = (eTagType)(m_Data[m_Pos]); @@ -276,7 +279,7 @@ int cParsedNBT::FindChildByName(int a_Tag, const char * a_Name, size_t a_NameLen for (int Child = m_Tags[a_Tag].m_FirstChild; Child != -1; Child = m_Tags[Child].m_NextSibling) { if ( - (m_Tags[Child].m_NameLength == a_NameLength) && + (m_Tags[Child].m_NameLength == (int)a_NameLength) && (memcmp(m_Data + m_Tags[Child].m_NameStart, a_Name, a_NameLength) == 0) ) { From a43f819bba8658ce5c7979777d36da4ff217d8c7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 7 Jan 2014 14:09:03 +0000 Subject: [PATCH 088/144] Regenerated VS2013 files --- VC2013/CryptoPP.vcxproj | 1 + VC2013/CryptoPP.vcxproj.filters | 6 +-- VC2013/MCServer.vcxproj | 7 ++-- VC2013/MCServer.vcxproj.filters | 67 +++++++++++++++++---------------- VC2013/ToLua.vcxproj | 1 + VC2013/ToLua.vcxproj.filters | 3 ++ 6 files changed, 47 insertions(+), 38 deletions(-) diff --git a/VC2013/CryptoPP.vcxproj b/VC2013/CryptoPP.vcxproj index 7ad8edaf..6f7ddae0 100644 --- a/VC2013/CryptoPP.vcxproj +++ b/VC2013/CryptoPP.vcxproj @@ -186,6 +186,7 @@ Level3 true ProgramDatabase + 4702;%(DisableSpecificWarnings) 0x0409 diff --git a/VC2013/CryptoPP.vcxproj.filters b/VC2013/CryptoPP.vcxproj.filters index d9d18bef..becd042b 100644 --- a/VC2013/CryptoPP.vcxproj.filters +++ b/VC2013/CryptoPP.vcxproj.filters @@ -2,15 +2,15 @@ - {de7b3b89-9cfa-4441-97a1-a41eb499d273} + {3c30caed-20a3-4bd8-b12e-fdd1e13455e5} .cpp - {1ddea6e2-83c2-4c5f-962a-7ad7f117cc85} + {770573d2-b90d-43f4-ac1c-464ab10c46ec} .;.h - {41edc228-f641-4aea-ad4b-14a4918be0a3} + {1ac058bb-f217-4ac3-a14b-9c6ba021e030} diff --git a/VC2013/MCServer.vcxproj b/VC2013/MCServer.vcxproj index 50a938ad..9daecba0 100644 --- a/VC2013/MCServer.vcxproj +++ b/VC2013/MCServer.vcxproj @@ -224,7 +224,6 @@ - @@ -234,7 +233,6 @@ - @@ -325,6 +323,7 @@ + @@ -351,6 +350,7 @@ + @@ -468,6 +468,7 @@ + @@ -629,7 +630,6 @@ - @@ -763,6 +763,7 @@ + diff --git a/VC2013/MCServer.vcxproj.filters b/VC2013/MCServer.vcxproj.filters index 74ddfafa..30e90a9b 100644 --- a/VC2013/MCServer.vcxproj.filters +++ b/VC2013/MCServer.vcxproj.filters @@ -10,73 +10,73 @@ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - {977716f7-b383-498a-950f-49afc6d551f6} + {813698c3-b2c1-4f3d-a89c-7ac6239fff97} - {14ac2998-63d0-4bb3-97e3-1bd0007ffc74} + {b120a538-d8b9-4576-8675-36cf01fd69fc} - {272cba2d-aa26-4c69-b6fa-94465078e351} + {85037cf1-81a5-47c7-8c2e-899ea706b8e7} - {1fabcea5-dba3-4265-b691-5795c69c4471} + {46c9cb22-7c7f-4589-b9b2-1fc79d2bdbdf} - {c29beffd-33f6-44eb-8310-3e0462cdddf9} + {f12178cb-2ecb-4e48-9a8d-ba3e2e73cfbc} - {430cae6d-cfb2-49a2-9fb2-614fde244868} + {488bc224-735f-405c-83de-870373cb52cb} - {87060076-8ef4-4535-88ee-7a609e4391ae} + {41c0d7c9-43b5-4d17-b50e-3c8ac3aa2905} - {4e33e863-d055-4476-bb95-efd5ebc115d3} + {2c71a15a-8c65-4be7-bdfb-e083f4841c4a} - {ae97007e-0940-4f87-9786-8ed1d201e52c} + {2227f719-f0ac-444e-af14-230853017c45} - {99483c91-c76c-47c7-838d-ba25c2066c79} + {eb070b55-ba10-4bce-ba06-5d785a055e54} - {51b8f5f3-83b3-4068-8825-503f19b42542} + {779dac55-c718-4fe1-8b67-547d431b9ebc} - {959da118-757d-44c1-a4bd-d3345cfeb637} + {89847a5d-608a-4137-a766-1557276b4fcf} - {be413233-b7df-4ef1-9eb3-8aa1de96bf3e} + {e159d08d-daec-46de-9b60-9f8e660da91d} - {224e8323-4bcc-4d7e-bdba-09fa22f42d66} + {0278092b-abe5-4276-81cf-59e4079e5bc7} - {f9ad84f7-9199-45d1-a609-128f60baa996} + {e4879cf2-e769-4e1d-8905-0f6c40ee5bc1} - {74088e2e-f7dc-478a-ae7f-bcfcb1a13dcc} + {d641a9d4-f5dc-4808-bee6-194306505244} - {5e5eae6e-3154-4f85-868e-2682d072a5b2} + {a1e39415-2aca-4779-a558-2567a9de304f} - {124dfea0-3dcd-45c0-a196-ec9bd6e00b6a} + {eb5f3060-03ed-4548-8bde-340454d3d23a} - {bc156df0-b3f8-4bf2-a434-59e63f5eafcc} + {7c681450-041a-4846-acf6-951c1f4e32a4} - {2bbb71f4-860a-4fc4-b9d9-ac05f806fea1} + {e961964c-9fb7-4513-89fa-05e0b760e0f1} - {05facd8b-76e8-4bc5-9135-831b49ac5c65} + {70696c83-2307-43c6-8851-81aa3baa8523} - {6b70646e-a784-4617-8b26-941de4f8fd20} + {d3b692db-0684-4b89-9d38-2e5af12e9a6e} - {a2b234d1-1013-47c0-8a44-f3b294d83d19} + {6eee304c-f055-4758-a248-a125e1af7e73} @@ -117,9 +117,6 @@ Source Files - - Source Files - Source Files @@ -390,6 +387,9 @@ Source Files\Entities + + Source Files\Entities + Source Files\Entities @@ -468,6 +468,9 @@ Source Files\OSSupport + + Source Files\OSSupport + Source Files\OSSupport @@ -798,6 +801,9 @@ Source Files\Items + + Source Files\Items + Source Files\Items @@ -945,9 +951,6 @@ Source Files\HTTPServer - - Source Files\Entities - @@ -1372,6 +1375,9 @@ Source Files\Entities + + Source Files\Entities + Source Files\Entities @@ -1660,9 +1666,6 @@ Source Files\HTTPServer - - Source Files\Entities - diff --git a/VC2013/ToLua.vcxproj b/VC2013/ToLua.vcxproj index 86f80d69..309d9635 100644 --- a/VC2013/ToLua.vcxproj +++ b/VC2013/ToLua.vcxproj @@ -163,6 +163,7 @@ + diff --git a/VC2013/ToLua.vcxproj.filters b/VC2013/ToLua.vcxproj.filters index 095111dc..5d104d7d 100644 --- a/VC2013/ToLua.vcxproj.filters +++ b/VC2013/ToLua.vcxproj.filters @@ -7,6 +7,9 @@ + + Source Files + Source Files From 913841f50115379ebaaba1cb88c3f1cdfed09320 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 09:31:06 -0600 Subject: [PATCH 089/144] Implement favicon for 1.7.2 Favicon data is a png encoded in base64 which is stored in the server and sent in the server response packet --- src/Protocol/Protocol17x.cpp | 13 +++++++++++++ src/Protocol/Protocol17x.h | 1 + src/Server.cpp | 11 +++++++++++ src/Server.h | 3 +++ 4 files changed, 28 insertions(+) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index bbbd5e97..c75fc987 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -383,6 +383,16 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc +void cProtocol172::SendFavicon(void) +{ + cPacketizer Pkt(*this, 0x0); // Favicon packet + Pkt.WriteString(cRoot::Get()->GetServer()->GetFaviconData()); +} + + + + + void cProtocol172::SendGameMode(eGameMode a_GameMode) { cPacketizer Pkt(*this, 0x2b); // Change Game State packet @@ -1116,6 +1126,9 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) AppendPrintf(Response, "\"description\":{\"text\":\"%s\"}", cRoot::Get()->GetServer()->GetDescription().c_str() ); + AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + cRoot::Get()->GetServer()->GetFaviconData() + ); Response.append("}"); cPacketizer Pkt(*this, 0x00); // Response packet diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 23ff2365..29fc75ee 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -72,6 +72,7 @@ public: virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override; virtual void SendEntityVelocity (const cEntity & a_Entity) override; virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; + virtual void SendFavicon (void); virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; diff --git a/src/Server.cpp b/src/Server.cpp index 7dedc390..e5050f32 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -203,6 +203,8 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; + if (cFile::Exists("favicon.png")) m_Favicon = Base64Encode(cFile::ReadWholeFile("favicon.png")); + if (m_bIsConnected) { LOGERROR("ERROR: Trying to initialize server while server is already running!"); @@ -289,6 +291,15 @@ int cServer::GetNumPlayers(void) +AString cServer::GetFaviconData(void) +{ + return m_Favicon; +} + + + + + void cServer::PrepareKeys(void) { // TODO: Save and load key for persistence across sessions diff --git a/src/Server.h b/src/Server.h index e62c4c7b..e3326427 100644 --- a/src/Server.h +++ b/src/Server.h @@ -106,6 +106,8 @@ public: // tolua_export /// Notifies the server that a player is being destroyed; the server uses this to adjust the number of players void PlayerDestroying(const cPlayer * a_Player); + + AString GetFaviconData(void); CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; } CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; } @@ -183,6 +185,7 @@ private: cRCONServer m_RCONServer; AString m_Description; + AString m_Favicon; int m_MaxPlayers; bool m_bIsHardcore; From 5fd62f9cd7c1a1594b6331a79f2b375bc0dfb9e2 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 09:38:51 -0600 Subject: [PATCH 090/144] Removed unused line --- src/Protocol/Protocol17x.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 29fc75ee..23ff2365 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -72,7 +72,6 @@ public: virtual void SendEntityStatus (const cEntity & a_Entity, char a_Status) override; virtual void SendEntityVelocity (const cEntity & a_Entity) override; virtual void SendExplosion (double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion) override; - virtual void SendFavicon (void); virtual void SendGameMode (eGameMode a_GameMode) override; virtual void SendHealth (void) override; virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override; From ede6757f6731fbdabb07092f8785fa09a59c5375 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 09:40:59 -0600 Subject: [PATCH 091/144] A few touch ups --- src/Server.cpp | 5 ++++- src/Server.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Server.cpp b/src/Server.cpp index e5050f32..0afd8958 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -203,7 +203,10 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; - if (cFile::Exists("favicon.png")) m_Favicon = Base64Encode(cFile::ReadWholeFile("favicon.png")); + if (cFile::Exists("favicon.png")) + { + m_FaviconData = Base64Encode(cFile::ReadWholeFile("favicon.png")); + } if (m_bIsConnected) { diff --git a/src/Server.h b/src/Server.h index e3326427..62fdf225 100644 --- a/src/Server.h +++ b/src/Server.h @@ -185,7 +185,7 @@ private: cRCONServer m_RCONServer; AString m_Description; - AString m_Favicon; + AString m_FaviconData; int m_MaxPlayers; bool m_bIsHardcore; From 2a058559d4f6076b6ef18e3ecb7da13b8f075dc7 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 7 Jan 2014 16:43:47 +0100 Subject: [PATCH 092/144] Update CONTRIBUTING.md Added control statement braces and end-of-file blank lines. --- CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5aba6ac9..83173a6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,3 @@ - Code Stuff ---------- @@ -23,7 +22,9 @@ Code Stuff - This helps prevent mistakes such as "if (a & 1 == 0)" * White space is free, so use it freely - "freely" as in "plentifully", not "arbitrarily" - * Please leave the first line of all files blank, to get around an IDE bug. + * Each and every control statement deserves its braces. This helps maintainability later on when the file is edited, lines added or removed - the control logic doesn't break so easily. + * Please leave the first line of all source files blank, to get around an IDE bug. + * Also leave the last line of all source files blank (GCC and GIT can complain otherwise) Copyright From 1c2eb4a1c07167e2fb53f9398383d3fda0940b0b Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 09:49:52 -0600 Subject: [PATCH 093/144] A few more touch ups --- src/Protocol/Protocol17x.cpp | 12 +----------- src/Server.cpp | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index c75fc987..2d00776a 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -383,16 +383,6 @@ void cProtocol172::SendExplosion(double a_BlockX, double a_BlockY, double a_Bloc -void cProtocol172::SendFavicon(void) -{ - cPacketizer Pkt(*this, 0x0); // Favicon packet - Pkt.WriteString(cRoot::Get()->GetServer()->GetFaviconData()); -} - - - - - void cProtocol172::SendGameMode(eGameMode a_GameMode) { cPacketizer Pkt(*this, 0x2b); // Change Game State packet @@ -1127,7 +1117,7 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) cRoot::Get()->GetServer()->GetDescription().c_str() ); AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", - cRoot::Get()->GetServer()->GetFaviconData() + cRoot::Get()->GetServer()->GetFaviconData().c_str() ); Response.append("}"); diff --git a/src/Server.cpp b/src/Server.cpp index 0afd8958..30c401d5 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -296,7 +296,7 @@ int cServer::GetNumPlayers(void) AString cServer::GetFaviconData(void) { - return m_Favicon; + return m_FaviconData; } From bcd41dc1aafcbfc12803e5326f80ee0b5ebf7fdf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 15:55:23 +0100 Subject: [PATCH 094/144] LuaState can push strings with embedded NULs. This also marginally improves performance, since a strlen() isn't called (inside lua_pushstring()), the string length is stored in the AString object directly. --- src/Bindings/LuaState.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index a684620f..83351591 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -297,7 +297,7 @@ void cLuaState::Push(const AString & a_String) { ASSERT(IsValid()); - tolua_pushcppstring(m_LuaState, a_String); + lua_pushlstring(m_LuaState, a_String.data(), a_String.size()); m_NumCurrentFunctionArgs += 1; } From 39a1bcdea0a5897a7090748529e3b903918882ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 16:00:19 +0100 Subject: [PATCH 095/144] More MSVC warning fixes. --- src/ChunkMap.cpp | 2 +- src/Generating/Ravines.cpp | 2 +- src/HTTPServer/MultipartParser.cpp | 2 +- src/LightingThread.cpp | 2 +- src/LineBlockTracer.cpp | 2 +- src/Server.cpp | 2 +- src/StringCompression.cpp | 4 ++-- src/StringUtils.cpp | 2 +- src/UI/SlotArea.cpp | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp index 86fbceff..e14090b1 100644 --- a/src/ChunkMap.cpp +++ b/src/ChunkMap.cpp @@ -991,7 +991,7 @@ bool cChunkMap::HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) int cChunkMap::GetHeight(int a_BlockX, int a_BlockZ) { - while (true) + for (;;) { cCSLock Lock(m_CSLayers); int ChunkX, ChunkZ, BlockY = 0; diff --git a/src/Generating/Ravines.cpp b/src/Generating/Ravines.cpp index 6413b963..cfda47e3 100644 --- a/src/Generating/Ravines.cpp +++ b/src/Generating/Ravines.cpp @@ -381,7 +381,7 @@ void cStructGenRavines::cRavine::FinishLinear(void) int R = itr->m_Radius; int T = itr->m_Top; int B = itr->m_Bottom; - while (true) + for (;;) { m_Points.push_back(cRavDefPoint(PrevX, PrevZ, R, T, B)); if ((PrevX == x1) && (PrevZ == z1)) diff --git a/src/HTTPServer/MultipartParser.cpp b/src/HTTPServer/MultipartParser.cpp index b49f6ec0..14c2c00f 100644 --- a/src/HTTPServer/MultipartParser.cpp +++ b/src/HTTPServer/MultipartParser.cpp @@ -156,7 +156,7 @@ void cMultipartParser::Parse(const char * a_Data, int a_Size) // Append to buffer, then parse it: m_IncomingData.append(a_Data, a_Size); - while (true) + for (;;) { if (m_EnvelopeParser.IsInHeaders()) { diff --git a/src/LightingThread.cpp b/src/LightingThread.cpp index 7c3cc9c7..a823c08c 100644 --- a/src/LightingThread.cpp +++ b/src/LightingThread.cpp @@ -216,7 +216,7 @@ void cLightingThread::ChunkReady(int a_ChunkX, int a_ChunkZ) void cLightingThread::Execute(void) { - while (true) + for (;;) { { cCSLock Lock(m_CS); diff --git a/src/LineBlockTracer.cpp b/src/LineBlockTracer.cpp index 110c6b5d..da1c7f2f 100644 --- a/src/LineBlockTracer.cpp +++ b/src/LineBlockTracer.cpp @@ -196,7 +196,7 @@ bool cLineBlockTracer::Item(cChunk * a_Chunk) ASSERT((m_CurrentY >= 0) && (m_CurrentY < cChunkDef::Height)); // This should be provided by FixStartAboveWorld() / FixStartBelowWorld() // This is the actual line tracing loop. - while (true) + for (;;) { // Report the current block through the callbacks: if (a_Chunk == NULL) diff --git a/src/Server.cpp b/src/Server.cpp index 7dedc390..e707235a 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -493,7 +493,7 @@ void cServer::ExecuteConsoleCommand(const AString & a_Cmd, cCommandOutputCallbac if (split[0].compare("killmem") == 0) { - while (true) + for (;;) { new char[100 * 1024 * 1024]; // Allocate and leak 100 MiB in a loop -> fill memory and kill MCS } diff --git a/src/StringCompression.cpp b/src/StringCompression.cpp index 36946b28..e1505884 100644 --- a/src/StringCompression.cpp +++ b/src/StringCompression.cpp @@ -74,7 +74,7 @@ int CompressStringGZIP(const char * a_Data, int a_Length, AString & a_Compressed return res; } - while (true) + for (;;) { res = deflate(&strm, Z_FINISH); switch (res) @@ -137,7 +137,7 @@ extern int UncompressStringGZIP(const char * a_Data, int a_Length, AString & a_U return res; } - while (true) + for (;;) { res = inflate(&strm, Z_FINISH); switch (res) diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 8d235233..e6deb070 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -612,7 +612,7 @@ AString StripColorCodes(const AString & a_Message) { AString res(a_Message); size_t idx = 0; - while (true) + for (;;) { idx = res.find("\xc2\xa7", idx); if (idx == AString::npos) diff --git a/src/UI/SlotArea.cpp b/src/UI/SlotArea.cpp index 61e43266..a721e6b7 100644 --- a/src/UI/SlotArea.cpp +++ b/src/UI/SlotArea.cpp @@ -491,7 +491,7 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player) return; } cItem * PlayerSlots = GetPlayerSlots(a_Player) + 1; - do + for (;;) { // Try distributing the result. If it fails, bail out: cItem ResultCopy(Result); @@ -517,7 +517,7 @@ void cSlotAreaCrafting::ShiftClickedResult(cPlayer & a_Player) // The recipe has changed, bail out return; } - } while (true); + } } From 8b9b09bf60860a591c78cce07dbc1c35804bd7c2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 16:10:39 +0100 Subject: [PATCH 096/144] Removed a debugging log output in cPluginManager:AddHook(). --- src/Bindings/ManualBindings.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 64f54288..6221727c 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1164,7 +1164,6 @@ static int tolua_cPluginManager_AddHook(lua_State * tolua_S) } else if (tolua_isusertable(S, 1, "cPluginManager", 0, &err)) { - LOGD("AddHook recommended style"); // Style 1, use the global PlgMgr, but increment ParamIdx ParamIdx++; } From a33b157dc9748e5126176df20fde5e96541b55f9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 17:15:08 +0100 Subject: [PATCH 097/144] Disabled an unneeded MSVC warning. Also sorted the enabled warnings by their numerical code for easier searching.. --- src/Globals.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Globals.h b/src/Globals.h index 1765c53d..f886ba2d 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -17,16 +17,19 @@ #pragma warning(disable:4100) // Unreferenced formal parameter // Useful warnings from warning level 4: - #pragma warning(3 : 4189) // Local variable is initialized but not referenced - #pragma warning(3 : 4702) // Unreachable code - #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch - #pragma warning(3 : 4389) // Signed/unsigned mismatch - #pragma warning(3 : 4701) // Potentially unitialized local variable used - #pragma warning(3 : 4310) // Cast truncates constant value - #pragma warning(3 : 4505) // Unreferenced local function has been removed #pragma warning(3 : 4127) // Conditional expression is constant + #pragma warning(3 : 4189) // Local variable is initialized but not referenced + #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch + #pragma warning(3 : 4310) // Cast truncates constant value + #pragma warning(3 : 4389) // Signed/unsigned mismatch + #pragma warning(3 : 4505) // Unreferenced local function has been removed + #pragma warning(3 : 4701) // Potentially unitialized local variable used + #pragma warning(3 : 4702) // Unreachable code #pragma warning(3 : 4706) // Assignment within conditional expression + // Disabling this warning, because we know what we're doing when we're doing this: + #pragma warning(disable: 4355) // 'this' used in initializer list + // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data From 5012b81578396154150cb4696d57c455766e22f2 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 10:26:56 -0600 Subject: [PATCH 098/144] Avoid making copies of favicon string --- src/Server.cpp | 2 +- src/Server.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Server.cpp b/src/Server.cpp index 30c401d5..e2a73541 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -294,7 +294,7 @@ int cServer::GetNumPlayers(void) -AString cServer::GetFaviconData(void) +const AString & cServer::GetFaviconData(void) const { return m_FaviconData; } diff --git a/src/Server.h b/src/Server.h index 62fdf225..2609b687 100644 --- a/src/Server.h +++ b/src/Server.h @@ -107,7 +107,7 @@ public: // tolua_export /// Notifies the server that a player is being destroyed; the server uses this to adjust the number of players void PlayerDestroying(const cPlayer * a_Player); - AString GetFaviconData(void); + const AString & GetFaviconData(void) const; CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; } CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; } From e353f29d4ab5deec7ac8b3aac5f3f5c2b8fa56e9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 7 Jan 2014 17:47:05 +0100 Subject: [PATCH 099/144] Plugin messages are received and handed to plugins. Note that MCS doesn't currently handle any channel registrations, this will come later on. --- MCServer/Plugins/Debuggers/Debuggers.lua | 35 ++++++++---------------- src/Bindings/Plugin.h | 1 + src/Bindings/PluginLua.cpp | 33 +++++++++++++++++++++- src/Bindings/PluginLua.h | 1 + src/Bindings/PluginManager.cpp | 21 ++++++++++++++ src/Bindings/PluginManager.h | 2 ++ src/ClientHandle.cpp | 9 ++++++ src/ClientHandle.h | 1 + src/Protocol/Protocol17x.cpp | 2 +- 9 files changed, 80 insertions(+), 25 deletions(-) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c769edc3..7b43b6c2 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -19,15 +19,16 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick2); --]] - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock); - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem); - cPluginManager.AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage); - cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick); - cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat); - cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); - cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); - cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); - cPluginManager.AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_BLOCK, OnPlayerUsingBlock); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_USING_ITEM, OnPlayerUsingItem); + cPluginManager:AddHook(cPluginManager.HOOK_TAKE_DAMAGE, OnTakeDamage); + cPluginManager:AddHook(cPluginManager.HOOK_TICK, OnTick); + cPluginManager:AddHook(cPluginManager.HOOK_CHAT, OnChat); + cPluginManager:AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); + cPluginManager:AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); + cPluginManager:AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); + cPluginManager:AddHook(cPluginManager.HOOK_PLUGINS_LOADED, OnPluginsLoaded); + cPluginManager:AddHook(cPluginManager.HOOK_PLUGIN_MESSAGE, OnPluginMessage); PM = cRoot:Get():GetPluginManager(); PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -541,7 +542,6 @@ function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0); local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0); if (BlockEntity ~= nil) then - LOG("Setting sign lines..."); local SignEntity = tolua.cast(BlockEntity, "cSignEntity"); SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)"); end @@ -964,21 +964,10 @@ end --- Test the hook adding formats in #121 and #401 -local function DoNothing() +function OnPluginMessage(a_Client, a_Channel, a_Message) + LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'"); end -LOG("Trying cPluginManager:AddHook()"); -cPluginManager:AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager.AddHook()"); -cPluginManager.AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager:Get():AddHook()"); -cPluginManager:Get():AddHook(cPluginManager.HOOK_CHAT, DoNothing); -LOG("Trying cPluginManager:Get():AddHook(Plugin, Hook)"); -cPluginManager:Get():AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); - -LOG("Trying cPluginManager.AddHook(Plugin, Hook)"); -cPluginManager.AddHook(cPluginManager:GetCurrentPlugin(), cPluginManager.HOOK_CHAT); diff --git a/src/Bindings/Plugin.h b/src/Bindings/Plugin.h index 2c893a65..f4a11772 100644 --- a/src/Bindings/Plugin.h +++ b/src/Bindings/Plugin.h @@ -84,6 +84,7 @@ public: virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0; virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0; virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) = 0; + virtual bool OnPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) = 0; virtual bool OnPluginsLoaded (void) = 0; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0; diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 87212ed8..209842e5 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -950,6 +950,26 @@ bool cPluginLua::OnPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_Block +bool cPluginLua::OnPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) +{ + cCSLock Lock(m_CriticalSection); + bool res = false; + cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PLUGIN_MESSAGE]; + for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr) + { + m_LuaState.Call((int)(**itr), &a_Client, a_Channel, a_Message); + if (res) + { + return true; + } + } + return false; +} + + + + + bool cPluginLua::OnPluginsLoaded(void) { cCSLock Lock(m_CriticalSection); @@ -1382,6 +1402,8 @@ const char * cPluginLua::GetHookFnName(int a_HookType) case cPluginManager::HOOK_PLAYER_USED_ITEM: return "OnPlayerUsedItem"; case cPluginManager::HOOK_PLAYER_USING_BLOCK: return "OnPlayerUsingBlock"; case cPluginManager::HOOK_PLAYER_USING_ITEM: return "OnPlayerUsingItem"; + case cPluginManager::HOOK_PLUGIN_MESSAGE: return "OnPluginMessage"; + case cPluginManager::HOOK_PLUGINS_LOADED: return "OnPluginsLoaded"; case cPluginManager::HOOK_POST_CRAFTING: return "OnPostCrafting"; case cPluginManager::HOOK_PRE_CRAFTING: return "OnPreCrafting"; case cPluginManager::HOOK_SPAWNED_ENTITY: return "OnSpawnedEntity"; @@ -1395,8 +1417,17 @@ const char * cPluginLua::GetHookFnName(int a_HookType) case cPluginManager::HOOK_WEATHER_CHANGED: return "OnWeatherChanged"; case cPluginManager::HOOK_WEATHER_CHANGING: return "OnWeatherChanging"; case cPluginManager::HOOK_WORLD_TICK: return "OnWorldTick"; - default: return NULL; + + case cPluginManager::HOOK_NUM_HOOKS: + { + // Satisfy a warning that all enum values should be used in a switch + // but don't want a default branch, so that we catch new hooks missing from this list. + break; + } } // switch (a_Hook) + LOGWARNING("Requested name of an unknown hook type function: %d (max is %d)", a_HookType, cPluginManager::HOOK_MAX); + ASSERT(!"Unknown hook requested!"); + return NULL; } diff --git a/src/Bindings/PluginLua.h b/src/Bindings/PluginLua.h index a47ab32e..c01f5ca8 100644 --- a/src/Bindings/PluginLua.h +++ b/src/Bindings/PluginLua.h @@ -81,6 +81,7 @@ public: virtual bool OnPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; virtual bool OnPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override; virtual bool OnPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override; + virtual bool OnPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) override; virtual bool OnPluginsLoaded (void) override; virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override; diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp index 3a6c542b..68e6aea3 100644 --- a/src/Bindings/PluginManager.cpp +++ b/src/Bindings/PluginManager.cpp @@ -1030,6 +1030,27 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i +bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGIN_MESSAGE); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnPluginMessage(a_Client, a_Channel, a_Message)) + { + return true; + } + } + return false; +} + + + + + bool cPluginManager::CallHookPluginsLoaded(void) { HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 16c64d86..9936f5a3 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -96,6 +96,7 @@ public: // tolua_export HOOK_PLAYER_USED_ITEM, HOOK_PLAYER_USING_BLOCK, HOOK_PLAYER_USING_ITEM, + HOOK_PLUGIN_MESSAGE, HOOK_PLUGINS_LOADED, HOOK_POST_CRAFTING, HOOK_PRE_CRAFTING, @@ -186,6 +187,7 @@ public: // tolua_export bool CallHookPlayerUsedItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); bool CallHookPlayerUsingBlock (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); bool CallHookPlayerUsingItem (cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ); + bool CallHookPluginMessage (cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message); bool CallHookPluginsLoaded (void); bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe); diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 17412c26..8125acb4 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -543,6 +543,15 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, +void cClientHandle::HandlePluginMessage(const AString & a_Channel, const AString & a_Message) +{ + cPluginManager::Get()->CallHookPluginMessage(*this, a_Channel, a_Message); +} + + + + + void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status) { LOGD("HandleLeftClick: {%i, %i, %i}; Face: %i; Stat: %i", diff --git a/src/ClientHandle.h b/src/ClientHandle.h index 26d5e74b..bc17df78 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -178,6 +178,7 @@ public: void HandlePlayerLook (float a_Rotation, float a_Pitch, bool a_IsOnGround); void HandlePlayerMoveLook (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround); // While m_bPositionConfirmed (normal gameplay) void HandlePlayerPos (double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround); + void HandlePluginMessage (const AString & a_Channel, const AString & a_Message); void HandleRespawn (void); void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem); void HandleSlotSelected (short a_SlotNum); diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 4d08df2d..5947415d 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1376,7 +1376,7 @@ void cProtocol172::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) HANDLE_READ(a_ByteBuffer, ReadBEShort, short, Length); AString Data; a_ByteBuffer.ReadString(Data, Length); - // TODO: m_Client->HandlePluginMessage(Channel, Data); + m_Client->HandlePluginMessage(Channel, Data); } From 1d96a615b5d1578912ec2e95c03dee6781cb3396 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 7 Jan 2014 16:53:40 +0000 Subject: [PATCH 100/144] Fixed favicons --- src/Protocol/Protocol17x.cpp | 2 +- src/Server.cpp | 14 +------------- src/Server.h | 3 ++- src/StringUtils.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 4d08df2d..e1ba4936 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -1112,7 +1112,7 @@ void cProtocol172::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) cRoot::Get()->GetServer()->GetMaxPlayers(), cRoot::Get()->GetServer()->GetNumPlayers() ); - AppendPrintf(Response, "\"description\":{\"text\":\"%s\"}", + AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", cRoot::Get()->GetServer()->GetDescription().c_str() ); AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", diff --git a/src/Server.cpp b/src/Server.cpp index b0439391..49067c17 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -203,10 +203,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni) m_PlayerCount = 0; m_PlayerCountDiff = 0; - if (cFile::Exists("favicon.png")) - { - m_FaviconData = Base64Encode(cFile::ReadWholeFile("favicon.png")); - } + m_FaviconData = Base64Encode(cFile::ReadWholeFile("favicon.png")); // Will return empty string if file nonexistant; client doesn't mind if (m_bIsConnected) { @@ -294,15 +291,6 @@ int cServer::GetNumPlayers(void) -const AString & cServer::GetFaviconData(void) const -{ - return m_FaviconData; -} - - - - - void cServer::PrepareKeys(void) { // TODO: Save and load key for persistence across sessions diff --git a/src/Server.h b/src/Server.h index 2609b687..d79417fb 100644 --- a/src/Server.h +++ b/src/Server.h @@ -107,7 +107,8 @@ public: // tolua_export /// Notifies the server that a player is being destroyed; the server uses this to adjust the number of players void PlayerDestroying(const cPlayer * a_Player); - const AString & GetFaviconData(void) const; + /* Returns base64 encoded favicon data (obtained from favicon.png) */ + const AString & GetFaviconData(void) const { return m_FaviconData; } CryptoPP::RSA::PrivateKey & GetPrivateKey(void) { return m_PrivateKey; } CryptoPP::RSA::PublicKey & GetPublicKey (void) { return m_PublicKey; } diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index e6deb070..5d16616c 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -759,7 +759,8 @@ AString Base64Decode(const AString & a_Base64String) } } res.resize(o >> 3); - return res;} + return res; +} @@ -774,7 +775,7 @@ AString Base64Encode(const AString & a_Input) 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' }; - std::string output; + AString output; output.resize(((a_Input.size() + 2) / 3) * 4); size_t output_index = 0; @@ -804,7 +805,7 @@ AString Base64Encode(const AString & a_Input) output[output_index++] = '='; } - assert(output_index == output.size()); + ASSERT(output_index == output.size()); return output; } From 524aecc1064046d1c16b70314cefab3e99aea6e9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 7 Jan 2014 17:25:20 +0000 Subject: [PATCH 101/144] Updated submodules --- MCServer/Plugins/Core | 2 +- MCServer/Plugins/ProtectionAreas | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 351aff7e..302115ae 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 351aff7efa94ce3c7ba733d5f83013e8a3fdfbfd +Subproject commit 302115ae19276227bf371971d4b6fa5f9f857da0 diff --git a/MCServer/Plugins/ProtectionAreas b/MCServer/Plugins/ProtectionAreas index 70d95481..9edfee93 160000 --- a/MCServer/Plugins/ProtectionAreas +++ b/MCServer/Plugins/ProtectionAreas @@ -1 +1 @@ -Subproject commit 70d95481e323874b147e3296a2bd0c35563b0bea +Subproject commit 9edfee93048f214175cbed7eb2a3f77f7ac4abb2 From 6c469ec1f54d0f63e0bead2a435047a9e70cd484 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 7 Jan 2014 18:51:16 +0000 Subject: [PATCH 102/144] Removed bitdeli badge - we have GitHub analytics now. --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 9004c531..7a5d48f2 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,3 @@ Earn bitcoins for commits or donate to reward the MCServer developers: [![tip fo Travis CI: [![Build Status](https://travis-ci.org/mc-server/MCServer.png?branch=master)](https://travis-ci.org/mc-server/MCServer) - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mc-server/mcserver/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - From e0d94e0f06e5e39319f68497479720e04f10ce58 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Tue, 7 Jan 2014 13:47:15 -0600 Subject: [PATCH 103/144] Add missing plugin error Previously, if a plugin was included but the folder had no lua files, the error given was ambiguous. Now, it explicitly describes lack of lua files. See issue #512 P.S. This probably isn't the best way, but this is where the fix can be made. --- src/Bindings/PluginLua.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 209842e5..196a4f73 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -90,6 +90,8 @@ bool cPluginLua::Initialize(void) // Load all files for this plugin, and execute them AStringVector Files = cFile::GetFolderContents(PluginPath.c_str()); + + int numFiles = 0; for (AStringVector::const_iterator itr = Files.begin(); itr != Files.end(); ++itr) { if (itr->rfind(".lua") == AString::npos) @@ -101,9 +103,19 @@ bool cPluginLua::Initialize(void) { Close(); return false; + } else + { + numFiles++; } } // for itr - Files[] + if (numFiles == 0) // no lua files found + { + LOGWARNING("No lua files found: plugin %s is missing.", GetName().c_str()); + Close(); + return false; + } + // Call intialize function bool res = false; if (!m_LuaState.Call("Initialize", this, cLuaState::Return, res)) From f578dbfc54e4fd17cd897c9dd86871b1d3c19f8f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 7 Jan 2014 21:23:26 +0000 Subject: [PATCH 104/144] Graceful shutdown on SIGTERM --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 81c6b41e..0620e0f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,6 +50,11 @@ void NonCtrlHandler(int a_Signal) LOGWARN("Segmentation fault; MCServer has crashed :("); exit(EXIT_FAILURE); } + case SIGTERM: + { + std::signal(SIGTERM, SIG_IGN); // Server is shutting down, wait for it... + break; + } default: break; } } From 6c65b050ca7f09e032b52ac2b1ef1fdc2363eddd Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 7 Jan 2014 21:29:01 +0000 Subject: [PATCH 105/144] Updated Core --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 302115ae..c65b5676 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 302115ae19276227bf371971d4b6fa5f9f857da0 +Subproject commit c65b56767a5e59ca387a05be72ef18791baa9aed From 38d0bdf00a370fa12ce4611789439fe8a57880e8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 8 Jan 2014 14:23:15 +0100 Subject: [PATCH 106/144] Fixed AppendVPrintf() handling for large strings. This caused a failure in server favicons. --- src/StringUtils.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 5d16616c..0b38297e 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -47,15 +47,13 @@ AString & AppendVPrintf(AString & str, const char *format, va_list args) #endif // _MSC_VER // Allocate a buffer and printf into it: - str.resize(len + 1); - // HACK: we're accessing AString's internal buffer in a way that is NOT guaranteed to always work. But it works on all STL implementations tested. - // I can't think of any other way that is safe, doesn't allocate twice as much space as needed and doesn't use C++11 features like the move constructor + std::vector Buffer(len + 1); #ifdef _MSC_VER - vsprintf_s((char *)str.data(), len + 1, format, args); + vsprintf_s((char *)&(Buffer.front()), Buffer.size(), format, args); #else // _MSC_VER - vsnprintf((char *)str.data(), len + 1, format, args); + vsnprintf((char *)&(Buffer.front()), Buffer.size(), format, args); #endif // else _MSC_VER - str.resize(len); + str.append(&(Buffer.front()), Buffer.size() - 1); return str; } From ca8421fe26f8dcd83fb66cdca0cdef5a5503b54a Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 8 Jan 2014 15:26:43 +0100 Subject: [PATCH 107/144] NetherGen: Now generates SoulSand. --- src/Generating/CompoGen.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index f929ddc2..9c67170d 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -589,7 +589,17 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) for (int y = 0; y < SEGMENT_HEIGHT; y++) { int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; - a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_NETHERRACK : E_BLOCK_AIR); + NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX * cChunkDef::Width + x)) / 8; + NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ * cChunkDef::Width + z)) / 8; + NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y, NoiseY); + if (CompBlock < -0.5) + { + a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_SOULSAND : E_BLOCK_AIR); + } + else + { + a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_NETHERRACK : E_BLOCK_AIR); + } } } From 5aa34cf77d3687442f148ffbb325e61a8f6ed249 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 8 Jan 2014 15:34:49 +0100 Subject: [PATCH 108/144] WormNestCaves now remove soul sand. --- src/Generating/Caves.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Generating/Caves.cpp b/src/Generating/Caves.cpp index c94113f5..2571e6b7 100644 --- a/src/Generating/Caves.cpp +++ b/src/Generating/Caves.cpp @@ -509,6 +509,7 @@ void cCaveTunnel::ProcessChunk( case E_BLOCK_GRAVEL: case E_BLOCK_SAND: case E_BLOCK_SANDSTONE: + case E_BLOCK_SOULSAND: case E_BLOCK_NETHERRACK: case E_BLOCK_COAL_ORE: case E_BLOCK_IRON_ORE: From 17363716a18e366e9bb0c94bd81628d0680d446a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 8 Jan 2014 17:17:37 +0100 Subject: [PATCH 109/144] ProtoProxy: Fixed favicon relaying. The buffer was too small for the favicon; now it's dynamic. --- Tools/ProtoProxy/Connection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp index 10f2b407..f38ea02e 100644 --- a/Tools/ProtoProxy/Connection.cpp +++ b/Tools/ProtoProxy/Connection.cpp @@ -2390,12 +2390,12 @@ bool cConnection::HandleServerStatusResponse(void) { Response.assign(Response.substr(0, idx + sizeof(DescSearch) - 1) + "ProtoProxy: " + Response.substr(idx + sizeof(DescSearch) - 1)); } - cByteBuffer Packet(1000); + cByteBuffer Packet(Response.size() + 50); Packet.WriteVarInt(0); // Packet type - status response Packet.WriteVarUTF8String(Response); AString Pkt; Packet.ReadAll(Pkt); - cByteBuffer ToClient(1000); + cByteBuffer ToClient(Response.size() + 50); ToClient.WriteVarUTF8String(Pkt); CLIENTSEND(ToClient); return true; From 71946f56719e453ed68fb54f22d498f1b8c7d90e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 8 Jan 2014 20:18:26 +0100 Subject: [PATCH 110/144] Added a known working favicon. --- MCServer/favicon.png | Bin 0 -> 9265 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 MCServer/favicon.png diff --git a/MCServer/favicon.png b/MCServer/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..946cce005ed483fce079aa31d9227551ca50d065 GIT binary patch literal 9265 zcmV-1B+lE3P)Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy32;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9a%BKeVQFr3 zE>1;MAa*k@H7+$tiu~XJ03&rtL_t(|Ue$YdY}|QvpGZ|o6npP&3a1xNB{>{&*hR5O zq#D&Iu}SQ8$YGmd?-bR`_Ve9(b9;7jhy&z|1n>dQAwc5%li&~pi7$W=Cx+vc^To+| z=lAk?-yyZS-Mzir+{X3__+i>_hVwq}^FHtM-ft9k6X)^^(v z@ATxA1f?TKe)y07?H_*sJOAd-!@`c>6gm=yJCcMu-{gNBFyaUg-G+rbt1_a7eU93| zR>k(*X4St~c~bxL)yMAO!gf(`JfQjcSitc|zOA|kLvy7KmGxCYwux<3ePS^c9vi@U^~e&$WE|Hc@?0V7zE z*)pG`MV%W_HV^xd)XrxKc!un-*GoT1IQn zYH8s?J$YAbG`VP?h0PM0+bSjRrj?cv^uxC+Y5kFte5-mInN`yGf}R$(+_e3?njXJf z9ena`we;Yv%HZnL`u{n-RrmW-t0hxyH}f1SeatB&B2;Wh#@ALZ2X)LJ8g}C3(eM&? za`wcm?Ye)n{DaNMl|Om@t-9d$t9of}w^|xocXHt5-72TWM|HIQqKbB&SJLu>3Yy+< z(&(CrCRX$`vu;9ACYsqaf%-a}Z=nZod1&u>6|L@902Bw!n~#g7)rSsgdC&b93mfIXH@0XSDR0RzrDmNz9%4v{oxe69 zhl0g5#vkBtWhUJiD{SeSS3et=SO0i+%@Ca5a7g~WT50EHt+fAkHElevM^@qY>u6wJL-zwZ8eZ1n`6B+p^!WW6diC)IdhxxB^!z&wwEtEOEj_NK)u(mz;8iu@ z^Jo#}F|}HZ?1#!?VZ%r>D_WXG(7r{K%aR)RjbM_SUj9xiz4bd6>EV0TU`?^)TQf?- zOFC(2)hKzlD*g-%`CZ>u_5JeNRCRpf$zvSPkpuRA4v<5|wv=Q?@4SDZ=Ed(`*;#v1 z`!84atA6g^s|)#U$!?1{t5*sl-uEa~o#zE@^0FPDMUYe0kSH zi#ruG51J1ynE;5ErjXgCeFxsBr3KJ@>xr9I_Dex^4S+*QY?ssYvP}RmJfonoxk8%4 zxt#UMMGY8WpqVWX&F|IH>~<-Qtr)0xUX9NOP+-}@x|L?Zs<{=jS zuA#^8;PrRGmd9lP#0s#Cq72p^I%$5_M*T~A8Um=x58cRSl@PwTd9{Eh{TF$r1^&uYlGSuV8W>H7c%zy%(9$hTWf z^Z0v#hv#VZQ3b6$u!ALLng&2a0Qx=v9}s1s!uPO=ZV}in0vik{6Qf|u{woi63w&=E zjYBwnDB1Z3=V)rP3|hjaR!T#D53Rg7A6$KT{s$pl00v4!~x;D)s3$yD+AP=B+%4lNEE`n#20|06Vs{ZJmD%yML zMuzOP{dN^S|6VIS`}hjJKqHOgOZ6|CX<)esouC5xP$3=37Da! zUhWbAZ3Y1>K`{B4+j7y;(@J{z_pi{qzt@gdcn%;~=^@(W^ABo7&{L~+h@_eZrewG+ zL}tx2zm59eKPNnfAD=PeQ`3;oL?eMpx-)5{_7Mfj3g&9TN_}H;>bRdzH+%DzICj>7 zFqJu~IbVA^s4*vzwkTN~YJi~7M;!nV4NwxO$euvO?lkf=r_qfu1x-NJ*O0BPCoY`=)CkubL~3r&4n2VX8x83Ym7anbw+o`>04-M7=$vvSb-9P0bL z2zuwaN7OLaII~9>90a`oin|B;I>e8`V+~=p^r4M%H=0^2fsUvUtd^D^mC*)39PsIB zV78QoQQON9z$F2I223fX&3Bs7HOfTx*Y@2sI-{emu|fdj3AXoG&%f3HwLT%!QJO5N zOi?5^oF%I(gLGC7K1BdxzMKGntf{(*gt?N`_g3_d+W&so#eTg6d4i>GfjN z9QwIWL4(sW8U{PYKwoCcv|mXxFf}Wn_X5;S-M3xOij zMUo64aPSNQgJX3jqFm09-IYuiZ{*Sa2^j#;(j>mDccYB@5L^#3*T1NRvI{#ayup)q ztKbicVPpUXzO?8((2;2{Vgo*bU+42yc8gIa4k2a%=nqr+{rpK&fo+46D2GWcP0W|jjZq~u0YbfCmx`Rp8E+0zVaW7s9ETU4;^I$CZ`WsAA*W|F(r<}33hvx2vkA$M+!h;i^%RG zizSTGT>#Jyg=dwAWfwI+>UYCDmD1#L1r05fi<%#vGSKL(o$k*#X=v6i4Na^6GCk|e zX)!t-{0mo`68{;f9^_1Oz3YqOKLtR4CZr9}0*xsaK}QJyLdO}>;59u0)*7QpV?6s> zM+)#-F50QJIDsy;XOkCYu=@;|N1ea??M8Y9KmYinHViy1qF+yJx~Yco3UaZC_!-LsQF5|Ii?b?Umb?BPiW|_7ye`c4ioGcU#dXMLz#>gP(K8_ z4+rbS&rPoX;TDUnrodfL+x8EOfxftXOB$RY&VDn{YIO z=EWk@?V}31IwGTc<4PKshQHXtNd2Hp1UCWzt|RLm6FRhF2Uz8#E5kAx4Va-1Wi&YJ zpzh&9!2ofLDFK{^`X;r(n>~3y;_>;@_|XsLs)$DlC_4wC)+1o_{!p-?&Y%IcIs4){ zfWptQAX>Qg4<7S-nLVr_d@xXQl#7;i1h471qW}a3$5oq6mv80MIC}cZ;P!-;?t!+PIX-wkU;xGzL2qcm;Cva4E>?-h(F1XmQRe`% zkKhL&mXiy1T1O}79W9h@^yGf;7sh1nhp6FEjUh_nFA650%|#pp8+!o2SpXABa!|Su z{(uFr$N_PLR><)@>w(#p7y_UoQvhHn!ee}%#gQmpV*pr04fa%WR%VgCB8%>U#@x5( zwq3OSeh7fk`BEWfT+@faGvycI5qxV1-lr4q8TMC*U{`issC`R_EnMetdmViR)HST2 z8+dMH4*G-AVesxxn$WFE9({I;6lO0?xx!w6MNEaP9Rgq|ih;m^0T4m~0DzGJ1VQbh zIJ^d5fYdIX^B!rWpXH zIcFM-LMd^VH~_{HBZRdO=N6)s8sRJMjwtCSYP}1s>=y!O!J2haKg5lNOsM$*0R59H z>KqEGe+POyx47OZBi(^kun8IhIQ(3<*FgPq7^d*J7k}f<0NCJnOLqoMSARhSxgPQq zu`<0iMbet0!GK80(?*aPUciD3a|`5PIQycOQS%CPhC+zrn*eA*`62{$2mpho(nW~# zL*?-)0D?({r>G6SoCE2ewhCcmLo>HqN2@4>KF;W&h>gmT*<80dqINFeN&J){;U>Ex$ij0LdBGK|C2a226(Y zlsFgwbRN0{0Iov3x?rjAg0j8yCffO+h1TB!03vv~_~JvLI|n!5h4}#h9mr1ng!j3w@n(!=}u9+xe*fGAUgI$c!4hRKPmN5 zlExS*zOWKsSc4Mad4Nq2)0>4&f6yX1qvAPBEGfYVHNX)7XhK@SR1Zy)F(Clp6S!2^ zNNG?yN^KO~9_9G~*9PW|BBKmINDR+W{{f|009o)D0H%LGCcM#En|M6ESR??L!)Gj^ zlW^C2wr!i#l`L_Y`$P9LtOHNwdb^W#0m>Bm(tMu?()#*RVQJxAGfSMY#LC%;k zJM0G04u!xSc!UBx&)~2=7_Fi981fA<2s|XBhX61LETXD|&tm}CQEK2A7ck(6z6}E- zOb-BHD?Gk{Hpi4k{jxTU2HfcDa_St!6bjKB0{{b4D$E>C+IqK%)*fM`#vpVZ0F3&r zIHy?DK6{9}gDQB4QvN#~r5V|w3-J}2k41nVl_F0G|0GPvwy9NNpkgX|< z(*6yXFhXNcZU%r`-U1xrB352ZeOB^u05IsYz$wbei)9S^2VSYqtz*fGnxBOgo`8=S zhc1k-l%X4N@NV*Nx`Mrvw$LiScc+sLTA>3Y)Oel&;Qr711g?1%%0tW)06gM zoJV3?2@4|35P~(K#R&kI1<(X88Lb%r;C;{&@wgBgz~Xu6AO!$;uNuJIn}SL&K=}^< zm|bxq%Y~qNfe^LPS-k*YZXL5eYJ3rPm~Armcy4>F6QV_;OvV?nR$ucFmK`_>uzG8t zjzJwYUBUvVCy%c88K~)c!3SRm0Mi12-%d<9DkUTwqs;s>l&69SqHYTid=6}~*&a_O zYXT0qx&r`0(_)lhh7MxL-GFa}IAXGtp$u3{xNP`++*J%HqYwa*Apr2@rY^l3|AMifaHM^o|>;XAJwpKowo@l~L=BOlrKA zj@cubnyxSa`BZx$i9C(*D~Fq)&ypZKG39toV(QUg?3v>fpKzQq!2%ABw?8@Zlb~`G zSb(7h!LVaI%pyBSVR1Py?ivRGFbI6;;TXAdFaZ3RjS-6^FIKun(EbJ#LfJX9hXC|U zs8G*k!v1o0d5~c(m|4SBWvKqtVyN#=q5U1|L(hbX?s*+l*PKLE4e?apmPB!zcw?VNvLaXF)y2#FkC=@IoCR?01mwf~W&z3o4gd(WDGe;~b2fQW#fYmxIFVFZr z(>f7o007*ZDHhvZZimyW3;?#!=o$q$=%^je<3oTPF3~sR9Tlmc2g=$sO3}T!Y%*nKTFhrm*9i^kX;ZWp3-|&Nga$;NIeEMwE9x)O)8nPoG_1z)1(Q-wQU+L{ zK+Pv5p2Wcb#E}vJu+vkEtR@^#8d>JmI;bA9%prfkwa&pG0-%7VaLK3)aWsGx)e0=D z7jrxZ!~n3rXK&9Ak-^}j3tOEz>>1h2a2FV!)>FS%E!fh5br=J1`4(v2m_*gh2~>*f z8;up%83IU;CznbMxpc8YE6Fkw(%;+!eXbeEGNOO1%!!v2xyh8TjG*}V6BKp!IAx;@ zl9NwS+}RV959-R)2#UvGY<+m~p~4P936^lH9n0Ip+LYQt#T%^H}Soz9|RBT3juHPVhG9)(}=>ohsCODpj3N zB$qphTC4TcamhvJU+pC-hdiTGt2z+i;uq(uD_S!QfdTY!yDMik{{ zL{sGH<3bN&g)VV|lCnd7K`6fv#&}X_G4S9vSAIh54J@uSXh!sFhOm_u zEfMF3j1YEwsPoae5CcYL%wm%3hYuLQ(Tn;0VsAcni@5BD1| zNKc5A`mzz_ltIX@$HPGWx#F=QZmCXCeDlS>Vk z)2Os6hAwq#=+>Zx8m?zjDb)T>KNh0hD3#6vq5Lj)Je65>)Zbo3eOFv`y$(KN~^m3@{Hqa!E=jNl_S?ijkn zDbXhL`Oejudo^%-j=X#MY>&G#y?5TVqqG1+qzc(+IJ+4fxCm1|u#!fEbT4 z%kv7HeSF)kOsYdacU8qw+if{oT0S`;bY(3`)N(D8ny+SvHdk4P)>l_Vef|A3a=VW1 zUv^RF1t$kj@2%gF*2i113i|>V_?iL0z^F*?)yq>QJrq<202l&KL;d%BuK=UhNVnnP+wLgna-WLs;`(2Cc`lh1={Q1x7Ae!I z)QBYEzEPe^ou4cKsI)7n7=1N2HJZ}n&xmqJO$~Ji&N@5B#6&Iwh$eTC zsN-V7Ec#{GHO&mPU-fIY6 zskgd+;d;OqO@s-tXHGi|Ie%%>W=kA2i(#oLj|y{>a6gVv9^?iHHN{FY;LGHv$G+Bs z_$YLUln?;iE#jk3QgRGzHGBjEkOmeA0N6)p;?Ob=t8*`2U_BJ{BWYPnta{0^c=O`(}v|ryNA|B zFVM)%Dh`~yopp4z&Jr{#v*aj&U;VSWDyL?}Rh0kN2vp+iS6F3K0uY!HT0AxtW(X!Q z7{V_Aq&K?*(>^}>G{r@pBn94+n+~QR`wRlJgpXXsS&Z8NU{FnW`;}B;=Q>WuRV4@| zyu1@5wlWugt2BYEU`FRvth2^0h~V4n%xH0#5g>3KO}NT5)I=|l?cd((p^oNay4!-^ z5kLccJ@qu*T`vKUPwrlH?`NdMAN!^C|KH zR_A)OTzNWq>N2UlI~Q!o6actt&;c&x(ZWyzt&B92|9*qW^vF#tIxgX-E^RJ?!J+5= z8zNw2n!4MtHyCQBjmb7?{(j?s9Jy8J`O^0HMX0bTGAawsws_1BT}1_-AYh3zUyuZKmn|BEUa`!=1IW@7EFgb1^~p8 z-I7agmy254b#$XQkD40_>B016>gcjk^<^wK##`vw;tl!`J^d*JZlS-ChHg~SJuqQ? z>>|Xkf;umj(5)u?^seu`v^8}}+VWm`x5;CT{mQ`~0uuVg`;qY4QlqETEc;_*T;dX7 z09YTCIhg!3$W#uu$yBmxv!E3ib(s;e3{n>=@I0(A%A_DS3N?RLXagUq3FsJU$I-{* z$kT!>*OgF3MJ4*Yj;^&9(!Q^azO&s)9i3LX*HJ=Gk>Quix9HuqJG2d8Sl9+{z(L|* zy7yfz7qt&&NGl^3|8!}jt(gNqipKwI(f-R$;twjf8e^&)npb93hNPFLOIl?<*bs;M zjzjjb4FUizQ@+p&H3XA`=I0KN{B#&89I5CUJWr&?MSv+0RMDJEHJ9_LvbKaSHhAcE zlZCF;=;)#E5^bS>PeS0Py6|J^`F2_w6tqV0Z8XtYOT!1jqt40ORVR(zu97D1)P3A> z!IS)JiQQL0CiGM6BjME!!?_|=&YxIqHc6*ZQC}-(Or#Rjtidv zrK8y)gzb>#{M?Q6cDi}78ep_Z9Q^jwl^-nhUCR7bHutL}{7cUjWB?HL73CKUdi{U4 z=yD~le`W!ODIB;u1YO{4Gb7kXD6_F9NAOh+g=nMMDN(S~XQ{1HBPO=4i^Xtq_=V|B z{Ad!CAH0rB-?yu%{hW=iHy~gH&G&mQms5ZDEgBdYkT$(ne!4Yvt?x_(e#`%57WZq5 z{4*cKAXs$TB#%S;U33JVAH)#F0?9&|gSA>YJOr0SB?peqQRPrlb#bA1UYQ+_zOJJ4 zB?@Y-GzwY|-v|ZH8E4w}z}XE$?XT2YsOxeKEiWz7_{2nTe02B^NAI4OeeJdWRlz!B zLxo*)wX8_?=SAvFiD!obbOHu|>%R;hqS{#~fGEX%W&z)?0T8uzIn~%?ys@DP)VLSo z#=+0_o}+hGJ795ZzzXzy)V*);mbAIK`B#%;BU4#vsr;WJeshKYssVqQHk4y5E4LPY zA2rVoQY=+?eqazRXqP-gI50!7e_%UZ4Li*Mu)FgM&)x>ntEIaaN(jpf`u27g&Gek3 z<&hQ$o=2J=z5TCdyyLq6=f3`R1^Xo+gq=KbJltg}yi=sg`fu-flHIL@6);-1^wfVUh9kiH`bZyIy(f?`-g&vC?6+#YNe6ZQc(6 zKoCn53I0KV!1nnN0KVUUjmKA94F=V_T1%n$_?_@|{3ng6%RI*iH@%mCyfJaj{{Owb zeckL}RX%e%BD}8D*jH@I`yVWl+$lZ_z$k)W8*c>=6=IZS^Yh_ukF+y=`IGIbtNWMg zN+bW)h3+>2hkuFDT3wo7VJrM0f)8>Ta9JGA5&qE7!c!YOemi|@t5f=LxA!LxW^Pt+ z*8f)8+iw!^7Y|lpVe!$?$Ig|RM&SW|#sbN$l7aBU$??hx6Q1;H=@x>&_wKcZl9+Eq zt$$UZm<<&+z0#@A|K~7CQVuNfJf=D~GTfVL9mGcCCE6 zAS22p6^`X)v7Rlh4|+NoFRF~D5m>k(he*!oq!1kV4zN8KTI Tx19@400000NkvXXu0mjf>QF|Z literal 0 HcmV?d00001 From 154d6b989a242b8d3c6bb24cc64c6fedb2109ad6 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Wed, 8 Jan 2014 13:45:16 -0600 Subject: [PATCH 111/144] A couple touchups --- src/Bindings/PluginLua.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index 196a4f73..eefcd2b0 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -103,13 +103,14 @@ bool cPluginLua::Initialize(void) { Close(); return false; - } else + } + else { numFiles++; } } // for itr - Files[] - if (numFiles == 0) // no lua files found + if (numFiles == 0) { LOGWARNING("No lua files found: plugin %s is missing.", GetName().c_str()); Close(); From d46208510870039a4e4870781ca88d0c80a00e32 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 8 Jan 2014 22:23:26 +0100 Subject: [PATCH 112/144] Speed-up. I got about 40 extra ch/s --- src/Generating/CompoGen.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 9c67170d..3545863f 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -589,17 +589,22 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) for (int y = 0; y < SEGMENT_HEIGHT; y++) { int Val = Lo + (Hi - Lo) * y / SEGMENT_HEIGHT; - NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX * cChunkDef::Width + x)) / 8; - NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ * cChunkDef::Width + z)) / 8; - NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y, NoiseY); - if (CompBlock < -0.5) + BLOCKTYPE Block = E_BLOCK_AIR; + if (Val < m_Threshold) // Don't calculate if the block should be Netherrack or Soulsand when it's already decided that it's air. { - a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_SOULSAND : E_BLOCK_AIR); - } - else - { - a_ChunkDesc.SetBlockType(x, y + Segment, z, (Val < m_Threshold) ? E_BLOCK_NETHERRACK : E_BLOCK_AIR); + NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX * cChunkDef::Width + x)) / 8; + NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ * cChunkDef::Width + z)) / 8; + NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y, NoiseY); + if (CompBlock < -0.5) + { + Block = E_BLOCK_SOULSAND; + } + else + { + Block = E_BLOCK_NETHERRACK; + } } + a_ChunkDesc.SetBlockType(x, y + Segment, z, Block); } } From 53e2ed8473b837de246009d1d4e419dc362d11ad Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 08:05:08 +0100 Subject: [PATCH 113/144] Specified the dynamic loader Lua should use. --- lib/lua/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt index b4b5b5f1..ff5dc927 100644 --- a/lib/lua/CMakeLists.txt +++ b/lib/lua/CMakeLists.txt @@ -25,6 +25,15 @@ else() add_library(lua ${SOURCE}) endif() +# Tell Lua what dynamic loader to use (for LuaRocks): +if (UNIX) + if (APPLE) + add_definitions(-DLUA_USE_MACOSX) + else() + add_definitions(-DLUA_USE_LINUX) + endif () +endif() + if (UNIX) target_link_libraries(lua m ${DYNAMIC_LOADER}) endif() From 18310752b8e7911b02e8fc27d15e6d534c059345 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 08:05:34 +0100 Subject: [PATCH 114/144] Fixed a typo in the TestLuaRocks test plugin. --- MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua index 6e90b1ae..4a7cd4e1 100644 --- a/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua +++ b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua @@ -27,7 +27,7 @@ LOG("headers: "); for k, v in pairs(headers or {}) do LOG(" " .. k .. ": " .. v); end -LOG("body length: " .. string.length(body)); +LOG("body length: " .. string.len(body)); From 4a1b78787f3982859efb9f27c5b22ebc21388a43 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 09:45:21 +0100 Subject: [PATCH 115/144] Windows nightbuild updated to generate .example.ini files. Fixes #314. --- MCServer/settings_apidump.ini | 30 ++++++++++++++++++++++++++++++ MakeLuaAPI.cmd | 1 + Nightbuild2008.cmd | 27 ++++++++++++++++++++------- 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 MCServer/settings_apidump.ini diff --git a/MCServer/settings_apidump.ini b/MCServer/settings_apidump.ini new file mode 100644 index 00000000..80227a71 --- /dev/null +++ b/MCServer/settings_apidump.ini @@ -0,0 +1,30 @@ +; This settings file is used by the $/MakeLuaAPI.cmd script +; It is copied over settings.ini so that the APIDump plugin gets loaded upon server start + +[Server] +Description=MCServer - in C++! +MaxPlayers=100 +HardcoreEnabled=0 +Port=25565 +PortsIPv6= +DefaultViewDistance=10 + +[RCON] +Enabled=0 + +[Authentication] +Authenticate=1 +Server=session.minecraft.net +Address=/game/checkserver.jsp?user=%USERNAME%&serverId=%SERVERID% + +[Worlds] +; World=secondworld +DefaultWorld=world + +[Plugins] +Plugin=APIDump + +[DeadlockDetect] +Enabled=0 +IntervalSec=20 + diff --git a/MakeLuaAPI.cmd b/MakeLuaAPI.cmd index 6ea44c9f..7054977a 100644 --- a/MakeLuaAPI.cmd +++ b/MakeLuaAPI.cmd @@ -29,6 +29,7 @@ if "a%ftpsite%" == "a" ( :: Create the API documentation by running the server and stopping it right after it starts: cd MCServer +copy /Y settings_apidump.ini settings.ini echo stop | MCServer cd .. diff --git a/Nightbuild2008.cmd b/Nightbuild2008.cmd index f3f1ca4c..8dcd5dc4 100644 --- a/Nightbuild2008.cmd +++ b/Nightbuild2008.cmd @@ -44,6 +44,7 @@ if "a%ftpsite%" == "a" ( :: Get the date and time into vars: +:: This is locale-dependent! For /f "tokens=2-4 delims=/. " %%a in ('date /t') do ( set MYYEAR=%%c set MYMONTH=%%b @@ -66,13 +67,11 @@ if errorlevel 1 goto haderror :: Update the external plugins to the latest revision: -cd MCServer\Plugins\Core -git pull +git submodule update if errorlevel 1 goto haderror -cd ..\ProtectionAreas -git pull -if errorlevel 1 goto haderror -cd ..\..\.. + + + :: Get the Git commit ID into an environment var For /f "tokens=1 delims=/. " %%a in ('git log -1 --oneline --no-abbrev-commit') do (set COMMITID=%%a) @@ -114,9 +113,23 @@ if errorlevel 1 goto haderror +:: Generate the .example.ini files by running the server without any ini files: +cd MCServer +del groups.ini +del settings.ini +del webadmin.ini +echo stop | MCServer +cd .. + + :: Copy all the example ini files into the Install folder for zipping: -copy MCServer\*.example.ini Install\ +copy MCServer\groups.ini Install\groups.example.ini +copy MCServer\settings.ini Install\settings.example.ini +copy MCServer\webadmin.ini Install\webadmin.example.ini + + + :: Use 7-zip to compress the resulting files into a single file: set FILESUFFIX=%MYYEAR%_%MYMONTH%_%MYDAY%_%MYTIME%_%COMMITID% From 1ef20e858fd5b38ede0e2de2d697cb894e245964 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 10:21:26 +0100 Subject: [PATCH 116/144] Height generator creating moved info HeiGen.cpp. The generator also explicitly sets the default back into the INI file. --- src/Generating/ComposableGenerator.cpp | 54 +------------------ src/Generating/ComposableGenerator.h | 9 +++- src/Generating/HeiGen.cpp | 73 ++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 54 deletions(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index c86568c9..a6fcbc9e 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -173,60 +173,8 @@ void cComposableGenerator::InitBiomeGen(cIniFile & a_IniFile) void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) { - AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", ""); - if (HeightGenName.empty()) - { - LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\"."); - HeightGenName = "Biomal"; - } - - int Seed = m_ChunkGenerator.GetSeed(); bool CacheOffByDefault = false; - if (NoCaseCompare(HeightGenName, "flat") == 0) - { - m_HeightGen = new cHeiGenFlat; - CacheOffByDefault = true; // We're generating faster than a cache would retrieve data - } - else if (NoCaseCompare(HeightGenName, "classic") == 0) - { - m_HeightGen = new cHeiGenClassic(Seed); - } - else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0) - { - m_HeightGen = new cDistortedHeightmap(Seed, *m_BiomeGen); - } - else if (NoCaseCompare(HeightGenName, "End") == 0) - { - m_HeightGen = new cEndGen(Seed); - } - else if (NoCaseCompare(HeightGenName, "Noise3D") == 0) - { - m_HeightGen = new cNoise3DComposable(Seed); - } - else // "biomal" or - { - if (NoCaseCompare(HeightGenName, "biomal") != 0) - { - LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str()); - } - m_HeightGen = new cHeiGenBiomal(Seed, *m_BiomeGen); - - /* - // Performance-testing: - LOGINFO("Measuring performance of cHeiGenBiomal..."); - clock_t BeginTick = clock(); - for (int x = 0; x < 500; x++) - { - cChunkDef::HeightMap Heights; - m_HeightGen->GenHeightMap(x * 5, x * 5, Heights); - } - clock_t Duration = clock() - BeginTick; - LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); - //*/ - } - - // Read the settings: - m_HeightGen->InitializeHeightGen(a_IniFile); + m_HeightGen = cTerrainHeightGen::CreateHeightGen(a_IniFile, *m_BiomeGen, m_ChunkGenerator.GetSeed(), CacheOffByDefault); // Add a cache, if requested: int CacheSize = a_IniFile.GetValueSetI("Generator", "HeightGenCacheSize", CacheOffByDefault ? 0 : 64); diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index 732f6430..a6b77f7b 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -50,7 +50,7 @@ public: virtual void InitializeBiomeGen(cIniFile & a_IniFile) {} /// Creates the correct BiomeGen descendant based on the ini file settings and the seed provided. - /// a_CacheOffByDefault gets set to whether the cache should be enabled by default + /// a_CacheOffByDefault gets set to whether the cache should be disabled by default /// Used in BiomeVisualiser, too. /// Implemented in BioGen.cpp! static cBiomeGen * CreateBiomeGen(cIniFile & a_IniFile, int a_Seed, bool & a_CacheOffByDefault); @@ -77,6 +77,13 @@ public: /// Reads parameters from the ini file, prepares generator for use. virtual void InitializeHeightGen(cIniFile & a_IniFile) {} + + /** Creates the correct TerrainHeightGen descendant based on the ini file settings and the seed provided. + a_BiomeGen is the underlying biome generator, some height generators may depend on it to generate more biomes + a_CacheOffByDefault gets set to whether the cache should be disabled by default + Implemented in HeiGen.cpp! + */ + static cTerrainHeightGen * CreateHeightGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault); } ; diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 2bf64108..051758f7 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -7,12 +7,85 @@ #include "HeiGen.h" #include "../LinearUpscale.h" #include "inifile/iniFile.h" +#include "DistortedHeightmap.h" +#include "EndGen.h" +#include "Noise3DGenerator.h" +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cTerrainHeightGen: + +cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBiomeGen & a_BiomeGen, int a_Seed, bool & a_CacheOffByDefault) +{ + AString HeightGenName = a_IniFile.GetValueSet("Generator", "HeightGen", ""); + if (HeightGenName.empty()) + { + LOGWARN("[Generator] HeightGen value not set in world.ini, using \"Biomal\"."); + HeightGenName = "Biomal"; + } + + a_CacheOffByDefault = false; + cTerrainHeightGen * res = NULL; + if (NoCaseCompare(HeightGenName, "flat") == 0) + { + res = new cHeiGenFlat; + a_CacheOffByDefault = true; // We're generating faster than a cache would retrieve data + } + else if (NoCaseCompare(HeightGenName, "classic") == 0) + { + res = new cHeiGenClassic(a_Seed); + } + else if (NoCaseCompare(HeightGenName, "DistortedHeightmap") == 0) + { + res = new cDistortedHeightmap(a_Seed, a_BiomeGen); + } + else if (NoCaseCompare(HeightGenName, "End") == 0) + { + res = new cEndGen(a_Seed); + } + else if (NoCaseCompare(HeightGenName, "Noise3D") == 0) + { + res = new cNoise3DComposable(a_Seed); + } + else if (NoCaseCompare(HeightGenName, "biomal") == 0) + { + res = new cHeiGenBiomal(a_Seed, a_BiomeGen); + + /* + // Performance-testing: + LOGINFO("Measuring performance of cHeiGenBiomal..."); + clock_t BeginTick = clock(); + for (int x = 0; x < 500; x++) + { + cChunkDef::HeightMap Heights; + res->GenHeightMap(x * 5, x * 5, Heights); + } + clock_t Duration = clock() - BeginTick; + LOGINFO("HeightGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); + //*/ + } + else + { + // No match found, force-set the default and retry + LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str()); + a_IniFile.SetValue("Generator", "HeightGen", "Biomal"); + return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault); + } + + // Read the settings: + res->InitializeHeightGen(a_IniFile); + + return res; +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cHeiGenFlat: From bd17662412e68463f38fb73b1b1aa43032262b78 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 10:35:51 +0100 Subject: [PATCH 117/144] Composition generator creating moved to a separate function. Also it forces the defaults into the INI file. --- src/Generating/ComposableGenerator.cpp | 138 ++++++++++++++----------- src/Generating/ComposableGenerator.h | 6 ++ 2 files changed, 83 insertions(+), 61 deletions(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index a6fcbc9e..76d06724 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -28,11 +28,87 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cTerrainCompositionGen: +cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed) +{ + AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", ""); + if (CompoGenName.empty()) + { + LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\"."); + CompoGenName = "Biomal"; + a_IniFile.SetValue("Generator", "CompositionGen", CompoGenName); + } + + cTerrainCompositionGen * res = NULL; + if (NoCaseCompare(CompoGenName, "sameblock") == 0) + { + res = new cCompoGenSameBlock; + } + else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0) + { + res = new cCompoGenDebugBiomes; + } + else if (NoCaseCompare(CompoGenName, "classic") == 0) + { + res = new cCompoGenClassic; + } + else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0) + { + res = new cDistortedHeightmap(a_Seed, a_BiomeGen); + } + else if (NoCaseCompare(CompoGenName, "end") == 0) + { + res = new cEndGen(a_Seed); + } + else if (NoCaseCompare(CompoGenName, "nether") == 0) + { + res = new cCompoGenNether(a_Seed); + } + else if (NoCaseCompare(CompoGenName, "Noise3D") == 0) + { + res = new cNoise3DComposable(a_Seed); + } + else if (NoCaseCompare(CompoGenName, "biomal") == 0) + { + res = new cCompoGenBiomal(a_Seed); + + /* + // Performance-testing: + LOGINFO("Measuring performance of cCompoGenBiomal..."); + clock_t BeginTick = clock(); + for (int x = 0; x < 500; x++) + { + cChunkDesc Desc(200 + x * 8, 200 + x * 8); + a_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap()); + a_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap()); + res->ComposeTerrain(Desc); + } + clock_t Duration = clock() - BeginTick; + LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); + //*/ + } + else + { + LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str()); + a_IniFile.SetValue("Generator", "CompositionGen", "Biomal"); + return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed); + } + ASSERT(res != NULL); + + // Read the settings from the ini file: + res->InitializeCompoGen(a_IniFile); + + return res; +} +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cComposableGenerator: + cComposableGenerator::cComposableGenerator(cChunkGenerator & a_ChunkGenerator) : super(a_ChunkGenerator), m_BiomeGen(NULL), @@ -199,67 +275,7 @@ void cComposableGenerator::InitHeightGen(cIniFile & a_IniFile) void cComposableGenerator::InitCompositionGen(cIniFile & a_IniFile) { - int Seed = m_ChunkGenerator.GetSeed(); - AString CompoGenName = a_IniFile.GetValueSet("Generator", "CompositionGen", ""); - if (CompoGenName.empty()) - { - LOGWARN("[Generator] CompositionGen value not set in world.ini, using \"Biomal\"."); - CompoGenName = "Biomal"; - } - if (NoCaseCompare(CompoGenName, "sameblock") == 0) - { - m_CompositionGen = new cCompoGenSameBlock; - } - else if (NoCaseCompare(CompoGenName, "debugbiomes") == 0) - { - m_CompositionGen = new cCompoGenDebugBiomes; - } - else if (NoCaseCompare(CompoGenName, "classic") == 0) - { - m_CompositionGen = new cCompoGenClassic; - } - else if (NoCaseCompare(CompoGenName, "DistortedHeightmap") == 0) - { - m_CompositionGen = new cDistortedHeightmap(Seed, *m_BiomeGen); - } - else if (NoCaseCompare(CompoGenName, "end") == 0) - { - m_CompositionGen = new cEndGen(Seed); - } - else if (NoCaseCompare(CompoGenName, "nether") == 0) - { - m_CompositionGen = new cCompoGenNether(Seed); - } - else if (NoCaseCompare(CompoGenName, "Noise3D") == 0) - { - m_CompositionGen = new cNoise3DComposable(m_ChunkGenerator.GetSeed()); - } - else - { - if (NoCaseCompare(CompoGenName, "biomal") != 0) - { - LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str()); - } - m_CompositionGen = new cCompoGenBiomal(Seed); - - /* - // Performance-testing: - LOGINFO("Measuring performance of cCompoGenBiomal..."); - clock_t BeginTick = clock(); - for (int x = 0; x < 500; x++) - { - cChunkDesc Desc(200 + x * 8, 200 + x * 8); - m_BiomeGen->GenBiomes(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetBiomeMap()); - m_HeightGen->GenHeightMap(Desc.GetChunkX(), Desc.GetChunkZ(), Desc.GetHeightMap()); - m_CompositionGen->ComposeTerrain(Desc); - } - clock_t Duration = clock() - BeginTick; - LOGINFO("CompositionGen for 500 chunks took %d ticks (%.02f sec)", Duration, (double)Duration / CLOCKS_PER_SEC); - //*/ - } - - // Read the settings from the ini file: - m_CompositionGen->InitializeCompoGen(a_IniFile); + m_CompositionGen = cTerrainCompositionGen::CreateCompositionGen(a_IniFile, *m_BiomeGen, *m_HeightGen, m_ChunkGenerator.GetSeed()); int CompoGenCacheSize = a_IniFile.GetValueSetI("Generator", "CompositionGenCacheSize", 64); if (CompoGenCacheSize > 1) diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index a6b77f7b..7c9c9758 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -104,6 +104,12 @@ public: /// Reads parameters from the ini file, prepares generator for use. virtual void InitializeCompoGen(cIniFile & a_IniFile) {} + + /** Creates the correct TerrainCompositionGen descendant based on the ini file settings and the seed provided. + a_BiomeGen is the underlying biome generator, some composition generators may depend on it to generate more biomes + a_HeightGen is the underlying height generator, some composition generators may depend on it providing additional values + */ + static cTerrainCompositionGen * CreateCompositionGen(cIniFile & a_IniFile, cBiomeGen & a_BiomeGen, cTerrainHeightGen & a_HeightGen, int a_Seed); } ; From fe978f0d1e01e284b591e1d5a08ebb24161fd587 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 11:39:42 +0100 Subject: [PATCH 118/144] Added cClientHandle::SendPluginMessage(). It is not yet exported in the API, though. --- src/ClientHandle.cpp | 9 +++++++++ src/ClientHandle.h | 1 + src/Protocol/Protocol.h | 1 + src/Protocol/Protocol125.cpp | 14 ++++++++++++++ src/Protocol/Protocol125.h | 1 + src/Protocol/Protocol17x.cpp | 12 ++++++++++++ src/Protocol/Protocol17x.h | 1 + src/Protocol/ProtocolRecognizer.cpp | 10 ++++++++++ src/Protocol/ProtocolRecognizer.h | 1 + 9 files changed, 50 insertions(+) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 8125acb4..9348a182 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1978,6 +1978,15 @@ void cClientHandle::SendPlayerSpawn(const cPlayer & a_Player) +void cClientHandle::SendPluginMessage(const AString & a_Channel, const AString & a_Message) +{ + m_Protocol->SendPluginMessage(a_Channel, a_Message); +} + + + + + void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) { m_Protocol->SendRemoveEntityEffect(a_Entity, a_EffectID); diff --git a/src/ClientHandle.h b/src/ClientHandle.h index bc17df78..297d62d5 100644 --- a/src/ClientHandle.h +++ b/src/ClientHandle.h @@ -120,6 +120,7 @@ public: void SendPlayerMoveLook (void); void SendPlayerPosition (void); void SendPlayerSpawn (const cPlayer & a_Player); + void SendPluginMessage (const AString & a_Channel, const AString & a_Message); // Exported in ManualBindings.cpp void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID); void SendRespawn (void); void SendExperience (void); diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h index fdbffb3e..3293da32 100644 --- a/src/Protocol/Protocol.h +++ b/src/Protocol/Protocol.h @@ -87,6 +87,7 @@ public: virtual void SendPlayerMoveLook (void) = 0; virtual void SendPlayerPosition (void) = 0; virtual void SendPlayerSpawn (const cPlayer & a_Player) = 0; + virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) = 0; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) = 0; virtual void SendRespawn (void) = 0; virtual void SendExperience (void) = 0; diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp index e49dd43f..48c085ae 100644 --- a/src/Protocol/Protocol125.cpp +++ b/src/Protocol/Protocol125.cpp @@ -704,6 +704,20 @@ void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocol125::SendPluginMessage(const AString & a_Channel, const AString & a_Message) +{ + cCSLock Lock(m_CSPacket); + WriteByte(PACKET_PLUGIN_MESSAGE); + WriteString(a_Channel); + WriteShort((short)a_Message.size()); + SendData(a_Message.data(), a_Message.size()); + Flush(); +} + + + + + void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) { cCSLock Lock(m_CSPacket); diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 0b32137d..d0e5c942 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -63,6 +63,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (void) override; virtual void SendExperience (void) override; diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index 8ec5dec2..c64aa088 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -628,6 +628,18 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocol172::SendPluginMessage(const AString & a_Channel, const AString & a_Message) +{ + cPacketizer Pkt(*this, 0x17); + Pkt.WriteString(a_Channel); + Pkt.WriteShort((short)a_Message.size()); + Pkt.WriteBuf(a_Message.data(), a_Message.size()); +} + + + + + void cProtocol172::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) { cPacketizer Pkt(*this, 0x1E); diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h index 23ff2365..fd6b1fc0 100644 --- a/src/Protocol/Protocol17x.h +++ b/src/Protocol/Protocol17x.h @@ -86,6 +86,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (void) override; virtual void SendSoundEffect (const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch) override; // a_Src coords are Block * 8 diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp index e2ea0e6e..a21f4f04 100644 --- a/src/Protocol/ProtocolRecognizer.cpp +++ b/src/Protocol/ProtocolRecognizer.cpp @@ -476,6 +476,16 @@ void cProtocolRecognizer::SendPlayerSpawn(const cPlayer & a_Player) +void cProtocolRecognizer::SendPluginMessage(const AString & a_Channel, const AString & a_Message) +{ + ASSERT(m_Protocol != NULL); + m_Protocol->SendPluginMessage(a_Channel, a_Message); +} + + + + + void cProtocolRecognizer::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID) { ASSERT(m_Protocol != NULL); diff --git a/src/Protocol/ProtocolRecognizer.h b/src/Protocol/ProtocolRecognizer.h index fbcf59f3..e94f4cde 100644 --- a/src/Protocol/ProtocolRecognizer.h +++ b/src/Protocol/ProtocolRecognizer.h @@ -98,6 +98,7 @@ public: virtual void SendPlayerMoveLook (void) override; virtual void SendPlayerPosition (void) override; virtual void SendPlayerSpawn (const cPlayer & a_Player) override; + virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override; virtual void SendRemoveEntityEffect (const cEntity & a_Entity, int a_EffectID) override; virtual void SendRespawn (void) override; virtual void SendExperience (void) override; From 6c75cbc8d75b5a2ba9ee071740edd43efeaac1e9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Thu, 9 Jan 2014 13:30:04 +0100 Subject: [PATCH 119/144] Fixed chunk borders. --- src/Generating/CompoGen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 3545863f..8d6c918c 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -592,9 +592,9 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) BLOCKTYPE Block = E_BLOCK_AIR; if (Val < m_Threshold) // Don't calculate if the block should be Netherrack or Soulsand when it's already decided that it's air. { - NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX * cChunkDef::Width + x)) / 8; - NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ * cChunkDef::Width + z)) / 8; - NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y, NoiseY); + NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX + x)) / 8; + NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ + z)) / 8; + NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y / 2, NoiseY); if (CompBlock < -0.5) { Block = E_BLOCK_SOULSAND; From f3bedb3c32dc39424712f5f98de7c9eab2fc56d1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 14:24:57 +0100 Subject: [PATCH 120/144] Fixed wrong packet number for PluginMessage packet. --- src/Protocol/Protocol17x.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index c64aa088..9c46c684 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -630,7 +630,7 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player) void cProtocol172::SendPluginMessage(const AString & a_Channel, const AString & a_Message) { - cPacketizer Pkt(*this, 0x17); + cPacketizer Pkt(*this, 0x3f); Pkt.WriteString(a_Channel); Pkt.WriteShort((short)a_Message.size()); Pkt.WriteBuf(a_Message.data(), a_Message.size()); From bb96737f455bbfb52864703e74397c61475936b4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 14:25:37 +0100 Subject: [PATCH 121/144] Exported cClientHandle::SendPluginMessage() to Lua. --- src/Bindings/ManualBindings.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 6221727c..344d5d2e 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1904,6 +1904,35 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) +static int tolua_cClientHandle_SendPluginMessage(lua_State * L) +{ + cLuaState S(L); + if ( + !S.CheckParamUserType(1, "cClientHandle") || + !S.CheckParamString(2, 3) || + !S.CheckParamEnd(4) + ) + { + return 0; + } + cClientHandle * Client = (cClientHandle *)tolua_tousertype(L, 1, NULL); + if (Client == NULL) + { + LOGWARNING("ClientHandle is nil in cClientHandle:SendPluginMessage()"); + S.LogStackTrace(); + return 0; + } + AString Channel, Message; + Channel.assign(lua_tostring(L, 2), lua_strlen(L, 2)); + Message.assign(lua_tostring(L, 3), lua_strlen(L, 3)); + Client->SendPluginMessage(Channel, Message); + return 0; +} + + + + + static int Lua_ItemGrid_GetSlotCoords(lua_State * L) { tolua_Error tolua_err; @@ -2292,6 +2321,7 @@ void ManualBindings::Bind(lua_State * tolua_S) tolua_beginmodule(tolua_S, "cClientHandle"); tolua_constant(tolua_S, "MAX_VIEW_DISTANCE", cClientHandle::MAX_VIEW_DISTANCE); tolua_constant(tolua_S, "MIN_VIEW_DISTANCE", cClientHandle::MIN_VIEW_DISTANCE); + tolua_function(tolua_S, "SendPluginMessage", tolua_cClientHandle_SendPluginMessage); tolua_endmodule(tolua_S); tolua_beginmodule(tolua_S, "cItemGrid"); From 00af5d4d6e26ad0d48085d7204a3b8d42b34edac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 9 Jan 2014 14:26:44 +0100 Subject: [PATCH 122/144] Debuggers: Test code for WECUI plugin messaging. --- MCServer/Plugins/Debuggers/Debuggers.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 7b43b6c2..8512fbd5 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -966,6 +966,23 @@ end function OnPluginMessage(a_Client, a_Channel, a_Message) LOGINFO("Received a plugin message from client " .. a_Client:GetUsername() .. ": channel '" .. a_Channel .. "', message '" .. a_Message .. "'"); + + if (a_Channel == "REGISTER") then + if (a_Message:find("WECUI")) then + -- The client has WorldEditCUI mod installed, test the comm by sending a few WECUI messages: + --[[ + WECUI messages have the following generic format: + | + If shape is p (cuboid selection), the params are sent individually for each corner click and have the following format: + |||| + point-index is 0 or 1 (lclk / rclk) + volume is the 3D volume of the current cuboid selected (all three coords' deltas multiplied), including the edge blocks; -1 if N/A + --]] + -- Select a 51 * 51 * 51 block cuboid: + a_Client:SendPluginMessage("WECUI", "p|0|50|50|50|-1"); + a_Client:SendPluginMessage("WECUI", "p|1|100|100|100|132651"); -- 132651 = 51 * 51 * 51 + end + end end From cee76f1ace49fea1ed3a3ebd6476cca9b799c5b2 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Thu, 9 Jan 2014 15:21:46 -0600 Subject: [PATCH 123/144] Move biome definition to separate files --- VC2008/MCServer.vcproj | 6 +- src/Bindings/AllToLua.pkg | 1 + src/BiomeDef.cpp | 130 ++++++++++++++++++++++++++++++++++++++ src/BiomeDef.h | 107 +++++++++++++++++++++++++++++++ src/BlockID.cpp | 100 ----------------------------- src/BlockID.h | 3 - src/ChunkDef.h | 93 +-------------------------- src/Defines.h | 28 -------- src/Globals.h | 1 + 9 files changed, 246 insertions(+), 223 deletions(-) create mode 100644 src/BiomeDef.cpp create mode 100644 src/BiomeDef.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index a017b5a2..2b11c06d 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -1,7 +1,7 @@ 
+ + diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index e9a5ea0c..f209d676 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -14,6 +14,7 @@ typedef unsigned short UInt16; $cfile "../ChunkDef.h" +$cfile "../BiomeDef.h" $cfile "../../lib/inifile/iniFile.h" diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp new file mode 100644 index 00000000..06b48e9d --- /dev/null +++ b/src/BiomeDef.cpp @@ -0,0 +1,130 @@ + +// BiomeDef.cpp + +// Implements biome helper functions + + + + +EMCSBiome StringToBiome(const AString & a_BiomeString) +{ + // If it is a number, return it: + int res = atoi(a_BiomeString.c_str()); + if ((res != 0) || (a_BiomeString.compare("0") == 0)) + { + // It was a valid number + return (EMCSBiome)res; + } + + // Convert using the built-in map: + static struct { + EMCSBiome m_Biome; + const char * m_String; + } BiomeMap[] = + { + {biOcean, "Ocean"} , + {biPlains, "Plains"}, + {biDesert, "Desert"}, + {biExtremeHills, "ExtremeHills"}, + {biForest, "Forest"}, + {biTaiga, "Taiga"}, + {biSwampland, "Swampland"}, + {biRiver, "River"}, + {biNether, "Hell"}, + {biNether, "Nether"}, + {biEnd, "Sky"}, + {biEnd, "End"}, + {biFrozenOcean, "FrozenOcean"}, + {biFrozenRiver, "FrozenRiver"}, + {biIcePlains, "IcePlains"}, + {biIcePlains, "Tundra"}, + {biIceMountains, "IceMountains"}, + {biMushroomIsland, "MushroomIsland"}, + {biMushroomShore, "MushroomShore"}, + {biBeach, "Beach"}, + {biDesertHills, "DesertHills"}, + {biForestHills, "ForestHills"}, + {biTaigaHills, "TaigaHills"}, + {biExtremeHillsEdge, "ExtremeHillsEdge"}, + {biJungle, "Jungle"}, + {biJungleHills, "JungleHills"}, + + // Release 1.7 biomes: + {biJungleEdge, "JungleEdge"}, + {biDeepOcean, "DeepOcean"}, + {biStoneBeach, "StoneBeach"}, + {biColdBeach, "ColdBeach"}, + {biBirchForest, "BirchForest"}, + {biBirchForestHills, "BirchForestHills"}, + {biRoofedForest, "RoofedForest"}, + {biColdTaiga, "ColdTaiga"}, + {biColdTaigaHills, "ColdTaigaHills"}, + {biMegaTaiga, "MegaTaiga"}, + {biMegaTaigaHills, "MegaTaigaHills"}, + {biExtremeHillsPlus, "ExtremeHillsPlus"}, + {biSavanna, "Savanna"}, + {biSavannaPlateau, "SavannaPlateau"}, + {biMesa, "Mesa"}, + {biMesaPlateauF, "MesaPlateauF"}, + {biMesaPlateau, "MesaPlateau"}, + + // Release 1.7 variants: + {biSunflowerPlains, "SunflowerPlains"}, + {biDesertM, "DesertM"}, + {biExtremeHillsM, "ExtremeHillsM"}, + {biFlowerForest, "FlowerForest"}, + {biTaigaM, "TaigaM"}, + {biSwamplandM, "SwamplandM"}, + {biIcePlainsSpikes, "IcePlainsSpikes"}, + {biJungleM, "JungleM"}, + {biJungleEdgeM, "JungleEdgeM"}, + {biBirchForestM, "BirchForestM"}, + {biBirchForestHillsM, "BirchForestHillsM"}, + {biRoofedForestM, "RoofedForestM"}, + {biColdTaigaM, "ColdTaigaM"}, + {biMegaSpruceTaiga, "MegaSpruceTaiga"}, + {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, + {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, + {biSavannaM, "SavannaM"}, + {biSavannaPlateauM, "SavannaPlateauM"}, + {biMesaBryce, "MesaBryce"}, + {biMesaPlateauFM, "MesaPlateauFM"}, + {biMesaPlateauM, "MesaPlateauM"}, + } ; + + for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++) + { + if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) + { + return BiomeMap[i].m_Biome; + } + } // for i - BiomeMap[] + return (EMCSBiome)-1; +} + + + + + +bool IsBiomeNoDownfall(EMCSBiome a_Biome) +{ + switch (a_Biome) + { + case biDesert: + case biDesertHills: + case biDesertM: + case biSavanna: + case biSavannaM: + case biSavannaPlateau: + case biSavannaPlateauM: + case biNether: + case biEnd: + { + return true; + } + default: + { + return false; + } + } +} \ No newline at end of file diff --git a/src/BiomeDef.h b/src/BiomeDef.h new file mode 100644 index 00000000..e1c29bc0 --- /dev/null +++ b/src/BiomeDef.h @@ -0,0 +1,107 @@ + +// BiomeDef.h + +// Defines relevant information and methods related to biomes + + + + + +#pragma once + + + + + +// tolua_begin +/** Biome IDs +The first batch corresponds to the clientside biomes, used by MineCraft. +BiomeIDs over 255 are used by MCServer internally and are translated to MC biomes before sending them to client +*/ +enum EMCSBiome +{ + biOcean = 0, + biPlains = 1, + biDesert = 2, + biExtremeHills = 3, + biForest = 4, + biTaiga = 5, + biSwampland = 6, + biRiver = 7, + biHell = 8, // same as Nether + biNether = 8, + biSky = 9, // same as biEnd + biEnd = 9, + biFrozenOcean = 10, + biFrozenRiver = 11, + biIcePlains = 12, + biTundra = 12, // same as Ice Plains + biIceMountains = 13, + biMushroomIsland = 14, + biMushroomShore = 15, + biBeach = 16, + biDesertHills = 17, + biForestHills = 18, + biTaigaHills = 19, + biExtremeHillsEdge = 20, + biJungle = 21, + biJungleHills = 22, + + // Release 1.7 biomes: + biJungleEdge = 23, + biDeepOcean = 24, + biStoneBeach = 25, + biColdBeach = 26, + biBirchForest = 27, + biBirchForestHills = 28, + biRoofedForest = 29, + biColdTaiga = 30, + biColdTaigaHills = 31, + biMegaTaiga = 32, + biMegaTaigaHills = 33, + biExtremeHillsPlus = 34, + biSavanna = 35, + biSavannaPlateau = 36, + biMesa = 37, + biMesaPlateauF = 38, + biMesaPlateau = 39, + + // Automatically capture the maximum consecutive biome value into biMaxBiome: + biNumBiomes, // True number of biomes, since they are zero-based + biMaxBiome = biNumBiomes - 1, // The maximum biome value + + // Add this number to the biomes to get the variant + biVariant = 128, + + // Release 1.7 biome variants: + biSunflowerPlains = 129, + biDesertM = 130, + biExtremeHillsM = 131, + biFlowerForest = 132, + biTaigaM = 133, + biSwamplandM = 134, + biIcePlainsSpikes = 140, + biJungleM = 149, + biJungleEdgeM = 151, + biBirchForestM = 155, + biBirchForestHillsM = 156, + biRoofedForestM = 157, + biColdTaigaM = 158, + biMegaSpruceTaiga = 160, + biMegaSpruceTaigaHills = 161, + biExtremeHillsPlusM = 162, + biSavannaM = 163, + biSavannaPlateauM = 164, + biMesaBryce = 165, + biMesaPlateauFM = 166, + biMesaPlateauM = 167, +} ; + +/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure. +extern EMCSBiome StringToBiome(const AString & a_BiomeString); + +/// Returns true if the biome has no downfall - deserts and savannas +extern bool IsBiomeNoDownfall(EMCSBiome a_Biome); + + +// tolua_end \ No newline at end of file diff --git a/src/BlockID.cpp b/src/BlockID.cpp index 05d4c659..b609af57 100644 --- a/src/BlockID.cpp +++ b/src/BlockID.cpp @@ -267,106 +267,6 @@ AString ItemToFullString(const cItem & a_Item) -EMCSBiome StringToBiome(const AString & a_BiomeString) -{ - // If it is a number, return it: - int res = atoi(a_BiomeString.c_str()); - if ((res != 0) || (a_BiomeString.compare("0") == 0)) - { - // It was a valid number - return (EMCSBiome)res; - } - - // Convert using the built-in map: - static struct { - EMCSBiome m_Biome; - const char * m_String; - } BiomeMap[] = - { - {biOcean, "Ocean"} , - {biPlains, "Plains"}, - {biDesert, "Desert"}, - {biExtremeHills, "ExtremeHills"}, - {biForest, "Forest"}, - {biTaiga, "Taiga"}, - {biSwampland, "Swampland"}, - {biRiver, "River"}, - {biNether, "Hell"}, - {biNether, "Nether"}, - {biEnd, "Sky"}, - {biEnd, "End"}, - {biFrozenOcean, "FrozenOcean"}, - {biFrozenRiver, "FrozenRiver"}, - {biIcePlains, "IcePlains"}, - {biIcePlains, "Tundra"}, - {biIceMountains, "IceMountains"}, - {biMushroomIsland, "MushroomIsland"}, - {biMushroomShore, "MushroomShore"}, - {biBeach, "Beach"}, - {biDesertHills, "DesertHills"}, - {biForestHills, "ForestHills"}, - {biTaigaHills, "TaigaHills"}, - {biExtremeHillsEdge, "ExtremeHillsEdge"}, - {biJungle, "Jungle"}, - {biJungleHills, "JungleHills"}, - - // Release 1.7 biomes: - {biJungleEdge, "JungleEdge"}, - {biDeepOcean, "DeepOcean"}, - {biStoneBeach, "StoneBeach"}, - {biColdBeach, "ColdBeach"}, - {biBirchForest, "BirchForest"}, - {biBirchForestHills, "BirchForestHills"}, - {biRoofedForest, "RoofedForest"}, - {biColdTaiga, "ColdTaiga"}, - {biColdTaigaHills, "ColdTaigaHills"}, - {biMegaTaiga, "MegaTaiga"}, - {biMegaTaigaHills, "MegaTaigaHills"}, - {biExtremeHillsPlus, "ExtremeHillsPlus"}, - {biSavanna, "Savanna"}, - {biSavannaPlateau, "SavannaPlateau"}, - {biMesa, "Mesa"}, - {biMesaPlateauF, "MesaPlateauF"}, - {biMesaPlateau, "MesaPlateau"}, - - // Release 1.7 variants: - {biSunflowerPlains, "SunflowerPlains"}, - {biDesertM, "DesertM"}, - {biExtremeHillsM, "ExtremeHillsM"}, - {biFlowerForest, "FlowerForest"}, - {biTaigaM, "TaigaM"}, - {biSwamplandM, "SwamplandM"}, - {biIcePlainsSpikes, "IcePlainsSpikes"}, - {biJungleM, "JungleM"}, - {biJungleEdgeM, "JungleEdgeM"}, - {biBirchForestM, "BirchForestM"}, - {biBirchForestHillsM, "BirchForestHillsM"}, - {biRoofedForestM, "RoofedForestM"}, - {biColdTaigaM, "ColdTaigaM"}, - {biMegaSpruceTaiga, "MegaSpruceTaiga"}, - {biMegaSpruceTaigaHills, "MegaSpruceTaigaHills"}, - {biExtremeHillsPlusM, "ExtremeHillsPlusM"}, - {biSavannaM, "SavannaM"}, - {biSavannaPlateauM, "SavannaPlateauM"}, - {biMesaBryce, "MesaBryce"}, - {biMesaPlateauFM, "MesaPlateauFM"}, - {biMesaPlateauM, "MesaPlateauM"}, - } ; - - for (size_t i = 0; i < ARRAYCOUNT(BiomeMap); i++) - { - if (NoCaseCompare(BiomeMap[i].m_String, a_BiomeString) == 0) - { - return BiomeMap[i].m_Biome; - } - } // for i - BiomeMap[] - return (EMCSBiome)-1; -} - - - - - int StringToMobType(const AString & a_MobString) { static struct { diff --git a/src/BlockID.h b/src/BlockID.h index 288719cc..899336fa 100644 --- a/src/BlockID.h +++ b/src/BlockID.h @@ -876,9 +876,6 @@ extern AString ItemTypeToString(short a_ItemType); /// Translates a full item into a fully-specified string (including meta and count). If the ItemType is not recognized, the ItemType number is output into the string. extern AString ItemToFullString(const cItem & a_Item); -/// Translates a biome string to biome enum. Takes either a number or a biome alias (built-in). Returns -1 on failure. -extern EMCSBiome StringToBiome(const AString & a_BiomeString); - /// Translates a mob string ("ocelot") to mobtype (E_ENTITY_TYPE_OCELOT) extern int StringToMobType(const AString & a_MobString); diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 7d727a4d..442c9633 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -38,6 +38,8 @@ class cBlockEntity; typedef std::list cEntityList; typedef std::list cBlockEntityList; +enum EMCSBiome; + @@ -57,97 +59,6 @@ typedef unsigned char HEIGHTTYPE; - - -// tolua_begin -/** Biome IDs -The first batch corresponds to the clientside biomes, used by MineCraft. -BiomeIDs over 255 are used by MCServer internally and are translated to MC biomes before sending them to client -*/ -enum EMCSBiome -{ - biOcean = 0, - biPlains = 1, - biDesert = 2, - biExtremeHills = 3, - biForest = 4, - biTaiga = 5, - biSwampland = 6, - biRiver = 7, - biHell = 8, // same as Nether - biNether = 8, - biSky = 9, // same as biEnd - biEnd = 9, - biFrozenOcean = 10, - biFrozenRiver = 11, - biIcePlains = 12, - biTundra = 12, // same as Ice Plains - biIceMountains = 13, - biMushroomIsland = 14, - biMushroomShore = 15, - biBeach = 16, - biDesertHills = 17, - biForestHills = 18, - biTaigaHills = 19, - biExtremeHillsEdge = 20, - biJungle = 21, - biJungleHills = 22, - - // Release 1.7 biomes: - biJungleEdge = 23, - biDeepOcean = 24, - biStoneBeach = 25, - biColdBeach = 26, - biBirchForest = 27, - biBirchForestHills = 28, - biRoofedForest = 29, - biColdTaiga = 30, - biColdTaigaHills = 31, - biMegaTaiga = 32, - biMegaTaigaHills = 33, - biExtremeHillsPlus = 34, - biSavanna = 35, - biSavannaPlateau = 36, - biMesa = 37, - biMesaPlateauF = 38, - biMesaPlateau = 39, - - // Automatically capture the maximum consecutive biome value into biMaxBiome: - biNumBiomes, // True number of biomes, since they are zero-based - biMaxBiome = biNumBiomes - 1, // The maximum biome value - - // Add this number to the biomes to get the variant - biVariant = 128, - - // Release 1.7 biome variants: - biSunflowerPlains = 129, - biDesertM = 130, - biExtremeHillsM = 131, - biFlowerForest = 132, - biTaigaM = 133, - biSwamplandM = 134, - biIcePlainsSpikes = 140, - biJungleM = 149, - biJungleEdgeM = 151, - biBirchForestM = 155, - biBirchForestHillsM = 156, - biRoofedForestM = 157, - biColdTaigaM = 158, - biMegaSpruceTaiga = 160, - biMegaSpruceTaigaHills = 161, - biExtremeHillsPlusM = 162, - biSavannaM = 163, - biSavannaPlateauM = 164, - biMesaBryce = 165, - biMesaPlateauFM = 166, - biMesaPlateauM = 167, -} ; - -// tolua_end - - - - /// Constants used throughout the code, useful typedefs and utility functions class cChunkDef { diff --git a/src/Defines.h b/src/Defines.h index 534802d5..c75effa4 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -563,34 +563,6 @@ namespace ItemCategory } } - - - - -/// Returns true if the biome has no downfall - deserts and savannas -inline bool IsBiomeNoDownfall(EMCSBiome a_Biome) -{ - switch (a_Biome) - { - case biDesert: - case biDesertHills: - case biDesertM: - case biSavanna: - case biSavannaM: - case biSavannaPlateau: - case biSavannaPlateauM: - case biNether: - case biEnd: - { - return true; - } - default: - { - return false; - } - } -} - // tolua_end diff --git a/src/Globals.h b/src/Globals.h index f886ba2d..d2080b8e 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -233,6 +233,7 @@ public: // Common headers (part 2, with macros): #include "ChunkDef.h" +#include "BiomeDef.h" #include "BlockID.h" #include "Entities/Effects.h" From 1704d0fd6bae38066d6b15e6468dadc058d1f703 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 10 Jan 2014 10:03:39 +0100 Subject: [PATCH 124/144] Using dlopen() on all platforms except WIN32. --- lib/lua/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt index ff5dc927..af03f4b1 100644 --- a/lib/lua/CMakeLists.txt +++ b/lib/lua/CMakeLists.txt @@ -27,11 +27,7 @@ endif() # Tell Lua what dynamic loader to use (for LuaRocks): if (UNIX) - if (APPLE) - add_definitions(-DLUA_USE_MACOSX) - else() - add_definitions(-DLUA_USE_LINUX) - endif () + add_definitions(-DLUA_USE_DLOPEN) endif() if (UNIX) From 8104f611f1c4ed80866803bf5504fc2a1ceedaca Mon Sep 17 00:00:00 2001 From: Matyas Dolak Date: Fri, 10 Jan 2014 11:55:43 +0100 Subject: [PATCH 125/144] BiomeVisualiser: Added zooming using the 1 - 8 keys. --- Tools/BiomeVisualiser/.gitignore | 1 + Tools/BiomeVisualiser/BiomeRenderer.cpp | 12 ++-- Tools/BiomeVisualiser/BiomeRenderer.h | 5 ++ Tools/BiomeVisualiser/BiomeViewWnd.cpp | 64 +++++++++++++++++--- Tools/BiomeVisualiser/BiomeViewWnd.h | 4 ++ Tools/BiomeVisualiser/BiomeVisualiser.vcproj | 10 +-- 6 files changed, 76 insertions(+), 20 deletions(-) diff --git a/Tools/BiomeVisualiser/.gitignore b/Tools/BiomeVisualiser/.gitignore index b4e15dc3..cfbc9164 100644 --- a/Tools/BiomeVisualiser/.gitignore +++ b/Tools/BiomeVisualiser/.gitignore @@ -1,3 +1,4 @@ Debug/ logs/ Release/ +Release profiled/ diff --git a/Tools/BiomeVisualiser/BiomeRenderer.cpp b/Tools/BiomeVisualiser/BiomeRenderer.cpp index 758eb4b4..569128a1 100644 --- a/Tools/BiomeVisualiser/BiomeRenderer.cpp +++ b/Tools/BiomeVisualiser/BiomeRenderer.cpp @@ -40,10 +40,10 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap) int Hei = a_Pixmap.GetHeight(); // Hint the approximate view area to the biome source so that it can adjust its caches: - int MinBlockX = ( - m_OriginX) / m_Zoom; - int MaxBlockX = (Wid - m_OriginX) / m_Zoom; - int MinBlockZ = ( - m_OriginY) / m_Zoom; - int MaxBlockZ = (Hei - m_OriginY) / m_Zoom; + int MinBlockX = ( - m_OriginX) * m_Zoom; + int MaxBlockX = (Wid - m_OriginX) * m_Zoom; + int MinBlockZ = ( - m_OriginY) * m_Zoom; + int MaxBlockZ = (Hei - m_OriginY) * m_Zoom; m_Cache.HintViewArea(MinBlockX / 16 - 1, MaxBlockX / 16 + 1, MinBlockZ / 16 - 1, MaxBlockZ / 16 + 1); // Hold one current chunk of biome data: @@ -55,12 +55,12 @@ bool cBiomeRenderer::Render(cPixmap & a_Pixmap) for (int y = 0; y < Hei; y++) { - int BlockZ = (y - m_OriginY) / m_Zoom; + int BlockZ = (y - m_OriginY) * m_Zoom; int ChunkZ = (BlockZ >= 0) ? (BlockZ / 16) : ((BlockZ + 1) / 16 - 1); int RelZ = BlockZ - ChunkZ * 16; for (int x = 0; x < Wid; x++) { - int BlockX = (x - m_OriginX) / m_Zoom; + int BlockX = (x - m_OriginX) * m_Zoom; int ChunkX = (BlockX >= 0) ? (BlockX / 16) : ((BlockX + 1) / 16 - 1); int RelX = BlockX - ChunkX * 16; if ((ChunkZ != CurChunkZ) || (ChunkX != CurChunkX)) diff --git a/Tools/BiomeVisualiser/BiomeRenderer.h b/Tools/BiomeVisualiser/BiomeRenderer.h index 2590e040..752b6181 100644 --- a/Tools/BiomeVisualiser/BiomeRenderer.h +++ b/Tools/BiomeVisualiser/BiomeRenderer.h @@ -37,6 +37,11 @@ public: void MoveViewBy(int a_OffsX, int a_OffsY); + void SetZoom(int a_NewZoom) + { + m_Zoom = a_NewZoom; + } + protected: cBiomeCache m_Cache; diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.cpp b/Tools/BiomeVisualiser/BiomeViewWnd.cpp index 5c1240bc..7fb61c06 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.cpp +++ b/Tools/BiomeVisualiser/BiomeViewWnd.cpp @@ -67,17 +67,41 @@ void cBiomeViewWnd::InitBiomeView(void) +void cBiomeViewWnd::SetZoom(int a_NewZoom) +{ + m_Renderer.SetZoom(a_NewZoom); + Redraw(); +} + + + + + +void cBiomeViewWnd::Redraw(void) +{ + if (m_Renderer.Render(m_Pixmap)) + { + SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL); + } + InvalidateRect(m_Wnd, NULL, FALSE); +} + + + + + LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam) { switch (a_Msg) { - case WM_CLOSE: return OnClose(); - case WM_COMMAND: return OnCommand(wParam, lParam); + case WM_CHAR: return OnChar (wParam, lParam); + case WM_CLOSE: return OnClose (); + case WM_COMMAND: return OnCommand (wParam, lParam); case WM_LBUTTONDOWN: return OnLButtonDown(wParam, lParam); case WM_LBUTTONUP: return OnLButtonUp (wParam, lParam); case WM_MOUSEMOVE: return OnMouseMove (wParam, lParam); - case WM_PAINT: return OnPaint(); - case WM_TIMER: return OnTimer(wParam); + case WM_PAINT: return OnPaint (); + case WM_TIMER: return OnTimer (wParam); } return ::DefWindowProc(a_Wnd, a_Msg, wParam, lParam); } @@ -86,6 +110,32 @@ LRESULT cBiomeViewWnd::WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lPa +LRESULT cBiomeViewWnd::OnChar(WPARAM wParam, LPARAM lParam) +{ + switch (wParam) + { + case '1': SetZoom(1); break; + case '2': SetZoom(2); break; + case '3': SetZoom(3); break; + case '4': SetZoom(4); break; + case '5': SetZoom(5); break; + case '6': SetZoom(6); break; + case '7': SetZoom(7); break; + case '8': SetZoom(8); break; + case 27: + { + // Esc pressed, exit + PostQuitMessage(0); + break; + } + } + return 0; +} + + + + + LRESULT cBiomeViewWnd::OnClose(void) { PostQuitMessage(0); @@ -126,12 +176,8 @@ LRESULT cBiomeViewWnd::OnMouseMove(WPARAM wParam, LPARAM lParam) POINT pnt; GetCursorPos(&pnt); m_Renderer.MoveViewBy(pnt.x - m_MouseDown.x, pnt.y - m_MouseDown.y); - if (m_Renderer.Render(m_Pixmap)) - { - SetTimer(m_Wnd, TIMER_RERENDER, 200, NULL); - } m_MouseDown = pnt; - InvalidateRect(m_Wnd, NULL, FALSE); + Redraw(); return 0; } diff --git a/Tools/BiomeVisualiser/BiomeViewWnd.h b/Tools/BiomeVisualiser/BiomeViewWnd.h index e3f70c7e..70c5e38f 100644 --- a/Tools/BiomeVisualiser/BiomeViewWnd.h +++ b/Tools/BiomeVisualiser/BiomeViewWnd.h @@ -48,9 +48,13 @@ protected: void InitBiomeView(void); + void SetZoom(int a_NewZoom); + void Redraw(void); + LRESULT WndProc(HWND a_Wnd, UINT a_Msg, WPARAM wParam, LPARAM lParam); // Message handlers: + LRESULT OnChar (WPARAM wParam, LPARAM lParam); LRESULT OnClose (void); LRESULT OnCommand (WPARAM wParam, LPARAM lParam); LRESULT OnLButtonDown(WPARAM wParam, LPARAM lParam); diff --git a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj index e42870b1..36865793 100644 --- a/Tools/BiomeVisualiser/BiomeVisualiser.vcproj +++ b/Tools/BiomeVisualiser/BiomeVisualiser.vcproj @@ -1,7 +1,7 @@ + + @@ -501,10 +505,6 @@ - - From 36c100a53ed70c38d304c3d2837940e699e9f2a1 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 10 Jan 2014 16:12:45 +0100 Subject: [PATCH 126/144] Fixed recurring pattern. --- src/Generating/CompoGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generating/CompoGen.cpp b/src/Generating/CompoGen.cpp index 8d6c918c..60356fe4 100644 --- a/src/Generating/CompoGen.cpp +++ b/src/Generating/CompoGen.cpp @@ -594,7 +594,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc) { NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX + x)) / 8; NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ + z)) / 8; - NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) y / 2, NoiseY); + NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) (y + Segment) / 2, NoiseY); if (CompBlock < -0.5) { Block = E_BLOCK_SOULSAND; From 4c360b54e3c3f8dcecf11adff9ffd5c2eaef0024 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 10 Jan 2014 16:23:22 +0100 Subject: [PATCH 127/144] Fixed cIniFile's SetValue(). How did we not see this earlier? Each call to SetValue would actually ADD a value! --- lib/inifile/iniFile.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index da523e78..5ca6f661 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -384,15 +384,7 @@ bool cIniFile::SetValue(const AString & keyname, const AString & valuename, cons } else { - if (!create) - { - keys[keyID].values[valueID] = value; - } - else - { - keys[keyID].names.resize(keys[keyID].names.size() + 1, valuename); - keys[keyID].values.resize(keys[keyID].values.size() + 1, value); - } + keys[keyID].values[valueID] = value; } return true; From 1c2004dfbbd520b929357bce13cdeb06d41ce0ff Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 09:23:53 -0600 Subject: [PATCH 128/144] Fixed missing externals Turns out you actually have to include the .cpp in the project file --- VC2008/MCServer.vcproj | 4 ++++ src/BiomeDef.cpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 2b11c06d..c5cd7c6d 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -442,6 +442,10 @@ RelativePath="..\src\Authenticator.h" > + + diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index 06b48e9d..f7f48db9 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -3,7 +3,8 @@ // Implements biome helper functions - +#include "BiomeDef.h" +#include "Globals.h" EMCSBiome StringToBiome(const AString & a_BiomeString) From 0a72390587778aa75e033015ae12965102bae3ca Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 09:33:48 -0600 Subject: [PATCH 129/144] Added files to VC2013 project file --- VC2013/MCServer.vcxproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VC2013/MCServer.vcxproj b/VC2013/MCServer.vcxproj index 9daecba0..d52c1632 100644 --- a/VC2013/MCServer.vcxproj +++ b/VC2013/MCServer.vcxproj @@ -234,6 +234,8 @@ + + From 712e6e0bb2ef2accf4ffc7792c1ad0ab0ae96662 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 10 Jan 2014 16:33:53 +0100 Subject: [PATCH 130/144] Fixed generator adding values to ini file. --- src/Generating/ComposableGenerator.cpp | 3 ++- src/Generating/HeiGen.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 76d06724..971ff453 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -90,7 +90,8 @@ cTerrainCompositionGen * cTerrainCompositionGen::CreateCompositionGen(cIniFile & } else { - LOGWARN("Unknown CompositionGen \"%s\", using \"biomal\" instead.", CompoGenName.c_str()); + LOGWARN("Unknown CompositionGen \"%s\", using \"Biomal\" instead.", CompoGenName.c_str()); + a_IniFile.DeleteValue("Generator", "CompositionGen"); a_IniFile.SetValue("Generator", "CompositionGen", "Biomal"); return CreateCompositionGen(a_IniFile, a_BiomeGen, a_HeightGen, a_Seed); } diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp index 051758f7..10710b4a 100644 --- a/src/Generating/HeiGen.cpp +++ b/src/Generating/HeiGen.cpp @@ -72,6 +72,7 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio { // No match found, force-set the default and retry LOGWARN("Unknown HeightGen \"%s\", using \"Biomal\" instead.", HeightGenName.c_str()); + a_IniFile.DeleteValue("Generator", "HeightGen"); a_IniFile.SetValue("Generator", "HeightGen", "Biomal"); return CreateHeightGen(a_IniFile, a_BiomeGen, a_Seed, a_CacheOffByDefault); } From ee74411024f1ba21b6a23eafadc9ab13ec6b3685 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 10:10:24 -0600 Subject: [PATCH 131/144] Added newlines at ends of files --- src/BiomeDef.cpp | 2 +- src/BiomeDef.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index f7f48db9..f41f4bce 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -128,4 +128,4 @@ bool IsBiomeNoDownfall(EMCSBiome a_Biome) return false; } } -} \ No newline at end of file +} diff --git a/src/BiomeDef.h b/src/BiomeDef.h index e1c29bc0..df1e387f 100644 --- a/src/BiomeDef.h +++ b/src/BiomeDef.h @@ -104,4 +104,4 @@ extern EMCSBiome StringToBiome(const AString & a_BiomeString); extern bool IsBiomeNoDownfall(EMCSBiome a_Biome); -// tolua_end \ No newline at end of file +// tolua_end From fe48f62575427c0b3f7449c5b9f067ba3186c3b9 Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 10:30:56 -0600 Subject: [PATCH 132/144] Include Biome enum in ChunkDef Can't forward declare an enum --- src/ChunkDef.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 442c9633..edeb7c0a 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -10,6 +10,7 @@ #pragma once #include "Vector3i.h" +#include "BiomeDef.h" @@ -38,8 +39,6 @@ class cBlockEntity; typedef std::list cEntityList; typedef std::list cBlockEntityList; -enum EMCSBiome; - From cea997426b7d66f5aa9f8aac5fd5b603bcaa3fb8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 10 Jan 2014 22:22:54 +0100 Subject: [PATCH 133/144] Decoupled cChunkGenerator from cWorld and cRoot. Now the chunk generator can be used by other projects without depending on the two hugest structures in MCS. --- src/Generating/ChunkGenerator.cpp | 48 +++++++--------- src/Generating/ChunkGenerator.h | 63 ++++++++++++++++++--- src/Generating/ComposableGenerator.cpp | 11 ++-- src/Generating/ComposableGenerator.h | 2 +- src/Generating/FinishGen.cpp | 4 +- src/Generating/FinishGen.h | 2 +- src/Generating/Noise3DGenerator.cpp | 4 +- src/Generating/Noise3DGenerator.h | 2 +- src/World.cpp | 78 +++++++++++++++++++++++++- src/World.h | 24 ++++++++ 10 files changed, 188 insertions(+), 50 deletions(-) diff --git a/src/Generating/ChunkGenerator.cpp b/src/Generating/ChunkGenerator.cpp index 126a896a..baa5b76b 100644 --- a/src/Generating/ChunkGenerator.cpp +++ b/src/Generating/ChunkGenerator.cpp @@ -2,13 +2,11 @@ #include "Globals.h" #include "ChunkGenerator.h" -#include "../World.h" #include "inifile/iniFile.h" -#include "../Root.h" -#include "../Bindings/PluginManager.h" #include "ChunkDesc.h" #include "ComposableGenerator.h" #include "Noise3DGenerator.h" +#include "../MersenneTwister.h" @@ -29,8 +27,9 @@ const unsigned int QUEUE_SKIP_LIMIT = 500; cChunkGenerator::cChunkGenerator(void) : super("cChunkGenerator"), - m_World(NULL), - m_Generator(NULL) + m_Generator(NULL), + m_PluginInterface(NULL), + m_ChunkSink(NULL) { } @@ -47,10 +46,12 @@ cChunkGenerator::~cChunkGenerator() -bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile) +bool cChunkGenerator::Start(cPluginInterface & a_PluginInterface, cChunkSink & a_ChunkSink, cIniFile & a_IniFile) { + m_PluginInterface = &a_PluginInterface; + m_ChunkSink = &a_ChunkSink; + MTRand rnd; - m_World = a_World; m_Seed = a_IniFile.GetValueSetI("Seed", "Seed", rnd.randInt()); AString GeneratorName = a_IniFile.GetValueSet("Generator", "Generator", "Composable"); @@ -73,7 +74,7 @@ bool cChunkGenerator::Start(cWorld * a_World, cIniFile & a_IniFile) return false; } - m_Generator->Initialize(a_World, a_IniFile); + m_Generator->Initialize(a_IniFile); return super::Start(); } @@ -237,14 +238,14 @@ void cChunkGenerator::Execute(void) } // Hack for regenerating chunks: if Y != 0, the chunk is considered invalid, even if it has its data set - if ((coords.m_ChunkY == 0) && m_World->IsChunkValid(coords.m_ChunkX, coords.m_ChunkZ)) + if ((coords.m_ChunkY == 0) && m_ChunkSink->IsChunkValid(coords.m_ChunkX, coords.m_ChunkZ)) { LOGD("Chunk [%d, %d] already generated, skipping generation", coords.m_ChunkX, coords.m_ChunkZ); // Already generated, ignore request continue; } - if (SkipEnabled && !m_World->HasChunkAnyClients(coords.m_ChunkX, coords.m_ChunkZ)) + if (SkipEnabled && !m_ChunkSink->HasChunkAnyClients(coords.m_ChunkX, coords.m_ChunkZ)) { LOGWARNING("Chunk generator overloaded, skipping chunk [%d, %d]", coords.m_ChunkX, coords.m_ChunkZ); continue; @@ -253,9 +254,6 @@ void cChunkGenerator::Execute(void) LOGD("Generating chunk [%d, %d, %d]", coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); DoGenerate(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); - // Save the chunk right after generating, so that we don't have to generate it again on next run - m_World->GetStorage().QueueSaveChunk(coords.m_ChunkX, coords.m_ChunkY, coords.m_ChunkZ); - NumChunksGenerated++; } // while (!bStop) } @@ -265,27 +263,20 @@ void cChunkGenerator::Execute(void) void cChunkGenerator::DoGenerate(int a_ChunkX, int a_ChunkY, int a_ChunkZ) { + ASSERT(m_PluginInterface != NULL); + ASSERT(m_ChunkSink != NULL); + cChunkDesc ChunkDesc(a_ChunkX, a_ChunkZ); - cRoot::Get()->GetPluginManager()->CallHookChunkGenerating(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc); + m_PluginInterface->CallHookChunkGenerating(ChunkDesc); m_Generator->DoGenerate(a_ChunkX, a_ChunkZ, ChunkDesc); - cRoot::Get()->GetPluginManager()->CallHookChunkGenerated(m_World, a_ChunkX, a_ChunkZ, &ChunkDesc); + m_PluginInterface->CallHookChunkGenerated(ChunkDesc); #ifdef _DEBUG // Verify that the generator has produced valid data: ChunkDesc.VerifyHeightmap(); #endif - cChunkDef::BlockNibbles BlockMetas; - ChunkDesc.CompressBlockMetas(BlockMetas); - - m_World->SetChunkData( - a_ChunkX, a_ChunkZ, - ChunkDesc.GetBlockTypes(), BlockMetas, - NULL, NULL, // We don't have lighting, chunk will be lighted when needed - &ChunkDesc.GetHeightMap(), &ChunkDesc.GetBiomeMap(), - ChunkDesc.GetEntities(), ChunkDesc.GetBlockEntities(), - true - ); + m_ChunkSink->OnChunkGenerated(ChunkDesc); } @@ -304,9 +295,8 @@ cChunkGenerator::cGenerator::cGenerator(cChunkGenerator & a_ChunkGenerator) : -void cChunkGenerator::cGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) +void cChunkGenerator::cGenerator::Initialize(cIniFile & a_IniFile) { - m_World = a_World; UNUSED(a_IniFile); } @@ -319,7 +309,7 @@ EMCSBiome cChunkGenerator::cGenerator::GetBiomeAt(int a_BlockX, int a_BlockZ) cChunkDef::BiomeMap Biomes; int Y = 0; int ChunkX, ChunkZ; - cWorld::AbsoluteToRelative(a_BlockX, Y, a_BlockZ, ChunkX, Y, ChunkZ); + cChunkDef::AbsoluteToRelative(a_BlockX, Y, a_BlockZ, ChunkX, ChunkZ); GenerateBiomes(ChunkX, ChunkZ, Biomes); return cChunkDef::GetBiome(Biomes, a_BlockX, a_BlockZ); } diff --git a/src/Generating/ChunkGenerator.h b/src/Generating/ChunkGenerator.h index 2d3bb808..9b2d9eb3 100644 --- a/src/Generating/ChunkGenerator.h +++ b/src/Generating/ChunkGenerator.h @@ -26,7 +26,6 @@ If the generator queue is overloaded, the generator skips chunks with no clients // fwd: -class cWorld; class cIniFile; class cChunkDesc; @@ -40,7 +39,7 @@ class cChunkGenerator : typedef cIsThread super; public: - /// The interface that a class has to implement to become a generator + /** The interface that a class has to implement to become a generator */ class cGenerator { public: @@ -48,7 +47,7 @@ public: virtual ~cGenerator() {} ; // Force a virtual destructor /// Called to initialize the generator on server startup. - virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile); + virtual void Initialize(cIniFile & a_IniFile); /// Generates the biomes for the specified chunk (directly, not in a separate thread). Used by the world loader if biomes failed loading. virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) = 0; @@ -61,14 +60,59 @@ public: protected: cChunkGenerator & m_ChunkGenerator; - cWorld * m_World; + } ; + + + /** The interface through which the plugins are called for their OnChunkGenerating / OnChunkGenerated hooks. */ + class cPluginInterface + { + public: + // Force a virtual destructor + virtual ~cPluginInterface() {} + + /** Called when the chunk is about to be generated. + The generator may be partly or fully overriden by the implementation + */ + virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) = 0; + + /** Called after the chunk is generated, before it is handed to the chunk sink. + a_ChunkDesc contains the generated chunk data. Implementation may modify this data. + */ + virtual void CallHookChunkGenerated(cChunkDesc & a_ChunkDesc) = 0; + } ; + + + /** The interface through which the generated chunks are handed to the cWorld or whoever created us. */ + class cChunkSink + { + public: + // Force a virtual destructor + virtual ~cChunkSink() {} + + /** Called after the chunk has been generated + The interface may store the chunk, send it over network, whatever. + The chunk is not expected to be modified, but the generator will survive if the implementation + changes the data within. All changes are ignored, though. + */ + virtual void OnChunkGenerated(cChunkDesc & a_ChunkDesc) = 0; + + /** Called just before the chunk generation is started, + to verify that it hasn't been generated in the meantime. + If this callback returns true, the chunk is not generated. + */ + virtual bool IsChunkValid(int a_ChunkX, int a_ChunkZ) = 0; + + /** Called when the generator is overloaded to skip chunks that are no longer needed. + If this callback returns false, the chunk is not generated. + */ + virtual bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) = 0; } ; cChunkGenerator (void); ~cChunkGenerator(); - bool Start(cWorld * a_World, cIniFile & a_IniFile); + bool Start(cPluginInterface & a_PluginInterface, cChunkSink & a_ChunkSink, cIniFile & a_IniFile); void Stop(void); /// Queues the chunk for generation; removes duplicate requests @@ -91,8 +135,6 @@ public: private: - cWorld * m_World; - int m_Seed; cCriticalSection m_CS; @@ -101,6 +143,13 @@ private: cEvent m_evtRemoved; ///< Set when an item is removed from the queue cGenerator * m_Generator; ///< The actual generator engine used to generate chunks + + /** The plugin interface that may modify the generated chunks */ + cPluginInterface * m_PluginInterface; + + /** The destination where the generated chunks are sent */ + cChunkSink * m_ChunkSink; + // cIsThread override: virtual void Execute(void) override; diff --git a/src/Generating/ComposableGenerator.cpp b/src/Generating/ComposableGenerator.cpp index 971ff453..87c4d2c5 100644 --- a/src/Generating/ComposableGenerator.cpp +++ b/src/Generating/ComposableGenerator.cpp @@ -157,9 +157,9 @@ cComposableGenerator::~cComposableGenerator() -void cComposableGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) +void cComposableGenerator::Initialize(cIniFile & a_IniFile) { - super::Initialize(a_World, a_IniFile); + super::Initialize(a_IniFile); InitBiomeGen(a_IniFile); InitHeightGen(a_IniFile); @@ -369,13 +369,14 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) int Seed = m_ChunkGenerator.GetSeed(); AString Structures = a_IniFile.GetValueSet("Generator", "Finishers", "SprinkleFoliage,Ice,Snow,Lilypads,BottomLava,DeadBushes,PreSimulator"); + eDimension Dimension = StringToDimension(a_IniFile.GetValue("General", "Dimension", "Overworld")); AStringVector Str = StringSplitAndTrim(Structures, ","); for (AStringVector::const_iterator itr = Str.begin(); itr != Str.end(); ++itr) { // Finishers, alpha-sorted: if (NoCaseCompare(*itr, "BottomLava") == 0) { - int DefaultBottomLavaLevel = (m_World->GetDimension() == dimNether) ? 30 : 10; + int DefaultBottomLavaLevel = (Dimension == dimNether) ? 30 : 10; int BottomLavaLevel = a_IniFile.GetValueSetI("Generator", "BottomLavaLevel", DefaultBottomLavaLevel); m_FinishGens.push_back(new cFinishGenBottomLava(BottomLavaLevel)); } @@ -389,7 +390,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "LavaSprings") == 0) { - m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, *m_World)); + m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_LAVA, a_IniFile, Dimension)); } else if (NoCaseCompare(*itr, "Lilypads") == 0) { @@ -409,7 +410,7 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile) } else if (NoCaseCompare(*itr, "WaterSprings") == 0) { - m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, *m_World)); + m_FinishGens.push_back(new cFinishGenFluidSprings(Seed, E_BLOCK_WATER, a_IniFile, Dimension)); } } // for itr - Str[] } diff --git a/src/Generating/ComposableGenerator.h b/src/Generating/ComposableGenerator.h index 7c9c9758..29add063 100644 --- a/src/Generating/ComposableGenerator.h +++ b/src/Generating/ComposableGenerator.h @@ -162,7 +162,7 @@ public: cComposableGenerator(cChunkGenerator & a_ChunkGenerator); virtual ~cComposableGenerator(); - virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override; + virtual void Initialize(cIniFile & a_IniFile) override; virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override; diff --git a/src/Generating/FinishGen.cpp b/src/Generating/FinishGen.cpp index 145fe22e..4915e681 100644 --- a/src/Generating/FinishGen.cpp +++ b/src/Generating/FinishGen.cpp @@ -520,7 +520,7 @@ void cFinishGenPreSimulator::StationarizeFluid( /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cFinishGenFluidSprings: -cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, const cWorld & a_World) : +cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension) : m_Noise(a_Seed + a_Fluid * 100), // Need to take fluid into account, otherwise water and lava springs generate next to each other m_HeightDistribution(255), m_Fluid(a_Fluid) @@ -529,7 +529,7 @@ cFinishGenFluidSprings::cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cI AString SectionName = IsWater ? "WaterSprings" : "LavaSprings"; AString DefaultHeightDistribution; int DefaultChance = 0; - switch (a_World.GetDimension()) + switch (a_Dimension) { case dimNether: { diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h index ed7df590..d89ffed1 100644 --- a/src/Generating/FinishGen.h +++ b/src/Generating/FinishGen.h @@ -164,7 +164,7 @@ class cFinishGenFluidSprings : public cFinishGen { public: - cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, const cWorld & a_World); + cFinishGenFluidSprings(int a_Seed, BLOCKTYPE a_Fluid, cIniFile & a_IniFile, eDimension a_Dimension); protected: diff --git a/src/Generating/Noise3DGenerator.cpp b/src/Generating/Noise3DGenerator.cpp index 2511bb65..afa40c64 100644 --- a/src/Generating/Noise3DGenerator.cpp +++ b/src/Generating/Noise3DGenerator.cpp @@ -150,10 +150,8 @@ cNoise3DGenerator::~cNoise3DGenerator() -void cNoise3DGenerator::Initialize(cWorld * a_World, cIniFile & a_IniFile) +void cNoise3DGenerator::Initialize(cIniFile & a_IniFile) { - m_World = a_World; - // Params: m_SeaLevel = a_IniFile.GetValueSetI("Generator", "Noise3DSeaLevel", 62); m_HeightAmplification = (NOISE_DATATYPE)a_IniFile.GetValueSetF("Generator", "Noise3DHeightAmplification", 0); diff --git a/src/Generating/Noise3DGenerator.h b/src/Generating/Noise3DGenerator.h index 0d211cdd..42f61a85 100644 --- a/src/Generating/Noise3DGenerator.h +++ b/src/Generating/Noise3DGenerator.h @@ -24,7 +24,7 @@ public: cNoise3DGenerator(cChunkGenerator & a_ChunkGenerator); virtual ~cNoise3DGenerator(); - virtual void Initialize(cWorld * a_World, cIniFile & a_IniFile) override; + virtual void Initialize(cIniFile & a_IniFile) override; virtual void GenerateBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override; virtual void DoGenerate(int a_ChunkX, int a_ChunkZ, cChunkDesc & a_ChunkDesc) override; diff --git a/src/World.cpp b/src/World.cpp index 39300d41..1cf82d64 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -10,6 +10,7 @@ #include "Root.h" #include "inifile/iniFile.h" #include "ChunkMap.h" +#include "Generating/ChunkDesc.h" #include "OSSupport/Timer.h" // Entities (except mobs): @@ -238,6 +239,7 @@ cWorld::cWorld(const AString & a_WorldName) : m_SkyDarkness(0), m_Weather(eWeather_Sunny), m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :) + m_GeneratorCallbacks(*this), m_TickThread(*this) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); @@ -583,7 +585,7 @@ void cWorld::Start(void) m_Lighting.Start(this); m_Storage.Start(this, m_StorageSchema); - m_Generator.Start(this, IniFile); + m_Generator.Start(m_GeneratorCallbacks, m_GeneratorCallbacks, IniFile); m_ChunkSender.Start(this); m_TickThread.Start(); @@ -2843,3 +2845,77 @@ void cWorld::cTaskSaveAllChunks::Run(cWorld & a_World) +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// cWorld::cChunkGeneratorCallbacks: + +cWorld::cChunkGeneratorCallbacks::cChunkGeneratorCallbacks(cWorld & a_World) : + m_World(&a_World) +{ +} + + + + + +void cWorld::cChunkGeneratorCallbacks::OnChunkGenerated(cChunkDesc & a_ChunkDesc) +{ + cChunkDef::BlockNibbles BlockMetas; + a_ChunkDesc.CompressBlockMetas(BlockMetas); + + m_World->SetChunkData( + a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), + a_ChunkDesc.GetBlockTypes(), BlockMetas, + NULL, NULL, // We don't have lighting, chunk will be lighted when needed + &a_ChunkDesc.GetHeightMap(), &a_ChunkDesc.GetBiomeMap(), + a_ChunkDesc.GetEntities(), a_ChunkDesc.GetBlockEntities(), + true + ); + + // Save the chunk right after generating, so that we don't have to generate it again on next run + m_World->GetStorage().QueueSaveChunk(a_ChunkDesc.GetChunkX(), 0, a_ChunkDesc.GetChunkZ()); +} + + + + + +bool cWorld::cChunkGeneratorCallbacks::IsChunkValid(int a_ChunkX, int a_ChunkZ) +{ + return m_World->IsChunkValid(a_ChunkX, a_ChunkZ); +} + + + + + +bool cWorld::cChunkGeneratorCallbacks::HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) +{ + return m_World->HasChunkAnyClients(a_ChunkX, a_ChunkZ); +} + + + + + +void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) +{ + cPluginManager::Get()->CallHookChunkGenerating( + m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc + ); +} + + + + + +void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) +{ + cPluginManager::Get()->CallHookChunkGenerated( + m_World, a_ChunkDesc.GetChunkX(), a_ChunkDesc.GetChunkZ(), &a_ChunkDesc + ); +} + + + + + diff --git a/src/World.h b/src/World.h index f90ddd90..b61708d0 100644 --- a/src/World.h +++ b/src/World.h @@ -636,6 +636,27 @@ private: virtual void Execute(void) override; } ; + + /** Implementation of the callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ + class cChunkGeneratorCallbacks : + public cChunkGenerator::cChunkSink, + public cChunkGenerator::cPluginInterface + { + cWorld * m_World; + + // cChunkSink overrides: + virtual void OnChunkGenerated (cChunkDesc & a_ChunkDesc) override; + virtual bool IsChunkValid (int a_ChunkX, int a_ChunkZ) override; + virtual bool HasChunkAnyClients(int a_ChunkX, int a_ChunkZ) override; + + // cPluginInterface overrides: + virtual void CallHookChunkGenerating(cChunkDesc & a_ChunkDesc) override; + virtual void CallHookChunkGenerated (cChunkDesc & a_ChunkDesc) override; + + public: + cChunkGeneratorCallbacks(cWorld & a_World); + } ; + AString m_WorldName; AString m_IniFileName; @@ -714,6 +735,9 @@ private: cChunkGenerator m_Generator; + /** The callbacks that the ChunkGenerator uses to store new chunks and interface to plugins */ + cChunkGeneratorCallbacks m_GeneratorCallbacks; + cChunkSender m_ChunkSender; cLightingThread m_Lighting; cTickThread m_TickThread; From af89794d760c04f1caf5f437de0f1dfa2803307c Mon Sep 17 00:00:00 2001 From: Bill Derouin Date: Fri, 10 Jan 2014 15:50:52 -0600 Subject: [PATCH 134/144] Globals.h needs to be first include --- src/BiomeDef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BiomeDef.cpp b/src/BiomeDef.cpp index f41f4bce..89a1cdef 100644 --- a/src/BiomeDef.cpp +++ b/src/BiomeDef.cpp @@ -3,8 +3,8 @@ // Implements biome helper functions -#include "BiomeDef.h" #include "Globals.h" +#include "BiomeDef.h" EMCSBiome StringToBiome(const AString & a_BiomeString) From 05e22dccf2682b61b32aa83241bbc52d57ddecaa Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 11 Jan 2014 11:38:34 +0200 Subject: [PATCH 135/144] Fixed glowstone drop count --- src/Blocks/BlockGlowstone.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Blocks/BlockGlowstone.h b/src/Blocks/BlockGlowstone.h index 5f0d95de..6c198efc 100644 --- a/src/Blocks/BlockGlowstone.h +++ b/src/Blocks/BlockGlowstone.h @@ -20,8 +20,8 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { // Reset meta to 0 - // TODO: More drops? - a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, 1, 0)); + MTRand r1; + a_Pickups.push_back(cItem(E_ITEM_GLOWSTONE_DUST, (char)(2 + r1.randInt(2)), 0)); } } ; From a332a5dc730289cca0357c7387731fd25e0b74cd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 16:44:28 +0100 Subject: [PATCH 136/144] IniFile: Split SetValue() into AddValue() and SetValue(). Each function does what one would assume - AddValue adds a new value, SetValue overwrites existing value (creates a new one if not exists, if instructed to do so). --- lib/inifile/iniFile.cpp | 85 +++++++++++++++++++++++++++-------------- lib/inifile/iniFile.h | 34 +++++++++++------ 2 files changed, 78 insertions(+), 41 deletions(-) diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index 5ca6f661..c1fd9c92 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -344,47 +344,79 @@ AString cIniFile::GetValueName(const AString & keyname, const int valueID) const -bool cIniFile::SetValue(const int keyID, const int valueID, const AString & value) +void cIniFile::AddValue(const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value) { - if ((keyID < (int)keys.size()) && (valueID < (int)keys[keyID].names.size())) + int keyID = FindKey(a_KeyName); + if (keyID == noID) { - keys[keyID].values[valueID] = value; + keyID = int(AddKeyName(a_KeyName)); } - return false; + + keys[keyID].names.push_back(a_ValueName); + keys[keyID].values.push_back(a_Value); } -bool cIniFile::SetValue(const AString & keyname, const AString & valuename, const AString & value, bool const create) +void cIniFile::AddValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value) { - int keyID = FindKey(keyname); + AddValue(a_KeyName, a_ValueName, Printf("%d", a_Value)); +} + + + + + +void cIniFile::AddValueF(const AString & a_KeyName, const AString & a_ValueName, const double a_Value) +{ + AddValue(a_KeyName, a_ValueName, Printf("%f", a_Value)); +} + + + + + +bool cIniFile::SetValue(const int keyID, const int valueID, const AString & value) +{ + if (((size_t)keyID >= keys.size()) || ((size_t)valueID >= keys[keyID].names.size())) + { + return false; + } + keys[keyID].values[valueID] = value; + return true; +} + + + + + +bool cIniFile::SetValue(const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists) +{ + int keyID = FindKey(a_KeyName); if (keyID == noID) { - if (create) - { - keyID = int(AddKeyName(keyname)); - } - else + if (!a_CreateIfNotExists) { return false; } + keyID = AddKeyName(a_KeyName); } - int valueID = FindValue(int(keyID), valuename); + int valueID = FindValue(keyID, a_ValueName); if (valueID == noID) { - if (!create) + if (!a_CreateIfNotExists) { return false; } - keys[keyID].names.resize(keys[keyID].names.size() + 1, valuename); - keys[keyID].values.resize(keys[keyID].values.size() + 1, value); + keys[keyID].names.push_back(a_ValueName); + keys[keyID].values.push_back(a_Value); } else { - keys[keyID].values[valueID] = value; + keys[keyID].values[valueID] = a_Value; } return true; @@ -394,37 +426,32 @@ bool cIniFile::SetValue(const AString & keyname, const AString & valuename, cons -bool cIniFile::SetValueI(const AString & keyname, const AString & valuename, const int value, bool const create) +bool cIniFile::SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists) { - AString Data; - Printf(Data, "%d", value); - return SetValue(keyname, valuename, Data, create); + return SetValue(a_KeyName, a_ValueName, Printf("%d", a_Value), a_CreateIfNotExists); } -bool cIniFile::SetValueF(const AString & keyname, const AString & valuename, double const value, bool const create) +bool cIniFile::SetValueF(const AString & a_KeyName, const AString & a_ValueName, double const a_Value, const bool a_CreateIfNotExists) { - AString Data; - Printf(Data, "%f", value); - return SetValue(keyname, valuename, Data, create); + return SetValue(a_KeyName, a_ValueName, Printf("%f", a_Value), a_CreateIfNotExists); } -bool cIniFile::SetValueV(const AString & keyname, const AString & valuename, char * format, ...) +bool cIniFile::SetValueV(const AString & a_KeyName, const AString & a_ValueName, const char * a_Format, ...) { va_list args; - va_start(args, format); - + va_start(args, a_Format); AString Data; - AppendVPrintf(Data, format, args); + AppendVPrintf(Data, a_Format, args); va_end(args); - return SetValue(keyname, valuename, Data); + return SetValue(a_KeyName, a_ValueName, Data); } diff --git a/lib/inifile/iniFile.h b/lib/inifile/iniFile.h index 83d961fc..40af618d 100644 --- a/lib/inifile/iniFile.h +++ b/lib/inifile/iniFile.h @@ -35,7 +35,7 @@ class cIniFile { private: - bool m_IsCaseInsensitive; + bool m_IsCaseInsensitive; struct key { @@ -122,22 +122,32 @@ public: return (GetValueSetI(keyname, valuename, defValue ? 1 : 0) != 0); } - // Sets value of [keyname] valuename =. - // Specify the optional paramter as false (0) if you do not want it to create - // the key if it doesn't exist. Returns true if data entered, false otherwise. - // Overloaded to accept string, int, and double. - bool SetValue( const int keyID, const int valueID, const AString & value); - bool SetValue( const AString & keyname, const AString & valuename, const AString & value, const bool create = true); - bool SetValueI( const AString & keyname, const AString & valuename, const int value, const bool create = true); - bool SetValueB( const AString & keyname, const AString & valuename, const bool value, const bool create = true) + // Adds a new value to the specified key. + // If a value of the same name already exists, creates another one (non-standard INI file) + void AddValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value); + void AddValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value); + void AddValueB(const AString & a_KeyName, const AString & a_ValueName, const bool a_Value) { - return SetValueI( keyname, valuename, int(value), create); + return AddValueI(a_KeyName, a_ValueName, a_Value ? 1 : 0); } - bool SetValueF( const AString & keyname, const AString & valuename, const double value, const bool create = true); + void AddValueF(const AString & a_KeyName, const AString & a_ValueName, const double a_Value); + + // Overwrites the value of [keyname].valuename + // Specify the optional parameter as false (0) if you do not want the value created if it doesn't exist. + // Returns true if value set, false otherwise. + // Overloaded to accept string, int, and double. + bool SetValue (const int keyID, const int valueID, const AString & value); + bool SetValue (const AString & a_KeyName, const AString & a_ValueName, const AString & a_Value, const bool a_CreateIfNotExists = true); + bool SetValueI(const AString & a_KeyName, const AString & a_ValueName, const int a_Value, const bool a_CreateIfNotExists = true); + bool SetValueB(const AString & a_KeyName, const AString & a_ValueName, const bool a_Value, const bool a_CreateIfNotExists = true) + { + return SetValueI(a_KeyName, a_ValueName, int(a_Value), a_CreateIfNotExists); + } + bool SetValueF(const AString & a_KeyName, const AString & a_ValueName, const double a_Value, const bool a_CreateIfNotExists = true); // tolua_end - bool SetValueV( const AString & keyname, const AString & valuename, char *format, ...); + bool SetValueV( const AString & a_KeyName, const AString & a_ValueName, const char * a_Format, ...); // tolua_begin From 2e0fcbdcb7a773509f8d08f50c8cbeb07d612d51 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 16:50:52 +0100 Subject: [PATCH 137/144] Documented the cIniFile:AddValue* functions. Now the documentation really matches the implementation. --- MCServer/Plugins/APIDump/APIDesc.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 26537918..9b117b0f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -867,6 +867,10 @@ ValueName0=SomeOtherValue { Params = "KeyName, Comment", Return = "", Notes = "Adds a comment to be stored in the file under the specified key" }, }, AddKeyName = { Params = "KeyName", Returns = "number", Notes = "Adds a new key of the specified name. Returns the KeyID of the new key." }, + AddValue = { Params = "KeyName, ValueName, Value", Return = "", Notes = "Adds a new value of the specified name to the specified key. If another value of the same name exists in the key, both are kept (nonstandard INI file)" }, + AddValueB = { Params = "KeyName, ValueName, Value", Return = "", Notes = "Adds a new bool value of the specified name to the specified key. If another value of the same name exists in the key, both are kept (nonstandard INI file)" }, + AddValueF = { Params = "KeyName, ValueName, Value", Return = "", Notes = "Adds a new float value of the specified name to the specified key. If another value of the same name exists in the key, both are kept (nonstandard INI file)" }, + AddValueI = { Params = "KeyName, ValueName, Value", Return = "", Notes = "Adds a new integer value of the specified name to the specified key. If another value of the same name exists in the key, both are kept (nonstandard INI file)" }, CaseInsensitive = { Params = "", Return = "", Notes = "Sets key names' and value names' comparisons to case insensitive (default)." }, CaseSensitive = { Params = "", Return = "", Notes = "Sets key names and value names comparisons to case sensitive." }, Clear = { Params = "", Return = "", Notes = "Removes all the in-memory data. Note that , like all the other operations, this doesn't affect any file data." }, From 7739238d3d5d7778b3f9239f5b12fa101c8ac13d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 20:10:50 +0100 Subject: [PATCH 138/144] Fixed reading the files. Duplicate values were ignored. --- lib/inifile/iniFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inifile/iniFile.cpp b/lib/inifile/iniFile.cpp index c1fd9c92..afa1c110 100644 --- a/lib/inifile/iniFile.cpp +++ b/lib/inifile/iniFile.cpp @@ -137,7 +137,7 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect) { valuename = line.substr(0, pLeft); value = line.substr(pLeft + 1); - SetValue(keyname, valuename, value); + AddValue(keyname, valuename, value); break; } From 7fa5217aad5426247d4a6cfd518e241d15c6f44e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 20:26:57 +0100 Subject: [PATCH 139/144] Fixed the warning in CryptoPP. It was getting on my nerves too much, decided to actually fix their code. --- lib/cryptopp/misc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cryptopp/misc.h b/lib/cryptopp/misc.h index 2b326dd6..9149b9ac 100644 --- a/lib/cryptopp/misc.h +++ b/lib/cryptopp/misc.h @@ -545,7 +545,7 @@ inline void SecureWipeArray(T *buf, size_t n) } // this function uses wcstombs(), which assumes that setlocale() has been called -static std::string StringNarrow(const wchar_t *str, bool throwOnError = true) +inline std::string StringNarrow(const wchar_t *str, bool throwOnError = true) { #ifdef _MSC_VER #pragma warning(push) From 2634261a289a856dd0d96eaebbc68b831d982aff Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 20:29:56 +0100 Subject: [PATCH 140/144] Removed unused variables. The Lua API calls had no side-effects, either. --- src/Bindings/ManualBindings.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 344d5d2e..f0dd0030 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -991,7 +991,6 @@ static int tolua_cPluginManager_GetAllPlugins(lua_State * tolua_S) const cPluginManager::PluginMap & AllPlugins = self->GetAllPlugins(); lua_newtable(tolua_S); - int newTable = lua_gettop(tolua_S); int index = 1; cPluginManager::PluginMap::const_iterator iter = AllPlugins.begin(); while (iter != AllPlugins.end()) @@ -1883,7 +1882,6 @@ static int tolua_cWebPlugin_GetTabNames(lua_State * tolua_S) const cWebPlugin::TabNameList & TabNames = self->GetTabNames(); lua_newtable(tolua_S); - int newTable = lua_gettop(tolua_S); int index = 1; cWebPlugin::TabNameList::const_iterator iter = TabNames.begin(); while(iter != TabNames.end()) From acfebab0272e605a05e39ef1926f1d4216faf236 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 21:22:40 +0100 Subject: [PATCH 141/144] Removed an unused file. --- VC2008/MCServer.vcproj | 4 -- src/Bindings/AllToLua.pkg | 2 - src/Bindings/tolua_base.h | 128 -------------------------------------- 3 files changed, 134 deletions(-) delete mode 100644 src/Bindings/tolua_base.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index a017b5a2..3b10092f 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2017,10 +2017,6 @@ RelativePath="..\src\Bindings\PluginManager.h" > - - diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg index e9a5ea0c..0dcead7d 100644 --- a/src/Bindings/AllToLua.pkg +++ b/src/Bindings/AllToLua.pkg @@ -1,8 +1,6 @@ $#include "../Globals.h" -$#include "tolua_base.h" - // Typedefs from Globals.h, so that we don't have to process that file: typedef long long Int64; typedef int Int32; diff --git a/src/Bindings/tolua_base.h b/src/Bindings/tolua_base.h deleted file mode 100644 index 6a76f97b..00000000 --- a/src/Bindings/tolua_base.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef TOLUA_BASE_H -#define TOLUA_BASE_H - -#pragma warning(disable:4800) // This file is ONLY included by Bindings.cpp and it throws lots of C4800 warnings - -#include "tolua++/include/tolua++.h" - - - - - -class ToluaBase { - - int lua_instance; - -protected: - - lua_State* lua_state; - - void lua_stacktrace(lua_State* L) const - { - lua_Debug entry; - int depth = 0; - - while (lua_getstack(L, depth, &entry)) - { - lua_getinfo(L, "Sln", &entry); - - LOGERROR("%s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "?"); - depth++; - } - } - - - bool report_errors(int status) const - { - if ( status!=0 ) - { - const char* s = lua_tostring(lua_state, -1); - LOGERROR("-- %s", s ); - //lua_pop(lua_state, 1); - LOGERROR("Stack:"); - lua_stacktrace( lua_state ); - return true; - } - return false; - } - - bool push_method(const char* name, lua_CFunction f) const { - - if (!lua_state) return false; - - lua_getref(lua_state, lua_instance); - lua_pushstring(lua_state, name); - //LOGINFO("1. push_method() Stack size: %i", lua_gettop( lua_state ) ); - lua_gettable(lua_state, -2); - //LOGINFO("2. push_method() Stack size: %i", lua_gettop( lua_state ) ); - - if (lua_isnil(lua_state, -1)) { - - // pop the table - lua_pop(lua_state, 2); - return false; - - } else { - - if (f) { - if (lua_iscfunction(lua_state, -1)) { - lua_pop(lua_state, 2); - return false; - }; - /* // not for now - lua_pushcfunction(lua_state, f); - if (lua_rawequal(lua_state, -1, -2)) { - - // avoid recursion, pop both functions and the table - lua_pop(lua_state, 3); - return false; - }; - - // pop f - lua_pop(lua_state, 1); - */ - }; - - // swap table with function - lua_insert(lua_state, -2); - }; - - return true; - }; - - void dbcall(lua_State* L, int nargs, int nresults) const { - - // using lua_call for now - int s = lua_pcall(L, nargs, nresults, 0); - report_errors( s ); - }; -public: - - int GetInstance() { return lua_instance; } - lua_State* GetLuaState() { return lua_state; } - - void tolua__set_instance(lua_State* L, lua_Object lo) { - - lua_state = L; - - lua_pushvalue(L, lo); - lua_instance = lua_ref(lua_state, 1); - }; - - ToluaBase() { - - lua_state = NULL; - }; - - ~ToluaBase() { - - if (lua_state) { - - lua_unref(lua_state, lua_instance); - }; - }; -}; - -#endif - - From b2b7e457570e87c87a3c158271ae3bffd823987c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 22:51:10 +0100 Subject: [PATCH 142/144] Removed internal methods from public cLuaState interface. PushFunction(), CallFunction() and GetReturn() are not to be called independently, but rather only by using the Call() templated overrides. Push() needs to be left in the public part, it is used for pushing results in the ManualBindings. Preparation for #418. --- src/Bindings/LuaState.cpp | 26 ++++++--- src/Bindings/LuaState.h | 98 ++++++++++++++++++++------------- src/Bindings/ManualBindings.cpp | 98 +++++++++------------------------ 3 files changed, 103 insertions(+), 119 deletions(-) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 83351591..1dd2b4dd 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -264,27 +264,26 @@ bool cLuaState::PushFunction(int a_FnRef) -bool cLuaState::PushFunctionFromRefTable(cRef & a_TableRef, const char * a_FnName) +bool cLuaState::PushFunction(const cTableRef & a_TableRef) { ASSERT(IsValid()); ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack - - lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef); // Get the table ref + + lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef.GetTableRef()); // Get the table ref if (!lua_istable(m_LuaState, -1)) { // Not a table, bail out lua_pop(m_LuaState, 1); return false; } - lua_getfield(m_LuaState, -1, a_FnName); + lua_getfield(m_LuaState, -1, a_TableRef.GetFnName()); if (lua_isnil(m_LuaState, -1) || !lua_isfunction(m_LuaState, -1)) { // Not a valid function, bail out lua_pop(m_LuaState, 2); return false; } - lua_remove(m_LuaState, -2); // Remove the table ref from the stack - m_CurrentFunctionName = ""; + Printf(m_CurrentFunctionName, "", a_TableRef.GetFnName()); m_NumCurrentFunctionArgs = 0; return true; } @@ -963,16 +962,25 @@ bool cLuaState::ReportErrors(lua_State * a_LuaState, int a_Status) void cLuaState::LogStackTrace(void) +{ + LogStackTrace(m_LuaState); +} + + + + + +void cLuaState::LogStackTrace(lua_State * a_LuaState) { LOGWARNING("Stack trace:"); lua_Debug entry; int depth = 0; - while (lua_getstack(m_LuaState, depth, &entry)) + while (lua_getstack(a_LuaState, depth, &entry)) { - int status = lua_getinfo(m_LuaState, "Sln", &entry); + int status = lua_getinfo(a_LuaState, "Sln", &entry); assert(status); - LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "?"); + LOGWARNING(" %s(%d): %s", entry.short_src, entry.currentline, entry.name ? entry.name : "(no name)"); depth++; } LOGWARNING("Stack trace end"); diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index 796559b6..c77dbeb7 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -85,6 +85,23 @@ public: } ; + /** Used for calling functions stored in a reference-stored table */ + class cTableRef + { + int m_TableRef; + const char * m_FnName; + public: + cTableRef(int a_TableRef, const char * a_FnName) : + m_TableRef(a_TableRef), + m_FnName(a_FnName) + { + } + + int GetTableRef(void) const { return m_TableRef; } + const char * GetFnName(void) const { return m_FnName; } + } ; + + /// A dummy class that's used only to delimit function args from return values for cLuaState::Call() class cRet { @@ -133,24 +150,6 @@ public: /// Returns true if a_FunctionName is a valid Lua function that can be called bool HasFunction(const char * a_FunctionName); - /** Pushes the function of the specified name onto the stack. - Returns true if successful. Logs a warning on failure (incl. m_SubsystemName) - */ - bool PushFunction(const char * a_FunctionName); - - /** Pushes a function that has been saved into the global registry, identified by a_FnRef. - Returns true if successful. Logs a warning on failure - */ - bool PushFunction(int a_FnRef); - - /** Pushes a function that is stored in a table ref. - Returns true if successful, false on failure. Doesn't log failure. - */ - bool PushFunctionFromRefTable(cRef & a_TableRef, const char * a_FnName); - - /// Pushes a usertype of the specified class type onto the stack - void PushUserType(void * a_Object, const char * a_Type); - // Push a value onto the stack void Push(const AString & a_String); void Push(const AStringVector & a_Vector); @@ -183,7 +182,7 @@ public: void Push(void * a_Ptr); void Push(cHopperEntity * a_Hopper); void Push(cBlockEntity * a_BlockEntity); - + /// Call any 0-param 0-return Lua function in a single line: template bool Call(FnT a_FnName) @@ -802,25 +801,6 @@ public: } - /// Retrieve value returned at a_StackPos, if it is a valid bool. If not, a_ReturnedVal is unchanged - void GetReturn(int a_StackPos, bool & a_ReturnedVal); - - /// Retrieve value returned at a_StackPos, if it is a valid string. If not, a_ReturnedVal is unchanged - void GetReturn(int a_StackPos, AString & a_ReturnedVal); - - /// Retrieve value returned at a_StackPos, if it is a valid number. If not, a_ReturnedVal is unchanged - void GetReturn(int a_StackPos, int & a_ReturnedVal); - - /// Retrieve value returned at a_StackPos, if it is a valid number. If not, a_ReturnedVal is unchanged - void GetReturn(int a_StackPos, double & a_ReturnedVal); - - /** - Calls the function that has been pushed onto the stack by PushFunction(), - with arguments pushed by PushXXX(). - Returns true if successful, logs a warning on failure. - */ - bool CallFunction(int a_NumReturnValues); - /// Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions bool CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam = -1); @@ -848,6 +828,9 @@ public: /// Logs all items in the current stack trace to the server console void LogStackTrace(void); + /// Logs all items in the current stack trace to the server console + static void LogStackTrace(lua_State * a_LuaState); + /// Returns the type of the item on the specified position in the stack AString GetTypeText(int a_StackPos); @@ -867,6 +850,45 @@ protected: /// Number of arguments currently pushed (for the Push / Call chain) int m_NumCurrentFunctionArgs; + + + /** Pushes the function of the specified name onto the stack. + Returns true if successful. Logs a warning on failure (incl. m_SubsystemName) + */ + bool PushFunction(const char * a_FunctionName); + + /** Pushes a function that has been saved into the global registry, identified by a_FnRef. + Returns true if successful. Logs a warning on failure + */ + bool PushFunction(int a_FnRef); + + /** Pushes a function that is stored in a referenced table by name + Returns true if successful. Logs a warning on failure + */ + bool PushFunction(const cTableRef & a_TableRef); + + /// Pushes a usertype of the specified class type onto the stack + void PushUserType(void * a_Object, const char * a_Type); + + /// Retrieve value returned at a_StackPos, if it is a valid bool. If not, a_ReturnedVal is unchanged + void GetReturn(int a_StackPos, bool & a_ReturnedVal); + + /// Retrieve value returned at a_StackPos, if it is a valid string. If not, a_ReturnedVal is unchanged + void GetReturn(int a_StackPos, AString & a_ReturnedVal); + + /// Retrieve value returned at a_StackPos, if it is a valid number. If not, a_ReturnedVal is unchanged + void GetReturn(int a_StackPos, int & a_ReturnedVal); + + /// Retrieve value returned at a_StackPos, if it is a valid number. If not, a_ReturnedVal is unchanged + void GetReturn(int a_StackPos, double & a_ReturnedVal); + + /** + Calls the function that has been pushed onto the stack by PushFunction(), + with arguments pushed by PushXXX(). + Returns true if successful, logs a warning on failure. + */ + bool CallFunction(int a_NumReturnValues); + } ; diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index f0dd0030..a9368f61 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1980,118 +1980,72 @@ public: virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNextBlock")) + bool res = false; + if (!m_LuaState.Call( + cLuaState::cTableRef(m_TableRef, "OnNextBlock"), + a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_EntryFace, + cLuaState::Return, res + )) { // No such function in the table, skip the callback return false; } - m_LuaState.Push(a_BlockX); - m_LuaState.Push(a_BlockY); - m_LuaState.Push(a_BlockZ); - m_LuaState.Push(a_BlockType); - m_LuaState.Push(a_BlockMeta); - m_LuaState.Push(a_EntryFace); - if (!m_LuaState.CallFunction(1)) - { - return false; - } - bool res = false; - if (lua_isboolean(m_LuaState, -1)) - { - res = (lua_toboolean(m_LuaState, -1) != 0); - } - lua_pop(m_LuaState, 1); return res; } virtual bool OnNextBlockNoData(int a_BlockX, int a_BlockY, int a_BlockZ, char a_EntryFace) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNextBlockNoData")) + bool res = false; + if (!m_LuaState.Call( + cLuaState::cTableRef(m_TableRef, "OnNextBlockNoData"), + a_BlockX, a_BlockY, a_BlockZ, a_EntryFace, + cLuaState::Return, res + )) { // No such function in the table, skip the callback return false; } - m_LuaState.Push(a_BlockX); - m_LuaState.Push(a_BlockY); - m_LuaState.Push(a_BlockZ); - m_LuaState.Push(a_EntryFace); - if (!m_LuaState.CallFunction(1)) - { - return false; - } - bool res = false; - if (lua_isboolean(m_LuaState, -1)) - { - res = (lua_toboolean(m_LuaState, -1) != 0); - } - lua_pop(m_LuaState, 1); return res; } virtual bool OnOutOfWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnOutOfWorld")) + bool res = false; + if (!m_LuaState.Call( + cLuaState::cTableRef(m_TableRef, "OnOutOfWorld"), + a_BlockX, a_BlockY, a_BlockZ, + cLuaState::Return, res + )) { // No such function in the table, skip the callback return false; } - m_LuaState.Push(a_BlockX); - m_LuaState.Push(a_BlockY); - m_LuaState.Push(a_BlockZ); - if (!m_LuaState.CallFunction(1)) - { - return false; - } - bool res = false; - if (lua_isboolean(m_LuaState, -1)) - { - res = (lua_toboolean(m_LuaState, -1) != 0); - } - lua_pop(m_LuaState, 1); return res; } virtual bool OnIntoWorld(double a_BlockX, double a_BlockY, double a_BlockZ) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnIntoWorld")) + bool res = false; + if (!m_LuaState.Call( + cLuaState::cTableRef(m_TableRef, "OnIntoWorld"), + a_BlockX, a_BlockY, a_BlockZ, + cLuaState::Return, res + )) { // No such function in the table, skip the callback return false; } - m_LuaState.Push(a_BlockX); - m_LuaState.Push(a_BlockY); - m_LuaState.Push(a_BlockZ); - if (!m_LuaState.CallFunction(1)) - { - return false; - } - bool res = false; - if (lua_isboolean(m_LuaState, -1)) - { - res = (lua_toboolean(m_LuaState, -1) != 0); - } - lua_pop(m_LuaState, 1); return res; } virtual void OnNoMoreHits(void) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNoMoreHits")) - { - // No such function in the table, skip the callback - return; - } - m_LuaState.CallFunction(0); + m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoMoreHits")); } virtual void OnNoChunk(void) override { - if (!m_LuaState.PushFunctionFromRefTable(m_TableRef, "OnNoChunk")) - { - // No such function in the table, skip the callback - return; - } - m_LuaState.CallFunction(0); + m_LuaState.Call(cLuaState::cTableRef(m_TableRef, "OnNoChunk")); } protected: From 023ba1768837e4a8c29996dbcf82a64366b30629 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 11 Jan 2014 23:10:40 +0100 Subject: [PATCH 143/144] Lua errors display stack trace. Fixes #418. --- src/Bindings/LuaState.cpp | 28 +++++++++++++++++++++++++--- src/Bindings/LuaState.h | 2 ++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index 1dd2b4dd..149c304e 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -228,6 +228,9 @@ bool cLuaState::PushFunction(const char * a_FunctionName) return false; } + // Push the error handler for lua_pcall() + lua_pushcfunction(m_LuaState, &ReportFnCallErrors); + lua_getglobal(m_LuaState, a_FunctionName); if (!lua_isfunction(m_LuaState, -1)) { @@ -249,6 +252,9 @@ bool cLuaState::PushFunction(int a_FnRef) ASSERT(IsValid()); ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack + // Push the error handler for lua_pcall() + lua_pushcfunction(m_LuaState, &ReportFnCallErrors); + lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_FnRef); // same as lua_getref() if (!lua_isfunction(m_LuaState, -1)) { @@ -269,6 +275,9 @@ bool cLuaState::PushFunction(const cTableRef & a_TableRef) ASSERT(IsValid()); ASSERT(m_NumCurrentFunctionArgs == -1); // If not, there's already something pushed onto the stack + // Push the error handler for lua_pcall() + lua_pushcfunction(m_LuaState, &ReportFnCallErrors); + lua_rawgeti(m_LuaState, LUA_REGISTRYINDEX, a_TableRef.GetTableRef()); // Get the table ref if (!lua_istable(m_LuaState, -1)) { @@ -731,11 +740,13 @@ void cLuaState::GetReturn(int a_StackPos, double & a_ReturnedVal) bool cLuaState::CallFunction(int a_NumResults) { ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first - ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 1)); + ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 1)); // The function to call + ASSERT(lua_isfunction(m_LuaState, -m_NumCurrentFunctionArgs - 2)); // The error handler - int s = lua_pcall(m_LuaState, m_NumCurrentFunctionArgs, a_NumResults, 0); - if (ReportErrors(s)) + int s = lua_pcall(m_LuaState, m_NumCurrentFunctionArgs, a_NumResults, -m_NumCurrentFunctionArgs - 2); + if (s != 0) { + // The error has already been printed together with the stacktrace LOGWARNING("Error in %s calling function %s()", m_SubsystemName.c_str(), m_CurrentFunctionName.c_str()); m_NumCurrentFunctionArgs = -1; m_CurrentFunctionName.clear(); @@ -1013,6 +1024,17 @@ AString cLuaState::GetTypeText(int a_StackPos) +int cLuaState::ReportFnCallErrors(lua_State * a_LuaState) +{ + LOGWARNING("LUA: %s", lua_tostring(a_LuaState, -1)); + LogStackTrace(a_LuaState); + return 1; // We left the error message on the stack as the return value +} + + + + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // cLuaState::cRef: diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h index c77dbeb7..a43d3973 100644 --- a/src/Bindings/LuaState.h +++ b/src/Bindings/LuaState.h @@ -889,6 +889,8 @@ protected: */ bool CallFunction(int a_NumReturnValues); + /** Used as the error reporting function for function calls */ + static int ReportFnCallErrors(lua_State * a_LuaState); } ; From 328b2db252fe42774cc001bf1a62d32fe7317c72 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 12 Jan 2014 08:43:13 +0100 Subject: [PATCH 144/144] Disabled a useless MSVC warning in Bindings.cpp. --- src/Bindings/tolua++.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Bindings/tolua++.h b/src/Bindings/tolua++.h index 4dfd0631..73e65b74 100644 --- a/src/Bindings/tolua++.h +++ b/src/Bindings/tolua++.h @@ -2,12 +2,18 @@ // tolua++.h // Redirection file, needed because ToLua++ generates the Bindings.cpp file with >> #include "tolua++.h" << +// Only used from Bindings.cpp #include "tolua++/include/tolua++.h" +#ifdef _MSC_VER + // Disable specific warnings for the generated Bindings.cpp file: + #pragma warning(disable: 4800) // 'int' : forcing value to bool 'true' or 'false' (performance warning) +#endif // _MSC_VER +