From be7483f26be138e337344b61799396994d3858a3 Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:01:04 +0200 Subject: Pre 1.8 release Added Gamemode Spectator --- src/Defines.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Defines.h b/src/Defines.h index 78c58034e..6355b75b4 100644 --- a/src/Defines.h +++ b/src/Defines.h @@ -115,12 +115,14 @@ enum eGameMode eGameMode_Survival = 0, eGameMode_Creative = 1, eGameMode_Adventure = 2, + eGameMode_Spectator = 3, // Easier-to-use synonyms: gmNotSet = eGameMode_NotSet, gmSurvival = eGameMode_Survival, gmCreative = eGameMode_Creative, gmAdventure = eGameMode_Adventure, + gmSpectator = eGameMode_Spectator, // These two are used to check GameMode for validity when converting from integers. gmMax, // Gets automatically assigned -- cgit v1.2.3 From 8dedbe4db52ee434595d9bdb32b3850a6c1e175f Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:02:27 +0200 Subject: Preparing 1.8 changes Added Spectator Gamemode --- src/Entities/Player.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 9821cc6d9..d64dd6b99 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -171,6 +171,9 @@ public: /** Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world */ bool IsGameModeAdventure(void) const; + /** Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world */ + bool IsGameModeSpectator(void) const; + AString GetIP(void) const { return m_IP; } // tolua_export /** Returns the associated team, NULL if none */ -- cgit v1.2.3 From 120b23d65eefdd6e29b1605b10b852a1069e5444 Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:04:17 +0200 Subject: Pre 1.8 release Added Spectator gamemode --- src/Entities/Player.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index ea795e346..81250bd40 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1043,6 +1043,14 @@ bool cPlayer::IsGameModeAdventure(void) const +bool cPlayer::IsGameModeSpectator(void) const +{ + return (m_GameMode == gmSpectator) || // Either the player is explicitly in Spectator + ((m_GameMode == gmNotSet) && m_World->IsGameModeSpectator()); // or they inherit from the world and the world is Adventure +} + + + void cPlayer::SetTeam(cTeam * a_Team) { -- cgit v1.2.3 From f246faec1636ba9a7e5850dfbbb568d1b7dff0b9 Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:05:55 +0200 Subject: Preparing 1.8 update Added Spectator gamemode --- src/World.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/World.h b/src/World.h index 0c57e6611..6f680694f 100644 --- a/src/World.h +++ b/src/World.h @@ -188,6 +188,9 @@ public: /** Returns true if the world is in Adventure mode */ bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); } + /** Returns true if the world is in Spectator mode */ + bool IsGameModeAdventure(void) const { return (m_GameMode == gmSpectator); } + bool IsPVPEnabled(void) const { return m_bEnabledPVP; } bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; } -- cgit v1.2.3 From 89c9aec5da5adfcaee06df9979bc701579d19f6d Mon Sep 17 00:00:00 2001 From: nesco Date: Tue, 16 Sep 2014 20:17:35 +0200 Subject: Preparing 1.8 update Partially added Spectator gamemode --- src/Entities/Player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 81250bd40..0f15ba620 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1166,7 +1166,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode) m_GameMode = a_GameMode; m_ClientHandle->SendGameMode(a_GameMode); - if (!IsGameModeCreative()) + if (!(IsGameModeCreative() || IsGameModeSpectator())) { SetFlying(false); SetCanFly(false); @@ -1348,6 +1348,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos) void cPlayer::SetVisible(bool a_bVisible) { + // Need to Check if this or other players are in gamemode spectator if (a_bVisible && !m_bVisible) // Make visible { m_bVisible = true; -- cgit v1.2.3 From c63e14b6d11a97b56e17d628aebdd5e244999a15 Mon Sep 17 00:00:00 2001 From: nesco Date: Wed, 17 Sep 2014 17:15:47 +0200 Subject: Preparing 1.8 update --- src/Entities/Player.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0f15ba620..660ad3239 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -451,6 +451,11 @@ void cPlayer::CancelChargingBow(void) void cPlayer::SetTouchGround(bool a_bTouchGround) { + if (IsGameModeSpectator()) // You can fly through the ground in survival + { + return; + } + m_bTouchGround = a_bTouchGround; if (!m_bTouchGround) @@ -585,7 +590,7 @@ bool cPlayer::Feed(int a_Food, double a_Saturation) void cPlayer::AddFoodExhaustion(double a_Exhaustion) { - if (!IsGameModeCreative()) + if (!(IsGameModeCreative() || IsGameModeSpectator())) { m_FoodExhaustionLevel = std::min(m_FoodExhaustionLevel + a_Exhaustion, 40.0); } @@ -823,9 +828,9 @@ bool cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI) { if ((a_TDI.DamageType != dtInVoid) && (a_TDI.DamageType != dtPlugin)) { - if (IsGameModeCreative()) + if (IsGameModeCreative() || IsGameModeSpectator()) { - // No damage / health in creative mode if not void or plugin damage + // No damage / health in creative or spectator mode if not void or plugin damage return false; } } @@ -1348,7 +1353,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos) void cPlayer::SetVisible(bool a_bVisible) { - // Need to Check if this or other players are in gamemode spectator + // Need to Check if the player or other players are in gamemode spectator, but will break compatibility if (a_bVisible && !m_bVisible) // Make visible { m_bVisible = true; @@ -1509,6 +1514,11 @@ void cPlayer::TossPickup(const cItem & a_Item) void cPlayer::TossItems(const cItems & a_Items) { + if (IsGameModeSpectator()) // Players can't toss items in spectator + { + return; + } + m_Stats.AddValue(statItemsDropped, (StatValue)a_Items.Size()); double vX = 0, vY = 0, vZ = 0; @@ -1795,7 +1805,7 @@ bool cPlayer::SaveToDisk() void cPlayer::UseEquippedItem(int a_Amount) { - if (IsGameModeCreative()) // No damage in creative + if (IsGameModeCreative() || IsGameModeSpectator()) // No damage in creative or spectator { return; } -- cgit v1.2.3 From b70e09bc90ce28d9397de75ea80bdb669dfbf4ef Mon Sep 17 00:00:00 2001 From: nesco Date: Wed, 17 Sep 2014 17:32:37 +0200 Subject: Update World.h --- src/World.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/World.h b/src/World.h index 6f680694f..8b40037af 100644 --- a/src/World.h +++ b/src/World.h @@ -189,7 +189,7 @@ public: bool IsGameModeAdventure(void) const { return (m_GameMode == gmAdventure); } /** Returns true if the world is in Spectator mode */ - bool IsGameModeAdventure(void) const { return (m_GameMode == gmSpectator); } + bool IsGameModeSpectator(void) const { return (m_GameMode == gmSpectator); } bool IsPVPEnabled(void) const { return m_bEnabledPVP; } bool IsDeepSnowEnabled(void) const { return m_IsDeepSnowEnabled; } -- cgit v1.2.3 From bf85c0b0abece030ba822223bd7b2dd6367e08eb Mon Sep 17 00:00:00 2001 From: nesco Date: Wed, 17 Sep 2014 21:17:06 +0200 Subject: Implementing Spectator Mode Adding some proprieties of the spectator game mode in player.cpp : - Players can't toss items - Players can't touch the ground --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 660ad3239..3920bdb56 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -451,7 +451,7 @@ void cPlayer::CancelChargingBow(void) void cPlayer::SetTouchGround(bool a_bTouchGround) { - if (IsGameModeSpectator()) // You can fly through the ground in survival + if (IsGameModeSpectator()) // You can fly through the ground in Spectator { return; } -- cgit v1.2.3