]> git.lizzy.rs Git - minetest.git/blobdiff - src/server.cpp
Remove ClientMap::m_camera_mutex
[minetest.git] / src / server.cpp
index 6cb79c8754b77eab96613ad983aa2147fde8b358..572533146555d9d923b17aed3e52297634978773 100644 (file)
@@ -585,21 +585,7 @@ void Server::AsyncRunStep(bool initial_step)
                        MutexAutoLock lock(m_env_mutex);
                        while (!m_admin_chat->command_queue.empty()) {
                                ChatEvent *evt = m_admin_chat->command_queue.pop_frontNoEx();
-                               if (evt->type == CET_NICK_ADD) {
-                                       // The terminal informed us of its nick choice
-                                       m_admin_nick = ((ChatEventNick *)evt)->nick;
-                                       if (!m_script->getAuth(m_admin_nick, NULL, NULL)) {
-                                               errorstream << "You haven't set up an account." << std::endl
-                                                       << "Please log in using the client as '"
-                                                       << m_admin_nick << "' with a secure password." << std::endl
-                                                       << "Until then, you can't execute admin tasks via the console," << std::endl
-                                                       << "and everybody can claim the user account instead of you," << std::endl
-                                                       << "giving them full control over this server." << std::endl;
-                                       }
-                               } else {
-                                       assert(evt->type == CET_CHAT);
-                                       handleAdminChat((ChatEventChat *)evt);
-                               }
+                               handleChatInterfaceEvent(evt);
                                delete evt;
                        }
                }
@@ -1473,7 +1459,7 @@ void Server::printToConsoleOnly(const std::string &text)
                m_admin_chat->outgoing_queue.push_back(
                        new ChatEventChat("", utf8_to_wide(text)));
        } else {
-               std::cout << text;
+               std::cout << text << std::endl;
        }
 }
 
@@ -2749,8 +2735,28 @@ void Server::UpdateCrafting(Player* player)
        plist->changeItem(0, preview);
 }
 
+void Server::handleChatInterfaceEvent(ChatEvent *evt)
+{
+       if (evt->type == CET_NICK_ADD) {
+               // The terminal informed us of its nick choice
+               m_admin_nick = ((ChatEventNick *)evt)->nick;
+               if (!m_script->getAuth(m_admin_nick, NULL, NULL)) {
+                       errorstream << "You haven't set up an account." << std::endl
+                               << "Please log in using the client as '"
+                               << m_admin_nick << "' with a secure password." << std::endl
+                               << "Until then, you can't execute admin tasks via the console," << std::endl
+                               << "and everybody can claim the user account instead of you," << std::endl
+                               << "giving them full control over this server." << std::endl;
+               }
+       } else {
+               assert(evt->type == CET_CHAT);
+               handleAdminChat((ChatEventChat *)evt);
+       }
+}
+
 std::wstring Server::handleChat(const std::string &name, const std::wstring &wname,
-       const std::wstring &wmessage, u16 peer_id_to_avoid_sending)
+       const std::wstring &wmessage, bool check_shout_priv,
+       u16 peer_id_to_avoid_sending)
 {
        // If something goes wrong, this player is to blame
        RollbackScopeActor rollback_scope(m_rollback,
@@ -2778,10 +2784,15 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
                else
                        line += L"-!- Invalid command: " + str_split(wcmd, L' ')[0];
        } else {
-               line += L"<";
-               line += wname;
-               line += L"> ";
-               line += wmessage;
+               if (check_shout_priv && !checkPriv(name, "shout")) {
+                       line += L"-!- You don't have permission to shout.";
+                       broadcast_line = false;
+               } else {
+                       line += L"<";
+                       line += wname;
+                       line += L"> ";
+                       line += wmessage;
+               }
        }
 
        /*
@@ -3023,7 +3034,8 @@ bool Server::hudSetFlags(Player *player, u32 flags, u32 mask)
                return false;
 
        SendHUDSetFlags(player->peer_id, flags, mask);
-       player->hud_flags = flags;
+       player->hud_flags &= ~mask;
+       player->hud_flags |= flags;
 
        PlayerSAO* playersao = player->getPlayerSAO();
 
@@ -3371,26 +3383,24 @@ v3f Server::findSpawnPos()
                return nodeposf * BS;
        }
 
-       s16 water_level = map.getWaterLevel();
-       s16 vertical_spawn_range = g_settings->getS16("vertical_spawn_range");
        bool is_good = false;
 
        // Try to find a good place a few times
-       for(s32 i = 0; i < 1000 && !is_good; i++) {
+       for(s32 i = 0; i < 4000 && !is_good; i++) {
                s32 range = 1 + i;
                // We're going to try to throw the player to this position
                v2s16 nodepos2d = v2s16(
                                -range + (myrand() % (range * 2)),
                                -range + (myrand() % (range * 2)));
 
-               // Get ground height at point
-               s16 groundheight = map.findGroundLevel(nodepos2d);
-               // Don't go underwater or to high places
-               if (groundheight <= water_level ||
-                               groundheight > water_level + vertical_spawn_range)
+               // Get spawn level at point
+               s16 spawn_level = m_emerge->getSpawnLevelAtPoint(nodepos2d);
+               // Continue if MAX_MAP_GENERATION_LIMIT was returned by
+               // the mapgen to signify an unsuitable spawn position
+               if (spawn_level == MAX_MAP_GENERATION_LIMIT)
                        continue;
 
-               v3s16 nodepos(nodepos2d.X, groundheight, nodepos2d.Y);
+               v3s16 nodepos(nodepos2d.X, spawn_level, nodepos2d.Y);
 
                s32 air_count = 0;
                for (s32 i = 0; i < 10; i++) {