1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-31 18:31:04 +00:00

added PlayerSAO and RemotePlayer, removed ServerRemotePlayer

This commit is contained in:
Kahrl 2012-03-19 03:04:16 +01:00 committed by Perttu Ahola
parent 072c265c30
commit f8c3743991
20 changed files with 833 additions and 810 deletions

View file

@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "utility.h"
#include "settings.h"
#include "main.h" // For g_settings
#include "content_sao.h"
#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
@ -216,20 +217,26 @@ void cmd_teleport(std::wostringstream &os,
return;
}
v3f dest(stoi(coords[0])*10, stoi(coords[1])*10, stoi(coords[2])*10);
v3f dest(stoi(coords[0])*BS, stoi(coords[1])*BS, stoi(coords[2])*BS);
actionstream<<ctx->player->getName()<<" teleports from "
<<PP(ctx->player->getPosition()/BS)<<" to "
<<PP(dest/BS)<<std::endl;
//ctx->player->setPosition(dest);
// Use the ServerActiveObject interface of ServerRemotePlayer
ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(ctx->player);
srp->setPos(dest);
ctx->server->SendMovePlayer(ctx->player);
os<< L"-!- Teleported.";
// Use the ServerActiveObject interface of RemotePlayer
// This forces a position change on the client
ServerActiveObject *sao = ctx->player->getPlayerSAO();
if(sao)
{
sao->setPos(dest);
os<< L"-!- Teleported.";
}
else
{
errorstream<<"Teleport failed, player object not found!"
<<std::endl;
os<< L"-!- Teleport failed.";
}
}
void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)