diff options
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 131 |
1 files changed, 69 insertions, 62 deletions
diff --git a/src/server.cpp b/src/server.cpp index 0f5c06773..42209960a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -974,7 +974,7 @@ void Server::AsyncRunStep(bool initial_step) void Server::Receive() { - u16 peer_id; + session_t peer_id; try { NetworkPacket pkt; m_con->Receive(&pkt); @@ -995,7 +995,7 @@ void Server::Receive() } } -PlayerSAO* Server::StageTwoClientInit(u16 peer_id) +PlayerSAO* Server::StageTwoClientInit(session_t peer_id) { std::string playername; PlayerSAO *playersao = NULL; @@ -1297,14 +1297,14 @@ void Server::deletingPeer(con::Peer *peer, bool timeout) m_peer_change_queue.push(con::PeerChange(con::PEER_REMOVED, peer->id, timeout)); } -bool Server::getClientConInfo(u16 peer_id, con::rtt_stat_type type, float* retval) +bool Server::getClientConInfo(session_t peer_id, con::rtt_stat_type type, float* retval) { *retval = m_con->getPeerStat(peer_id,type); return *retval != -1; } bool Server::getClientInfo( - u16 peer_id, + session_t peer_id, ClientState* state, u32* uptime, u8* ser_vers, @@ -1381,7 +1381,7 @@ void Server::Send(NetworkPacket *pkt) Send(pkt->getPeerId(), pkt); } -void Server::Send(u16 peer_id, NetworkPacket *pkt) +void Server::Send(session_t peer_id, NetworkPacket *pkt) { m_clients.send(peer_id, clientCommandFactoryTable[pkt->getCommand()].channel, @@ -1389,7 +1389,7 @@ void Server::Send(u16 peer_id, NetworkPacket *pkt) clientCommandFactoryTable[pkt->getCommand()].reliable); } -void Server::SendMovement(u16 peer_id) +void Server::SendMovement(session_t peer_id) { std::ostringstream os(std::ios_base::binary); @@ -1416,7 +1416,7 @@ void Server::SendPlayerHPOrDie(PlayerSAO *playersao) if (!g_settings->getBool("enable_damage")) return; - u16 peer_id = playersao->getPeerID(); + session_t peer_id = playersao->getPeerID(); bool is_alive = playersao->getHP() > 0; if (is_alive) @@ -1425,21 +1425,21 @@ void Server::SendPlayerHPOrDie(PlayerSAO *playersao) DiePlayer(peer_id); } -void Server::SendHP(u16 peer_id, u16 hp) +void Server::SendHP(session_t peer_id, u16 hp) { NetworkPacket pkt(TOCLIENT_HP, 1, peer_id); pkt << hp; Send(&pkt); } -void Server::SendBreath(u16 peer_id, u16 breath) +void Server::SendBreath(session_t peer_id, u16 breath) { NetworkPacket pkt(TOCLIENT_BREATH, 2, peer_id); pkt << (u16) breath; Send(&pkt); } -void Server::SendAccessDenied(u16 peer_id, AccessDeniedCode reason, +void Server::SendAccessDenied(session_t peer_id, AccessDeniedCode reason, const std::string &custom_reason, bool reconnect) { assert(reason < SERVER_ACCESSDENIED_MAX); @@ -1454,14 +1454,14 @@ void Server::SendAccessDenied(u16 peer_id, AccessDeniedCode reason, Send(&pkt); } -void Server::SendAccessDenied_Legacy(u16 peer_id,const std::wstring &reason) +void Server::SendAccessDenied_Legacy(session_t peer_id,const std::wstring &reason) { NetworkPacket pkt(TOCLIENT_ACCESS_DENIED_LEGACY, 0, peer_id); pkt << reason; Send(&pkt); } -void Server::SendDeathscreen(u16 peer_id,bool set_camera_point_target, +void Server::SendDeathscreen(session_t peer_id, bool set_camera_point_target, v3f camera_point_target) { NetworkPacket pkt(TOCLIENT_DEATHSCREEN, 1 + sizeof(v3f), peer_id); @@ -1469,7 +1469,7 @@ void Server::SendDeathscreen(u16 peer_id,bool set_camera_point_target, Send(&pkt); } -void Server::SendItemDef(u16 peer_id, +void Server::SendItemDef(session_t peer_id, IItemDefManager *itemdef, u16 protocol_version) { NetworkPacket pkt(TOCLIENT_ITEMDEF, 0, peer_id); @@ -1492,7 +1492,7 @@ void Server::SendItemDef(u16 peer_id, Send(&pkt); } -void Server::SendNodeDef(u16 peer_id, +void Server::SendNodeDef(session_t peer_id, INodeDefManager *nodedef, u16 protocol_version) { NetworkPacket pkt(TOCLIENT_NODEDEF, 0, peer_id); @@ -1539,7 +1539,7 @@ void Server::SendInventory(PlayerSAO* playerSAO) Send(&pkt); } -void Server::SendChatMessage(u16 peer_id, const ChatMessage &message) +void Server::SendChatMessage(session_t peer_id, const ChatMessage &message) { NetworkPacket pkt(TOCLIENT_CHAT_MESSAGE, 0, peer_id); u8 version = 1; @@ -1557,7 +1557,7 @@ void Server::SendChatMessage(u16 peer_id, const ChatMessage &message) } } -void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec, +void Server::SendShowFormspecMessage(session_t peer_id, const std::string &formspec, const std::string &formname) { NetworkPacket pkt(TOCLIENT_SHOW_FORMSPEC, 0 , peer_id); @@ -1573,7 +1573,7 @@ void Server::SendShowFormspecMessage(u16 peer_id, const std::string &formspec, } // Spawns a particle on peer with peer_id -void Server::SendSpawnParticle(u16 peer_id, u16 protocol_version, +void Server::SendSpawnParticle(session_t peer_id, u16 protocol_version, v3f pos, v3f velocity, v3f acceleration, float expirationtime, float size, bool collisiondetection, bool collision_removal, @@ -1624,7 +1624,7 @@ void Server::SendSpawnParticle(u16 peer_id, u16 protocol_version, } // Adds a ParticleSpawner on peer with peer_id -void Server::SendAddParticleSpawner(u16 peer_id, u16 protocol_version, +void Server::SendAddParticleSpawner(session_t peer_id, u16 protocol_version, u16 amount, float spawntime, v3f minpos, v3f maxpos, v3f minvel, v3f maxvel, v3f minacc, v3f maxacc, float minexptime, float maxexptime, float minsize, float maxsize, bool collisiondetection, bool collision_removal, @@ -1667,7 +1667,7 @@ void Server::SendAddParticleSpawner(u16 peer_id, u16 protocol_version, Send(&pkt); } -void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id) +void Server::SendDeleteParticleSpawner(session_t peer_id, u32 id) { NetworkPacket pkt(TOCLIENT_DELETE_PARTICLESPAWNER, 4, peer_id); @@ -1681,7 +1681,7 @@ void Server::SendDeleteParticleSpawner(u16 peer_id, u32 id) } -void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form) +void Server::SendHUDAdd(session_t peer_id, u32 id, HudElement *form) { NetworkPacket pkt(TOCLIENT_HUDADD, 0 , peer_id); @@ -1692,14 +1692,14 @@ void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form) Send(&pkt); } -void Server::SendHUDRemove(u16 peer_id, u32 id) +void Server::SendHUDRemove(session_t peer_id, u32 id) { NetworkPacket pkt(TOCLIENT_HUDRM, 4, peer_id); pkt << id; Send(&pkt); } -void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value) +void Server::SendHUDChange(session_t peer_id, u32 id, HudElementStat stat, void *value) { NetworkPacket pkt(TOCLIENT_HUDCHANGE, 0, peer_id); pkt << id << (u8) stat; @@ -1732,7 +1732,7 @@ void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value Send(&pkt); } -void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask) +void Server::SendHUDSetFlags(session_t peer_id, u32 flags, u32 mask) { NetworkPacket pkt(TOCLIENT_HUD_SET_FLAGS, 4 + 4, peer_id); @@ -1743,14 +1743,14 @@ void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask) Send(&pkt); } -void Server::SendHUDSetParam(u16 peer_id, u16 param, const std::string &value) +void Server::SendHUDSetParam(session_t peer_id, u16 param, const std::string &value) { NetworkPacket pkt(TOCLIENT_HUD_SET_PARAM, 0, peer_id); pkt << param << value; Send(&pkt); } -void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor, +void Server::SendSetSky(session_t peer_id, const video::SColor &bgcolor, const std::string &type, const std::vector<std::string> ¶ms, bool &clouds) { @@ -1765,7 +1765,7 @@ void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor, Send(&pkt); } -void Server::SendCloudParams(u16 peer_id, float density, +void Server::SendCloudParams(session_t peer_id, float density, const video::SColor &color_bright, const video::SColor &color_ambient, float height, @@ -1779,7 +1779,7 @@ void Server::SendCloudParams(u16 peer_id, float density, Send(&pkt); } -void Server::SendOverrideDayNightRatio(u16 peer_id, bool do_override, +void Server::SendOverrideDayNightRatio(session_t peer_id, bool do_override, float ratio) { NetworkPacket pkt(TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO, @@ -1790,7 +1790,7 @@ void Server::SendOverrideDayNightRatio(u16 peer_id, bool do_override, Send(&pkt); } -void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed) +void Server::SendTimeOfDay(session_t peer_id, u16 time, f32 time_speed) { NetworkPacket pkt(TOCLIENT_TIME_OF_DAY, 0, peer_id); pkt << time << time_speed; @@ -1803,7 +1803,7 @@ void Server::SendTimeOfDay(u16 peer_id, u16 time, f32 time_speed) } } -void Server::SendPlayerHP(u16 peer_id) +void Server::SendPlayerHP(session_t peer_id) { PlayerSAO *playersao = getPlayerSAO(peer_id); // In some rare case if the player is disconnected @@ -1828,7 +1828,7 @@ void Server::SendPlayerBreath(PlayerSAO *sao) SendBreath(sao->getPeerID(), sao->getBreath()); } -void Server::SendMovePlayer(u16 peer_id) +void Server::SendMovePlayer(session_t peer_id) { RemotePlayer *player = m_env->getPlayer(peer_id); assert(player); @@ -1850,7 +1850,8 @@ void Server::SendMovePlayer(u16 peer_id) Send(&pkt); } -void Server::SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f32 animation_speed) +void Server::SendLocalPlayerAnimations(session_t peer_id, v2s32 animation_frames[4], + f32 animation_speed) { NetworkPacket pkt(TOCLIENT_LOCAL_PLAYER_ANIMATIONS, 0, peer_id); @@ -1861,13 +1862,14 @@ void Server::SendLocalPlayerAnimations(u16 peer_id, v2s32 animation_frames[4], f Send(&pkt); } -void Server::SendEyeOffset(u16 peer_id, v3f first, v3f third) +void Server::SendEyeOffset(session_t peer_id, v3f first, v3f third) { NetworkPacket pkt(TOCLIENT_EYE_OFFSET, 0, peer_id); pkt << first << third; Send(&pkt); } -void Server::SendPlayerPrivileges(u16 peer_id) + +void Server::SendPlayerPrivileges(session_t peer_id) { RemotePlayer *player = m_env->getPlayer(peer_id); assert(player); @@ -1887,7 +1889,7 @@ void Server::SendPlayerPrivileges(u16 peer_id) Send(&pkt); } -void Server::SendPlayerInventoryFormspec(u16 peer_id) +void Server::SendPlayerInventoryFormspec(session_t peer_id) { RemotePlayer *player = m_env->getPlayer(peer_id); assert(player); @@ -1899,7 +1901,7 @@ void Server::SendPlayerInventoryFormspec(u16 peer_id) Send(&pkt); } -u32 Server::SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas) +u32 Server::SendActiveObjectRemoveAdd(session_t peer_id, const std::string &datas) { NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD, datas.size(), peer_id); pkt.putRawString(datas.c_str(), datas.size()); @@ -1907,7 +1909,8 @@ u32 Server::SendActiveObjectRemoveAdd(u16 peer_id, const std::string &datas) return pkt.getSize(); } -void Server::SendActiveObjectMessages(u16 peer_id, const std::string &datas, bool reliable) +void Server::SendActiveObjectMessages(session_t peer_id, const std::string &datas, + bool reliable) { NetworkPacket pkt(TOCLIENT_ACTIVE_OBJECT_MESSAGES, datas.size(), peer_id); @@ -1919,7 +1922,7 @@ void Server::SendActiveObjectMessages(u16 peer_id, const std::string &datas, boo &pkt, reliable); } -void Server::SendCSMFlavourLimits(u16 peer_id) +void Server::SendCSMFlavourLimits(session_t peer_id) { NetworkPacket pkt(TOCLIENT_CSM_FLAVOUR_LIMITS, sizeof(m_csm_flavour_limits) + sizeof(m_csm_noderange_limit), peer_id); @@ -2151,7 +2154,8 @@ void Server::setBlockNotSent(v3s16 p) m_clients.unlock(); } -void Server::SendBlockNoLock(u16 peer_id, MapBlock *block, u8 ver, u16 net_proto_version) +void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver, + u16 net_proto_version) { v3s16 p = block->getPos(); @@ -2332,7 +2336,7 @@ void Server::fillMediaCache() } } -void Server::sendMediaAnnouncement(u16 peer_id, const std::string &lang_code) +void Server::sendMediaAnnouncement(session_t peer_id, const std::string &lang_code) { verbosestream << "Server: Announcing files to id(" << peer_id << ")" << std::endl; @@ -2375,7 +2379,7 @@ struct SendableMedia {} }; -void Server::sendRequestedMedia(u16 peer_id, +void Server::sendRequestedMedia(session_t peer_id, const std::vector<std::string> &tosend) { verbosestream<<"Server::sendRequestedMedia(): " @@ -2474,7 +2478,7 @@ void Server::sendRequestedMedia(u16 peer_id, } } -void Server::sendDetachedInventory(const std::string &name, u16 peer_id) +void Server::sendDetachedInventory(const std::string &name, session_t peer_id) { if(m_detached_inventories.count(name) == 0) { errorstream<<FUNCTION_NAME<<": \""<<name<<"\" not found"<<std::endl; @@ -2505,7 +2509,7 @@ void Server::sendDetachedInventory(const std::string &name, u16 peer_id) } } -void Server::sendDetachedInventories(u16 peer_id) +void Server::sendDetachedInventories(session_t peer_id) { for (const auto &detached_inventory : m_detached_inventories) { const std::string &name = detached_inventory.first; @@ -2518,7 +2522,7 @@ void Server::sendDetachedInventories(u16 peer_id) Something random */ -void Server::DiePlayer(u16 peer_id) +void Server::DiePlayer(session_t peer_id) { PlayerSAO *playersao = getPlayerSAO(peer_id); // In some rare cases this can be NULL -- if the player is disconnected @@ -2539,7 +2543,7 @@ void Server::DiePlayer(u16 peer_id) SendDeathscreen(peer_id, false, v3f(0,0,0)); } -void Server::RespawnPlayer(u16 peer_id) +void Server::RespawnPlayer(session_t peer_id) { PlayerSAO *playersao = getPlayerSAO(peer_id); assert(playersao); @@ -2561,14 +2565,14 @@ void Server::RespawnPlayer(u16 peer_id) } -void Server::DenySudoAccess(u16 peer_id) +void Server::DenySudoAccess(session_t peer_id) { NetworkPacket pkt(TOCLIENT_DENY_SUDO_MODE, 0, peer_id); Send(&pkt); } -void Server::DenyAccessVerCompliant(u16 peer_id, u16 proto_ver, AccessDeniedCode reason, +void Server::DenyAccessVerCompliant(session_t peer_id, u16 proto_ver, AccessDeniedCode reason, const std::string &str_reason, bool reconnect) { SendAccessDenied(peer_id, reason, str_reason, reconnect); @@ -2578,7 +2582,8 @@ void Server::DenyAccessVerCompliant(u16 peer_id, u16 proto_ver, AccessDeniedCode } -void Server::DenyAccess(u16 peer_id, AccessDeniedCode reason, const std::string &custom_reason) +void Server::DenyAccess(session_t peer_id, AccessDeniedCode reason, + const std::string &custom_reason) { SendAccessDenied(peer_id, reason, custom_reason); m_clients.event(peer_id, CSE_SetDenied); @@ -2587,20 +2592,20 @@ void Server::DenyAccess(u16 peer_id, AccessDeniedCode reason, const std::string // 13/03/15: remove this function when protocol version 25 will become // the minimum version for MT users, maybe in 1 year -void Server::DenyAccess_Legacy(u16 peer_id, const std::wstring &reason) +void Server::DenyAccess_Legacy(session_t peer_id, const std::wstring &reason) { SendAccessDenied_Legacy(peer_id, reason); m_clients.event(peer_id, CSE_SetDenied); DisconnectPeer(peer_id); } -void Server::DisconnectPeer(u16 peer_id) +void Server::DisconnectPeer(session_t peer_id) { m_modchannel_mgr->leaveAllChannels(peer_id); m_con->DisconnectPeer(peer_id); } -void Server::acceptAuth(u16 peer_id, bool forSudoMode) +void Server::acceptAuth(session_t peer_id, bool forSudoMode) { if (!forSudoMode) { RemoteClient* client = getClient(peer_id, CS_Invalid); @@ -2629,7 +2634,7 @@ void Server::acceptAuth(u16 peer_id, bool forSudoMode) } } -void Server::DeleteClient(u16 peer_id, ClientDeletionReason reason) +void Server::DeleteClient(session_t peer_id, ClientDeletionReason reason) { std::wstring message; { @@ -2814,7 +2819,7 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna if they are using protocol version >= 29 */ - u16 peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT); + session_t peer_id_to_avoid_sending = (player ? player->peer_id : PEER_ID_INEXISTENT); if (player && player->protocol_version >= 29) peer_id_to_avoid_sending = PEER_ID_INEXISTENT; @@ -2839,7 +2844,7 @@ void Server::handleAdminChat(const ChatEventChat *evt) } } -RemoteClient* Server::getClient(u16 peer_id, ClientState state_min) +RemoteClient *Server::getClient(session_t peer_id, ClientState state_min) { RemoteClient *client = getClientNoEx(peer_id,state_min); if(!client) @@ -2847,12 +2852,12 @@ RemoteClient* Server::getClient(u16 peer_id, ClientState state_min) return client; } -RemoteClient* Server::getClientNoEx(u16 peer_id, ClientState state_min) +RemoteClient *Server::getClientNoEx(session_t peer_id, ClientState state_min) { return m_clients.getClientNoEx(peer_id, state_min); } -std::string Server::getPlayerName(u16 peer_id) +std::string Server::getPlayerName(session_t peer_id) { RemotePlayer *player = m_env->getPlayer(peer_id); if (!player) @@ -2860,7 +2865,7 @@ std::string Server::getPlayerName(u16 peer_id) return player->getName(); } -PlayerSAO* Server::getPlayerSAO(u16 peer_id) +PlayerSAO *Server::getPlayerSAO(session_t peer_id) { RemotePlayer *player = m_env->getPlayer(peer_id); if (!player) @@ -3104,7 +3109,7 @@ const std::string& Server::hudGetHotbarSelectedImage(RemotePlayer *player) const return player->getHotbarSelectedImage(); } -Address Server::getPeerAddress(u16 peer_id) +Address Server::getPeerAddress(session_t peer_id) { return m_con->GetPeerAddress(peer_id); } @@ -3186,7 +3191,8 @@ void Server::spawnParticle(const std::string &playername, v3f pos, if (!m_env) return; - u16 peer_id = PEER_ID_INEXISTENT, proto_ver = 0; + session_t peer_id = PEER_ID_INEXISTENT; + u16 proto_ver = 0; if (!playername.empty()) { RemotePlayer *player = m_env->getPlayer(playername.c_str()); if (!player) @@ -3212,7 +3218,8 @@ u32 Server::addParticleSpawner(u16 amount, float spawntime, if (!m_env) return -1; - u16 peer_id = PEER_ID_INEXISTENT, proto_ver = 0; + session_t peer_id = PEER_ID_INEXISTENT; + u16 proto_ver = 0; if (!playername.empty()) { RemotePlayer *player = m_env->getPlayer(playername.c_str()); if (!player) @@ -3244,7 +3251,7 @@ void Server::deleteParticleSpawner(const std::string &playername, u32 id) if (!m_env) throw ServerError("Can't delete particle spawners during initialisation!"); - u16 peer_id = PEER_ID_INEXISTENT; + session_t peer_id = PEER_ID_INEXISTENT; if (!playername.empty()) { RemotePlayer *player = m_env->getPlayer(playername.c_str()); if (!player) @@ -3475,7 +3482,7 @@ void Server::requestShutdown(const std::string &msg, bool reconnect, float delay } } -PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id, u16 proto_version) +PlayerSAO* Server::emergePlayer(const char *name, session_t peer_id, u16 proto_version) { /* Try to get an existing player @@ -3636,7 +3643,7 @@ void Server::broadcastModChannelMessage(const std::string &channel, NetworkPacket resp_pkt(TOCLIENT_MODCHANNEL_MSG, 2 + channel.size() + 2 + sender.size() + 2 + message.size()); resp_pkt << channel << sender << message; - for (u16 peer_id : peers) { + for (session_t peer_id : peers) { // Ignore sender if (peer_id == from_peer) continue; |