else if( (
else if(
void checkauto() // Check automatic/timer controlled stuff (Like fighting and regeneration){	//int k;	unsigned int i;	register unsigned int currenttime = uiCurrentTime;	static unsigned int checkspawnregions = 0;	static unsigned int checknpcs = 0;	static unsigned int checktamednpcs = 0;	static unsigned int checknpcfollow = 0;	static unsigned int checkitemstime = 0;	static unsigned int lighttime = 0;	static unsigned int htmltime = 0;	static unsigned int housedecaytimer = 0;	static unsigned int freeUnusedMemory = 0;	//static unsigned int repairworldtimer=0;	if (housedecaytimer<=currenttime)	{		//////////////////////		///// check_houses		/////////////////////		if(SrvParams->housedecay_secs() != -1)			int check_house_decay();		////////////////////		// check stabling		///////////////////		unsigned long int diff;		// TODO: BAD !! We do that twice a loop		AllCharsIterator iter_char;		   		for (iter_char.Begin(); !iter_char.atEnd(); ++iter_char)		{			P_CHAR pc = iter_char.GetData();			if (pc->npc_type() == 1)			{				vector<SERIAL> pets( stablesp.getData(pc->serial) );				unsigned int ci;				for (ci = 0; ci < pets.size();ci++)				{					P_CHAR pc_pet = FindCharBySerial(pets[ci]);					if (pc_pet != NULL)					{						diff = (getNormalizedTime() - pc_pet->timeused_last()) / MY_CLOCKS_PER_SEC;						pc_pet->setTime_unused( pc_pet->time_unused() + diff );						//clConsole.send("stabling-check debug-name: %s\n",chars[i].name);					}				}			}		}		housedecaytimer=uiCurrentTime+MY_CLOCKS_PER_SEC*60*30; // check only each 30 minutes	}	if(checkspawnregions<=currenttime && SrvParams->spawnRegionCheckTime() != -1)//Regionspawns	{		cAllSpawnRegions::getInstance()->check();		checkspawnregions=uiCurrentTime+SrvParams->spawnRegionCheckTime()*MY_CLOCKS_PER_SEC;//Don't check them TOO often (Keep down the lag)	}	if(SrvParams->html()>0 && (htmltime<=currenttime || overflow))	{			updatehtml();			htmltime=currenttime+(SrvParams->html()*MY_CLOCKS_PER_SEC);	}	if (SrvParams->saveInterval() != 0)	{		if (autosaved == 0)		{			autosaved = 1;			time( (time_t*) (&oldtime)) ;		}		time( (time_t*) ( &newtime)) ;		if (dosavewarning==1)		if (difftime(newtime,oldtime)==SrvParams->saveInterval()-10) 		{		   sysbroadcast("World will be saved in 10 seconds..");		   dosavewarning = 0;		}		if (difftime(newtime, oldtime)>=SrvParams->saveInterval() || cwmWorldState->Saving() )		{			autosaved = 0;			cwmWorldState->savenewworld(0);			dosavewarning = 1;		}	}	//Time functions	if (uotickcount<=currenttime||(overflow))	{		uoTime.addSecs(1);		uotickcount = currenttime + SrvParams->secondsPerUOMinute()*MY_CLOCKS_PER_SEC;	}	if(lighttime<=currenttime || (overflow))	{		doworldlight(); //Changes lighting, if it is currently time to.		int i;		for (i = 0; i < now; i++) 			if (online(currchar[i])) 				dolight(i, SrvParams->worldCurrentLevel()); // bandwidth fix, LB		lighttime=currenttime+30*MY_CLOCKS_PER_SEC;	}	static unsigned int itemlooptime = 0;    if(itemlooptime <=currenttime || (overflow))	{       itemlooptime = currenttime+5*MY_CLOCKS_PER_SEC;	   AllItemsIterator iterItems;       for( iterItems.Begin(); !iterItems.atEnd(); ++iterItems ) // Ripper...so spawners get set to nodecay.	   {			P_ITEM pi = iterItems.GetData();			if(pi != NULL)			{				// lets make sure they are spawners.				if ((pi->type()>=61 && pi->type()<=65) || (pi->type()==69) || (pi->type()==125))				{					// set to nodecay and refresh.	                pi->priv=0;		            RefreshItem(pi);				 }			}		}	}	for( cUOSocket *socket = cNetwork::instance()->first(); socket; socket = cNetwork::instance()->next() )	{		if( !socket->player() )			continue;		genericCheck( socket->player(), currenttime );		checkPC( socket->player(), currenttime );		// Check all Characters first		RegionIterator4Chars iterator( socket->player()->pos );		for( iterator.Begin(); !iterator.atEnd(); iterator++ )		{			P_CHAR pChar = iterator.GetData();			if( !pChar )				continue;			// we check tamed npcs more often than			// untamed npcs so they can react faster			if( ( !pChar->tamed() && checknpcs <= currenttime ) ||				( pChar->tamed() && checktamednpcs <= currenttime ) ||				( ( pChar->npcWander == 1 ) && checknpcfollow <= currenttime ) ||				overflow )			{				if( pChar->isNpc() )				{					genericCheck( pChar, currenttime );					// We only process the AI for NPCs who are in a used area					if( pChar->pos.distance( socket->player()->pos ) <= 24 )						checkNPC( pChar, currenttime );				}				// Timed for logout				else if( ( 						pChar->logout() && 						( pChar->logout() >= currenttime ) 					) || overflow )				{					pChar->setLogout( 0 );					pChar->removeFromView( false );					pChar->resend( false );				}			}				}		// Now for the items		if( ( checkitemstime <= currenttime ) || overflow )		{			RegionIterator4Items itemIter( socket->player()->pos );			for( itemIter.Begin(); !itemIter.atEnd(); itemIter++ )			{				P_ITEM pItem = itemIter.GetData();					if( !pItem )					continue;							Items->RespawnItem( currenttime, pItem ); // Checks if the item is a spawner				Items->DecayItem( currenttime, pItem ); // Checks if the item should decay				switch( pItem->type() )				{				case 51:				case 52:					if( pItem->gatetime < currenttime )						Items->DeleItem( pItem );					break;				case 88:					if( pItem->pos.distance( socket->player()->pos ) < pItem->morey )						if( RandomNum( 1, 100 ) <= pItem->morez )							socket->soundEffect( pItem->morex, pItem );					break;				case 117:					if( ( pItem->tags.get( "tiller" ).isValid() && 						( pItem->gatetime <= currenttime ) ) || overflow )					{						cBoat* pBoat = dynamic_cast< cBoat* >( FindItemBySerial( pItem->tags.get( "boatserial" ).toUInt() ) );						if( pBoat )						{							pBoat->move();							pItem->gatetime=(UINT32)( currenttime + (double)( SrvParams->boatSpeed() * MY_CLOCKS_PER_SEC ) );						}					}					break;				};							}		}	}