| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -14,12 +14,11 @@ using namespace std;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				#include <dfhack/DFVector.h>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				#include <dfhack/DFTypes.h>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				DFHack::Materials * Materials;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				DFHack::Items * Items;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				int main (int argc, char *argv[])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    bool dump_scattered = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    bool confiscate_all = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    bool dry_run = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    int wear_dump_level = 65536;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    for(int i = 1; i < argc; i++)
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -30,9 +29,15 @@ int main (int argc, char *argv[])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        for (; *arg; arg++) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            switch (arg[0]) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            case 'j':
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            case 'd':
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                dry_run = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            case 'l':
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                dump_scattered = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            case 'a':
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                confiscate_all = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                break;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            case 'x':
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                wear_dump_level = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                break;
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -62,10 +67,16 @@ int main (int argc, char *argv[])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::VersionInfo * mem = DF->getMemoryInfo();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Materials = DF->getMaterials();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Items = DF->getItems();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::Materials *Materials = DF->getMaterials();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::Items *Items = DF->getItems();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::Creatures *Creatures = DF->getCreatures();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::Translation *Tran = DF->getTranslation();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Materials->ReadAllMaterials();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    uint32_t num_creatures;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Creatures->Start(num_creatures);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    Tran->Start();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    p = DF->getProcess();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    DFHack::OffsetGroup* itemGroup = mem->getGroup("Items");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    unsigned vector_addr = itemGroup->getAddress("items_vector");
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -88,21 +99,26 @@ int main (int argc, char *argv[])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (itm.header.flags.bits.rotten)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating a rotten item.\n");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating a rotten item: \t");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            confiscate = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        else if (itm.wear_level >= wear_dump_level)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating and dumping a worn item.\n");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating and dumping a worn item: \t");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            confiscate = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            dump = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        else if (dump_scattered && itm.header.flags.bits.on_ground)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating and dumping an untidily placed item.\n");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating and dumping litter: \t");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            confiscate = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            dump = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        else if (confiscate_all)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("Confiscating: \t");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            confiscate = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (confiscate)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -110,17 +126,44 @@ int main (int argc, char *argv[])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (dump)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                itm.header.flags.bits.dump = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (!dry_run)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Items->setItemFlags(curItem, itm.header.flags);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                "%5d: %08x %08x (%d,%d,%d) #%08x [%d] %s - %s\n", 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                "%s (wear %d)",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Items->getItemDescription(curItem, Materials).c_str(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                itm.wear_level
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            int32_t owner = Items->getItemOwnerID(curItem);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            int32_t owner_index = Creatures->FindIndexById(owner);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            std::string info;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (owner_index >= 0)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                DFHack::t_creature temp;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Creatures->ReadCreature(owner_index,temp);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                temp.name.first_name[0] = toupper(temp.name.first_name[0]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                info = temp.name.first_name;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                if (temp.name.nickname[0])
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    info += std::string(" '") + temp.name.nickname + "'";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                info += " ";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                info += Tran->TranslateName(temp.name,false);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                printf(", owner %s", info.c_str());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            printf("\n");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				/*            printf(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                "%5d: %08x %08x (%d,%d,%d) #%08x [%d] %s - %s %s\n",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                i, curItem, itm.header.flags.whole,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                itm.header.x, itm.header.y, itm.header.z,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                p->readDWord(curItem),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                itm.wear_level,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Items->getItemClass(itm.matdesc.itemType).c_str(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Items->getItemDescription(curItem, Materials).c_str()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            );
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                Items->getItemDescription(curItem, Materials).c_str(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                info.c_str()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                  );*/
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |