From 09620b65fbe65f6b04a4544b5e3876981c6c0208 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Mon, 5 May 2014 15:13:32 +1000 Subject: [PATCH 1/6] delete obsolete plugins, add notes +new dfstatus The new dfstatus script needs some work on magic numbers before it moves to the scripts folder; the notes file contains my notes on further things to delete. --- needs_porting/_notes.txt | 72 ++++++++ needs_porting/dfstatus.cpp | 206 --------------------- needs_porting/dfstatus.lua | 110 +++++++++++ needs_porting/digger.cpp | 363 ------------------------------------- needs_porting/digger2.cpp | 180 ------------------ needs_porting/fix-3708.cpp | 217 ---------------------- needs_porting/lair.cpp | 74 -------- needs_porting/reveal.py | 93 ---------- needs_porting/veinswap.cpp | 229 ----------------------- 9 files changed, 182 insertions(+), 1362 deletions(-) create mode 100644 needs_porting/_notes.txt delete mode 100644 needs_porting/dfstatus.cpp create mode 100644 needs_porting/dfstatus.lua delete mode 100644 needs_porting/digger.cpp delete mode 100644 needs_porting/digger2.cpp delete mode 100644 needs_porting/fix-3708.cpp delete mode 100644 needs_porting/lair.cpp delete mode 100644 needs_porting/reveal.py delete mode 100644 needs_porting/veinswap.cpp diff --git a/needs_porting/_notes.txt b/needs_porting/_notes.txt new file mode 100644 index 000000000..04e123228 --- /dev/null +++ b/needs_porting/_notes.txt @@ -0,0 +1,72 @@ +Notes by PeridexisErrant, on the needs_porting scripts and plugins: + +I've deleted "reveal", "lair", and "dfstatus.cpp" - they've been replaced by other more recent versions. (I added the dfstatus script). +Also deleted "digger", less useful than "digger2" and generally replaced by autochop. "digger2" is replaced by digfort. +And now "veinswap"; replaced by "changevein". "fix-3708.cpp" deals with a bug that the Mantis tracker marks as resolved. + + +Need confirmation that they're obsolete before deleting (notes below): +attachtest.py, dfbauxtite.cpp, digpattern.cpp, drawtile.cpp, treedump.py, and veinlook.cpp + +To port: +copypaste.cpp, hellhole.cpp, hotkeynotedump.py, itemdesignator.cpp (partial), position.py + + +All undeleted plugins: + +attachtest.py +- checks if dfhack is working with DF (i think) +- definitely replaced on windows, pretty sure also on other platforms + +copypaste.cpp +- a proof-of-concept plugin to allow copy-pasting in DF +- if I read it right, it does both terrain and buildings/constructions +- would be awesome if someone ported it! + +creaturemanager.cpp +- Display creatures; modify skills and labors of creatures; kill creatures; etc +- looks pretty impressive if incomplete (at 1500 lines I only looked over the comments) +- could maybe do with porting, but it's unfinished and I suspect that most functions are available elsewhere + +dfbauxtite.cpp +- as far as I can tell, this plugin changes the material of all mechanisms (printed string 'mechanisms', class 'item_trapparts') to Bauxtite; presumably from when this was the only magma-safe stone. +- I don't know of a newer alternative, but it's not really neccessary anymore + +digpattern.cpp +- I think all this one does is allow multi-z designations - no longer required. + +drawtile.cpp +- draws changes to tiles +- I think this is replaced by tiletypes, but not sure + +hellhole.cpp +- digs a hole to HFS instantly +- no known equivilant, needs porting + +hotkeynotedump.py +- outputs a list of hotkeys with names +- less useful with propper dfhack keybindings available, but still useful +- trivial to redo in lua (it's 20 lines, could be 10) + +incrementalsearch.cpp +- linux-only memory voodoo; leaving this alone + +itemdesignator.cpp +- applies flags to categories of items (eg item_microcline; forbid/dump/melt/on fire) +- appart from fire, replaced by Falconne's enhanced stocks screen +- port the fire part? + +position.py +- prints information about time (year/month/day/tick) and place (embark location/cursor pos) and window size +- the wider context can be written to gamelog on world load by "log-region.lua"; this doesn't seem to be included yet + +SegementedFinder.h +- no idea what's happening here + +treedump.py +- looks like it outputs a list of trees in a given volume +- overlaps with 'prospect' and 'autochop'; probably does not need porting + +veinlook.cpp +- I'm not sure what this does that "digv" and "reveal" don't but there must be something since it was around at the same time as reveal. + diff --git a/needs_porting/dfstatus.cpp b/needs_porting/dfstatus.cpp deleted file mode 100644 index 91c6f6589..000000000 --- a/needs_porting/dfstatus.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * dfstatus.cpp -*/ - -#include - -#ifndef LINUX_BUILD - #include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include //to break on keyboard input -#include -#include -#include -using namespace std; -#include -#include -#include - -WINDOW *create_newwin(int height, int width, int starty, int startx); - - int32_t drinkCount = 0; - int32_t mealsCount = 0; - int32_t plantCount = 0; - int32_t fishCount = 0; - int32_t meatCount = 0; - int32_t logsCount = 0; - int32_t barCount = 0; - int32_t clothCount = 0; - int32_t ironBars = 0; - int32_t pigIronBars = 0; - int32_t goldBars = 0; - int32_t silverBars = 0; - int32_t copperBars = 0; - int32_t steelBars = 0; - int32_t fuel = 0; - uint64_t start_time = 0; - uint64_t end_time = 0; - uint64_t total_time = 0; - -WINDOW *create_newwin(int height, int width, int starty, int startx){ - WINDOW *local_win; - - local_win = newwin(height, width, starty, startx); - box(local_win, 0, 0); /* 0, 0 gives default characters - * for the vertical and horizontal - * lines */ - //first row - mvwprintw(local_win,2 ,2,"Drinks : %d", drinkCount); - mvwprintw(local_win,4 ,2,"Meals : %d", mealsCount); - mvwprintw(local_win,6 ,2,"Plants : %d", plantCount); - mvwprintw(local_win,7 ,2,"Fish : %d", fishCount); - mvwprintw(local_win,8 ,2,"Meat : %d", meatCount); - mvwprintw(local_win,10,2,"Logs : %d", logsCount); - mvwprintw(local_win,12,2,"Cloth : %d", clothCount); - //second row - mvwprintw(local_win,2,22,"Iron Bars : %d", ironBars); - mvwprintw(local_win,3,22,"Gold Bars : %d", goldBars); - mvwprintw(local_win,4,22,"Silver Bars : %d", silverBars); - mvwprintw(local_win,5,22,"Copper Bars : %d", copperBars); - mvwprintw(local_win,6,22,"Steel Bars : %d", steelBars); - mvwprintw(local_win,7,22,"Pig iron Bars : %d", pigIronBars); - mvwprintw(local_win,9,22,"Fuel : %d", fuel); - total_time += end_time - start_time; - mvwprintw(local_win,14,2,"Time: %d ms last update, %d ms total", end_time - start_time, total_time); - - wrefresh(local_win); // paint the screen and all components. - - return local_win; -} - -int main() -{ - WINDOW *my_win; - int startx, starty, width, height; - - DFHack::Process * p; - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context * DF; - DFHack::Materials * Materials; - try{ //is DF running? - DF = DFMgr.getSingleContext(); - DF->Attach(); - Materials = DF->getMaterials(); - Materials->ReadAllMaterials(); - DF->Resume(); - } - catch (exception& e){ - cerr << e.what() << endl; - return 1; - } - //init and Attach - ofstream file("dfstatus_errors.txt"); - streambuf* strm_buffer = cerr.rdbuf(); // save cerr's output buffer - cerr.rdbuf (file.rdbuf()); // redirect output into the file - - initscr(); //start curses. - nonl(); - intrflush(stdscr, FALSE); - keypad(stdscr, TRUE); - do{ - drinkCount = 0; - mealsCount = 0; - plantCount = 0; - fishCount = 0; - meatCount = 0; - logsCount = 0; - barCount = 0; - clothCount = 0; - ironBars = 0; - pigIronBars = 0; - goldBars = 0; - silverBars = 0; - copperBars = 0; - steelBars = 0; - fuel = 0; - - //FILE * pFile; - //pFile = fopen("dump.txt","w"); - start_time = GetTimeMs64(); - if(!DF->Suspend()) - { - break; - } - - //DFHack::Gui * Gui = DF->getGui(); - - DFHack::Items * Items = DF->getItems(); - Items->Start(); - - DFHack::VersionInfo * mem = DF->getMemoryInfo(); - p = DF->getProcess(); - - DFHack::OffsetGroup* itemGroup = mem->getGroup("Items"); - DFHack::DfVector p_items (p, itemGroup->getAddress("items_vector")); - uint32_t size = p_items.size(); - - DFHack::dfh_item itm; //declare itm - //memset(&itm, 0, sizeof(DFHack::dfh_item)); //seems to set every value in itm to 0 - - for(unsigned int idx = 0; idx < size; idx++) //fill our item variables with this loop - { - Items->readItem(p_items[idx], itm); - - if (itm.base.flags.owned) //only count what we actually own. - continue; - - string s0 = Items->getItemClass(itm.matdesc.itemType).c_str(); - string s1 = Items->getItemDescription(itm, Materials).c_str(); - - if( s0 == "drink" ) {drinkCount += itm.quantity;} - else if(s0 == "food"){mealsCount += itm.quantity;} - else if(s0 == "plant"){plantCount += itm.quantity;} - else if(s0 == "fish"){fishCount += itm.quantity;} - else if(s0 == "meat"){meatCount += itm.quantity;} - else if(s0 == "wood"){logsCount += itm.quantity;} - else if(s0 == "cloth"){clothCount += itm.quantity;} - else if(s0 == "bar") //need to break it down by ItemDescription to get the different types of bars. - { - barCount = barCount + itm.quantity; - if(s1.find("PIG_IRON")!=string::npos){pigIronBars++;} - else if(s1.find("IRON")!=string::npos){ironBars++;} - else if(s1.find("GOLD")!=string::npos){goldBars++;} - else if(s1.find("SILVER")!=string::npos){silverBars++;} - else if(s1.find("COPPER")!=string::npos){copperBars++;} - else if(s1.find("STEEL")!=string::npos){steelBars++;} - else if(s1.find("COAL")!=string::npos){fuel++;} - } - /*if(s0 != "boulder" && s0 != "thread"){ - fprintf(pFile,"%5d: %12s - %64s - [%d]\n", idx, Items->getItemClass(itm.matdesc.itemType).c_str(), Items->getItemDescription(itm, Materials).c_str(), itm.quantity); - }*/ - } - DF->Resume(); - end_time = GetTimeMs64(); - //printf("%d - %d\n", (clock()/CLOCKS_PER_SEC),(clock()/CLOCKS_PER_SEC)%60); - height = LINES; - width = COLS; - starty = (LINES - height) / 2; - startx = (COLS - width) / 2; - - my_win = create_newwin(height, width, starty, startx); - -#ifdef LINUX_BUILD - sleep(10); -#else - Sleep(10000); -#endif - - } while(true); - - endwin(); /* End curses mode */ - cerr.rdbuf (strm_buffer); // restore old output buffer - file.close(); - - return 0; -} \ No newline at end of file diff --git a/needs_porting/dfstatus.lua b/needs_porting/dfstatus.lua new file mode 100644 index 000000000..180d2afa3 --- /dev/null +++ b/needs_porting/dfstatus.lua @@ -0,0 +1,110 @@ +-- dfstatus 1.04 - a quick access status screen. +-- written by enjia2000@gmail.com + +local gui = require 'gui' + +function draw() + screen2 = gui.FramedScreen{ + frame_style = gui.GREY_LINE_FRAME, + frame_title = 'dfstatus', + frame_width = 16, + frame_height = 17, + frame_inset = 1, + } +end + +if (not shown) then + draw() + screen2:show() + shown = true +else + shown = nil + screen2:dismiss() +end + +function screen2:onRenderBody(dc) + local drink = 0 + local wood = 0 + --local meat = 0 + --local raw_fish = 0 + --local plants = 0 + local prepared_meals = 0 + + local fuel = 0 + local pigiron = 0 + local iron = 0 + local steel = 0 + + local silver = 0 + local copper = 0 + local gold = 0 + + local tannedhides = 0 + local cloth = 0 + + for _,item in ipairs(df.global.world.items.all) do + if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid and not item.flags.in_building and not item.flags.trader) then + if (item:getType() == 5) then wood = wood + item:getStackSize() + elseif (item:getType() == 68) then drink = drink + item:getStackSize() + elseif (item:getType() == 54) then tannedhides = tannedhides + item:getStackSize() + elseif (item:getType() == 57) then cloth = cloth + item:getStackSize() + --elseif (item:getType() == 47) then meat = meat + item:getStackSize() + --elseif (item:getType() == 49) then raw_fish = raw_fish + item:getStackSize() + --elseif (item:getType() == 53) then plants = plants + item:getStackSize() + elseif (item:getType() == 71) then prepared_meals = prepared_meals + item:getStackSize() + elseif (item:getType() == 0) then + for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do + if (token == "silver") then silver = silver + item:getStackSize() + elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() + elseif (token == "iron") then iron = iron + item:getStackSize() + elseif (token == "pig") then pigiron = pigiron + item:getStackSize() + elseif (token == "copper") then copper = copper + item:getStackSize() + elseif (token == "gold") then gold = gold + item:getStackSize() + elseif (token == "steel") then steel = steel + item:getStackSize() + end + break -- only need to look at the 1st token of each item. + end + end + end + end + dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) + dc:newline(0) + --dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) + --dc:newline(0) + --dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) + --dc:newline(0) + dc:newline(0) + dc:string("Bars:", COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:newline(1) + dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) +end + +function screen2:onInput(keys) + if keys.LEAVESCREEN or keys.SELECT then + shown = nil + self:dismiss() + end +end diff --git a/needs_porting/digger.cpp b/needs_porting/digger.cpp deleted file mode 100644 index 86a9b84b2..000000000 --- a/needs_porting/digger.cpp +++ /dev/null @@ -1,363 +0,0 @@ -// digger.cpp - -// NOTE currently only works with trees - -// TODO add a sort of "sub-target" to dig() to make it able to designate stone as well - -#include -#include -#include -#include -#include -#include -using namespace std; - -#include -#include -#include - -// counts the occurances of a certain element in a vector -// used to determine of a given tile is a target -int vec_count(vector& vec, uint16_t t) -{ - int count = 0; - for (uint32_t i = 0; i < vec.size(); ++i) - { - if (vec[i] == t) - ++count; - } - return count; -} - -// splits a string on a certain char -// -// src is the string to split -// delim is the delimiter to split the string around -// tokens is filled with every occurance between delims -void string_split(vector& tokens, const std::string& src, const std::string& delim) -{ - std::string::size_type start = 0; - std::string::size_type end; - while (true) - { - end = src.find(delim, start); - tokens.push_back(src.substr(start, end - start)); - if (end == std::string::npos) // last token handled - break; - start = end + delim.size(); // skip next delim - } -} - -// this is used to parse the command line options -void parse_int_csv(vector& targets, const std::string& src) -{ - std::string::size_type start = 0; - std::string::size_type end; - while (true) - { - end = src.find(",", start); - targets.push_back(atoi(src.substr(start, end - start).c_str())); - if (end == std::string::npos) // last token handled - break; - start = end + 1; // skip next delim - } -} - -struct DigTarget -{ - DigTarget() : - source_distance(0), - grid_x(0), grid_y(0), - local_x(0), local_y(0), - real_x(0), real_y(0), z(0) - { - } - - DigTarget( - int realx, int realy, int _z, - int sourcex, int sourcey, int sourcez) : - real_x(realx), real_y(realy), z(_z) - { - grid_x = realx/16; - grid_y = realy/16; - - local_x = realx%16; - local_y = realy%16; - - source_distance = manhattan_distance( - real_x, real_y, z, - sourcex, sourcey, sourcez); - } - - DigTarget( - int gridx, int gridy, int _z, - int localx, int localy, - int sourcex, int sourcey, int sourcez) : - grid_x(gridx), grid_y(gridy), - local_x(localx), local_y(localy), - z(_z) - { - real_x = (grid_x*16)+local_x; - real_y = (grid_y*16)+local_y; - - source_distance = manhattan_distance( - real_x, real_y, z, - sourcex, sourcey, sourcez); - } - - int source_distance; // the distance to the source coords, used for sorting - - int grid_x, grid_y; // what grid the target is in - int local_x, local_y; // on what coord in the grid the target is in (0-16) - int real_x, real_y; // real coordinates for target, thats grid*16+local - int z; // z position for target, stored plain since there arent z grids - - bool operator<(const DigTarget& o) const { return source_distance < o.source_distance; } - -private: - // calculates the manhattan distance between two coords - int manhattan_distance(int x, int y, int z, int xx, int yy, int zz) - { - return abs(x-xx)+abs(y-yy)+abs(z-zz); - } -}; - -int dig(DFHack::Maps* Maps, - vector& targets, - int num = -1, - const int x_source = 0, - const int y_source = 0, - const int z_source = 0, - bool verbose = false) -{ - if (num == 0) - return 0; // max limit of 0, nothing to do - - uint32_t x_max,y_max,z_max; - DFHack::designations40d designations; - DFHack::tiletypes40d tiles; - Maps->getSize(x_max,y_max,z_max); - - // every tile found, will later be sorted by distance to source - vector candidates; - - if (verbose) - cout << "source is " << x_source << " " << y_source << " " << z_source << endl; - - // walk the map - for(uint32_t x = 0; x < x_max; x++) - { - for(uint32_t y = 0; y < y_max; y++) - { - for(uint32_t z = 0; z < z_max; z++) - { - if(Maps->isValidBlock(x,y,z)) - { - // read block designations and tiletype - Maps->ReadDesignations(x,y,z, &designations); - Maps->ReadTileTypes(x,y,z, &tiles); - - // search all tiles for dig targets: - // visible, not yet marked for dig and matching tile type - for(uint32_t lx = 0; lx < 16; lx++) - { - for(uint32_t ly = 0; ly < 16; ly++) - { - if (/*designations[lx][ly].bits.hidden == 0 && */ - designations[lx][ly].bits.dig == 0 && - vec_count(targets, DFHack::tileShape(tiles[lx][ly])) > 0) - { - DigTarget dt( - x, y, z, - lx, ly, - x_source, y_source, z_source); - candidates.push_back(dt); - - if (verbose) - { - cout << "target found at " << dt.real_x << " " << dt.real_y << " " << dt.z; - cout << ", " << dt.source_distance << " tiles to source" << endl; - } - } - } // local y - } // local x - } - } - } - } - - // if we found more tiles than was requested, sort them by distance to source, - // keep the front 'num' elements and drop the rest - if (num != -1 && candidates.size() > (unsigned int)num) - { - sort(candidates.begin(), candidates.end()); - candidates.resize(num); - } - num = candidates.size(); - - if (verbose) - cout << "=== proceeding to designating targets ===" << endl; - - // mark the tiles for actual digging - for (vector::const_iterator i = candidates.begin(); i != candidates.end(); ++i) - { - if (verbose) - { - cout << "designating at " << (*i).real_x << " " << (*i).real_y << " " << (*i).z; - cout << ", " << (*i).source_distance << " tiles to source" << endl; - } - - // TODO this could probably be made much better, theres a big chance the trees are on the same grid - Maps->ReadDesignations((*i).grid_x, (*i).grid_y, (*i).z, &designations); - designations[(*i).local_x][(*i).local_y].bits.dig = DFHack::designation_default; - Maps->WriteDesignations((*i).grid_x, (*i).grid_y, (*i).z, &designations); - - // Mark as dirty so the jobs are properly picked up by the dwarves - Maps->WriteDirtyBit((*i).grid_x, (*i).grid_y, (*i).z, true); - } - - return num; -} - -void test() -{ - ////////////////////////// - // DigTarget - { - DigTarget dt( - 20, 35, 16, - 10, 12, 14); - - assert(dt.grid_x == 1); - assert(dt.grid_y == 2); - - assert(dt.local_x == 4); - assert(dt.local_y == 3); - - assert(dt.real_x == 20); - assert(dt.real_y == 35); - - assert(dt.z == 16); - assert(dt.source_distance == 35); - } - { - DigTarget dt( - 2, 4, 16, - 5, 10, - 10, 12, 14); - - assert(dt.grid_x == 2); - assert(dt.grid_y == 4); - - assert(dt.local_x == 5); - assert(dt.local_y == 10); - - assert(dt.real_x == 37); - assert(dt.real_y == 74); - - assert(dt.z == 16); - assert(dt.source_distance == 91); - } - - ////////////////////////// - // string splitter - { - vector tokens; - string src = "10,9,11"; - string delim = ","; - string_split(tokens, src, delim); - - assert(tokens.size() == 3); - assert(tokens[0] == "10"); - assert(tokens[1] == "9"); - assert(tokens[2] == "11"); - } - { - vector tokens; - string src = "10"; - string delim = ","; - string_split(tokens, src, delim); - - assert(tokens.size() == 1); - assert(tokens[0] == "10"); - } - { - vector targets; - parse_int_csv(targets, "9,10"); - assert(targets[0] == 9); - assert(targets[1] == 10); - } -} - -int main (int argc, char** argv) -{ - //test(); - - // Command line options - string s_targets; - string s_origin; - bool verbose; - int max = 10; - argstream as(argc,argv); - - as >>option('v',"verbose",verbose,"Active verbose mode") - >>parameter('o',"origin",s_origin,"Close to where we should designate targets, format: x,y,z") - >>parameter('t',"targets",s_targets,"What kinds of tile we should designate, format: type1,type2") - >>parameter('m',"max",max,"The maximum limit of designated targets") - >>help(); - - // some commands need extra care - vector targets; - parse_int_csv(targets, s_targets); - - vector origin; - parse_int_csv(origin, s_origin); - - // sane check - if (!as.isOk()) - { - cout << as.errorLog(); - } - else if (targets.size() == 0 || origin.size() != 3) - { - cout << as.usage(); - } - else - { - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context *DF = DFMgr.getSingleContext(); - try - { - DF->Attach(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - DFHack::Maps *Maps = DF->getMaps(); - if (Maps && Maps->Start()) - { - int count = dig(Maps, targets, max, origin[0],origin[1],origin[2], verbose); - cout << count << " targets designated" << endl; - Maps->Finish(); - - if (!DF->Detach()) - { - cerr << "Unable to detach DF process" << endl; - } - } - else - { - cerr << "Unable to init map" << endl; - } - } - #ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); - #endif - return 0; -} diff --git a/needs_porting/digger2.cpp b/needs_porting/digger2.cpp deleted file mode 100644 index ea34b8c2c..000000000 --- a/needs_porting/digger2.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/** - * @file digger2.cpp - * @author rOut - * - * Improved digger tool. - * - * Takes a text file as first an only argument. - * The text file is read as a grid, and every character represents a designation for a tile. - * Allowed characters are 'd' for dig, 'u' for up stairs, 'j' for down stairs, 'i' for up and down stairs, 'h' for channel, 'r' for upward ramp and 'x' to remove designation. - * Other characters don't do anything and can be used for padding. - * The designation pattern is the wrote in game memory, centered on the current cursor position. Thus, the game needs to be in designation mode or, perhaps, any other mode that have a cursor. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -#include -#include -#define BLOCK_SIZE 16 - - -void dig(DFHack::Maps* layers, DFHack::Gui* Gui, ::std::vector< ::std::string >& dig_map, bool verbose = false) -{ - int32_t x_cent; - int32_t y_cent; - int32_t z_cent; - Gui->getCursorCoords(x_cent, y_cent, z_cent); - -// ::std::cout << "x_cent: " << x_cent << " y_cent: " << y_cent << " z_cent: " << z_cent << ::std::endl; - - int32_t z_from = z_cent; - int32_t z = 0; - - uint32_t x_max; - uint32_t y_max; - uint32_t z_max; - layers->getSize(x_max, y_max, z_max); - -// ::std::cout << "x_max: " << x_max << " y_max: " << y_max << " z_max: " << z_max << ::std::endl; - - int32_t dig_height = dig_map.size(); - int32_t y_from = y_cent - (dig_height / 2); -// ::std::cout << "dig_height: " << dig_height << ::std::endl; -// ::std::cout << "y_from: " << y_from << ::std::endl; - - int32_t y = 0; - DFHack::designations40d designations; - DFHack::tiletypes40d tiles; - ::std::vector< ::std::string >::iterator str_it; - for (str_it = dig_map.begin(); str_it != dig_map.end(); ++str_it) { - int32_t dig_width = str_it->size(); - int32_t x_from = x_cent - (dig_width / 2); - -// ::std::cout << "x_cent: " << x_cent << " y_cent: " << y_cent << " z_cent: " << z_cent << ::std::endl; -// ::std::cout << "dig_width: " << dig_width << ::std::endl; -// ::std::cout << "x_from: " << x_from << ::std::endl; - - int32_t x = 0; - ::std::string::iterator chr_it; - for (chr_it = str_it->begin(); chr_it != str_it ->end(); ++chr_it) - { - int32_t x_grid = (x_from + x) / BLOCK_SIZE; - int32_t y_grid = (y_from + y) / BLOCK_SIZE; - int32_t z_grid = z_from + z; - int32_t x_locl = (x_from + x) - x_grid * BLOCK_SIZE; - int32_t y_locl = (y_from + y) - y_grid * BLOCK_SIZE; - int32_t z_locl = 0; - - if (x_grid >= 0 && y_grid >= 0 && x_grid < x_max && y_grid < y_max) - { - // TODO this could probably be made much better, theres a big chance the trees are on the same grid - layers->ReadDesignations(x_grid, y_grid, z_grid, &designations); - layers->ReadTileTypes(x_grid, y_grid, z_grid, &tiles); - -// ::std::cout << ::std::hex << "designations: " << designations[x_locl][y_locl].bits.dig << ::std::dec << ::std::endl; - DFHack::naked_designation & des = designations[x_locl][y_locl].bits; - if ( DFHack::tileShape(tiles[x_locl][y_locl]) == DFHack::WALL) - { - switch ((char) *chr_it) - { - case 'd': - des.dig = DFHack::designation_default; - break; - case 'u': - des.dig = DFHack::designation_u_stair; - break; - case 'j': - des.dig = DFHack::designation_d_stair; - break; - case 'i': - des.dig = DFHack::designation_ud_stair; - break; - case 'h': - des.dig = DFHack::designation_channel; - break; - case 'r': - des.dig = DFHack::designation_ramp; - break; - case 'x': - des.dig = DFHack::designation_no; - break; - } - - if (verbose) - { - ::std::cout << "designating " << (char) *chr_it << " at " << x_from + x << " " << y_from + y << " " << z_from + z << ::std::endl; - } - - layers->WriteDesignations(x_grid, y_grid, z_grid, &designations); - - // Mark as dirty so the jobs are properly picked up by the dwarves - layers->WriteDirtyBit(x_grid, y_grid, z_grid, true); - } - } - - ++x; - } - ++y; - } -} - -int main(int argc, char** argv) { - if(argc < 2) { - ::std::cout << "gimme a file!" << ::std::endl; - return 1; - } - - ::std::ifstream map_in(argv[1]); - - ::std::vector< ::std::string > dig_map; - while (map_in.good() && !map_in.eof() && !map_in.bad()) { - ::std::string line; - map_in >> line; - - dig_map.push_back(line); - } - dig_map.resize(dig_map.size() - 1); - - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context * DF = DFMgr.getSingleContext(); - - try { - DF->Attach(); - } catch (::std::exception& e) { - ::std::cerr << e.what() << ::std::endl; -#ifndef LINUX_BUILD - ::std::cin.ignore(); -#endif - return 1; - } - - DFHack::Maps *layers = DF->getMaps(); - if (layers && layers->Start()) { - - dig(layers, DF->getGui(), dig_map, true); - - ::std::cout << "Finished digging" << ::std::endl; - layers->Finish(); - - if (!DF->Detach()) { - ::std::cerr << "Unable to detach DF process" << ::std::endl; - } - - } else { - ::std::cerr << "Unable to init map" << ::std::endl; - } - -#ifndef LINUX_BUILD - ::std::cout << "Done. Press any key to continue" << ::std::endl; - ::std::cin.ignore(); -#endif - return 0; -} diff --git a/needs_porting/fix-3708.cpp b/needs_porting/fix-3708.cpp deleted file mode 100644 index 2cfaed912..000000000 --- a/needs_porting/fix-3708.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* Fixes bug 3708 (Ghosts that can't be engraved on a slab). - - Cause of the bug: - - In order to be engraved on a slab, the creature must be - a historical figure, i.e. be in the historical figure list - of the Legends mode. It seems that caravan guards are not - added to that list until they do something notable, e.g. - kill a goblin. Unfortunately, their own death doesn't - trigger this sometimes. - - Solution: - - Steal a historical figure entry from a dead goblin, by - replacing the IDs in the structures; also overwrite his - name, race and profession to make the menus make slightly - more sense. - - Downsides: - - - Obviously, this is an ugly hack. - - The Legends mode still lists the guard as belonging to - the goblin civilization, and killed by whoever killed the - original goblin. There might be other inconsistencies. - - Positive sides: - - - Avoids messing with tricky creature control code, - by allowing the ghost to be removed naturally. - */ - -#include -#include -#include -#include -#include -#include -using namespace std; - -#define DFHACK_WANT_MISCUTILS -#include - -enum likeType -{ - FAIL = 0, - MATERIAL = 1, - ITEM = 2, - FOOD = 3 -}; - -DFHack::Materials * Materials; -DFHack::VersionInfo *mem; -DFHack::Creatures * Creatures = NULL; - -void printCreature(DFHack::Context * DF, const DFHack::t_creature & creature) -{ - cout << "Address: " << hex << creature.origin << dec << ", creature race: " << Materials->raceEx[creature.race].rawname - << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl - << "Name: " << creature.name.first_name; - - if (creature.name.nickname[0]) - cout << " `" << creature.name.nickname << "'"; - - DFHack::Translation * Tran = DF->getTranslation(); - - cout << " " << Tran->TranslateName(creature.name,false) - << " (" << Tran->TranslateName(creature.name,true) << ")" << endl; - - cout << "Profession: " << mem->getProfession(creature.profession); - - if(creature.custom_profession[0]) - cout << ", custom: " << creature.custom_profession; - - uint32_t dayoflife = creature.birth_year*12*28 + creature.birth_time/1200; - cout << endl - << "Born on the year " << creature.birth_year - << ", month " << (creature.birth_time/1200/28) - << ", day " << ((creature.birth_time/1200) % 28 + 1) - << ", " << dayoflife << " days lived." << endl << endl; -} - - -int main (int numargs, char ** args) -{ - DFHack::World * World; - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context* DF; - try - { - DF = DFMgr.getSingleContext(); - DF->Attach(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - Creatures = DF->getCreatures(); - Materials = DF->getMaterials(); - World = DF->getWorld(); - DFHack::Translation * Tran = DF->getTranslation(); - - uint32_t numCreatures; - if(!Creatures->Start(numCreatures)) - { - cerr << "Can't get creatures" << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - Materials->ReadCreatureTypes(); - Materials->ReadCreatureTypesEx(); - - mem = DF->getMemoryInfo(); - DFHack::Process *p = DF->getProcess(); - - if(!Tran->Start()) - { - cerr << "Can't get name tables" << endl; - return 1; - } - - DFHack::OffsetGroup *ogc = mem->getGroup("Creatures")->getGroup("creature"); - uint32_t o_flags3 = ogc->getOffset("flags3"); - uint32_t o_c_hfid = ogc->getGroup("advanced")->getOffset("hist_figure_id"); - - std::list goblins; - std::list ghosts; - - for(uint32_t i = 0; i < numCreatures; i++) - { - DFHack::t_creature temp; - Creatures->ReadCreature(i,temp); - - int32_t hfid = p->readDWord(temp.origin + o_c_hfid); - - if (hfid > 0) { - if (temp.flags1.bits.dead) { - std::string name = Materials->raceEx[temp.race].rawname; - if (name == "GOBLIN") - goblins.push_back(i); - } - } else { - uint32_t flags3 = p->readDWord(temp.origin + o_flags3); - if (!(flags3 & 0x1000)) - continue; - - ghosts.push_back(i); - } - } - - if (goblins.size() >= ghosts.size() && ghosts.size() > 0) - { - DFHack::OffsetGroup *grp_figures = mem->getGroup("Legends")->getGroup("figures"); - uint32_t f_vector = p->readDWord(grp_figures->getAddress("vector")); - uint32_t f_id = grp_figures->getOffset("figure_id"); - uint32_t f_unit = grp_figures->getOffset("unit_id"); - uint32_t f_name = grp_figures->getOffset("name"); - uint32_t f_race = grp_figures->getOffset("race"); - uint32_t f_profession = grp_figures->getOffset("profession"); - - for (std::list::iterator it = ghosts.begin(); it != ghosts.end(); ++it) - { - int i = *it; - DFHack::t_creature ghost; - Creatures->ReadCreature(i,ghost); - - printCreature(DF,ghost); - - int igoblin = goblins.front(); - goblins.pop_front(); - DFHack::t_creature goblin; - Creatures->ReadCreature(igoblin,goblin); - - printCreature(DF,goblin); - - int32_t hfid = p->readDWord(goblin.origin + o_c_hfid); - uint32_t fptr = p->readDWord(f_vector + 4*hfid); - - if (p->readDWord(fptr + f_id) != hfid || - p->readDWord(fptr + f_unit) != goblin.id || - p->readWord(fptr + f_race) != goblin.race) - { - cout << "Data structure inconsistency detected, aborting."; - break; - } - - if (1) { - p->writeDWord(goblin.origin + o_c_hfid, -1); - p->writeDWord(ghost.origin + o_c_hfid, hfid); - p->writeDWord(fptr + f_unit, ghost.id); - p->writeWord(fptr + f_race, ghost.race); - p->writeWord(fptr + f_profession, ghost.profession); - Creatures->CopyNameTo(ghost, fptr + f_name); - cout << "Pair succesfully patched." << endl << endl; - } - } - } - else - { - cout << "No suitable ghosts, or not enough goblins." << endl; - } - - Creatures->Finish(); - DF->Detach(); - #ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); - #endif - return 0; -} diff --git a/needs_porting/lair.cpp b/needs_porting/lair.cpp deleted file mode 100644 index 7bf3ddc28..000000000 --- a/needs_porting/lair.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// This is a simple bit writer... it marks the whole map as a creature lair, preventing item scatter. - -#include -#include -#include -using namespace std; -#include -#include - -int main (void) -{ - bool temporary_terminal = TemporaryTerminal(); - uint32_t x_max,y_max,z_max; - DFHack::occupancies40d occupancies; - - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context *DF; - try - { - DF = DFMgr.getSingleContext(); - DF->Attach(); - } - catch (exception& e) - { - cerr << e.what() << endl; - if(temporary_terminal) - cin.ignore(); - return 1; - } - - DFHack::Maps *Maps =DF->getMaps(); - - // init the map - if(!Maps->Start()) - { - cerr << "Can't init map." << endl; - if(temporary_terminal) - cin.ignore(); - return 1; - } - - cout << "Designating, please wait..." << endl; - - Maps->getSize(x_max,y_max,z_max); - for(uint32_t x = 0; x< x_max;x++) - { - for(uint32_t y = 0; y< y_max;y++) - { - for(uint32_t z = 0; z< z_max;z++) - { - if(Maps->isValidBlock(x,y,z)) - { - // read block designations - Maps->ReadOccupancy(x,y,z, &occupancies); - //Maps->ReadTileTypes(x,y,z, &tiles); - // change the monster_lair flag to 1 - for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++) - { - // add tile type chack here - occupancies[i][j].bits.monster_lair = 1; - } - // write the designations back - Maps->WriteOccupancy(x,y,z, &occupancies); - } - } - } - } - if(temporary_terminal) - { - cout << "The map has been marked as a creature lair. Items shouldn't scatter." << endl; - cin.ignore(); - } - return 0; -} diff --git a/needs_porting/reveal.py b/needs_porting/reveal.py deleted file mode 100644 index 268e1a3a8..000000000 --- a/needs_porting/reveal.py +++ /dev/null @@ -1,93 +0,0 @@ -import time -from context import ContextManager - -class HideBlock(object): - __slots__ = [ "x", "y", "z", "hiddens" ] - - def __init__(self, *args, **kwargs): - self.x = 0 - self.y = 0 - self.z = 0 - self.hiddens = [[0 for i in xrange(16)] for j in xrange(16)] - -df_cm = ContextManager("Memory.xml") -df = df_cm.get_single_context() - -df.attach() - -m = df.maps -w = df.world - -print "Pausing..." - -w.start() - -#this mimics the hack in the C++ reveal tool that attempts to ensure that DF isn't in the middle of -#a frame update -w.set_pause_state(True) -df.resume() -time.sleep(1) -df.suspend() - -w.finish() - -m.start() - -print "Revealing, please wait..." - -m_x, m_y, m_z = m.size -hide_blocks = [] - -for x in xrange(m_x): - for y in xrange(m_y): - for z in xrange(m_z): - if m.is_valid_block(x, y, z): - hb = HideBlock() - - hb.x = x - hb.y = y - hb.z = z - - d = m.read_designations(x, y, z) - - for k_i, i in enumerate(d): - for k_j, j in enumerate(i): - hb.hiddens[k_i][k_j] = j.bits.hidden - - j.bits.hidden = 0 - - hide_blocks.append(hb) - - m.write_designations(x, y, z, d) - -m.finish() -df.detach() - -print "Map revealed. The game has been paused for you." -print "Unpausing can unleash the forces of hell!" -print "Press any key to unreveal." -print "Close to keep the map revealed !!FOREVER!!" - -raw_input() - -print "Unrevealing...please wait" - -df.attach() -m = df.maps -m.start() - -for h in hide_blocks: - d = m.read_designations(h.x, h.y, h.z) - - for k_i, i in enumerate(h.hiddens): - for k_j, j in enumerate(i): - d[k_i][k_j].bits.hidden = j - - m.write_designations(h.x, h.y, h.z, d) - -m.finish() - -print "Done. Press any key to continue" -raw_input() - -df.detach() \ No newline at end of file diff --git a/needs_porting/veinswap.cpp b/needs_porting/veinswap.cpp deleted file mode 100644 index 668386100..000000000 --- a/needs_porting/veinswap.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include -#include -#include -using namespace std; - -#include - -#include -#include -#include - - -//Globals -DFHack::Context *DF; -DFHack::Maps *maps; -DFHack::Gui *gui; -DFHack::Materials *mats; - - - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -int main (void) -{ - int32_t - cx,cy,z, //cursor coords - tx,ty, //tile coords within block - bx,by; //block coords - //DFHack::designations40d designations; - //DFHack::tiletypes40d tiles; - //DFHack::t_temperatures temp1,temp2; - uint32_t x_max,y_max,z_max; - - DFHack::ContextManager DFMgr("Memory.xml"); - try - { - - DF=DFMgr.getSingleContext(); - DF->Attach(); - maps = DF->getMaps(); - maps->Start(); - maps->getSize(x_max,y_max,z_max); - gui = DF->getGui(); - mats = DF->getMaterials(); - mats->ReadAllMaterials(); - if(!mats->ReadInorganicMaterials()) - { - printf("Error: Could not load materials!\n"); - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - - - bool end = false; - cout << "Welcome to the Vein Swap tool.\nType 'help' or ? for a list of available commands, 'q' to quit" << endl; - string mode = ""; - string command = ""; - - while(!end) - { - DF->Resume(); - - cout << endl << ":"; - getline(cin, command); - int ch = command[0]; - if(command.length()<=0) ch=0; - if( ((int)command.find("help")) >=0 ) ch='?'; //under windows, find was casting unsigned! - - //Process user command. - switch(ch) - { - case 'h': - case '?': - cout << "" << endl - << "Commands:" << endl - << "p - print vein at cursor" << endl - << "m - print all inorganic material types" << endl - << "r MatTo - replace the vein at cursor with MatTo" << endl - << "R Percent MatFrom MatTo - replace Percent of MatFrom veins with MatTo veins" << endl - << "help OR ? - print this list of commands" << endl - << "q - quit" << endl - << endl - << "Usage:\n\t" << endl; - break; - case 'p': - case 10: - case 13: - case 0: - { - //Print current cursor - mats->ReadAllMaterials(); - - if(!maps->Start()) - { - cout << "Can't see any DF map loaded." << endl; - break; - } - if(!gui->getCursorCoords(cx,cy,z)) - { - cout << "Can't get cursor coords! Make sure you have a cursor active in DF." << endl; - break; - } - //cout << "cursor coords: " << x << "/" << y << "/" << z << endl; - tx=cx%16; ty=cy%16; - bx=cx/16; by=cy/16; - DFHack::DFCoord xyz(cx,cy,z); - - printf("Cursor[%d,%d,%d] Block(%d,%d) Tile(%d,%d)\n", cx,cy,z, bx,by, tx,ty ); - - if(!maps->isValidBlock(bx,by,z)) - { - cout << "Invalid block." << endl; - break; - } - - vector veinVector; - int found=0; - maps->ReadVeins(bx,by,z,&veinVector); - printf("Veins in block (%d):\n",veinVector.size()); - for(unsigned long i=0;iinorganic[veinVector[i].type].id - ); - } - printf("Cursor is%s in vein.\n", (found?"":" not") ); - - maps->Finish(); - DF->Resume(); - } - break; - case 'v': - break; - case 'm': - break; - case 'R': - break; - case 'q': - end = true; - cout << "Bye!" << endl; - break; - case 'r': - DF->Suspend(); - do{ - //Process parameters - long matto = atol( command.c_str()+1 ); - if( matto < 0 || matto >= (long)mats->inorganic.size() ){ - cout << "Invalid material: " << matto << endl; - break; - } - - if(!maps->Start()) - { - cout << "Can't see any DF map loaded." << endl; - break; - } - if(!gui->getCursorCoords(cx,cy,z)) - { - cout << "Can't get cursor coords! Make sure you have a cursor active in DF." << endl; - break; - } - tx=cx%16; ty=cy%16; - bx=cx/16; by=cy/16; - printf("Cursor[%d,%d,%d] Block(%d,%d) Tile(%d,%d)\n", cx,cy,z, bx,by, tx,ty ); - - if(!maps->isValidBlock(bx,by,z)) - { - cout << "Invalid block." << endl; - break; - } - - //MapExtras::MapCache MC(maps); - //MapExtras::Block B(maps,DFHack::DFCoord(bx,by,z)); - - vector veinVector; - int v=-1; //the vector pointed to by the cursor - - mats->ReadAllMaterials(); - - maps->ReadVeins(bx,by,z,&veinVector); - for(unsigned long i=0 ; v<0 && iinorganic[veinVector[v].type].id, matto, mats->inorganic[matto].id ); -printf("%X\n",veinVector[v].vtable); - vector veinTable; - - veinVector[v].type = matto; - maps->WriteVein( &veinVector[v] ); - - - maps->Finish(); - - cout << endl << "Finished." << endl; - }while(0); - DF->Resume(); - break; - default: - cout << "Unknown command: " << command << endl; - }//end switch - - }//end while - - DF->Detach(); - //#ifndef LINUX_BUILD - //cout << "Done. Press any key to continue" << endl; - //cin.ignore(); - //#endif - return 0; -} From e011c390f10cabe3d1c67a96038a3de5a8ffcdf1 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Mon, 5 May 2014 15:52:21 +1000 Subject: [PATCH 2/6] formatted notes, deleted more went through `blame` and `history` to work out value of remaining stuff, formatted notes for other people to read and deleted a few more plugins --- needs_porting/_notes.txt | 92 +-- needs_porting/attachtest.py | 53 -- needs_porting/drawtile.cpp | 315 ---------- needs_porting/treedump.py | 52 -- needs_porting/veinlook.cpp | 1117 ----------------------------------- 5 files changed, 25 insertions(+), 1604 deletions(-) delete mode 100644 needs_porting/attachtest.py delete mode 100644 needs_porting/drawtile.cpp delete mode 100644 needs_porting/treedump.py delete mode 100644 needs_porting/veinlook.cpp diff --git a/needs_porting/_notes.txt b/needs_porting/_notes.txt index 04e123228..a653a7b56 100644 --- a/needs_porting/_notes.txt +++ b/needs_porting/_notes.txt @@ -1,72 +1,30 @@ Notes by PeridexisErrant, on the needs_porting scripts and plugins: -I've deleted "reveal", "lair", and "dfstatus.cpp" - they've been replaced by other more recent versions. (I added the dfstatus script). -Also deleted "digger", less useful than "digger2" and generally replaced by autochop. "digger2" is replaced by digfort. -And now "veinswap"; replaced by "changevein". "fix-3708.cpp" deals with a bug that the Mantis tracker marks as resolved. +I deleted: + attachtest.py obsolete + digger.cpp less useful than digger2, replaced by autochop + digger2.cpp replaced by digfort + dfstatus.cpp replaced by dfstatus.lua (which needs a little work too) + drawtile.cpp replaced by tiletypes + fix-3708.cpp obsolete, bug fixed in vanilla + lair.cpp replaced by lair + reveal.py replaced by reveal + treedump.py replaced by prospect & autochop + veinlook.cpp replaced by prospect + veinswap.cpp replaced by changevein + + +To investigate further: + creaturemanager.cpp modify skills and labors of creatures, kill creatures, etc; impressive but I suspect most functions implemented elsewhere + digpattern.cpp allows multi-Z designations. Obsolete, or is there more here? + incrementalsearch.cpp linux-only memory stuff; unqualified to judge + SegementedFinder.h more memory stuff -Need confirmation that they're obsolete before deleting (notes below): -attachtest.py, dfbauxtite.cpp, digpattern.cpp, drawtile.cpp, treedump.py, and veinlook.cpp - To port: -copypaste.cpp, hellhole.cpp, hotkeynotedump.py, itemdesignator.cpp (partial), position.py - - -All undeleted plugins: - -attachtest.py -- checks if dfhack is working with DF (i think) -- definitely replaced on windows, pretty sure also on other platforms - -copypaste.cpp -- a proof-of-concept plugin to allow copy-pasting in DF -- if I read it right, it does both terrain and buildings/constructions -- would be awesome if someone ported it! - -creaturemanager.cpp -- Display creatures; modify skills and labors of creatures; kill creatures; etc -- looks pretty impressive if incomplete (at 1500 lines I only looked over the comments) -- could maybe do with porting, but it's unfinished and I suspect that most functions are available elsewhere - -dfbauxtite.cpp -- as far as I can tell, this plugin changes the material of all mechanisms (printed string 'mechanisms', class 'item_trapparts') to Bauxtite; presumably from when this was the only magma-safe stone. -- I don't know of a newer alternative, but it's not really neccessary anymore - -digpattern.cpp -- I think all this one does is allow multi-z designations - no longer required. - -drawtile.cpp -- draws changes to tiles -- I think this is replaced by tiletypes, but not sure - -hellhole.cpp -- digs a hole to HFS instantly -- no known equivilant, needs porting - -hotkeynotedump.py -- outputs a list of hotkeys with names -- less useful with propper dfhack keybindings available, but still useful -- trivial to redo in lua (it's 20 lines, could be 10) - -incrementalsearch.cpp -- linux-only memory voodoo; leaving this alone - -itemdesignator.cpp -- applies flags to categories of items (eg item_microcline; forbid/dump/melt/on fire) -- appart from fire, replaced by Falconne's enhanced stocks screen -- port the fire part? - -position.py -- prints information about time (year/month/day/tick) and place (embark location/cursor pos) and window size -- the wider context can be written to gamelog on world load by "log-region.lua"; this doesn't seem to be included yet - -SegementedFinder.h -- no idea what's happening here - -treedump.py -- looks like it outputs a list of trees in a given volume -- overlaps with 'prospect' and 'autochop'; probably does not need porting - -veinlook.cpp -- I'm not sure what this does that "digv" and "reveal" don't but there must be something since it was around at the same time as reveal. - + copypaste.cpp high value target - a proof of concept plugin to allow copy-pasting in DF; does both terrain and buildings/constructions + dfbauxtite.cpp changes material of mechanisms to bauxtite (ie magma-safe) + hellhole.cpp instantly creates a hole to the HFS + hotkeynotedump.py outputs a list of hotkeys and names; most useful before keybindings were possible. Trival to port but low value. + itemdesignator.cpp mostly replaced by Falconne's enhanced stocks, but could port the interesting 'set fire to things' function + position.py outputs very detailed time& place info diff --git a/needs_porting/attachtest.py b/needs_porting/attachtest.py deleted file mode 100644 index e734e1ba1..000000000 --- a/needs_porting/attachtest.py +++ /dev/null @@ -1,53 +0,0 @@ -import time -from pydfhack import ContextManager - -df_cm = ContextManager("Memory.xml") -df = None - -def test_attach(): - global df - - if not df: - df = df_cm.get_single_context() - - if not df.attach(): - print "Unable to attach!" - return False - elif not df.detach(): - print "Unabled to detach!" - return False - else: - return True - -def suspend_test(): - global df - - if not df: - df = df_cm.get_single_context() - - print "Testing suspend/resume" - - df.attach() - - t1 = time.time() - - for i in xrange(1000): - df.suspend() - - if i % 10 == 0: - print "%i%%" % (i / 10.0,) - - df.resume() - - t2 = time.time() - - df.detach() - - print "suspend test done in $0.9f seconds" % (t2 - t1) - -if __name__ == "__main__": - if test_attach(): - suspend_test() - - print "Done. Press any key to continue" - raw_input() \ No newline at end of file diff --git a/needs_porting/drawtile.cpp b/needs_porting/drawtile.cpp deleted file mode 100644 index 72f2beb0f..000000000 --- a/needs_porting/drawtile.cpp +++ /dev/null @@ -1,315 +0,0 @@ -// - -#include -#include -#include -#include -#include -using namespace std; - -#include - - -#include -#include - -//Avoid including Windows.h because it causes name clashes -extern "C" __declspec(dllimport) void __stdcall Sleep(unsigned long milliseconds); - -//Trim -#define WHITESPACE " \t\r\n" -inline string trimr(const string & s, const string & t = WHITESPACE) -{ - string d (s); - string::size_type i (d.find_last_not_of (t)); - if (i == string::npos) - return ""; - else - return d.erase (d.find_last_not_of (t) + 1) ; -} -inline string triml(const string & s, const string & t = WHITESPACE) -{ - string d (s); - return d.erase (0, s.find_first_not_of (t)) ; -} -inline string trim(const string & s, const string & t = WHITESPACE) -{ - string d (s); - return triml(trimr(d, t), t); -} - -void printtiletype( int i ){ - printf("%s\n%4i ; %-13s ; %-11s ; %c ; %-12s ; %s\n", - ( DFHack::tileTypeTable[i].name ? DFHack::tileTypeTable[i].name : "[invalid tile]" ), - i, - ( DFHack::tileTypeTable[i].name ? DFHack::TileShapeString[ DFHack::tileTypeTable[i].shape ] : "" ), - ( DFHack::tileTypeTable[i].name ? DFHack::TileMaterialString[ DFHack::tileTypeTable[i].material ] : "" ), - ( DFHack::tileTypeTable[i].variant ? '0'+ DFHack::tileTypeTable[i].variant : ' ' ), - ( DFHack::tileTypeTable[i].special ? DFHack::TileSpecialString[ DFHack::tileTypeTable[i].special ] : "" ), - ( DFHack::tileTypeTable[i].direction.whole ? DFHack::tileTypeTable[i].direction.getStr() : "" ), - 0 - ); -} - - -int main (void) -{ - int32_t x,y,z,tx,ty; - //DFHack::designations40d designations; - DFHack::tiletypes40d tiles; - //DFHack::t_temperatures temp1,temp2; - uint32_t x_max,y_max,z_max; - int32_t oldT, newT; - int count, dirty; - - //Brush defaults - DFHack::TileShape BrushClass = DFHack::WALL; - DFHack::TileMaterial BrushMat = DFHack::tilematerial_invalid; - int BrushType = -1; - - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context *DF; - DFHack::Maps * Maps; - DFHack::Gui * Gui; - try - { - DF=DFMgr.getSingleContext(); - DF->Attach(); - Maps = DF->getMaps(); - Maps->Start(); - Maps->getSize(x_max,y_max,z_max); - Gui = DF->getGui(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - bool end = false; - cout << "Welcome to the Tile Drawing tool.\nType 'help' or ? for a list of available commands, 'q' to quit" << endl; - string mode = "wall"; - string command = ""; - - while(!end) - { - DF->Resume(); - - cout << endl << ":"; - getline(cin, command); - int ch = command[0]; - if(command.length()<=0) ch=0; - if( ((int)command.find("help")) >=0 ) ch='?'; //under windows, find was casting unsigned! - switch(ch) - { - case '?': - cout << "Modes:" << endl - << "O - draw Open Space" << endl - << "M - draw material only (shape unchanged)" << endl - << "m number - use Material value entered" << endl - << "r - use Rock/stone material" << endl - << "l - use Soil material" << endl - << "v - use Vein material" << endl - << "H - draw tile shape only (material unchanged)" << endl - << "h number - draw Tile Shape value entered" << endl - << "w - draw Wall tiles" << endl - << "f - draw Floor tiles" << endl - << "t number - draw exact tile type entered" << endl - << "Commands:" << endl - << "p - print tile shapes and materials, and current brush" << endl - << "P - print all tile types" << endl - << "q - quit" << endl - << "help OR ? - print this list of commands" << endl - << "d - being drawing" << endl - << endl - << "Usage:\nChoose a mode (default is walls), then enter 'd' to being drawing.\nMove the cursor in DF wherever you want to draw.\nPress any key to pause drawing." << endl; - break; - case 'p': - //Classes - printf("\nTile Type Classes:\n"); - for(int i=0;iSuspend(); - kbhit(); //throw away, just to be sure. - for(;;) - { - if(!Maps->Start()) - { - cout << "Can't see any DF map loaded." << endl; - break; - } - if(!Gui->getCursorCoords(x,y,z)) - { - cout << "Can't get cursor coords! Make sure you have a cursor active in DF." << endl; - break; - } - //cout << "cursor coords: " << x << "/" << y << "/" << z << endl; - tx=x%16; ty=y%16; - - if(!Maps->isValidBlock(x/16,y/16,z)) - { - cout << "Invalid block." << endl; - break; - } - - //Read the tiles. - dirty=0; - Maps->ReadTileTypes((x/16),(y/16),z, &tiles); - oldT = tiles[tx][ty]; - - newT = -1; - if( 0=0 && BrushClass>=0 && ( BrushClass != DFHack::tileTypeTable[oldT].shape || BrushMat != DFHack::tileTypeTable[oldT].material) ){ - //Set tile material and class - newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tileTypeTable[oldT].variant , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction ); - if(newT<0) newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tilevariant_invalid, DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction ); - if(newT<0) newT = DFHack::findTileType(BrushClass,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , (uint32_t)0 ); - }else if( BrushMat<0 && BrushClass>=0 && BrushClass != DFHack::tileTypeTable[oldT].shape ){ - //Set current tile class only, as accurately as can be expected - newT = DFHack::findSimilarTileType(oldT,BrushClass); - }else if( BrushClass<0 && BrushMat>=0 && BrushMat != DFHack::tileTypeTable[oldT].material ){ - //Set current tile material only - newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tileTypeTable[oldT].variant , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction ); - if(newT<0) newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , DFHack::tileTypeTable[oldT].direction ); - if(newT<0) newT = DFHack::findTileType(DFHack::tileTypeTable[oldT].shape,BrushMat, DFHack::tilevariant_invalid , DFHack::tileTypeTable[oldT].special , (uint32_t)0 ); - } - //If no change, skip it (couldn't find a good tile type, or already what we want) - if ( newT > 0 && oldT != newT ){ - //Set new tile type - tiles[tx][ty] = newT; - dirty=-1; - } - //If anything was changed, write it all. - if (dirty) - { - //Maps->WriteDesignations(x/16,y/16,z/16, &designations); - Maps->WriteTileTypes(x/16,y/16,z, &tiles); - printf("(%4d,%4d,%4d)",x,y,z); - ++count; - } - - Maps->Finish(); - - Sleep(10); - if( kbhit() ) break; - } - cin.clear(); - cout << endl << count << " tiles were drawn." << endl << "Drawing halted. Entering command mode." << endl; - } - continue; - break; - default: - cout << "Unknown command: " << command << endl; - } - - } - DF->Detach(); - #ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); - #endif - return 0; -} diff --git a/needs_porting/treedump.py b/needs_porting/treedump.py deleted file mode 100644 index f6017c94b..000000000 --- a/needs_porting/treedump.py +++ /dev/null @@ -1,52 +0,0 @@ -from context import Context, ContextManager - -cm = ContextManager("Memory.xml") -df = cm.get_single_context() - -df.attach() - -gui = df.gui -veg = df.vegetation -mps = df.maps -mat = df.materials - -x, y, z = gui.get_cursor_coords() - -num_veg = veg.start() - -if x == -30000: - print "----==== Trees ====----" - - for i in xrange(num_veg): - t = veg.read(i) - - print "%d/%d/%d, %d:%d" % (t.x, t.y, t.z, t.type, t.material) -else: - #new method, gets the list of trees in a block. can show farm plants - if mps.start(): - pos_tuple = (x, y, z) - trees = mps.read_vegetation(x / 16, y / 16, z) - - if trees is not None: - for t in trees: - if (t.x, t.y, t.z) == pos_tuple: - print "----==== Tree at %d/%d/%d ====----" % pos_tuple - print str(t) - break - mps.finish() - - #old method, get the tree from the global vegetation vector. can't show farm plants - for i in xrange(num_veg): - t = veg.read(i) - - if (t.x, t.y, t.z) == pos_tuple: - print "----==== Tree at %d/%d/%d ====----" % pos_tuple - print str(t) - break - -veg.finish() - -df.detach() - -print "Done. Press any key to continue" -raw_input() \ No newline at end of file diff --git a/needs_porting/veinlook.cpp b/needs_porting/veinlook.cpp deleted file mode 100644 index c5837a25c..000000000 --- a/needs_porting/veinlook.cpp +++ /dev/null @@ -1,1117 +0,0 @@ -#include // for memset -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -#include -// the header name comes from the build system. -#include -#include -#include -#include -#include - -#define DFHACK_WANT_MISCUTILS -#define DFHACK_WANT_TILETYPES -#include - -using namespace DFHack; - - -string error; -Context * pDF = 0; - - -struct t_tempz -{ - int32_t limit; - int character; -}; - -t_tempz temp_limits[]= -{ - {50, '.'}, - {100, '+'}, - {500, '*'}, - {1000, '#'}, - {2000, '!'} -}; -#define NUM_LIMITS 5 - -static void finish(int sig); - -int gotoxy(int x, int y) -{ - wmove(stdscr, y , x ); - return 0; -} - -void putch(int x, int y, int znak, int color) -{ - attron(COLOR_PAIR(color)); - mvwaddch(stdscr, y, x, znak); - attroff(COLOR_PAIR(color)); -} -void putwch(int x, int y, int znak, int color) -{ - attron(COLOR_PAIR(color)); - mvwaddch(stdscr, y, x, znak); - attroff(COLOR_PAIR(color)); -} -/* - enum TileClass - { - EMPTY, - - WALL, - PILLAR, - FORTIFICATION, - - STAIR_UP, - STAIR_DOWN, - STAIR_UPDOWN, - - RAMP, - - FLOOR, - TREE_DEAD, - TREE_OK, - SAPLING_DEAD, - SAPLING_OK, - SHRUB_DEAD, - SHRUB_OK, - BOULDER, - PEBBLES - };*/ - -void puttile(int x, int y, int tiletype, int color) -{ - unsigned int znak; - switch(tileShape(tiletype)) - { - case EMPTY: - znak = ' '; - break; - case PILLAR: - case WALL: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u2593"); - attroff(COLOR_PAIR(color)); - //znak = ; - return; - case FORTIFICATION: - znak = '#'; - break; - case STAIR_DOWN: - znak = '>'; - break; - case STAIR_UP: - znak = '<'; - break; - case STAIR_UPDOWN: - znak = '='; - break; - case RAMP: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u25B2"); - attroff(COLOR_PAIR(color)); - return; - case RAMP_TOP: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u25BC"); - attroff(COLOR_PAIR(color)); - return; - case FLOOR: - znak = '.'; - break; - case TREE_DEAD: - case TREE_OK: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u2663"); - attroff(COLOR_PAIR(color)); - return; - case SAPLING_DEAD: - case SAPLING_OK: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u03C4"); - attroff(COLOR_PAIR(color)); - return; - case SHRUB_DEAD: - case SHRUB_OK: - attron(COLOR_PAIR(color)); - mvwaddwstr(stdscr, y, x, L"\u2666"); - attroff(COLOR_PAIR(color)); - return; - case BOULDER: - case PEBBLES: - znak= '*'; - break; - } - attron(COLOR_PAIR(color)); - mvwaddch(stdscr, y, x, znak); - attroff(COLOR_PAIR(color)); -} - -int cprintf(const char *fmt, ...) -{ - va_list ap; - va_start(ap, fmt); - int i = vwprintw(stdscr,fmt, ap); - va_end(ap); - return i; -} - -void clrscr() -{ - wbkgd(stdscr, COLOR_PAIR(COLOR_BLACK)); - wclear(stdscr); -} - -/* - enum TileMaterial - { - AIR, - SOIL, - STONE, - FEATSTONE, // whatever it is - OBSIDIAN, - - VEIN, - ICE, - GRASS, - GRASS2, - GRASS_DEAD, - GRASS_DRY, - DRIFTWOOD, - HFS, - MAGMA, - CAMPFIRE, - FIRE, - ASHES, - CONSTRUCTED - }; -*/ -int pickColor(int tiletype) -{ - switch(tileMaterial(tiletype)) - { - case AIR: - return COLOR_BLACK; - case STONE: - case FEATSTONE: - case OBSIDIAN: - case CONSTRUCTED: - case ASHES: - default: - return COLOR_WHITE; - case SOIL: - case GRASS_DEAD: - case GRASS_DRY: - case DRIFTWOOD: - return COLOR_YELLOW; - case ICE: - return COLOR_CYAN; - case VEIN: - return COLOR_MAGENTA; - case GRASS: - case GRASS2: - return COLOR_GREEN; - case HFS: - case MAGMA: - case CAMPFIRE: - case FIRE: - return COLOR_RED; - } - -} - -/* -address = absolute address of dump start -length = length in bytes -*/ -void hexdump (DFHack::Context* DF, uint32_t address, uint32_t length, int filenum) -{ - uint32_t reallength; - uint32_t lines; - lines = (length / 16) + 1; - reallength = lines * 16; - char *buf = new char[reallength]; - ofstream myfile; - - stringstream ss; - ss << "hexdump" << filenum << ".txt"; - string name = ss.str(); - - myfile.open (name.c_str()); - - DF->ReadRaw(address, reallength, (uint8_t *) buf); - for (size_t i = 0; i < lines; i++) - { - // leading offset - myfile << "0x" << hex << setw(4) << i*16 << " "; - // groups - for(int j = 0; j < 4; j++) - { - // bytes - for(int k = 0; k < 4; k++) - { - int idx = i * 16 + j * 4 + k; - - myfile << hex << setw(2) << int(static_cast(buf[idx])) << " "; - } - myfile << " "; - } - myfile << endl; - } - delete buf; - myfile.close(); -} - -// p = attached process -// blockaddr = address of the block -// blockX, blockY = local map X and Y coords in 16x16 of the block -// printX, printX = where to print stuff on the screen -/* -void do_features(Process* p, uint32_t blockaddr, uint32_t blockX, uint32_t blockY, int printX, int printY, vector &stonetypes) -{ - memory_info* mem = p->getDescriptor(); - uint32_t block_feature1 = mem->getOffset("map_data_feature_local"); - uint32_t block_feature2 = mem->getOffset("map_data_feature_global"); - uint32_t region_x_offset = mem->getAddress("region_x"); - uint32_t region_y_offset = mem->getAddress("region_y"); - uint32_t region_z_offset = mem->getAddress("region_z"); - uint32_t feature1_start_ptr = mem->getAddress("local_feature_start_ptr"); - int32_t regionX, regionY, regionZ; - - // read position of the region inside DF world - p->readDWord (region_x_offset, (uint32_t &)regionX); - p->readDWord (region_y_offset, (uint32_t &)regionY); - p->readDWord (region_z_offset, (uint32_t &)regionZ); - // local feature present ? - int16_t idx = p->readWord(blockaddr + block_feature1); - if(idx != -1) - { - gotoxy(printX,printY); - cprintf("local feature present: %d", idx); - - uint64_t block48_x = blockX / 3 + regionX; - gotoxy(printX,printY+1); - cprintf("blockX: %d, regionX: %d\nbigblock_x: %d\n", blockX, regionX, block48_x); - - // region X coord offset by 8 big blocks (48x48 tiles) - uint16_t region_x_plus8 = ( block48_x + 8 ) / 16; - //uint16_t v12b = block48_x / 16; - //cout << "v12: " << v12 << " : " << v12b << endl; - // plain region Y coord - uint64_t region_y_local = (blockY / 3 + regionY) / 16; - gotoxy(printX,printY+2); - cprintf("region_y_local: %d\n", region_y_local); - - // deref pointer to the humongo-structure - uint32_t base = p->readDWord(feature1_start_ptr); - gotoxy(printX,printY+3); - cprintf("region_y_local: 0x%x\n", base); - - // this is just a few pointers to arrays of 16B (4 DWORD) structs - uint32_t array_elem = p->readDWord(base + (region_x_plus8 / 16) * 4); - gotoxy(printX,printY+4); - cprintf("array_elem: 0x%x\n", array_elem); - - // second element of the struct is a pointer - uint32_t wtf = p->readDWord(array_elem + (16*(region_y_local/16)) + 4); // rounding! - gotoxy(printX,printY+5); - cprintf("wtf : 0x%x @ 0x%x\n", wtf, array_elem + (16*(region_y_local/16)) ); - if(wtf) - { - //v14 = v10 + 24 * ((signed __int16)_tX + 16 * v9 % 16); - uint32_t feat_vector = wtf + 24 * (16 * (region_x_plus8 % 16) + (region_y_local % 16)); - gotoxy(printX,printY+6); - cprintf("local feature vector: 0x%x\n", feat_vector); - DfVector p_features(p, feat_vector); - gotoxy(printX,printY + 7); - cprintf("feature %d addr: 0x%x\n", idx, p_features[idx]); - if(idx >= p_features.size()) - { - gotoxy(printX,printY + 8); - cprintf("ERROR, out of vector bounds."); - } - else - { - string name = p->readClassName(p->readDWord( p_features[idx] )); - bool discovered = p->readDWord( p_features[idx] + 4 ); - gotoxy(printX,printY+8); - cprintf("%s", name.c_str()); - if(discovered) - { - gotoxy(printX,printY+9); - cprintf("You've discovered it already!"); - } - - if(name == "feature_init_deep_special_tubest") - { - int32_t master_type = p->readWord( p_features[idx] + 0x30 ); - int32_t slave_type = p->readDWord( p_features[idx] + 0x34 ); - char * matname = "unknown"; - // is stone? - if(master_type == 0) - { - matname = stonetypes[slave_type].id; - } - gotoxy(printX,printY+10); - cprintf("material %d/%d : %s", master_type, slave_type, matname); - - } - } - } - } - // global feature present - idx = p->readWord(blockaddr + block_feature2); - if(idx != -1) - { - gotoxy(printX,printY+11); - cprintf( "global feature present: %d\n", idx); - DfVector p_features (p,mem->getAddress("global_feature_vector")); - if(idx < p_features.size()) - { - uint32_t feat_ptr = p->readDWord(p_features[idx] + mem->getOffset("global_feature_funcptr_")); - gotoxy(printX,printY+12); - cprintf("feature descriptor?: 0x%x\n", feat_ptr); - string name = p->readClassName(p->readDWord( feat_ptr)); - bool discovered = p->readDWord( feat_ptr + 4 ); - gotoxy(printX,printY+13); - cprintf("%s", name.c_str()); - if(discovered) - { - gotoxy(printX,printY+14); - cout << "You've discovered it already!" << endl; - } - if(name == "feature_init_underworld_from_layerst") - { - int16_t master_type = p->readWord( feat_ptr + 0x34 ); - int32_t slave_type = p->readDWord( feat_ptr + 0x38 ); - char * matname = "unknown"; - // is stone? - if(master_type == 0) - { - matname = stonetypes[slave_type].id; - } - gotoxy(printX,printY+15); - cprintf("material %d/%d : %s", master_type, slave_type, matname); - } - } - } -} -*/ -void do_features(Context* DF, mapblock40d * block, uint32_t blockX, uint32_t blockY, int printX, int printY, vector &stonetypes) -{ - Maps * Maps = DF->getMaps(); - Process * p = DF->getProcess(); - if(!Maps) - return; - vector global_features; - std::map > local_features; - if(!Maps->ReadGlobalFeatures(global_features)) - return; - if(!Maps->ReadLocalFeatures(local_features)) - return; - - DFCoord pc(blockX, blockY); - int16_t idx =block->global_feature; - if(idx != -1) - { - t_feature &ftr =global_features[idx]; - gotoxy(printX,printY); - cprintf( "global feature present: %d @ 0x%x\n", idx, ftr.origin); - if(ftr.discovered ) - { - gotoxy(printX,printY+1); - cprintf("You've discovered it already!"); - } - - char * matname = (char *) "unknown"; - // is stone? - if(ftr.main_material == 0) - { - matname = stonetypes[ftr.sub_material].id; - } - gotoxy(printX,printY+2); - cprintf("%d:%s, material %d/%d : %s", ftr.type, sa_feature(ftr.type), ftr.main_material, ftr.sub_material, matname); - { - gotoxy(printX,printY+3); - string name = p->readClassName(p->readDWord( ftr.origin )); - cprintf("%s", name.c_str()); - } - } - idx =block->local_feature; - if(idx != -1) - { - vector &ftrv = local_features[pc]; - if(idx < ftrv.size()) - { - t_feature & ftr = *ftrv[idx]; - gotoxy(printX,printY + 4); - cprintf( "local feature present: %d @ 0x%x\n", idx, ftr.origin); - if(ftr.discovered ) - { - gotoxy(printX,printY+ 5); - cprintf("You've discovered it already!"); - } - char * matname = (char *) "unknown"; - // is stone? - if(ftr.main_material == 0) - { - matname = stonetypes[ftr.sub_material].id; - } - gotoxy(printX,printY+6); - cprintf("%d:%s, material %d/%d : %s", ftr.type, sa_feature(ftr.type), ftr.main_material, ftr.sub_material, matname); - - gotoxy(printX,printY+7); - string name = p->readClassName(p->readDWord( ftr.origin )); - cprintf("%s", name.c_str()); - } - else - { - gotoxy(printX,printY + 4); - cprintf( "local feature vector overflow: %d", idx); - } - } -} - -int main(int argc, char *argv[]) -{ - /* initialize your non-curses data structures here */ - - signal(SIGINT, finish); /* arrange interrupts to terminate */ - setlocale(LC_ALL,""); - initscr(); /* initialize the curses library */ - keypad(stdscr, TRUE); /* enable keyboard mapping */ - nonl(); /* tell curses not to do NL->CR/NL on output */ - cbreak(); /* take input chars one at a time, no wait for \n */ - noecho(); /* don't echo input */ - //nodelay(stdscr, true); - - keypad(stdscr, TRUE); - scrollok(stdscr, TRUE); - - if (has_colors()) - { - start_color(); - - /* - * Simple color assignment, often all we need. - */ - init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); - init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); - init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); - init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); - init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); - - init_color(COLOR_CYAN, 700, 700, 700); // lt grey - init_color(COLOR_MAGENTA, 500, 500, 500); // dk grey - init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); - init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); - init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); - } - - int x_max,y_max,z_max; - uint32_t x_max_a,y_max_a,z_max_a; - /* - uint16_t tiletypes[16][16]; - DFHack::t_designation designations[16][16]; - uint8_t regionoffsets[16]; - */ - map materials; - materials.clear(); - mapblock40d blocks[3][3]; - vector effects; - vector< vector > layerassign; - vector veinVector; - vector IceVeinVector; - vector splatter; - vector grass; - vector wconstructs; - t_temperatures b_temp1; - t_temperatures b_temp2; - - DFHack::Materials * Mats = 0; - DFHack::Maps * Maps = 0; - - - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context* DF; - try - { - pDF = DF = DFMgr.getSingleContext(); - DF->Attach(); - Maps = DF->getMaps(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - finish(0); - } - bool hasmats = true; - try - { - Mats = DF->getMaterials(); - } - catch (exception&) - { - hasmats = false; - } - - // init the map - if(!Maps->Start()) - { - error = "Can't find a map to look at."; - finish(0); - } - - Maps->getSize(x_max_a,y_max_a,z_max_a); - x_max = x_max_a; - y_max = y_max_a; - z_max = z_max_a; - - bool hasInorgMats = false; - bool hasPlantMats = false; - bool hasCreatureMats = false; - - if(hasmats) - { - // get stone matgloss mapping - if(Mats->ReadInorganicMaterials()) - { - hasInorgMats = true; - } - if(Mats->ReadCreatureTypes()) - { - hasCreatureMats = true; - } - if(Mats->ReadOrganicMaterials()) - { - hasPlantMats = true; - } - } -/* - // get region geology - if(!DF.ReadGeology( layerassign )) - { - error = "Can't read local geology."; - pDF = 0; - finish(0); - } -*/ - // FIXME: could fail on small forts - int cursorX = x_max/2 - 1; - int cursorY = y_max/2 - 1; - int cursorZ = z_max/2 - 1; - - - bool dig = false; - bool dump = false; - bool digbit = false; - bool dotwiddle; - unsigned char twiddle = 0; - int vein = 0; - int filenum = 0; - bool dirtybit = false; - uint32_t blockaddr = 0; - uint32_t blockaddr2 = 0; - t_blockflags bflags; - bflags.whole = 0; - enum e_tempmode - { - TEMP_NO, - TEMP_1, - TEMP_2, - WATER_SALT, - WATER_STAGNANT - }; - e_tempmode temperature = TEMP_NO; - - // resume so we don't block DF while we wait for input - DF->Resume(); - - for (;;) - { - dig = false; - dump = false; - dotwiddle = false; - digbit = false; - - int c = getch(); /* refresh, accept single keystroke of input */ - flushinp(); - clrscr(); - /* process the command keystroke */ - switch(c) - { - case KEY_DOWN: - cursorY ++; - break; - case KEY_UP: - cursorY --; - break; - case KEY_LEFT: - cursorX --; - break; - case KEY_RIGHT: - cursorX ++; - break; - case KEY_NPAGE: - cursorZ --; - break; - case KEY_PPAGE: - cursorZ ++; - break; - case '+': - vein ++; - break; - case 'd': - dig = true; - break; - case 'o': - dump = true; - break; - case '-': - vein --; - break; - case 'z': - digbit = true; - break; - case '/': - if(twiddle != 0) twiddle--; - break; - case '*': - twiddle++; - break; - case 't': - dotwiddle = true; - break; - case 'b': - temperature = TEMP_NO; - break; - case 'n': - temperature = TEMP_1; - break; - case 'm': - temperature = TEMP_2; - break; - case 'c': - temperature = WATER_SALT; - break; - case 'v': - temperature = WATER_STAGNANT; - break; - case 27: // escape key - DF->Detach(); - return 0; - break; - default: - break; - } - cursorX = max(cursorX, 0); - cursorY = max(cursorY, 0); - cursorZ = max(cursorZ, 0); - - cursorX = min(cursorX, x_max - 1); - cursorY = min(cursorY, y_max - 1); - cursorZ = min(cursorZ, z_max - 1); - - if(twiddle > 31) - twiddle = 31; - - // clear data before we suspend - memset(blocks,0,sizeof(blocks)); - veinVector.clear(); - IceVeinVector.clear(); - effects.clear(); - splatter.clear(); - grass.clear(); - dirtybit = 0; - - // Supend, read/write data - DF->Suspend(); - // restart cleared modules - Maps->Start(); - if(hasmats) - { - Mats->Start(); - if(hasInorgMats) - { - Mats->ReadInorganicMaterials(); - } - if(hasPlantMats) - { - Mats->ReadOrganicMaterials(); - } - if(hasCreatureMats) - { - Mats->ReadCreatureTypes(); - } - } - /* - if(DF.InitReadEffects(effectnum)) - { - for(uint32_t i = 0; i < effectnum;i++) - { - t_effect_df40d effect; - DF.ReadEffect(i,effect); - effects.push_back(effect); - } - } - */ - for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) - { - mapblock40d * Block = &blocks[i+1][j+1]; - if(Maps->isValidBlock(cursorX+i,cursorY+j,cursorZ)) - { - Maps->ReadBlock40d(cursorX+i,cursorY+j,cursorZ, Block); - // extra processing of the block in the middle - if(i == 0 && j == 0) - { - if(hasInorgMats) - do_features(DF, Block, cursorX, cursorY, 50,10, Mats->inorganic); - // read veins - Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,&veinVector,&IceVeinVector,&splatter,&grass, &wconstructs); - - // get pointer to block - blockaddr = Maps->getBlockPtr(cursorX+i,cursorY+j,cursorZ); - blockaddr2 = Block->origin; - - // dig all veins and trees - if(dig) - { - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - int16_t tiletype = Block->tiletypes[x][y]; - TileShape tc = tileShape(tiletype); - TileMaterial tm = tileMaterial(tiletype); - if( tc == WALL && tm == VEIN || tc == TREE_OK || tc == TREE_DEAD) - { - Block->designation[x][y].bits.dig = designation_default; - } - } - Maps->WriteDesignations(cursorX+i,cursorY+j,cursorZ, &(Block->designation)); - } - - // read temperature data - Maps->ReadTemperatures(cursorX+i,cursorY+j,cursorZ,&b_temp1, &b_temp2 ); - if(dotwiddle) - { - bitset<32> bs ((int)Block->designation[0][0].whole); - bs.flip(twiddle); - Block->designation[0][0].whole = bs.to_ulong(); - Maps->WriteDesignations(cursorX+i,cursorY+j,cursorZ, &(Block->designation)); - dotwiddle = false; - } - - // do a dump of the block data - if(dump) - { - hexdump(DF,blockaddr,0x1E00,filenum); - filenum++; - } - // read/write dirty bit of the block - Maps->ReadDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit); - Maps->ReadBlockFlags(cursorX+i,cursorY+j,cursorZ,bflags); - if(digbit) - { - dirtybit = !dirtybit; - Maps->WriteDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit); - } - } - } - } - // Resume, print stuff to the terminal - DF->Resume(); - for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) - { - mapblock40d * Block = &blocks[i+1][j+1]; - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - int color = COLOR_BLACK; - color = pickColor(Block->tiletypes[x][y]); - /* - if(!Block->designation[x][y].bits.hidden) - { - puttile(x+(i+1)*16,y+(j+1)*16,Block->tiletypes[x][y], color); - } - else*/ - { - - attron(A_STANDOUT); - puttile(x+(i+1)*16,y+(j+1)*16,Block->tiletypes[x][y], color); - attroff(A_STANDOUT); - - } - } - // print effects for the center tile - /* - if(i == 0 && j == 0) - { - for(uint zz = 0; zz < effects.size();zz++) - { - if(effects[zz].z == cursorZ && !effects[zz].isHidden) - { - // block coords to tile coords - uint16_t x = effects[zz].x - (cursorX * 16); - uint16_t y = effects[zz].y - (cursorY * 16); - if(x < 16 && y < 16) - { - putch(x + 16,y + 16,'@',COLOR_WHITE); - } - } - } - } - */ - } - gotoxy(50,0); - cprintf("arrow keys, PGUP, PGDN = navigate"); - gotoxy(50,1); - cprintf("+,- = switch vein"); - gotoxy(50,2); - uint32_t mineralsize = veinVector.size(); - uint32_t icesize = IceVeinVector.size(); - uint32_t splattersize = splatter.size(); - uint32_t grasssize = grass.size(); - uint32_t wconstrsize = wconstructs.size(); - uint32_t totalVeinSize = mineralsize+ icesize + splattersize + grasssize + wconstrsize; - if(vein == totalVeinSize) vein = totalVeinSize - 1; - if(vein < -1) vein = -1; - cprintf("X %d/%d, Y %d/%d, Z %d/%d. Vein %d of %d",cursorX+1,x_max,cursorY+1,y_max,cursorZ,z_max,vein+1,totalVeinSize); - if(!veinVector.empty() || !IceVeinVector.empty() || !splatter.empty() || !grass.empty() || !wconstructs.empty()) - { - if(vein != -1 && vein < totalVeinSize) - { - uint32_t realvein = 0; - if(vein < mineralsize) - { - realvein = vein; - //iterate through vein rows - for(uint32_t j = 0;j<16;j++) - { - //iterate through the bits - for (uint32_t k = 0; k< 16;k++) - { - // and the bit array with a one-bit mask, check if the bit is set - bool set = !!(((1 << k) & veinVector[realvein].assignment[j]) >> k); - if(set) - { - putch(k+16,j+16,'$',COLOR_RED); - } - } - } - if(hasInorgMats) - { - gotoxy(50,3); - cprintf("Mineral: %s",Mats->inorganic[veinVector[vein].type].id); - } - } - else if (vein < mineralsize + icesize) - { - realvein = vein - mineralsize; - t_frozenliquidvein &frozen = IceVeinVector[realvein]; - for(uint32_t i = 0;i<16;i++) - { - for (uint32_t j = 0; j< 16;j++) - { - int color = COLOR_BLACK; - int tile = frozen.tiles[i][j]; - color = pickColor(tile); - - attron(A_STANDOUT); - puttile(i+16,j+16,tile, color); - attroff(A_STANDOUT); - } - } - gotoxy(50,3); - cprintf("ICE"); - } - else if(vein < mineralsize + icesize + splattersize) - { - realvein = vein - mineralsize - icesize; - for(uint32_t yyy = 0; yyy < 16; yyy++) - { - for(uint32_t xxx = 0; xxx < 16; xxx++) - { - uint8_t intensity = splatter[realvein].intensity[xxx][yyy]; - if(intensity) - { - attron(A_STANDOUT); - putch(xxx+16,yyy+16,'*', COLOR_RED); - attroff(A_STANDOUT); - } - } - } - if(hasCreatureMats) - { - gotoxy(50,3); - cprintf("Spatter: %s",PrintSplatterType(splatter[realvein].mat1,splatter[realvein].mat2,Mats->race).c_str()); - } - } - else if(vein < mineralsize + icesize + splattersize + grasssize) - { - realvein = vein - mineralsize - icesize - splattersize; - t_grassvein & grassy =grass[realvein]; - for(uint32_t yyy = 0; yyy < 16; yyy++) - { - for(uint32_t xxx = 0; xxx < 16; xxx++) - { - uint8_t intensity = grassy.intensity[xxx][yyy]; - if(intensity) - { - attron(A_STANDOUT); - putch(xxx+16,yyy+16,'X', COLOR_RED); - attroff(A_STANDOUT); - } - } - } - if(hasPlantMats) - { - gotoxy(50,3); - cprintf("Grass: 0x%x, %s",grassy.address_of, Mats->organic[grassy.material].id); - } - } - else - { - realvein = vein - mineralsize - icesize - splattersize - grasssize; - t_worldconstruction & wconstr=wconstructs[realvein]; - for(uint32_t j = 0; j < 16; j++) - { - for(uint32_t k = 0; k < 16; k++) - { - bool set = !!(((1 << k) & wconstr.assignment[j]) >> k); - if(set) - { - putch(k+16,j+16,'$',COLOR_RED); - } - } - } - if(hasInorgMats) - { - gotoxy(50,3); - cprintf("Road: 0x%x, %d - %s", wconstr.address_of, wconstr.material,Mats->inorganic[wconstr.material].id); - } - } - } - } - mapblock40d * Block = &blocks[1][1]; - t_temperatures * ourtemp; - if(temperature == TEMP_NO) - { - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - if((Block->occupancy[x][y].whole & (1 << twiddle))) - { - putch(x + 16,y + 16,'@',COLOR_WHITE); - } - } - } - else if(temperature == WATER_SALT) - { - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - if(Block->designation[x][y].bits.water_salt) - { - putch(x + 16,y + 16,'@',COLOR_WHITE); - } - } - gotoxy (50,8); - cprintf ("Salt water"); - } - else if(temperature == WATER_STAGNANT) - { - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - if(Block->designation[x][y].bits.water_stagnant) - { - putch(x + 16,y + 16,'@',COLOR_WHITE); - } - } - gotoxy (50,8); - cprintf ("Stagnant water"); - } - else - { - if(temperature == TEMP_1) - ourtemp = &b_temp1; - else if(temperature == TEMP_2) - ourtemp = &b_temp2; - uint64_t sum = 0; - uint16_t min, max; - min = max = (*ourtemp)[0][0]; - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - uint16_t temp = (*ourtemp)[x][y]; - if(temp < min) min = temp; - if(temp > max) max = temp; - sum += temp; - } - uint64_t average = sum/256; - gotoxy (50,8); - if(temperature == TEMP_1) - cprintf ("temperature1 [°U] (min,avg,max): %d,%d,%d", min, average, max); - else if(temperature == TEMP_2) - cprintf ("temperature2 [°U] (min,avg,max): %d,%d,%d", min, average, max); - - for(int x = 0; x < 16; x++) for(int y = 0; y < 16; y++) - { - int32_t temper = (int32_t) (*ourtemp)[x][y]; - temper -= average; - uint32_t abs_temp = abs(temper); - int color; - unsigned char character = ' '; - if(temper >= 0) - color = COLOR_RED; - else - color = COLOR_BLUE; - - for(int i = 0; i < NUM_LIMITS; i++) - { - if(temp_limits[i].limit < abs_temp) - character = temp_limits[i].character; - else break; - } - if( character != ' ') - { - putch(x + 16,y + 16,character,color); - } - } - } - gotoxy (50,4); - cprintf("block address 0x%x, flags 0x%08x",blockaddr, bflags.whole); - gotoxy (50,5); - cprintf("dirty bit: %d, twiddle: %d",dirtybit,twiddle); - gotoxy (50,6); - cprintf ("d - dig veins, o - dump map block, z - toggle dirty bit"); - gotoxy (50,7); - cprintf ("b - no temperature, n - temperature 1, m - temperature 2"); - wrefresh(stdscr); - } - pDF = 0; - finish(0); -} - -static void finish(int sig) -{ - // ugly - if(pDF) - { - pDF->ForceResume(); - pDF->Detach(); - } - endwin(); - if(!error.empty()) - { - cerr << error << endl; - } - exit(0); -} From acdf90c1bacd2555b70105512923aa4383b21de0 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Wed, 7 May 2014 12:26:18 +1000 Subject: [PATCH 3/6] fixed dfstatus script, readme and init entries replaced magic numbers in dfstatus script with `df.item_type.TOKEN`; added dfstatus to readme and init_example; myself to contributors list, updated needs_porting notes and removed script --- Contributors.rst | 1 + Readme.rst | 4 ++ dfhack.init-example | 3 + needs_porting/_notes.txt | 2 +- needs_porting/dfstatus.lua | 110 --------------------------------- scripts/dfstatus.lua | 121 +++++++++++++++++++++++++++++++++++++ 6 files changed, 130 insertions(+), 111 deletions(-) delete mode 100644 needs_porting/dfstatus.lua create mode 100644 scripts/dfstatus.lua diff --git a/Contributors.rst b/Contributors.rst index b10877718..7f09dce73 100644 --- a/Contributors.rst +++ b/Contributors.rst @@ -61,6 +61,7 @@ The following is a list of people who have contributed to **DFHack**. - Caldfir - Antalia - Angus Mezick +- PeridexisErrant And those are the cool people who made **stonesense**. diff --git a/Readme.rst b/Readme.rst index 499920cab..720d06ad1 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2400,6 +2400,10 @@ dfhack commands. Useful for hotkeys. Example:: multicmd locate-ore iron ; digv +dfstatus +======== +Show a quick overview of critical stock quantities, including food, dirnks, wood, and various bars. + ======================= In-game interface tools ======================= diff --git a/dfhack.init-example b/dfhack.init-example index 3470bf36b..83b309001 100644 --- a/dfhack.init-example +++ b/dfhack.init-example @@ -48,6 +48,9 @@ keybinding add Ctrl-Shift-B "adv-bodyswap force" # Stocks plugin keybinding add Ctrl-Shift-Z@dwarfmode/Default "stocks show" +# open an overview window summarising some stocks (dfstatus) +keybinding add Ctrl-Shift-I@dwarfmode/Default dfstatus + # Workflow keybinding add Ctrl-W@dwarfmode/QueryBuilding/Some "gui/workflow" keybinding add Ctrl-I "gui/workflow status" diff --git a/needs_porting/_notes.txt b/needs_porting/_notes.txt index a653a7b56..041e0932d 100644 --- a/needs_porting/_notes.txt +++ b/needs_porting/_notes.txt @@ -4,7 +4,7 @@ I deleted: attachtest.py obsolete digger.cpp less useful than digger2, replaced by autochop digger2.cpp replaced by digfort - dfstatus.cpp replaced by dfstatus.lua (which needs a little work too) + dfstatus.cpp replaced by dfstatus.lua drawtile.cpp replaced by tiletypes fix-3708.cpp obsolete, bug fixed in vanilla lair.cpp replaced by lair diff --git a/needs_porting/dfstatus.lua b/needs_porting/dfstatus.lua deleted file mode 100644 index 180d2afa3..000000000 --- a/needs_porting/dfstatus.lua +++ /dev/null @@ -1,110 +0,0 @@ --- dfstatus 1.04 - a quick access status screen. --- written by enjia2000@gmail.com - -local gui = require 'gui' - -function draw() - screen2 = gui.FramedScreen{ - frame_style = gui.GREY_LINE_FRAME, - frame_title = 'dfstatus', - frame_width = 16, - frame_height = 17, - frame_inset = 1, - } -end - -if (not shown) then - draw() - screen2:show() - shown = true -else - shown = nil - screen2:dismiss() -end - -function screen2:onRenderBody(dc) - local drink = 0 - local wood = 0 - --local meat = 0 - --local raw_fish = 0 - --local plants = 0 - local prepared_meals = 0 - - local fuel = 0 - local pigiron = 0 - local iron = 0 - local steel = 0 - - local silver = 0 - local copper = 0 - local gold = 0 - - local tannedhides = 0 - local cloth = 0 - - for _,item in ipairs(df.global.world.items.all) do - if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid and not item.flags.in_building and not item.flags.trader) then - if (item:getType() == 5) then wood = wood + item:getStackSize() - elseif (item:getType() == 68) then drink = drink + item:getStackSize() - elseif (item:getType() == 54) then tannedhides = tannedhides + item:getStackSize() - elseif (item:getType() == 57) then cloth = cloth + item:getStackSize() - --elseif (item:getType() == 47) then meat = meat + item:getStackSize() - --elseif (item:getType() == 49) then raw_fish = raw_fish + item:getStackSize() - --elseif (item:getType() == 53) then plants = plants + item:getStackSize() - elseif (item:getType() == 71) then prepared_meals = prepared_meals + item:getStackSize() - elseif (item:getType() == 0) then - for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do - if (token == "silver") then silver = silver + item:getStackSize() - elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() - elseif (token == "iron") then iron = iron + item:getStackSize() - elseif (token == "pig") then pigiron = pigiron + item:getStackSize() - elseif (token == "copper") then copper = copper + item:getStackSize() - elseif (token == "gold") then gold = gold + item:getStackSize() - elseif (token == "steel") then steel = steel + item:getStackSize() - end - break -- only need to look at the 1st token of each item. - end - end - end - end - dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) - dc:newline(0) - --dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) - --dc:newline(0) - --dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) - --dc:newline(0) - dc:newline(0) - dc:string("Bars:", COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:newline(1) - dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) -end - -function screen2:onInput(keys) - if keys.LEAVESCREEN or keys.SELECT then - shown = nil - self:dismiss() - end -end diff --git a/scripts/dfstatus.lua b/scripts/dfstatus.lua new file mode 100644 index 000000000..8f494df81 --- /dev/null +++ b/scripts/dfstatus.lua @@ -0,0 +1,121 @@ +-- dfstatus 1.0 - a quick access status screen. +-- written by enjia2000@gmail.com, fixed by Lethosor and PeridexisErrant + + +local gui = require 'gui' + +function draw() + screen2 = gui.FramedScreen{ + frame_style = gui.GREY_LINE_FRAME, + frame_title = 'dfstatus', + frame_width = 16, + frame_height = 17, + frame_inset = 1, + } +end + +if (not shown) then + draw() + screen2:show() + shown = true +else + shown = nil + screen2:dismiss() +end + +function screen2:onRenderBody(dc) + local drink = 0 + local wood = 0 + --local meat = 0 + --local raw_fish = 0 + --local plants = 0 + local prepared_meals = 0 + + local fuel = 0 + local pigiron = 0 + local iron = 0 + local steel = 0 + + local silver = 0 + local copper = 0 + local gold = 0 + + local tannedhides = 0 + local cloth = 0 + + --print("------------------------------") + for _,item in ipairs(df.global.world.items.all) do + if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid) then + if(item:getType() ~= df.item_type.THREAD and item:getType() ~= df.item_type.REMAINS and item:getType() ~= df.item_type.ARMOR and item:getType() ~= df.item_type.SHOES and item:getType() ~= df.item_type.SHIELD and item:getType() ~= df.item_type.HELM and item:getType() ~= df.item_type.GOVES) then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end + if(item:getType() == df.item_type.DRINK)then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end + + if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize() + elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize() + elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize() + elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize() + --elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize() + --elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize() + --elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize() + elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize() + elseif (item:getType() == df.item_type.BAR) then + for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do + if (token == "silver") then silver = silver + item:getStackSize() + elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() + elseif (token == "iron") then iron = iron + item:getStackSize() + elseif (token == "pig") then pigiron = pigiron + item:getStackSize() + elseif (token == "copper") then copper = copper + item:getStackSize() + elseif (token == "gold") then gold = gold + item:getStackSize() + elseif (token == "steel") then steel = steel + item:getStackSize() + end + break -- only need to look at the 1st token of each item. + end + end + end + end + --print("------------------------------") + dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) + dc:newline(0) +-- dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) +-- dc:newline(0) +-- dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) +-- dc:newline(0) + dc:newline(0) + dc:string("Bars:", COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:newline(1) + dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) +end + +function screen2:onInput(keys) + if keys.LEAVESCREEN or keys.SELECT then + shown = nil + self:dismiss() + end +end + From a2f5e971e2fd8528f8906219dfe3095bc568bba9 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Mon, 12 May 2014 10:29:59 +1000 Subject: [PATCH 4/6] fixed whitespace in dfstatus script all indents now use a uniform eight spaces; fixed from mix of four spaces and tabs --- scripts/dfstatus.lua | 204 +++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/scripts/dfstatus.lua b/scripts/dfstatus.lua index 8f494df81..3442503d9 100644 --- a/scripts/dfstatus.lua +++ b/scripts/dfstatus.lua @@ -1,121 +1,121 @@ --- dfstatus 1.0 - a quick access status screen. +-- dfstatus 1.5 - a quick access status screen. -- written by enjia2000@gmail.com, fixed by Lethosor and PeridexisErrant local gui = require 'gui' function draw() - screen2 = gui.FramedScreen{ - frame_style = gui.GREY_LINE_FRAME, - frame_title = 'dfstatus', - frame_width = 16, - frame_height = 17, - frame_inset = 1, - } + screen2 = gui.FramedScreen{ + frame_style = gui.GREY_LINE_FRAME, + frame_title = 'dfstatus', + frame_width = 16, + frame_height = 17, + frame_inset = 1, + } end if (not shown) then - draw() - screen2:show() - shown = true + draw() + screen2:show() + shown = true else - shown = nil - screen2:dismiss() + shown = nil + screen2:dismiss() end function screen2:onRenderBody(dc) - local drink = 0 - local wood = 0 - --local meat = 0 - --local raw_fish = 0 - --local plants = 0 - local prepared_meals = 0 - - local fuel = 0 - local pigiron = 0 - local iron = 0 - local steel = 0 - - local silver = 0 - local copper = 0 - local gold = 0 - - local tannedhides = 0 - local cloth = 0 - - --print("------------------------------") - for _,item in ipairs(df.global.world.items.all) do + local drink = 0 + local wood = 0 + --local meat = 0 + --local raw_fish = 0 + --local plants = 0 + local prepared_meals = 0 + + local fuel = 0 + local pigiron = 0 + local iron = 0 + local steel = 0 + + local silver = 0 + local copper = 0 + local gold = 0 + + local tannedhides = 0 + local cloth = 0 + + --print("------------------------------") + for _,item in ipairs(df.global.world.items.all) do if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid) then - if(item:getType() ~= df.item_type.THREAD and item:getType() ~= df.item_type.REMAINS and item:getType() ~= df.item_type.ARMOR and item:getType() ~= df.item_type.SHOES and item:getType() ~= df.item_type.SHIELD and item:getType() ~= df.item_type.HELM and item:getType() ~= df.item_type.GOVES) then - --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) - end - if(item:getType() == df.item_type.DRINK)then - --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) - end - - if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize() - elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize() - elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize() - elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize() - --elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize() - --elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize() - --elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize() - elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize() - elseif (item:getType() == df.item_type.BAR) then - for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do - if (token == "silver") then silver = silver + item:getStackSize() - elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() - elseif (token == "iron") then iron = iron + item:getStackSize() - elseif (token == "pig") then pigiron = pigiron + item:getStackSize() - elseif (token == "copper") then copper = copper + item:getStackSize() - elseif (token == "gold") then gold = gold + item:getStackSize() - elseif (token == "steel") then steel = steel + item:getStackSize() - end - break -- only need to look at the 1st token of each item. - end - end - end - end - --print("------------------------------") - dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) - dc:newline(0) --- dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) --- dc:newline(0) --- dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) --- dc:newline(0) - dc:newline(0) - dc:string("Bars:", COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:newline(1) - dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) + if(item:getType() ~= df.item_type.THREAD and item:getType() ~= df.item_type.REMAINS and item:getType() ~= df.item_type.ARMOR and item:getType() ~= df.item_type.SHOES and item:getType() ~= df.item_type.SHIELD and item:getType() ~= df.item_type.HELM and item:getType() ~= df.item_type.GOVES) then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end + if(item:getType() == df.item_type.DRINK)then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end + + if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize() + elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize() + elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize() + elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize() + --elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize() + --elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize() + --elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize() + elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize() + elseif (item:getType() == df.item_type.BAR) then + for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do + if (token == "silver") then silver = silver + item:getStackSize() + elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() + elseif (token == "iron") then iron = iron + item:getStackSize() + elseif (token == "pig") then pigiron = pigiron + item:getStackSize() + elseif (token == "copper") then copper = copper + item:getStackSize() + elseif (token == "gold") then gold = gold + item:getStackSize() + elseif (token == "steel") then steel = steel + item:getStackSize() + end + break -- only need to look at the 1st token of each item. + end + end + end +end + --print("------------------------------") + dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) + dc:newline(0) + -- dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) + -- dc:newline(0) + -- dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) + -- dc:newline(0) + dc:newline(0) + dc:string("Bars:", COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:newline(1) + dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) end function screen2:onInput(keys) - if keys.LEAVESCREEN or keys.SELECT then - shown = nil - self:dismiss() - end + if keys.LEAVESCREEN or keys.SELECT then + shown = nil + self:dismiss() + end end From 8a488ec9147656622b5c31a7469fb380ebf96f95 Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Mon, 12 May 2014 10:32:46 +1000 Subject: [PATCH 5/6] actually fixed whitespace to four-space indentations. I should have read the documentation earlier... --- scripts/dfstatus.lua | 196 +++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/scripts/dfstatus.lua b/scripts/dfstatus.lua index 3442503d9..0ebaa141d 100644 --- a/scripts/dfstatus.lua +++ b/scripts/dfstatus.lua @@ -5,117 +5,117 @@ local gui = require 'gui' function draw() - screen2 = gui.FramedScreen{ - frame_style = gui.GREY_LINE_FRAME, - frame_title = 'dfstatus', - frame_width = 16, - frame_height = 17, - frame_inset = 1, - } + screen2 = gui.FramedScreen{ + frame_style = gui.GREY_LINE_FRAME, + frame_title = 'dfstatus', + frame_width = 16, + frame_height = 17, + frame_inset = 1, + } end if (not shown) then - draw() - screen2:show() - shown = true + draw() + screen2:show() + shown = true else - shown = nil - screen2:dismiss() + shown = nil + screen2:dismiss() end function screen2:onRenderBody(dc) - local drink = 0 - local wood = 0 - --local meat = 0 - --local raw_fish = 0 - --local plants = 0 - local prepared_meals = 0 - - local fuel = 0 - local pigiron = 0 - local iron = 0 - local steel = 0 - - local silver = 0 - local copper = 0 - local gold = 0 - - local tannedhides = 0 - local cloth = 0 + local drink = 0 + local wood = 0 + --local meat = 0 + --local raw_fish = 0 + --local plants = 0 + local prepared_meals = 0 + + local fuel = 0 + local pigiron = 0 + local iron = 0 + local steel = 0 + + local silver = 0 + local copper = 0 + local gold = 0 + + local tannedhides = 0 + local cloth = 0 + + --print("------------------------------") + for _,item in ipairs(df.global.world.items.all) do + if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid) then + if(item:getType() ~= df.item_type.THREAD and item:getType() ~= df.item_type.REMAINS and item:getType() ~= df.item_type.ARMOR and item:getType() ~= df.item_type.SHOES and item:getType() ~= df.item_type.SHIELD and item:getType() ~= df.item_type.HELM and item:getType() ~= df.item_type.GOVES) then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end + if(item:getType() == df.item_type.DRINK)then + --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) + end - --print("------------------------------") - for _,item in ipairs(df.global.world.items.all) do - if(not item.flags.rotten and not item.flags.dump and not item.flags.forbid) then - if(item:getType() ~= df.item_type.THREAD and item:getType() ~= df.item_type.REMAINS and item:getType() ~= df.item_type.ARMOR and item:getType() ~= df.item_type.SHOES and item:getType() ~= df.item_type.SHIELD and item:getType() ~= df.item_type.HELM and item:getType() ~= df.item_type.GOVES) then - --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) - end - if(item:getType() == df.item_type.DRINK)then - --print(item:getType() .. ":" .. dfhack.items.getDescription(item,0)) - end - - if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize() - elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize() - elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize() - elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize() - --elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize() - --elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize() - --elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize() - elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize() - elseif (item:getType() == df.item_type.BAR) then - for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do - if (token == "silver") then silver = silver + item:getStackSize() - elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() - elseif (token == "iron") then iron = iron + item:getStackSize() - elseif (token == "pig") then pigiron = pigiron + item:getStackSize() - elseif (token == "copper") then copper = copper + item:getStackSize() - elseif (token == "gold") then gold = gold + item:getStackSize() - elseif (token == "steel") then steel = steel + item:getStackSize() - end - break -- only need to look at the 1st token of each item. - end + if (item:getType() == df.item_type.WOOD) then wood = wood + item:getStackSize() + elseif (item:getType() == df.item_type.DRINK) then drink = drink + item:getStackSize() + elseif (item:getType() == df.item_type.SKIN_TANNED) then tannedhides = tannedhides + item:getStackSize() + elseif (item:getType() == df.item_type.CLOTH) then cloth = cloth + item:getStackSize() + --elseif (item:getType() == df.item_type.MEAT) then meat = meat + item:getStackSize() + --elseif (item:getType() == df.item_type.FISH_RAW) then raw_fish = raw_fish + item:getStackSize() + --elseif (item:getType() == df.item_type.PLANT) then plants = plants + item:getStackSize() + elseif (item:getType() == df.item_type.FOOD) then prepared_meals = prepared_meals + item:getStackSize() + elseif (item:getType() == df.item_type.BAR) then + for token in string.gmatch(dfhack.items.getDescription(item,0),"[^%s]+") do + if (token == "silver") then silver = silver + item:getStackSize() + elseif (token == "charcoal" or token == "coke") then fuel = fuel + item:getStackSize() + elseif (token == "iron") then iron = iron + item:getStackSize() + elseif (token == "pig") then pigiron = pigiron + item:getStackSize() + elseif (token == "copper") then copper = copper + item:getStackSize() + elseif (token == "gold") then gold = gold + item:getStackSize() + elseif (token == "steel") then steel = steel + item:getStackSize() end + break -- only need to look at the 1st token of each item. + end end + end end - --print("------------------------------") - dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) - dc:newline(0) - dc:newline(0) - dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) - dc:newline(0) - dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) - dc:newline(0) - -- dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) - -- dc:newline(0) - -- dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) - -- dc:newline(0) - dc:newline(0) - dc:string("Bars:", COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) - dc:newline(1) - dc:newline(1) - dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) - dc:newline(1) - dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) + --print("------------------------------") + dc:string("Drinks: ".. drink, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Meals: ".. prepared_meals, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Wood: ".. wood, COLOR_LIGHTGREEN) + dc:newline(0) + dc:newline(0) + dc:string("Hides: ".. tannedhides, COLOR_LIGHTGREEN) + dc:newline(0) + dc:string("Cloth: ".. cloth, COLOR_LIGHTGREEN) + dc:newline(0) + -- dc:string("Raw Fish: ".. raw_fish, COLOR_LIGHTGREEN) + -- dc:newline(0) + -- dc:string("Plants: ".. plants, COLOR_LIGHTGREEN) + -- dc:newline(0) + dc:newline(0) + dc:string("Bars:", COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Fuel: ".. fuel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Pig Iron: ".. pigiron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Steel: ".. steel, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Iron: ".. iron, COLOR_LIGHTGREEN) + dc:newline(1) + dc:newline(1) + dc:string("Copper: ".. copper, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Silver: ".. silver, COLOR_LIGHTGREEN) + dc:newline(1) + dc:string("Gold: ".. gold, COLOR_LIGHTGREEN) end function screen2:onInput(keys) - if keys.LEAVESCREEN or keys.SELECT then - shown = nil - self:dismiss() - end + if keys.LEAVESCREEN or keys.SELECT then + shown = nil + self:dismiss() + end end From ac4ff7672728e03bcb381461115aeccd10b03485 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 12 May 2014 21:55:49 +0400 Subject: [PATCH 6/6] Add to NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index db889b4ae..28b5bcff1 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ DFHack future - gui/clone-uniform: duplicates the currently selected uniform in the military screen. - fix/build-location: partial work-around for bug 5991 (trying to build wall while standing on it) - undump-buildings: removes dump designation from materials used in buildings. + - dfstatus: show an overview of critical stock quantities, including food, drinks, wood, and bars. New commands: - move the 'grow', 'extirpate' and 'immolate' commands as 'plant' subcommands