From b0e4643eb65f926a9e6b08ef73fa51adf03d92df Mon Sep 17 00:00:00 2001 From: Jonathan Fabian Date: Tue, 2 Dec 2014 20:24:05 -0500 Subject: Allow Spectator Gamemode as a world default. --- src/World.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/World.cpp b/src/World.cpp index 00c8caf13..9a6ef5c30 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -614,7 +614,7 @@ void cWorld::Start(void) } // Adjust the enum-backed variables into their respective bounds: - m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmAdventure); + m_GameMode = (eGameMode) Clamp(GameMode, (int)gmSurvival, (int)gmSpectator); m_TNTShrapnelLevel = (eShrapnelLevel)Clamp(TNTShrapnelLevel, (int)slNone, (int)slAll); m_Weather = (eWeather) Clamp(Weather, (int)wSunny, (int)wStorm); -- cgit v1.2.3 From 24c6da6209be2d6726c1bad441945310f1c4aaab Mon Sep 17 00:00:00 2001 From: Jonathan Fabian Date: Tue, 2 Dec 2014 20:25:41 -0500 Subject: Add missing IsSpectatorMode() checks in Player.cpp, make sure that player is flying when spawned otherwise it will fall through the world. --- src/Entities/Player.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index edcdb4799..e422d4042 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -120,6 +120,11 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : { m_CanFly = true; } + if (World->IsGameModeSpectator()) //Otherwise Player will fall out of the world on join + { + m_CanFly = true; + m_IsFlying = true; + } } cRoot::Get()->GetServer()->PlayerCreated(this); @@ -1074,7 +1079,7 @@ 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 + ((m_GameMode == gmNotSet) && m_World->IsGameModeSpectator()); // or they inherit from the world and the world is Spectator } @@ -1893,8 +1898,8 @@ void cPlayer::UseEquippedItem(int a_Amount) void cPlayer::TickBurning(cChunk & a_Chunk) { - // Don't burn in creative and stop burning in creative if necessary - if (!IsGameModeCreative()) + // Don't burn in creative or spectator and stop burning in creative if necessary + if (!(IsGameModeCreative() || IsGameModeSpectator())) { super::TickBurning(a_Chunk); } @@ -1913,9 +1918,9 @@ void cPlayer::HandleFood(void) { // Ref.: http://www.minecraftwiki.net/wiki/Hunger - if (IsGameModeCreative()) + if (IsGameModeCreative() || IsGameModeSpectator()) { - // Hunger is disabled for Creative + // Hunger is disabled for Creative and Spectator return; } @@ -2080,7 +2085,7 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos) void cPlayer::ApplyFoodExhaustionFromMovement() { - if (IsGameModeCreative()) + if (IsGameModeCreative() || IsGameModeSpectator()) { return; } -- cgit v1.2.3 From 1e6c13ea51061be078f705135a0183f38d3f0bdd Mon Sep 17 00:00:00 2001 From: Jonathan Fabian Date: Tue, 2 Dec 2014 20:54:56 -0500 Subject: Fix Spaces to Tabs --- src/Entities/Player.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e422d4042..e066df1bd 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -120,11 +120,11 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : { m_CanFly = true; } - if (World->IsGameModeSpectator()) //Otherwise Player will fall out of the world on join - { - m_CanFly = true; - m_IsFlying = true; - } + if (World->IsGameModeSpectator()) //Otherwise Player will fall out of the world on join + { + m_CanFly = true; + m_IsFlying = true; + } } cRoot::Get()->GetServer()->PlayerCreated(this); -- cgit v1.2.3 From 6ca47185c467a8972ecea66df44c2145e061053e Mon Sep 17 00:00:00 2001 From: Jonathan Fabian Date: Wed, 3 Dec 2014 23:04:53 -0500 Subject: Updated whitespace in comment, changed conditional to logical equivalent due to popular demand --- src/Entities/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e066df1bd..bafd06277 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -120,7 +120,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : { m_CanFly = true; } - if (World->IsGameModeSpectator()) //Otherwise Player will fall out of the world on join + if (World->IsGameModeSpectator()) // Otherwise Player will fall out of the world on join { m_CanFly = true; m_IsFlying = true; @@ -1899,7 +1899,7 @@ void cPlayer::UseEquippedItem(int a_Amount) void cPlayer::TickBurning(cChunk & a_Chunk) { // Don't burn in creative or spectator and stop burning in creative if necessary - if (!(IsGameModeCreative() || IsGameModeSpectator())) + if (!IsGameModeCreative() && !IsGameModeSpectator()) { super::TickBurning(a_Chunk); } -- cgit v1.2.3