Commented out debug statements again
[oweals/minetest.git] / src / server.cpp
index 5b657bc2efe8c51853798ad840c5fca7ccdd9895..fd93d7523b22f872fdbf8f2b9106c403a6382b21 100644 (file)
@@ -584,7 +584,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
                                Don't generate or send if not in sight
                        */
 
-                       if(isBlockInSight(p, camera_pos, camera_dir, 10000*BS) == false)
+                       if(isBlockInSight(p, camera_pos, camera_dir, M_PI, 10000*BS) == false)
                        {
                                continue;
                        }
@@ -774,6 +774,7 @@ void RemoteClient::SendObjectData(
                u16 command
                u16 number of player positions
                for each player:
+                       u16 peer_id
                        v3s32 position*100
                        v3s32 speed*100
                        s32 pitch*100
@@ -1252,6 +1253,20 @@ void Server::AsyncRunStep()
                m_uptime.set(m_uptime.get() + dtime);
        }
        
+       {
+               // Process connection's timeouts
+               JMutexAutoLock lock2(m_con_mutex);
+               ScopeProfiler sp(&g_profiler, "Server: connection timeout processing");
+               m_con.RunTimeouts(dtime);
+       }
+       
+       {
+               // This has to be called so that the client list gets synced
+               // with the peer list of the connection
+               ScopeProfiler sp(&g_profiler, "Server: peer change handling");
+               handlePeerChanges();
+       }
+
        /*
                Update m_time_of_day and overall game time
        */
@@ -1294,20 +1309,6 @@ void Server::AsyncRunStep()
                }
        }
 
-       {
-               // Process connection's timeouts
-               JMutexAutoLock lock2(m_con_mutex);
-               ScopeProfiler sp(&g_profiler, "Server: connection timeout processing");
-               m_con.RunTimeouts(dtime);
-       }
-       
-       {
-               // This has to be called so that the client list gets synced
-               // with the peer list of the connection
-               ScopeProfiler sp(&g_profiler, "Server: peer change handling");
-               handlePeerChanges();
-       }
-
        {
                JMutexAutoLock lock(m_env_mutex);
                // Step environment
@@ -2445,7 +2446,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                        if(g_settings.getBool("creative_mode") == false)
                                        {
                                                // Skip if inventory has no free space
-                                               if(ilist->getUsedSlots() == ilist->getSize())
+                                               if(ilist->roomForItem(item) == false)
                                                {
                                                        dout_server<<"Player inventory has no free space"<<std::endl;
                                                        return;
@@ -2922,6 +2923,18 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                        return;
                                }
 
+                               /*
+                                       If in creative mode, item dropping is disabled unless
+                                       player has build privileges
+                               */
+                               if(g_settings.getBool("creative_mode") &&
+                                       (getPlayerPrivs(player) & PRIV_BUILD) == 0)
+                               {
+                                       derr_server<<"Not allowing player to drop item: "
+                                                       "creative mode and no build privs"<<std::endl;
+                                       return;
+                               }
+
                                dout_server<<"Placing a miscellaneous item on map"
                                                <<std::endl;
                                
@@ -3185,6 +3198,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                                mlist->addItem(item1);
                                        }
                                }
+                               // Disallow moving items if not allowed to build
+                               else if((getPlayerPrivs(player) & PRIV_BUILD) == 0)
+                                       return;
                        }
                        
                        if(disable_action == false)
@@ -3245,13 +3261,13 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                u64 privs = getPlayerPrivs(player);
 
                // Parse commands
-               std::wstring commandprefix = L"/#";
-               if(message.substr(0, commandprefix.size()) == commandprefix)
+               if(message[0] == L'/')
                {
-                       line += L"Server: ";
+                       size_t strip_size = 1;
+                       if (message[1] == L'#') // support old-style commans
+                               ++strip_size;
+                       message = message.substr(strip_size);
 
-                       message = message.substr(commandprefix.size());
-                       
                        WStrfnd f1(message);
                        f1.next(L" "); // Skip over /#whatever
                        std::wstring paramstring = f1.next(L"");
@@ -3264,9 +3280,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                                player,
                                privs);
 
-                       line += processServerCommand(ctx);
-                       send_to_sender = ctx->flags & 1;
-                       send_to_others = ctx->flags & 2;
+                       std::wstring reply(processServerCommand(ctx));
+                       send_to_sender = ctx->flags & SEND_TO_SENDER;
+                       send_to_others = ctx->flags & SEND_TO_OTHERS;
+
+                       if (ctx->flags & SEND_NO_PREFIX)
+                               line += reply;
+                       else
+                               line += L"Server: " + reply;
+
                        delete ctx;
 
                }