|  |  | @ -4,6 +4,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <iostream> |  |  |  | #include <iostream> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <vector> |  |  |  | #include <vector> | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <map> |  |  |  | #include <map> | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | #include <cstdlib> | 
			
		
	
		
		
			
				
					
					|  |  |  | using namespace std; |  |  |  | using namespace std; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | #include <DFHack.h> |  |  |  | #include <DFHack.h> | 
			
		
	
	
		
		
			
				
					|  |  | @ -45,6 +46,8 @@ int main (void) | 
			
		
	
		
		
			
				
					
					|  |  |  |     string flowmode="f+"; |  |  |  |     string flowmode="f+"; | 
			
		
	
		
		
			
				
					
					|  |  |  |     string setmode ="s."; |  |  |  |     string setmode ="s."; | 
			
		
	
		
		
			
				
					
					|  |  |  |     int amount = 7; |  |  |  |     int amount = 7; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	int width = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	int height = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |     while(!end) |  |  |  |     while(!end) | 
			
		
	
		
		
			
				
					
					|  |  |  |     { |  |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |  |         DF->Resume(); |  |  |  |         DF->Resume(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -69,6 +72,7 @@ int main (void) | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "0-7           - set liquid amount" << endl |  |  |  |                  << "0-7           - set liquid amount" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "Brush:" << endl |  |  |  |                  << "Brush:" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "point         - single tile" << endl |  |  |  |                  << "point         - single tile" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				 << "range         - rectangle with cursor at top left" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "block         - block with cursor in it" << endl |  |  |  |                  << "block         - block with cursor in it" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "Other:" << endl |  |  |  |                  << "Other:" << endl | 
			
		
	
		
		
			
				
					
					|  |  |  |                  << "q             - quit" << endl |  |  |  |                  << "q             - quit" << endl | 
			
		
	
	
		
		
			
				
					|  |  | @ -110,6 +114,18 @@ int main (void) | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             brush = "point"; |  |  |  |             brush = "point"; | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		else if(command == "range") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			cout << " :set range width<" << width << "># "; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			getline(cin, command); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			width = atoi (command.c_str()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if(width < 1) width = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			cout << " :set range height<" << height << "># "; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			getline(cin, command); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			height = atoi (command.c_str()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if(height < 1) height = 1; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		    brush = "range"; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |         else if(command == "block") |  |  |  |         else if(command == "block") | 
			
		
	
		
		
			
				
					
					|  |  |  |         { |  |  |  |         { | 
			
		
	
		
		
			
				
					
					|  |  |  |             brush = "block"; |  |  |  |             brush = "block"; | 
			
		
	
	
		
		
			
				
					|  |  | @ -257,94 +273,192 @@ int main (void) | 
			
		
	
		
		
			
				
					
					|  |  |  |                 else |  |  |  |                 else | 
			
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  |                 { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     // place the magma
 |  |  |  |                     // place the magma
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     Maps->ReadDesignations((x/16),(y/16),z, &designations); |  |  |  | 					if(brush != "range") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     Maps->ReadTemperatures((x/16),(y/16),z, &temp1, &temp2); |  |  |  | 					{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     if(brush == "point") |  |  |  | 						Maps->ReadDesignations((x/16),(y/16),z, &designations); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     { |  |  |  | 						Maps->ReadTemperatures((x/16),(y/16),z, &temp1, &temp2); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         if(mode != "flowbits") |  |  |  | 						if(brush == "point") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         { |  |  |  | 						{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             // fix temperatures so we don't produce lethal heat traps
 |  |  |  | 							if(mode != "flowbits") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if(amount == 0 || designations[x%16][y%16].bits.liquid_type == DFHack::liquid_magma && mode == "water") |  |  |  | 							{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 temp1[x%16][y%16] = temp2[x%16][y%16] = 10015; |  |  |  | 								// fix temperatures so we don't produce lethal heat traps
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             DFHack::naked_designation & flow = designations[x%16][y%16].bits; |  |  |  | 								if(amount == 0 || designations[x%16][y%16].bits.liquid_type == DFHack::liquid_magma && mode == "water") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if(setmode == "s.") |  |  |  | 									temp1[x%16][y%16] = temp2[x%16][y%16] = 10015; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             { |  |  |  | 								DFHack::naked_designation & flow = designations[x%16][y%16].bits; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 flow.flow_size = amount; |  |  |  | 								if(setmode == "s.") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  | 								{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             else if(setmode == "s+") |  |  |  | 									flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             { |  |  |  | 								} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 if(flow.flow_size < amount) |  |  |  | 								else if(setmode == "s+") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     flow.flow_size = amount; |  |  |  | 								{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  | 									if(flow.flow_size < amount) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             else if(setmode == "s-") |  |  |  | 										flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             { |  |  |  | 								} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 if (flow.flow_size > amount) |  |  |  | 								else if(setmode == "s-") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     flow.flow_size = amount; |  |  |  | 								{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  | 									if (flow.flow_size > amount) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  | 										flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         if(mode == "magma") |  |  |  | 								} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; |  |  |  | 							} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         else if(mode == "water") |  |  |  | 							if(mode == "magma") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             designations[x%16][y%16].bits.liquid_type = DFHack::liquid_water; |  |  |  | 								designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  | 							else if(mode == "water") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     else |  |  |  | 								designations[x%16][y%16].bits.liquid_type = DFHack::liquid_water; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     { |  |  |  | 						}					 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++) |  |  |  | 						else | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         { |  |  |  | 						{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if(mode != "flowbits") |  |  |  | 							for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             { |  |  |  | 							{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 // fix temperatures so we don't produce lethal heat traps
 |  |  |  | 								if(mode != "flowbits") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 if(amount == 0 || designations[xx][yy].bits.liquid_type == DFHack::liquid_magma && mode == "water") |  |  |  | 								{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     temp1[xx%16][yy%16] = temp2[xx%16][yy%16] = 10015; |  |  |  | 									// fix temperatures so we don't produce lethal heat traps
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 DFHack::naked_designation & flow= designations[xx][yy].bits; |  |  |  | 									if(amount == 0 || designations[xx][yy].bits.liquid_type == DFHack::liquid_magma && mode == "water") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 if(setmode == "s.") |  |  |  | 										temp1[xx%16][yy%16] = temp2[xx%16][yy%16] = 10015; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 { |  |  |  | 									DFHack::naked_designation & flow= designations[xx][yy].bits; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     flow.flow_size = amount; |  |  |  | 									if(setmode == "s.") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  | 									{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 else if(setmode == "s+") |  |  |  | 										flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 { |  |  |  | 									} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     if(flow.flow_size < amount) |  |  |  | 									else if(setmode == "s+") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                         flow.flow_size = amount; |  |  |  | 									{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  | 										if(flow.flow_size < amount) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 else if(setmode == "s-") |  |  |  | 											flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 { |  |  |  | 									} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                     if (flow.flow_size > amount) |  |  |  | 									else if(setmode == "s-") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                         flow.flow_size = amount; |  |  |  | 									{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 } |  |  |  | 										if (flow.flow_size > amount) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             } |  |  |  | 											flow.flow_size = amount; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             if(mode == "magma") |  |  |  | 									} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 designations[xx][yy].bits.liquid_type = DFHack::liquid_magma; |  |  |  | 								} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                             else if(mode == "water") |  |  |  | 								if(mode == "magma") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                 designations[xx][yy].bits.liquid_type = DFHack::liquid_water; |  |  |  | 									designations[xx][yy].bits.liquid_type = DFHack::liquid_magma; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                         } |  |  |  | 								else if(mode == "water") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  | 									designations[xx][yy].bits.liquid_type = DFHack::liquid_water; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     Maps->WriteTemperatures((x/16),(y/16),z, &temp1, &temp2); |  |  |  | 							} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     Maps->WriteDesignations(x/16,y/16,z, &designations); |  |  |  | 						} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  | 						Maps->WriteTemperatures((x/16),(y/16),z, &temp1, &temp2); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						Maps->WriteDesignations(x/16,y/16,z, &designations); | 
			
		
	
		
		
			
				
					
					|  |  |  | 					 |  |  |  | 					 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 // make the magma flow :)
 |  |  |  | 						// make the magma flow :)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 DFHack::t_blockflags bflags; |  |  |  | 						DFHack::t_blockflags bflags; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 Maps->ReadBlockFlags((x/16),(y/16),z,bflags); |  |  |  | 						Maps->ReadBlockFlags((x/16),(y/16),z,bflags); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 // 0x00000001 = job-designated
 |  |  |  | 						// 0x00000001 = job-designated
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 // 0x0000000C = run flows? - both bit 3 and 4 required for making magma placed on a glacier flow
 |  |  |  | 						// 0x0000000C = run flows? - both bit 3 and 4 required for making magma placed on a glacier flow
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 if(flowmode == "f+") |  |  |  | 						if(flowmode == "f+") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  | 						{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     bflags.bits.liquid_1 = true; |  |  |  | 							bflags.bits.liquid_1 = true; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     bflags.bits.liquid_2 = true; |  |  |  | 							bflags.bits.liquid_2 = true; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  | 						} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 else if(flowmode == "f-") |  |  |  | 						else if(flowmode == "f-") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  | 						{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     bflags.bits.liquid_1 = false; |  |  |  | 							bflags.bits.liquid_1 = false; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     bflags.bits.liquid_2 = false; |  |  |  | 							bflags.bits.liquid_2 = false; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  | 						} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 else |  |  |  | 						else | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 { |  |  |  | 						{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     cout << "flow bit 1 = " << bflags.bits.liquid_1 << endl;  |  |  |  | 							cout << "flow bit 1 = " << bflags.bits.liquid_1 << endl;  | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                     cout << "flow bit 2 = " << bflags.bits.liquid_2 << endl; |  |  |  | 							cout << "flow bit 2 = " << bflags.bits.liquid_2 << endl; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  | 						} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 Maps->WriteBlockFlags((x/16),(y/16),z,bflags); |  |  |  | 						Maps->WriteBlockFlags((x/16),(y/16),z,bflags); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 cout << "OK" << endl; |  |  |  | 					} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 Maps->Finish(); |  |  |  | 					else // (brush == "range")
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						// Crop the range into each block if necessary
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						int beginxblock = x/16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						int endxblock = (x+width)/16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						int beginyblock = y/16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						int endyblock = (y+height)/16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						for(uint32_t bx = beginxblock; bx < endxblock+1; bx++) for(uint32_t by = beginyblock; by < endyblock+1; by++) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							if(Maps->isValidBlock(bx,by,z)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->ReadDesignations(bx,by,z, &designations); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->ReadTemperatures(bx,by,z, &temp1, &temp2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								// Take original range and crop it into current block
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								int nx = x; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								int ny = y; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								int nwidth = width; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								int nheight = height; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if(x/16 < bx) //Start point is left of block
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									nx = bx*16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									nwidth -= nx - x; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if (nx/16 < (nx+nwidth-1)/16)// End point is right of block
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									nwidth = (bx*16)+16-nx; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if(y/16 < by) //Start point is above block
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									ny = by*16; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									nheight -= ny - y; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if (ny/16 < (ny+nheight-1)/16) // End point is below block
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									nheight = (by*16)+16-ny; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								cout << " Block:" << bx << "," << by << ":" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								cout << " Start:" << nx << "," << ny << ":" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								cout << " Area: " << nwidth << "," << nheight << ":" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								for(uint32_t xx = nx; xx < nx+nwidth; xx++) for(uint32_t yy = ny; yy < ny+nheight; yy++) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									if(mode != "flowbits") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										// fix temperatures so we don't produce lethal heat traps
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										if(amount == 0 || designations[xx%16][yy%16].bits.liquid_type == DFHack::liquid_magma && mode == "water") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 											temp1[xx%16][yy%16] = temp2[xx%16][yy%16] = 10015; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										DFHack::naked_designation & flow= designations[xx%16][yy%16].bits; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										if(setmode == "s.") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 											flow.flow_size = amount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										else if(setmode == "s+") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 											if(flow.flow_size < amount) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 												flow.flow_size = amount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										else if(setmode == "s-") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 											if (flow.flow_size > amount) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 												flow.flow_size = amount; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									if(mode == "magma") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										designations[xx%16][yy%16].bits.liquid_type = DFHack::liquid_magma; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									else if(mode == "water") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 										designations[xx%16][yy%16].bits.liquid_type = DFHack::liquid_water; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->WriteTemperatures(bx,by,z, &temp1, &temp2); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->WriteDesignations(bx,by,z, &designations); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								// make the magma flow :)
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								DFHack::t_blockflags bflags; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->ReadBlockFlags(bx,by,z,bflags); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								// 0x00000001 = job-designated
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								// 0x0000000C = run flows? - both bit 3 and 4 required for making magma placed on a glacier flow
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								if(flowmode == "f+") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									bflags.bits.liquid_1 = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									bflags.bits.liquid_2 = true; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								else if(flowmode == "f-") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									bflags.bits.liquid_1 = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									bflags.bits.liquid_2 = false; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									cout << "flow bit 1 = " << bflags.bits.liquid_1 << endl;  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 									cout << "flow bit 2 = " << bflags.bits.liquid_2 << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 								Maps->WriteBlockFlags(bx,by,z,bflags); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 							} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 						} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				cout << "OK" << endl; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				Maps->Finish(); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } while (0); |  |  |  |             } while (0); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |