m_clients(&m_con),
m_shutdown_requested(false),
m_ignore_map_edit_events(false),
- m_ignore_map_edit_events_peer_id(0)
+ m_ignore_map_edit_events_peer_id(0),
+ m_next_sound_id(0)
{
m_liquid_transform_timer = 0.0;
// Lock environment
JMutexAutoLock envlock(m_env_mutex);
+ // Load mapgen params from Settings
+ m_emerge->loadMapgenParams();
+
+ // Create the Map (loads map_meta.txt, overriding configured mapgen params)
+ ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
+
// Initialize scripting
infostream<<"Server: Initializing Lua"<<std::endl;
std::string scriptpath = getBuiltinLuaPath() + DIR_DELIM "init.lua";
- if (!m_script->loadScript(scriptpath)) {
+ if (!m_script->loadScript(scriptpath))
throw ModError("Failed to load and run " + scriptpath);
- }
-
// Print 'em
infostream<<"Server: Loading mods: ";
// Apply item aliases in the node definition manager
m_nodedef->updateAliases(m_itemdef);
- // Perform pending node name resolutions
- m_nodedef->getResolver()->resolveNodes();
+ m_nodedef->setNodeRegistrationStatus(true);
- // Load the mapgen params from global settings now after any
- // initial overrides have been set by the mods
- m_emerge->loadMapgenParams();
+ // Perform pending node name resolutions
+ m_nodedef->runNodeResolverCallbacks();
// Initialize Environment
- ServerMap *servermap = new ServerMap(path_world, this, m_emerge);
m_env = new ServerEnvironment(servermap, m_script, this, m_path_world);
m_clients.setEnv(m_env);
- // Run some callbacks after the MG params have been set up but before activation
- m_script->environment_OnMapgenInit(&m_emerge->params);
-
// Initialize mapgens
m_emerge->initMapgens();
void Server::start(Address bind_addr)
{
DSTACK(__FUNCTION_NAME);
+
+ m_bind_addr = bind_addr;
+
infostream<<"Starting server on "
<< bind_addr.serializeString() <<"..."<<std::endl;
m_env->step(dtime);
}
- const float map_timer_and_unload_dtime = 2.92;
+ static const float map_timer_and_unload_dtime = 2.92;
if(m_map_timer_and_unload_interval.step(dtime, map_timer_and_unload_dtime))
{
JMutexAutoLock lock(m_env_mutex);
/*
Set the modified blocks unsent for all the clients
*/
- if(modified_blocks.size() > 0)
+ if(!modified_blocks.empty())
{
SetBlocksNotSent(modified_blocks);
}
g_settings->getBool("server_announce"))
{
ServerList::sendAnnounce(counter ? "update" : "start",
+ m_bind_addr.getPort(),
m_clients.getPlayerNames(),
m_uptime.get(),
m_env->getGameTime(),
client->m_known_objects, added_objects);
// Ignore if nothing happened
- if(removed_objects.size() == 0 && added_objects.size() == 0)
+ if(removed_objects.empty() && added_objects.empty())
{
//infostream<<"active objects: none changed"<<std::endl;
continue;
/*
Set blocks not sent to far players
*/
- if(far_players.size() > 0)
+ if(!far_players.empty())
{
// Convert list format to that wanted by SetBlocksNotSent
std::map<v3s16, MapBlock*> modified_blocks2;
u8 client_max = data[2];
u8 our_max = SER_FMT_VER_HIGHEST_READ;
// Use the highest version supported by both
- u8 deployed = std::min(client_max, our_max);
+ int deployed = std::min(client_max, our_max);
// If it's lower than the lowest supported, give up.
if(deployed < SER_FMT_VER_LOWEST)
deployed = SER_FMT_VER_INVALID;
<<"tried to connect from "<<addr_s<<" "
<<"but it was disallowed for the following reason: "
<<reason<<std::endl;
- DenyAccess(peer_id, narrow_to_wide(reason.c_str()));
+ DenyAccess(peer_id, narrow_to_wide(reason));
return;
}
}
}
} // action == 4
-
+
/*
Catch invalid actions
continue;
ServerPlayingSound &psound = i->second;
psound.clients.erase(peer_id);
- if(psound.clients.size() == 0)
+ if(psound.clients.empty())
m_playing_sounds.erase(i++);
}
}
dst_clients.push_back(*i);
}
}
- if(dst_clients.size() == 0)
+ if(dst_clients.empty())
return -1;
// Create the sound
{
ServerPlayingSound &psound = i->second;
psound.clients.erase(peer_id);
- if(psound.clients.size() == 0)
+ if(psound.clients.empty())
m_playing_sounds.erase(i++);
else
i++;
name = narrow_to_wide(player->getName());
// Add name to information string
if(!first)
- os<<L",";
+ os<<L", ";
else
first = false;
os<<name;
u32 Server::hudAdd(Player *player, HudElement *form) {
if (!player)
return -1;
-
+
u32 id = player->addHud(form);
SendHUDAdd(player->peer_id, id, form);
if (!todel)
return false;
-
+
delete todel;
SendHUDRemove(player->peer_id, id);
SendHUDSetFlags(player->peer_id, flags, mask);
player->hud_flags = flags;
-
+
PlayerSAO* playersao = player->getPlayerSAO();
-
+
if (playersao == NULL)
return false;
{
infostream<<"Dedicated server quitting"<<std::endl;
#if USE_CURL
- if(g_settings->getBool("server_announce") == true)
- ServerList::sendAnnounce("delete");
+ if(g_settings->getBool("server_announce"))
+ ServerList::sendAnnounce("delete", server.m_bind_addr.getPort());
#endif
break;
}