fully working i guess
authorPerttu Ahola <celeron55@gmail.com>
Fri, 11 Feb 2011 17:55:42 +0000 (19:55 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 11 Feb 2011 17:55:42 +0000 (19:55 +0200)
16 files changed:
minetest.conf.example
src/defaultsettings.cpp
src/main.cpp
src/main.h
src/map.cpp
src/map.h
src/mapblock.cpp
src/mapchunk.h
src/materials.cpp
src/mineral.cpp
src/mineral.h
src/servermain.cpp
src/socket.h
src/tile.h
src/utility.h
src/voxel.h

index 92fe68b5f8d95c69c60bd0f1d99fc3c77a5b7e91..264d77e5a36d10db198db42e7daa23a253442344 100644 (file)
@@ -25,6 +25,7 @@
 #enable_fog = true
 #new_style_water = true
 #new_style_leaves = true
+#frametime_graph = false
 
 # Server side stuff
 
index e3ecf55f99aa2926d29aff840a8ec190084a4c23..de825ff0ad85f4aba6e701472b642a5ca8338ce3 100644 (file)
@@ -41,6 +41,7 @@ void set_default_settings()
        g_settings.setDefault("enable_fog", "true");
        g_settings.setDefault("new_style_water", "true");
        g_settings.setDefault("new_style_leaves", "true");
+       g_settings.setDefault("frametime_graph", "false");
        
        g_settings.setDefault("free_move", "false");
        g_settings.setDefault("continuous_forward", "false");
index 105acedf7284759bfed88300cdf84152742c3499..c37a35cdb82f7fc7ced47bce9eadd529a3c8927f 100644 (file)
@@ -267,15 +267,6 @@ Doing now (most important at the top):
 # maybe done\r
 * not done\r
 \r
-=== Immediate stuff\r
-* Combine meshes to bigger ones in ClientMap and set them EHM_STATIC\r
-\r
-=== Making it more portable\r
-* MinGW: Switch away from swprintf; mingw has a bad version of it.\r
-  Use snprintf + narrow_to_wide or (w)ostringstream\r
-* Some MSVC: std::sto* are defined without a namespace and collide\r
-  with the ones in utility.h\r
-\r
 === Stuff to do before release\r
 * Save the new mapgen stuff\r
   - map/meta.txt, which should contain only plain text, something like this:\r
@@ -291,7 +282,15 @@ Doing now (most important at the top):
 * only_from_disk might not work anymore - check and fix it.\r
 * Check the fixmes in the list above\r
 \r
+=== Making it more portable\r
+* MinGW: Switch away from swprintf; mingw has a bad version of it.\r
+  Use snprintf + narrow_to_wide or (w)ostringstream\r
+* Some MSVC: std::sto* are defined without a namespace and collide\r
+  with the ones in utility.h\r
+\r
 === Stuff to do after release\r
+* Move digging property stuff from material.{h,cpp} to mapnode.cpp...\r
+  - Or maybe move content_features to material.{h,cpp}?\r
 * Add some kind of erosion and other stuff that now is possible\r
 * Make client to fetch stuff asynchronously\r
   - Needs method SyncProcessData\r
@@ -308,6 +307,7 @@ Doing now (most important at the top):
   is generated. Fix it.\r
 * Make a small history check to transformLiquids to detect and log\r
   continuous oscillations, in such detail that they can be fixed.\r
+* Combine meshes to bigger ones in ClientMap and set them EHM_STATIC\r
 \r
 ======================================================================\r
 \r
@@ -381,7 +381,7 @@ Doing now (most important at the top):
 IrrlichtWrapper *g_irrlicht = NULL;\r
 \r
 // This makes textures\r
-TextureSource *g_texturesource = NULL;\r
+ITextureSource *g_texturesource = NULL;\r
 \r
 MapDrawControl draw_control;\r
 \r
@@ -1659,7 +1659,8 @@ int main(int argc, char *argv[])
        \r
        g_device = device;\r
        g_irrlicht = new IrrlichtWrapper(device);\r
-       g_texturesource = new TextureSource(device);\r
+       TextureSource *texturesource = new TextureSource(device);\r
+       g_texturesource = texturesource;\r
 \r
        /*\r
                Speed tests (done after irrlicht is loaded to get timer)\r
@@ -1722,7 +1723,7 @@ int main(int argc, char *argv[])
 \r
        init_content_inventory_texture_paths();\r
        init_mapnode(); // Second call with g_texturesource set\r
-       init_mineral(g_irrlicht);\r
+       init_mineral();\r
 \r
        /*\r
                GUI stuff\r
@@ -2084,7 +2085,7 @@ int main(int argc, char *argv[])
                /*\r
                        Process TextureSource's queue\r
                */\r
-               g_texturesource->processQueue();\r
+               texturesource->processQueue();\r
 \r
                /*\r
                        Random calculations\r
@@ -3006,6 +3007,7 @@ int main(int argc, char *argv[])
                /*\r
                        Frametime log\r
                */\r
+               if(g_settings.getBool("frametime_graph") == true)\r
                {\r
                        s32 x = 10;\r
                        for(core::list<float>::Iterator\r
index 9978c537a39281023f158686ca403c17fada5b31..b951ab5b04440c6453d9f8f82a66567778c5d9e8 100644 (file)
@@ -32,7 +32,7 @@ extern IrrlichtWrapper *g_irrlicht;
 
 // This makes and maps textures
 #include "tile.h"
-extern TextureSource *g_texturesource;
+extern ITextureSource *g_texturesource;
 
 // Debug streams
 
index e4992618d7ecda391476c5583ea48fa76bfcfa3c..ba958d148f00ec665cc5a8b3d05d8ae2d1f8d257 100644 (file)
@@ -1741,10 +1741,10 @@ ServerMap::ServerMap(std::string savedir):
        //m_chunksize = 2;
        
        // TODO: Save to and load from a file
-       m_seed = (((u64)myrand()<<0)%0x7fff)
-                       + (((u64)myrand()<<16)%0x7fff)
-                       + (((u64)myrand()<<32)%0x7fff)
-                       + (((u64)myrand()<<48)%0x7fff);
+       m_seed = (((u64)(myrand()%0xffff)<<0)
+                       + ((u64)(myrand()%0xffff)<<16)
+                       + ((u64)(myrand()%0xffff)<<32)
+                       + ((u64)(myrand()%0xffff)<<48));
 
        /*
                Experimental and debug stuff
@@ -1774,16 +1774,24 @@ ServerMap::ServerMap(std::string savedir):
                        }
                        else
                        {
-                               // Load master heightmap
-                               loadMasterHeightmap();
+                               // Load map metadata (seed, chunksize)
+                               loadMapMeta();
                                
-                               // Load sector (0,0) and throw and exception on fail
+                               // Load chunk metadata
+                               loadChunkMeta();
+                       
+                               /*// Load sector (0,0) and throw and exception on fail
                                if(loadSectorFull(v2s16(0,0)) == false)
-                                       throw LoadError("Failed to load sector (0,0)");
+                                       throw LoadError("Failed to load sector (0,0)");*/
 
-                               dstream<<DTIME<<"Server: Successfully loaded master "
-                                               "heightmap and sector (0,0) from "<<savedir<<
+                               /*dstream<<DTIME<<"Server: Successfully loaded chunk "
+                                               "metadata and sector (0,0) from "<<savedir<<
                                                ", assuming valid save directory."
+                                               <<std::endl;*/
+
+                               dstream<<DTIME<<"INFO: Server: Successfully loaded map "
+                                               <<"and chunk metadata from "<<savedir
+                                               <<", assuming valid save directory."
                                                <<std::endl;
 
                                m_map_saving_enabled = true;
@@ -1798,13 +1806,13 @@ ServerMap::ServerMap(std::string savedir):
        }
        catch(std::exception &e)
        {
-               dstream<<DTIME<<"Server: Failed to load map from "<<savedir
+               dstream<<DTIME<<"WARNING: Server: Failed to load map from "<<savedir
                                <<", exception: "<<e.what()<<std::endl;
-               dstream<<DTIME<<"Please remove the map or fix it."<<std::endl;
-               dstream<<DTIME<<"WARNING: Map saving will be disabled."<<std::endl;
+               dstream<<"Please remove the map or fix it."<<std::endl;
+               dstream<<"WARNING: Map saving will be disabled."<<std::endl;
        }
 
-       dstream<<DTIME<<"Initializing new map."<<std::endl;
+       dstream<<DTIME<<"INFO: Initializing new map."<<std::endl;
        
        // Create zero sector
        emergeSector(v2s16(0,0));
@@ -2062,6 +2070,8 @@ double base_rock_level_2d(u64 seed, v2s16 p)
        return h;
 }
 
+#define VMANIP_FLAG_DUNGEON VOXELFLAG_CHECKED1
+
 /*
        This is the main map generation method
 */
@@ -2195,6 +2205,9 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                vmanip.initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
        }
 
+       // Clear all flags
+       vmanip.clearFlag(0xff);
+
        TimeTaker timer_generate("generateChunkRaw() generate");
 
        // Maximum height of the stone surface and obstacles.
@@ -2414,7 +2427,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
        /*
                Make dungeons
        */
-       u32 dungeons_count = relative_volume / 600000;
+       u32 dungeons_count = relative_volume / 400000;
        u32 bruises_count = relative_volume * stone_surface_max_y / 40000000;
        if(stone_surface_max_y < WATER_LEVEL)
                bruises_count = 0;
@@ -2424,7 +2437,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
        {
                s16 min_tunnel_diameter = 2;
                s16 max_tunnel_diameter = 6;
-               u16 tunnel_routepoints = 15;
+               u16 tunnel_routepoints = 25;
                
                bool bruise_surface = (jj < bruises_count);
 
@@ -2464,14 +2477,14 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                of -= v3s16(1,0,1) * more;
                
                s16 route_y_min = 0;
-               //s16 route_y_max = ar.Y-1;
-               s16 route_y_max = -of.Y + stone_surface_max_y + max_tunnel_diameter/2;
-               // If dungeons
+               // Allow half a diameter + 7 over stone surface
+               s16 route_y_max = -of.Y + stone_surface_max_y + max_tunnel_diameter/2 + 7;
+
+               /*// If dungeons, don't go through surface too often
                if(bruise_surface == false)
-               {
-                       // Don't go through surface too often
-                       route_y_max -= myrand_range(0, max_tunnel_diameter*2);
-               }
+                       route_y_max -= myrand_range(0, max_tunnel_diameter*2);*/
+
+               // Limit maximum to area
                route_y_max = rangelim(route_y_max, 0, ar.Y-1);
 
                if(bruise_surface)
@@ -2489,10 +2502,24 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                /*dstream<<"route_y_min = "<<route_y_min
                                <<", route_y_max = "<<route_y_max<<std::endl;*/
 
+               s16 route_start_y_min = route_y_min;
+               s16 route_start_y_max = route_y_max;
+
+               // Start every 2nd dungeon from surface
+               bool coming_from_surface = (jj % 2 == 0 && bruise_surface == false);
+
+               if(coming_from_surface)
+               {
+                       route_start_y_min = -of.Y + stone_surface_max_y + 5;
+               }
+               
+               route_start_y_min = rangelim(route_start_y_min, 0, ar.Y-1);
+               route_start_y_max = rangelim(route_start_y_max, 0, ar.Y-1);
+
                // Randomize starting position
                v3f orp(
                        (float)(myrand()%ar.X)+0.5,
-                       (float)(myrand_range(route_y_min, route_y_max))+0.5,
+                       (float)(myrand_range(route_start_y_min, route_start_y_max))+0.5,
                        (float)(myrand()%ar.Z)+0.5
                );
 
@@ -2509,18 +2536,35 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                        s16 max_d = max_tunnel_diameter;
                        s16 rs = myrand_range(min_d, max_d);
                        
-                       v3s16 maxlen(15, 5, 15);
-
+                       v3s16 maxlen;
                        if(bruise_surface)
                        {
                                maxlen = v3s16(rs*7,rs*7,rs*7);
                        }
+                       else
+                       {
+                               maxlen = v3s16(15, myrand_range(1, 20), 15);
+                       }
+
+                       v3f vec;
+                       
+                       if(coming_from_surface && j < 3)
+                       {
+                               vec = v3f(
+                                       (float)(myrand()%(maxlen.X*2))-(float)maxlen.X,
+                                       (float)(myrand()%(maxlen.Y*1))-(float)maxlen.Y,
+                                       (float)(myrand()%(maxlen.Z*2))-(float)maxlen.Z
+                               );
+                       }
+                       else
+                       {
+                               vec = v3f(
+                                       (float)(myrand()%(maxlen.X*2))-(float)maxlen.X,
+                                       (float)(myrand()%(maxlen.Y*2))-(float)maxlen.Y,
+                                       (float)(myrand()%(maxlen.Z*2))-(float)maxlen.Z
+                               );
+                       }
 
-                       v3f vec(
-                               (float)(myrand()%(maxlen.X*2))-(float)maxlen.X,
-                               (float)(myrand()%(maxlen.Y*2))-(float)maxlen.Y,
-                               (float)(myrand()%(maxlen.Z*2))-(float)maxlen.Z
-                       );
                        v3f rp = orp + vec;
                        if(rp.X < 0)
                                rp.X = 0;
@@ -2553,7 +2597,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                                //s16 si2 = rs - MYMAX(0, maxabsxz-rs/4);
                                                s16 si2 = rs - MYMAX(0, maxabsxz-rs/7);
                                                //s16 si2 = rs - abs(x0);
-                                               for(s16 y0=-si2+1+1; y0<=si2-1; y0++)
+                                               for(s16 y0=-si2+1+2; y0<=si2-1; y0++)
                                                {
                                                        s16 z = cp.Z + z0;
                                                        s16 y = cp.Y + y0;
@@ -2580,6 +2624,12 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                                        // water afterwards
                                                        u32 i = vmanip.m_area.index(p);
                                                        vmanip.m_data[i] = airnode;
+
+                                                       if(bruise_surface == false)
+                                                       {
+                                                               // Set tunnel flag
+                                                               vmanip.m_flags[i] |= VMANIP_FLAG_DUNGEON;
+                                                       }
                                                }
                                        }
                                }
@@ -3000,13 +3050,17 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                                        break;
                                }
                                
-                               n->d = CONTENT_WATERSOURCE;
-                               n->setLight(LIGHTBANK_DAY, light);
+                               // Make water only not in dungeons
+                               if(!(vmanip.m_flags[i]&VMANIP_FLAG_DUNGEON))
+                               {
+                                       n->d = CONTENT_WATERSOURCE;
+                                       //n->setLight(LIGHTBANK_DAY, light);
 
-                               // Add to transforming liquid queue (in case it'd
-                               // start flowing)
-                               v3s16 p = v3s16(p2d.X, y, p2d.Y);
-                               m_transforming_liquid.push_back(p);
+                                       // Add to transforming liquid queue (in case it'd
+                                       // start flowing)
+                                       v3s16 p = v3s16(p2d.X, y, p2d.Y);
+                                       m_transforming_liquid.push_back(p);
+                               }
                                
                                // Next one
                                vmanip.m_area.add_y(em, i, -1);
@@ -3519,6 +3573,7 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
                //TimeTaker timer("generateChunkRaw() blitBackAll");
                vmanip.blitBackAll(&changed_blocks);
        }
+
        /*
                Update day/night difference cache of the MapBlocks
        */
@@ -3553,14 +3608,22 @@ MapChunk* ServerMap::generateChunkRaw(v2s16 chunkpos,
        }
 
        /*
-               Set central chunk non-volatile and return it
+               Set central chunk non-volatile
        */
        MapChunk *chunk = getChunk(chunkpos);
        assert(chunk);
        // Set non-volatile
        //chunk->setIsVolatile(false);
        chunk->setGenLevel(GENERATED_FULLY);
-       // Return it
+       
+       /*
+               Save changed parts of map
+       */
+       save(true);
+
+       /*
+               Return central chunk (which was requested)
+       */
        return chunk;
 }
 
@@ -4543,7 +4606,8 @@ void ServerMap::save(bool only_changed)
                dstream<<DTIME<<"ServerMap: Saving whole map, this can take time."
                                <<std::endl;
        
-       saveMasterHeightmap();
+       saveMapMeta();
+       saveChunkMeta();
        
        u32 sector_meta_count = 0;
        u32 block_count = 0;
@@ -4601,8 +4665,9 @@ void ServerMap::loadAll()
 {
        DSTACK(__FUNCTION_NAME);
        dstream<<DTIME<<"ServerMap: Loading map..."<<std::endl;
-
-       loadMasterHeightmap();
+       
+       loadMapMeta();
+       loadChunkMeta();
 
        std::vector<fs::DirListNode> list = fs::GetDirListing(m_savedir+"/sectors/");
 
@@ -4657,6 +4722,7 @@ void ServerMap::loadAll()
        dstream<<DTIME<<"ServerMap: Map loaded."<<std::endl;
 }
 
+#if 0
 void ServerMap::saveMasterHeightmap()
 {
        DSTACK(__FUNCTION_NAME);
@@ -4685,6 +4751,163 @@ void ServerMap::loadMasterHeightmap()
        if(is.good() == false)
                throw FileNotGoodException("Cannot open master heightmap");*/
 }
+#endif
+
+void ServerMap::saveMapMeta()
+{
+       DSTACK(__FUNCTION_NAME);
+       
+       dstream<<"INFO: ServerMap::saveMapMeta(): "
+                       <<"seed="<<m_seed<<", chunksize="<<m_chunksize
+                       <<std::endl;
+
+       createDir(m_savedir);
+       
+       std::string fullpath = m_savedir + "/meta.txt";
+       std::ofstream os(fullpath.c_str(), std::ios_base::binary);
+       if(os.good() == false)
+       {
+               dstream<<"ERROR: ServerMap::saveMapMeta(): "
+                               <<"could not open"<<fullpath<<std::endl;
+               throw FileNotGoodException("Cannot open chunk metadata");
+       }
+       
+       Settings params;
+       params.setU64("seed", m_seed);
+       params.setS32("chunksize", m_chunksize);
+
+       params.writeLines(os);
+
+       os<<"[end_of_params]\n";
+       
+}
+
+void ServerMap::loadMapMeta()
+{
+       DSTACK(__FUNCTION_NAME);
+       
+       dstream<<"INFO: ServerMap::loadMapMeta(): Loading chunk metadata"
+                       <<std::endl;
+
+       std::string fullpath = m_savedir + "/meta.txt";
+       std::ifstream is(fullpath.c_str(), std::ios_base::binary);
+       if(is.good() == false)
+       {
+               dstream<<"ERROR: ServerMap::loadMapMeta(): "
+                               <<"could not open"<<fullpath<<std::endl;
+               throw FileNotGoodException("Cannot open chunk metadata");
+       }
+
+       Settings params;
+
+       for(;;)
+       {
+               if(is.eof())
+                       throw SerializationError
+                                       ("ServerMap::loadMapMeta(): [end_of_params] not found");
+               std::string line;
+               std::getline(is, line);
+               std::string trimmedline = trim(line);
+               if(trimmedline == "[end_of_params]")
+                       break;
+               params.parseConfigLine(line);
+       }
+
+       m_seed = params.getU64("seed");
+       m_chunksize = params.getS32("chunksize");
+
+       dstream<<"INFO: ServerMap::loadMapMeta(): "
+                       <<"seed="<<m_seed<<", chunksize="<<m_chunksize
+                       <<std::endl;
+}
+
+void ServerMap::saveChunkMeta()
+{
+       DSTACK(__FUNCTION_NAME);
+       
+       u32 count = m_chunks.size();
+
+       dstream<<"INFO: ServerMap::saveChunkMeta(): Saving metadata of "
+                       <<count<<" chunks"<<std::endl;
+
+       createDir(m_savedir);
+       
+       std::string fullpath = m_savedir + "/chunk_meta";
+       std::ofstream os(fullpath.c_str(), std::ios_base::binary);
+       if(os.good() == false)
+       {
+               dstream<<"ERROR: ServerMap::saveChunkMeta(): "
+                               <<"could not open"<<fullpath<<std::endl;
+               throw FileNotGoodException("Cannot open chunk metadata");
+       }
+       
+       u8 version = 0;
+       
+       // Write version
+       os.write((char*)&version, 1);
+
+       u8 buf[4];
+       
+       // Write count
+       writeU32(buf, count);
+       os.write((char*)buf, 4);
+       
+       for(core::map<v2s16, MapChunk*>::Iterator
+                       i = m_chunks.getIterator();
+                       i.atEnd()==false; i++)
+       {
+               v2s16 p = i.getNode()->getKey();
+               MapChunk *chunk = i.getNode()->getValue();
+               // Write position
+               writeV2S16(buf, p);
+               os.write((char*)buf, 4);
+               // Write chunk data
+               chunk->serialize(os, version);
+       }
+}
+
+void ServerMap::loadChunkMeta()
+{
+       DSTACK(__FUNCTION_NAME);
+       
+       dstream<<"INFO: ServerMap::loadChunkMeta(): Loading chunk metadata"
+                       <<std::endl;
+
+       std::string fullpath = m_savedir + "/chunk_meta";
+       std::ifstream is(fullpath.c_str(), std::ios_base::binary);
+       if(is.good() == false)
+       {
+               dstream<<"ERROR: ServerMap::loadChunkMeta(): "
+                               <<"could not open"<<fullpath<<std::endl;
+               throw FileNotGoodException("Cannot open chunk metadata");
+       }
+
+       u8 version = 0;
+       
+       // Read version
+       is.read((char*)&version, 1);
+
+       u8 buf[4];
+       
+       // Read count
+       is.read((char*)buf, 4);
+       u32 count = readU32(buf);
+
+       dstream<<"INFO: ServerMap::loadChunkMeta(): Loading metadata of "
+                       <<count<<" chunks"<<std::endl;
+       
+       for(u32 i=0; i<count; i++)
+       {
+               v2s16 p;
+               MapChunk *chunk = new MapChunk();
+               // Read position
+               is.read((char*)buf, 4);
+               p = readV2S16(buf);
+               // Read chunk data
+               chunk->deSerialize(is, version);
+               m_chunks.insert(p, chunk);
+       }
+}
 
 void ServerMap::saveSectorMeta(ServerMapSector *sector)
 {
index d18278834469385795bd09839f80c1c1990cc98a..fb05558245a2b9f2c220db80c69f2033e5d3008e 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -475,18 +475,13 @@ public:
        void save(bool only_changed);
        void loadAll();
        
-       // TODO
+       // Saves map seed and possibly other stuff
        void saveMapMeta();
        void loadMapMeta();
        
-       // TODO
        void saveChunkMeta();
        void loadChunkMeta();
        
-       // DEPRECATED
-       void saveMasterHeightmap();
-       void loadMasterHeightmap();
-
        // The sector mutex should be locked when calling most of these
        
        // This only saves sector-specific data such as the heightmap
index e0b8965b43cacc5ac4d748149b2423e0354e8a16..bff366addc2e4bee975b40d39b1feecdd0ced727 100644 (file)
@@ -148,25 +148,6 @@ u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
                v3s16 face_dir)
 {
        try{
-               // DEBUG
-               /*{
-                       if(n.d == CONTENT_WATER)
-                       {
-                               u8 l = n.param2*2;
-                               if(l > LIGHT_MAX)
-                                       l = LIGHT_MAX;
-                               return l;
-                       }
-                       if(n2.d == CONTENT_WATER)
-                       {
-                               u8 l = n2.param2*2;
-                               if(l > LIGHT_MAX)
-                                       l = LIGHT_MAX;
-                               return l;
-                       }
-               }*/
-
-
                u8 light;
                u8 l1 = n.getLightBlend(daynight_ratio);
                u8 l2 = n2.getLightBlend(daynight_ratio);
@@ -177,11 +158,13 @@ u8 MapBlock::getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
 
                // Make some nice difference to different sides
 
+               // This makes light come from a corner
                /*if(face_dir.X == 1 || face_dir.Z == 1 || face_dir.Y == -1)
                        light = diminish_light(diminish_light(light));
                else if(face_dir.X == -1 || face_dir.Z == -1)
                        light = diminish_light(light);*/
-
+               
+               // All neighboring faces have different shade (like in minecraft)
                if(face_dir.X == 1 || face_dir.X == -1 || face_dir.Y == -1)
                        light = diminish_light(diminish_light(light));
                else if(face_dir.Z == 1 || face_dir.Z == -1)
@@ -791,7 +774,7 @@ void MapBlock::updateMesh(u32 daynight_ratio)
        // Flowing water material
        video::SMaterial material_water1;
        material_water1.setFlag(video::EMF_LIGHTING, false);
-       material_water1.setFlag(video::EMF_BACK_FACE_CULLING, false);
+       //material_water1.setFlag(video::EMF_BACK_FACE_CULLING, false);
        material_water1.setFlag(video::EMF_BILINEAR_FILTER, false);
        material_water1.setFlag(video::EMF_FOG_ENABLE, true);
        material_water1.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
@@ -1040,9 +1023,9 @@ void MapBlock::updateMesh(u32 daynight_ratio)
                                        video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,1),
                                        video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
                                        video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),*/
-                                       video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c,
+                                       video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
                                                        pa_water1.x0(), pa_water1.y1()),
-                                       video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c,
+                                       video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
                                                        pa_water1.x1(), pa_water1.y1()),
                                        video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
                                                        pa_water1.x1(), pa_water1.y0()),
@@ -1118,21 +1101,25 @@ void MapBlock::updateMesh(u32 daynight_ratio)
                                        video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c, 1,1),
                                        video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
                                        video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),*/
-                                       video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c,
+                                       video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
                                                        pa_water1.x0(), pa_water1.y1()),
-                                       video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c,
-                                                       pa_water1.x1(), pa_water1.y1()),
                                        video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
+                                                       pa_water1.x1(), pa_water1.y1()),
+                                       video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c,
                                                        pa_water1.x1(), pa_water1.y0()),
-                                       video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
+                                       video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c,
                                                        pa_water1.x0(), pa_water1.y0()),
                                };
+                               
+                               // This fixes a strange bug
+                               s32 corner_resolve[4] = {3,2,1,0};
 
                                for(s32 i=0; i<4; i++)
                                {
                                        //vertices[i].Pos.Y += water_level;
                                        //vertices[i].Pos.Y += neighbor_levels[v3s16(0,0,0)];
-                                       vertices[i].Pos.Y += corner_levels[i];
+                                       s32 j = corner_resolve[i];
+                                       vertices[i].Pos.Y += corner_levels[j];
                                        vertices[i].Pos += intToFloat(p + getPosRelative());
                                }
 
index 1f89b38a7de4f6c1332b159463323d6a923d68bb..1819fa13ed380eeb909cdcba254774ee02151e63 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        some MapSectors. (something like 16x16)
 */
 
+// These should fit in 8 bits, as they are saved as such.
 enum{
        GENERATED_FULLY = 0,
        GENERATED_PARTLY = 10,
@@ -35,21 +36,10 @@ class MapChunk
 {
 public:
        MapChunk():
-               //m_is_volatile(true)
                m_generation_level(GENERATED_NOT)
        {
        }
 
-       /*
-               If is_volatile is true, chunk can be modified when
-               neighboring chunks are generated.
-
-               It is set to false when all the 8 neighboring chunks have
-               been generated.
-       */
-       /*bool getIsVolatile(){ return m_is_volatile; }
-       void setIsVolatile(bool is){ m_is_volatile = is; }*/
-       
        /*
                Generation level. Possible values:
                GENERATED_FULLY = 0 = fully generated
@@ -59,9 +49,17 @@ public:
        u16 getGenLevel(){ return m_generation_level; }
        void setGenLevel(u16 lev){ m_generation_level = lev; }
 
+       void serialize(std::ostream &os, u8 version)
+       {
+               os.write((char*)&m_generation_level, 1);
+       }
+       void deSerialize(std::istream &is, u8 version)
+       {
+               is.read((char*)&m_generation_level, 1);
+       }
+
 private:
-       //bool m_is_volatile;
-       u16 m_generation_level;
+       u8 m_generation_level;
 };
 
 #endif
index 00d212c6339ece76d085e07aafbbf23b335a0256..f56b024b2e3dd7cb32935371d7b989138101e90d 100644 (file)
@@ -58,7 +58,7 @@ void initializeMaterialProperties()
                        DiggingProperties(true, 1.0, 0));
        
        g_material_properties[CONTENT_SAND].setDiggingProperties("",
-                       DiggingProperties(true, 0.5, 0));
+                       DiggingProperties(true, 0.4, 0));
        
        /*
                Add MesePick to everything
index 905f6497cc1465c22f80b1d197f441f257125c30..e61c25c1ec75091773f18e48774ff3d0904f02a5 100644 (file)
@@ -30,14 +30,12 @@ const char *mineral_filenames[MINERAL_COUNT] =
 //textureid_t mineral_textures[MINERAL_COUNT] = {0};
 std::string mineral_textures[MINERAL_COUNT];
 
-void init_mineral(IIrrlichtWrapper *irrlicht)
+void init_mineral()
 {
        for(u32 i=0; i<MINERAL_COUNT; i++)
        {
                if(mineral_filenames[i] == NULL)
                        continue;
-               //mineral_textures[i] = irrlicht->getTextureId(mineral_filenames[i]);
-               //mineral_textures[i] = 0;
                mineral_textures[i] = mineral_filenames[i];
        }
 }
index a181b89de8255cdf00f21bfa82c05eec6700a443..fcc1bd123d5ed0f427d2a8276b74bf186911f93a 100644 (file)
@@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "inventory.h"
 #include "texture.h"
-#include "iirrlichtwrapper.h"
 
 /*
        Minerals
@@ -32,7 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 // Caches textures
-void init_mineral(IIrrlichtWrapper *irrlicht);
+void init_mineral();
 
 #define MINERAL_NONE 0
 #define MINERAL_COAL 1
index 7ec397ace526f955c6189bba03dd8e8c2913a041..1c301d4f59af8dce1cd79d76a38c5e53aecb8798 100644 (file)
@@ -79,6 +79,9 @@ Settings g_settings;
 
 extern void set_default_settings();
 
+// A dummy thing
+ITextureSource *g_texturesource = NULL;
+
 /*
        Debug streams
 */
@@ -259,9 +262,8 @@ int main(int argc, char *argv[])
 
        // Initialize stuff
        
-       IIrrlichtWrapper irrlicht; // Dummy
-       init_mapnode(&irrlicht);
-       init_mineral(&irrlicht);
+       init_mapnode();
+       init_mineral();
 
        /*
                Check parameters
index 10bcdefee825c2a96a08fd4841318d38680e6c53..6b7a2462ee61ce2d696843978b99a9edf175968c 100644 (file)
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
        #include <winsock2.h>
        #include <ws2tcpip.h>
        #ifdef _MSC_VER
-               #pragma comment(lib, "wsock32.lib")
+               #pragma comment(lib, "ws2_32.lib")
        #endif
 typedef SOCKET socket_t;
 typedef int socklen_t;
index 2a342313d4ea13110e40a92f8ca8aaaa3c0e905d..1e339806f6c9493e9042687c0bce5c1df08a05f6 100644 (file)
@@ -103,10 +103,28 @@ struct SourceAtlasPointer
        }
 };
 
+/*
+       Implementation (to be used as a no-op on the server)
+*/
+class ITextureSource
+{
+public:
+       ITextureSource(){}
+       virtual ~ITextureSource(){}
+       virtual u32 getTextureId(const std::string &name){return 0;}
+       virtual u32 getTextureIdDirect(const std::string &name){return 0;}
+       virtual std::string getTextureName(u32 id){return "";}
+       virtual AtlasPointer getTexture(u32 id){return AtlasPointer(0);}
+       virtual AtlasPointer getTexture(const std::string &name)
+               {return AtlasPointer(0);}
+       virtual video::ITexture* getTextureRaw(const std::string &name)
+               {return NULL;}
+};
+
 /*
        Creates and caches textures.
 */
-class TextureSource
+class TextureSource : public ITextureSource
 {
 public:
        TextureSource(IrrlichtDevice *device);
index deaa78d90a7bb8735c8b295358f18b617896d113..9e47a5dacbdecbb3083138724392e39838c3d39a 100644 (file)
@@ -1201,6 +1201,15 @@ public:
                return value;
        }
 
+       u64 getU64(std::string name)
+       {
+               u64 value = 0;
+               std::string s = get(name);
+               std::istringstream ss(s);
+               ss>>value;
+               return value;
+       }
+
        void setS32(std::string name, s32 value)
        {
                set(name, itos(value));
@@ -1218,6 +1227,13 @@ public:
                set(name, os.str());
        }
 
+       void setU64(std::string name, u64 value)
+       {
+               std::ostringstream os;
+               os<<value;
+               set(name, os.str());
+       }
+
        void clear()
        {
                m_settings.clear();
index 0cffb16b58e83cb174ca4ea8d2d2fbf04269e5f3..c5aa48006e643693f158af47d12b1653fd0f18db 100644 (file)
@@ -314,16 +314,12 @@ public:
 // Checked as being inexistent in source
 #define VOXELFLAG_INEXISTENT (1<<1)
 // Algorithm-dependent
-// flowWater: "visited"
-#define VOXELFLAG_CHECKED (1<<2)
+#define VOXELFLAG_CHECKED1 (1<<2)
 // Algorithm-dependent
-// getWaterPressure: "visited"
 #define VOXELFLAG_CHECKED2 (1<<3)
 // Algorithm-dependent
-// spreadWaterPressure: "visited"
 #define VOXELFLAG_CHECKED3 (1<<4)
 // Algorithm-dependent
-// water: "pressure check route node"
 #define VOXELFLAG_CHECKED4 (1<<5)
 
 enum VoxelPrintMode