Compare commits

...

5 Commits

Author SHA1 Message Date
Ciaran Gultnieks 09d86db9a3 Fix get_all_craft_recipes documentation error 2015-05-11 12:45:10 +01:00
Ciaran Gultnieks 7d8079885d Rework/cleanup of Selat's rewritten pathfinder 2015-01-21 15:41:38 +00:00
Ciaran Gultnieks 36d0152f6c Revert "Pathfinder rewrite - minetest PR #1151 squashed"
This reverts commit 0af0a711f410b436b893ac9573abced8d746bc89.
2015-01-21 15:40:40 +00:00
Ciaran Gultnieks 99f17c9047 Fix incorrect distant player positions when attached
When a player is attached to an object (e.g. riding a cart, animal,
vehicle) and that object goes out of range, the player's position
gets messed up. With this change, if a player is attached to an
object, that object always sends its position to clients (if unlimited
range for players is set).
2015-01-21 15:39:14 +00:00
Ciaran Gultnieks 538d575391 Disable unnecessary logging 2015-01-21 15:39:13 +00:00
5 changed files with 38 additions and 5 deletions

View File

@ -1997,7 +1997,7 @@ and `minetest.auth_reload` call the authetification handler.
or `nil` if no recipe was found
* recipe entry table:
{
method = 'normal' or 'cooking' or 'fuel'
type = 'normal' or 'cooking' or 'fuel'
width = 0-3, 0 means shapeless recipe
items = indexed [1-9] table with recipe items
output = string with item name and quantity

View File

@ -617,6 +617,26 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
}
}
bool LuaEntitySAO::unlimitedTransferDistance() const
{
// If a player is attached to this object, we want to always send its
// position to clients, regardless of range. Otherwise, the player
// position is reported wrongly on the clients.
if(!g_settings->getBool("unlimited_player_transfer_distance"))
return false;
std::list<Player*> players = m_env->getPlayers();
for(std::list<Player*>::iterator
i = players.begin();
i != players.end(); ++i) {
Player *player = *i;
PlayerSAO* sao = player->getPlayerSAO();
if(sao != NULL && sao->isAttachedTo(m_id))
return true;
}
return false;
}
std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
{
std::ostringstream os(std::ios::binary);
@ -1125,6 +1145,11 @@ bool PlayerSAO::isAttached()
return false;
}
bool PlayerSAO::isAttachedTo(u16 id)
{
return m_attachment_parent_id == id;
}
void PlayerSAO::step(float dtime, bool send_recommended)
{
if(!m_properties_sent)

View File

@ -46,6 +46,7 @@ public:
{ return ACTIVEOBJECT_TYPE_GENERIC; }
virtual void addedToEnvironment(u32 dtime_s);
void removingFromEnvironment();
bool unlimitedTransferDistance() const;
static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
const std::string &data);
bool isAttached();
@ -183,6 +184,7 @@ public:
std::string getClientInitializationData(u16 protocol_version);
std::string getStaticData();
bool isAttached();
bool isAttachedTo(u16 id);
void step(float dtime, bool send_recommended);
void setBasePosition(const v3f &position);
void setPos(v3f pos);

View File

@ -31,6 +31,7 @@
#include <set>
#include <climits>
#include <algorithm>
#define PPOS(pos) "(" << pos.X << "," << pos.Y << "," << pos.Z << ")"
@ -141,6 +142,11 @@ std::vector<v3s16> PathFinder::getPath(ServerEnvironment* env,
std::vector<v3s16> path;
buildPath(path, source, destination);
// Support bug of previous pathfinder
if(path.size() == 1) {
path.push_back(path[path.size() - 1]);
}
#ifdef PATHFINDER_CALC_TIME
timespec ts2;
clock_gettime(CLOCK_REALTIME, &ts2);
@ -282,7 +288,7 @@ bool PathFinder::findPathHeuristic(v3s16 pos, std::vector <v3s16>& directions,
++test_pos.Y;
node_at_test_pos = m_env->getMap().getNodeNoEx(test_pos);
}
// Did we find surface?
if((test_pos.Y <= m_limits.Y.max) &&
(node_at_test_pos.param0 == CONTENT_AIR) &&
@ -317,6 +323,6 @@ void PathFinder::buildPath(std::vector<v3s16>& path, v3s16 start_pos, v3s16 end_
path.push_back(current_pos);
current_pos = used[current_pos].first;
}
path.push_back(start_pos);
path.push_back(start_pos);
std::reverse(path.begin(), path.end());
}

View File

@ -1024,7 +1024,7 @@ void Server::AsyncRunStep(bool initial_step)
}
else if(event->type == MEET_BLOCK_NODE_METADATA_CHANGED)
{
infostream<<"Server: MEET_BLOCK_NODE_METADATA_CHANGED"<<std::endl;
//infostream<<"Server: MEET_BLOCK_NODE_METADATA_CHANGED"<<PP(event->p)<<std::endl;
prof.add("MEET_BLOCK_NODE_METADATA_CHANGED", 1);
setBlockNotSent(event->p);
}