|
@@ -90,7 +90,6 @@ private:
|
|
|
|
|
|
void *ServerThread::run()
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
BEGIN_DEBUG_EXCEPTION_HANDLER
|
|
|
|
|
|
m_server->AsyncRunStep(true);
|
|
@@ -367,8 +366,6 @@ Server::~Server()
|
|
|
|
|
|
void Server::start(Address bind_addr)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
m_bind_addr = bind_addr;
|
|
|
|
|
|
infostream<<"Starting server on "
|
|
@@ -400,8 +397,6 @@ void Server::start(Address bind_addr)
|
|
|
|
|
|
void Server::stop()
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
infostream<<"Server: Stopping and waiting threads"<<std::endl;
|
|
|
|
|
|
// Stop threads (set run=false first so both start stopping)
|
|
@@ -415,7 +410,6 @@ void Server::stop()
|
|
|
|
|
|
void Server::step(float dtime)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
// Limit a bit
|
|
|
if (dtime > 2.0)
|
|
|
dtime = 2.0;
|
|
@@ -437,8 +431,6 @@ void Server::step(float dtime)
|
|
|
|
|
|
void Server::AsyncRunStep(bool initial_step)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
g_profiler->add("Server::AsyncRunStep (num)", 1);
|
|
|
|
|
|
float dtime;
|
|
@@ -980,7 +972,6 @@ void Server::AsyncRunStep(bool initial_step)
|
|
|
|
|
|
void Server::Receive()
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
u16 peer_id;
|
|
|
try {
|
|
|
NetworkPacket pkt;
|
|
@@ -1093,7 +1084,6 @@ inline void Server::handleCommand(NetworkPacket* pkt)
|
|
|
|
|
|
void Server::ProcessData(NetworkPacket *pkt)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
// Environment is locked first.
|
|
|
MutexAutoLock envlock(m_env_mutex);
|
|
|
|
|
@@ -1290,7 +1280,6 @@ void Server::SetBlocksNotSent(std::map<v3s16, MapBlock *>& block)
|
|
|
|
|
|
void Server::peerAdded(con::Peer *peer)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
verbosestream<<"Server::peerAdded(): peer->id="
|
|
|
<<peer->id<<std::endl;
|
|
|
|
|
@@ -1299,7 +1288,6 @@ void Server::peerAdded(con::Peer *peer)
|
|
|
|
|
|
void Server::deletingPeer(con::Peer *peer, bool timeout)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
verbosestream<<"Server::deletingPeer(): peer->id="
|
|
|
<<peer->id<<", timeout="<<timeout<<std::endl;
|
|
|
|
|
@@ -1396,7 +1384,6 @@ void Server::Send(NetworkPacket* pkt)
|
|
|
|
|
|
void Server::SendMovement(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
std::ostringstream os(std::ios_base::binary);
|
|
|
|
|
|
NetworkPacket pkt(TOCLIENT_MOVEMENT, 12 * sizeof(float), peer_id);
|
|
@@ -1433,8 +1420,6 @@ void Server::SendPlayerHPOrDie(PlayerSAO *playersao)
|
|
|
|
|
|
void Server::SendHP(u16 peer_id, u16 hp)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_HP, 1, peer_id);
|
|
|
pkt << hp;
|
|
|
Send(&pkt);
|
|
@@ -1442,8 +1427,6 @@ void Server::SendHP(u16 peer_id, u16 hp)
|
|
|
|
|
|
void Server::SendBreath(u16 peer_id, u16 breath)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_BREATH, 2, peer_id);
|
|
|
pkt << (u16) breath;
|
|
|
Send(&pkt);
|
|
@@ -1466,8 +1449,6 @@ void Server::SendAccessDenied(u16 peer_id, AccessDeniedCode reason,
|
|
|
|
|
|
void Server::SendAccessDenied_Legacy(u16 peer_id,const std::wstring &reason)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_ACCESS_DENIED_LEGACY, 0, peer_id);
|
|
|
pkt << reason;
|
|
|
Send(&pkt);
|
|
@@ -1476,8 +1457,6 @@ void Server::SendAccessDenied_Legacy(u16 peer_id,const std::wstring &reason)
|
|
|
void Server::SendDeathscreen(u16 peer_id,bool set_camera_point_target,
|
|
|
v3f camera_point_target)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_DEATHSCREEN, 1 + sizeof(v3f), peer_id);
|
|
|
pkt << set_camera_point_target << camera_point_target;
|
|
|
Send(&pkt);
|
|
@@ -1486,8 +1465,6 @@ void Server::SendDeathscreen(u16 peer_id,bool set_camera_point_target,
|
|
|
void Server::SendItemDef(u16 peer_id,
|
|
|
IItemDefManager *itemdef, u16 protocol_version)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_ITEMDEF, 0, peer_id);
|
|
|
|
|
|
/*
|
|
@@ -1511,8 +1488,6 @@ void Server::SendItemDef(u16 peer_id,
|
|
|
void Server::SendNodeDef(u16 peer_id,
|
|
|
INodeDefManager *nodedef, u16 protocol_version)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_NODEDEF, 0, peer_id);
|
|
|
|
|
|
/*
|
|
@@ -1540,8 +1515,6 @@ void Server::SendNodeDef(u16 peer_id,
|
|
|
|
|
|
void Server::SendInventory(PlayerSAO* playerSAO)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
UpdateCrafting(playerSAO->getPlayer());
|
|
|
|
|
|
/*
|
|
@@ -1561,8 +1534,6 @@ void Server::SendInventory(PlayerSAO* playerSAO)
|
|
|
|
|
|
void Server::SendChatMessage(u16 peer_id, const ChatMessage &message)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket legacypkt(TOCLIENT_CHAT_MESSAGE_OLD, 0, peer_id);
|
|
|
legacypkt << message.message;
|
|
|
|
|
@@ -1588,8 +1559,6 @@ void Server::SendChatMessage(u16 peer_id, const ChatMessage &message)
|
|
|
void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec,
|
|
|
const std::string &formname)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_SHOW_FORMSPEC, 0 , peer_id);
|
|
|
if (formspec.empty()){
|
|
|
//the client should close the formspec
|
|
@@ -1610,7 +1579,6 @@ void Server::SendSpawnParticle(u16 peer_id, u16 protocol_version,
|
|
|
bool vertical, const std::string &texture,
|
|
|
const struct TileAnimationParams &animation, u8 glow)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
static thread_local const float radius =
|
|
|
g_settings->getS16("max_block_send_distance") * MAP_BLOCKSIZE * BS;
|
|
|
|
|
@@ -1662,7 +1630,6 @@ void Server::SendAddParticleSpawner(u16 peer_id, u16 protocol_version,
|
|
|
u16 attached_id, bool vertical, const std::string &texture, u32 id,
|
|
|
const struct TileAnimationParams &animation, u8 glow)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
if (peer_id == PEER_ID_INEXISTENT) {
|
|
|
// This sucks and should be replaced:
|
|
|
std::vector<u16> clients = m_clients.getClientIDs();
|
|
@@ -1701,8 +1668,6 @@ void Server::SendAddParticleSpawner(u16 peer_id, u16 protocol_version,
|
|
|
|
|
|
void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_DELETE_PARTICLESPAWNER_LEGACY, 2, peer_id);
|
|
|
|
|
|
// Ugly error in this packet
|
|
@@ -1828,8 +1793,6 @@ void Server::SendOverrideDayNightRatio(u16 peer_id, bool do_override,
|
|
|
|
|
|
void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_TIME_OF_DAY, 0, peer_id);
|
|
|
pkt << time << time_speed;
|
|
|
|
|
@@ -1843,7 +1806,6 @@ void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed)
|
|
|
|
|
|
void Server::SendPlayerHP(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
|
|
// In some rare case if the player is disconnected
|
|
|
// while Lua call l_punch, for example, this can be NULL
|
|
@@ -1861,7 +1823,6 @@ void Server::SendPlayerHP(u16 peer_id)
|
|
|
|
|
|
void Server::SendPlayerBreath(PlayerSAO *sao)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
assert(sao);
|
|
|
|
|
|
m_script->player_event(sao, "breath_changed");
|
|
@@ -1870,7 +1831,6 @@ void Server::SendPlayerBreath(PlayerSAO *sao)
|
|
|
|
|
|
void Server::SendMovePlayer(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
RemotePlayer *player = m_env->getPlayer(peer_id);
|
|
|
assert(player);
|
|
|
PlayerSAO *sao = player->getPlayerSAO();
|
|
@@ -2194,8 +2154,6 @@ void Server::setBlockNotSent(v3s16 p)
|
|
|
|
|
|
void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto_version)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
v3s16 p = block->getPos();
|
|
|
|
|
|
/*
|
|
@@ -2216,8 +2174,6 @@ void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto
|
|
|
|
|
|
void Server::SendBlocks(float dtime)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
MutexAutoLock envlock(m_env_mutex);
|
|
|
//TODO check if one big lock could be faster then multiple small ones
|
|
|
|
|
@@ -2282,8 +2238,6 @@ void Server::SendBlocks(float dtime)
|
|
|
|
|
|
void Server::fillMediaCache()
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
infostream<<"Server: Calculating media file checksums"<<std::endl;
|
|
|
|
|
|
// Collect all media file paths
|
|
@@ -2379,8 +2333,6 @@ void Server::fillMediaCache()
|
|
|
|
|
|
void Server::sendMediaAnnouncement(u16 peer_id, const std::string &lang_code)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
verbosestream << "Server: Announcing files to id(" << peer_id << ")"
|
|
|
<< std::endl;
|
|
|
|
|
@@ -2425,8 +2377,6 @@ struct SendableMedia
|
|
|
void Server::sendRequestedMedia(u16 peer_id,
|
|
|
const std::vector<std::string> &tosend)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
verbosestream<<"Server::sendRequestedMedia(): "
|
|
|
<<"Sending files to client"<<std::endl;
|
|
|
|
|
@@ -2556,8 +2506,6 @@ void Server::sendDetachedInventory(const std::string &name, u16 peer_id)
|
|
|
|
|
|
void Server::sendDetachedInventories(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
for (const auto &detached_inventory : m_detached_inventories) {
|
|
|
const std::string &name = detached_inventory.first;
|
|
|
//Inventory *inv = i->second;
|
|
@@ -2571,7 +2519,6 @@ void Server::sendDetachedInventories(u16 peer_id)
|
|
|
|
|
|
void Server::DiePlayer(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
|
|
// In some rare cases this can be NULL -- if the player is disconnected
|
|
|
// when a Lua function modifies l_punch, for example
|
|
@@ -2593,8 +2540,6 @@ void Server::DiePlayer(u16 peer_id)
|
|
|
|
|
|
void Server::RespawnPlayer(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
|
|
assert(playersao);
|
|
|
|
|
@@ -2617,8 +2562,6 @@ void Server::RespawnPlayer(u16 peer_id)
|
|
|
|
|
|
void Server::DenySudoAccess(u16 peer_id)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
NetworkPacket pkt(TOCLIENT_DENY_SUDO_MODE, 0, peer_id);
|
|
|
Send(&pkt);
|
|
|
}
|
|
@@ -2643,8 +2586,6 @@ void Server::DenyAccessVerCompliant(u16 peer_id, u16 proto_ver, AccessDeniedCode
|
|
|
|
|
|
void Server::DenyAccess(u16 peer_id, AccessDeniedCode reason, const std::string &custom_reason)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
SendAccessDenied(peer_id, reason, custom_reason);
|
|
|
m_clients.event(peer_id, CSE_SetDenied);
|
|
|
m_con->DisconnectPeer(peer_id);
|
|
@@ -2654,8 +2595,6 @@ void Server::DenyAccess(u16 peer_id, AccessDeniedCode reason, const std::string
|
|
|
// the minimum version for MT users, maybe in 1 year
|
|
|
void Server::DenyAccess_Legacy(u16 peer_id, const std::wstring &reason)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
SendAccessDenied_Legacy(peer_id, reason);
|
|
|
m_clients.event(peer_id, CSE_SetDenied);
|
|
|
m_con->DisconnectPeer(peer_id);
|
|
@@ -2663,8 +2602,6 @@ void Server::DenyAccess_Legacy(u16 peer_id, const std::wstring &reason)
|
|
|
|
|
|
void Server::acceptAuth(u16 peer_id, bool forSudoMode)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
if (!forSudoMode) {
|
|
|
RemoteClient* client = getClient(peer_id, CS_Invalid);
|
|
|
|
|
@@ -2694,7 +2631,6 @@ void Server::acceptAuth(u16 peer_id, bool forSudoMode)
|
|
|
|
|
|
void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
std::wstring message;
|
|
|
{
|
|
|
/*
|
|
@@ -2770,8 +2706,6 @@ void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason)
|
|
|
|
|
|
void Server::UpdateCrafting(RemotePlayer *player)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
// Get a preview for crafting
|
|
|
ItemStack preview;
|
|
|
InventoryLocation loc;
|
|
@@ -3608,8 +3542,6 @@ void Server::unregisterModStorage(const std::string &name)
|
|
|
|
|
|
void dedicated_server_loop(Server &server, bool &kill)
|
|
|
{
|
|
|
- DSTACK(FUNCTION_NAME);
|
|
|
-
|
|
|
verbosestream<<"dedicated_server_loop()"<<std::endl;
|
|
|
|
|
|
IntervalLimiter m_profiler_interval;
|