// Add one
block->m_static_objects.insert(0, s_obj);
delete obj;
- block->setChangedFlag();
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "spawnRandomObjects");
}
}
}
event.p = block->getPos();
m_map->dispatchEvent(&event);
- block->setChangedFlag();
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "node metadata modified in activateBlock");
}
// TODO: Do something
MapBlock *block = m_map->getBlockNoCreateNoEx(obj->m_static_block);
if(block){
block->m_static_objects.remove(id);
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "clearAllObjects");
obj->m_static_exists = false;
}
}
if(num_stored != 0 || num_active != 0){
block->m_static_objects.m_stored.clear();
block->m_static_objects.m_active.clear();
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "clearAllObjects");
num_objs_cleared += num_stored + num_active;
num_blocks_cleared++;
}
event.p = p;
m_map->dispatchEvent(&event);
- block->setChangedFlag();
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "node metadata modified in step");
}
}
}
if(block)
{
block->m_static_objects.insert(0, s_obj);
- block->raiseModified(MOD_STATE_WRITE_AT_UNLOAD);
+ block->raiseModified(MOD_STATE_WRITE_AT_UNLOAD,
+ "addActiveObjectAsStatic");
succeeded = true;
}
else{
object->m_static_block = blockpos;
if(set_changed)
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "addActiveObjectRaw");
}
else{
errorstream<<"ServerEnvironment::addActiveObjectRaw(): "
if(block)
{
block->m_static_objects.remove(id);
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "removeRemovedObjects");
obj->m_static_exists = false;
}
}
<<"; removing all of them."<<std::endl;
// Clear stored list
block->m_static_objects.m_stored.clear();
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "stored list cleared in activateObjects due to "
+ "large amount of objects");
return;
}
// A list for objects that couldn't be converted to static for some
The objects have just been activated and moved from the stored
static list to the active static list.
As such, the block is essentially the same.
- Thus, do not call block->setChangedFlag().
+ Thus, do not call block->raiseModified(MOD_STATE_WRITE_NEEDED).
Otherwise there would be a huge amount of unnecessary I/O.
*/
}
obj->m_static_exists = false;
// Only mark block as modified if data changed considerably
if(shall_be_written)
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "deactivateFarObjects: Static data "
+ "changed considerably");
}
}
// Only mark block as modified if data changed considerably
if(shall_be_written)
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "deactivateFarObjects: Static data "
+ "changed considerably");
obj->m_static_exists = true;
obj->m_static_block = block->getPos();
if(block->getModified() != MOD_STATE_CLEAN
&& save_before_unloading)
{
+ verbosestream<<"Saving block before unloading, "
+ <<"modified by: "
+ <<block->getModifiedReason()<<std::endl;
saveBlock(block);
saved_blocks_count++;
}
/*
Set block as modified
*/
- block->raiseModified(MOD_STATE_WRITE_NEEDED);
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "finishBlockMake updateDayNightDiff");
}
/*
if(block->getModified() >= MOD_STATE_WRITE_NEEDED
|| only_changed == false)
{
+ verbosestream<<"Saving block because of MOD_STATE_WRITE_NEEDED, "
+ <<"modified by: "
+ <<block->getModifiedReason()<<std::endl;
saveBlock(block);
block_count++;
m_pos(pos),
m_gamedef(gamedef),
m_modified(MOD_STATE_WRITE_NEEDED),
+ m_modified_reason("initial"),
+ m_modified_reason_too_long(false),
is_underground(false),
m_lighting_expired(true),
m_day_night_differs(false),
//data[i] = MapNode();
data[i] = MapNode(CONTENT_IGNORE);
}
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "reallocate");
}
/*
reallocate();
}
- /*
- This is called internally or externally after the block is
- modified, so that the block is saved and possibly not deleted from
- memory.
- */
- // DEPRECATED, use *Modified()
- void setChangedFlag()
- {
- //dstream<<"Deprecated setChangedFlag() called"<<std::endl;
- raiseModified(MOD_STATE_WRITE_NEEDED);
- }
- // DEPRECATED, use *Modified()
- void resetChangedFlag()
- {
- //dstream<<"Deprecated resetChangedFlag() called"<<std::endl;
- resetModified();
- }
- // DEPRECATED, use *Modified()
- bool getChangedFlag()
- {
- //dstream<<"Deprecated getChangedFlag() called"<<std::endl;
- if(getModified() == MOD_STATE_CLEAN)
- return false;
- else
- return true;
- }
-
// m_modified methods
- void raiseModified(u32 mod)
- {
- m_modified = MYMAX(m_modified, mod);
+ void raiseModified(u32 mod, const std::string &reason="unknown")
+ {
+ if(mod > m_modified){
+ m_modified = mod;
+ m_modified_reason = reason;
+ m_modified_reason_too_long = false;
+ } else if(mod == m_modified){
+ if(!m_modified_reason_too_long){
+ if(m_modified_reason.size() < 40)
+ m_modified_reason += ", " + reason;
+ else{
+ m_modified_reason += "...";
+ m_modified_reason_too_long = true;
+ }
+ }
+ }
}
u32 getModified()
{
return m_modified;
}
+ std::string getModifiedReason()
+ {
+ return m_modified_reason;
+ }
void resetModified()
{
m_modified = MOD_STATE_CLEAN;
+ m_modified_reason = "none";
+ m_modified_reason_too_long = false;
}
// is_underground getter/setter
void setIsUnderground(bool a_is_underground)
{
is_underground = a_is_underground;
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "setIsUnderground");
}
#ifndef SERVER
{
if(expired != m_lighting_expired){
m_lighting_expired = expired;
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "setLightingExpired");
}
}
bool getLightingExpired()
void setGenerated(bool b)
{
if(b != m_generated){
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "setGenerated");
m_generated = b;
}
}
if(y < 0 || y >= MAP_BLOCKSIZE) throw InvalidPositionException();
if(z < 0 || z >= MAP_BLOCKSIZE) throw InvalidPositionException();
data[z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + y*MAP_BLOCKSIZE + x] = n;
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "setNode");
}
void setNode(v3s16 p, MapNode & n)
if(data == NULL)
throw InvalidPositionException();
data[z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + y*MAP_BLOCKSIZE + x] = n;
- raiseModified(MOD_STATE_WRITE_NEEDED);
+ raiseModified(MOD_STATE_WRITE_NEEDED, "setNodeNoCheck");
}
void setNodeNoCheck(v3s16 p, MapNode & n)
void setTimestamp(u32 time)
{
m_timestamp = time;
- raiseModified(MOD_STATE_WRITE_AT_UNLOAD);
+ raiseModified(MOD_STATE_WRITE_AT_UNLOAD, "setTimestamp");
}
void setTimestampNoChangedFlag(u32 time)
{
- On the client, this is used for nothing.
*/
u32 m_modified;
+ std::string m_modified_reason;
+ bool m_modified_reason_too_long;
/*
When propagating sunlight and the above block doesn't exist,
last_node_walkable = false;
}
}
- block->setChangedFlag();
+ block->raiseModified(MOD_STATE_WRITE_NEEDED, "mapgen::add_random_objects");
#endif
}
MapBlock *block = m_env->getMap().getBlockNoCreateNoEx(blockpos);
if(block)
{
- block->setChangedFlag();
+ block->raiseModified(MOD_STATE_WRITE_NEEDED,
+ "sign node text");
}
- for(core::map<u16, RemoteClient*>::Iterator
- i = m_clients.getIterator();
- i.atEnd()==false; i++)
- {
- RemoteClient *client = i.getNode()->getValue();
- client->SetBlockNotSent(blockpos);
- }
+ setBlockNotSent(blockpos);
}
else if(command == TOSERVER_INVENTORY_ACTION)
{
MAP_BLOCKSIZE, MAP_BLOCKSIZE));*/
// Changed flag should be initially set
- assert(b.getChangedFlag() == true);
- b.resetChangedFlag();
- assert(b.getChangedFlag() == false);
+ assert(b.getModified() == MOD_STATE_WRITE_NEEDED);
+ b.resetModified();
+ assert(b.getModified() == MOD_STATE_CLEAN);
// All nodes should have been set to
// .d=CONTENT_IGNORE and .getLight() = 0