From 0fdb1772083d7b4b8dd71c6f084acd9d2e001eec Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 30 Aug 2014 12:46:26 +0200 Subject: Fixed potion removing in creative mode. --- src/Entities/Player.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b0dd40615..5e0da3298 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -627,13 +627,11 @@ void cPlayer::FinishEating(void) } ItemHandler->OnFoodEaten(m_World, this, &Item); - GetInventory().RemoveOneEquippedItem(); - // if the food is mushroom soup, return a bowl to the inventory if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP) { - cItem EmptyBowl(E_ITEM_BOWL); - GetInventory().AddItem(EmptyBowl, true, true); + GetInventory().RemoveOneEquippedItem(); + GetInventory().AddItem(cItem(E_ITEM_BOWL), true, true); } } -- cgit v1.2.3 From 6444bc25ba326b20f2d6bd2e64992e7d7b8e7231 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 5 Sep 2014 16:55:16 +0200 Subject: Fixed security: Player cannot spawn in a disabled world. --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 756410989..51a1f8699 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1670,7 +1670,7 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) cEnderChestEntity::LoadFromJson(root["enderchestinventory"], m_EnderChestContents); m_LoadedWorldName = root.get("world", "world").asString(); - a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), true); + a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false); m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); -- cgit v1.2.3 From 9e1f67932b32241312f25279d924c235d4cff66d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 6 Sep 2014 15:26:20 +0200 Subject: Fixed player spawning in unknown world. This may happen if the admin removes a world. --- src/Entities/Player.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 51a1f8699..b0da6965a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1671,6 +1671,10 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) m_LoadedWorldName = root.get("world", "world").asString(); a_World = cRoot::Get()->GetWorld(GetLoadedWorldName(), false); + if (a_World == NULL) + { + a_World = cRoot::Get()->GetDefaultWorld(); + } m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); -- cgit v1.2.3 From f94df06b6601f9dcecd383f5d093d225f41d1c65 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 9 Sep 2014 03:02:25 +0200 Subject: Added the player list to the 1.8 protocol. --- src/Entities/Player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b0da6965a..a720d8c35 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -266,7 +266,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) cTimer t1; if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { - m_World->SendPlayerList(this); + m_World->BroadcastPlayerListItem(*this, 2); m_LastPlayerListTime = t1.GetNowTime(); } @@ -1172,6 +1172,8 @@ void cPlayer::SetGameMode(eGameMode a_GameMode) SetFlying(false); SetCanFly(false); } + + m_World->BroadcastPlayerListItem(*this, 1); } -- cgit v1.2.3 From 96e03fc3ea9dd0a009f8e1f10fa364b2868c5d94 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 12 Sep 2014 19:34:19 +0200 Subject: Added extra mushroom handler. --- src/Entities/Player.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index e1f9c30ea..ea795e346 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -627,13 +627,6 @@ void cPlayer::FinishEating(void) return; } ItemHandler->OnFoodEaten(m_World, this, &Item); - - // if the food is mushroom soup, return a bowl to the inventory - if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP) - { - GetInventory().RemoveOneEquippedItem(); - GetInventory().AddItem(cItem(E_ITEM_BOWL), true, true); - } } -- 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(+) (limited to 'src/Entities/Player.cpp') 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 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(-) (limited to 'src/Entities/Player.cpp') 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(-) (limited to 'src/Entities/Player.cpp') 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 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(-) (limited to 'src/Entities/Player.cpp') 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 From 95af3eb526dc8d3289d6b1ced6462283a6ebb6b3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 17 Sep 2014 23:32:14 +0200 Subject: Fixed minor style issues. --- src/Entities/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3920bdb56..38d42be14 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 Spectator + if (IsGameModeSpectator()) // You can fly through the ground in Spectator { return; } @@ -1514,7 +1514,7 @@ void cPlayer::TossPickup(const cItem & a_Item) void cPlayer::TossItems(const cItems & a_Items) { - if (IsGameModeSpectator()) // Players can't toss items in spectator + if (IsGameModeSpectator()) // Players can't toss items in spectator { return; } -- cgit v1.2.3 From 43ed690520d3c3b47ed7ff6f48f868e8011565e0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 18 Sep 2014 18:50:17 +0200 Subject: Exported player list states to extra functions. --- src/Entities/Player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 826e0786f..36d8307b0 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -266,7 +266,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) cTimer t1; if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { - m_World->BroadcastPlayerListItem(*this, 2); + // m_World->BroadcastPlayerListUpdatePing(*this); m_LastPlayerListTime = t1.GetNowTime(); } @@ -1164,7 +1164,7 @@ void cPlayer::SetGameMode(eGameMode a_GameMode) SetCanFly(false); } - m_World->BroadcastPlayerListItem(*this, 1); + m_World->BroadcastPlayerListUpdateGameMode(*this); } -- cgit v1.2.3 From 52c875531ec3622eedd7096e44f6bc67c5e5483b Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 18 Sep 2014 18:51:36 +0200 Subject: Derp --- src/Entities/Player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 36d8307b0..55065d550 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -266,7 +266,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) cTimer t1; if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { - // m_World->BroadcastPlayerListUpdatePing(*this); + m_World->BroadcastPlayerListUpdatePing(*this); m_LastPlayerListTime = t1.GetNowTime(); } -- cgit v1.2.3