X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fserver.cpp;h=2139df957388a8b05740cdaf4440374541fdf9ec;hb=81385682c8c1da90f2366452b10e20a93c0865fb;hp=69f655e6acd7b244a2bc4a7cdd62dca0f8d96281;hpb=c89d1cf072f4ac34cfb35eadd8c9890b3de1b922;p=minetest.git diff --git a/src/server.cpp b/src/server.cpp index 69f655e6a..2139df957 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -48,6 +48,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "sha1.h" #include "base64.h" #include "tool.h" +#include "utility_string.h" #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" @@ -108,6 +109,10 @@ void * ServerThread::Thread() { infostream<<"Server: PeerNotFoundException"<setAsyncFatalError(e.what()); + } } END_DEBUG_EXCEPTION_HANDLER(errorstream) @@ -824,32 +829,21 @@ void PlayerInfo::PrintLine(std::ostream *s) (*s)< &l) -{ - core::list::Iterator i; - u32 checksum = 1; - u32 a = 10; - for(i=l.begin(); i!=l.end(); i++) - { - checksum += a * (i->id+1); - checksum ^= 0x435aafcd; - a *= 10; - } - return checksum; -} - /* Server */ Server::Server( - std::string path_world, - std::string path_config, - std::string gamename + const std::string &path_world, + const std::string &path_config, + const SubgameSpec &gamespec, + bool simple_singleplayer_mode ): - m_gamename(gamename), m_path_world(path_world), m_path_config(path_config), + m_gamespec(gamespec), + m_simple_singleplayer_mode(simple_singleplayer_mode), + m_async_fatal_error(""), m_env(NULL), m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this), m_authmanager(path_world+DIR_DELIM+"auth.txt"), @@ -867,11 +861,6 @@ Server::Server( m_ignore_map_edit_events(false), m_ignore_map_edit_events_peer_id(0) { - infostream<<"Server created."<::const_iterator i = m_gamespec.addon_paths.begin(); + i != m_gamespec.addon_paths.end(); i++) + infostream<<"- addons: "<<(*i)<::const_iterator i = m_path_addons.begin(); - i != m_path_addons.end(); i++){ + for(std::set::const_iterator i = m_gamespec.addon_paths.begin(); + i != m_gamespec.addon_paths.end(); i++) m_modspaths.push_front((*i) + DIR_DELIM + "mods"); - } - + // Print out mod search paths - infostream<<"- mod search paths:"<::Iterator i = m_modspaths.begin(); i != m_modspaths.end(); i++){ std::string modspath = *i; - infostream<<" "<::Iterator i = m_mods.begin(); + i != m_mods.end(); i++){ + const ModSpec &mod = *i; + infostream<::Iterator i = m_mods.begin(); i != m_mods.end(); i++){ const ModSpec &mod = *i; - infostream<<"Server: Loading mod \""<__| \\___ >____ > |__| "<peer_id, 0, reply, true); - infostream<<"Server: Sent object remove/add: " + verbosestream<<"Server: Sent object remove/add: " <= 4) disable_single_change_sending = true; - bool got_any_events = false; + int event_count = m_unsent_map_edit_queue.size(); // We'll log the amount of each Profiler prof; while(m_unsent_map_edit_queue.size() != 0) { - got_any_events = true; - MapEditEvent* event = m_unsent_map_edit_queue.pop_front(); // Players far away from the change are stored here. @@ -1772,10 +1806,12 @@ void Server::AsyncRunStep() break;*/ } - if(got_any_events) - { + if(event_count >= 5){ infostream<<"Server: MapEditEvents:"<serialization_version; @@ -1916,7 +1954,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(datasize < 2+1+PLAYERNAME_SIZE) return; - infostream<<"Server: Got TOSERVER_INIT from " + verbosestream<<"Server: Got TOSERVER_INIT from " < 1){ + infostream<<"Server: Not allowing another client to connect in" + <<" simple singleplayer mode"<get("name")) { + actionstream<<"Server: "<getPlayer(peer_id); - if(player != NULL) - name = narrow_to_wide(player->getName()); + // Send information about server to player in chat + SendChatMessage(peer_id, getStatusString()); - std::wstring message; - message += L"*** "; - message += name; - message += L" joined game"; - BroadcastChatMessage(message); + // Send information about joining in chat + { + std::wstring name = L"unknown"; + Player *player = m_env->getPlayer(peer_id); + if(player != NULL) + name = narrow_to_wide(player->getName()); + + std::wstring message; + message += L"*** "; + message += name; + message += L" joined game"; + BroadcastChatMessage(message); + } } // Warnings about protocol version can be issued here @@ -2374,7 +2443,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) { // Strip command and create a stream std::string datastring((char*)&data[2], datasize-2); - infostream<<"TOSERVER_INVENTORY_ACTION: data="< tosend; - u16 numtextures = readU16(is); - for(int i = 0; i < numtextures; i++) { + infostream<<"Sending "<getName() + verbosestream<<"TOSERVER_INTERACT: "<getName() <<" tried to interact, but is dead!"<getActiveObject(pointed.object_id); if(pointed_object == NULL) { - infostream<<"TOSERVER_INTERACT: " + verbosestream<<"TOSERVER_INTERACT: " "pointed object is NULL"<getName()<<" punches object " - <getDescription()<getWieldedItem(); ToolCapabilities toolcap = @@ -3016,7 +3088,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) return; actionstream<getName()<<" right-clicks object " - <getDescription()<rightClick(srp); @@ -3223,7 +3296,7 @@ core::list Server::getPlayerInfo() void Server::peerAdded(con::Peer *peer) { DSTACK(__FUNCTION_NAME); - infostream<<"Server::peerAdded(): peer->id=" + verbosestream<<"Server::peerAdded(): peer->id=" <id<id=" + verbosestream<<"Server::deletingPeer(): peer->id=" <id<<", timeout="<::Iterator i = m_mods.begin(); - i != m_mods.end(); i++){ - const ModSpec &mod = *i; - std::string texturepath = mod.path + DIR_DELIM + "textures"; - std::vector dirlist = fs::GetDirListing(texturepath); - for(u32 j=0; j dirlist = fs::GetDirListing(texturepath); + for(u32 j=0; jm_Textures[tname] = TextureInformation(tpath,digest_string); - infostream<<"Server::PrepareTextures(): added sha1 for "<< tname <m_Textures[tname] = TextureInformation(tpath,digest_string); + verbosestream<<"Server: sha1 for "< texture_announcements; @@ -3866,7 +3941,6 @@ void Server::SendTextureAnnouncement(u16 peer_id){ // Make data buffer std::string s = os.str(); - infostream<<"Server::SendTextureAnnouncement(): Send to client"< data((u8*)s.c_str(), s.size()); // Send as reliable @@ -3891,7 +3965,8 @@ struct SendableTexture void Server::SendTexturesRequested(u16 peer_id,core::list tosend) { DSTACK(__FUNCTION_NAME); - infostream<<"Server::SendTexturesRequested(): Sending textures to client"< tosend // Make data buffer std::string s = os.str(); - infostream<<"Server::SendTexturesRequested(): bunch "<get("name")) + return PRIV_ALL; + return getPlayerAuthPrivs(name); +} + void Server::setPlayerPassword(const std::string &name, const std::wstring &password) { // Add player to auth manager @@ -4481,7 +4591,7 @@ void Server::handlePeerChanges() { PeerChange c = m_peer_change_queue.pop_front(); - infostream<<"Server: Handling peer change: " + verbosestream<<"Server: Handling peer change: " <<"id="<clear(); } } - - /* - Player info - */ - static int counter = 0; - counter--; - if(counter <= 0) - { - counter = 10; - - core::list list = server.getPlayerInfo(); - core::list::Iterator i; - static u32 sum_old = 0; - u32 sum = PIChecksum(list); - if(sum != sum_old) - { - infostream<PrintLine(&infostream); - } - } - sum_old = sum; - } } }