From c0015d01c6be8b4061a19484d13b7d0e74426be5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Jun 2014 19:50:27 +0200 Subject: Player permissions aren't logged to console anymore. This was only logspam on most servers and there are alternative ways to list players' permissions. --- 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 0dfdcfd8b..3a9324d09 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1650,13 +1650,6 @@ bool cPlayer::LoadFromDisk() { LoadPermissionsFromDisk(); - // Log player permissions, cause it's what the cool kids do - LOGINFO("Player %s has permissions:", GetName().c_str() ); - for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr ) - { - if( itr->second ) LOG(" - %s", itr->first.c_str() ); - } - AString SourceFile; Printf(SourceFile, "players/%s.json", GetName().c_str() ); -- cgit v1.2.3 From b904223b9dbbe7b696dbd30e748bc131742e11ea Mon Sep 17 00:00:00 2001 From: Mattes D Date: Fri, 6 Jun 2014 22:31:16 +0200 Subject: Added queue for adding entities to cWorld. This alone doesn't work properly yet, further changes to cPlayer are needed. --- src/Entities/Player.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3a9324d09..b83419903 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1595,8 +1595,6 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); // Add player to all the necessary parts of the new world - SetWorld(World); - m_ClientHandle->StreamChunks(); World->AddEntity(this); World->AddPlayer(this); -- cgit v1.2.3 From af4a21ea0689107b377818574cb07dc4a2e8b755 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 8 Jun 2014 21:58:08 +0200 Subject: Fixed deadlock when moving players to other worlds. Fixes #1039, fixes #851 --- src/Entities/Player.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index b83419903..feb09b5d2 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -940,6 +940,8 @@ void cPlayer::Killed(cEntity * a_Victim) void cPlayer::Respawn(void) { + ASSERT(m_World != NULL); + m_Health = GetMaxHealth(); SetInvulnerableTicks(20); @@ -952,7 +954,7 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(); + m_ClientHandle->SendRespawn(*m_World); // Extinguish the fire: StopBurning(); @@ -1583,19 +1585,19 @@ bool cPlayer::MoveToWorld(const char * a_WorldName) return false; } - eDimension OldDimension = m_World->GetDimension(); - + // Send the respawn packet: + if (m_ClientHandle != NULL) + { + m_ClientHandle->SendRespawn(*World); + } + // Remove all links to the old world m_World->RemovePlayer(this); - m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntity(this); // If the dimension is different, we can send the respawn packet // http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02 - m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension())); - // Add player to all the necessary parts of the new world - World->AddEntity(this); + // Queue adding player to the new world, including all the necessary adjustments to the object World->AddPlayer(this); return true; -- cgit v1.2.3 From ee50790398791c38e563eee04cf12780fab74baf Mon Sep 17 00:00:00 2001 From: Tycho Date: Mon, 16 Jun 2014 15:12:50 +0100 Subject: Merge branch 'master' of github.com:mc-server/MCServer --- src/Entities/Player.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/Entities/Player.cpp') diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index feb09b5d2..fdc0bb390 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -22,6 +22,12 @@ #include "inifile/iniFile.h" #include "json/json.h" +// 6000 ticks or 5 minutes +#define PLAYER_INVENTORY_SAVE_INTERVAL 6000 + +// 1000 = once per second +#define PLAYER_LIST_TIME_MS 1000 + @@ -64,6 +70,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) , m_BowCharge(0) , m_FloaterID(-1) , m_Team(NULL) + , m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL) { LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d", a_PlayerName.c_str(), a_Client->GetIPString().c_str(), @@ -250,7 +257,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) // Send Player List (Once per m_LastPlayerListTime/1000 ms) cTimer t1; - if (m_LastPlayerListTime + cPlayer::PLAYER_LIST_TIME_MS <= t1.GetNowTime()) + if (m_LastPlayerListTime + PLAYER_LIST_TIME_MS <= t1.GetNowTime()) { m_World->SendPlayerList(this); m_LastPlayerListTime = t1.GetNowTime(); @@ -260,6 +267,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) { m_LastGroundHeight = (float)GetPosY(); } + + if (m_TicksUntilNextSave == 0) + { + SaveToDisk(); + m_TicksUntilNextSave = PLAYER_INVENTORY_SAVE_INTERVAL; + } + else + { + m_TicksUntilNextSave--; + } } @@ -1257,6 +1274,17 @@ Vector3d cPlayer::GetThrowSpeed(double a_SpeedCoeff) const void cPlayer::ForceSetSpeed(const Vector3d & a_Speed) { SetSpeed(a_Speed); +} + + + + + +void cPlayer::DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) +{ + super::DoSetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ); + + // Send the speed to the client so he actualy moves m_ClientHandle->SendEntityVelocity(*this); } -- cgit v1.2.3