forked from oerkki/voxelands
just some tweaks to the last commit
This commit is contained in:
parent
ef5a26cc31
commit
5a6e6d5fd8
|
@ -861,6 +861,14 @@ void ServerEnvironment::step(float dtime)
|
||||||
if (block == NULL)
|
if (block == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
std::list<u16> new_list;
|
||||||
|
for (std::list<u16>::iterator oi = block->m_active_objects.begin(); oi != block->m_active_objects.end(); oi++) {
|
||||||
|
ServerActiveObject *obj = getActiveObject(*oi);
|
||||||
|
if (obj && obj->m_static_exists && obj->m_static_block == block->getPos())
|
||||||
|
new_list.push_back(*oi);
|
||||||
|
}
|
||||||
|
block->m_active_objects.swap(new_list);
|
||||||
|
|
||||||
// Reset block usage timer
|
// Reset block usage timer
|
||||||
if (circuitstep || metastep)
|
if (circuitstep || metastep)
|
||||||
block->resetUsageTimer();
|
block->resetUsageTimer();
|
||||||
|
@ -3479,11 +3487,11 @@ void ServerEnvironment::removeRemovedObjects()
|
||||||
for (std::map<u16, ServerActiveObject*>::iterator i = m_active_objects.begin(); i != m_active_objects.end(); ++i) {
|
for (std::map<u16, ServerActiveObject*>::iterator i = m_active_objects.begin(); i != m_active_objects.end(); ++i) {
|
||||||
u16 id = i->first;
|
u16 id = i->first;
|
||||||
ServerActiveObject* obj = i->second;
|
ServerActiveObject* obj = i->second;
|
||||||
// This shouldn't happen but check it
|
// this shouldn't happen but check it
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
infostream<<"NULL object found in ServerEnvironment"
|
infostream<<"NULL object found in ServerEnvironment"
|
||||||
<<" while finding removed objects. id="<<id<<std::endl;
|
<<" while finding removed objects. id="<<id<<std::endl;
|
||||||
// Id to be removed from m_active_objects
|
// id to be removed from m_active_objects
|
||||||
objects_to_remove.push_back(id);
|
objects_to_remove.push_back(id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3497,13 +3505,14 @@ void ServerEnvironment::removeRemovedObjects()
|
||||||
if (obj->m_static_exists) {
|
if (obj->m_static_exists) {
|
||||||
MapBlock *block = m_map->emergeBlock(obj->m_static_block, false);
|
MapBlock *block = m_map->emergeBlock(obj->m_static_block, false);
|
||||||
if (block) {
|
if (block) {
|
||||||
obj->m_static_exists = false;
|
bool keep = false;
|
||||||
for (std::list<u16>::iterator oi = block->m_active_objects.begin(); oi != block->m_active_objects.end(); oi++) {
|
for (std::list<u16>::iterator oi = block->m_active_objects.begin(); oi != block->m_active_objects.end(); oi++) {
|
||||||
if (*oi == id) {
|
if (*oi == id) {
|
||||||
obj->m_static_exists = true;
|
keep = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
obj->m_static_exists = keep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!obj->m_static_exists) {
|
if (!obj->m_static_exists) {
|
||||||
|
@ -3516,8 +3525,10 @@ void ServerEnvironment::removeRemovedObjects()
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (obj->m_known_by_count > 0)
|
if (obj->m_known_by_count > 0) {
|
||||||
|
obj->m_pending_deactivation = true;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Delete static data from block if is marked as removed
|
Delete static data from block if is marked as removed
|
||||||
|
@ -3590,8 +3601,7 @@ void ServerEnvironment::activateObjects(MapBlock *block)
|
||||||
<<"activating objects of block "<<PP(block->getPos())
|
<<"activating objects of block "<<PP(block->getPos())
|
||||||
<<" ("<<block->m_static_objects.m_objects.size()
|
<<" ("<<block->m_static_objects.m_objects.size()
|
||||||
<<" objects)"<<std::endl;
|
<<" objects)"<<std::endl;
|
||||||
bool large_amount = (block->m_static_objects.m_objects.size() > 49);
|
if (block->m_static_objects.m_objects.size() > 49) {
|
||||||
if (large_amount) {
|
|
||||||
errorstream<<"suspiciously large amount of objects detected: "
|
errorstream<<"suspiciously large amount of objects detected: "
|
||||||
<<block->m_static_objects.m_objects.size()<<" in "
|
<<block->m_static_objects.m_objects.size()<<" in "
|
||||||
<<PP(block->getPos())
|
<<PP(block->getPos())
|
||||||
|
@ -3605,8 +3615,6 @@ void ServerEnvironment::activateObjects(MapBlock *block)
|
||||||
// Activate stored objects
|
// Activate stored objects
|
||||||
std::list<StaticObject> new_stored;
|
std::list<StaticObject> new_stored;
|
||||||
for (std::list<StaticObject>::iterator i = block->m_static_objects.m_objects.begin(); i != block->m_static_objects.m_objects.end(); i++) {
|
for (std::list<StaticObject>::iterator i = block->m_static_objects.m_objects.begin(); i != block->m_static_objects.m_objects.end(); i++) {
|
||||||
/*infostream<<"Server: Creating an active object from "
|
|
||||||
<<"static data"<<std::endl;*/
|
|
||||||
StaticObject &s_obj = *i;
|
StaticObject &s_obj = *i;
|
||||||
// Create an active object from the data
|
// Create an active object from the data
|
||||||
ServerActiveObject *obj = ServerActiveObject::create(s_obj.type, this, 0, s_obj.pos, s_obj.data);
|
ServerActiveObject *obj = ServerActiveObject::create(s_obj.type, this, 0, s_obj.pos, s_obj.data);
|
||||||
|
|
Loading…
Reference in New Issue