]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/server.cpp
commit before some more radical changes
[dragonfireclient.git] / src / server.cpp
index 9171c79668e46acdf4d89158f5ca83931e6ae54f..b3ce9c13aeeef720b876219bf11227d0516b75dd 100644 (file)
@@ -232,16 +232,18 @@ void * EmergeThread::Thread()
                        */
                        
                        if(lighting_invalidated_blocks.size() > 0)
-                               dstream<<"lighting "<<lighting_invalidated_blocks.size()
-                                               <<" blocks"<<std::endl;
-                       
-                       // 50-100ms for single block generation
-                       //TimeTaker timer("** EmergeThread updateLighting");
-                       
-                       // Update lighting without locking the environment mutex,
-                       // add modified blocks to changed blocks
-                       map.updateLighting(lighting_invalidated_blocks, modified_blocks);
+                       {
+                               /*dstream<<"lighting "<<lighting_invalidated_blocks.size()
+                                               <<" blocks"<<std::endl;*/
                        
+                               // 50-100ms for single block generation
+                               //TimeTaker timer("** EmergeThread updateLighting");
+                               
+                               // Update lighting without locking the environment mutex,
+                               // add modified blocks to changed blocks
+                               map.updateLighting(lighting_invalidated_blocks, modified_blocks);
+                       }
+                               
                        // Add all from changed_blocks to modified_blocks
                        for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator();
                                        i.atEnd() == false; i++)
@@ -542,6 +544,11 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
                                        block_is_invalid = true;
                                }
                                
+                               /*if(block->isFullyGenerated() == false)
+                               {
+                                       block_is_invalid = true;
+                               }*/
+                               
                                v2s16 p2d(p.X, p.Z);
                                ServerMap *map = (ServerMap*)(&server->m_env.getMap());
                                v2s16 chunkpos = map->sector_to_chunk(p2d);
@@ -1710,7 +1717,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
                writeU16(&reply[0], TOCLIENT_INIT);
                writeU8(&reply[2], deployed);
                writeV3S16(&reply[2+1], floatToInt(player->getPosition()+v3f(0,BS/2,0), BS));
-               writeU64(&reply[2+1+6], m_env.getServerMap().getSeed());
+               //writeU64(&reply[2+1+6], m_env.getServerMap().getSeed());
+               
                // Send as reliable
                m_con.Send(peer_id, 0, reply, true);
 
@@ -3319,6 +3327,36 @@ void setCreativeInventory(Player *player)
        /*
                Give materials
        */
+       
+       // CONTENT_IGNORE-terminated list
+       u8 material_items[] = {
+               CONTENT_TORCH,
+               CONTENT_MUD,
+               CONTENT_STONE,
+               CONTENT_SAND,
+               CONTENT_TREE,
+               CONTENT_LEAVES,
+               CONTENT_MESE,
+               CONTENT_WATERSOURCE,
+               CONTENT_CLOUD,
+               CONTENT_FURNACE,
+               CONTENT_SIGN_WALL,
+               CONTENT_IGNORE
+       };
+       
+       u8 *mip = material_items;
+       for(u16 i=0; i<PLAYER_INVENTORY_SIZE; i++)
+       {
+               if(*mip == CONTENT_IGNORE)
+                       break;
+
+               InventoryItem *item = new MaterialItem(*mip, 1);
+               player->inventory.addItem("main", item);
+
+               mip++;
+       }
+
+#if 0
        assert(USEFUL_CONTENT_COUNT <= PLAYER_INVENTORY_SIZE);
        
        // add torch first
@@ -3336,6 +3374,8 @@ void setCreativeInventory(Player *player)
                InventoryItem *item = new MaterialItem(i, 1);
                player->inventory.addItem("main", item);
        }
+#endif
+
        // Sign
        {
                InventoryItem *item = new MapBlockObjectItem("Sign Example text");
@@ -3411,26 +3451,16 @@ Player *Server::emergePlayer(const char *name, const char *password,
                s16 groundheight = 0;
 #if 1
                // Try to find a good place a few times
-               for(s32 i=0; i<500; i++)
+               for(s32 i=0; i<1000; i++)
                {
                        s32 range = 1 + i;
                        // We're going to try to throw the player to this position
                        nodepos = v2s16(-range + (myrand()%(range*2)),
                                        -range + (myrand()%(range*2)));
                        v2s16 sectorpos = getNodeSectorPos(nodepos);
-                       /*
-                               Ignore position if it is near a chunk edge.
-                               Otherwise it would cause excessive loading time at
-                               initial generation
-                       */
-                       {
-                               if(m_env.getServerMap().sector_to_chunk(sectorpos+v2s16(1,1))
-                               != m_env.getServerMap().sector_to_chunk(sectorpos+v2s16(-1,-1)))
-                                       continue;
-                       }
-                       // Get sector
-                       m_env.getMap().emergeSector(sectorpos);
-                       // Get ground height at point
+                       // Get sector (NOTE: Don't get because it's slow)
+                       //m_env.getMap().emergeSector(sectorpos);
+                       // Get ground height at point (fallbacks to heightmap function)
                        groundheight = m_env.getServerMap().findGroundLevel(nodepos);
                        // Don't go underwater
                        if(groundheight < WATER_LEVEL)
@@ -3438,7 +3468,15 @@ Player *Server::emergePlayer(const char *name, const char *password,
                                //dstream<<"-> Underwater"<<std::endl;
                                continue;
                        }
-#if 0 // Doesn't work, generating blocks is a bit too complicated for doing here
+                       // Don't go to high places
+                       if(groundheight > WATER_LEVEL + 4)
+                       {
+                               //dstream<<"-> Underwater"<<std::endl;
+                               continue;
+                       }
+
+#if 0
+// Doesn't work, generating blocks is a bit too complicated for doing here
                        // Get block at point
                        v3s16 nodepos3d;
                        nodepos3d = v3s16(nodepos.X, groundheight+1, nodepos.Y);
@@ -3464,6 +3502,7 @@ Player *Server::emergePlayer(const char *name, const char *password,
                                continue;
                        }
 #endif
+
                        // Found a good place
                        dstream<<"Searched through "<<i<<" places."<<std::endl;
                        break;
@@ -3476,7 +3515,7 @@ Player *Server::emergePlayer(const char *name, const char *password,
 
                player->setPosition(intToFloat(v3s16(
                                nodepos.X,
-                               groundheight + 1,
+                               groundheight + 5, // Accomodate mud
                                nodepos.Y
                ), BS));
 #endif