From f231f23332f77f1ff11a5467378dd72f5ad7f767 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Mar 2010 16:29:05 -0500 Subject: [PATCH 1/8] Putting in some broken code to get a peer review --- tools/magma_create.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tools/magma_create.cpp diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp new file mode 100644 index 000000000..6679d7698 --- /dev/null +++ b/tools/magma_create.cpp @@ -0,0 +1,40 @@ +// This will create 7 deep magama on the square the cursor is on. It does not +// enable magma buildings at this time. + +#include +#include +#include +using namespace std; + +#include +#include + +int main (void) +{ + uint32_t x,y,z; + DFHack::designations40d designations; + + DFHack::API DF("Memory.xml"); + if(!DF.Attach()) + { + cerr << "DF not found" << endl; + return 1; + } + DF.InitMap(); + + DF.getCursorCoords(x,y,z); + + DF.ReadDesignations((x/16),(y/16),(z/16), &designations); + + + designations[x%16][y%16].bits.flow_size = 7; + designations[x%16][y%16].bits.liquid_type = liquid_magma; + + + DF.Detach(); + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; + cin.ignore(); + #endif + return 0; +} From 811233746c344eb119ac28010104b6bcde77ef4d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 25 Mar 2010 16:48:09 -0500 Subject: [PATCH 2/8] partially working now, does not have a compile error --- tools/magma_create.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index 6679d7698..e697b7146 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -11,8 +11,8 @@ using namespace std; int main (void) { - uint32_t x,y,z; - DFHack::designations40d designations; + int32_t x,y,z; + DFHack::designations40d designations; DFHack::API DF("Memory.xml"); if(!DF.Attach()) @@ -22,15 +22,17 @@ int main (void) } DF.InitMap(); - DF.getCursorCoords(x,y,z); + if(DF.getCursorCoords(x,y,z)) + { + if(DF.isValidBlock(x,y,z)) + { + DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - - - designations[x%16][y%16].bits.flow_size = 7; - designations[x%16][y%16].bits.liquid_type = liquid_magma; - - + designations[x%16][y%16].bits.flow_size = 7; + designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; + DF.WriteDesignations(x,y,z, &designations); + } + } DF.Detach(); #ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; From ba5ebf9efb096485fcc4646beda7e6342f0fb5e3 Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 16:53:35 -0500 Subject: [PATCH 3/8] another temp code for review --- tools/magma_create.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index e697b7146..5acd3cc22 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -15,6 +15,7 @@ int main (void) DFHack::designations40d designations; DFHack::API DF("Memory.xml"); + if(!DF.Attach()) { cerr << "DF not found" << endl; @@ -22,17 +23,22 @@ int main (void) } DF.InitMap(); - if(DF.getCursorCoords(x,y,z)) - { - if(DF.isValidBlock(x,y,z)) - { - DF.ReadDesignations((x/16),(y/16),(z/16), &designations); + if (DF.InitViewAndCursor()) + { + if(DF.getCursorCoords(x,y,z)) + { + if(DF.isValidBlock(x,y,z)) + { + DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - designations[x%16][y%16].bits.flow_size = 7; - designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; - DF.WriteDesignations(x,y,z, &designations); + designations[x%16][y%16].bits.flow_size = 7; + designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; + DF.WriteDesignations(x,y,z, &designations); + } } } + else + cout << "Process Failed" << endl; DF.Detach(); #ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; From da6874d7250110a61eb426e6f986be2547e1fbd4 Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 16:59:46 -0500 Subject: [PATCH 4/8] another temp code for review --- tools/magma_create.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index 5acd3cc22..878eb175f 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -30,10 +30,11 @@ int main (void) if(DF.isValidBlock(x,y,z)) { DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - + cout << x%16; designations[x%16][y%16].bits.flow_size = 7; designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; DF.WriteDesignations(x,y,z, &designations); + cout << "Success" << endl; } } } From 57689b18aba5fd8743e3a531f4954d53902025ec Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 17:04:29 -0500 Subject: [PATCH 5/8] another temp code for review --- tools/magma_create.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index 878eb175f..f05706276 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -21,12 +21,11 @@ int main (void) cerr << "DF not found" << endl; return 1; } - DF.InitMap(); if (DF.InitViewAndCursor()) { if(DF.getCursorCoords(x,y,z)) - { + { if(DF.isValidBlock(x,y,z)) { DF.ReadDesignations((x/16),(y/16),(z/16), &designations); @@ -36,7 +35,11 @@ int main (void) DF.WriteDesignations(x,y,z, &designations); cout << "Success" << endl; } + else + cout << "Failure 1" << endl; } + else + cout << "Failure 1" << endl; } else cout << "Process Failed" << endl; From 9acf33d80f406160c44687526c551435621fb34d Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 17:12:05 -0500 Subject: [PATCH 6/8] another temp code for review --- tools/magma_create.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index f05706276..4993fbc9c 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -21,15 +21,17 @@ int main (void) cerr << "DF not found" << endl; return 1; } + DF.InitMap(); if (DF.InitViewAndCursor()) { if(DF.getCursorCoords(x,y,z)) { + cout << "cursor coords: " << x << "/" << y << "/" << z << endl; if(DF.isValidBlock(x,y,z)) { DF.ReadDesignations((x/16),(y/16),(z/16), &designations); - cout << x%16; + designations[x%16][y%16].bits.flow_size = 7; designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; DF.WriteDesignations(x,y,z, &designations); @@ -39,7 +41,7 @@ int main (void) cout << "Failure 1" << endl; } else - cout << "Failure 1" << endl; + cout << "Failure 2" << endl; } else cout << "Process Failed" << endl; From 0b1c3ea469ffe18d322ce09602f055bb45957818 Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 17:31:43 -0500 Subject: [PATCH 7/8] another temp code for review --- tools/magma_create.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/magma_create.cpp b/tools/magma_create.cpp index 4993fbc9c..eaedbad08 100644 --- a/tools/magma_create.cpp +++ b/tools/magma_create.cpp @@ -28,13 +28,13 @@ int main (void) if(DF.getCursorCoords(x,y,z)) { cout << "cursor coords: " << x << "/" << y << "/" << z << endl; - if(DF.isValidBlock(x,y,z)) + if(DF.isValidBlock(x/16,y/16,z)) { DF.ReadDesignations((x/16),(y/16),(z/16), &designations); designations[x%16][y%16].bits.flow_size = 7; designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma; - DF.WriteDesignations(x,y,z, &designations); + DF.WriteDesignations(x/16,y/16,z, &designations); cout << "Success" << endl; } else From 504730c260c88820cecfe6239224fef3b1455f3c Mon Sep 17 00:00:00 2001 From: NMLittle Date: Thu, 25 Mar 2010 17:32:04 -0500 Subject: [PATCH 8/8] another temp code for review --- tools/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9eb8fa50e..0e53d3495 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -35,6 +35,9 @@ TARGET_LINK_LIBRARIES(dfdigger dfhack) ADD_EXECUTABLE(dfitemdesignator itemdesignator.cpp) TARGET_LINK_LIBRARIES(dfitemdesignator dfhack) +# a magma creation toold +ADD_EXECUTABLE(dfmagma_create magma_create.cpp) +TARGET_LINK_LIBRARIES(dfmagma_create dfhack) IF(UNIX) install(TARGETS