• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Clean Protection Zone for TFS 0.2

Norix

Hosting Service !
Joined
Jan 18, 2008
Messages
544
Reaction score
8
Location
Germany
Hi
There is a option in TFS 0.3+ that you can clean protection zone. How to make it in TFS 0.2????

Thx in advance

Your's Norix
 
I've tested it before and it works 100% but still use it on your own risk!

replace your "uint32_t Map::clean()"
with this.

map.cpp:
Code:
uint32_t Map::clean()
{
	g_game.setGameState(GAME_STATE_MAINTAIN);

	g_game.setStateTime(0);
	uint64_t start = OTSYS_TIME();
	uint64_t count = 0;
	Tile* tile = NULL;
	Item *item = NULL;

	QTreeLeafNode* startLeaf;
	QTreeLeafNode* leafE;
	QTreeLeafNode* leafS;
	Floor* floor;

	startLeaf = getLeaf(0, 0);
	leafS = startLeaf;

	for(int32_t ny = 0; ny <= 0xFFFF; ny += FLOOR_SIZE)
	{
		leafE = leafS;
		for(int32_t nx = 0; nx <= 0xFFFF; nx += FLOOR_SIZE)
		{
			if(leafE)
			{
				for(int32_t nz = 0; nz < MAP_MAX_LAYERS; ++nz)
				{
					if(leafE && (floor = leafE->getFloor(nz)))
					{
						for(int32_t ly = 0; ly < FLOOR_SIZE; ++ly)
						{
							for(int32_t lx = 0; lx < FLOOR_SIZE; ++lx)
							{
								if(floor && (tile = floor->tiles[(nx + lx) & FLOOR_MASK][(ny + ly) & FLOOR_MASK]))
								{
                                    if(g_config.getBoolean(ConfigManager::CLEAN_PROTECTION_ZONE))
                                    {
			                            if(!tile->hasFlag(TILESTATE_HOUSE))
			                            {
										    for(uint32_t i = 0; i < tile->getThingCount(); ++i)
										    {
											    item = tile->__getThing(i)->getItem();
											    if(item && !item->isLoadedFromMap() && !item->isNotMoveable())
											    {
												    g_game.internalRemoveItem(item);
												    i--;
												    count++;
                                                }
											}
										}
									}
									else if(!g_config.getBoolean(ConfigManager::CLEAN_PROTECTION_ZONE))
									{
                                        if(!tile->hasFlag(TILESTATE_PROTECTIONZONE))
			                            {  
                                            for(uint32_t i = 0; i < tile->getThingCount(); ++i)
	                                        {
                                                item = tile->__getThing(i)->getItem();
                                                if(item && !item->isLoadedFromMap() && !item->isNotMoveable())
                                                {
                                                    g_game.internalRemoveItem(item);
                                                    i--;
                                                    count++;
                                                }
                                            }
					                    }
								    }
                                }
							}
						}
					}
				}
				leafE = leafE->stepEast();
			}
			else
				leafE = getLeaf(nx + FLOOR_SIZE, ny);
		}
		if(leafS)
			leafS = leafS->stepSouth();
		else
			leafS = getLeaf(0, ny + FLOOR_SIZE);
	}

	std::cout << "> Cleaning time: " << (OTSYS_TIME() - start) / (1000.) << " seconds, collected " << count << " item" << (count != 1 ? "s" : "") << "." << std::endl;
	g_game.setStateTime(OTSYS_TIME() + STATE_TIME);
	g_game.setGameState(GAME_STATE_NORMAL);
	return count;
}

configmanager.cpp:

after:
Code:
m_confBoolean[SHOW_GAMEMASTERS_ONLINE] = (getGlobalString(L, "displayGamemastersWithOnlineCommand", "no") == "yes");

paste this:
Code:
m_confBoolean[CLEAN_PROTECTION_ZONE] = (getGlobalString(L, "cleanProtectionZone", "no") == "yes");

configmanager.h:

after this
Code:
SHOW_GAMEMASTERS_ONLINE,

paste this
Code:
CLEAN_PROTECTION_ZONE,

then add this into your config.lua

Code:
cleanProtectionZone = "yes"

If you want improvements etc. feel free to ask me for them :)


kind regards, Evil Hero
 
Last edited:
Back
Top