Beispiel #1
0
void init()
{
// clean up all trash
	object room;
	int i;
	object *inv;
	dest_trash();
	room = environment(this_object());
	if(room)
	{
	inv = all_inventory(room);
        for(i=0; i<sizeof(inv); i++) {

	if( userp( inv[i]) ) 
	{
	if ( !random(5))
	set_leader(inv[i]);
	continue;
	}
	if( inv[i]->query("no_shown")) continue;
	if( inv[i]->query("no_get")) continue;
        if( inv[i]->is_character()) continue;
        if( inv[i]->is_corpse()) continue;
	command("get "+ inv[i]->query("id"));
	}
	}

}
Beispiel #2
0
void SFileWorker::EmptyTrash(void)
{
	BEntry trashEntry(TRASH_ENTRY);
	SFile dest_trash(&trashEntry);
	for (int32 i=0; i < iFileList->CountItems(); i++) 
	{
		SFile *file=(SFile *) iFileList->ItemAt(i);
		delete file;
	}
	iFileList->MakeEmpty();

	// set directory to the entry represented by this item
	BEntry entry;
	BDirectory directory(TRASH_ENTRY);

	while ((directory.GetNextEntry(&entry, false)==B_OK))
	{
		SFile *file=new SFile(&entry);
		iFileList->AddItem(file);
	}

	// deep-scan
	int32 nItems=iFileList->CountItems();
	for (int32 indx=0; indx < nItems; indx++)
	{
		SFile *file=(SFile *) iFileList->ItemAt(indx);
		
		if(file->IsDirectory())
		{
			directory.SetTo(file->Ref());
			while (directory.GetNextEntry(&entry, false)==B_OK)
			{
				SFile *newFile=new SFile(&entry);				
				iFileList->AddItem(newFile);
				nItems +=1;				
			}
		}
	}

	iFileList->SortItems(CompareByLevel);

	iFileOp=P_OP_CUT;

	if(iFileList->CountItems()==0)
		return;

	SCopyWindow *copyWindow=new SCopyWindow(iWindow, iFileList, &dest_trash,iFileOp, P_OP_REMOVE);
	iWindow->AddToSubset(copyWindow);
	copyWindow->Show();
	
	// clear old list
	for (int32 i=0; i < iFileList->CountItems(); i++)
	{
		SFile *file=(SFile *) iFileList->ItemAt(i);
		delete file;
	}
	iFileList->MakeEmpty();
}