server starting on port 0 on invalid settings
authorPerttu Ahola <celeron55@gmail.com>
Wed, 22 Dec 2010 15:58:02 +0000 (17:58 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Wed, 22 Dec 2010 15:58:02 +0000 (17:58 +0200)
minetest.conf.example
src/defaultsettings.cpp
src/map.cpp
src/mapnode.h
src/server.cpp
src/servermain.cpp

index 3e9f49b0e236060cb724913c02e8818201c2f582..30716cf7decaecb129c739db6e7f6fd15dea38fc 100644 (file)
@@ -42,6 +42,7 @@
 #height_base = linear 0 0 0
 #plants_amount = 1.0
 #ravines_amount = 1.0
+#coal_amount = 1.0
 
 # Set to true to enable creative mode (unlimited inventory)
 #creative_mode = false
index 065ff2e44fbce83471cc836dfb5f5f25d2f89e0e..0b8d9e9240a376d4d05cb8eb459a26673c0abf27 100644 (file)
@@ -46,6 +46,8 @@ void set_default_settings()
        g_settings.setDefault("height_base", "linear 0 0 0");
        g_settings.setDefault("plants_amount", "1.0");
        g_settings.setDefault("ravines_amount", "1.0");
+       g_settings.setDefault("coal_amount", "1.0");
+
        g_settings.setDefault("objectdata_interval", "0.2");
        g_settings.setDefault("active_object_range", "2");
        g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");
index 700312fb236bf87429c024d57f5e2b94c38481a6..acaf8436a3deea78edf8aea16ab4366aac606577 100644 (file)
@@ -1950,6 +1950,10 @@ MapBlock * ServerMap::emergeBlock(
        if(some_part_underground)
        {
                s16 underground_level = (lowest_ground_y/MAP_BLOCKSIZE - block_y)+1;
+
+               /*
+                       Add meseblocks
+               */
                for(s16 i=0; i<underground_level*1; i++)
                {
                        if(rand()%2 == 0)
@@ -1978,9 +1982,16 @@ MapBlock * ServerMap::emergeBlock(
                        }
                }
 
-               if(rand()%3 == 0)
+               /*
+                       Add coal
+               */
+               u16 coal_amount = 30.0 * g_settings.getFloat("coal_amount");
+               u16 coal_rareness = 60 / coal_amount;
+               if(coal_rareness == 0)
+                       coal_rareness = 1;
+               if(rand()%coal_rareness == 0)
                {
-                       for(s16 i=0; i<20; i++)
+                       for(s16 i=0; i<coal_amount; i++)
                        {
                                v3s16 cp(
                                        (rand()%(MAP_BLOCKSIZE-2))+1,
@@ -2157,22 +2168,26 @@ MapBlock * ServerMap::emergeBlock(
                                                                <<std::endl;*/
                                                {
                                                        v3s16 p2 = p + v3s16(x,y,z-2);
-                                                       if(is_ground_content(sector->getNode(p2).d))
+                                                       if(is_ground_content(sector->getNode(p2).d)
+                                                                       && !is_mineral(sector->getNode(p2).d))
                                                                sector->setNode(p2, n);
                                                }
                                                {
                                                        v3s16 p2 = p + v3s16(x,y,z-1);
-                                                       if(is_ground_content(sector->getNode(p2).d))
+                                                       if(is_ground_content(sector->getNode(p2).d)
+                                                                       && !is_mineral(sector->getNode(p2).d))
                                                                sector->setNode(p2, n2);
                                                }
                                                {
                                                        v3s16 p2 = p + v3s16(x,y,z+0);
-                                                       if(is_ground_content(sector->getNode(p2).d))
+                                                       if(is_ground_content(sector->getNode(p2).d)
+                                                                       && !is_mineral(sector->getNode(p2).d))
                                                                sector->setNode(p2, n2);
                                                }
                                                {
                                                        v3s16 p2 = p + v3s16(x,y,z+1);
-                                                       if(is_ground_content(sector->getNode(p2).d))
+                                                       if(is_ground_content(sector->getNode(p2).d)
+                                                                       && !is_mineral(sector->getNode(p2).d))
                                                                sector->setNode(p2, n);
                                                }
 
index 20634bf7673a3ab605d81002b4de212af5145d0a..ad85d88e848a3af0dc9fdf50489425f08c1213c7 100644 (file)
@@ -158,10 +158,17 @@ inline bool is_ground_content(u8 m)
                m == CONTENT_GRASS ||
                m == CONTENT_GRASS_FOOTSTEPS ||
                m == CONTENT_MESE ||
-               m == CONTENT_MUD
+               m == CONTENT_MUD ||
+               m == CONTENT_COALSTONE
        );
 }
 
+inline bool is_mineral(u8 c)
+{
+       return(c == CONTENT_MESE
+               || c == CONTENT_COALSTONE);
+}
+
 /*inline bool content_has_faces(u8 c)
 {
        return (m != CONTENT_IGNORE
index ddef11ae457177385e080b12be6b210628ce2783..f99aefb882d62b05e2eab6a8787738b7d0b12745 100644 (file)
@@ -927,7 +927,7 @@ Server::Server(
        m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
        m_thread(this),
        m_emergethread(this),
-       m_time_of_day(12000),
+       m_time_of_day(8000),
        m_time_counter(0),
        m_time_of_day_send_timer(0)
 {
index 0c2faa7ec9285546401d636a3037a96111ab6095..24d3b24e8f8d99f788ad0771f09c4ff99f546805 100644 (file)
@@ -277,11 +277,11 @@ int main(int argc, char *argv[])
        
        // Port?
        u16 port = 30000;
-       if(cmd_args.exists("port"))
+       if(cmd_args.exists("port") && cmd_args.getU16("port") != 0)
        {
                port = cmd_args.getU16("port");
        }
-       else if(g_settings.exists("port"))
+       else if(g_settings.exists("port") && g_settings.getU16("port") != 0)
        {
                port = g_settings.getU16("port");
        }