diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cf8e4b25..d251b78e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,13 @@ # main project file. use it from a build sub-folder, see COMPILE for details -## setting the build type. -IF(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") - SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo.") -ENDIF() +# Set up build types +if(CMAKE_CONFIGURATION_TYPES) + SET(CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo" CACHE STRING "Semicolon-separate list of supported configuration types" FORCE) +else(CMAKE_CONFIGURATION_TYPES) + if (NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release RelWithDebInfo.") + endif (NOT CMAKE_BUILD_TYPE) +endif(CMAKE_CONFIGURATION_TYPES) ## some generic CMake magic cmake_minimum_required(VERSION 2.8 FATAL_ERROR) diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index c0b5b8412..e2f3a8893 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -88,9 +88,6 @@ namespace DFHack return a.type != b.type || a.subtype != b.subtype; } -class Context; -class DFContextShared; - /** * Type for holding an item read from DF * \ingroup grp_items diff --git a/plugins/devel/CMakeLists.txt b/plugins/devel/CMakeLists.txt index 31c31a224..49fefd253 100644 --- a/plugins/devel/CMakeLists.txt +++ b/plugins/devel/CMakeLists.txt @@ -7,5 +7,6 @@ DFHACK_PLUGIN(rawdump rawdump.cpp) DFHACK_PLUGIN(itemhacks itemhacks.cpp) DFHACK_PLUGIN(notes notes.cpp) DFHACK_PLUGIN(memview memview.cpp) +DFHACK_PLUGIN(catsplosion catsplosion.cpp) DFHACK_PLUGIN(buildprobe buildprobe.cpp) #DFHACK_PLUGIN(tiles tiles.cpp) diff --git a/plugins/devel/catsplosion.cpp b/plugins/devel/catsplosion.cpp new file mode 100644 index 000000000..1649ea562 --- /dev/null +++ b/plugins/devel/catsplosion.cpp @@ -0,0 +1,131 @@ +// Catsplosion +// By Zhentar , Further modified by dark_rabite, peterix, belal +// This work of evil makes animals pregnant +// and due within 2 in-game hours... + +#include +#include +#include +#include +#include // for rand() +#include // for std::transform +#include +#include +#include +using namespace std; + +#include "DFHack.h" +#include "Core.h" +#include "Console.h" +#include "Export.h" +#include "PluginManager.h" +#include "DataDefs.h" +#include +#include + +using namespace DFHack; +using namespace DFHack::Simple; + +command_result catsplosion (Core * c, std::vector & parameters); + +DFhackCExport const char * plugin_name ( void ) +{ + return "catsplosion"; +} + +// Mandatory init function. If you have some global state, create it here. +DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) +{ + // Fill the command list with your commands. + commands.clear(); + commands.push_back(PluginCommand( + "catsplosion", "Do nothing, look pretty.", + catsplosion, false, + " This command does nothing at all. For now.\n" + )); + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( Core * c ) +{ + return CR_OK; +} + +command_result catsplosion (Core * c, std::vector & parameters) +{ + list s_creatures; + // only cats for now. + s_creatures.push_back("CAT"); + // make the creature list unique ... with cats. they are always unique + s_creatures.unique(); + // SUSPEND THE CORE! ::Evil laugh:: + CoreSuspender susp(c); + + uint32_t numCreatures; + if(!(numCreatures = Units::getNumCreatures())) + { + cerr << "Can't get any creatures." << endl; + return CR_FAILURE; + } + + int totalcount=0; + int totalchanged=0; + string sextype; + + // shows all the creatures and returns. + + int maxlength = 0; + map > male_counts; + map > female_counts; + + // classify + for(uint32_t i =0;i < numCreatures;i++) + { + df::unit * creature = Units::GetCreature(i); + df::creature_raw *raw = df::global::world->raws.creatures.all[creature->race]; + if(creature->sex == 0) // female + { + female_counts[raw->creature_id].push_back(creature); + male_counts[raw->creature_id].size(); + } + else // male, other, etc. + { + male_counts[raw->creature_id].push_back(creature); + female_counts[raw->creature_id].size(); //auto initialize the females as well + } + } + + // print (optional) + //if (showcreatures == 1) + { + c->con.print("Type Male # Female #\n"); + for(auto it1 = male_counts.begin();it1!=male_counts.end();it1++) + { + c->con.print("%20s %6d %8d\n", it1->first.c_str(), it1->second.size(), female_counts[it1->first].size()); + } + } + + /* + // process + for (list::iterator it = s_creatures.begin(); it != s_creatures.end(); ++it) + { + std::string clinput = *it; + std::transform(clinput.begin(), clinput.end(), clinput.begin(), ::toupper); + vector &females = female_counts[clinput]; + uint32_t sz_fem = females.size(); + totalcount += sz_fem; + for(uint32_t i = 0; i < sz_fem && totalchanged != maxpreg; i++) + { + t_creature & female = females[i]; + uint32_t preg_timer = proc->readDWord(female.origin + creature_pregnancy_offset); + if(preg_timer != 0) + { + proc->writeDWord(female.origin + creature_pregnancy_offset, rand() % 100 + 1); + totalchanged++; + } + } + } + */ + cout << totalchanged << " pregnancies accelerated. Total creatures checked: " << totalcount << "." << endl; + return CR_OK; +} diff --git a/tools/playground/catsplosion.cpp b/tools/playground/catsplosion.cpp deleted file mode 100644 index c3c0126d2..000000000 --- a/tools/playground/catsplosion.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Catsplosion -// By Zhentar , Further modified by dark_rabite, peterix, belal -// This work of evil makes animals pregnant -// and due within 2 in-game hours... - -#include -#include -#include -#include -#include // for rand() -#include // for std::transform -#include -#include -#include -using namespace std; - -#include -#include - -using namespace DFHack; - -int main ( int argc, char** argv ) -{ - DFHack::VersionInfo *mem; - DFHack::Process *proc; - uint32_t creature_pregnancy_offset; - - //bool femaleonly = 0; - bool showcreatures = 0; - int maxpreg = 1000; // random start value, since its not required and im not sure how to set it to infinity - list s_creatures; - - // parse input, handle this nice and neat before we get to the connecting - argstream as(argc,argv); - as // >>option('f',"female",femaleonly,"Impregnate females only") - >>option('s',"show",showcreatures,"Show creature list (read only)") - >>parameter('m',"max",maxpreg,"The maximum limit of pregnancies ", false) - >>values(back_inserter(s_creatures), "any number of creatures") - >>help(); - - // make the creature list unique - s_creatures.unique(); - - if (!as.isOk()) - { - cout << as.errorLog(); - return(0); - } - else if (as.helpRequested()) - { - cout<Attach(); - } - catch (exception& e) - { - cerr << e.what() << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - proc = DF->getProcess(); - mem = DF->getMemoryInfo(); - DFHack::Materials *Mats = DF->getMaterials(); - DFHack::Creatures *Cre = DF->getCreatures(); - creature_pregnancy_offset = mem->getOffset("creature_pregnancy"); - - if(!Mats->ReadCreatureTypesEx()) - { - cerr << "Can't get the creature types." << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - uint32_t numCreatures; - if(!Cre->Start(numCreatures)) - { - cerr << "Can't get creatures" << endl; - #ifndef LINUX_BUILD - cin.ignore(); - #endif - return 1; - } - - int totalcount=0; - int totalchanged=0; - string sextype; - - // shows all the creatures and returns. - - int maxlength = 0; - map > male_counts; - map > female_counts; - - // classify - for(uint32_t i =0;i < numCreatures;i++) - { - DFHack::t_creature creature; - Cre->ReadCreature(i,creature); - DFHack::t_creaturetype & crt = Mats->raceEx[creature.race]; - string castename = crt.castes[creature.sex].rawname; - if(castename == "FEMALE") - { - female_counts[Mats->raceEx[creature.race].rawname].push_back(creature); - male_counts[Mats->raceEx[creature.race].rawname].size(); - } - else // male, other, etc. - { - male_counts[Mats->raceEx[creature.race].rawname].push_back(creature); - female_counts[Mats->raceEx[creature.race].rawname].size(); //auto initialize the females as well - } - } - - // print (optional) - if (showcreatures == 1) - { - cout << "Type\t\tMale #\tFemale #" << endl; - for(map >::iterator it1 = male_counts.begin();it1!=male_counts.end();it1++) - { - cout << it1->first << "\t\t" << it1->second.size() << "\t" << female_counts[it1->first].size() << endl; - } - } - - // process - for (list::iterator it = s_creatures.begin(); it != s_creatures.end(); ++it) - { - std::string clinput = *it; - std::transform(clinput.begin(), clinput.end(), clinput.begin(), ::toupper); - vector &females = female_counts[clinput]; - uint32_t sz_fem = females.size(); - totalcount += sz_fem; - for(uint32_t i = 0; i < sz_fem && totalchanged != maxpreg; i++) - { - t_creature & female = females[i]; - uint32_t preg_timer = proc->readDWord(female.origin + creature_pregnancy_offset); - if(preg_timer != 0) - { - proc->writeDWord(female.origin + creature_pregnancy_offset, rand() % 100 + 1); - totalchanged++; - } - } - } - - cout << totalchanged << " pregnancies accelerated. Total creatures checked: " << totalcount << "." << endl; - Cre->Finish(); - DF->Detach(); - #ifndef LINUX_BUILD - cout << "Done. Press any key to continue" << endl; - cin.ignore(); - #endif - return 0; -} diff --git a/tools/supported/position.cpp b/tools/supported/position.cpp deleted file mode 100644 index 1bf6cf098..000000000 --- a/tools/supported/position.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// Just show some position data - -#include -#include -#include -#include -using namespace std; - -#include -#include -std::ostream &operator<<(std::ostream &stream, DFHack::t_gamemodes funzies) -{ - const char * gm[]= - { - "Fort", - "Adventurer", - "Legends", - "Menus", - "Arena", - "Arena - Assumed", - "Kittens!", - "Worldgen" - }; - const char * cm[]= - { - "Managing", - "Direct Control", - "Kittens!", - "Menus" - }; - if(funzies.game_mode <= DFHack::GM_MAX && funzies.control_mode <= DFHack::CM_MAX) - stream << "Game mode: " << gm[funzies.game_mode] << ", Control mode: " << cm[funzies.control_mode]; - else - stream << "Game mode is too funky: (" << funzies.game_mode << "," << funzies.control_mode << ")"; - return stream; -} - -int main (int argc, char** argv) -{ - bool temporary_terminal = TemporaryTerminal(); - bool quiet = false; - for(int i = 1; i < argc; i++) - { - string test = argv[i]; - if(test == "-q") - { - quiet = true; - } - } - - DFHack::Gui * Gui = 0; - DFHack::Maps * Maps = 0; - DFHack::World * World = 0; - DFHack::ContextManager DFMgr("Memory.xml"); - DFHack::Context * DF; - bool have_maps = false; - try - { - DF = DFMgr.getSingleContext(); - DF->Attach(); - Gui = DF->getGui(); - Maps = DF->getMaps(); - World = DF->getWorld(); - have_maps = Maps->Start(); - } - catch (exception& e) - { - cerr << e.what() << endl; - if(temporary_terminal) - cin.ignore(); - return 1; - } - DFHack::t_gamemodes gmm; - if(World->ReadGameMode(gmm)) - { - cout << gmm << endl; - } - cout << "Year: " << World->ReadCurrentYear() - << " Month: " << World->ReadCurrentMonth() - << " Day: " << World->ReadCurrentDay() - << " Tick: " << World->ReadCurrentTick() << endl; - if (Gui) - { - int32_t vx,vy,vz; - int32_t cx,cy,cz; - int32_t wx,wy,wz; - int32_t width,height; - if(have_maps) - { - Maps->getPosition(wx,wy,wz); - cout << "Map world offset: " << wx << "/" << wy << "/" << wz << " embark squares." << endl; - } - bool have_cursor = Gui->getCursorCoords(cx,cy,cz); - bool have_view = Gui->getViewCoords(vx,vy,vz); - if(have_view) - { - cout << "view coords: " << vx << "/" << vy << "/" << vz << endl; - if(have_maps) - cout << " world: " << vx+wx*48 << "/" << vy+wy*48 << "/" << vz+wz << endl; - } - if(have_cursor) - { - cout << "cursor coords: " << cx << "/" << cy << "/" << cz << endl; - if(have_maps) - cout << " world: " << cx+wx*48 << "/" << cy+wy*48 << "/" << cz+wz << endl; - } - if(Gui->getWindowSize(width,height)) - cout << "window size : " << width << " " << height << endl; - } - else - { - cerr << "cursor and window parameters are unsupported on your version of DF" << endl; - } - - if(!DF->Detach()) - { - cerr << "Can't detach from DF" << endl; - } - - if(!quiet && temporary_terminal) - { - cout << "Done. Press any key to continue" << endl; - cin.ignore(); - } - return 0; -}