summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Bindings/PluginManager.cpp22
-rw-r--r--src/Entities/Entity.cpp13
-rw-r--r--src/Entities/Entity.h3
-rw-r--r--src/Entities/Pawn.cpp6
4 files changed, 43 insertions, 1 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index 4d291f164..bf907b31d 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -1894,7 +1894,27 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector &
// Player doesn't have permission for the command
continue;
}
- a_Results.push_back(itr->first);
+
+ /* Client expects to only get back the last part of a space separated command.
+ Find the position of the beginning of the last part:
+ Position of last space + 1 for space separated commands
+ string::npos + 1 = 0 for commands that are not separated
+
+ Then skip all commands that have too many subcommands.
+ When the client asks for suggestions for "/time s"
+ the server must skip all commands that consist of more than 2 words just as
+ "/time set day". Or in other words, the position of the last space (separator)
+ in the strings must be equal or string::npos for both. */
+ size_t LastSpaceInText = a_Text.find_last_of(' ') + 1;
+ size_t LastSpaceInSuggestion = itr->first.find_last_of(' ') + 1;
+
+ if (LastSpaceInText != LastSpaceInSuggestion)
+ {
+ // Suggestion has more subcommands than a_Text
+ continue;
+ }
+
+ a_Results.push_back(itr->first.substr(LastSpaceInSuggestion));
}
}
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index ff03bae3c..0706a1676 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -1873,6 +1873,19 @@ bool cEntity::IsA(const char * a_ClassName) const
+bool cEntity::IsAttachedTo(const cEntity * a_Entity) const
+{
+ if ((m_AttachedTo != nullptr) && (a_Entity->GetUniqueID() == m_AttachedTo->GetUniqueID()))
+ {
+ return true;
+ }
+ return false;
+}
+
+
+
+
+
void cEntity::SetHeadYaw(double a_HeadYaw)
{
m_HeadYaw = a_HeadYaw;
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 3715fb5c4..dbfc019e7 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -423,6 +423,9 @@ public:
/** Detaches from the currently attached entity, if any */
virtual void Detach(void);
+ /** Returns true if this entity is attached to the specified entity */
+ bool IsAttachedTo(const cEntity * a_Entity) const;
+
/** Makes sure head yaw is not over the specified range. */
void WrapHeadYaw();
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 6b404f7e0..2d86dfecf 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -73,6 +73,12 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return false;
}
+ // do not push a boat / minecart you're sitting in
+ if (m_Pusher->IsAttachedTo(a_Entity))
+ {
+ return false;
+ }
+
Vector3d v3Delta = a_Entity->GetPosition() - m_Pusher->GetPosition();
v3Delta.y = 0.0; // we only push sideways
v3Delta *= 1.0 / (v3Delta.Length() + 0.01); // we push harder if we're close