From 7c372d49846ffeb56c3d57e78941b2f7667e614a Mon Sep 17 00:00:00 2001 From: PeridexisErrant Date: Tue, 16 Dec 2014 11:23:50 +1100 Subject: [PATCH] remove mostly-obsolete plugins dfbauxtite - simply disable temperature, if the many more magma-safe materials aren't helping. itemdesignator is replaced by enhanced stocks screen, excpet for settings things on fire for which other tools exist. --- needs_porting/dfbauxite.cpp | 161 ------------------------------- needs_porting/itemdesignator.cpp | 148 ---------------------------- 2 files changed, 309 deletions(-) delete mode 100644 needs_porting/dfbauxite.cpp delete mode 100644 needs_porting/itemdesignator.cpp diff --git a/needs_porting/dfbauxite.cpp b/needs_porting/dfbauxite.cpp deleted file mode 100644 index 3a2fdb978..000000000 --- a/needs_porting/dfbauxite.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* -DFBauxite - Converts all your mechanisms to bauxite (for use in magma). -Author: Alex Legg - -Based on code from and uses DFHack - www.sourceforge.net/projects/dfhack -*/ - -#include -#include -#include -#include -#include -#include -#include -using namespace std; - - -#include -#include -#include -#include -#include -#include -#include -using namespace DFHack; - - -int main () -{ - DFHack::Process *proc; - DFHack::memory_info *meminfo; - DFHack::DfVector *items_vector; - DFHack::t_item_df40d item_40d; - DFHack::t_matglossPair item_40d_material; - vector stoneMat; - uint32_t item_material_offset; - uint32_t temp; - int32_t type; - int items; - int found = 0, converted = 0; - - DFHack::ContextManager DF("Memory.xml"); - try - { - DF.Attach(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - // Find out which material is bauxite - if(!DF.ReadStoneMatgloss(stoneMat)) - { - cout << "Materials not supported for this version of DF, exiting." << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - DF.Detach(); - return EXIT_FAILURE; - } - int bauxiteIndex = -1; - for (int i = 0; i < stoneMat.size();i++) - { - if(strcmp(stoneMat[i].id, "BAUXITE") == 0) - { - bauxiteIndex = i; - break; - } - } - if(bauxiteIndex == -1) - { - cout << "Cannot locate bauxite in the DF raws, exiting" << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - DF.Detach(); - return EXIT_FAILURE; - } - - // Get some basics needed for full access - proc = DF.getProcess(); - meminfo = proc->getDescriptor(); - - // Get the object name/ID mapping - //FIXME: work on the 'supported features' system required - - // Check availability of required addresses and offsets (doing custom stuff here) - - items = meminfo->getAddress("items"); - item_material_offset = meminfo->getOffset("item_materials"); - if( !items || ! item_material_offset) - { - cout << "Items not supported for this DF version, exiting" << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - DF.Detach(); - return EXIT_FAILURE; - } - - items_vector = new DFHack::DfVector (proc, items); - for(uint32_t i = 0; i < items_vector->size(); i++) - { - // get pointer to object - temp = items_vector->at (i); - // read object - proc->read (temp, sizeof (DFHack::t_item_df40d), (uint8_t *) &item_40d); - - // resolve object type - type = -1; - - // skip things we can't identify - if(!meminfo->resolveObjectToClassID (temp, type)) - continue; - string classname; - if(!meminfo->resolveClassIDToClassname (type, classname)) - continue; - - if(classname == "item_trapparts") - { - proc->read (temp + item_material_offset, sizeof (DFHack::t_matglossPair), (uint8_t *) &item_40d_material); - - cout << dec << "Mechanism at x:" << item_40d.x << " y:" << item_40d.y << " z:" << item_40d.z << " ID:" << item_40d.ID << endl; - - if (item_40d_material.index != bauxiteIndex) - { - item_40d_material.index = bauxiteIndex; - proc->write (temp + item_material_offset, sizeof (DFHack::t_matglossPair), (uint8_t *) &item_40d_material); - converted++; - } - - found++; - } - } - - - if (found == 0) - { - cout << "No mechanisms to convert" << endl; - } else { - cout << found << " mechanisms found" << endl; - cout << converted << " mechanisms converted" << endl; - } - - DF.Resume(); - DF.Detach(); - - delete items_vector; - -#ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); -#endif - - return 0; -} diff --git a/needs_porting/itemdesignator.cpp b/needs_porting/itemdesignator.cpp deleted file mode 100644 index 63b41eb72..000000000 --- a/needs_porting/itemdesignator.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// Item designator - -#include -#include -#include -#include -#include -using namespace std; - -#include -#include -using namespace DFHack; - -int main () -{ - - DFHack::ContextManager CM ("Memory.xml"); - DFHack::Context * DF; - DFHack::VersionInfo *mem; - DFHack::Gui * Gui; - DFHack::Materials * Mats; - DFHack::Items * Items; - cout << "This utility lets you mass-designate items by type and material." << endl - << "Like set on fire all MICROCLINE item_stone..." << endl - << "Some unusual combinations might be untested and cause the program to crash..."<< endl - << "so, watch your step and backup your fort" << endl; - try - { - DF = CM.getSingleContext(); - DF->Attach(); - mem = DF->getMemoryInfo(); - Gui = DF->getGui(); - Mats = DF->getMaterials(); - Mats->ReadAllMaterials(); - Items = DF->getItems(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - DFHack::Process * p = DF->getProcess(); - DFHack::OffsetGroup* itemGroup = mem->getGroup("Items"); - unsigned vector_addr = itemGroup->getAddress("items_vector"); - DFHack::DfVector p_items (p, vector_addr); - uint32_t numItems = p_items.size(); - - map< string, map > > itemmap; - map< string, map< string, vector< dfh_item > > >::iterator it1; - int failedItems = 0; - map bad_mat_items; - for(uint32_t i=0; i< numItems; i++) - { - DFHack::dfh_item temp; - Items->readItem(p_items[i],temp); - string typestr = Items->getItemClass(temp); - string material = Mats->getDescription(temp.matdesc); - itemmap[typestr][material].push_back(temp); - } - - int i =0; - for( it1 = itemmap.begin(); it1!=itemmap.end();it1++) - { - cout << i << ": " << it1->first << "\n"; - i++; - } - if(i == 0) - { - cout << "No items found" << endl; - DF->Detach(); - return 0; - } - cout << endl << "Select an item type from the list:"; - int number; - string in; - stringstream ss; - getline(cin, in); - ss.str(in); - ss >> number; - int j = 0; - it1 = itemmap.begin(); - while(j < number && it1!=itemmap.end()) - { - it1++; - j++; - } - cout << it1->first << "\n"; - map >::iterator it2; - i=0; - for(it2 = it1->second.begin();it2!=it1->second.end();it2++){ - cout << i << ":\t" << it2->first << " [" << it2->second.size() << "]" << endl; - i++; - } - cout << endl << "Select a material type: "; - int number2; - ss.clear(); - getline(cin, in); - ss.str(in); - ss >> number2; - - decideAgain: - cout << "Select a designation - (d)ump, (f)orbid, (m)melt, set on fi(r)e :" << flush; - string designationType; - getline(cin,designationType); - DFHack::t_itemflags changeFlag = {0}; - if(designationType == "d" || designationType == "dump") - { - changeFlag.dump = 1; - } - else if(designationType == "f" || designationType == "forbid") - { - changeFlag.forbid = 1; - } - else if(designationType == "m" || designationType == "melt") - { - changeFlag.melt = 1; - } - else if(designationType == "r" || designationType == "fire") - { - changeFlag.on_fire = 1; - } - else - { - goto decideAgain; - } - j=0; - it2= it1->second.begin(); - while(j < number2 && it2!=it1->second.end()) - { - it2++; - j++; - } - for(uint32_t k = 0;k< it2->second.size();k++) - { - DFHack::dfh_item & t = it2->second[k]; - t.base.flags.whole |= changeFlag.whole; - Items->writeItem(t); - } - DF->Detach(); -#ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); -#endif - return 0; -}