Sup, clean globalevent freezes server no idea why there aren't much code lol
Also i have set up it for 13:00 and it cleaned at 22:00 wtf?
Distro: TFS 0.4
Client: Tibia 8.60
Dedi: Debian 6 32bit
globalevents.xml
clean.lua
luainterface.cpp
and whole cleanMapEx function from game.cpp
i have no idea what may cause server to freeze.
ps. talkaction clean works like charm but doesn't clean whole map, it only uses cleantile in cid range function.
-EDIT-
i just noticed there is return true in clean.lua can this cause that freeze problem ? Lol...
Also i have set up it for 13:00 and it cleaned at 22:00 wtf?
Distro: TFS 0.4
Client: Tibia 8.60
Dedi: Debian 6 32bit
globalevents.xml
Code:
<globalevent name="clean" time="13:00" event="script" value="clean.lua"/>
clean.lua
Code:
function onTime(interval)
doCleanMap()
doBroadcastMessage("Game map cleaned, next clean in at 13:00.")
return true
end
luainterface.cpp
Code:
int32_t LuaInterface::luaDoCleanMap(lua_State* L)
{
//doCleanMap()
uint32_t count = 0;
g_game.cleanMapEx(count);
lua_pushnumber(L, count);
return 1;
}
and whole cleanMapEx function from game.cpp
Code:
void Game::cleanMapEx(uint32_t& count)
{
uint64_t start = OTSYS_TIME();
uint32_t tiles = 0; count = 0;
int32_t marked = -1;
if(gameState == GAMESTATE_NORMAL)
setGameState(GAMESTATE_MAINTAIN);
Tile* tile = NULL;
ItemVector::iterator tit;
if(g_config.getBool(ConfigManager::STORE_TRASH))
{
marked = trash.size();
Trash::iterator it = trash.begin();
if(g_config.getBool(ConfigManager::CLEAN_PROTECTED_ZONES))
{
for(; it != trash.end(); ++it)
{
if(!(tile = getTile(*it)))
continue;
tile->resetFlag(TILESTATE_TRASHED);
if(tile->hasFlag(TILESTATE_HOUSE) || !tile->getItemList())
continue;
++tiles;
tit = tile->getItemList()->begin();
while(tile->getItemList() && tit != tile->getItemList()->end())
{
if((*tit)->isMoveable() && !(*tit)->isLoadedFromMap()
&& !(*tit)->isScriptProtected())
{
internalRemoveItem(NULL, *tit);
if(tile->getItemList())
tit = tile->getItemList()->begin();
++count;
}
else
++tit;
}
}
trash.clear();
}
else
{
for(; it != trash.end(); ++it)
{
if(!(tile = getTile(*it)))
continue;
tile->resetFlag(TILESTATE_TRASHED);
if(tile->hasFlag(TILESTATE_PROTECTIONZONE) || !tile->getItemList())
continue;
++tiles;
tit = tile->getItemList()->begin();
while(tile->getItemList() && tit != tile->getItemList()->end())
{
if((*tit)->isMoveable() && !(*tit)->isLoadedFromMap()
&& !(*tit)->isScriptProtected())
{
internalRemoveItem(NULL, *tit);
if(tile->getItemList())
tit = tile->getItemList()->begin();
++count;
}
else
++tit;
}
}
trash.clear();
}
}
else if(g_config.getBool(ConfigManager::CLEAN_PROTECTED_ZONES))
{
for(uint16_t z = 0; z < (uint16_t)MAP_MAX_LAYERS; z++)
{
for(uint16_t y = 1; y <= map->mapHeight; y++)
{
for(uint16_t x = 1; x <= map->mapWidth; x++)
{
if(!(tile = getTile(x, y, z)) || tile->hasFlag(TILESTATE_HOUSE) || !tile->getItemList())
continue;
++tiles;
tit = tile->getItemList()->begin();
while(tile->getItemList() && tit != tile->getItemList()->end())
{
if((*tit)->isMoveable() && !(*tit)->isLoadedFromMap()
&& !(*tit)->isScriptProtected())
{
internalRemoveItem(NULL, *tit);
if(tile->getItemList())
tit = tile->getItemList()->begin();
++count;
}
else
++tit;
}
}
}
}
}
else
{
for(uint16_t z = 0; z < (uint16_t)MAP_MAX_LAYERS; z++)
{
for(uint16_t y = 1; y <= map->mapHeight; y++)
{
for(uint16_t x = 1; x <= map->mapWidth; x++)
{
if(!(tile = getTile(x, y, z)) || tile->hasFlag(TILESTATE_PROTECTIONZONE) || !tile->getItemList())
continue;
++tiles;
tit = tile->getItemList()->begin();
while(tile->getItemList() && tit != tile->getItemList()->end())
{
if((*tit)->isMoveable() && !(*tit)->isLoadedFromMap()
&& !(*tit)->isScriptProtected())
{
internalRemoveItem(NULL, *tit);
if(tile->getItemList())
tit = tile->getItemList()->begin();
++count;
}
else
++tit;
}
}
}
}
}
if(gameState == GAMESTATE_MAINTAIN)
setGameState(GAMESTATE_NORMAL);
std::clog << "> CLEAN: Removed " << count << " item" << (count != 1 ? "s" : "")
<< " from " << tiles << " tile" << (tiles != 1 ? "s" : "");
if(marked >= 0)
std::clog << " (" << marked << " were marked)";
std::clog << " in " << (OTSYS_TIME() - start) / (1000.) << " seconds." << std::endl;
}
i have no idea what may cause server to freeze.
ps. talkaction clean works like charm but doesn't clean whole map, it only uses cleantile in cid range function.
-EDIT-
i just noticed there is return true in clean.lua can this cause that freeze problem ? Lol...
Last edited: