if (!string_allowed(lbm_def->name, LBM_NAME_ALLOWED_CHARS)) {
throw ModError("Error adding LBM \"" + lbm_def->name +
"\": Does not follow naming conventions: "
- "Only chararacters [a-z0-9_:] are allowed.");
+ "Only characters [a-z0-9_:] are allowed.");
}
m_lbm_defs[lbm_def->name] = lbm_def;
// If the player exists, ensure that they respawn inside legal bounds
// This fixes an assert crash when the player can't be added
// to the environment
- if (objectpos_over_limit(playersao->getBasePosition())) {
+ ServerMap &map = getServerMap();
+ if (map.getMapgenParams()->saoPosOverLimit(playersao->getBasePosition())) {
actionstream << "Respawn position for player \""
<< player->getName() << "\" outside limits, resetting" << std::endl;
playersao->setBasePosition(m_server->findSpawnPos());
chance = 1;
ActiveABM aabm;
aabm.abm = abm;
- if(abm->getSimpleCatchUp()) {
+ if (abm->getSimpleCatchUp()) {
float intervals = actual_interval / trigger_interval;
if(intervals == 0)
continue;
} else {
aabm.chance = chance;
}
+
// Trigger neighbors
- std::set<std::string> required_neighbors_s
- = abm->getRequiredNeighbors();
- for(std::set<std::string>::iterator
- i = required_neighbors_s.begin();
- i != required_neighbors_s.end(); ++i)
- {
- ndef->getIds(*i, aabm.required_neighbors);
+ const std::set<std::string> &required_neighbors_s =
+ abm->getRequiredNeighbors();
+ for (std::set<std::string>::iterator rn = required_neighbors_s.begin();
+ rn != required_neighbors_s.end(); ++rn) {
+ ndef->getIds(*rn, aabm.required_neighbors);
}
+
// Trigger contents
- std::set<std::string> contents_s = abm->getTriggerContents();
- for(std::set<std::string>::iterator
- i = contents_s.begin(); i != contents_s.end(); ++i)
- {
+ const std::set<std::string> &contents_s = abm->getTriggerContents();
+ for (std::set<std::string>::iterator cs = contents_s.begin();
+ cs != contents_s.end(); ++cs) {
std::set<content_t> ids;
- ndef->getIds(*i, ids);
- for(std::set<content_t>::const_iterator k = ids.begin();
- k != ids.end(); ++k)
- {
+ ndef->getIds(*cs, ids);
+ for (std::set<content_t>::const_iterator k = ids.begin();
+ k != ids.end(); ++k) {
content_t c = *k;
if (c >= m_aabms.size())
m_aabms.resize(c + 256, NULL);
return true;
}
-void ServerEnvironment::getObjectsInsideRadius(std::vector<u16> &objects, v3f pos, float radius)
+void ServerEnvironment::getObjectsInsideRadius(std::vector<u16> &objects, v3f pos,
+ float radius)
{
- for (ActiveObjectMap::iterator i = m_active_objects.begin();
+ for (ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
u16 id = i->first;
infostream << "ServerEnvironment::clearObjects(): "
<< "Removing all active objects" << std::endl;
std::vector<u16> objects_to_remove;
- for (ActiveObjectMap::iterator i = m_active_objects.begin();
+ for (ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER)
// Update this one
// NOTE: This is kind of funny on a singleplayer game, but doesn't
// really matter that much.
- static const float server_step = g_settings->getFloat("dedicated_server_step");
+ static thread_local const float server_step =
+ g_settings->getFloat("dedicated_server_step");
m_recommended_send_interval = server_step;
/*
/*
Update list of active blocks, collecting changes
*/
- static const s16 active_block_range = g_settings->getS16("active_block_range");
+ static thread_local const s16 active_block_range =
+ g_settings->getS16("active_block_range");
std::set<v3s16> blocks_removed;
std::set<v3s16> blocks_added;
m_active_blocks.update(players_blockpos, active_block_range,
send_recommended = true;
}
- for(ActiveObjectMap::iterator i = m_active_objects.begin();
+ for (ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
// Don't step if is to be removed or stored statically
Manage particle spawner expiration
*/
if (m_particle_management_interval.step(dtime, 1.0)) {
- for (UNORDERED_MAP<u32, float>::iterator i = m_particle_spawners.begin();
+ for (std::unordered_map<u32, float>::iterator i = m_particle_spawners.begin();
i != m_particle_spawners.end(); ) {
//non expiring spawners
if (i->second == PARTICLE_SPAWNER_NO_EXPIRY) {
u32 id = 0;
for (;;) { // look for unused particlespawner id
id++;
- UNORDERED_MAP<u32, float>::iterator f = m_particle_spawners.find(id);
+ std::unordered_map<u32, float>::iterator f = m_particle_spawners.find(id);
if (f == m_particle_spawners.end()) {
m_particle_spawners[id] = time;
break;
void ServerEnvironment::deleteParticleSpawner(u32 id, bool remove_from_object)
{
m_particle_spawners.erase(id);
- UNORDERED_MAP<u32, u16>::iterator it = m_particle_spawner_attachments.find(id);
+ std::unordered_map<u32, u16>::iterator it = m_particle_spawner_attachments.find(id);
if (it != m_particle_spawner_attachments.end()) {
u16 obj_id = (*it).second;
ServerActiveObject *sao = getActiveObject(obj_id);
ServerActiveObject* ServerEnvironment::getActiveObject(u16 id)
{
- ActiveObjectMap::iterator n = m_active_objects.find(id);
+ ServerActiveObjectMap::const_iterator n = m_active_objects.find(id);
return (n != m_active_objects.end() ? n->second : NULL);
}
-bool isFreeServerActiveObjectId(u16 id, ActiveObjectMap &objects)
+bool isFreeServerActiveObjectId(u16 id, ServerActiveObjectMap &objects)
{
if (id == 0)
return false;
return objects.find(id) == objects.end();
}
-u16 getFreeServerActiveObjectId(ActiveObjectMap &objects)
+u16 getFreeServerActiveObjectId(ServerActiveObjectMap &objects)
{
//try to reuse id's as late as possible
static u16 last_used_id = 0;
- discard objects that are found in current_objects.
- add remaining objects to added_objects
*/
- for (ActiveObjectMap::iterator i = m_active_objects.begin();
+ for (ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
u16 id = i->first;
so_it = block->m_static_objects.m_active.begin();
so_it != block->m_static_objects.m_active.end(); ++so_it) {
// Get the ServerActiveObject counterpart to this StaticObject
- ActiveObjectMap::iterator ao_it = m_active_objects.find(so_it->first);
+ ServerActiveObjectMap::const_iterator ao_it = m_active_objects.find(so_it->first);
if (ao_it == m_active_objects.end()) {
// If this ever happens, there must be some kind of nasty bug.
errorstream << "ServerEnvironment::setStaticForObjectsInBlock(): "
void ServerEnvironment::removeRemovedObjects()
{
std::vector<u16> objects_to_remove;
- for(ActiveObjectMap::iterator i = m_active_objects.begin();
+ for(ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
u16 id = i->first;
ServerActiveObject* obj = i->second;
void ServerEnvironment::deactivateFarObjects(bool _force_delete)
{
std::vector<u16> objects_to_remove;
- for(ActiveObjectMap::iterator i = m_active_objects.begin();
+ for (ServerActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
// force_delete might be overriden per object
bool force_delete = _force_delete;