server starting on port 0 on invalid settings

This commit is contained in:
Perttu Ahola 2010-12-22 17:58:02 +02:00
parent 3de176cc58
commit 58ccc68c81
6 changed files with 35 additions and 10 deletions

View File

@ -42,6 +42,7 @@
#height_base = linear 0 0 0 #height_base = linear 0 0 0
#plants_amount = 1.0 #plants_amount = 1.0
#ravines_amount = 1.0 #ravines_amount = 1.0
#coal_amount = 1.0
# Set to true to enable creative mode (unlimited inventory) # Set to true to enable creative mode (unlimited inventory)
#creative_mode = false #creative_mode = false

View File

@ -46,6 +46,8 @@ void set_default_settings()
g_settings.setDefault("height_base", "linear 0 0 0"); g_settings.setDefault("height_base", "linear 0 0 0");
g_settings.setDefault("plants_amount", "1.0"); g_settings.setDefault("plants_amount", "1.0");
g_settings.setDefault("ravines_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("objectdata_interval", "0.2");
g_settings.setDefault("active_object_range", "2"); g_settings.setDefault("active_object_range", "2");
g_settings.setDefault("max_simultaneous_block_sends_per_client", "1"); g_settings.setDefault("max_simultaneous_block_sends_per_client", "1");

View File

@ -1950,6 +1950,10 @@ MapBlock * ServerMap::emergeBlock(
if(some_part_underground) if(some_part_underground)
{ {
s16 underground_level = (lowest_ground_y/MAP_BLOCKSIZE - block_y)+1; s16 underground_level = (lowest_ground_y/MAP_BLOCKSIZE - block_y)+1;
/*
Add meseblocks
*/
for(s16 i=0; i<underground_level*1; i++) for(s16 i=0; i<underground_level*1; i++)
{ {
if(rand()%2 == 0) 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( v3s16 cp(
(rand()%(MAP_BLOCKSIZE-2))+1, (rand()%(MAP_BLOCKSIZE-2))+1,
@ -2157,22 +2168,26 @@ MapBlock * ServerMap::emergeBlock(
<<std::endl;*/ <<std::endl;*/
{ {
v3s16 p2 = p + v3s16(x,y,z-2); 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); sector->setNode(p2, n);
} }
{ {
v3s16 p2 = p + v3s16(x,y,z-1); 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); sector->setNode(p2, n2);
} }
{ {
v3s16 p2 = p + v3s16(x,y,z+0); 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); sector->setNode(p2, n2);
} }
{ {
v3s16 p2 = p + v3s16(x,y,z+1); 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); sector->setNode(p2, n);
} }

View File

@ -158,10 +158,17 @@ inline bool is_ground_content(u8 m)
m == CONTENT_GRASS || m == CONTENT_GRASS ||
m == CONTENT_GRASS_FOOTSTEPS || m == CONTENT_GRASS_FOOTSTEPS ||
m == CONTENT_MESE || 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) /*inline bool content_has_faces(u8 c)
{ {
return (m != CONTENT_IGNORE return (m != CONTENT_IGNORE

View File

@ -927,7 +927,7 @@ Server::Server(
m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this), m_con(PROTOCOL_ID, 512, CONNECTION_TIMEOUT, this),
m_thread(this), m_thread(this),
m_emergethread(this), m_emergethread(this),
m_time_of_day(12000), m_time_of_day(8000),
m_time_counter(0), m_time_counter(0),
m_time_of_day_send_timer(0) m_time_of_day_send_timer(0)
{ {

View File

@ -277,11 +277,11 @@ int main(int argc, char *argv[])
// Port? // Port?
u16 port = 30000; u16 port = 30000;
if(cmd_args.exists("port")) if(cmd_args.exists("port") && cmd_args.getU16("port") != 0)
{ {
port = cmd_args.getU16("port"); 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"); port = g_settings.getU16("port");
} }